Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed2d37e6f4 | |||
| fbbf5d9da5 | |||
| 8f57142e5a | |||
| d198058ce3 | |||
| 3ea70b4780 | |||
| 8b0224626a | |||
| 41fe9d1070 | |||
| d7b981c516 | |||
| 09a4627886 |
+3
-2
@@ -2,7 +2,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = "LFLiveKit"
|
||||
s.version = "1.6.6"
|
||||
s.version = "1.7.0"
|
||||
s.summary = "LaiFeng ios Live. LFLiveKit."
|
||||
s.homepage = "https://github.com/chenliming777"
|
||||
s.license = { :type => "MIT", :file => "LICENSE" }
|
||||
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
|
||||
s.source_files = "LFLiveKit/**/*.{*}"
|
||||
s.public_header_files = "LFLiveKit/**/*.h"
|
||||
|
||||
s.frameworks = "VideoToolbox", "AudioToolbox","AVFoundation","Foundation","UIKit","CFNetwork","OpenGLES","QuartzCore","Security"
|
||||
s.frameworks = "VideoToolbox", "AudioToolbox","AVFoundation","Foundation","UIKit"
|
||||
s.library = "z"
|
||||
|
||||
s.requires_arc = true
|
||||
@@ -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.6</string>
|
||||
<string>1.7.0</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,15 @@
|
||||
|
||||
#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() {
|
||||
return YYDispatchQueueGetForQOS(NSQualityOfServiceUserInitiated);
|
||||
}
|
||||
|
||||
#define DATA_ITEMS_MAX_COUNT 100
|
||||
#define RTMP_DATA_RESERVE_SIZE 400
|
||||
#define RTMP_HEAD_SIZE (sizeof(RTMPPacket)+RTMP_MAX_HEADER_SIZE)
|
||||
@@ -46,7 +51,6 @@ SAVC(mp4a);
|
||||
@property (nonatomic, weak) id<LFStreamSocketDelegate> delegate;
|
||||
@property (nonatomic, strong) LFLiveStreamInfo *stream;
|
||||
@property (nonatomic, strong) LFStreamingBuffer *buffer;
|
||||
@property (nonatomic, strong) dispatch_queue_t socketQueue;
|
||||
@property (nonatomic, strong) LFLiveDebug *debugInfo;
|
||||
//错误信息
|
||||
@property (nonatomic, assign) RTMPError error;
|
||||
@@ -83,7 +87,7 @@ SAVC(mp4a);
|
||||
}
|
||||
|
||||
- (void) start{
|
||||
dispatch_async(self.socketQueue, ^{
|
||||
dispatch_async(YYRtmpSendQueue(), ^{
|
||||
if(!_stream) return;
|
||||
if(_isConnecting) return;
|
||||
if(_rtmp != NULL) return;
|
||||
@@ -96,7 +100,10 @@ SAVC(mp4a);
|
||||
}
|
||||
|
||||
- (void) stop{
|
||||
dispatch_async(self.socketQueue, ^{
|
||||
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);
|
||||
@@ -106,9 +113,7 @@ SAVC(mp4a);
|
||||
}
|
||||
|
||||
- (void) sendFrame:(LFFrame*)frame{
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.socketQueue, ^{
|
||||
__strong typeof(_self) self = _self;
|
||||
dispatch_async(YYRtmpSendQueue(), ^{
|
||||
if(!frame) return;
|
||||
[self.buffer appendObject:frame];
|
||||
[self sendFrame];
|
||||
@@ -398,7 +403,10 @@ Failed:
|
||||
int success = PILI_RTMP_SendPacket(_rtmp,packet,0,&_error);
|
||||
if(success){
|
||||
self.isSending = NO;
|
||||
[self sendFrame];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self sendFrame];
|
||||
});
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -438,30 +446,24 @@ 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;
|
||||
socket.isReconnecting = YES;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(socket.reconnectInterval * NSEC_PER_SEC)), socket.socketQueue, ^{
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(socket.reconnectInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[socket reconnect];
|
||||
});
|
||||
}else if(socket.retryTimes4netWorkBreaken >= socket.reconnectCount){
|
||||
@@ -480,12 +482,6 @@ void ConnectionTimeCallback(PILI_CONNECTION_TIME* conn_time, void *userData){
|
||||
}
|
||||
|
||||
#pragma mark -- Getter Setter
|
||||
- (dispatch_queue_t)socketQueue{
|
||||
if(!_socketQueue){
|
||||
_socketQueue = dispatch_queue_create("com.youku.LaiFeng.live.socketQueue", NULL);
|
||||
}
|
||||
return _socketQueue;
|
||||
}
|
||||
|
||||
- (LFStreamingBuffer*)buffer{
|
||||
if(!_buffer){
|
||||
|
||||
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