本地录制开关

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); 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);
if (liveWinMode.IsLive) if (liveWinMode.IsLive && settingWindowViewModel.LocalRecorder)
{ {
view.OnRenderVideoFrameHandler += (data, w, h) => view.OnRenderVideoFrameHandler += (data, w, h) =>
{ {
@ -255,7 +255,7 @@ namespace JianGongYun.TRTC
SelectVieoSub(); SelectVieoSub();
lTRTCCloud.startScreenCapture(IntPtr.Zero, TRTCVideoStreamType.TRTCVideoStreamTypeSub, settingWindowViewModel.SubEncParams); 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 && settingWindowViewModel.LocalRecorder)
{ {
view.OnRenderVideoFrameHandler += (data, w, h) => view.OnRenderVideoFrameHandler += (data, w, h) =>
{ {
@ -338,7 +338,10 @@ namespace JianGongYun.TRTC
{ {
liveWinMode.MicRunning = true; liveWinMode.MicRunning = true;
lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel); lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel);
StartRecordAudio(); if (settingWindowViewModel.LocalRecorder)
{
StartRecordAudio();
}
StartMUX(); StartMUX();
} }
@ -372,7 +375,10 @@ namespace JianGongYun.TRTC
if (liveWinMode.MicRunning) if (liveWinMode.MicRunning)
{ {
liveWinMode.MicRunning = false; liveWinMode.MicRunning = false;
StopRecordAudio(); if (settingWindowViewModel.LocalRecorder)
{
StopRecordAudio();
}
lTRTCCloud.stopLocalAudio(); lTRTCCloud.stopLocalAudio();
} }
} }
@ -721,13 +727,13 @@ namespace JianGongYun.TRTC
ITRTCCloud.destroyTRTCShareInstance();//销毁TRTC实例 ITRTCCloud.destroyTRTCShareInstance();//销毁TRTC实例
lTRTCCloud.Dispose(); lTRTCCloud.Dispose();
lTRTCCloud = null; lTRTCCloud = null;
if (CallerWindow == null) //if (CallerWindow == null)
{ //{
//关闭程序 // //关闭程序
Application.Current.Shutdown(); // Application.Current.Shutdown();
return; // return;
} //}
CallerWindow.Close();//直接关闭 //CallerWindow.Close();//直接关闭
Application.Current.Shutdown(); 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>
/// 录制倒计时 /// 录制倒计时
/// </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_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_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_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";//录制保存路径
//直播 //直播

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> <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> </Canvas>
</Grid> </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 VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel Margin="0 0 0 20" HorizontalAlignment="Center" Orientation="Horizontal"> <StackPanel Margin="0 0 0 20" HorizontalAlignment="Center" Orientation="Horizontal">
<Path Width="30" Height="35" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Camera}" /> <Path Width="30" Height="35" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Camera}" />
@ -146,20 +146,20 @@
</StackPanel> </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}" /> <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> </StackPanel>
</Grid> </Grid>-->
<Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="3"> <Grid Margin="5" Background="#2f3035" Grid.Row="0" Grid.Column="2">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 30" Width="30" Height="30" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Screen}" /> <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}" /> <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> </StackPanel>
</Grid> </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"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 25" Width="30" Height="35" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Camera}" /> <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}" /> <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> </StackPanel>
</Grid> </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"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Margin="0 0 0 15" Width="30" Height="45" Fill="#cccccc" Shape.Stretch="Fill" Data="{StaticResource Icon_Mic}" /> <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}" /> <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); base.OnActivated(e);
//颜色前台设置无效,手动调用才行 //颜色前台设置无效,手动调用才行
var color = (SolidColorBrush)(new BrushConverter().ConvertFrom("#cccccc")); var color = (SolidColorBrush)(new BrushConverter().ConvertFrom("#cccccc"));
Rad1.Foreground = color; //Rad1.Foreground = color;
Rad2.Foreground = color; Rad2.Foreground = color;
Rad3.Foreground = color; Rad3.Foreground = color;
Rad4.Foreground = color; Rad4.Foreground = color;
@ -155,7 +155,10 @@ namespace JianGongYun.TRTC.Windows
LiveClassroom.StartVideoSub(AfterLiveSubViewWrap); LiveClassroom.StartVideoSub(AfterLiveSubViewWrap);
} }
LiveClassroom.StartMic(); LiveClassroom.StartMic();
LiveClassroom.VideoRecordTask(ref onEnd);//启动录制 if (SettingWindowViewModel.LocalRecorder)
{
LiveClassroom.VideoRecordTask(ref onEnd);//启动录制
}
LiveClassroom.SetMicMute(false); LiveClassroom.SetMicMute(false);
}, SettingWindowViewModel.ScreenRecordingCountdown); }, SettingWindowViewModel.ScreenRecordingCountdown);
@ -169,12 +172,11 @@ namespace JianGongYun.TRTC.Windows
LiveClassroom.StopVideoMain(AfterLiveViewWrap); LiveClassroom.StopVideoMain(AfterLiveViewWrap);
LiveClassroom.StopVideoSub(AfterLiveSubViewWrap); LiveClassroom.StopVideoSub(AfterLiveSubViewWrap);
this.Hide(); if (onEnd == null)
if (LiveClassroom.CallerWindow == null) { {
Application.Current.Shutdown(); this.Close();
return;
} }
LiveClassroom.CallerWindow.Show();//还原调用者窗口 //LiveClassroom.CallerWindow.Show();//还原调用者窗口
} }
} }

View File

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