Skip to content

Commit

Permalink
Update 20190930.1
Browse files Browse the repository at this point in the history
设备信息结构移到独立类文件。
增加码率设置功能(不支持保存)。
命名空间调整。
  • Loading branch information
TGSAN committed Sep 30, 2019
1 parent c751371 commit f077624
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
16 changes: 16 additions & 0 deletions MirrorCaster/DeviceInfoData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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;
}
}
2 changes: 1 addition & 1 deletion MirrorCaster/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 24 additions & 10 deletions MirrorCaster/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading;
using Microsoft.VisualBasic;

namespace StdDemo
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 partial class MainForm : Form
{
private const uint WS_EX_LAYERED = 0x80000;
Expand Down Expand Up @@ -82,6 +76,8 @@ bool is_casting
DeviceInfoData deviceInfoData = new DeviceInfoData(); // device info form adb
DeviceInfoData instart_deviceInfoData = new DeviceInfoData(); // device info at start cast

double castMbitRate = 15; // 16M适中

public static NamedPipeClientStream client;

public MainForm()
Expand All @@ -94,7 +90,25 @@ public MainForm()

private void StartCastButton_Click(object sender, EventArgs e)
{
StartCastAction();
string inputText = string.Empty;
try
{
inputText = Interaction.InputBox("请输入投屏码率(Mbps):\r\n\r\n<10:适合互联网传输\r\n<30:适合一般手机通过USB传输\r\n<100:适合编码能力强的手机通过家庭局域网(百兆)内传输\r\n<=200:适合编码能力超强的手机通过USB传输\r\n\r\n建议值:15", "准备投屏", $"{castMbitRate}", -1, -1);
castMbitRate = double.Parse(inputText);
if (castMbitRate <= 0 || castMbitRate > 200)
{
MessageBox.Show("码率(Mbps)必须大于0且不超过200", "警告");
}
else
{
StartCastAction();
}
}
catch
{
if (inputText.Length > 0)
MessageBox.Show("请输入正确的码率(Mbps)", "警告");
}
}

private void StartCastAction()
Expand Down Expand Up @@ -159,7 +173,7 @@ private void StdOut()
//stdout_process.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=16000000 --output-format=h264 --size {deviceInfoData.device_width.ToString()}x{deviceInfoData.device_height.ToString()} - ;done\""; //
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;
Expand Down
2 changes: 2 additions & 0 deletions MirrorCaster/MirrorCaster.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -47,6 +48,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DeviceInfoData.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion MirrorCaster/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StdDemo
namespace MirrorCaster
{
static class Program
{
Expand Down
2 changes: 1 addition & 1 deletion MirrorCaster/StreamPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace StdDemo
namespace MirrorCaster
{
class StreamPipe
{
Expand Down

0 comments on commit f077624

Please sign in to comment.