This commit is contained in:
parent
7c47e0ea0f
commit
8d8cb28d66
|
@ -105,6 +105,7 @@ namespace JianGongYun.TRTC.Components
|
||||||
mLocalView = false;
|
mLocalView = false;
|
||||||
mFirstFrame = false;
|
mFirstFrame = false;
|
||||||
mRenderMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
mRenderMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit;
|
||||||
|
this.OnViewRemove?.Invoke();
|
||||||
this.InvalidateVisual();
|
this.InvalidateVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +232,7 @@ namespace JianGongYun.TRTC.Components
|
||||||
/// 渲染回调int width, int height, int rotation,WriteableBitmap image
|
/// 渲染回调int width, int height, int rotation,WriteableBitmap image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<WriteableBitmap> OnRenderVideoFrameHandler;
|
public event Action<WriteableBitmap> OnRenderVideoFrameHandler;
|
||||||
|
public event Action OnViewRemove;
|
||||||
|
|
||||||
private void RenderFillMode(DrawingContext dc, byte[] data, int width, int height, int rotation)
|
private void RenderFillMode(DrawingContext dc, byte[] data, int width, int height, int rotation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Window = System.Windows.Window;
|
using Window = System.Windows.Window;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace JianGongYun.TRTC
|
namespace JianGongYun.TRTC
|
||||||
{
|
{
|
||||||
|
@ -234,10 +235,13 @@ namespace JianGongYun.TRTC
|
||||||
{
|
{
|
||||||
liveWinMode.MicRunning = true;
|
liveWinMode.MicRunning = true;
|
||||||
lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel);
|
lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel);
|
||||||
if (liveWinMode.IsLive)
|
if (liveWinMode.IsLive && !liveWinMode.AudioRecordRunning)
|
||||||
{
|
{
|
||||||
var pars = new TRTCAudioRecordingParams { filePath = "" };
|
liveWinMode.AudioRecordRunning = true;
|
||||||
lTRTCCloud.startAudioRecording(ref pars);
|
var time = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
||||||
|
var pars = new TRTCAudioRecordingParams { filePath = Path.Combine(RecoderDir, $"{time}audio.pcm") };
|
||||||
|
var res = lTRTCCloud.startAudioRecording(ref pars);
|
||||||
|
Console.WriteLine(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,6 +253,11 @@ namespace JianGongYun.TRTC
|
||||||
if (liveWinMode.MicRunning)
|
if (liveWinMode.MicRunning)
|
||||||
{
|
{
|
||||||
liveWinMode.MicRunning = false;
|
liveWinMode.MicRunning = false;
|
||||||
|
if (liveWinMode.AudioRecordRunning)
|
||||||
|
{
|
||||||
|
liveWinMode.AudioRecordRunning = false;
|
||||||
|
lTRTCCloud.stopAudioRecording();
|
||||||
|
}
|
||||||
lTRTCCloud.stopLocalAudio();
|
lTRTCCloud.stopLocalAudio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,8 +281,10 @@ 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.RenderParams.fillMode : TRTCVideoFillMode.TRTCVideoFillMode_Fit);
|
||||||
videoView.Width = parent.ActualWidth;
|
//videoView.Width = parent.ActualWidth;
|
||||||
videoView.Height = parent.ActualHeight;
|
videoView.SetBinding(TXLiteAVVideoView.WidthProperty, new Binding("ActualWidth") { Source = parent });
|
||||||
|
//videoView.Height = parent.ActualHeight;
|
||||||
|
videoView.SetBinding(TXLiteAVVideoView.HeightProperty, new Binding("ActualHeight") { Source = parent });
|
||||||
parent.Dispatcher.Invoke(new Action(() =>
|
parent.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
parent.Children.Add(videoView);
|
parent.Children.Add(videoView);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
@ -18,7 +19,7 @@ namespace JianGongYun.TRTC.Utils
|
||||||
{
|
{
|
||||||
using (MemoryStream outStream = new MemoryStream())
|
using (MemoryStream outStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
BitmapEncoder enc = new JpegBitmapEncoder();
|
BitmapEncoder enc = new PngBitmapEncoder();
|
||||||
enc.Frames.Add(BitmapFrame.Create(writeableBitmap));
|
enc.Frames.Add(BitmapFrame.Create(writeableBitmap));
|
||||||
enc.Save(outStream);
|
enc.Save(outStream);
|
||||||
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(outStream))
|
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(outStream))
|
||||||
|
@ -28,5 +29,20 @@ namespace JianGongYun.TRTC.Utils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// WriteableBitmap转Bitmap
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writeableBitmap"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Bitmap ToBitmap(this WriteableBitmap writeableBitmap)
|
||||||
|
{
|
||||||
|
using (MemoryStream outStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
BitmapEncoder enc = new PngBitmapEncoder();
|
||||||
|
enc.Frames.Add(BitmapFrame.Create(writeableBitmap));
|
||||||
|
enc.Save(outStream);
|
||||||
|
return new System.Drawing.Bitmap(outStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,25 @@ namespace JianGongYun.TRTC.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 麦克风录音中
|
||||||
|
/// </summary>
|
||||||
|
private bool _AudioRecordRunning = false;
|
||||||
|
public bool AudioRecordRunning
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_AudioRecordRunning = value;
|
||||||
|
if (PropertyChanged != null)
|
||||||
|
{
|
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs("AudioRecordRunning"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _AudioRecordRunning;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 麦克风静音
|
/// 麦克风静音
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool _MicMute = false;
|
private bool _MicMute = false;
|
||||||
|
|
|
@ -32,8 +32,8 @@ namespace JianGongYun.TRTC.Windows
|
||||||
public LiveWindow()
|
public LiveWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BeforeLiveSubViewWrap.SizeChanged += BeforeLiveSubViewWrap_SizeChanged;
|
//BeforeLiveSubViewWrap.SizeChanged += BeforeLiveSubViewWrap_SizeChanged;
|
||||||
AfterLiveSubViewWrap.SizeChanged += AfterLiveSubViewWrap_SizeChanged;
|
//AfterLiveSubViewWrap.SizeChanged += AfterLiveSubViewWrap_SizeChanged;
|
||||||
AttachConsole(-1);//把进程挂在控制台,通过命令行启动程序可以看到控制台输出
|
AttachConsole(-1);//把进程挂在控制台,通过命令行启动程序可以看到控制台输出
|
||||||
LiveWindowViewModel = new ViewModels.LiveWindowViewModel();
|
LiveWindowViewModel = new ViewModels.LiveWindowViewModel();
|
||||||
SettingWindowViewModel = ViewModels.SettingWindowViewModel.GetInstance();
|
SettingWindowViewModel = ViewModels.SettingWindowViewModel.GetInstance();
|
||||||
|
@ -41,21 +41,21 @@ namespace JianGongYun.TRTC.Windows
|
||||||
BorderBrush = new SolidColorBrush(color: Color.FromRgb(42, 43, 48));//窗口标题背景颜色
|
BorderBrush = new SolidColorBrush(color: Color.FromRgb(42, 43, 48));//窗口标题背景颜色
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AfterLiveSubViewWrap_SizeChanged(object sender, SizeChangedEventArgs e)
|
//private void AfterLiveSubViewWrap_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
{
|
//{
|
||||||
if (LiveWindowViewModel.IsLive)
|
// if (LiveWindowViewModel.IsLive)
|
||||||
{
|
// {
|
||||||
this.Dispatcher.Invoke(new Action(() => LiveClassroom.ResizeVideoSub(AfterLiveSubViewWrap)));
|
// this.Dispatcher.Invoke(new Action(() => LiveClassroom.ResizeVideoSub(AfterLiveSubViewWrap)));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
private void BeforeLiveSubViewWrap_SizeChanged(object sender, SizeChangedEventArgs e)
|
//private void BeforeLiveSubViewWrap_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
{
|
//{
|
||||||
if (!LiveWindowViewModel.IsLive)
|
// if (!LiveWindowViewModel.IsLive)
|
||||||
{
|
// {
|
||||||
this.Dispatcher.Invoke(new Action(() => LiveClassroom.ResizeVideoSub(BeforeLiveSubViewWrap)));
|
// this.Dispatcher.Invoke(new Action(() => LiveClassroom.ResizeVideoSub(BeforeLiveSubViewWrap)));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue