diff --git a/APIDiffs/api-diffs-1.6.1.md b/APIDiffs/api-diffs-1.6.1.md new file mode 100644 index 0000000..e60dfb1 --- /dev/null +++ b/APIDiffs/api-diffs-1.6.1.md @@ -0,0 +1,5 @@ +# PLCameraStreamingKit 1.6.0 to 1.6.1 API Differences + +## General Headers + +None \ No newline at end of file diff --git a/Example/PLCameraStreamingKit/Base.lproj/Main_iPhone.storyboard b/Example/PLCameraStreamingKit/Base.lproj/Main_iPhone.storyboard index ac06cfe..2562157 100644 --- a/Example/PLCameraStreamingKit/Base.lproj/Main_iPhone.storyboard +++ b/Example/PLCameraStreamingKit/Base.lproj/Main_iPhone.storyboard @@ -133,6 +133,20 @@ + + + + + + + + + + + + + + @@ -148,6 +162,8 @@ + + @@ -155,6 +171,7 @@ + diff --git a/Example/PLCameraStreamingKit/PLCameraStreamingViewController.h b/Example/PLCameraStreamingKit/PLCameraStreamingViewController.h index be75474..fdef47c 100644 --- a/Example/PLCameraStreamingKit/PLCameraStreamingViewController.h +++ b/Example/PLCameraStreamingKit/PLCameraStreamingViewController.h @@ -15,5 +15,8 @@ @property (weak, nonatomic) IBOutlet UIButton *torchButton; @property (weak, nonatomic) IBOutlet UIButton *muteButton; @property (weak, nonatomic) IBOutlet UITextView *textView; +@property (weak, nonatomic) IBOutlet UISegmentedControl *segementedControl; + +- (IBAction)segmentedControlValueDidChange:(id)sender; @end diff --git a/Example/PLCameraStreamingKit/PLCameraStreamingViewController.m b/Example/PLCameraStreamingKit/PLCameraStreamingViewController.m index f59e8e0..9bb687d 100644 --- a/Example/PLCameraStreamingKit/PLCameraStreamingViewController.m +++ b/Example/PLCameraStreamingKit/PLCameraStreamingViewController.m @@ -26,6 +26,8 @@ "Reachable via CELL" }; +#define kReloadConfigurationEnable 0 + // 假设在 videoFPS 低于预期 50% 的情况下就触发降低推流质量的操作,这里的 40% 是一个假定数值,你可以更改数值来尝试不同的策略 #define kMaxVideoFPSPercent 0.5 @@ -85,9 +87,9 @@ - (void)viewDidLoad { // 预先设定几组编码质量,之后可以切换 CGSize videoSize = CGSizeMake(320, 480); self.videoConfigurations = @[ - [PLVideoStreamingConfiguration configurationWithVideoSize:videoSize videoQuality:kPLVideoStreamingQualityMedium1], - [PLVideoStreamingConfiguration configurationWithVideoSize:videoSize videoQuality:kPLVideoStreamingQualityMedium2], - [PLVideoStreamingConfiguration configurationWithVideoSize:videoSize videoQuality:kPLVideoStreamingQualityMedium3], + [[PLVideoStreamingConfiguration alloc] initWithVideoSize:videoSize videoFrameRate:15 videoMaxKeyframeInterval:45 videoBitrate:800 * 1000 videoProfileLevel:AVVideoProfileLevelH264Baseline31], + [[PLVideoStreamingConfiguration alloc] initWithVideoSize:videoSize videoFrameRate:24 videoMaxKeyframeInterval:72 videoBitrate:800 * 1000 videoProfileLevel:AVVideoProfileLevelH264Baseline31], + [[PLVideoStreamingConfiguration alloc] initWithVideoSize:videoSize videoFrameRate:30 videoMaxKeyframeInterval:90 videoBitrate:800 * 1000 videoProfileLevel:AVVideoProfileLevelH264Baseline31], ]; self.sessionQueue = dispatch_queue_create("pili.queue.streaming", DISPATCH_QUEUE_SERIAL); @@ -227,6 +229,7 @@ - (void)cameraStreamingSession:(PLCameraStreamingSession *)session streamStatusD NSLog(@"%@", status); self.textView.text = LogString(); +#if kReloadConfigurationEnable NSDate *now = [NSDate date]; if (!self.keyTime) { self.keyTime = now; @@ -246,6 +249,7 @@ - (void)cameraStreamingSession:(PLCameraStreamingSession *)session streamStatusD [self higherQuality]; } } +#endif // #if kReloadConfigurationEnable } #pragma mark - @@ -295,6 +299,11 @@ - (void)startSession { #pragma mark - Action +- (IBAction)segmentedControlValueDidChange:(id)sender { + PLVideoStreamingConfiguration *config = self.videoConfigurations[self.segementedControl.selectedSegmentIndex]; + [self.session reloadVideoConfiguration:config]; +} + - (IBAction)actionButtonPressed:(id)sender { if (PLStreamStateConnected == self.session.streamState) { [self stopSession]; diff --git a/Example/Podfile.lock b/Example/Podfile.lock index b44684c..7cac5ce 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,11 +1,11 @@ PODS: - HappyDNS (0.2.3) - - PLCameraStreamingKit (1.6.0): - - PLStreamingKit (~> 1.1.2) - - PLStreamingKit (1.1.2): + - PLCameraStreamingKit (1.6.1): + - PLStreamingKit (~> 1.1.3) + - PLStreamingKit (1.1.3): - HappyDNS - - PLStreamingKit/precompiled (= 1.1.2) - - PLStreamingKit/precompiled (1.1.2): + - PLStreamingKit/precompiled (= 1.1.3) + - PLStreamingKit/precompiled (1.1.3): - HappyDNS DEPENDENCIES: @@ -17,7 +17,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: HappyDNS: 6d85942e64c28b4fa61f8c76580398f52d6d1d11 - PLCameraStreamingKit: 3ca6897d972fa8913165f8be1d6246ae73a32c4a - PLStreamingKit: 0031931293c5acbe5874515f13f8451a33186755 + PLCameraStreamingKit: df7c55ad9527dc83bff75ae077aa9a9afec996c6 + PLStreamingKit: 4ce7abd3688c4e6767b4ac83a813bd785a2c1748 COCOAPODS: 0.39.0 diff --git a/Example/Pods/Local Podspecs/PLCameraStreamingKit.podspec.json b/Example/Pods/Local Podspecs/PLCameraStreamingKit.podspec.json index c42fa3b..9cd500a 100644 --- a/Example/Pods/Local Podspecs/PLCameraStreamingKit.podspec.json +++ b/Example/Pods/Local Podspecs/PLCameraStreamingKit.podspec.json @@ -1,6 +1,6 @@ { "name": "PLCameraStreamingKit", - "version": "1.6.0", + "version": "1.6.1", "summary": "Pili iOS camera streaming framework via RTMP.", "homepage": "https://github.com/pili-engineering/PLCameraStreamingKit", "license": "Apache License, Version 2.0", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/pili-engineering/PLCameraStreamingKit.git", - "tag": "v1.6.0" + "tag": "v1.6.1" }, "platforms": { "ios": "7.0" @@ -22,7 +22,7 @@ ], "dependencies": { "PLStreamingKit": [ - "~> 1.1.2" + "~> 1.1.3" ] }, "frameworks": [ diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index b44684c..7cac5ce 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,11 +1,11 @@ PODS: - HappyDNS (0.2.3) - - PLCameraStreamingKit (1.6.0): - - PLStreamingKit (~> 1.1.2) - - PLStreamingKit (1.1.2): + - PLCameraStreamingKit (1.6.1): + - PLStreamingKit (~> 1.1.3) + - PLStreamingKit (1.1.3): - HappyDNS - - PLStreamingKit/precompiled (= 1.1.2) - - PLStreamingKit/precompiled (1.1.2): + - PLStreamingKit/precompiled (= 1.1.3) + - PLStreamingKit/precompiled (1.1.3): - HappyDNS DEPENDENCIES: @@ -17,7 +17,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: HappyDNS: 6d85942e64c28b4fa61f8c76580398f52d6d1d11 - PLCameraStreamingKit: 3ca6897d972fa8913165f8be1d6246ae73a32c4a - PLStreamingKit: 0031931293c5acbe5874515f13f8451a33186755 + PLCameraStreamingKit: df7c55ad9527dc83bff75ae077aa9a9afec996c6 + PLStreamingKit: 4ce7abd3688c4e6767b4ac83a813bd785a2c1748 COCOAPODS: 0.39.0 diff --git a/Example/Pods/PLStreamingKit/Pod/Library/lib/libPLStreamingKit.a b/Example/Pods/PLStreamingKit/Pod/Library/lib/libPLStreamingKit.a index 6187f0e..c77197a 100644 Binary files a/Example/Pods/PLStreamingKit/Pod/Library/lib/libPLStreamingKit.a and b/Example/Pods/PLStreamingKit/Pod/Library/lib/libPLStreamingKit.a differ diff --git a/Example/Pods/PLStreamingKit/README.md b/Example/Pods/PLStreamingKit/README.md index be0f2c0..94ae188 100644 --- a/Example/Pods/PLStreamingKit/README.md +++ b/Example/Pods/PLStreamingKit/README.md @@ -342,6 +342,8 @@ PLStreamingKit 使用 HeaderDoc 注释来做文档支持。 ## 版本历史 +- 1.1.3 ([Release Notes](https://github.com/pili-engineering/PLStreamingKit/blob/master/ReleaseNotes/release-notes-1.1.3.md) && [API Diffs](https://github.com/pili-engineering/PLStreamingKit/blob/master/APIDiffs/api-diffs-1.1.3.md)) + - 优化网络发包,合并多个小包一起发送,提升带宽利用率 - 1.1.2 ([Release Notes](https://github.com/pili-engineering/PLStreamingKit/blob/master/ReleaseNotes/release-notes-1.1.2.md) && [API Diffs](https://github.com/pili-engineering/PLStreamingKit/blob/master/APIDiffs/api-diffs-1.1.2.md)) - 修复 dynamic 推流 nounce 取值过小,导致安卓端推流后,同一个流在 iOS 端推流会失败的问题 - 1.1.1 ([Release Notes](https://github.com/pili-engineering/PLStreamingKit/blob/master/ReleaseNotes/release-notes-1.1.1.md) && [API Diffs](https://github.com/pili-engineering/PLStreamingKit/blob/master/APIDiffs/api-diffs-1.1.1.md)) diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PLCameraStreamingKit.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PLCameraStreamingKit.xcscheme index cd3f53b..96f1fde 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PLCameraStreamingKit.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PLCameraStreamingKit.xcscheme @@ -14,7 +14,7 @@ buildForArchiving = "YES"> diff --git a/PLCameraStreamingKit.podspec b/PLCameraStreamingKit.podspec index f5c2c0c..f39467b 100644 --- a/PLCameraStreamingKit.podspec +++ b/PLCameraStreamingKit.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.name = "PLCameraStreamingKit" - s.version = "1.6.0" + s.version = "1.6.1" s.summary = "Pili iOS camera streaming framework via RTMP." s.homepage = "https://github.com/pili-engineering/PLCameraStreamingKit" s.license = 'Apache License, Version 2.0' @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.public_header_files = 'Pod/Classes/*.h' s.source_files = 'Pod/Classes/*.h', 'Pod/Classes/*.m' - s.dependency 'PLStreamingKit', '~> 1.1.2' + s.dependency 'PLStreamingKit', '~> 1.1.3' s.frameworks = ['UIKit', 'AVFoundation', 'CoreGraphics', 'CFNetwork', 'AudioToolbox', 'CoreMedia', 'VideoToolbox'] s.libraries = 'z', 'c++' diff --git a/Pod/Classes/PLCameraSource.h b/Pod/Classes/PLCameraSource.h index f69fea5..2f67d0e 100644 --- a/Pod/Classes/PLCameraSource.h +++ b/Pod/Classes/PLCameraSource.h @@ -40,7 +40,7 @@ PLSourceAccessProtocol @property (nonatomic, PL_WEAK) id delegate; -@property (nonatomic, PL_WEAK) PLVideoStreamingConfiguration *videoConfiguration; +@property (nonatomic, copy) PLVideoStreamingConfiguration *videoConfiguration; @property (nonatomic, readwrite, assign) PLCaptureDevicePosition cameraPosition; @property (nonatomic, readwrite, assign, getter=isTorchOn) BOOL torchOn; @property (nonatomic, readonly, PL_WEAK) AVCaptureVideoPreviewLayer *previewLayer; @@ -62,6 +62,6 @@ PLSourceAccessProtocol - (void)startRunning; - (void)stopRunning; -- (void)reloadVideoConfiguration; +- (void)reloadVideoConfiguration:(PLVideoStreamingConfiguration *)videoConfiguration; @end \ No newline at end of file diff --git a/Pod/Classes/PLCameraSource.m b/Pod/Classes/PLCameraSource.m index 3b13870..5546756 100644 --- a/Pod/Classes/PLCameraSource.m +++ b/Pod/Classes/PLCameraSource.m @@ -75,15 +75,8 @@ - (instancetype)initWithVideoConfiguration:(PLVideoStreamingConfiguration *)conf if ([device hasMediaType:AVMediaTypeVideo]) { if (device.position == position) { self.captureDevice = device; + break; } - - NSError *error; - [device lockForConfiguration:&error]; - if (PL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { - device.activeVideoMinFrameDuration = CMTimeMake(1, self.videoConfiguration.videoFrameRate); - device.activeVideoMaxFrameDuration = CMTimeMake(1, self.videoConfiguration.videoFrameRate); - } - [device unlockForConfiguration]; } } @@ -137,7 +130,7 @@ - (void)refreshFPS { } else { NSUInteger frameRate = self.videoConfiguration.videoFrameRate; AVFrameRateRange *range = [captureDevice.activeFormat.videoSupportedFrameRateRanges firstObject]; - if (frameRate < range.maxFrameRate && frameRate > range.minFrameRate) { + if (frameRate <= range.maxFrameRate && frameRate >= range.minFrameRate) { if ([captureDevice respondsToSelector:@selector(activeVideoMaxFrameDuration)]) { captureDevice.activeVideoMaxFrameDuration = CMTimeMake(1, (int32_t)frameRate); captureDevice.activeVideoMinFrameDuration = CMTimeMake(1, (int32_t)frameRate); @@ -264,20 +257,13 @@ - (void)stopRunning { self.isRunning = NO; } -- (void)reloadVideoConfiguration { - NSArray *devices = [AVCaptureDevice devices]; - for (AVCaptureDevice *device in devices) { - if ([device hasMediaType:AVMediaTypeVideo]) { - - NSError *error; - [device lockForConfiguration:&error]; - if (PL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { - device.activeVideoMinFrameDuration = CMTimeMake(1, self.videoConfiguration.videoFrameRate); - device.activeVideoMaxFrameDuration = CMTimeMake(1, self.videoConfiguration.videoFrameRate); - } - [device unlockForConfiguration]; - } +- (void)reloadVideoConfiguration:(PLVideoStreamingConfiguration *)videoConfiguration { + if ([videoConfiguration isEqual:self.videoConfiguration]) { + return; } + + self.videoConfiguration = videoConfiguration; + [self refreshFPS]; } #pragma mark - Property diff --git a/Pod/Classes/PLCameraStreamingSession.h b/Pod/Classes/PLCameraStreamingSession.h index f66dc73..c750eae 100644 --- a/Pod/Classes/PLCameraStreamingSession.h +++ b/Pod/Classes/PLCameraStreamingSession.h @@ -153,16 +153,19 @@ extern NSString *PLAudioComponentFailedToCreateNotification; @property (nonatomic, PL_WEAK) id bufferDelegate; -/// 最低阈值, [0..1], 不可超出这个范围, 默认为 0.5 -@property (nonatomic, assign) CGFloat lowThreshold; - -/// 最高阈值, [0..1], 不可超出这个范围, 默认为 1 -@property (nonatomic, assign) CGFloat highThreshold; +/// [0..1], 不可超出这个范围, 默认为 0.5 +@property (nonatomic, assign) CGFloat threshold; /// Buffer 最多可包含的包数,默认为 300 @property (nonatomic, assign) NSUInteger maxCount; @property (nonatomic, assign, readonly) NSUInteger currentCount; + +/// 已弃用,最低阈值, [0..1], 不可超出这个范围, 默认为 0.5 +@property (nonatomic, assign) CGFloat lowThreshold DEPRECATED_ATTRIBUTE; +/// 已弃用,最高阈值, [0..1], 不可超出这个范围, 默认为 1 +@property (nonatomic, assign) CGFloat highThreshold DEPRECATED_ATTRIBUTE; + @end #pragma mark - Category (CameraSource) diff --git a/Pod/Classes/PLCameraStreamingSession.m b/Pod/Classes/PLCameraStreamingSession.m index e65421b..3028244 100644 --- a/Pod/Classes/PLCameraStreamingSession.m +++ b/Pod/Classes/PLCameraStreamingSession.m @@ -41,6 +41,7 @@ @interface PLCameraStreamingSession () // Category rewrite @property (nonatomic, PL_WEAK) id bufferDelegate; +@property (nonatomic, assign) CGFloat threshold; @property (nonatomic, assign) CGFloat lowThreshold; @property (nonatomic, assign) CGFloat highThreshold; @property (nonatomic, assign) NSTimeInterval maxDuration; @@ -147,7 +148,9 @@ - (void)reloadVideoConfiguration:(PLVideoStreamingConfiguration *)videoConfigura return; } - self.streamingSession.videoConfiguration = videoConfiguration; + self.videoConfiguration = videoConfiguration; + + [self.cameraSource reloadVideoConfiguration:videoConfiguration]; [self.streamingSession reloadVideoConfiguration:videoConfiguration]; } @@ -338,24 +341,14 @@ - (void)previewViewTaped:(UITapGestureRecognizer *)tap { #pragma mark - Property -- (CGFloat)lowThreshold { - return self.streamingSession.lowThreshold; -} - -- (void)setLowThreshold:(CGFloat)lowThreshold { - [self willChangeValueForKey:@"lowThreshold"]; - self.streamingSession.lowThreshold = lowThreshold; - [self didChangeValueForKey:@"lowThreshold"]; -} - -- (CGFloat)highThreshold { - return self.streamingSession.highThreshold; +- (CGFloat)threshold { + return self.streamingSession.threshold; } -- (void)setHighThreshold:(CGFloat)highThreshold { - [self willChangeValueForKey:@"highThreshold"]; - self.streamingSession.highThreshold = highThreshold; - [self didChangeValueForKey:@"highThreshold"]; +- (void)setThreshold:(CGFloat)threshold { + [self willChangeValueForKey:@"threshold"]; + self.streamingSession.threshold = threshold; + [self didChangeValueForKey:@"threshold"]; } - (NSUInteger)maxCount { diff --git a/README.md b/README.md index d2dd8d5..af5d29a 100644 --- a/README.md +++ b/README.md @@ -146,29 +146,11 @@ if (PLAuthorizationStatusNotDetermined == status) { 移动端因网络环境不稳定及用户电量宝贵等原因,并不建议直接使用最高码率和分辨率来做推流,以最佳编码参数来做设置可以带来更好的推流效果和用户体验。 -你无需辛苦的一个个参数设置,```PLCameraStreamingKit``` 提供了一个编码配置的类来帮你快速完成配置。 +如果你不能确定该如何配置各个编码参数,也不用担心,```PLCameraStreamingKit``` 提供了一个编码配置的类来帮你快速完成配置,你可以通过使用 SDK 预先定义好的 quality 来构建编码推流配置。 ### 视频编码参数 ```Objective-C -// 初始化编码配置类的实例需要的两个参数 - -// 视频横纵比及分辨率 -typedef NS_ENUM(NSUInteger, PLStreamingDimension) { - PLStreamingDimension_16_9__416x234, - PLStreamingDimension_16_9__480x270, - PLStreamingDimension_16_9__640x360, - PLStreamingDimension_16_9__960x540, - PLStreamingDimension_16_9__1280x720, - PLStreamingDimension_4_3__400x300, - PLStreamingDimension_4_3__480x360, - PLStreamingDimension_4_3__640x480, - PLStreamingDimension_4_3__960x720, - PLStreamingDimension_4_3__1280x960, - PLStreamingDimension_UserDefine, - PLStreamingDimension_Default = PLStreamingDimension_4_3__640x480 -}; - // 视频推流质量 /*! * @abstract Video streaming quality low 1 @@ -237,14 +219,14 @@ extern NSString *kPLVideoStreamingQualityHigh3; 需要明确以上两者,便可以直接获取到最佳的视频编码配置。 ```Objective-C -// 默认情况下,PLCameraStreamingKit 会使用 4:3 的 640x480 分辨率,及 kPLVideoStreamingQualityMedium1 作为参数初始化编码配置类的实例. +// 该方法每次都会生成一个新的配置,不是单例方法。默认情况下,对应的参数为分辨率 (320, 480), video quality PLStreamingQualityMedium1 PLVideoStreamingConfiguration *videoConfiguration = [PLVideoStreamingConfiguration defaultConfiguration]; -// 当然你也可以自己指定,比如你希望输出直播视频是 16:9 的 960x540 的分辨率,并且你已经明确你需要的视频质量为 High1,你可以这样来设置编码配置 -PLVideoStreamingConfiguration *videoConfiguration = [PLVideoStreamingConfiguration configurationWithDimension:PLStreamingDimension_16_9__960x540 videoQuality:kPLVideoStreamingQualityHigh1]; +// 你也可以指定自己想要的分辨率和已有的 video quality 参数 +PLVideoStreamingConfiguration *videoConfiguration = [PLVideoStreamingConfiguration configurationWithVideoSize:CGSizeMake(320, 480) videoQuality:kPLVideoStreamingQualityHigh1]; -// 当已有的分辨率无法满足你的需求时,你可以自己定义视频的大小 -PLVideoStreamingConfiguration *videoConfiguration = [PLVideoStreamingConfiguration configurationWithUserDefineDimension:CGSizeMake(width, height) videoQuality:kPLVideoStreamingQualityHigh1]; +// 当已有的分辨率无法满足你的需求时,你可以自己定义所有参数,但请务必确保你清楚参数的含义 +PLVideoStreamingConfiguration *videoConfiguration = [[PLVideoStreamingConfiguration alloc] initWithVideoSize:CGSizeMake(width, height) videoFrameRate:30 videoMaxKeyframeInterval:90 videoBitrate:1200 * 1000 videoProfileLevel:AVVideoProfileLevelH264Main32]]; ``` ### Video Quality 具体参数 @@ -307,14 +289,18 @@ PLAudioStreamingConfiguration *audioConfiguration = [PLAudioStreamingConfigurati - (void)cameraStreamingSession:(PLCameraStreamingSession *)session streamStateDidChange:(PLStreamState)state { // 当流状态变更为非 Error 时,会回调到这里 } - ``` ```Objective-C - (void)cameraStreamingSession:(PLCameraStreamingSession *)session didDisconnectWithError:(NSError *)error { // 当流状态变为 Error, 会携带 NSError 对象回调这个方法 } +``` +```Objective-C +- (void)streamingSession:(PLStreamingSession *)session streamStatusDidUpdate:(PLStreamStatus *)status { + // 当开始推流时,会每间隔 3s 调用该回调方法来反馈该 3s 内的流状态,包括视频帧率、音频帧率、音视频总码率 +} ``` ## 变更推流质量及策略 @@ -327,12 +313,8 @@ PLAudioStreamingConfiguration *audioConfiguration = [PLAudioStreamingConfigurati // BufferDelegate @protocol PLStreamingSendingBufferDelegate -- (void)streamingSessionSendingBufferFillDidLowerThanLowThreshold:(id)session; -- (void)streamingSessionSendingBufferFillDidHigherThanHighThreshold:(id)session; - (void)streamingSessionSendingBufferDidEmpty:(id)session; - (void)streamingSessionSendingBufferDidFull:(id)session; -- (void)streamingSession:(id)session sendingBufferDidDropItems:(NSArray *)items; -- (void)streamingSession:(id)session sendingBufferCurrentDurationDidChange:(NSTimeInterval)currentDuration; @end @@ -341,11 +323,8 @@ PLAudioStreamingConfiguration *audioConfiguration = [PLAudioStreamingConfigurati @property (nonatomic, PL_WEAK) id bufferDelegate; -/// 最低阈值, [0..1], 不可超出这个范围, 默认为 0.5 -@property (nonatomic, assign) CGFloat lowThreshold; - -/// 最高阈值, [0..1], 不可超出这个范围, 默认为 1 -@property (nonatomic, assign) CGFloat highThreshold; +/// [0..1], 不可超出这个范围, 默认为 0.5 +@property (nonatomic, assign) CGFloat threshold; /// Buffer 最多可包含的包数,默认为 300 @property (nonatomic, assign) NSUInteger maxCount; @@ -354,7 +333,7 @@ PLAudioStreamingConfiguration *audioConfiguration = [PLAudioStreamingConfigurati @end ``` -buffer 是一个可以缓存待发送内容的队列,它按照时间(秒)作为缓存长度的判定,可以通过 maxDuration 来读取和设定,buffer 的下阈值和上阈值设定体现你期望的变更推流质量的策略,默认下阈值为 buffer 的 20%(0.2),上阈值为 0.8。 +buffer 是一个可以缓存待发送内容的队列,它按照帧数作为缓存长度的判定,可以通过 maxCount 来读取和设定,buffer 的阈值设定体现你期望的变更推流质量的策略,默认阈值为 buffer 的 50%(0.5)。 当 buffer 变为空时,会回调 @@ -364,29 +343,10 @@ buffer 是一个可以缓存待发送内容的队列,它按照时间(秒)作 `- (void)streamingSessionSendingBufferDidFull:(id)session;` -如果 buffer 已经满了,但是还有数据传入时,会触发丢帧,会调用 - -`- (void)streamingSession:(id)session sendingBufferDidDropItems:(NSArray *)items;` - -buffer 的内容高过上阈值时,会回调 - -`- (void)streamingSessionSendingBufferFillDidHigherThanHighThreshold:(id)session;` - -这是可以尝试降低 quality 的时机 - -内容低于下阈值时,会回调 - -`- (void)streamingSessionSendingBufferFillDidLowerThanLowThreshold:(id)session;` - -这是可以尝试增加 quality 的时机。 - -当了解了可以触发变更 quality 的时机,那么当你需要变更 quality 时,通过下面的方式来做调用 +当你希望在 streamStatus 变化,buffer empty 或者 buffer full 时变化 video configuration,可以调用 session 的 reloadVideoConfiguration: 方法 ```Objective-C -[self.session beginUpdateConfiguration]; -self.session.videoConfiguration.videoQuality = kPLVideoStreamingQualityMedium2; -self.session.audioConfiguration.audioQuality = kPLAudioStreamingQualityHigh1; -[self.session endUpdateConfiguration]; +[self.session reloadVideoConfiguration:newConfiguraiton]; ``` ## 文档支持 @@ -402,6 +362,9 @@ PLCameraStreamingKit 使用 HeaderDoc 注释来做文档支持。 ## 版本历史 +- 1.6.1 ([Release Notes](https://github.com/pili-engineering/PLCameraStreamingKit/blob/master/ReleaseNotes/release-notes-1.6.1.md) && [API Diffs](https://github.com/pili-engineering/PLCameraStreamingKit/blob/master/APIDiffs/api-diffs-1.6.1.md)) + - 更新依赖 PLStreamingKit 的版本到 `v1.1.3` + - 修复调用 `- (void)reloadVideoConfiguraiton` 方法,fps 变更失败的问题 - 1.6.0 ([Release Notes](https://github.com/pili-engineering/PLCameraStreamingKit/blob/master/ReleaseNotes/release-notes-1.6.0.md) && [API Diffs](https://github.com/pili-engineering/PLCameraStreamingKit/blob/master/APIDiffs/api-diffs-1.6.0.md)) - 更新依赖 PLStreamingKit 的版本到 `v1.1.2` - 添加 `PLStreamStatus` 回调,便于客户端监控推流状态 diff --git a/ReleaseNotes/release-notes-1.6.1.md b/ReleaseNotes/release-notes-1.6.1.md new file mode 100644 index 0000000..ee0d122 --- /dev/null +++ b/ReleaseNotes/release-notes-1.6.1.md @@ -0,0 +1,24 @@ +# PLCameraStreamingKit Release Notes for 1.6.1 + +## 内容 + +- [简介](#简介) +- [问题反馈](#问题反馈) +- [记录](#记录) + +## 简介 + +PLCameraStreamingKit 为 iOS 开发者提供直播推流 SDK。 + +## 问题反馈 + +当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 ```issues``` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 ```Labels``` 中指明类型为 bug 或者其他。 + +[通过这里查看已有的 issues 和提交 Bug](https://github.com/pili-engineering/PLCameraStreamingKit/issues) + +## 记录 + +### 架构 + +- 更新依赖 PLStreamingKit 的版本到 `v1.1.3` +- 修复调用 `- (void)reloadVideoConfiguraiton` 方法,fps 变更失败的问题 \ No newline at end of file