Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HatsuneMikuFansYSQ
LYAVFoundation
提交
5e43be0d
L
LYAVFoundation
项目概览
HatsuneMikuFansYSQ
/
LYAVFoundation
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
LYAVFoundation
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5e43be0d
编写于
8月 23, 2021
作者:
杨
杨时权
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【需求】支持可动态更新码率。
上级
a6abc3a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
6 deletion
+71
-6
project/iPhone/LWAVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.h
...AVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.h
+2
-2
project/iPhone/LWAVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.m
...AVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.m
+18
-0
project/iPhone/LWAVFoundation/LWAVFoundation/ViewController/CaptureViewController.m
...ion/LWAVFoundation/ViewController/CaptureViewController.m
+51
-4
未找到文件。
project/iPhone/LWAVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.h
浏览文件 @
5e43be0d
...
...
@@ -39,9 +39,9 @@ typedef NS_ENUM(NSUInteger, LWVideoEncodeStatus) {
-
(
LWVideoEncodeStatus
)
reconfig
:(
LWVideoEncoderConfig
*
)
config
;
-
(
LWVideoEncodeStatus
)
setOptionWithInt32
:(
NSString
*
)
key
value
:(
int32_t
)
value
;
-
(
LWVideoEncodeStatus
)
setOptionWithInt32
:(
const
NSString
*
)
key
value
:(
int32_t
)
value
;
-
(
LWVideoEncodeStatus
)
getOptionWithInt32
:(
NSString
*
)
key
value
:(
int32_t
*
)
value
;
-
(
LWVideoEncodeStatus
)
getOptionWithInt32
:(
const
NSString
*
)
key
value
:(
int32_t
*
)
value
;
@end
...
...
project/iPhone/LWAVFoundation/LWAVFoundation/AVFoundation/LWVideoEncoder.m
浏览文件 @
5e43be0d
#import <Foundation/Foundation.h>
#import "LWVideoEncoder.h"
#import "LWVideoOptions.h"
@interface
LWVideoEncoder
()
{
...
...
@@ -59,6 +60,23 @@ void compressSessionOutputCallback(void *opaque,
return
kLWVideoEncodeStatus_Success
;
}
-
(
LWVideoEncodeStatus
)
setOptionWithInt32
:(
const
NSString
*
)
key
value
:(
int32_t
)
value
{
LWVideoEncodeStatus
status
=
kLWVideoEncodeStatus_Success
;
// 动态更新码率
if
([
key
isEqual
:
kLWVideoOptions_Bitrate
])
{
_config
.
bitrate
=
value
;
[
self
setBitrate
:
value
];
NSLog
(
@"%s:%d dynamic bitrate %d"
,
__func__
,
__LINE__
,
value
);
}
else
{
status
=
kLWVideoEncodeStatus_Err_NO_Support
;
}
return
status
;
}
-
(
LWVideoEncodeStatus
)
getOptionWithInt32
:(
const
NSString
*
)
key
value
:(
int32_t
*
)
value
{
return
kLWVideoEncodeStatus_Err_NO_Support
;
}
-
(
void
)
dealloc
{
[
self
destroySession
];
}
...
...
project/iPhone/LWAVFoundation/LWAVFoundation/ViewController/CaptureViewController.m
浏览文件 @
5e43be0d
...
...
@@ -4,11 +4,17 @@
#import "LWCheckBoxView.h"
#import "LWVideoCaptureSession.h"
#import "LWVideoEncoder.h"
#import "LWVideoOptions.h"
@interface
CaptureViewController
()
<
LWVideoCaptureSessionDelegate
,
LWCheckBoxViewDelegate
,
LWVideoEncoderDelegate
>
@interface
CaptureViewController
()
<
LWVideoCaptureSessionDelegate
,
LWCheckBoxViewDelegate
,
LWVideoEncoderDelegate
,
UITextFieldDelegate
>
@property
(
strong
,
nonatomic
)
UIView
*
displayView
;
@property
(
strong
,
nonatomic
)
LWCheckBoxView
*
checkBoxView
;
@property
(
strong
,
nonatomic
)
UILabel
*
captureTypeLabel
;
@property
(
strong
,
nonatomic
)
UILabel
*
encodeBitRateLabel
;
@property
(
strong
,
nonatomic
)
UITextField
*
encodeBitRateField
;
@property
(
strong
,
nonatomic
)
UIButton
*
encodeBitRateSettedBtn
;
@property
(
strong
,
nonatomic
)
UIButton
*
startBtn
;
@property
(
strong
,
nonatomic
)
UIButton
*
stopBtn
;
...
...
@@ -24,10 +30,11 @@
@implementation
CaptureViewController
-
(
void
)
viewDidLoad
{
CGRect
bounds
=
[
UIScreen
mainScreen
].
bounds
;
int
displayViewX
=
0
;
int
displayViewY
=
20
;
int
displayViewW
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
;
int
displayViewH
=
displayViewW
/
16
*
9
;
int
displayViewH
=
displayViewW
/
16
*
12
;
self
.
hatsuneMiKuColor
=
[
UIColor
colorWithRed
:(
0x39
*
1
.
0
/
0xff
)
green
:(
0xc5
*
1
.
0
/
0xff
)
blue
:
(
0xbb
*
1
.
0
/
0xff
)
alpha
:
1
.
0
];
self
.
displayView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
displayViewX
,
displayViewY
,
displayViewW
,
displayViewH
)];
self
.
displayView
.
backgroundColor
=
[
UIColor
blackColor
];
...
...
@@ -52,7 +59,32 @@
self
.
captureTypeLabel
.
textColor
=
[
UIColor
blackColor
];
[
self
.
view
addSubview
:
self
.
captureTypeLabel
];
self
.
startBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
0
,
checkBoxViewY
+
checkBoxViewH
+
10
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
30
)];
int
bitrateLabelX
=
0
;
int
bitrateLabelY
=
checkBoxViewY
+
checkBoxViewH
+
10
;
int
bitrateLabelW
=
60
;
int
bitrateLabelH
=
30
;
int
bitrateBtnW
=
90
;
self
.
encodeBitRateLabel
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
bitrateLabelX
,
bitrateLabelY
,
bitrateLabelW
,
bitrateLabelH
)];
self
.
encodeBitRateLabel
.
text
=
@"码率:"
;
self
.
encodeBitRateLabel
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
encodeBitRateLabel
.
textColor
=
[
UIColor
blackColor
];
[
self
.
view
addSubview
:
self
.
encodeBitRateLabel
];
self
.
encodeBitRateField
=
[[
UITextField
alloc
]
initWithFrame
:
CGRectMake
(
bitrateLabelX
+
bitrateLabelW
,
bitrateLabelY
,
bounds
.
size
.
width
-
bitrateBtnW
-
bitrateLabelX
-
bitrateLabelW
,
30
)];
self
.
encodeBitRateField
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
encodeBitRateField
.
textColor
=
[
UIColor
blackColor
];
self
.
encodeBitRateField
.
text
=
@"2000"
;
self
.
encodeBitRateField
.
delegate
=
self
;
[
self
.
view
addSubview
:
self
.
encodeBitRateField
];
self
.
encodeBitRateSettedBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
bounds
.
size
.
width
-
bitrateBtnW
,
bitrateLabelY
,
bitrateBtnW
,
30
)];
[
self
.
encodeBitRateSettedBtn
setTitle
:
@"设置"
forState
:
UIControlStateNormal
];
[
self
.
encodeBitRateSettedBtn
setBackgroundColor
:[
UIColor
whiteColor
]];
[
self
.
encodeBitRateSettedBtn
setTitleColor
:[
UIColor
blackColor
]
forState
:
UIControlStateNormal
];
[
self
.
encodeBitRateSettedBtn
addTarget
:
self
action
:
@selector
(
setBitrateSender
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
self
.
encodeBitRateSettedBtn
];
self
.
startBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
0
,
bitrateLabelY
+
bitrateLabelH
+
10
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
30
)];
// self.startBtn.enabled = YES;
[
self
.
startBtn
setTitle
:
@"start"
forState
:
UIControlStateNormal
];
[
self
.
startBtn
setTitleColor
:[
UIColor
blackColor
]
forState
:
UIControlStateNormal
];
...
...
@@ -64,7 +96,7 @@
[
self
.
startBtn
.
layer
setBorderColor
:[
UIColor
blackColor
].
CGColor
];
[
self
.
view
addSubview
:
self
.
startBtn
];
self
.
stopBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
([
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
checkBoxViewY
+
checkBoxView
H
+
10
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
30
)];
self
.
stopBtn
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
([
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
bitrateLabelY
+
bitrateLabel
H
+
10
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
/
2
,
30
)];
// self.startBtn.enabled = YES;
[
self
.
stopBtn
setTitle
:
@"stop"
forState
:
UIControlStateNormal
];
[
self
.
stopBtn
setTitleColor
:[
UIColor
blackColor
]
forState
:
UIControlStateNormal
];
...
...
@@ -114,6 +146,16 @@
self
.
encoder
=
nil
;
}
-
(
IBAction
)
setBitrateSender
:(
id
)
sender
{
NSString
*
bitStr
=
self
.
encodeBitRateField
.
text
;
int
bitrate
=
[
bitStr
intValue
];
if
(
self
.
encoder
)
{
[
self
.
encoder
setOptionWithInt32
:
kLWVideoOptions_Bitrate
value
:
bitrate
];
}
else
{
self
.
encoderConfig
.
bitrate
=
bitrate
;
}
}
#pragma mark LWVideoCaptureSessionDelegate
-
(
void
)
onVideoWithSampleBuffer
:(
CMSampleBufferRef
)
sampleBuffer
{
if
(
self
.
encoder
)
{
...
...
@@ -137,4 +179,9 @@
sampleBuffer
:(
CMSampleBufferRef
)
sampleBuffer
{
}
#pragma mark UITextFieldDelegate
-
(
BOOL
)
textFieldShouldReturn
:(
UITextField
*
)
textField
{
return
[
self
.
encodeBitRateField
resignFirstResponder
];
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录