diff --git a/MirrorCaster/DeviceInfoData.cs b/MirrorCaster/DeviceInfoData.cs index 2f3f171..300609f 100644 --- a/MirrorCaster/DeviceInfoData.cs +++ b/MirrorCaster/DeviceInfoData.cs @@ -1,16 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MirrorCaster +namespace MirrorCaster { public class DeviceInfoData { - public int device_width = 1920; - public int device_height = 1080; - public int device_refreshRate = 60; - public bool device_vmode = false; + public int deviceWidth = 1920; + public int deviceHeight = 1080; + public int deviceRefreshRate = 60; + public bool deviceVmode = false; // 是否为竖屏状态 } } diff --git a/MirrorCaster/MainForm.Designer.cs b/MirrorCaster/MainForm.Designer.cs index d81fc27..d19139b 100644 --- a/MirrorCaster/MainForm.Designer.cs +++ b/MirrorCaster/MainForm.Designer.cs @@ -39,11 +39,12 @@ private void InitializeComponent() this.backKeyButton = new System.Windows.Forms.Button(); this.homeKeyButton = new System.Windows.Forms.Button(); this.controlPanel = new System.Windows.Forms.FlowLayoutPanel(); + this.testButton = new System.Windows.Forms.Button(); this.mutiKeyButton = new System.Windows.Forms.Button(); + this.menuKeyButton = new System.Windows.Forms.Button(); this.volUpKeyButton = new System.Windows.Forms.Button(); this.volDownKeyButton = new System.Windows.Forms.Button(); - this.menuKeyButton = new System.Windows.Forms.Button(); - this.testButton = new System.Windows.Forms.Button(); + this.startCastSingleButton = new System.Windows.Forms.Button(); this.screenBox.SuspendLayout(); this.controlPanel.SuspendLayout(); this.SuspendLayout(); @@ -62,7 +63,7 @@ private void InitializeComponent() // stopCastButton // this.stopCastButton.Enabled = false; - this.stopCastButton.Location = new System.Drawing.Point(189, 4); + this.stopCastButton.Location = new System.Drawing.Point(459, 4); this.stopCastButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.stopCastButton.Name = "stopCastButton"; this.stopCastButton.Size = new System.Drawing.Size(87, 33); @@ -104,7 +105,7 @@ private void InitializeComponent() // powerKeyButton // this.powerKeyButton.Enabled = false; - this.powerKeyButton.Location = new System.Drawing.Point(282, 4); + this.powerKeyButton.Location = new System.Drawing.Point(552, 4); this.powerKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.powerKeyButton.Name = "powerKeyButton"; this.powerKeyButton.Size = new System.Drawing.Size(87, 33); @@ -116,7 +117,7 @@ private void InitializeComponent() // backKeyButton // this.backKeyButton.Enabled = false; - this.backKeyButton.Location = new System.Drawing.Point(375, 4); + this.backKeyButton.Location = new System.Drawing.Point(645, 4); this.backKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.backKeyButton.Name = "backKeyButton"; this.backKeyButton.Size = new System.Drawing.Size(87, 33); @@ -128,7 +129,7 @@ private void InitializeComponent() // homeKeyButton // this.homeKeyButton.Enabled = false; - this.homeKeyButton.Location = new System.Drawing.Point(468, 4); + this.homeKeyButton.Location = new System.Drawing.Point(738, 4); this.homeKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.homeKeyButton.Name = "homeKeyButton"; this.homeKeyButton.Size = new System.Drawing.Size(87, 33); @@ -143,6 +144,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.controlPanel.AutoScroll = true; this.controlPanel.Controls.Add(this.startCastButton); + this.controlPanel.Controls.Add(this.startCastSingleButton); this.controlPanel.Controls.Add(this.testButton); this.controlPanel.Controls.Add(this.stopCastButton); this.controlPanel.Controls.Add(this.powerKeyButton); @@ -158,10 +160,22 @@ private void InitializeComponent() this.controlPanel.TabIndex = 6; this.controlPanel.WrapContents = false; // + // testButton + // + this.testButton.Location = new System.Drawing.Point(366, 4); + this.testButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.testButton.Name = "testButton"; + this.testButton.Size = new System.Drawing.Size(87, 33); + this.testButton.TabIndex = 15; + this.testButton.Text = "测试按钮"; + this.testButton.UseVisualStyleBackColor = true; + this.testButton.Visible = false; + this.testButton.Click += new System.EventHandler(this.testButton_Click); + // // mutiKeyButton // this.mutiKeyButton.Enabled = false; - this.mutiKeyButton.Location = new System.Drawing.Point(561, 4); + this.mutiKeyButton.Location = new System.Drawing.Point(831, 4); this.mutiKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.mutiKeyButton.Name = "mutiKeyButton"; this.mutiKeyButton.Size = new System.Drawing.Size(87, 33); @@ -170,10 +184,22 @@ private void InitializeComponent() this.mutiKeyButton.UseVisualStyleBackColor = true; this.mutiKeyButton.Click += new System.EventHandler(this.MutiKeyButton_Click); // + // menuKeyButton + // + this.menuKeyButton.Enabled = false; + this.menuKeyButton.Location = new System.Drawing.Point(924, 4); + this.menuKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.menuKeyButton.Name = "menuKeyButton"; + this.menuKeyButton.Size = new System.Drawing.Size(87, 33); + this.menuKeyButton.TabIndex = 14; + this.menuKeyButton.Text = "菜单"; + this.menuKeyButton.UseVisualStyleBackColor = true; + this.menuKeyButton.Click += new System.EventHandler(this.MenuKeyButton_Click); + // // volUpKeyButton // this.volUpKeyButton.Enabled = false; - this.volUpKeyButton.Location = new System.Drawing.Point(747, 4); + this.volUpKeyButton.Location = new System.Drawing.Point(1017, 4); this.volUpKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.volUpKeyButton.Name = "volUpKeyButton"; this.volUpKeyButton.Size = new System.Drawing.Size(87, 33); @@ -185,7 +211,7 @@ private void InitializeComponent() // volDownKeyButton // this.volDownKeyButton.Enabled = false; - this.volDownKeyButton.Location = new System.Drawing.Point(840, 4); + this.volDownKeyButton.Location = new System.Drawing.Point(1110, 4); this.volDownKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.volDownKeyButton.Name = "volDownKeyButton"; this.volDownKeyButton.Size = new System.Drawing.Size(87, 33); @@ -194,29 +220,17 @@ private void InitializeComponent() this.volDownKeyButton.UseVisualStyleBackColor = true; this.volDownKeyButton.Click += new System.EventHandler(this.VolDownKeyButton_Click); // - // menuKeyButton + // startCastSingleButton // - this.menuKeyButton.Enabled = false; - this.menuKeyButton.Location = new System.Drawing.Point(654, 4); - this.menuKeyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.menuKeyButton.Name = "menuKeyButton"; - this.menuKeyButton.Size = new System.Drawing.Size(87, 33); - this.menuKeyButton.TabIndex = 14; - this.menuKeyButton.Text = "菜单"; - this.menuKeyButton.UseVisualStyleBackColor = true; - this.menuKeyButton.Click += new System.EventHandler(this.MenuKeyButton_Click); - // - // testButton - // - this.testButton.Location = new System.Drawing.Point(96, 4); - this.testButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.testButton.Name = "testButton"; - this.testButton.Size = new System.Drawing.Size(87, 33); - this.testButton.TabIndex = 15; - this.testButton.Text = "测试按钮"; - this.testButton.UseVisualStyleBackColor = true; - this.testButton.Visible = false; - this.testButton.Click += new System.EventHandler(this.testButton_Click); + this.startCastSingleButton.Location = new System.Drawing.Point(96, 4); + this.startCastSingleButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.startCastSingleButton.Name = "startCastSingleButton"; + this.startCastSingleButton.Size = new System.Drawing.Size(264, 33); + this.startCastSingleButton.TabIndex = 16; + this.startCastSingleButton.Tag = "Single"; + this.startCastSingleButton.Text = "开始独立窗口投屏 (可用于OBS游戏源捕获)"; + this.startCastSingleButton.UseVisualStyleBackColor = true; + this.startCastSingleButton.Click += new System.EventHandler(this.startCastSingleButton_Click); // // MainForm // @@ -254,6 +268,7 @@ private void InitializeComponent() private System.Windows.Forms.Button volDownKeyButton; private System.Windows.Forms.Button menuKeyButton; private System.Windows.Forms.Button testButton; + private System.Windows.Forms.Button startCastSingleButton; } } diff --git a/MirrorCaster/MainForm.cs b/MirrorCaster/MainForm.cs index ac820c7..c3531f8 100644 --- a/MirrorCaster/MainForm.cs +++ b/MirrorCaster/MainForm.cs @@ -1,15 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; +using Microsoft.VisualBasic; +using System; +using System.Diagnostics; using System.IO.Pipes; using System.Runtime.InteropServices; -using System.Windows.Forms; -using System.Diagnostics; +using System.Text; using System.Text.RegularExpressions; using System.Threading; -using Microsoft.VisualBasic; +using System.Windows.Forms; namespace MirrorCaster { @@ -48,20 +45,19 @@ int dwFlags [DllImport("user32.dll")] private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); - Process stdout_process = new Process(); - Process stdin_process = new Process(); - StreamPipe RePipe; + private readonly Process stdoutProcess = new Process(); + private readonly Process stdinProcess = new Process(); + private StreamPipe RePipe; + private CastType castType = CastType.Internal; + private bool isCastingValue = false; - bool is_casting_value = false; - bool is_casting + private bool isCasting { - get - { - return is_casting_value; - } + get => isCastingValue; set { - is_casting_value = value; + isCastingValue = value; + stopCastButton.Enabled = value; powerKeyButton.Enabled = value; backKeyButton.Enabled = value; @@ -73,10 +69,16 @@ bool is_casting } } - DeviceInfoData deviceInfoData = new DeviceInfoData(); // device info form adb - DeviceInfoData instart_deviceInfoData = new DeviceInfoData(); // device info at start cast + private enum CastType + { + Internal, + Single + } + + private readonly DeviceInfoData deviceInfoData = new DeviceInfoData(); // device info form adb + private readonly DeviceInfoData instartDeviceInfoData = new DeviceInfoData(); // device info at start cast - double castMbitRate = 30; // 16M适中 + private double castMbitRate = 30; // 16M适中 public static NamedPipeClientStream client; @@ -88,7 +90,20 @@ public MainForm() #endif } + private void startCastSingleButton_Click(object sender, EventArgs e) + { + MessageBox.Show("关于独立窗口模式\n\n可便于OBS等直播软件抓取,因为弹出外部播放器窗口相比内建可控性更差,画面旋转及分辨率自适应已被禁用。\n\n建议先将手机处于应用横屏状态再点击“确定”按钮开始投屏。\n\n若使用OBS进行抓取,请使用:\n游戏捕获->模式:捕获特定窗口->窗口:[mpv.exe] Mirror Caster Source", "提示"); + castType = CastType.Single; + ShowConfigDialog(); + } + private void StartCastButton_Click(object sender, EventArgs e) + { + castType = CastType.Internal; + ShowConfigDialog(); + } + + private void ShowConfigDialog() { string inputText = string.Empty; try @@ -107,7 +122,9 @@ private void StartCastButton_Click(object sender, EventArgs e) catch { if (inputText.Length > 0) + { MessageBox.Show("请输入正确的码率(Mbps)", "警告"); + } } } @@ -128,11 +145,12 @@ private void StartCast() { StdOut(); StdIn(); - RePipe = new StreamPipe(stdout_process.StandardOutput.BaseStream, stdin_process.StandardInput.BaseStream); + RePipe = new StreamPipe(stdoutProcess.StandardOutput.BaseStream, stdinProcess.StandardInput.BaseStream); RePipe.Connect(); - instart_deviceInfoData.device_vmode = deviceInfoData.device_vmode; // 记录播放时的横竖屏状态(是否竖屏) - is_casting = true; + instartDeviceInfoData.deviceVmode = deviceInfoData.deviceVmode; // 记录播放时的横竖屏状态(是否竖屏) + isCasting = true; heartTimer.Enabled = true; + if (castType == CastType.Single) nosigalLabel.Text = "投屏中 (`・ω・´)"; } private void StopCast() @@ -141,49 +159,68 @@ private void StopCast() { try { - // stdout_process.OutputDataReceived -= new DataReceivedEventHandler(StdOutProcessOutDataReceived); - stdout_process.Kill(); + stdoutProcess.Exited -= StdIOProcess_Exited; + // stdoutProcess.OutputDataReceived -= new DataReceivedEventHandler(StdOutProcessOutDataReceived); + stdoutProcess.Kill(); + } + catch (Exception ex) + { + Console.WriteLine("无法关闭StdOUT," + ex.Message); } - catch { } try { - // stdin_process.OutputDataReceived -= new DataReceivedEventHandler(StdInProcessOutDataReceived); - stdin_process.Kill(); + stdinProcess.Exited -= StdIOProcess_Exited; + // stdinProcess.OutputDataReceived -= new DataReceivedEventHandler(StdInProcessOutDataReceived); + stdinProcess.Kill(); + } + catch (Exception ex) + { + Console.WriteLine("无法关闭StdIN," + ex.Message); } - catch - { } RePipe.Disconnect(); } - catch { } - is_casting = false; + catch (Exception ex) + { + Console.WriteLine("无法断开管道重定向," + ex.Message); + } + heartTimer.Enabled = false; + isCasting = false; + nosigalLabel.Text = "无信号_(:3」∠)_"; } public void SetPenetrate(IntPtr useHandle, bool flag = true) { uint style = GetWindowLong(useHandle, GWL_EXSTYLE); if (flag) + { SetWindowLong(useHandle, GWL_EXSTYLE, style | WS_EX_TRANSPARENT | WS_EX_LAYERED); + } else + { SetWindowLong(useHandle, GWL_EXSTYLE, style & ~(WS_EX_TRANSPARENT | WS_EX_LAYERED)); + } + SetLayeredWindowAttributes(useHandle, 0, 100, LWA_ALPHA); } private void StdOut() { - //stdout_process.OutputDataReceived -= new DataReceivedEventHandler(StdOutProcessOutDataReceived); + //stdoutProcess.OutputDataReceived -= new DataReceivedEventHandler(StdOutProcessOutDataReceived); // https://developer.android.com/studio/releases/platform-tools.html - stdout_process.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + @"lib\adb\adb.exe"; - stdout_process.StartInfo.Arguments = $"exec-out \"while true;do screenrecord --bit-rate={(int)(castMbitRate * 1000000)} --output-format=h264 --size {deviceInfoData.device_width.ToString()}x{deviceInfoData.device_height.ToString()} - ;done\""; // - stdout_process.StartInfo.UseShellExecute = false; - stdout_process.StartInfo.RedirectStandardOutput = true; - stdout_process.StartInfo.CreateNoWindow = true; - stdout_process.Start(); - if (stdin_process.StartInfo.FileName.Length != 0) + stdoutProcess.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + @"lib\adb\adb.exe"; + stdoutProcess.StartInfo.Arguments = $"exec-out \"while true;do screenrecord --bit-rate={(int)(castMbitRate * 1000000)} --output-format=h264 --size {deviceInfoData.deviceWidth.ToString()}x{deviceInfoData.deviceHeight.ToString()} - ;done\""; // + stdoutProcess.StartInfo.UseShellExecute = false; + stdoutProcess.StartInfo.RedirectStandardOutput = true; + stdoutProcess.StartInfo.CreateNoWindow = true; + stdoutProcess.EnableRaisingEvents = true; + stdoutProcess.Exited += StdIOProcess_Exited; + stdoutProcess.Start(); + if (stdinProcess.StartInfo.FileName.Length != 0) { - stdin_process.CancelOutputRead(); - stdin_process.Close(); + stdinProcess.CancelOutputRead(); + stdinProcess.Close(); } - //stdout_process.OutputDataReceived += new DataReceivedEventHandler(StdOutProcessOutDataReceived); + //stdoutProcess.OutputDataReceived += new DataReceivedEventHandler(StdOutProcessOutDataReceived); } private void StdOutProcessOutDataReceived(object sender, DataReceivedEventArgs e) @@ -231,28 +268,50 @@ private string ADBResult(string args) private void StdIn() { - stdin_process.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + @"lib\mpv\mpv.exe"; - stdin_process.StartInfo.Arguments = $"--hwdec=auto --opengl-glfinish=yes --opengl-swapinterval=0 --d3d11-sync-interval=0 --fps={deviceInfoData.device_refreshRate} --no-audio --framedrop=decoder --no-correct-pts --speed=2 --profile=low-latency --no-border --no-config --input-default-bindings=no --osd-level=0 -no-osc --wid={screenBox.Handle.ToInt64().ToString()} -"; - stdin_process.StartInfo.UseShellExecute = false; - stdin_process.StartInfo.RedirectStandardOutput = true; - stdin_process.StartInfo.RedirectStandardInput = true; - stdin_process.StartInfo.CreateNoWindow = true; - stdin_process.Start(); - stdin_process.BeginOutputReadLine(); - //stdin_process.OutputDataReceived += new DataReceivedEventHandler(StdInProcessOutDataReceived); + string widArg; + switch (castType) + { + case CastType.Internal: + widArg = $"--wid={screenBox.Handle.ToInt64().ToString()}"; + break; + case CastType.Single: + widArg = default; + break; + default: + widArg = default; + break; + } + stdinProcess.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + @"lib\mpv\mpv.exe"; + stdinProcess.StartInfo.Arguments = $"--title=\"Mirror Caster Source\" --no-taskbar-progress --hwdec=auto --opengl-glfinish=yes --opengl-swapinterval=0 --d3d11-sync-interval=0 --fps={deviceInfoData.deviceRefreshRate} --no-audio --framedrop=decoder --no-correct-pts --speed=2 --profile=low-latency --no-config --input-default-bindings=no --osd-level=0 --no-border -no-osc {widArg} -"; + //stdinProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; + stdinProcess.StartInfo.UseShellExecute = false; + stdinProcess.StartInfo.RedirectStandardOutput = true; + stdinProcess.StartInfo.RedirectStandardInput = true; + stdinProcess.StartInfo.CreateNoWindow = true; + stdinProcess.EnableRaisingEvents = true; + stdinProcess.Exited += StdIOProcess_Exited; + stdinProcess.Start(); + stdinProcess.BeginOutputReadLine(); + //stdinProcess.OutputDataReceived += new DataReceivedEventHandler(StdInProcessOutDataReceived); + } + + private void StdIOProcess_Exited(object sender, EventArgs e) + { + Console.WriteLine("StdIO管道被关闭,关闭投屏"); + Invoke(new Action(StopCast)); // 结束投屏需要修改UI,所以Invoke } private void StdInProcessOutDataReceived(object sender, DataReceivedEventArgs e) { try { - this.Invoke(new Action(() => + Invoke(new Action(() => { - SetParent(stdin_process.MainWindowHandle, screenBox.Handle); - SetPenetrate(stdin_process.MainWindowHandle, true); - SetParent(stdin_process.MainWindowHandle, this.Handle); + SetParent(stdinProcess.MainWindowHandle, screenBox.Handle); + SetPenetrate(stdinProcess.MainWindowHandle, true); + SetParent(stdinProcess.MainWindowHandle, Handle); // window, x, y, width, height, repaint - MoveWindow(stdin_process.MainWindowHandle, screenBox.Location.X, screenBox.Location.Y, screenBox.Width, screenBox.Height, false); + MoveWindow(stdinProcess.MainWindowHandle, screenBox.Location.X, screenBox.Location.Y, screenBox.Width, screenBox.Height, false); })); } catch { } @@ -270,14 +329,16 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e) private void Form1_Resize(object sender, EventArgs e) { - //MoveWindow(stdin_process.MainWindowHandle, screenBox.Location.X, screenBox.Location.Y, screenBox.Width, screenBox.Height, false); + //MoveWindow(stdinProcess.MainWindowHandle, screenBox.Location.X, screenBox.Location.Y, screenBox.Width, screenBox.Height, false); } private bool UpdateScreenDeviceInfo() { string str = ADBResult("shell \"dumpsys window displays && dumpsys SurfaceFlinger\"").ToLower(); if (str.StartsWith("error: no devices/emulators found")) + { return false; //MessageBox.Show("找不到任何设备或模拟器", "警告"); + } // Console.WriteLine(str); Regex regexSize = new Regex(@"\s+cur=(?[0-9]*)x(?[0-9]*?)\s+", RegexOptions.Multiline); Match matchSize = regexSize.Match(str); @@ -288,16 +349,19 @@ private bool UpdateScreenDeviceInfo() Console.WriteLine("Size成功"); try { - int width = Int32.Parse(matchSize.Groups["width"].Value); //宽 - int height = Int32.Parse(matchSize.Groups["height"].Value); //高 + int width = int.Parse(matchSize.Groups["width"].Value); //宽 + int height = int.Parse(matchSize.Groups["height"].Value); //高 bool vmode = true; //垂直 if (width > height) + { vmode = false; //水平 + } + string strFormat = string.Format("{0}*{1},是否垂直:{2}", width, height, vmode.ToString()); Console.WriteLine(strFormat); - deviceInfoData.device_width = width; - deviceInfoData.device_height = height; - deviceInfoData.device_vmode = vmode; + deviceInfoData.deviceWidth = width; + deviceInfoData.deviceHeight = height; + deviceInfoData.deviceVmode = vmode; } catch { } } @@ -309,7 +373,7 @@ private bool UpdateScreenDeviceInfo() int refreshRate = (int)double.Parse(matchRefreshRate.Groups["refreshRate"].Value); string strFormat = string.Format("刷新率:{0}", refreshRate); Console.WriteLine(strFormat); - deviceInfoData.device_refreshRate = refreshRate; + deviceInfoData.deviceRefreshRate = refreshRate; } catch { } } @@ -320,8 +384,10 @@ private void HeartTimer_Tick(object sender, EventArgs e) { if (UpdateScreenDeviceInfo()) { - if (instart_deviceInfoData.device_vmode != deviceInfoData.device_vmode) - StartCastAction(); // 如果设备info切换则重新连接(为了转换分辨率) + if (instartDeviceInfoData.deviceVmode != deviceInfoData.deviceVmode) + { + if (castType == CastType.Internal) StartCastAction(); // 如果设备info切换则重新连接(为了转换分辨率) + } } else { diff --git a/MirrorCaster/Properties/AssemblyInfo.cs b/MirrorCaster/Properties/AssemblyInfo.cs index 50fda21..2b85101 100644 --- a/MirrorCaster/Properties/AssemblyInfo.cs +++ b/MirrorCaster/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/MirrorCaster/StreamPipe.cs b/MirrorCaster/StreamPipe.cs index f28bf09..88192a3 100644 --- a/MirrorCaster/StreamPipe.cs +++ b/MirrorCaster/StreamPipe.cs @@ -1,16 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; +using System.IO; using System.Threading; using System.Threading.Tasks; namespace MirrorCaster { - class StreamPipe + internal class StreamPipe { - private const Int32 BufferSize = 4096; + private const int BufferSize = 4096; public Stream Source { get; protected set; } public Stream Destination { get; protected set; } @@ -33,9 +29,12 @@ public StreamPipe Connect() while (true) { _cancellationToken.Token.ThrowIfCancellationRequested(); - var count = await Source.ReadAsync(buffer, 0, BufferSize, _cancellationToken.Token); + int count = await Source.ReadAsync(buffer, 0, BufferSize, _cancellationToken.Token); if (count <= 0) + { break; + } + await Destination.WriteAsync(buffer, 0, count, _cancellationToken.Token); await Destination.FlushAsync(_cancellationToken.Token); } diff --git a/MirrorCaster/lib/mpv/d3dcompiler_43.dll b/MirrorCaster/lib/mpv/d3dcompiler_43.dll new file mode 100644 index 0000000..d52042a Binary files /dev/null and b/MirrorCaster/lib/mpv/d3dcompiler_43.dll differ diff --git a/MirrorCaster/lib/mpv/libaacs.dll b/MirrorCaster/lib/mpv/libaacs.dll deleted file mode 100644 index e412075..0000000 Binary files a/MirrorCaster/lib/mpv/libaacs.dll and /dev/null differ diff --git a/MirrorCaster/lib/mpv/libbdplus.dll b/MirrorCaster/lib/mpv/libbdplus.dll deleted file mode 100644 index 5e948f2..0000000 Binary files a/MirrorCaster/lib/mpv/libbdplus.dll and /dev/null differ diff --git a/MirrorCaster/lib/mpv/mpv.exe b/MirrorCaster/lib/mpv/mpv.exe index 459c40e..3aff21c 100644 Binary files a/MirrorCaster/lib/mpv/mpv.exe and b/MirrorCaster/lib/mpv/mpv.exe differ