diff --git a/GoogleCast.SampleApp/GoogleCast.SampleApp.csproj b/GoogleCast.SampleApp/GoogleCast.SampleApp.csproj index beedc2f..5447afb 100644 --- a/GoogleCast.SampleApp/GoogleCast.SampleApp.csproj +++ b/GoogleCast.SampleApp/GoogleCast.SampleApp.csproj @@ -28,6 +28,6 @@ - + \ No newline at end of file diff --git a/GoogleCast.SampleApp/MainViewModel.cs b/GoogleCast.SampleApp/MainViewModel.cs index ddf1b85..2d051da 100644 --- a/GoogleCast.SampleApp/MainViewModel.cs +++ b/GoogleCast.SampleApp/MainViewModel.cs @@ -237,7 +237,8 @@ private async Task ConnectAsync() var selectedReceiver = SelectedReceiver; if (selectedReceiver != null) { - await Sender.ConnectAsync(selectedReceiver); + //await Sender.ConnectAsync(selectedReceiver); + await Sender.ConnectAsync("192.168.3.142", 8009); return true; } return false; diff --git a/GoogleCast.sln b/GoogleCast.sln index 37a3a45..25b6bff 100644 --- a/GoogleCast.sln +++ b/GoogleCast.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleCast", "GoogleCast\GoogleCast.csproj", "{0B336E66-C5C4-47B7-BD45-85847CCEF991}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleCastIP", "GoogleCast\GoogleCastIP.csproj", "{0B336E66-C5C4-47B7-BD45-85847CCEF991}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleCast.SampleApp", "GoogleCast.SampleApp\GoogleCast.SampleApp.csproj", "{347B2A0B-04B1-40D7-A63E-D0077A651306}" EndProject diff --git a/GoogleCast/DeviceLocator.cs b/GoogleCast/DeviceLocator.cs index 647d481..f85dca3 100644 --- a/GoogleCast/DeviceLocator.cs +++ b/GoogleCast/DeviceLocator.cs @@ -24,6 +24,7 @@ private Receiver CreateReceiver(IZeroconfHost host) { Id = properties["id"], FriendlyName = properties["fn"], + ModelName = properties["md"], IPEndPoint = new IPEndPoint(IPAddress.Parse(host.IPAddress), service.Port) }; } diff --git a/GoogleCast/GoogleCast.csproj b/GoogleCast/GoogleCastIP.csproj similarity index 83% rename from GoogleCast/GoogleCast.csproj rename to GoogleCast/GoogleCastIP.csproj index 650a9ac..88d2968 100644 --- a/GoogleCast/GoogleCast.csproj +++ b/GoogleCast/GoogleCastIP.csproj @@ -7,14 +7,14 @@ True False key.pfx - Stéphane Mitermite - Stéphane Mitermite + Saqib Khan + SmartAzan Implementation of the Google Cast protocol (.NET Standard 2.0 library). Copyright © 2021 Stéphane Mitermite https://github.com/kakone/GoogleCast google cast googlecast chromecast True - 1.7.0 + 1.9 https://github.com/kakone/GoogleCast AGPL-3.0-only GoogleCast.png @@ -37,6 +37,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/GoogleCast/ISender.cs b/GoogleCast/ISender.cs index 22b5fe6..50b6eee 100644 --- a/GoogleCast/ISender.cs +++ b/GoogleCast/ISender.cs @@ -30,6 +30,19 @@ public interface ISender /// receiver Task ConnectAsync(IReceiver receiver); + + /// + /// Connects to a receiver using IP Address + /// + /// + /// + /// + Task ConnectAsync(string ipAddress, int port); + + /// + /// + + /// /// Disconnects /// diff --git a/GoogleCast/Receiver.cs b/GoogleCast/Receiver.cs index ae75700..11f5490 100644 --- a/GoogleCast/Receiver.cs +++ b/GoogleCast/Receiver.cs @@ -17,6 +17,11 @@ public class Receiver : IReceiver /// public string FriendlyName { get; set; } = default!; + /// + /// Gets or sets the Model name + /// + public string ModelName { get; set; } = default!; + /// /// Gets or sets the network endpoint /// diff --git a/GoogleCast/Sender.cs b/GoogleCast/Sender.cs index 08bdb50..118ff84 100644 --- a/GoogleCast/Sender.cs +++ b/GoogleCast/Sender.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Net; using System.Net.Security; using System.Net.Sockets; using System.Runtime.CompilerServices; @@ -136,6 +137,25 @@ public async Task ConnectAsync(IReceiver receiver) await GetChannel().ConnectAsync(); } + /// + public async Task ConnectAsync(string ipAddress, int port) + { + Dispose(); + + + var tcpClient = new TcpClient(); + TcpClient = tcpClient; + + var host = ipAddress; + await tcpClient.ConnectAsync(host, port); + var secureStream = new SslStream(tcpClient.GetStream(), true, (sender, certificate, chain, sslPolicyErrors) => true); + await secureStream.AuthenticateAsClientAsync(host); + NetworkStream = secureStream; + + Receive(); + await GetChannel().ConnectAsync(); + } + private void Receive() { var cancellationTokenSource = new CancellationTokenSource();