History

Support dynamic bitrate

duncanthrax committed 7 years ago

Commit 263da991 parent 9fe175e7 files · +46 −43Browse files

Unified · Split

7 files
  1. Install/driver/Scream.inf +1 −1
  2. Install/driver/Scream.sys +0 −0
  3. Install/driver/scream.cat +0 −0
  4. Receivers/dotnet-windows/ScreamReader/ScreamReader/App.config +3 −3
  5. Receivers/dotnet-windows/ScreamReader/ScreamReader/Properties/Settings.Designer.cs +9 −13
  6. Receivers/dotnet-windows/ScreamReader/ScreamReader/ScreamReader.csproj +7 −1
  7. Receivers/dotnet-windows/ScreamReader/ScreamReader/UdpWaveStreamPlayer.cs +28 −27
Install/driver/Scream.inf+1−1
@@ -3,7 +3,7 @@ Signature="$CHICAGO$" · 2 unmodified lines
3Class=MEDIA3Class=MEDIA
4Provider=%SCR%4Provider=%SCR%
5ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}5ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
6DriverVer = 06/02/2018,23.38.3.9826DriverVer = 11/29/2018,21.2.39.303
7CatalogFile=scream.cat7CatalogFile=scream.cat
8 8
9[SourceDisksNames]9[SourceDisksNames]
Install/driver/Scream.sys+0−0

Binary file not shown.

Install/driver/scream.cat+0−0

Binary file not shown.

Receivers/dotnet-windows/ScreamReader/ScreamReader/App.config+3−3
@@ -1,6 +1,6 @@
1<?xml version="1.0" encoding="utf-8" ?>1<?xml version="1.0" encoding="utf-8"?>
2<configuration>2<configuration>
3 <startup> 3 <startup>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
5 </startup>5 </startup>
6</configuration>6</configuration>
Receivers/dotnet-windows/ScreamReader/ScreamReader/Properties/Settings.Designer.cs+9−13
@@ -8,21 +8,17 @@ · 7 unmodified lines
8// </auto-generated>8// </auto-generated>
9//------------------------------------------------------------------------------9//------------------------------------------------------------------------------
10 10
11namespace ScreamReader.Properties11namespace ScreamReader.Properties {
12{12
13 13
14
15 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]14 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]15 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
17 internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase16 internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
18 {17
19
20 private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));18 private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 19
22 public static Settings Default20 public static Settings Default {
23 {21 get {
24 get
25 {
26 return defaultInstance;22 return defaultInstance;
27 }23 }
28 }24 }
Receivers/dotnet-windows/ScreamReader/ScreamReader/ScreamReader.csproj+7−1
@@ -8,9 +8,10 @@ · 7 unmodified lines
8 <OutputType>WinExe</OutputType>8 <OutputType>WinExe</OutputType>
9 <RootNamespace>ScreamReader</RootNamespace>9 <RootNamespace>ScreamReader</RootNamespace>
10 <AssemblyName>ScreamReader</AssemblyName>10 <AssemblyName>ScreamReader</AssemblyName>
11 <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>11 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <FileAlignment>512</FileAlignment>12 <FileAlignment>512</FileAlignment>
13 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>13 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14 <TargetFrameworkProfile />
14 </PropertyGroup>15 </PropertyGroup>
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">16 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 <PlatformTarget>AnyCPU</PlatformTarget>17 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -21,6 +22,7 @@ · 4 unmodified lines
21 <DefineConstants>DEBUG;TRACE</DefineConstants>22 <DefineConstants>DEBUG;TRACE</DefineConstants>
22 <ErrorReport>prompt</ErrorReport>23 <ErrorReport>prompt</ErrorReport>
23 <WarningLevel>4</WarningLevel>24 <WarningLevel>4</WarningLevel>
25 <Prefer32Bit>false</Prefer32Bit>
24 </PropertyGroup>26 </PropertyGroup>
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">27 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <PlatformTarget>AnyCPU</PlatformTarget>28 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,6 +32,10 @@ · 3 unmodified lines
30 <DefineConstants>TRACE</DefineConstants>32 <DefineConstants>TRACE</DefineConstants>
31 <ErrorReport>prompt</ErrorReport>33 <ErrorReport>prompt</ErrorReport>
32 <WarningLevel>4</WarningLevel>34 <WarningLevel>4</WarningLevel>
35 <Prefer32Bit>false</Prefer32Bit>
36 </PropertyGroup>
37 <PropertyGroup>
38 <StartupObject />
33 </PropertyGroup>39 </PropertyGroup>
34 <ItemGroup>40 <ItemGroup>
35 <Reference Include="NAudio, Version=1.8.3.0, Culture=neutral, processorArchitecture=MSIL">41 <Reference Include="NAudio, Version=1.8.3.0, Culture=neutral, processorArchitecture=MSIL">
Receivers/dotnet-windows/ScreamReader/ScreamReader/UdpWaveStreamPlayer.cs+28−27
@@ -20,11 +20,6 @@ namespace ScreamReader · 19 unmodified lines
20 /// The port scream is broadcasting on.20 /// The port scream is broadcasting on.
21 /// </summary>21 /// </summary>
22 public static readonly int ScreamMulticastPort = 4010;22 public static readonly int ScreamMulticastPort = 4010;
23
24 /// <summary>
25 /// Default <see cref="waveFormat"/> is 44.1 kHz, 16 bits, stereo.
26 /// </summary>
27 public static readonly WaveFormat ScreamWaveFormat = new WaveFormat();
28 #endregion23 #endregion
29 24
30 #region instance variables25 #region instance variables
@@ -37,12 +32,7 @@ namespace ScreamReader · 6 unmodified lines
37 /// The port to listen to.32 /// The port to listen to.
38 /// </summary>33 /// </summary>
39 protected int multicastPort { get; set; }34 protected int multicastPort { get; set; }
40 35
41 /// <summary>
42 /// The used <see cref="waveFormat"/>.
43 /// </summary>
44 protected WaveFormat waveFormat { get; set; }
45
46 private Semaphore startLock;36 private Semaphore startLock;
47 37
48 private Semaphore shutdownLock;38 private Semaphore shutdownLock;
@@ -81,7 +71,7 @@ namespace ScreamReader · 32 unmodified lines
81 /// Default c'tor that supports Scream's default settings.71 /// Default c'tor that supports Scream's default settings.
82 /// </summary>72 /// </summary>
83 public UdpWaveStreamPlayer()73 public UdpWaveStreamPlayer()
84 : this(ScreamMulticastAddress, ScreamMulticastPort, ScreamWaveFormat)74 : this(ScreamMulticastAddress, ScreamMulticastPort)
85 {75 {
86 }76 }
87 77
@@ -90,26 +80,18 @@ namespace ScreamReader · 2 unmodified lines
90 /// </summary>80 /// </summary>
91 /// <param name="multicastAddress"></param>81 /// <param name="multicastAddress"></param>
92 /// <param name="multicastPort"></param>82 /// <param name="multicastPort"></param>
93 /// <param name="waveFormat"></param>83 public UdpWaveStreamPlayer(IPAddress multicastAddress, int multicastPort)
94 public UdpWaveStreamPlayer(IPAddress multicastAddress, int multicastPort, WaveFormat waveFormat)
95 {84 {
96 this.multicastAddress = multicastAddress;85 this.multicastAddress = multicastAddress;
97 this.multicastPort = multicastPort;86 this.multicastPort = multicastPort;
98 this.waveFormat = waveFormat;
99 87
100 this.startLock = new Semaphore(1, 1);88 this.startLock = new Semaphore(1, 1);
101 this.shutdownLock = new Semaphore(0, 1);89 this.shutdownLock = new Semaphore(0, 1);
102 this.output = new WaveOut()90
103 {
104 DesiredLatency = 80
105 };
106
107 this.udpClient = new UdpClient91 this.udpClient = new UdpClient
108 {92 {
109 ExclusiveAddressUse = false93 ExclusiveAddressUse = false
110 };94 };
111
112 this.Volume = 100;
113 }95 }
114 96
115 /// <summary>97 /// <summary>
@@ -123,17 +105,21 @@ namespace ScreamReader · 7 unmodified lines
123 105
124 Task.Factory.StartNew(() =>106 Task.Factory.StartNew(() =>
125 {107 {
108 var currentRate = 129;
109 var currentWidth = 16;
126 var localEp = new IPEndPoint(IPAddress.Any, this.multicastPort);110 var localEp = new IPEndPoint(IPAddress.Any, this.multicastPort);
127 111
128 this.udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);112 this.udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
129 this.udpClient.Client.Bind(localEp);113 this.udpClient.Client.Bind(localEp);
130 this.udpClient.JoinMulticastGroup(this.multicastAddress);114 this.udpClient.JoinMulticastGroup(this.multicastAddress);
131 115
116 var rsws = new BufferedWaveProvider(new WaveFormat(44100, 16, 2)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true };
132 117
133 var rsws = new BufferedWaveProvider(new WaveFormat())118 this.output = new WaveOut()
134 {119 {
135 BufferDuration = TimeSpan.FromMilliseconds(500)120 DesiredLatency = 200
136 };121 };
122 this.Volume = 100;
137 123
138 this.output.Init(rsws);124 this.output.Init(rsws);
139 this.output.Play();125 this.output.Play();
@@ -145,15 +131,31 @@ namespace ScreamReader · 5 unmodified lines
145 try131 try
146 {132 {
147 Byte[] data = this.udpClient.Receive(ref localEp);133 Byte[] data = this.udpClient.Receive(ref localEp);
148 rsws.AddSamples(data, 0, data.Length);134
135 if (data[0] != currentRate || data[1] != currentWidth)
136 {
137 currentRate = data[0];
138 currentWidth = data[1];
139 this.output.Stop();
140 var rate = ((currentRate >= 128) ? 44100 : 48000) * (currentRate % 128);
141 rsws = new BufferedWaveProvider(new WaveFormat(rate, currentWidth, 2)) { BufferDuration = TimeSpan.FromMilliseconds(200), DiscardOnBufferOverflow = true };
142 this.output = new WaveOut()
143 {
144 DesiredLatency = 200
145 };
146 this.Volume = 100;
147 this.output.Init(rsws);
148 this.output.Play();
149 }
150 rsws.AddSamples(data, 2, data.Length - 2);
149 } catch (SocketException) { } // Usually when interrupted151 } catch (SocketException) { } // Usually when interrupted
150 }152 }
151 }, this.cancellationTokenSource.Token);153 }, this.cancellationTokenSource.Token);
152 154
153 this.shutdownLock.WaitOne();155 this.shutdownLock.WaitOne();
154 156
155 this.udpClient.Close();
156 this.output.Stop();157 this.output.Stop();
158 this.udpClient.Close();
157 }, this.cancellationTokenSource.Token);159 }, this.cancellationTokenSource.Token);
158 }160 }
159 161
@@ -177,7 +179,6 @@ namespace ScreamReader · 17 unmodified lines
177 {179 {
178 if (disposing)180 if (disposing)
179 {181 {
180 this.udpClient.Dispose();
181 this.startLock.Dispose();182 this.startLock.Dispose();
182 this.shutdownLock.Dispose();183 this.shutdownLock.Dispose();
183 }184 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t