-
Hello, I'm trying to write a program which makes use of the self defined webrtc ingest protocol to provide a webrtc stream to OME. I've had some success in receiving the offer and sending a response but I see references to SDP parsing errors and unsupported protocols in the server logs, however I can also see it appears to set up a stream.
The SDP I receive from the server is as follows.
I don't have much experience with WebRTC and its associated technologies but from what I understand
I'll post my C# code at the end which handles the signalling, its not complex so should be easy to follow even with little C# experience. One thing I'm unusre of is if I should be adding tracks before setting the remote description, for now I am with hard coded codecs and format IDs based on what the SDP usually has for VP8. If I don't add these tracks I get additional errors in the server log, this is probably down to my lack of knowledge on WebRTC.
C# // Setup buffer to read socket data into and a web socket to negotiate signalling.
// Custom verification callback to work around self signed cert.
using var buffer = MemoryPool<byte>.Shared.Rent(ushort.MaxValue);
using var socket = new ClientWebSocket();
socket.Options.RemoteCertificateValidationCallback = (object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors sslPolicyErrors) =>
{
return true;
};
// Connect to OME and request an SDP offer.
await socket.ConnectAsync(new Uri("wss://localhost:3334/app/bypass_stream?direction=send"), default);
await socket.SendAsync(Encoding.UTF8.GetBytes(JSONWriter.ToJson(new { command = "request_offer" })), WebSocketMessageType.Text, false, default);
var result = await socket.ReceiveAsync(buffer.Memory, default);
var sdpstr = Encoding.UTF8.GetString(buffer.Memory.Slice(0, result.Count).Span);
var offer = JSONParser.FromJson<Offer>(sdpstr);
// Create out peer with the provided ice servers and setup some listeners to track interesting events.
var config = new RTCConfiguration { iceServers = offer.ice_servers.Select(ice => new RTCIceServer { credential = ice.credential, username = ice.user_name, urls = string.Join(", ", ice.urls) }).ToList() };
var peer = new RTCPeerConnection(config);
// Add video and audio track.
// Should we be doing this now? I've just hard coded these based on the sort of SDPs we get.
peer.addTrack(new MediaStreamTrack(new VideoFormat(VideoCodecsEnum.VP8, 101), MediaStreamStatusEnum.SendOnly));
peer.addTrack(new MediaStreamTrack(new AudioFormat(AudioCodecsEnum.OPUS, 102, 48000, 2), MediaStreamStatusEnum.SendOnly));
foreach (var str in offer.candidates)
{
peer.addIceCandidate(new RTCIceCandidateInit { candidate = str.candidate, sdpMLineIndex = (ushort)str.sdpMLineIndex });
}
peer.setRemoteDescription(offer.sdp);
peer.VideoLocalTrack.RestrictCapabilities(new VideoFormat(VideoCodecsEnum.VP8, 101));
var answer = peer.createAnswer();
var response = new Offer { command = "answer", id = offer.id, sdp = answer };
var json = JSONWriter.ToJson(response);
await peer.setLocalDescription(answer);
await socket.SendAsync(Encoding.UTF8.GetBytes(json), WebSocketMessageType.Text, false, default); Hopefully that all makes enough sense to get some pointers on whats going wrong, any help greatly appreciated. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
I wish I knew more about SDP (but it feels like I learn a bit every time this comes up). But I have one observation about the particular line that is giving the error: In OME the offer is: But your answer is: I think the F is important for feedback/error correction. A couple of possible red herrings but also things I noticed:
Good luck and keep us posted! |
Beta Was this translation helpful? Give feedback.
This is a situation where signaling is complete, but ICE connection is not established. *:10000-10004/udp If you are using * in the configuration, it would be a good idea to put your actual IP instead of *.
I think your network configuration is also strange. Please upload Server.xml. You are probably using a virtual machine.
OBS advertises their ICE Candidate as follows: