Compare commits

...

8 Commits

Author SHA1 Message Date
chenliming 13bc9ad1eb update version 2016-07-14 19:59:01 +08:00
chenliming 1e6e42f2c6 线程变为单线程 2016-07-14 19:58:26 +08:00
chenliming ed2d37e6f4 update 2016-07-14 19:39:50 +08:00
chenliming fbbf5d9da5 麦克风被占用问题 2016-07-14 19:37:36 +08:00
chenliming 8f57142e5a 修改内存bug 2016-07-14 19:28:56 +08:00
chenliming d198058ce3 修改停止直播的bug 2016-07-14 17:57:27 +08:00
chenliming 3ea70b4780 短线重连的bug 2016-07-14 16:50:44 +08:00
chenliming 8b0224626a update demo 2016-07-13 17:40:23 +08:00
9 changed files with 51 additions and 38 deletions
+2 -1
View File
@@ -2,7 +2,7 @@
Pod::Spec.new do |s|
s.name = "LFLiveKit"
s.version = "1.6.7"
s.version = "1.7.1"
s.summary = "LaiFeng ios Live. LFLiveKit."
s.homepage = "https://github.com/chenliming777"
s.license = { :type => "MIT", :file => "LICENSE" }
@@ -21,5 +21,6 @@ Pod::Spec.new do |s|
s.dependency "CocoaAsyncSocket", "~> 7.4.1"
s.dependency 'LMGPUImage', '~> 0.1.9'
s.dependency "pili-librtmp", "~> 1.0.2"
s.dependency "YYDispatchQueuePool"
end
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.6.7</string>
<string>1.7.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+2
View File
@@ -169,6 +169,8 @@ NSString *const LFAudioComponentFailedToCreateNotification = @"LFAudioComponentF
break;
}
NSLog(@"handleRouteChange reason is %@",seccReason);
[[AVAudioSession sharedInstance] setActive:YES error:nil];
AVAudioSessionPortDescription *input = [[session.currentRoute.inputs count]?session.currentRoute.inputs:nil objectAtIndex:0];
if (input.portType == AVAudioSessionPortHeadsetMic) {
+38 -31
View File
@@ -8,10 +8,17 @@
#import "LFStreamRtmpSocket.h"
#import "rtmp.h"
#import "YYDispatchQueuePool.h"
static const NSInteger RetryTimesBreaken = 20;///< 重连1分钟 3秒一次 一共20次
static const NSInteger RetryTimesMargin = 3;
static dispatch_queue_t YYRtmpSendQueue() {
YYDispatchQueuePool *pool = [[YYDispatchQueuePool alloc] initWithName:@"com.youku.laifeng.rtmpsendQueue" queueCount:1 qos:NSQualityOfServiceDefault];
dispatch_queue_t queue = [pool queue];
return queue;
}
#define DATA_ITEMS_MAX_COUNT 100
#define RTMP_DATA_RESERVE_SIZE 400
#define RTMP_HEAD_SIZE (sizeof(RTMPPacket)+RTMP_MAX_HEADER_SIZE)
@@ -82,31 +89,37 @@ SAVC(mp4a);
}
- (void) start{
if(!_stream) return;
if(_isConnecting) return;
if(_rtmp != NULL) return;
self.debugInfo.streamId = self.stream.streamId;
self.debugInfo.uploadUrl = self.stream.url;
self.debugInfo.isRtmp = YES;
[self clean];
[self RTMP264_Connect:(char*)[_stream.url cStringUsingEncoding:NSASCIIStringEncoding]];
dispatch_async(YYRtmpSendQueue(), ^{
if(!_stream) return;
if(_isConnecting) return;
if(_rtmp != NULL) return;
self.debugInfo.streamId = self.stream.streamId;
self.debugInfo.uploadUrl = self.stream.url;
self.debugInfo.isRtmp = YES;
[self clean];
[self RTMP264_Connect:(char*)[_stream.url cStringUsingEncoding:NSASCIIStringEncoding]];
});
}
- (void) stop{
if(self.delegate && [self.delegate respondsToSelector:@selector(socketStatus:status:)]){
[self.delegate socketStatus:self status:LFLiveStop];
}
if(_rtmp != NULL){
PILI_RTMP_Close(_rtmp, &_error);
PILI_RTMP_Free(_rtmp);
_rtmp = NULL;
}
dispatch_async(YYRtmpSendQueue(), ^{
if(self.delegate && [self.delegate respondsToSelector:@selector(socketStatus:status:)]){
[self.delegate socketStatus:self status:LFLiveStop];
}
if(_rtmp != NULL){
PILI_RTMP_Close(_rtmp, &_error);
PILI_RTMP_Free(_rtmp);
_rtmp = NULL;
}
});
}
- (void) sendFrame:(LFFrame*)frame{
if(!frame) return;
[self.buffer appendObject:frame];
[self sendFrame];
dispatch_async(YYRtmpSendQueue(), ^{
if(!frame) return;
[self.buffer appendObject:frame];
[self sendFrame];
});
}
- (void) setDelegate:(id<LFStreamSocketDelegate>)delegate{
@@ -435,25 +448,19 @@ Failed:
// 断线重连
-(void) reconnect {
_isReconnecting = NO;
if(_isConnected) return;
if(_rtmp){
PILI_RTMP_ReconnectStream(_rtmp, 0, &_error);
}else{
dispatch_async(YYRtmpSendQueue(), ^{
_isReconnecting = NO;
if(_isConnected) return;
[self stop];
[self start];
}
});
}
#pragma mark -- CallBack
void RTMPErrorCallback(RTMPError *error, void *userData){
LFStreamRtmpSocket *socket = (__bridge LFStreamRtmpSocket*)userData;
if(error->code == RTMPErrorSocketClosedByPeer){
[socket stop];
if(socket.delegate && [socket.delegate respondsToSelector:@selector(socketStatus:status:)]){
[socket.delegate socketStatus:socket status:LFLiveError];
}
}else{
if(error->code < 0){
if(socket.retryTimes4netWorkBreaken++ < socket.reconnectCount && !socket.isReconnecting){
socket.isConnected = NO;
socket.isConnecting = NO;
+5 -3
View File
@@ -59,7 +59,9 @@
}
case AVAuthorizationStatusAuthorized:{
// 已经开启授权,可继续
[_self.session setRunning:YES];
dispatch_async(dispatch_get_main_queue(), ^{
[_self.session setRunning:YES];
});
break;
}
case AVAuthorizationStatusDenied:
@@ -218,7 +220,7 @@
*/
_session.running = YES;
_session.delegate = self;
_session.preView = self;
}
return _session;
@@ -310,7 +312,7 @@
if(_self.startLiveButton.selected){
[_self.startLiveButton setTitle:@"结束直播" forState:UIControlStateNormal];
LFLiveStreamInfo *stream = [LFLiveStreamInfo new];
stream.url = @"rtmp://30.96.179.95:1935/live/1234";
stream.url = @"rtmp://live.hkstv.hk.lxdns.com:1935/live/stream789";
//stream.url = @"rtmp://daniulive.com:1935/live/stream2399";
[_self.session startLive:stream];
}else{
+2 -1
View File
@@ -3,6 +3,7 @@ platform :ios,'8.0'
target "LFLiveKitDemo" do
pod 'LFLiveKit', '~> 1.5.2'
pod 'LFLiveKit', '~> 1.6.7'
pod 'YYDispatchQueuePool'
end
+1 -1
View File
@@ -6,5 +6,5 @@ target "LFLiveKit" do
pod 'CocoaAsyncSocket', '~> 7.4.1'
pod 'pili-librtmp', '~> 1.0.2'
pod 'LMGPUImage', '~> 0.1.9'
pod 'YYDispatchQueuePool'
end