From 6736748a6fdb0fabd4afe6b011c876806d402ed0 Mon Sep 17 00:00:00 2001 From: lxmou666 <772765102@qq.com> Date: Wed, 27 Jan 2021 23:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=81=E8=B7=AF=E6=8E=A8=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JianGongYun/TRTC/LiveClassroom.cs | 40 +++++++++++++++++++-- JianGongYun/TRTC/Windows/LiveWindow.xaml.cs | 3 ++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/JianGongYun/TRTC/LiveClassroom.cs b/JianGongYun/TRTC/LiveClassroom.cs index 78d00f8..dbbafec 100644 --- a/JianGongYun/TRTC/LiveClassroom.cs +++ b/JianGongYun/TRTC/LiveClassroom.cs @@ -28,8 +28,10 @@ namespace JianGongYun.TRTC /// public static class LiveClassroom { - const uint SDKAppID = 1400472092; - const string SDKAppKEY = "75907eef24093acc1d2cc20ed1eb95c50cd6728c8f5e0d98b17c5180824eee78"; + const uint SDKAppID = 1400463444; + const string SDKAppKEY = "6ee2586282eb8ab5bff3f917b44500c4ffd9bbd3d820258b1fa8cdd470cfd1ee"; + const uint LIVEAppID = 1252883401; + const uint LIVEBizid = 126866; /// /// TRTC实例 /// @@ -90,7 +92,9 @@ namespace JianGongYun.TRTC userSig = GenTestUserSig(CurrentClassroomEntity.TeacherId), roomId = 0,//使用strRoomId strRoomId = CurrentClassroomEntity.TeacherId, - role = TRTCRoleType.TRTCRoleAnchor + role = TRTCRoleType.TRTCRoleAnchor, + streamId = CurrentClassroomEntity.TeacherId,//旁路CDN流名字为教师id + userDefineRecordId= CurrentClassroomEntity.TeacherId//指定id录制教师 }; lTRTCCloud.enterRoom(ref roomPars, TRTCAppScene.TRTCAppSceneLIVE);//创建房间 @@ -292,6 +296,33 @@ namespace JianGongYun.TRTC lTRTCCloud.selectScreenCaptureTarget(ref current, ref rect, ref property); } + //开启音频后调用 + public static void StartMUX(bool stop = false) + { + if (stop) + { + lTRTCCloud.setMixTranscodingConfig(null); + return; + } + var resolution = settingWindowViewModel.SubEncParams.videoResolution.ToString().Split('_');//屏幕分辨率,本地储存分辨率以屏幕分享分辨率为基准 + lTRTCCloud.setMixTranscodingConfig(new TRTCTranscodingConfig //设置混流 + { + mode = TRTCTranscodingConfigMode.TRTCTranscodingConfigMode_Template_ScreenSharing, + appId = LIVEAppID, + bizId = LIVEBizid, + videoWidth = uint.Parse(resolution[1]), + videoHeight = uint.Parse(resolution[2]), + videoBitrate = settingWindowViewModel.SubEncParams.videoBitrate, + videoFramerate = settingWindowViewModel.SubEncParams.videoFps, + videoGOP = 3, + backgroundColor = 0x202020, + audioSampleRate = 48000, + audioBitrate = 128, + audioChannels = 2 + + }); + } + /// /// 启动麦克风 /// @@ -302,6 +333,8 @@ namespace JianGongYun.TRTC liveWinMode.MicRunning = true; lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel); StartRecordAudio(); + + StartMUX(); } } @@ -553,6 +586,7 @@ namespace JianGongYun.TRTC prc.WaitForExit(); CurrentLiveWindow.Dispatcher.Invoke(new Action(() => { + CurrentLiveWindow.Close(); NoticeManager.NotifiactionShow.AddNotifiaction(new NotifiactionModel() { Title = "提醒", diff --git a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs index 7e1cb26..0134eb5 100644 --- a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs +++ b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs @@ -168,6 +168,9 @@ namespace JianGongYun.TRTC.Windows LiveClassroom.StopMic(); LiveClassroom.StopVideoMain(AfterLiveViewWrap); LiveClassroom.StopVideoSub(AfterLiveSubViewWrap); + + this.Hide(); + LiveClassroom.CallerWindow.Show();//还原调用者窗口 } }