This commit is contained in:
lxmou666 2021-01-03 22:18:39 +08:00
parent b5da99ae9e
commit a63abac88a
6 changed files with 306 additions and 152 deletions

View File

@ -8,7 +8,7 @@
<NoWarn>$(NoWarn);0067</NoWarn> <NoWarn>$(NoWarn);0067</NoWarn>
<ApplicationIcon>logo.ico</ApplicationIcon> <ApplicationIcon>logo.ico</ApplicationIcon>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<StartupObject /> <StartupObject></StartupObject>
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -17,6 +17,7 @@ using Window = System.Windows.Window;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Windows.Data; using System.Windows.Data;
using System.Drawing; using System.Drawing;
using System.Diagnostics;
namespace JianGongYun.TRTC namespace JianGongYun.TRTC
{ {
@ -99,12 +100,6 @@ namespace JianGongYun.TRTC
{ {
lTRTCCloud.stopSystemAudioLoopback(); lTRTCCloud.stopSystemAudioLoopback();
} }
var encParams = settingWindowViewModel.EncParams;
var qosParams = settingWindowViewModel.QosParams;
var renderParams = settingWindowViewModel.RenderParams;
lTRTCCloud.setVideoEncoderParam(ref encParams);
lTRTCCloud.setNetworkQosParam(ref qosParams);
lTRTCCloud.setLocalRenderParams(ref renderParams);
//设备完结 //设备完结
//liveWinMode.LoadAllScreen(); //liveWinMode.LoadAllScreen();
@ -148,6 +143,12 @@ namespace JianGongYun.TRTC
{ {
if (!liveWinMode.CameraRunning) if (!liveWinMode.CameraRunning)
{ {
var encParams = settingWindowViewModel.MainEncParams;
var qosParams = settingWindowViewModel.MainQosParams;
var renderParams = settingWindowViewModel.MainRenderParams;
lTRTCCloud.setVideoEncoderParam(ref encParams);
lTRTCCloud.setNetworkQosParam(ref qosParams);
lTRTCCloud.setLocalRenderParams(ref renderParams);
lTRTCCloud.startLocalPreview(IntPtr.Zero); lTRTCCloud.startLocalPreview(IntPtr.Zero);
liveWinMode.CameraRunning = true; liveWinMode.CameraRunning = true;
var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeBig, true); var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeBig, true);
@ -186,7 +187,7 @@ namespace JianGongYun.TRTC
{ {
liveWinMode.ScreenRunning = true; liveWinMode.ScreenRunning = true;
SelectVieoSub(); SelectVieoSub();
lTRTCCloud.startScreenCapture(IntPtr.Zero, TRTCVideoStreamType.TRTCVideoStreamTypeSub, settingWindowViewModel.EncParams); lTRTCCloud.startScreenCapture(IntPtr.Zero, TRTCVideoStreamType.TRTCVideoStreamTypeSub, settingWindowViewModel.SubEncParams);
var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeSub, true); var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeSub, true);
if (liveWinMode.IsLive) if (liveWinMode.IsLive)
{ {
@ -234,7 +235,7 @@ namespace JianGongYun.TRTC
{ {
liveWinMode.AudioRecordRunning = true; liveWinMode.AudioRecordRunning = true;
var time = Util.TimeStr(); var time = Util.TimeStr();
var pars = new TRTCAudioRecordingParams { filePath = Path.Combine(RecoderDir, $"{time}audio.pcm") }; var pars = new TRTCAudioRecordingParams { filePath = Path.Combine(RecoderDir, $"{time}audio.wav") };
var res = lTRTCCloud.startAudioRecording(ref pars); var res = lTRTCCloud.startAudioRecording(ref pars);
Console.WriteLine(res); Console.WriteLine(res);
} }
@ -272,10 +273,15 @@ namespace JianGongYun.TRTC
public static void VedioRecordTask(TXLiteAVVideoView view, TRTCVideoStreamType streamType) public static void VedioRecordTask(TXLiteAVVideoView view, TRTCVideoStreamType streamType)
{ {
var end = false; var end = false;
Stopwatch sw1 = new Stopwatch();
Stopwatch sw2 = new Stopwatch();
ConcurrentQueue<Mat> bitmaps = new ConcurrentQueue<Mat>(); ConcurrentQueue<Mat> bitmaps = new ConcurrentQueue<Mat>();
view.OnRenderVideoFrameHandler += (b) => view.OnRenderVideoFrameHandler += (b) =>
{ {
sw1.Restart();
bitmaps.Enqueue(b.ToMat()); bitmaps.Enqueue(b.ToMat());
sw1.Stop();
//Debug.Print("a" + sw1.Elapsed.TotalMilliseconds.ToString());
}; };
view.OnViewRemove += () => view.OnViewRemove += () =>
{ {
@ -289,6 +295,13 @@ namespace JianGongYun.TRTC
var videoFile = Path.Combine(_recoderDir, $"{Util.TimeStr()}_{streamType}.avi"); var videoFile = Path.Combine(_recoderDir, $"{Util.TimeStr()}_{streamType}.avi");
VideoWriter vw = new VideoWriter(); VideoWriter vw = new VideoWriter();
bool videoWriterInit = false; bool videoWriterInit = false;
var frameCount = 0;
Timer timer = new Timer((a) =>
{
//Console.WriteLine($"{streamType} fps {frameCount}");
Debug.Print($"{streamType} fps {frameCount}");
Interlocked.Exchange(ref frameCount, 0);
}, null, 0, 1000);
while (!end || bitmaps.Count > 0) while (!end || bitmaps.Count > 0)
{ {
if (bitmaps.Count == 0) if (bitmaps.Count == 0)
@ -298,6 +311,7 @@ namespace JianGongYun.TRTC
} }
if (bitmaps.TryDequeue(out var mat)) if (bitmaps.TryDequeue(out var mat))
{ {
sw2.Restart();
//mat.SaveImage(imgTemp); //mat.SaveImage(imgTemp);
//mat.Dispose(); //mat.Dispose();
//mat = Cv2.ImRead(imgTemp, ImreadModes.AnyColor); //mat = Cv2.ImRead(imgTemp, ImreadModes.AnyColor);
@ -305,11 +319,13 @@ namespace JianGongYun.TRTC
//Cv2.WaitKey(1); //Cv2.WaitKey(1);
if (!videoWriterInit) if (!videoWriterInit)
{ {
vw.Open(videoFile, FourCC.H264, settingWindowViewModel.EncParams.videoFps, mat.Size()); vw.Open(videoFile, FourCC.H264, settingWindowViewModel.LiveFps, mat.Size());
videoWriterInit = true; videoWriterInit = true;
} }
vw.Write(mat); vw.Write(mat);
mat.Dispose(); mat.Dispose();
Interlocked.Increment(ref frameCount);
//Debug.Print("b"+sw2.Elapsed.TotalMilliseconds.ToString());
} }
else else
{ {
@ -322,6 +338,7 @@ namespace JianGongYun.TRTC
{ {
File.Delete(imgTemp); File.Delete(imgTemp);
} }
timer.Dispose();
Console.WriteLine($"VedioRecordTask End {streamType}"); Console.WriteLine($"VedioRecordTask End {streamType}");
}, TaskCreationOptions.LongRunning); }, TaskCreationOptions.LongRunning);
} }
@ -333,7 +350,7 @@ namespace JianGongYun.TRTC
{ {
TXLiteAVVideoView videoView = new TXLiteAVVideoView(); TXLiteAVVideoView videoView = new TXLiteAVVideoView();
videoView.RegEngine(userId, streamType, lTRTCCloud, local); videoView.RegEngine(userId, streamType, lTRTCCloud, local);
videoView.SetRenderMode(streamType == TRTCVideoStreamType.TRTCVideoStreamTypeBig ? settingWindowViewModel.RenderParams.fillMode : TRTCVideoFillMode.TRTCVideoFillMode_Fit); videoView.SetRenderMode(streamType == TRTCVideoStreamType.TRTCVideoStreamTypeBig ? settingWindowViewModel.MainRenderParams.fillMode : settingWindowViewModel.SubRenderParams.fillMode);
//videoView.Width = parent.ActualWidth; //videoView.Width = parent.ActualWidth;
videoView.SetBinding(TXLiteAVVideoView.WidthProperty, new Binding("ActualWidth") { Source = parent }); videoView.SetBinding(TXLiteAVVideoView.WidthProperty, new Binding("ActualWidth") { Source = parent });
//videoView.Height = parent.ActualHeight; //videoView.Height = parent.ActualHeight;

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace JianGongYun.TRTC.Models
{
/// <summary>
/// 直播画质
/// </summary>
public enum LiveLevelEnum
{
Low = 0,
Mormal,
High
}
}

View File

@ -73,7 +73,7 @@ namespace JianGongYun.TRTC.ViewModels
public LiveWindowViewModel() public LiveWindowViewModel()
{ {
timer = new DispatcherTimer(); timer = new DispatcherTimer(DispatcherPriority.Render);
timer.Interval = TimeSpan.FromSeconds(1); timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += new EventHandler((a, b) => LiveTimeCount = ""); timer.Tick += new EventHandler((a, b) => LiveTimeCount = "");
} }

View File

@ -308,125 +308,125 @@ namespace JianGongYun.TRTC.ViewModels
#region #region
/// <summary> ///// <summary>
/// 视频帧率(fps) ///// 视频帧率(fps)
/// </summary> ///// </summary>
private string _ScreenRecordingFps = "60"; //private string _ScreenRecordingFps = "60";
public string ScreenRecordingFps //public string ScreenRecordingFps
{ //{
get // get
{ // {
var screenRecordingFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS);//本地缓存 // var screenRecordingFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS);//本地缓存
if (string.IsNullOrEmpty(screenRecordingFps)) // if (string.IsNullOrEmpty(screenRecordingFps))
{ // {
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS, _ScreenRecordingFps);//生成初始数据 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS, _ScreenRecordingFps);//生成初始数据
} // }
else // else
{ // {
_ScreenRecordingFps = screenRecordingFps; // _ScreenRecordingFps = screenRecordingFps;
} // }
return _ScreenRecordingFps; // return _ScreenRecordingFps;
} // }
set // set
{ // {
_ScreenRecordingFps = value; // _ScreenRecordingFps = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS, value);//生成保存本地 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_FPS, value);//生成保存本地
if (PropertyChanged != null) // if (PropertyChanged != null)
{ // {
PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingFps")); // PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingFps"));
} // }
} // }
} //}
/// <summary> ///// <summary>
/// 音频码率 ///// 音频码率
/// </summary> ///// </summary>
private string _ScreenRecordingAudioBitrate = "320000"; //private string _ScreenRecordingAudioBitrate = "320000";
public string ScreenRecordingAudioBitrate //public string ScreenRecordingAudioBitrate
{ //{
get // get
{ // {
var screenRecordingAudioBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE);//本地缓存 // var screenRecordingAudioBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE);//本地缓存
if (string.IsNullOrEmpty(screenRecordingAudioBitrate)) // if (string.IsNullOrEmpty(screenRecordingAudioBitrate))
{ // {
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE, _ScreenRecordingAudioBitrate);//生成初始数据 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE, _ScreenRecordingAudioBitrate);//生成初始数据
} // }
else // else
{ // {
_ScreenRecordingAudioBitrate = screenRecordingAudioBitrate; // _ScreenRecordingAudioBitrate = screenRecordingAudioBitrate;
} // }
return _ScreenRecordingAudioBitrate; // return _ScreenRecordingAudioBitrate;
} // }
set // set
{ // {
_ScreenRecordingAudioBitrate = value; // _ScreenRecordingAudioBitrate = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE, value);//生成保存本地 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE, value);//生成保存本地
if (PropertyChanged != null) // if (PropertyChanged != null)
{ // {
PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingAudioBitrate")); // PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingAudioBitrate"));
} // }
} // }
} //}
/// <summary> ///// <summary>
/// 音频采样率 ///// 音频采样率
/// </summary> ///// </summary>
private string _ScreenRecordingAudioFreq = "48000"; //private string _ScreenRecordingAudioFreq = "48000";
public string ScreenRecordingAudioFreq //public string ScreenRecordingAudioFreq
{ //{
get // get
{ // {
var screenRecordingAudioFreq = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ);//本地缓存 // var screenRecordingAudioFreq = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ);//本地缓存
if (string.IsNullOrEmpty(screenRecordingAudioFreq)) // if (string.IsNullOrEmpty(screenRecordingAudioFreq))
{ // {
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ, _ScreenRecordingAudioFreq);//生成初始数据 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ, _ScreenRecordingAudioFreq);//生成初始数据
} // }
else // else
{ // {
_ScreenRecordingAudioFreq = screenRecordingAudioFreq; // _ScreenRecordingAudioFreq = screenRecordingAudioFreq;
} // }
return _ScreenRecordingAudioFreq; // return _ScreenRecordingAudioFreq;
} // }
set // set
{ // {
_ScreenRecordingAudioFreq = value; // _ScreenRecordingAudioFreq = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ, value);//生成保存本地 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_AUDIO_FREQ, value);//生成保存本地
if (PropertyChanged != null) // if (PropertyChanged != null)
{ // {
PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingAudioFreq")); // PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingAudioFreq"));
} // }
} // }
} //}
/// <summary> ///// <summary>
/// 编码级别 ///// 编码级别
/// </summary> ///// </summary>
private string _ScreenRecordingProfileLevel = "-profile:v high -level 5.1"; //private string _ScreenRecordingProfileLevel = "-profile:v high -level 5.1";
public string ScreenRecordingProfileLevel //public string ScreenRecordingProfileLevel
{ //{
get // get
{ // {
var screenRecordingProfileLevel = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL);//本地缓存 // var screenRecordingProfileLevel = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL);//本地缓存
if (string.IsNullOrEmpty(screenRecordingProfileLevel)) // if (string.IsNullOrEmpty(screenRecordingProfileLevel))
{ // {
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL, _ScreenRecordingProfileLevel);//生成初始数据 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL, _ScreenRecordingProfileLevel);//生成初始数据
} // }
else // else
{ // {
_ScreenRecordingProfileLevel = screenRecordingProfileLevel; // _ScreenRecordingProfileLevel = screenRecordingProfileLevel;
} // }
return _ScreenRecordingProfileLevel; // return _ScreenRecordingProfileLevel;
} // }
set // set
{ // {
_ScreenRecordingProfileLevel = value; // _ScreenRecordingProfileLevel = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL, value);//生成保存本地 // storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL, value);//生成保存本地
if (PropertyChanged != null) // if (PropertyChanged != null)
{ // {
PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingProfileLevel")); // PropertyChanged(this, new PropertyChangedEventArgs("ScreenRecordingProfileLevel"));
} // }
} // }
} //}
/// <summary> /// <summary>
/// 录制倒计时 /// 录制倒计时
@ -536,7 +536,7 @@ namespace JianGongYun.TRTC.ViewModels
var liveFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_FPS);//本地缓存 var liveFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_FPS);//本地缓存
if (string.IsNullOrEmpty(liveFps)) if (string.IsNullOrEmpty(liveFps))
{ {
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, _LiveFps.ToString());//生成初始数据 storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_FPS, _LiveFps.ToString());//生成初始数据
} }
else else
{ {
@ -556,10 +556,42 @@ namespace JianGongYun.TRTC.ViewModels
} }
} }
/// <summary> /// <summary>
/// 摄像画面级别 /// 网络调控策略
/// </summary> /// </summary>
private TRTCVideoQosPreference _LiveMainLevel = TRTCVideoQosPreference.TRTCVideoQosPreferenceClear; private TRTCVideoQosPreference _LiveMainQos = TRTCVideoQosPreference.TRTCVideoQosPreferenceClear;
public TRTCVideoQosPreference LiveMainLevel public TRTCVideoQosPreference LiveMainQos
{
get
{
var liveMainQos = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_QOS);//本地缓存
if (string.IsNullOrEmpty(liveMainQos))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_QOS, _LiveMainQos.ToString());//生成初始数据
}
else
{
_LiveMainQos = (TRTCVideoQosPreference)Enum.Parse(typeof(TRTCVideoQosPreference), liveMainQos);
}
return _LiveMainQos;
}
set
{
_LiveMainQos = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_QOS, value.ToString());//生成保存本地
//var pars = MainQosParams;
//LiveClassroom.lTRTCCloud.setNetworkQosParam(ref pars);//重设参数
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveMainQos"));
}
}
}
/// <summary>
/// 摄像头画质
/// </summary>
private LiveLevelEnum _LiveMainLevel = LiveLevelEnum.High;
public LiveLevelEnum LiveMainLevel
{ {
get get
{ {
@ -570,7 +602,7 @@ namespace JianGongYun.TRTC.ViewModels
} }
else else
{ {
_LiveMainLevel = (TRTCVideoQosPreference)Enum.Parse(typeof(TRTCVideoQosPreference), liveMainLevel); _LiveMainLevel = (LiveLevelEnum)Enum.Parse(typeof(LiveLevelEnum), liveMainLevel);
} }
return _LiveMainLevel; return _LiveMainLevel;
} }
@ -578,14 +610,41 @@ namespace JianGongYun.TRTC.ViewModels
{ {
_LiveMainLevel = value; _LiveMainLevel = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_LEVEL, value.ToString());//生成保存本地 storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_LEVEL, value.ToString());//生成保存本地
var pars = QosParams;
LiveClassroom.lTRTCCloud.setNetworkQosParam(ref pars);//重设参数
if (PropertyChanged != null) if (PropertyChanged != null)
{ {
PropertyChanged(this, new PropertyChangedEventArgs("LiveMainLevel")); PropertyChanged(this, new PropertyChangedEventArgs("LiveMainLevel"));
} }
} }
} }
/// <summary>
/// 屏幕分享画质
/// </summary>
private LiveLevelEnum _LiveSubLevel = LiveLevelEnum.High;
public LiveLevelEnum LiveSubLevel
{
get
{
var liveSubLevel = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_LEVEL);//本地缓存
if (string.IsNullOrEmpty(liveSubLevel))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_LEVEL, _LiveSubLevel.ToString());//生成初始数据
}
else
{
_LiveSubLevel = (LiveLevelEnum)Enum.Parse(typeof(LiveLevelEnum), liveSubLevel);
}
return _LiveSubLevel;
}
set
{
_LiveSubLevel = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_LEVEL, value.ToString());//生成保存本地
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveSubLevel"));
}
}
}
///// <summary> ///// <summary>
///// 摄像画面帧率 ///// 摄像画面帧率
@ -711,27 +770,71 @@ namespace JianGongYun.TRTC.ViewModels
#endregion #endregion
#region #region
public TRTCVideoEncParam EncParams public TRTCVideoEncParam MainEncParams
{ {
get get
{ {
return new TRTCVideoEncParam { enableAdjustRes = false, resMode = TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape, videoBitrate = LiveMainBitrate, videoFps = LiveMainFps }; var videoResolution = TRTCVideoResolution.TRTCVideoResolution_1280_720;
uint videoBitrate = 1600;
switch (LiveMainLevel)
{
case LiveLevelEnum.Low:
videoResolution = TRTCVideoResolution.TRTCVideoResolution_640_480;
videoBitrate = 600;
break;
case LiveLevelEnum.Mormal:
videoResolution = TRTCVideoResolution.TRTCVideoResolution_960_720;
videoBitrate = 1000;
break;
case LiveLevelEnum.High:
break;
}
return new TRTCVideoEncParam { enableAdjustRes = false, resMode = TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape, videoResolution = videoResolution, minVideoBitrate = videoBitrate, videoBitrate = videoBitrate, videoFps = LiveFps };
} }
} }
public TRTCNetworkQosParam QosParams public TRTCVideoEncParam SubEncParams
{ {
get get
{ {
return new TRTCNetworkQosParam { preference = LiveMainLevel }; var videoResolution = TRTCVideoResolution.TRTCVideoResolution_1920_1080;
uint videoBitrate = 2000;
switch (LiveMainLevel)
{
case LiveLevelEnum.Low:
videoResolution = TRTCVideoResolution.TRTCVideoResolution_960_540;
videoBitrate = 850;
break;
case LiveLevelEnum.Mormal:
videoResolution = TRTCVideoResolution.TRTCVideoResolution_1280_720;
videoBitrate = 1600;
break;
case LiveLevelEnum.High:
break;
}
return new TRTCVideoEncParam { enableAdjustRes = false, resMode = TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape, videoResolution = videoResolution, minVideoBitrate = videoBitrate, videoBitrate = videoBitrate, videoFps = LiveFps };
} }
} }
public TRTCRenderParams RenderParams public TRTCNetworkQosParam MainQosParams
{
get
{
return new TRTCNetworkQosParam { preference = LiveMainQos };
}
}
public TRTCRenderParams MainRenderParams
{ {
get get
{ {
return new TRTCRenderParams { fillMode = TRTCVideoFillMode.TRTCVideoFillMode_Fill, mirrorType = TRTCVideoMirrorType.TRTCVideoMirrorType_Enable, rotation = TRTCVideoRotation.TRTCVideoRotation0 }; return new TRTCRenderParams { fillMode = TRTCVideoFillMode.TRTCVideoFillMode_Fill, mirrorType = TRTCVideoMirrorType.TRTCVideoMirrorType_Enable, rotation = TRTCVideoRotation.TRTCVideoRotation0 };
} }
} }
public TRTCRenderParams SubRenderParams
{
get
{
return new TRTCRenderParams { fillMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit, mirrorType = TRTCVideoMirrorType.TRTCVideoMirrorType_Enable, rotation = TRTCVideoRotation.TRTCVideoRotation0 };
}
}
#endregion #endregion
#region #region
@ -788,24 +891,26 @@ namespace JianGongYun.TRTC.ViewModels
private const string INI_KEY_CHOOSE_MIC = "INI_KEY_CHOOSE_MIC";//当前麦克风 private const string INI_KEY_CHOOSE_MIC = "INI_KEY_CHOOSE_MIC";//当前麦克风
private const string INI_KEY_CHOOSE_CAMERA = "INI_KEY_CHOOSE_CAMERA";//当前摄像头 private const string INI_KEY_CHOOSE_CAMERA = "INI_KEY_CHOOSE_CAMERA";//当前摄像头
private const string INI_KEY_AUDIO_MIC_VOLUME = "INI_KEY_AUDIO_MIC_VOLUME";//麦克风音量 private const string INI_KEY_AUDIO_MIC_VOLUME = "INI_KEY_AUDIO_MIC_VOLUME";//麦克风音量
private const string INI_KEY_AUDIO_SPEAKER_VOLUME = "INI_KEY_AUDIO_SOURCE";//播放音量 //private const string INI_KEY_AUDIO_SPEAKER_VOLUME = "INI_KEY_AUDIO_SOURCE";//播放音量
private const string INI_KEY_AUDIO_SOURCE = "INI_KEY_AUDIO_SOURCE";//音频来源 private const string INI_KEY_AUDIO_SOURCE = "INI_KEY_AUDIO_SOURCE";//音频来源
private const string INI_KEY_AUDIO_SYSTEM_GATHER_VOLUME = "INI_KEY_AUDIO_SYSTEM_GATHER_VOLUME";//麦克风音量 private const string INI_KEY_AUDIO_SYSTEM_GATHER_VOLUME = "INI_KEY_AUDIO_SYSTEM_GATHER_VOLUME";//麦克风音量
//录屏 //录屏
private const string INI_KEY_SCREEN_RECORDING_FPS = "INI_KEY_SCREEN_RECORDING_FPS";//视频帧率(fps) //private const string INI_KEY_SCREEN_RECORDING_FPS = "INI_KEY_SCREEN_RECORDING_FPS";//视频帧率(fps)
private const string INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE = "INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE";//音频码率 //private const string INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE = "INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE";//音频码率
private const string INI_KEY_SCREEN_RECORDING_AUDIO_FREQ = "INI_KEY_SCREEN_RECORDING_AUDIO_FREQ";//音频采样率 //private const string INI_KEY_SCREEN_RECORDING_AUDIO_FREQ = "INI_KEY_SCREEN_RECORDING_AUDIO_FREQ";//音频采样率
private const string INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL = "INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL";//编码级别 //private const string INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL = "INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL";//编码级别
private const string INI_KEY_SCREEN_RECORDING_COUNTDOWN = "INI_KEY_SCREEN_RECORDING_COUNTDOWN";//录制倒计时 private const string INI_KEY_SCREEN_RECORDING_COUNTDOWN = "INI_KEY_SCREEN_RECORDING_COUNTDOWN";//录制倒计时
private const string INI_KEY_SCREEN_RECORDING_DIR = "INI_KEY_SCREEN_RECORDING_DIR";//录制保存路径 private const string INI_KEY_SCREEN_RECORDING_DIR = "INI_KEY_SCREEN_RECORDING_DIR";//录制保存路径
//直播 //直播
private const string INI_KEY_LIVE_AUDIO_LEVEL = "INI_KEY_LIVE_AUDIO_LEVEL";//直播音频等级 private const string INI_KEY_LIVE_AUDIO_LEVEL = "INI_KEY_LIVE_AUDIO_LEVEL";//直播音频等级
private const string INI_KEY_LIVE_FPS = "INI_KEY_LIVE_FPS";//直播帧率 private const string INI_KEY_LIVE_FPS = "INI_KEY_LIVE_FPS";//直播帧率
private const string INI_KEY_LIVE_MAIN_FPS = "INI_KEY_LIVE_MAIN_FPS";//直播主帧率 //private const string INI_KEY_LIVE_MAIN_FPS = "INI_KEY_LIVE_MAIN_FPS";//直播主帧率
private const string INI_KEY_LIVE_MAIN_BITTRATE = "INI_KEY_LIVE_MAIN_BITTRATE";//直播主码率 //private const string INI_KEY_LIVE_MAIN_BITTRATE = "INI_KEY_LIVE_MAIN_BITTRATE";//直播主码率
private const string INI_KEY_LIVE_MAIN_LEVEL = "INI_KEY_LIVE_MAIN_LEVEL";//主画面级别 private const string INI_KEY_LIVE_MAIN_QOS = "INI_KEY_LIVE_MAIN_QOS";//网络调控策略
private const string INI_KEY_LIVE_SUB_FPS = "INI_KEY_LIVE_SUB_FPS";//屏幕分享帧率 private const string INI_KEY_LIVE_MAIN_LEVEL = "INI_KEY_LIVE_MAIN_LEVEL";//摄像头画质
private const string INI_KEY_LIVE_SUB_BITTRATE = "INI_KEY_LIVE_SUB_BITTRATE";//屏幕分享码率 private const string INI_KEY_LIVE_SUB_LEVEL = "INI_KEY_LIVE_SUB_LEVEL";//屏幕画质
//private const string INI_KEY_LIVE_SUB_FPS = "INI_KEY_LIVE_SUB_FPS";//屏幕分享帧率
//private const string INI_KEY_LIVE_SUB_BITTRATE = "INI_KEY_LIVE_SUB_BITTRATE";//屏幕分享码率
#endregion #endregion

View File

@ -139,16 +139,32 @@
<ComboBoxItem Content="12" /> <ComboBoxItem Content="12" />
<ComboBoxItem Content="15" /> <ComboBoxItem Content="15" />
<ComboBoxItem Content="20" /> <ComboBoxItem Content="20" />
<ComboBoxItem Content="24" /> <!--<ComboBoxItem Content="24" />-->
</Metro:AduComboBox> </Metro:AduComboBox>
</DockPanel> </DockPanel>
<DockPanel Style="{StaticResource SettingItem}"> <DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 网络调控策略</TextBlock> <TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 网络调控策略</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Tag" SelectedValue="{Binding Path=LiveMainLevel}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}"> <Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Tag" SelectedValue="{Binding Path=LiveMainQos}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="弱网下保流畅" Tag="TRTCVideoQosPreferenceSmooth" /> <ComboBoxItem Content="弱网下保流畅" Tag="TRTCVideoQosPreferenceSmooth" />
<ComboBoxItem Content="弱网下保清晰" Tag="TRTCVideoQosPreferenceClear"/> <ComboBoxItem Content="弱网下保清晰" Tag="TRTCVideoQosPreferenceClear"/>
</Metro:AduComboBox> </Metro:AduComboBox>
</DockPanel> </DockPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 摄像头画质</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Tag" SelectedValue="{Binding LiveMainLevel}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="低" Tag="Low" />
<ComboBoxItem Content="中" Tag="Mormal"/>
<ComboBoxItem Content="高" Tag="High"/>
</Metro:AduComboBox>
</DockPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 屏幕分享画质</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Tag" SelectedValue="{Binding LiveSubLevel}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="低" Tag="Low" />
<ComboBoxItem Content="中" Tag="Mormal"/>
<ComboBoxItem Content="高" Tag="High"/>
</Metro:AduComboBox>
</DockPanel>
<!--<DockPanel Style="{StaticResource SettingItem}"> <!--<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 摄像画面帧率(fps)</TextBlock> <TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 摄像画面帧率(fps)</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding LiveMainFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}"> <Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding LiveMainFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">