Browse Source

直播推流

zwp 5 months ago
parent
commit
c3f1f9409b

+ 1 - 1
BuguLive/Class/General/Helper/GlobalVariables/GlobalVariables.m

@@ -299,7 +299,7 @@
 
 -(BOOL)openAgora
 {
-    return YES;
+    return NO;
 }
 
 - (BOOL)openFirebaseSMS

+ 3 - 0
BuguLive/Class/Live/LiveUI/Controller/TLive/FWTBase/BGTLinkMicPlayController.m

@@ -230,6 +230,9 @@
 - (void)onError:(TXLiteAVError)errCode
          errMsg:(nullable NSString *)errMsg
         extInfo:(nullable NSDictionary *)extInfo{
+    
+    NSLog(@"onError code: %d  message: %@", errCode, errMsg);
+
     if (ERR_CAMERA_NOT_AUTHORIZED == errCode) {
         NSString *errorInfo = @"Current application is not authorized to use the camera:";
         errorInfo = [errorInfo stringByAppendingString: errMsg];

+ 1 - 1
BuguLive/Class/Live/LiveUI/Controller/TLive/FWTBase/BGTPlayController.m

@@ -343,7 +343,7 @@ typedef NS_ENUM(NSInteger, ENUM_TYPE_CACHE_STRATEGY)
 //        [_txLivePlayer setMinCacheTime:1];
 //        [_txLivePlayer setMaxCacheTime:4];
         int result = [_txLivePlayer startLivePlay:playUrl type:_playType];
-        NSLog(@"播流地址 %@",playUrl);
+        NSLog(@"播放结果:%d, 播流地址 %@", result, playUrl);
         if (result == -1)
         {
             [self toastTip:ASLocalizedString(@"非腾讯云链接,若要放开限制请联系腾讯云商务团队")];

+ 1 - 1
BuguLive/Class/Live/LiveUI/Controller/TLive/FWTBase/BGTPublishController.h

@@ -65,7 +65,7 @@ typedef void(^LeaveRoomBlockSuccess)(void);
 
 @property (nonatomic, copy) LeaveRoomBlockSuccess leaveRoomBlockSuccess;
 
-@property (nonatomic, strong) TRTCCloud * trtcCloud;
+@property (nonatomic, strong, readonly) TRTCCloud * trtcCloud;
 @property(nonatomic, strong) NSString *agora_token;
 - (void)adjustPlayItemAgora:(TLiveMickListModel *)mickListModel;
 

+ 51 - 41
BuguLive/Class/Live/LiveUI/Controller/TLive/FWTBase/BGTPublishController.m

@@ -68,6 +68,10 @@
     
 }
 
+- (TRTCCloud *)trtcCloud {
+    return [TRTCCloud sharedInstance];
+}
+
 - (void)endLive
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -329,8 +333,6 @@
 }
 #pragma mark - 初始化
 - (void)initializeAgoraEngine {
-    
-    self.trtcCloud = [TRTCCloud sharedInstance];
     [self.trtcCloud addDelegate:self];
 }
 
@@ -339,7 +341,7 @@
     // 设置本地画面的预览模式:开启左右镜像,设置画面为填充模式
     TRTCRenderParams *param = [[TRTCRenderParams alloc] init];
     param.fillMode   = TRTCVideoFillMode_Fill;
-    param.mirrorType = TRTCVideoMirrorTypeDisable;
+    param.mirrorType = TRTCVideoMirrorTypeAuto;
     [self.trtcCloud setLocalRenderParams:param];
 
     // 启动本地摄像头的预览(localCameraVideoView 是用于渲染本地渲染画面的控件)
@@ -385,9 +387,13 @@
         [self startRtmpStreaming:self.pushUrlStr];
     } else {
         // result 代表进房失败的错误码
-        [self toastTip:@"Enter room failed!"];
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            NSString *string = [NSString stringWithFormat:@"Enter room failed (%ld)", result];
+            [self toastTip:string];
+        });
+        
     }
-    
+    NSLog(@"onEnterRoom result: %ld", (long)result);
     AppDelegate.sharedAppDelegate.isEnterLiveVC = YES;
 }
 //远程静音视频或者音频
@@ -524,6 +530,7 @@
 - (void)onError:(TXLiteAVError)errCode
          errMsg:(nullable NSString *)errMsg
         extInfo:(nullable NSDictionary *)extInfo {
+    NSLog(@"onError code: %d  message: %@", errCode, errMsg);
     if (ERR_CAMERA_NOT_AUTHORIZED == errCode) {
         NSString *errorInfo = @"Current application is not authorized to use the camera:";
         errorInfo = [errorInfo stringByAppendingString:errMsg];
@@ -625,7 +632,7 @@
     config.videoLayoutList = [layoutList copy];
 #warning 暂时注释,后续确认是否需要
     // 开始发布媒体流 不转码
-//    [self.trtcCloud startPublishMediaStream:target encoderParam:nil mixingConfig:nil];
+    [self.trtcCloud startPublishMediaStream:target encoderParam:nil mixingConfig:nil];
 
     // 开始发布媒体流 转码
 //    [self.trtcCloud startPublishMediaStream:target encoderParam:encoderParam mixingConfig:nil];
@@ -1100,7 +1107,7 @@
                         
                         TRTCRenderParams *params = [[TRTCRenderParams alloc] init];
                         // 画面镜像模式
-                        params.mirrorType = TRTCVideoMirrorTypeDisable;
+                        params.mirrorType = TRTCVideoMirrorTypeAuto;
                         // 画面填充模式
                         params.fillMode = TRTCVideoFillMode_Fill;
                         // 画面旋转角度
@@ -1470,46 +1477,49 @@
 }
 
 #pragma mark - ----------------------- 自定义Toast -----------------------
-/**
- @method 获取指定宽度width的字符串在UITextView上的高度
- @param textView 待计算的UITextView
- @param Width 限制字符串显示区域的宽度
- @result float 返回的高度
- */
-- (float)heightForString:(UITextView *)textView andWidth:(float)width
-{
-    CGSize sizeToFit = [textView sizeThatFits:CGSizeMake(width, MAXFLOAT)];
-    return sizeToFit.height;
-}
+///**
+// @method 获取指定宽度width的字符串在UITextView上的高度
+// @param textView 待计算的UITextView
+// @param Width 限制字符串显示区域的宽度
+// @result float 返回的高度
+// */
+//- (float)heightForString:(UITextView *)textView andWidth:(float)width
+//{
+//    CGSize sizeToFit = [textView sizeThatFits:CGSizeMake(width, MAXFLOAT)];
+//    return sizeToFit.height;
+//}
 
 - (void)toastTip:(NSString*)toastInfo
 {
     NSLog(@"======publishtoastInfo:%@",toastInfo);
     
-    CGRect frameRC = [[UIScreen mainScreen] bounds];
-    frameRC.origin.y = frameRC.size.height - 110;
-    frameRC.size.height -= 110;
-    __block UITextView * toastView = [[UITextView alloc] init];
-    
-    toastView.editable = NO;
-    toastView.selectable = NO;
-    
-    frameRC.size.height = [self heightForString:toastView andWidth:frameRC.size.width];
-    
-    toastView.frame = frameRC;
-    
-    toastView.text = toastInfo;
-    toastView.backgroundColor = [UIColor whiteColor];
-    toastView.alpha = 0.5;
-    
-    [self.view addSubview:toastView];
-    
-    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
+    [QMUITips showWithText:toastInfo];
+
     
-    dispatch_after(popTime, dispatch_get_main_queue(), ^(){
-        [toastView removeFromSuperview];
-        toastView = nil;
-    });
+//    CGRect frameRC = [[UIScreen mainScreen] bounds];
+//    frameRC.origin.y = frameRC.size.height - 110;
+//    frameRC.size.height -= 110;
+//    __block UITextView * toastView = [[UITextView alloc] init];
+//    
+//    toastView.editable = NO;
+//    toastView.selectable = NO;
+//    
+//    frameRC.size.height = [self heightForString:toastView andWidth:frameRC.size.width];
+//    
+//    toastView.frame = frameRC;
+//    
+//    toastView.text = toastInfo;
+//    toastView.backgroundColor = [UIColor whiteColor];
+//    toastView.alpha = 0.5;
+//    
+//    [self.view addSubview:toastView];
+//    
+//    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
+//    
+//    dispatch_after(popTime, dispatch_get_main_queue(), ^(){
+//        [toastView removeFromSuperview];
+//        toastView = nil;
+//    });
 }