本地录制开关

This commit is contained in:
lxmou666 2021-02-13 14:01:34 +08:00
parent df03186995
commit 32d79cd4d0
5 changed files with 77 additions and 29 deletions

View File

@ -204,7 +204,7 @@ namespace JianGongYun.TRTC
lTRTCCloud.startLocalPreview(IntPtr.Zero);
liveWinMode.CameraRunning = true;
var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeBig, true);
if (liveWinMode.IsLive)
if (liveWinMode.IsLive && settingWindowViewModel.LocalRecorder)
{
view.OnRenderVideoFrameHandler += (data, w, h) =>
{
@ -255,7 +255,7 @@ namespace JianGongYun.TRTC
SelectVieoSub();
lTRTCCloud.startScreenCapture(IntPtr.Zero, TRTCVideoStreamType.TRTCVideoStreamTypeSub, settingWindowViewModel.SubEncParams);
var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeSub, true);
if (liveWinMode.IsLive)
if (liveWinMode.IsLive && settingWindowViewModel.LocalRecorder)
{
view.OnRenderVideoFrameHandler += (data, w, h) =>
{
@ -338,7 +338,10 @@ namespace JianGongYun.TRTC
{
liveWinMode.MicRunning = true;
lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel);
StartRecordAudio();
if (settingWindowViewModel.LocalRecorder)
{
StartRecordAudio();
}
StartMUX();
}
@ -372,7 +375,10 @@ namespace JianGongYun.TRTC
if (liveWinMode.MicRunning)
{
liveWinMode.MicRunning = false;
StopRecordAudio();
if (settingWindowViewModel.LocalRecorder)
{
StopRecordAudio();
}
lTRTCCloud.stopLocalAudio();
}
}
@ -721,13 +727,13 @@ namespace JianGongYun.TRTC
ITRTCCloud.destroyTRTCShareInstance();//销毁TRTC实例
lTRTCCloud.Dispose();
lTRTCCloud = null;
if (CallerWindow == null)
{
//关闭程序
Application.Current.Shutdown();
return;
}
CallerWindow.Close();//直接关闭
//if (CallerWindow == null)
//{
// //关闭程序
// Application.Current.Shutdown();
// return;
//}
//CallerWindow.Close();//直接关闭
Application.Current.Shutdown();
}

View File

@ -428,6 +428,38 @@ namespace JianGongYun.TRTC.ViewModels
// }
//}
/// <summary>
/// 本地录制
/// </summary>
private bool _LocalRecorder = false;
public bool LocalRecorder
{
get
{
var localRecorder = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER);//本地缓存
if (string.IsNullOrEmpty(localRecorder))
{
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER, _LocalRecorder.ToString());//生成初始数据
}
else
{
_LocalRecorder = bool.Parse(localRecorder);
}
return _LocalRecorder;
}
set
{
_LocalRecorder = value;
storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER, value.ToString());//生成保存本地
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("LocalRecorder"));
}
}
}
/// <summary>
/// 录制倒计时
/// </summary>
@ -899,6 +931,7 @@ namespace JianGongYun.TRTC.ViewModels
//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_PROFILE_LEVEL = "INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL";//编码级别
private const string INI_KEY_SCREEN_LOCALRECORDER = "INI_KEY_SCREEN_LOCALRECORDER";//本地录制
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";//录制保存路径
//直播

View File

@ -137,7 +137,7 @@
<TextBlock Width="{Binding ElementName=CameraPrew,Path=ActualWidth}" Canvas.Bottom="0" Canvas.Left="0" Padding="5" FontSize="14" Foreground="#cccccc" Background="#65888888" TextAlignment="Center">摄像头预览</TextBlock>
</Canvas>
</Grid>
<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="2">
<!--<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="2">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel Margin="0 0 0 20" HorizontalAlignment="Center" Orientation="Horizontal">
<Path Width="30" Height="35" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Camera}" />
@ -146,20 +146,20 @@
</StackPanel>
<Metro:AduRadioButton x:Name="Rad1" Click="Tpye_Click" GroupName="LiveType" Foreground="#cccccc" Content="摄像头+屏幕分享" FontSize="14" IconWidth="16" IsChecked="{Binding LiveType,Converter={StaticResource LiveTypeConverter},ConverterParameter=CameraAndScreen}" />
</StackPanel>
</Grid>
<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="3">
</Grid>-->
<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="2">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 30" Width="30" Height="30" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Screen}" />
<Metro:AduRadioButton x:Name="Rad2" Click="Tpye_Click" GroupName="LiveType" Foreground="#cccccc" Content="屏幕分享" FontSize="14" IconWidth="16" IsChecked="{Binding LiveType,Converter={StaticResource LiveTypeConverter},ConverterParameter=OnlyScreen}" />
</StackPanel>
</Grid>
<Grid Margin="5" Background="#2f3035" Grid.Row="1" Grid.Column="2">
<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="3">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 25" Width="30" Height="35" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Camera}" />
<Metro:AduRadioButton x:Name="Rad3" Click="Tpye_Click" GroupName="LiveType" Foreground="#cccccc" Content="摄像头" FontSize="14" IconWidth="16" IsChecked="{Binding LiveType,Converter={StaticResource LiveTypeConverter},ConverterParameter=OnlyCamera}" />
</StackPanel>
</Grid>
<Grid Margin="5" Background="#2f3035" Grid.Row="1" Grid.Column="3">
<Grid Margin="5" Background="#2f3035" Grid.Row="1" Grid.Column="2">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 15" Width="30" Height="45" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Mic}" />
<Metro:AduRadioButton x:Name="Rad4" Click="Tpye_Click" GroupName="LiveType" Foreground="#cccccc" Content="仅声音" FontSize="14" IconWidth="16" IsChecked="{Binding LiveType,Converter={StaticResource LiveTypeConverter},ConverterParameter=OnlyAudio}" />

View File

@ -48,7 +48,7 @@ namespace JianGongYun.TRTC.Windows
base.OnActivated(e);
//颜色前台设置无效,手动调用才行
var color = (SolidColorBrush)(new BrushConverter().ConvertFrom("#cccccc"));
Rad1.Foreground = color;
//Rad1.Foreground = color;
Rad2.Foreground = color;
Rad3.Foreground = color;
Rad4.Foreground = color;
@ -155,7 +155,10 @@ namespace JianGongYun.TRTC.Windows
LiveClassroom.StartVideoSub(AfterLiveSubViewWrap);
}
LiveClassroom.StartMic();
LiveClassroom.VideoRecordTask(ref onEnd);//启动录制
if (SettingWindowViewModel.LocalRecorder)
{
LiveClassroom.VideoRecordTask(ref onEnd);//启动录制
}
LiveClassroom.SetMicMute(false);
}, SettingWindowViewModel.ScreenRecordingCountdown);
@ -169,12 +172,11 @@ namespace JianGongYun.TRTC.Windows
LiveClassroom.StopVideoMain(AfterLiveViewWrap);
LiveClassroom.StopVideoSub(AfterLiveSubViewWrap);
this.Hide();
if (LiveClassroom.CallerWindow == null) {
Application.Current.Shutdown();
return;
if (onEnd == null)
{
this.Close();
}
LiveClassroom.CallerWindow.Show();//还原调用者窗口
//LiveClassroom.CallerWindow.Show();//还原调用者窗口
}
}

View File

@ -100,6 +100,13 @@
<ComboBoxItem Content="高级画质" Tag="-profile:v high -level 5.1"/>
</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 LocalRecorder}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
<ComboBoxItem Content="关闭" Tag="False" />
<ComboBoxItem Content="开启" Tag="True" />
</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 ScreenRecordingCountdown}" ComBoxItemPanelBackground="{StaticResource ComboBoxBrush}">
@ -153,17 +160,17 @@
<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"/>
<ComboBoxItem Content="低(640x480)" Tag="Low" />
<ComboBoxItem Content="中(960x720)" Tag="Mormal"/>
<ComboBoxItem Content="高(1280x720)" 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"/>
<ComboBoxItem Content="低(960x540)" Tag="Low" />
<ComboBoxItem Content="中(1280x720)" Tag="Mormal"/>
<ComboBoxItem Content="高(1920x1080)" Tag="High"/>
</Metro:AduComboBox>
</DockPanel>
<!--<DockPanel Style="{StaticResource SettingItem}">