This commit is contained in:
lxmou666 2020-12-31 17:35:34 +08:00
parent b36c183e2d
commit b5da99ae9e
3 changed files with 241 additions and 133 deletions

View File

@ -392,10 +392,6 @@ namespace JianGongYun.TRTC
/// </summary>
public static void ResetVideoMain() { }
/// <summary>
/// 重设主视频(摄像头)网络
/// </summary>
public static void ResetVideoMainQos() { }
/// <summary>
/// 重设副视频(录屏)
/// </summary>
public static void ResetVideoSub() { }

View File

@ -34,15 +34,28 @@ namespace JianGongYun.TRTC.ViewModels
/// <summary>
/// 直播主窗口viewmodel
/// </summary>
private LiveWindowViewModel LiveWindowViewModel
//private LiveWindowViewModel LiveWindowViewModel
//{
// get
// {
// return LiveClassroom.CurrentLiveWindow.DataContext == null ? null : LiveClassroom.CurrentLiveWindow.DataContext as LiveWindowViewModel;
// }
//}
#region
private List<ComboBoxEntity> LoadDeviceList(TRTCDeviceType deviceType)
{
get
var devices = LiveClassroom.lTXDeviceManager.getDevicesList(deviceType);
List<ComboBoxEntity> devicesList = new List<ComboBoxEntity>();
var count = devices.getCount();
for (uint i = 0; i < count; i++)
{
return LiveClassroom.CurrentLiveWindow.DataContext == null ? null : LiveClassroom.CurrentLiveWindow.DataContext as LiveWindowViewModel;
var temp = new ComboBoxEntity { Id = devices.getDevicePID(i), Text = devices.getDeviceName(i) };
devicesList.Add(temp);
}
return devicesList;
}
#region
/// <summary>
/// 集合,实时获取
/// </summary>
@ -50,15 +63,7 @@ namespace JianGongYun.TRTC.ViewModels
{
get
{
var mics = LiveClassroom.lTXDeviceManager.getDevicesList(ManageLiteAV.TRTCDeviceType.TXMediaDeviceTypeMic);
List<ComboBoxEntity> micList = new List<ComboBoxEntity>();
var count = mics.getCount();
for (uint i = 0; i < count; i++)
{
var temp = new ComboBoxEntity { Id = mics.getDevicePID(i), Text = mics.getDeviceName(i) };
micList.Add(temp);
}
return micList;
return LoadDeviceList(TRTCDeviceType.TXMediaDeviceTypeMic);
}
}
@ -242,6 +247,63 @@ namespace JianGongYun.TRTC.ViewModels
}
/// <summary>
/// 集合,实时获取
/// </summary>
public List<ComboBoxEntity> CameraList
{
get
{
return LoadDeviceList(TRTCDeviceType.TXMediaDeviceTypeCamera);
}
}
/// <summary>
/// 当前
/// </summary>
private string _CurrentCamera;
public string CurrentCamera
{
get
{
var tempList = this.CameraList;
if (tempList.Count == 0)
{
return null;
}
if (string.IsNullOrEmpty(_CurrentCamera) || !tempList.Any(a => a.Id == _CurrentCamera))//第一次取或者设备发生变动找不到上次的选择
{
var localCamera = storage.GetValue(INI_ROOT_KEY, INI_KEY_CHOOSE_CAMERA);//本地缓存
if (string.IsNullOrEmpty(localCamera))//本地没有就取第一个
{
_CurrentCamera = tempList.First().Id;
storage.SetValue(INI_ROOT_KEY, INI_KEY_CHOOSE_CAMERA, _CurrentCamera);//生成初始数据
}
else
{
_CurrentCamera = localCamera;
var temp = tempList.Where(a => a.Id == localCamera).FirstOrDefault();
if (temp == null)//找不到上次缓存的设备就取第一个
{
_CurrentCamera = tempList.First().Id;
storage.SetValue(INI_ROOT_KEY, INI_KEY_CHOOSE_CAMERA, _CurrentCamera);//生成初始数据
}
}
}
return _CurrentCamera;
}
set
{
_CurrentCamera = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_CHOOSE_CAMERA, value);//生成保存本地
LiveClassroom.lTXDeviceManager.setCurrentDevice(ManageLiteAV.TRTCDeviceType.TXMediaDeviceTypeCamera, _CurrentCamera);//设置麦克
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("CurrentCamera"));
}
}
}
#endregion
#region
@ -435,7 +497,7 @@ namespace JianGongYun.TRTC.ViewModels
/// <summary>
/// 音频质量
/// </summary>
private TRTCAudioQuality _LiveAudioLevel = TRTCAudioQuality.TRTCAudioQualityDefault;
private TRTCAudioQuality _LiveAudioLevel = TRTCAudioQuality.TRTCAudioQualityMusic;
public TRTCAudioQuality LiveAudioLevel
{
get
@ -455,70 +517,41 @@ namespace JianGongYun.TRTC.ViewModels
{
_LiveAudioLevel = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_AUDIO_LEVEL, value.ToString());//生成保存本地
LiveClassroom.RestartAudio();//重启音频
//LiveClassroom.RestartAudio();//重启音频
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveAudioLevel"));
}
}
}
/// <summary>
/// 摄像画面帧率
/// </summary>
private uint _LiveMainFps = 24;
public uint LiveMainFps
private uint _LiveFps = 24;
public uint LiveFps
{
get
{
var liveMainFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS);//本地缓存
if (string.IsNullOrEmpty(liveMainFps))
var liveFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_FPS);//本地缓存
if (string.IsNullOrEmpty(liveFps))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, _LiveMainFps.ToString());//生成初始数据
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, _LiveFps.ToString());//生成初始数据
}
else
{
_LiveMainFps = uint.Parse(liveMainFps);
_LiveFps = uint.Parse(liveFps);
}
return _LiveMainFps;
return _LiveFps;
}
set
{
_LiveMainFps = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, value.ToString());//生成保存本地
_LiveFps = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_FPS, value.ToString());//生成保存本地
LiveClassroom.ResetVideoMain();//重设参数
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveMainFps"));
}
}
}
/// <summary>
/// 摄像画面码率
/// </summary>
private uint _LiveMainBitrate = 1600;
public uint LiveMainBitrate
{
get
{
var liveMainBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE);//本地缓存
if (string.IsNullOrEmpty(liveMainBitrate))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE, _LiveMainBitrate.ToString());//生成初始数据
}
else
{
_LiveMainBitrate = uint.Parse(liveMainBitrate);
}
return _LiveMainBitrate;
}
set
{
_LiveMainBitrate = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE, value.ToString());//生成保存本地
LiveClassroom.ResetVideoMain();//重设参数
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveMainBitrate"));
PropertyChanged(this, new PropertyChangedEventArgs("LiveFps"));
}
}
}
@ -545,73 +578,136 @@ namespace JianGongYun.TRTC.ViewModels
{
_LiveMainLevel = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_LEVEL, value.ToString());//生成保存本地
LiveClassroom.ResetVideoMainQos();//重设参数
var pars = QosParams;
LiveClassroom.lTRTCCloud.setNetworkQosParam(ref pars);//重设参数
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveMainLevel"));
}
}
}
/// <summary>
/// 屏幕分享帧率
/// </summary>
private uint _LiveSubFps = 24;
public uint LiveSubFps
{
get
{
var liveSubFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS);//本地缓存
if (string.IsNullOrEmpty(liveSubFps))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS, _LiveSubFps.ToString());//生成初始数据
}
else
{
_LiveSubFps = uint.Parse(liveSubFps);
}
return _LiveSubFps;
}
set
{
_LiveSubFps = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS, value.ToString());//生成保存本地
LiveClassroom.ResetVideoSub();//重新设置副画面参数
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveSubFps"));
}
}
}
/// <summary>
/// 屏幕分享码率
/// </summary>
private uint _LiveSubBitrate = 2000;
public uint LiveSubBitrate
{
get
{
var liveSubBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE);//本地缓存
if (string.IsNullOrEmpty(liveSubBitrate))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE, _LiveSubBitrate.ToString());//生成初始数据
}
else
{
_LiveSubBitrate = uint.Parse(liveSubBitrate);
}
return _LiveSubBitrate;
}
set
{
_LiveSubBitrate = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE, value.ToString());//生成保存本地
LiveClassroom.ResetVideoSub();//重启音频
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LiveSubBitrate"));
}
}
}
///// <summary>
///// 摄像画面帧率
///// </summary>
//private uint _LiveMainFps = 24;
//public uint LiveMainFps
//{
// get
// {
// var liveMainFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS);//本地缓存
// if (string.IsNullOrEmpty(liveMainFps))
// {
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, _LiveMainFps.ToString());//生成初始数据
// }
// else
// {
// _LiveMainFps = uint.Parse(liveMainFps);
// }
// return _LiveMainFps;
// }
// set
// {
// _LiveMainFps = value;
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_FPS, value.ToString());//生成保存本地
// LiveClassroom.ResetVideoMain();//重设参数
// if (PropertyChanged != null)
// {
// PropertyChanged(this, new PropertyChangedEventArgs("LiveMainFps"));
// }
// }
//}
///// <summary>
///// 摄像画面码率
///// </summary>
//private uint _LiveMainBitrate = 1600;
//public uint LiveMainBitrate
//{
// get
// {
// var liveMainBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE);//本地缓存
// if (string.IsNullOrEmpty(liveMainBitrate))
// {
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE, _LiveMainBitrate.ToString());//生成初始数据
// }
// else
// {
// _LiveMainBitrate = uint.Parse(liveMainBitrate);
// }
// return _LiveMainBitrate;
// }
// set
// {
// _LiveMainBitrate = value;
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_MAIN_BITTRATE, value.ToString());//生成保存本地
// LiveClassroom.ResetVideoMain();//重设参数
// if (PropertyChanged != null)
// {
// PropertyChanged(this, new PropertyChangedEventArgs("LiveMainBitrate"));
// }
// }
//}
///// <summary>
///// 屏幕分享帧率
///// </summary>
//private uint _LiveSubFps = 24;
//public uint LiveSubFps
//{
// get
// {
// var liveSubFps = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS);//本地缓存
// if (string.IsNullOrEmpty(liveSubFps))
// {
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS, _LiveSubFps.ToString());//生成初始数据
// }
// else
// {
// _LiveSubFps = uint.Parse(liveSubFps);
// }
// return _LiveSubFps;
// }
// set
// {
// _LiveSubFps = value;
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_FPS, value.ToString());//生成保存本地
// LiveClassroom.ResetVideoSub();//重新设置副画面参数
// if (PropertyChanged != null)
// {
// PropertyChanged(this, new PropertyChangedEventArgs("LiveSubFps"));
// }
// }
//}
///// <summary>
///// 屏幕分享码率
///// </summary>
//private uint _LiveSubBitrate = 2000;
//public uint LiveSubBitrate
//{
// get
// {
// var liveSubBitrate = storage.GetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE);//本地缓存
// if (string.IsNullOrEmpty(liveSubBitrate))
// {
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE, _LiveSubBitrate.ToString());//生成初始数据
// }
// else
// {
// _LiveSubBitrate = uint.Parse(liveSubBitrate);
// }
// return _LiveSubBitrate;
// }
// set
// {
// _LiveSubBitrate = value;
// storage.SetValue(INI_ROOT_KEY, INI_KEY_LIVE_SUB_BITTRATE, value.ToString());//生成保存本地
// LiveClassroom.ResetVideoSub();//重启音频
// if (PropertyChanged != null)
// {
// PropertyChanged(this, new PropertyChangedEventArgs("LiveSubBitrate"));
// }
// }
//}
#endregion
#region
@ -688,8 +784,9 @@ namespace JianGongYun.TRTC.ViewModels
private string sPath = ".\\TRTCConfig.ini";
//根节点
private const string INI_ROOT_KEY = "TRTCLOCALCONFIG";
//音频
//设备
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_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_SOURCE = "INI_KEY_AUDIO_SOURCE";//音频来源
@ -703,6 +800,7 @@ namespace JianGongYun.TRTC.ViewModels
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_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_BITTRATE = "INI_KEY_LIVE_MAIN_BITTRATE";//直播主码率
private const string INI_KEY_LIVE_MAIN_LEVEL = "INI_KEY_LIVE_MAIN_LEVEL";//主画面级别

View File

@ -11,7 +11,7 @@
<Metro:MetroWindow.Resources>
<DataTemplate x:Key="CusHeaderTitle1">
<TextBlock Foreground="#aaaaaa" FontWeight="Bold" Background="Transparent">音频设置</TextBlock>
<TextBlock Foreground="#aaaaaa" FontWeight="Bold" Background="Transparent">设备设置</TextBlock>
</DataTemplate>
<DataTemplate x:Key="CusHeaderTitle2">
<TextBlock Foreground="#aaaaaa" FontWeight="Bold" Background="Transparent">录屏设置</TextBlock>
@ -26,8 +26,12 @@
IndicatorSelectedIndex="0" IndicatorPlacement="Left">
<Metro:MetroScrollViewer HorizontalScrollBarVisibility="Disabled">
<StackPanel Background="#232428">
<Metro:AduGroupBoxNor HeaderTemplate="{StaticResource CusHeaderTitle1}" Header="音频设置" HeaderBackground="Transparent" BorderThickness="0" BorderBrush="{StaticResource DefaultBorderBrush}" FontSize="14" HeaderPadding="10,6">
<Metro:AduGroupBoxNor HeaderTemplate="{StaticResource CusHeaderTitle1}" Header="设备设置" HeaderBackground="Transparent" BorderThickness="0" BorderBrush="{StaticResource DefaultBorderBrush}" FontSize="14" HeaderPadding="10,6">
<StackPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 摄像头</TextBlock>
<Metro:AduComboBox ItemsSource="{Binding CameraList,Mode=OneWay}" DisplayMemberPath="Text" SelectedValuePath="Id" SelectedValue="{Binding CurrentMic,Mode=TwoWay}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}"></Metro:AduComboBox>
</DockPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 麦克风</TextBlock>
<Metro:AduFlatButton Content="检测麦克风" x:Name="MicTestBtn" Click="TestMic" Width="100" DockPanel.Dock="Right" Margin=" 11 0 10 0" Type="info" />
@ -52,7 +56,7 @@
</Metro:AduGroupBoxNor>
<Metro:AduGroupBoxNor HeaderTemplate="{StaticResource CusHeaderTitle2}" Header="录屏设置" HeaderBackground="Transparent" BorderThickness="0" BorderBrush="{StaticResource DefaultBorderBrush}" FontSize="14" HeaderPadding="10,6">
<StackPanel>
<DockPanel Style="{StaticResource SettingItem}">
<!--<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 视频帧率(fps)</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding ScreenRecordingFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="10" />
@ -95,7 +99,7 @@
<ComboBoxItem Content="主流画质" Tag="-profile:v main -level 4.2"/>
<ComboBoxItem Content="高级画质" Tag="-profile:v high -level 5.1"/>
</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 ScreenRecordingCountdown}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
@ -129,6 +133,23 @@
</Metro:AduComboBox>
</DockPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 帧率(fps)</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding LiveFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="10" />
<ComboBoxItem Content="12" />
<ComboBoxItem Content="15" />
<ComboBoxItem Content="20" />
<ComboBoxItem Content="24" />
</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 Path=LiveMainLevel}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="弱网下保流畅" Tag="TRTCVideoQosPreferenceSmooth" />
<ComboBoxItem Content="弱网下保清晰" Tag="TRTCVideoQosPreferenceClear"/>
</Metro:AduComboBox>
</DockPanel>
<!--<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 摄像画面帧率(fps)</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding LiveMainFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="10" />
@ -146,13 +167,6 @@
<ComboBoxItem Content="1600Kbps" Tag="1600"/>
</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 Path=LiveMainLevel}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="弱网下保流畅" Tag="TRTCVideoQosPreferenceSmooth" />
<ComboBoxItem Content="弱网下保清晰" Tag="TRTCVideoQosPreferenceClear"/>
</Metro:AduComboBox>
</DockPanel>
<DockPanel Style="{StaticResource SettingItem}">
<TextBlock Style="{StaticResource SettingItemText}" DockPanel.Dock="Left"> 屏幕分享帧率(fps)</TextBlock>
<Metro:AduComboBox Margin="0 0 10 0" SelectedValuePath="Content" SelectedValue="{Binding LiveSubFps}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
@ -170,7 +184,7 @@
<ComboBoxItem Content="1600Kbps" Tag="1600"/>
<ComboBoxItem Content="2000Kbps" Tag="2000"/>
</Metro:AduComboBox>
</DockPanel>
</DockPanel>-->
</StackPanel>
</Metro:AduGroupBoxNor>
</StackPanel>