網(wǎng)易云從集成到多人視頻會(huì)議(3)~中間的坑~~

本地視頻

遠(yuǎn)程視頻

這也是坑。。。
以一般人的思維,創(chuàng)建完會(huì)議室,然后加入房間,就跳轉(zhuǎn)到視頻頁(yè)面,,顯示本地自己的視頻圖像,,然后有人加進(jìn)來(lái)的話再把對(duì)方的視頻圖像顯示出來(lái)。
然而。。。不能這么做。就是在這里我卡了兩天。。。。。。。真想打人。

創(chuàng)建加入會(huì)議房間必須在同一個(gè)頁(yè)面完成,否則會(huì)出現(xiàn)本地視頻代理方法不走。。然后你就獲取不到本地流,顯示不出來(lái)。。。

首先需要

           #import "NTESGLView.h"

這個(gè)東西(ijkl)這也是坑啊。。。倒入的時(shí)候報(bào)錯(cuò)。。相對(duì)路徑和絕對(duì)路徑的錯(cuò)
解決方法就是直接把相對(duì)路徑去掉
#include "ijksdl_vout.h" 這樣子。 就可以了。


B8A82E3F-A86C-4F85-AE47-8EE731D4B439.png

不想寫了直接上代碼了

.m文件
//
//  LSXVideoChatVC.m
//  wxf
//
//  Created by 醫(yī)聯(lián)通 on 17/10/13.
//  Copyright ? 2017年 lsx. All rights reserved.
//

#import "LSXVideoChatVC.h"
#import <NIMAVChat/NIMAVChat.h>
#import <NIMSDK/NIMSDK.h>
#import "NTESGLView.h"
#import "NTESBundleSetting.h"
@interface LSXVideoChatVC ()<NIMNetCallManagerDelegate>

@property (nonatomic, strong) NTESGLView *videoView;
@property (nonatomic, strong) UIView * localView;

@end

@implementation LSXVideoChatVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _localView=[UIView new];
    
    _videoView=[[NTESGLView alloc]initWithFrame:CGRectMake(0, 64,SCREEN_WIDTH, SCREEN_HEIGHT/2)];
    _videoView.backgroundColor=LineColor;
    [self.view addSubview:_videoView];
    
    if([_CreatOrJoin isEqualToString:@"1"]){
        _localView.frame=_videoView.bounds;
    }else{
        _localView.frame=CGRectMake(SCREEN_WIDTH-110, 74, 100, 100);
    }
    
    [[NIMAVChatSDK sharedSDK].netCallManager addDelegate:self];
    
    if([_CreatOrJoin isEqualToString:@"1"]){
        //創(chuàng)建
        [self reserveMeetingWithRoomId:_roomId];
    }else{
        //加入
        NIMNetCallMeeting *meeting = [[NIMNetCallMeeting alloc] init];
        meeting.name =_roomId;
        [self joinNetCallWithRMeeting:meeting];
    }
}
//
//-(void)CreatButtons{
//    
//    UIButton * btn1=[UIButton new];
//    [_videoView addSubview:btn1];
//    btn1.frame=CGRectMake(10, 74, <#CGFloat width#>, <#CGFloat height#>)
//    
//}









//預(yù)訂會(huì)議(創(chuàng)建會(huì)議)
- (void)reserveMeetingWithRoomId:(NSString *)roomId{
    
    NIMNetCallMeeting *meeting = [[NIMNetCallMeeting alloc] init];
    meeting.name = roomId;
    meeting.type = NIMNetCallMediaTypeVideo;
    meeting.ext = @"哈哈哈哈";
    meeting.actor = YES;
    [[NIMAVChatSDK sharedSDK].netCallManager reserveMeeting:meeting completion:^(NIMNetCallMeeting * _Nonnull meeting, NSError * _Nonnull error) {
        if (!error) {
            NSLog(@"預(yù)定成功 ,進(jìn)入房間");
            [self joinNetCallWithRMeeting:meeting];
            
        } else {
            if (error.code == 417) {
                [self joinNetCallWithRMeeting:meeting];
            } else {
                NSLog(@"預(yù)定房間失敗");
            }
        }
    }];
}
//加入會(huì)議相關(guān)方法
- (void)joinNetCallWithRMeeting:(NIMNetCallMeeting *)rMeeting {
    
    
    NIMNetCallOption *callOption =[[NIMNetCallOption alloc]init];
    // 發(fā)送視頻質(zhì)量(SDK會(huì)處理 有可能無(wú)效)
    //callOption.preferredVideoQuality =NIMNetCallVideoQualityDefault;
    // 禁止剪裁
    // callOption.disableVideoCropping =NO;
    // 自動(dòng)旋轉(zhuǎn)遠(yuǎn)端畫面
    callOption.autoRotateRemoteVideo =YES;
    // 期望的視頻編碼器
    callOption.preferredVideoEncoder =NIMNetCallVideoCodecDefault;
    // 期望的視頻解碼器
    callOption.preferredVideoDecoder =NIMNetCallVideoCodecDefault;
    // 初始打開(kāi)攝像頭,
    callOption.videoCaptureParam.startWithCameraOn =YES;
    // 啟用互動(dòng)直播
    callOption.enableBypassStreaming =YES;
    // 互動(dòng)直播推流地址
    callOption.bypassStreamingUrl =nil;
    // 是否在服務(wù)器錄制音頻
    callOption.serverRecordAudio =YES;
    callOption.autoDeactivateAudioSession = NO;
    // 是否在服務(wù)器錄制視頻
    callOption.serverRecordVideo =YES;
    callOption.videoCaptureParam = [self videoCaptureParam];
    // 加入會(huì)議的類型->音頻/視頻
    rMeeting.type =NIMNetCallMediaTypeVideo;
    // 是否發(fā)送音視頻數(shù)據(jù)
    rMeeting.actor = YES;
    // 網(wǎng)路電話配置
    rMeeting.option = callOption;
    //進(jìn)入房間聊天
    [[NIMAVChatSDK sharedSDK].netCallManager joinMeeting:rMeeting completion:^(NIMNetCallMeeting * _Nonnull meeting, NSError * _Nonnull error) {
        if (!error) {
            NSLog(@"進(jìn)入成功");
            NSLog(@"callID====%llu---name===--%@",meeting.callID,meeting.name);
        } else {
            NSLog(@"進(jìn)入失敗");
            [self reserveMeetingWithRoomId:_roomId];
        }
    }];
}
//音視頻配置
- (NIMNetCallVideoCaptureParam *)videoCaptureParam{
    
    NIMNetCallVideoCaptureParam *param = [[NIMNetCallVideoCaptureParam alloc] init];
    
    param.videoCrop = [[NTESBundleSetting sharedConfig] videochatVideoCrop];
    // 使用后置攝像頭開(kāi)始視頻, 默認(rèn)是 YES
    param.startWithBackCamera   = [[NTESBundleSetting sharedConfig] startWithBackCamera];
    
    param.preferredVideoQuality = [[NTESBundleSetting sharedConfig] preferredVideoQuality];
    
    param.provideLocalVideoProcess = [[NTESBundleSetting sharedConfig] provideLocalProcess];
    
    param.preferredVideoQuality = NIMNetCallVideoQualityLow;
    
    return param;
}

#pragma NIMNetCallManagerDelegate
/// 遠(yuǎn)程視頻 (是控制遠(yuǎn)程視頻流)
-(void)onRemoteYUVReady:(NSData *)yuvData width:(NSUInteger)width height:(NSUInteger)height from:(NSString *)user{

    if (yuvData) {
       _localView.frame=CGRectMake(SCREEN_WIDTH-110, 74, 100, 100);
        [_videoView render:yuvData width:width height:height];
    }
}
/// 本地視頻 (此處是控制本地視頻流)
-(void)onLocalDisplayviewReady:(UIView *)displayView{
   
    displayView.frame=_localView.bounds;
    [_localView addSubview:displayView];
    [_videoView addSubview:_localView];
}
-(void)viewWillDisappear:(BOOL)animated{
    [self hzId:_hzId withType:@"2"];
    [self MSUNetCallManagerLeaveMeeting];
}
//離開(kāi)會(huì)議
- (void)MSUNetCallManagerLeaveMeeting {
    
    NIMNetCallMeeting *meeting = [[NIMNetCallMeeting alloc] init];
    meeting.name = _roomId;
    [[NIMAVChatSDK sharedSDK].netCallManager leaveMeeting:meeting];
}
- (void)dealloc{
    [[NIMAVChatSDK sharedSDK].netCallManager removeDelegate:self];
}
@end

以上就是網(wǎng)易云多人視頻會(huì)議。如果有什么問(wèn)題可以留言。歡迎指出錯(cuò)誤一起交流學(xué)習(xí)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容