Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13bc9ad1eb | |||
| 1e6e42f2c6 | |||
| ed2d37e6f4 | |||
| fbbf5d9da5 | |||
| 8f57142e5a | |||
| d198058ce3 | |||
| 3ea70b4780 | |||
| 8b0224626a |
+2
-1
@@ -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
|
||||
|
||||
BIN
Binary file not shown.
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Generated
BIN
Binary file not shown.
@@ -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{
|
||||
|
||||
@@ -3,6 +3,7 @@ platform :ios,'8.0'
|
||||
|
||||
target "LFLiveKitDemo" do
|
||||
|
||||
pod 'LFLiveKit', '~> 1.5.2'
|
||||
pod 'LFLiveKit', '~> 1.6.7'
|
||||
pod 'YYDispatchQueuePool'
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user