-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from HeraShowFeng/v3.0.3_docs_release
v3.0.3 release
- Loading branch information
Showing
64 changed files
with
2,917 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# PLMediaStreamingKit 3.0.2 to 3.0.3 API Differences | ||
|
||
## General Headers | ||
|
||
|
||
``` | ||
PLStreamingEnv.h | ||
``` | ||
- *Added* `+(void)initEnvWithUserUID:(NSString *)UID;` | ||
|
||
- *Deprecated* `+(void)initEnv` | ||
|
||
|
||
``` | ||
PLMediaStreamingSession.h | ||
``` | ||
- *Added* `- (AudioBuffer *)mediaStreamingSession:(PLMediaStreamingSession *)session microphoneSourceDidGetAudioBuffer:(AudioBuffer *)audioBuffer asbd:(const AudioStreamBasicDescription *)asbd;` | ||
|
||
- *Added* `- (void)reloadAudioStreamingConfiguration:(PLAudioStreamingConfiguration *)audioStreamingConfiguration;` | ||
|
||
|
||
``` | ||
PLStreamStatus.h | ||
``` | ||
- *Added* `@property (nonatomic, assign, readonly) double videoBitrate;` | ||
- *Added* `@property (nonatomic, assign, readonly) double audioBitrate;` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// BroadcastManager.h | ||
// PLReplaykitExtension | ||
// | ||
// Created by 冯文秀 on 2020/3/23. | ||
// Copyright © 2020 冯文秀. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <PLMediaStreamingKit/PLMediaStreamingKit.h> | ||
|
||
@interface BroadcastManager : NSObject | ||
|
||
@property (nonatomic, strong) PLStreamingSession *session; | ||
|
||
+ (instancetype)createBroadcastManagerWithVideoSize:(CGSize)videoSize streamingURL:(NSString *)streamingURL; | ||
+ (instancetype)sharedBroadcastManager; | ||
- (PLStreamState)streamState; | ||
|
||
- (void)pushVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer; | ||
- (void)pushAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer; | ||
- (void)pushAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer withChannelID:(const NSString *)channelID; | ||
- (void)restartStreaming; | ||
- (void)stopStreaming; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// | ||
// BroadcastManager.m | ||
// PLReplaykitExtension | ||
// | ||
// Created by 冯文秀 on 2020/3/23. | ||
// Copyright © 2020 冯文秀. All rights reserved. | ||
// | ||
|
||
#import "BroadcastManager.h" | ||
#import <PLMediaStreamingKit/PLMediaStreamingKit.h> | ||
|
||
@interface BroadcastManager () | ||
< | ||
PLStreamingSessionDelegate | ||
> | ||
|
||
@end | ||
|
||
@implementation BroadcastManager | ||
|
||
static BroadcastManager *_instance; | ||
|
||
+ (instancetype)sharedBroadcastManager { | ||
return _instance; | ||
} | ||
|
||
+ (instancetype)createBroadcastManagerWithVideoSize:(CGSize)videoSize streamingURL:(NSString *)streamingURL { | ||
_instance = [[BroadcastManager alloc] initWithVideoSize:videoSize streamingURL:streamingURL]; | ||
return _instance; | ||
} | ||
|
||
- (instancetype)initWithVideoSize:(CGSize)videoSize streamingURL:(NSString *)streamingURL | ||
{ | ||
if (self = [super init]) { | ||
[PLStreamingEnv initEnv]; | ||
[PLStreamingEnv enableFileLogging]; | ||
[PLStreamingEnv setLogLevel:PLStreamLogLevelDebug]; | ||
|
||
NSLog(@"%@", PLMediaStreamingSession.versionInfo); | ||
|
||
// [PLStreamingEnv setLogLevel:PLStreamLogLevelDebug]; | ||
// [PLStreamingEnv enableFileLogging]; | ||
|
||
PLVideoStreamingConfiguration *videoConfiguration = [[PLVideoStreamingConfiguration alloc] initWithVideoSize:videoSize expectedSourceVideoFrameRate:24 videoMaxKeyframeInterval:72 averageVideoBitRate:1000*1024 videoProfileLevel:AVVideoProfileLevelH264HighAutoLevel videoEncoderType:PLH264EncoderType_AVFoundation]; | ||
PLAudioStreamingConfiguration *audioConfiguration = [PLAudioStreamingConfiguration defaultConfiguration]; | ||
audioConfiguration.encodedAudioSampleRate = PLStreamingAudioSampleRate_44100Hz; | ||
audioConfiguration.inputAudioChannelDescriptions = @[kPLAudioChannelApp, kPLAudioChannelMic]; | ||
audioConfiguration.audioEncoderType = PLAACEncoderType_iOS_AAC; | ||
|
||
self.session = [[PLStreamingSession alloc] initWithVideoStreamingConfiguration:videoConfiguration | ||
audioStreamingConfiguration:audioConfiguration | ||
stream:nil]; | ||
self.session.autoReconnectEnable = YES; | ||
self.session.connectionInterruptionHandler = ^(NSError *error) { | ||
return YES; | ||
}; | ||
self.session.connectionChangeActionCallback = ^(PLNetworkStateTransition transition) { | ||
return YES; | ||
}; | ||
[self.session enableAdaptiveBitrateControlWithMinVideoBitRate:500 * 1024]; | ||
self.session.delegate = self; | ||
|
||
__weak typeof(self) weakSelf = self; | ||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | ||
[weakSelf.session startWithPushURL:[NSURL URLWithString:streamingURL] feedback:^(PLStreamStartStateFeedback feedback) { | ||
if (PLStreamStartStateSuccess == feedback) { | ||
NSLog(@"[PLReplaykitExtension] streaming connected successfully"); | ||
} else { | ||
NSLog(@"[PLReplaykitExtension] stream failed to connect"); | ||
} | ||
}]; | ||
}); | ||
} | ||
return self; | ||
} | ||
|
||
- (PLStreamState)streamState { | ||
return self.session.streamState; | ||
} | ||
|
||
- (void)pushVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer { | ||
[self.session pushVideoSampleBuffer:sampleBuffer]; | ||
} | ||
|
||
- (void)pushAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer { | ||
[self.session pushAudioSampleBuffer:sampleBuffer]; | ||
} | ||
|
||
- (void)pushAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer withChannelID:(const NSString *)channelID { | ||
[self.session pushAudioSampleBuffer:sampleBuffer withChannelID:channelID completion:nil]; | ||
} | ||
|
||
- (void)restartStreaming { | ||
[self.session restartWithFeedback:^(PLStreamStartStateFeedback feedback) { | ||
if (PLStreamStartStateSuccess == feedback) { | ||
NSLog(@"[PLReplaykitExtension] stream restarted successfully"); | ||
} | ||
}]; | ||
} | ||
|
||
- (void)stopStreaming { | ||
[self.session destroy]; | ||
NSLog(@"[PLReplaykitExtension] stream stopped"); | ||
} | ||
|
||
|
||
#pragma mark - PLStreamingSessionDelegate | ||
- (void)streamingSession:(PLStreamingSession *)session didDisconnectWithError:(NSError *)error { | ||
NSLog(@"[PLReplaykitExtension] streaming error : %@", error); | ||
} | ||
|
||
- (void)streamingSession:(PLStreamingSession *)session streamStateDidChange:(PLStreamState)state { | ||
NSLog(@"[PLReplaykitExtension] stream state did change to: %ld", (long)state); | ||
NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.qbox"]; | ||
[userDefaults setObject:@(state) forKey:@"PLReplayStreamState"]; | ||
[userDefaults synchronize]; | ||
} | ||
|
||
- (void)streamingSession:(PLStreamingSession *)session streamStatusDidUpdate:(PLStreamStatus *)status { | ||
NSLog(@"[PLReplaykitExtension] stream status updated: %@", status); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>BroadcastUploadExtension</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.broadcast-services-upload</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>SampleHandler</string> | ||
<key>RPBroadcastProcessMode</key> | ||
<string>RPBroadcastProcessModeSampleBuffer</string> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// SampleHandler.h | ||
// BroadcastUploadExtension | ||
// | ||
// Created by 冯文秀 on 2021/3/4. | ||
// Copyright © 2021 0dayZh. All rights reserved. | ||
// | ||
|
||
#import <ReplayKit/ReplayKit.h> | ||
|
||
@interface SampleHandler : RPBroadcastSampleHandler | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// SampleHandler.m | ||
// PLReplaykitExtension | ||
// | ||
// Created by 冯文秀 on 2020/3/23. | ||
// Copyright © 2020 冯文秀. All rights reserved. | ||
// | ||
|
||
|
||
#import "SampleHandler.h" | ||
#import "BroadcastManager.h" | ||
|
||
@interface SampleHandler () | ||
|
||
@end | ||
|
||
@implementation SampleHandler | ||
|
||
- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo { | ||
// User has requested to start the broadcast. Setup info from the UI extension will be supplied. | ||
#warning 填入您的推流地址 | ||
NSString *streamingURL = @""; | ||
|
||
CGSize videoSize = CGSizeMake(540, 960); | ||
[BroadcastManager createBroadcastManagerWithVideoSize:videoSize streamingURL:streamingURL]; | ||
} | ||
|
||
- (void)broadcastPaused { | ||
// User has requested to pause the broadcast. Samples will stop being delivered. | ||
[[BroadcastManager sharedBroadcastManager] stopStreaming]; | ||
} | ||
|
||
- (void)broadcastResumed { | ||
// User has requested to resume the broadcast. Samples delivery will resume. | ||
[[BroadcastManager sharedBroadcastManager] restartStreaming]; | ||
} | ||
|
||
- (void)broadcastFinished { | ||
// User has requested to finish the broadcast. | ||
[[BroadcastManager sharedBroadcastManager] stopStreaming]; | ||
} | ||
|
||
- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType { | ||
|
||
if (sampleBuffer && [BroadcastManager sharedBroadcastManager].streamState == PLStreamStateConnected) { | ||
@autoreleasepool { | ||
switch (sampleBufferType) { | ||
case RPSampleBufferTypeVideo: | ||
// Handle video sample buffer | ||
[[BroadcastManager sharedBroadcastManager] pushVideoSampleBuffer:sampleBuffer]; | ||
break; | ||
case RPSampleBufferTypeAudioApp: | ||
// Handle audio sample buffer for app audio | ||
[[BroadcastManager sharedBroadcastManager] pushAudioSampleBuffer:sampleBuffer withChannelID:kPLAudioChannelApp]; | ||
break; | ||
case RPSampleBufferTypeAudioMic: | ||
// Handle audio sample buffer for mic audio | ||
[[BroadcastManager sharedBroadcastManager] pushAudioSampleBuffer:sampleBuffer withChannelID:kPLAudioChannelMic]; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@end |
14 changes: 14 additions & 0 deletions
14
Example/BroadcastUploadExtensionSetupUI/BroadcastSetupViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// BroadcastSetupViewController.h | ||
// BroadcastUploadExtensionSetupUI | ||
// | ||
// Created by 冯文秀 on 2021/3/4. | ||
// Copyright © 2021 0dayZh. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <ReplayKit/ReplayKit.h> | ||
|
||
@interface BroadcastSetupViewController : UIViewController | ||
|
||
@end |
31 changes: 31 additions & 0 deletions
31
Example/BroadcastUploadExtensionSetupUI/BroadcastSetupViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// BroadcastSetupViewController.m | ||
// BroadcastUploadExtensionSetupUI | ||
// | ||
// Created by 冯文秀 on 2021/3/4. | ||
// Copyright © 2021 0dayZh. All rights reserved. | ||
// | ||
|
||
#import "BroadcastSetupViewController.h" | ||
|
||
@implementation BroadcastSetupViewController | ||
|
||
// Call this method when the user has finished interacting with the view controller and a broadcast stream can start | ||
- (void)userDidFinishSetup { | ||
|
||
// URL of the resource where broadcast can be viewed that will be returned to the application | ||
NSURL *broadcastURL = [NSURL URLWithString:@"http://apple.com/broadcast/streamID"]; | ||
|
||
// Dictionary with setup information that will be provided to broadcast extension when broadcast is started | ||
NSDictionary *setupInfo = @{ @"broadcastName" : @"example" }; | ||
|
||
// Tell ReplayKit that the extension is finished setting up and can begin broadcasting | ||
[self.extensionContext completeRequestWithBroadcastURL:broadcastURL setupInfo:setupInfo]; | ||
} | ||
|
||
- (void)userDidCancelSetup { | ||
// Tell ReplayKit that the extension was cancelled by the user | ||
[self.extensionContext cancelRequestWithError:[NSError errorWithDomain:@"YourAppDomain" code:-1 userInfo:nil]]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>BroadcastUploadExtensionSetupUI</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>NSExtensionActivationRule</key> | ||
<dict> | ||
<key>NSExtensionActivationSupportsReplayKitStreaming</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.broadcast-services-setupui</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>BroadcastSetupViewController</string> | ||
</dict> | ||
</dict> | ||
</plist> |
Oops, something went wrong.