Skip to content

Commit

Permalink
Merge pull request #142 from iossun/master
Browse files Browse the repository at this point in the history
update PLMediaStreamingKit v3.0.6
  • Loading branch information
Kivenhaoyu committed Sep 27, 2021
2 parents 896d8d2 + e99fd6a commit a5f4bdd
Show file tree
Hide file tree
Showing 30 changed files with 330 additions and 126 deletions.
7 changes: 7 additions & 0 deletions APIDiffs/api-diffs-3.0.6.md
@@ -0,0 +1,7 @@
# PLMediaStreamingKit 3.0.5 to 3.0.6 API Differences

## General Headers




6 changes: 4 additions & 2 deletions Example/PLMediaStreamingKitDemo.xcodeproj/project.pbxproj
Expand Up @@ -718,10 +718,12 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PLMediaStreamingKitDemo/Pods-PLMediaStreamingKitDemo-frameworks.sh",
"${PODS_ROOT}/../../Pod/Library/PLMediaStreamingKit.framework",
"${PODS_ROOT}/../../Pod/Library/HappyDNS.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PLMediaStreamingKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -894,7 +896,7 @@
"$(inherited)",
"$(PROJECT_DIR)/PLMediaStreamingKitDemo/Weixin",
);
MARKETING_VERSION = 3.0.3;
MARKETING_VERSION = 3.0.6;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.pili-engineering.PLMediaStreamingKitDemo";
PRODUCT_NAME = PLMediaStreamingKitDemo;
Expand Down Expand Up @@ -923,7 +925,7 @@
"$(inherited)",
"$(PROJECT_DIR)/PLMediaStreamingKitDemo/Weixin",
);
MARKETING_VERSION = 3.0.3;
MARKETING_VERSION = 3.0.6;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.pili-engineering.PLMediaStreamingKitDemo";
Expand Down
6 changes: 1 addition & 5 deletions Example/PLMediaStreamingKitDemo/PLInitViewController.m
Expand Up @@ -94,7 +94,7 @@ - (void)defaultSettings {

// 根据音视频配置 初始化 PLMediaStreamingSession
_mediaSession = [[PLMediaStreamingSession alloc] initWithVideoCaptureConfiguration:_videoCaptureConfiguration audioCaptureConfiguration:_audioCaptureConfiguration videoStreamingConfiguration:_videoStreamConfiguration audioStreamingConfiguration:_audioStreamingConfiguration stream:nil];

// 外部导入音视频配置 初始化 PLStreamingSession
_streamSession = [[PLStreamingSession alloc] initWithVideoStreamingConfiguration:_videoStreamConfiguration audioStreamingConfiguration:_audioStreamingConfiguration stream:nil];
}
Expand Down Expand Up @@ -259,10 +259,6 @@ - (void)bundleIdAuth {

// 进入推流程序
- (void)nextStep {
if (_settingsView.urlTextField.text.length < 7 || _settingsView.urlTextField.text.length == 0) {
[self alertViewWithMessage:@"推流 URL 地址不可用!"];
return;
}
if (_settingsView.streamType == 2) {
// 外部导入数据 推流
UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
Expand Down
23 changes: 19 additions & 4 deletions Example/PLMediaStreamingKitDemo/PLStreamViewController.m
Expand Up @@ -42,7 +42,7 @@
};

// PreferredExtension
static NSString *PLPreferredExtension = @"ccom.pili-engineering.PLMediaStreamingKitDemo.BroadcastUploadExtension";
static NSString *PLPreferredExtension = @"com.qbox.PLMediaStreamingKitDemo.PLReplaykitExtension";

@interface PLStreamViewController ()
<
Expand Down Expand Up @@ -73,7 +73,6 @@ @interface PLStreamViewController ()
@property (nonatomic, strong) PLAudioCaptureConfiguration *audioCaptureConfiguration;
// 音频流配置
@property (nonatomic, strong) PLAudioStreamingConfiguration *audioStreamingConfiguration;

// 推流混音播放器
@property (nonatomic, strong) PLAudioPlayer *audioPlayer;

Expand Down Expand Up @@ -120,6 +119,15 @@ - (void)dealloc {
// 必须移除监听
[self removeObservers];

// _mediaSession 退出不销毁,为保持下次进入 UI 保持一致,这里重置 default
[_pushImageView removeFromSuperview];
[_mediaSession clearWaterMark];
[_mediaSession setPushImage:nil];
_mediaSession.muted = NO;
[_mediaSession removeAllOverlayViews];
[self showDetailView:nil didClickIndex:0 currentType:PLSetDetailViewOrientaion];
[_mediaSession closeCurrentAudio];

// 销毁 PLMediaStreamingSession
if (_mediaSession.isStreamingRunning) {
[_mediaSession stopStreaming];
Expand All @@ -133,7 +141,6 @@ - (void)dealloc {
_streamSession.delegate = nil;
_streamSession = nil;
}

// 打印代表 PLStreamViewController 成功释放
NSLog(@"[PLStreamViewController] dealloc !");
}
Expand Down Expand Up @@ -168,6 +175,7 @@ - (void)viewDidDisappear:(BOOL)animated {
}
}


- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
Expand Down Expand Up @@ -581,6 +589,7 @@ - (void)buttonControlsView:(PLButtonControlsView *)buttonControlsView didClickIn
}
}


#pragma mark - PLShowDetailViewDelegate
- (void)showDetailView:(PLShowDetailView *)showDetailView didClickIndex:(NSInteger)index currentType:(PLSetDetailViewType)type {
// 转换方向
Expand Down Expand Up @@ -752,6 +761,7 @@ - (void)switchCamera {

// 开始/停止推流
- (void)startStream:(UIButton *)button {

// PLMediaStreamingSession
if (_type == 0 || _type == 1) {
// 开始/停止 推流
Expand Down Expand Up @@ -1072,14 +1082,18 @@ - (void)stopScreenRecorder {
if (@available(iOS 11.0, *)) {
[_streamSession stop];
_startButton.selected = NO;
[_screenRecorder.cameraPreviewView removeFromSuperview];
[_screenRecorder stopRecordingWithHandler:^(RPPreviewViewController * _Nullable previewViewController, NSError * _Nullable error) {
if (!error) {
NSLog(@"[PLStreamViewController] RPScreenRecorder stop recording success!");
} else {
NSLog(@"[PLStreamViewController] RPScreenRecorder stop recording, error code %ld description %@", error.code, error.localizedDescription);
}
}];
if (_screenRecorder.isRecording) {
[_screenRecorder stopCaptureWithHandler:nil];
}

[_screenRecorder.cameraPreviewView removeFromSuperview];
}
}
}
Expand Down Expand Up @@ -1229,6 +1243,7 @@ - (void)selectedReplayType {
weakSelf.needRecordSystem = YES;
weakSelf.startButton.hidden = YES;
weakSelf.seiButton.hidden = YES;
[weakSelf startStream:_startButton];
}];
[alertViewController addAction:yesAction];

Expand Down
108 changes: 100 additions & 8 deletions Example/PLMediaStreamingKitDemo/Views/PLSettingsView.m
Expand Up @@ -38,7 +38,7 @@ @interface PLSettingsView()

// PLMediaStreamingSession、PLStreamingSession 类型分栏
@property (nonatomic, strong) UISegmentedControl *typeSegmentControl;

@property (nonatomic, strong) UISegmentedControl *modleSegmentControl;
// configuration 配置数组
@property (nonatomic, strong) NSMutableArray *configurationArray;
// session 配置数组
Expand Down Expand Up @@ -110,6 +110,22 @@ - (id)initWithFrame:(CGRect)frame mediaSession:(PLMediaStreamingSession *)mediaS
[_typeSegmentControl addTarget:self action:@selector(streamTypeSegmentAction:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_typeSegmentControl];

// 协议类型
UILabel *streamModelLab = [[UILabel alloc]init];
streamModelLab.font = FONT_LIGHT(12.f);
streamModelLab.textColor = [UIColor blackColor];
streamModelLab.textAlignment = NSTextAlignmentLeft;
streamModelLab.text = @"协议类型:";
[self addSubview:streamModelLab];

// 类型选择
_modleSegmentControl = [[UISegmentedControl alloc] initWithItems:@[@"RTMP", @"srt"]];
_modleSegmentControl.backgroundColor = [UIColor whiteColor];
_modleSegmentControl.tintColor = COLOR_RGB(16, 169, 235, 1);
_modleSegmentControl.selectedSegmentIndex = 0;
[_modleSegmentControl addTarget:self action:@selector(streamModelSegmentAction:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_modleSegmentControl];

// 先确认分类
_setSegmentControl = [[UISegmentedControl alloc] initWithItems:@[@"Configuration 配置", @"Session 配置"]];
_setSegmentControl.backgroundColor = [UIColor whiteColor];
Expand Down Expand Up @@ -165,10 +181,23 @@ - (id)initWithFrame:(CGRect)frame mediaSession:(PLMediaStreamingSession *)mediaS
make.height.mas_equalTo(26);
}];

[streamModelLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).offset(PL_SETTING_X_SPACE);
make.top.mas_equalTo(streamTypeLab.mas_bottom).offset(14);
make.size.mas_equalTo(CGSizeMake(60, 26));
}];

[_modleSegmentControl mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(streamModelLab.mas_right);
make.right.mas_equalTo(self.mas_right).offset(-PL_SETTING_X_SPACE);
make.top.mas_equalTo(streamModelLab.mas_top);
make.height.mas_equalTo(26);
}];

[_setSegmentControl mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).offset(PL_SETTING_X_SPACE);
make.right.mas_equalTo(self.mas_right).offset(-PL_SETTING_X_SPACE);
make.top.mas_equalTo(streamTypeLab.mas_bottom).offset(10);
make.top.mas_equalTo(streamModelLab.mas_bottom).offset(10);
make.height.mas_equalTo(26);
}];

Expand Down Expand Up @@ -209,16 +238,44 @@ - (void)requestPublishURL {
NSString *streamString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray *urlArray = [streamString componentsSeparatedByString:@"?"];

// 更新推流的 URL
_streamURL = [NSURL URLWithString:urlArray[0]];
dispatch_async(dispatch_get_main_queue(), ^{
_urlTextField.text = urlArray[0];
// 更新推流的 URL
NSString *urlStr = urlArray[0];
_streamURL = [NSURL URLWithString:urlStr];
if (_modleSegmentControl.selectedSegmentIndex == 1) {//srt
_urlTextField.text = [self urlRtmpToSrt:urlStr];
}else{
_urlTextField.text = urlStr;
}

});
}];

[task resume];
}

-(NSString *)urlRtmpToSrt:(NSString *)rtmp{
if(!rtmp || [rtmp isEqualToString:@""]) return nil;
NSArray*array = [rtmp componentsSeparatedByString:@"/"];
if (array.count < 3) {
NSLog(@"url domain get error");
return nil;
}
NSString *domain = array[2];

NSArray*array1 = [rtmp componentsSeparatedByString:@"com/"];
if (array1.count < 2) {
NSLog(@"url h get error");
return nil;
}
NSString *hStr = array1[1];
NSString *urlStr = nil;
urlStr = [NSString stringWithFormat:@"srt://%@?streamid=#!::h=%@,m=publish",domain,hStr];
NSLog(@"srt url%@",urlStr);
return urlStr;
}


#pragma mark - 将 configuration 的相关配置转换成 model
- (void)combineConfigurationSettings {
NSArray *configureArr;
Expand Down Expand Up @@ -358,12 +415,47 @@ - (void)streamTypeSegmentAction:(UISegmentedControl *)segment {
_streamSession = streamSession;
_mediaSession = nil;
}

[self streamModelSegmentAction:_modleSegmentControl];
if (self.delegate && [self.delegate respondsToSelector:@selector(settingsView:didChangedSession:streamSession:)]) {
[self.delegate settingsView:self didChangedSession:_mediaSession streamSession:_streamSession ];
[self.delegate settingsView:self didChangedSession:_mediaSession streamSession:_streamSession];
}
}

- (void)streamModelSegmentAction:(UISegmentedControl *)segment {
NSInteger index = segment.selectedSegmentIndex;
switch (index) {
case PLProtocolModelsrt:
if (_streamSession) {
_streamSession.protocolModel = PLProtocolModelsrt;
}
if (_mediaSession) {
_mediaSession.protocolModel = PLProtocolModelsrt;
}
if (_modleSegmentControl.selectedSegmentIndex == 1) {//srt
_urlTextField.text = [self urlRtmpToSrt:_streamURL.absoluteString];
}

break;
case PLProtocolModelrtmp:
if (_streamSession) {
_streamSession.protocolModel = PLProtocolModelrtmp;
}
if (_mediaSession) {
_mediaSession.protocolModel = PLProtocolModelrtmp;
}
if (_modleSegmentControl.selectedSegmentIndex == 0) {
_urlTextField.text = _streamURL.absoluteString;
}

break;
default:
break;
}

}



#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (_setSegmentControl.selectedSegmentIndex == 0) {
Expand Down Expand Up @@ -682,7 +774,7 @@ - (void)configureStreamWithConfigureModel:(PLConfigureModel *)configureModel cat

// PLAudioStreamingConfiguration
} else if ([categoryModel.categoryKey isEqualToString:@"PLAudioStreamingConfiguration"]) {
PLAudioStreamingConfiguration *audioStreamingConfiguration = [PLAudioStreamingConfiguration defaultConfiguration];
PLAudioStreamingConfiguration *audioStreamingConfiguration = _mediaSession.audioStreamingConfiguration;
if ([configureModel.configuraKey containsString:@"encodedAudioSampleRate"]) {
switch (index) {
case 0:
Expand Down
24 changes: 22 additions & 2 deletions Example/PLMediaStreamingKitDemo/Views/PLShowDetailView.m
Expand Up @@ -18,7 +18,7 @@ @interface PLShowDetailView()
PLPasterViewDelegate
>

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, assign) UIView *backView;
@property (nonatomic, assign) PLSetDetailViewType type;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
Expand Down Expand Up @@ -84,6 +84,26 @@ - (id)initWithFrame:(CGRect)frame backView:(UIView *)backView{
return self;
}



-(void)setDelegate:(id<PLShowDetailViewDelegate>)delegate{
_delegate = delegate;

if(!_delegate) return;
// 设置默认值
[self segmentAction:_beautyModeSegmentControl];
[self sliderAction:_beautySliderArray[0]];
[self.delegate showDetailView:self didClickIndex:_orientaionSegmentControl.selectedSegmentIndex currentType:PLSetDetailViewOrientaion];
[self.delegate showDetailView:self didClickIndex:_imgPushSegmentControl.selectedSegmentIndex currentType:PLSetDetailViewImagePush];
[self.delegate showDetailView:self didClickIndex:_watermarkSegmentControl.selectedSegmentIndex currentType:PLSetDetailViewWaterMark];
[self.delegate showDetailView:self didClickIndex:_audioEffectSegmentControl.selectedSegmentIndex currentType:PLSetDetailViewAudioEffect];
[self.delegate showDetailView:self didUpdateAudioPlayer:NO playBack:NO file:_musicFileString];

[self volumeSliderAction:_volumeSlider];
[self progressSliderAction:_progressSlider];
}


#pragma mark - 旋转方向
- (void)layoutOrientaionView {
_orientaionSegmentControl = [[UISegmentedControl alloc] initWithItems:@[@"Portrait", @"UpsideDown", @"Right", @"Left"]];
Expand Down Expand Up @@ -503,7 +523,7 @@ - (void)volumeSliderAction:(UISlider *)slider {
- (void)progressSliderAction:(UISlider *)slider {
if (self.delegate && [self.delegate respondsToSelector:@selector(showDetailView:didUpdateAudioPlayProgress:)]) {
[self.delegate showDetailView:self didUpdateAudioPlayProgress:slider.value];
}\
}
}

- (void)delegateUpdateStateAudioPlayer {
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Expand Up @@ -3,9 +3,9 @@ PODS:
- Fabric (~> 1.10.1)
- Fabric (1.10.1)
- Masonry (1.1.0)
- PLMediaStreamingKit (3.0.4):
- PLMediaStreamingKit/iphoneos (= 3.0.4)
- PLMediaStreamingKit/iphoneos (3.0.4)
- PLMediaStreamingKit (3.0.6):
- PLMediaStreamingKit/iphoneos (= 3.0.6)
- PLMediaStreamingKit/iphoneos (3.0.6)

DEPENDENCIES:
- Crashlytics
Expand All @@ -27,7 +27,7 @@ SPEC CHECKSUMS:
Crashlytics: 666da4380b70d38c80426754fa9d5dfca0e5fd43
Fabric: 58508b243fa6053c03bd04b9e0ada772f317d5b4
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
PLMediaStreamingKit: 433ad99ed8feb48a2305db85a42f7937ba8875c6
PLMediaStreamingKit: f0aaeca813ca60be64636dadc39545d0d42f1dc0

PODFILE CHECKSUM: 01b839d9eedb8dc4ae7438d2253f169c3d8deb5b

Expand Down

0 comments on commit a5f4bdd

Please sign in to comment.