Skip to content

Commit

Permalink
update to v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ksvcci committed Nov 20, 2017
1 parent ab8ba2d commit db45d1f
Show file tree
Hide file tree
Showing 102 changed files with 11,815 additions and 4,067 deletions.
8 changes: 4 additions & 4 deletions UnionMobileStreaming.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |s|
s.name = 'UnionMobileStreaming'
s.version = '0.9.0'
s.version = '1.0.0'
s.license = {
:type => 'Proprietary',
:text => <<-LICENSE
Copyright 2015 kingsoft Ltd. All rights reserved.
Copyright 2017 opencdnunion Ltd. All rights reserved.
LICENSE
}
s.homepage = 'http://v.ksyun.com/doc.html'
s.homepage = 'https://github.com/ksvc/UnionMobileStreaming_iOS'
s.authors = { 'ksyun' => '[email protected]' }
s.summary = 'UnionMobileStreaming for stream live video from ios mobile devices.'
s.description = <<-DESC
Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.ios.frameworks = [ 'AVFoundation', 'VideoToolbox', 'AudioToolbox']
s.ios.deployment_target = '8.0'
s.source = {
:git => 'https://github.com/ksvc/UnionMobileStreaming.git',
:git => 'https://github.com/ksvc/UnionMobileStreaming_iOS.git',
:tag => 'v'+s.version.to_s
}
s.requires_arc = true
Expand Down
4 changes: 2 additions & 2 deletions demo/UnionStreamDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
DEVELOPMENT_TEAM = ZGJ54Q7R45;
INFOPLIST_FILE = UnionStreamDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ksyun.ios.UnionStreamDemo;
PRODUCT_BUNDLE_IDENTIFIER = org.opencdnunion.UnionStreamDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -359,7 +359,7 @@
DEVELOPMENT_TEAM = ZGJ54Q7R45;
INFOPLIST_FILE = UnionStreamDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ksyun.ios.UnionStreamDemo;
PRODUCT_BUNDLE_IDENTIFIER = org.opencdnunion.UnionStreamDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
11 changes: 10 additions & 1 deletion demo/UnionStreamDemo/UnionSettingVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ @interface UnionSettingVC ()<UIPickerViewDataSource,
@property UIPickerView *profilePicker; // 选择参数
@property UIButton *startBtn; //开始推流

@property UISegmentedControl* aCodecSeg; // 音频codec
@property UISegmentedControl* vCodecSeg; // 视频codec

@property NSInteger curProfileIdx;
@property NSURL *url;

Expand All @@ -33,7 +36,7 @@ - (void)viewDidLoad {
NSString * uuidStr =[[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSString *devCode = [[uuidStr substringToIndex:3] lowercaseString];
//推流地址
NSString *streamSrv = @"rtmp://test.uplive.ks-cdn.com/live";
NSString *streamSrv = @"rtmp://120.92.224.235/live";
NSString *streamUrl = [ NSString stringWithFormat:@"%@/%@", streamSrv, devCode];
_url = [[NSURL alloc] initWithString:streamUrl];

Expand Down Expand Up @@ -62,6 +65,8 @@ - (void)setupUI{
[_profilePicker selectRow:7 inComponent:0 animated:YES];
[self pickerView:_profilePicker didSelectRow:7 inComponent:0];

_aCodecSeg = [_ctrlView addSegCtrlWithItems:@[@"ATAAC", @"fdk-aac"]];
_vCodecSeg = [_ctrlView addSegCtrlWithItems:@[@"VT264", @"x264"]];
_startBtn = [_ctrlView addButton:@"开始"];

[self.view addSubview:_ctrlView];
Expand All @@ -76,6 +81,8 @@ - (void)layoutUI{
_ctrlView.yPos +=_ctrlView.btnH;
_ctrlView.btnH = 216;
[_ctrlView putRow1:_profilePicker];
_ctrlView.btnH = 30;
[_ctrlView putRow:@[_aCodecSeg, _vCodecSeg]];
_ctrlView.btnH = _ctrlView.height - _ctrlView.yPos;
[_ctrlView putRow:@[_startBtn]];
}
Expand All @@ -87,6 +94,8 @@ - (void)onBtn:(UIButton *)btn{
else if (btn == _startBtn) {
_url = [[NSURL alloc] initWithString:_hostUrlUI.text];
UnionStreamVC * vc = [[UnionStreamVC alloc] initWithUrl:_url andPreset:_curProfileIdx];
vc.audioCodecIdx = _aCodecSeg.selectedSegmentIndex;
vc.videoCodecIdx = _vCodecSeg.selectedSegmentIndex;
[self presentViewController:vc animated:true completion:nil];
}
}
Expand Down
5 changes: 5 additions & 0 deletions demo/UnionStreamDemo/UnionStreamVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@

- (id)initWithUrl:(NSURL *)rtmpUrl andPreset:(UnionPreset) preset;

@property NSInteger audioCodecIdx;
@property NSInteger videoCodecIdx;

// 重写此方法,调整UI布局
- (void)setupUI;
- (void)onBtn:(UIButton *)btn;
- (void)onQuit;
@end

#define SEL_VALUE(SEL_NAME) [NSValue valueWithPointer:@selector(SEL_NAME)]
66 changes: 60 additions & 6 deletions demo/UnionStreamDemo/UnionStreamVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
#import "UnionStreamVC.h"
#import "UnionFileSelector.h"

#import "UnionVT264Encoder.h"
#import "UnionATAACEncoder.h"
#import "UnionX264Encoder.h"
#import "UnionFDKAACEncoder.h"

@interface UnionStreamVC () {
UnionFileSelector * _fSel;
NSMutableDictionary *_obsDict;
}

@property UIButton *captureBtn;//预览按钮
Expand All @@ -31,6 +37,8 @@ - (id)initWithUrl:(NSURL *)rtmpUrl andPreset:(UnionPreset) preset {
_url = rtmpUrl;
_preset = preset;
}

[self initObservers];
return self;
}

Expand All @@ -41,7 +49,12 @@ - (void)viewDidLoad {
//摄像头位置
_kit.cameraPosition = AVCaptureDevicePositionFront;
self.view.backgroundColor = [UIColor whiteColor];

if (_audioCodecIdx == 1) { // 0 is defalut ataac
_kit.aEncoder = [[UnionFDKAACEncoder alloc] initWithConfig:_kit.audioEncCfg];
}
if (_videoCodecIdx == 1) { // 0 is defalut vt264
_kit.vEncoder = [[UnionX264Encoder alloc] initWithConfig:_kit.videoEncCfg];
}
[self setupUI];
[self setupLogo];
[self onCapture];
Expand Down Expand Up @@ -120,36 +133,33 @@ - (void)onStream{
_streamBtn.selected = !_streamBtn.selected;
if (_streamBtn.selected) {
NSLog(@"%@", self.url.absoluteString);
_streamState.text = @"开始推流";
_streamBtn.enabled = NO;
_quitBtn.enabled = NO;
dispatch_async(dispatch_get_global_queue(0,0), ^(){
[_kit startStream:self.url];
dispatch_async(dispatch_get_main_queue(), ^(){
_streamState.text = @"推流中";
_streamBtn.enabled = YES;
_quitBtn.enabled = YES;
});
});
}
else {
_streamState.text = @"结束推流";
_streamBtn.enabled = NO;
_quitBtn.enabled = NO;
dispatch_async(dispatch_get_global_queue(0,0), ^(){
[_kit stopStream];
dispatch_async(dispatch_get_main_queue(), ^(){
_streamState.text = @"空闲";
_streamBtn.enabled = YES;
_quitBtn.enabled = YES;
});
});

}
}
- (void)onQuit{
[_kit stopPreview];
[self rmObservers];
_kit = nil;

[self dismissViewControllerAnimated:YES completion:nil];
}

Expand Down Expand Up @@ -200,4 +210,48 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
}];
}

#pragma mark - notification
- (void) initObservers{
_obsDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
SEL_VALUE(onPublisherStateChange:) , UnionPublisherStateDidChangeNotification,
nil];
}

- (void) rmObservers {
[super rmObservers];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void) addObservers {
[super addObservers];

NSNotificationCenter* dc = [NSNotificationCenter defaultCenter];
for (NSString* key in _obsDict) {
SEL aSel = [[_obsDict objectForKey:key] pointerValue];
[dc addObserver:self
selector:aSel
name:key
object:nil];
}
}

#pragma mark - state change
- (void) onPublisherStateChange:(NSNotification *)notification{
if(UnionPublisherStateDidChangeNotification == notification.name)
{
if(UnionPublisherState_Idle == _kit.publisher.publisherState)
_streamState.text = @"空闲状态";
else if(UnionPublisherState_Started == _kit.publisher.publisherState)
_streamState.text = @"开始推流";
else if(UnionPublisherState_Stopped == _kit.publisher.publisherState)
_streamState.text = @"推流结束";
else if(UnionPublisherState_Error == _kit.publisher.publisherState)
{
_streamState.text = @"推流错误";
NSLog(@"%@", _kit.publisher.error);
}
}
}


@end
2 changes: 1 addition & 1 deletion doc/docset-installed.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Documentation set was installed to Xcode!

Path: /Users/ksvc/Library/Developer/Shared/Documentation/DocSets/org.opencdnunion.UnionMobileStreaming.docset
Time: 2017-11-10 09:49:43 +0000
Time: 2017-11-20 03:49:58 +0000
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ <h1 id="library-title">

<option value="//api/name/encoderCfg">encoderCfg</option>

<option value="//api/name/encoderConfigUpdateCallback">encoderConfigUpdateCallback</option>

<option value="//api/name/error">error</option>

<option value="//api/name/frameDropped">frameDropped</option>
Expand Down Expand Up @@ -496,6 +498,47 @@ <h3 class="method-title"><code><a href="#//api/name/encodedPacketCallback">&nbsp



<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<p><code class="declared-in-ref">UnionEncoderBase.h</code></p>
</div>


</div>
</div>
</div><div class="section-method">
<a name="//api/name/encoderConfigUpdateCallback" title="encoderConfigUpdateCallback"></a>
<h3 class="method-title"><code><a href="#//api/name/encoderConfigUpdateCallback">&nbsp;&nbsp;encoderConfigUpdateCallback</a></code>
</h3>

<div class="method-info">
<div class="pointy-thing"></div>

<div class="method-info-container">


<div class="method-subsection brief-description">
<p>编码器参数变化回调</p>
</div>



<div class="method-subsection method-declaration"><code>@property (nonatomic, copy) void ( ^ ) ( UnionEncoderCfg *cfg ) encoderConfigUpdateCallback</code></div>















<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<p><code class="declared-in-ref">UnionEncoderBase.h</code></p>
Expand Down
Loading

0 comments on commit db45d1f

Please sign in to comment.