Closed ghost closed 3 years ago
Please check the IWindow interface. It contains the RTCPeerConnection creation call: IRTCPeerConnection RTCPeerConnection(RTCConfiguration configuration = null);
Here is an example of how to create RTCPeerConnection:
var webRtc = CrossWebRtc.Current;
var window = webRtc.Window(/*jsRuntime - for Blazor only*/);
var configuration = new RTCConfiguration
{
IceServers = new RTCIceServer
{
Urls = new string[]
{
"stun:stun.stunprotocol.org:3478",
"stun:stun.l.google.com:19302"
}
};
};
peerConnection = window.RTCPeerConnection(configuration);
You can create the data channel as follows:
var dataChannel = peerConnection.CreateDataChannel(
"Channel name here",
new RTCDataChannelInit
{
Negotiated = false,
});
Currently there is no Xamarin UWP or macOS support. Please check WebRTCme plugin source code; only Android and iOS. Blazor can be used on Windows/macOS.
Thanks, do you have any plans to add support for Xamarin UWP and macOS? I'm not very familiar with Blazor but reading this: "Blazor runs on .NET Standard 2.0 so you can share your .NET code with most other .NET apps." makes me think it might be possible to use the Blazor NuGet on Xamarin.Forms as well, do you think that might be possible with WebRTCme?
Not on the short term. Similar to Android and iOS, the desktop bindings shall be created for that.
Blazor NuGet will not run on Forms. Blazor is using JS Interop to access WebRTC functionality embedded into the browser. Blazor is not that hard:) And WebRTCme is using the same API for Xamarin and Blazor. So the code from my first message will be OK for Blazor too, with a parameter addition to Window() call ==> Window(jsRuntime).
I'm making a desktop application that requires WebRTC on macOS and UWP and it's being developed in Xamarin.Forms since its not possible to add Blazor code and nugets directly to Xamarin.Forms i will have to wait for the desktop bindings being implemented. I was very glad to find this library it seems to be the only cross platform WebRTC solution. I've been trying to build the source code from google and implementing my own bindings, but have not been successful, so i will definitely be watching for the desktop bindings in the future. Thanks for the help with the code and info.
You are welcome.
It is possible to run hybrid code (Blazor with Xamarin). Worth to check I believe. https://docs.microsoft.com/en-us/mobile-blazor-bindings/
Another option will be running Blazor code as desktop using Electron: https://www.youtube.com/watch?v=6MjxgbmTAAM
.NET6 will support Blazor Desktop out of the box: https://visualstudiomagazine.com/articles/2021/02/17/net-6-preview-1.aspx
can this be used now for Maui Windows and MacCatalyst
can this be used now for Maui Windows and MacCatalyst
Currently, there is limited support for both. The core library (WebRTCme) can be used on Windows and Mac. They both employ the SipSorcery library. It was not the ideal solution I wanted, but this is how it is now. No support yet on Middleware and DemoApp layers.
I've been looking at the samples and I can't find any usage of the low level objects/functions like RTCPeerConnection, my aim is to create a RTCPeerConnection and data channel to communicate like a simple chat, but the WebRTCme nuget only seems to have an IRTCPeerConnection interface., is this possible with this library? Also I'm intending to use this on Xamarin UWP and Xamarin.Mac, will this work?