简体   繁体   中英

How to send contents of a webrtc stream directly to my server?

I've recently started getting into webRTC and would like to stream my webcam to my web server. However, I can only seem to find concrete examples of doing this peer to peer.

I know the very basics:

 navigator.getUserMedia(constraints, successCallback, errorCallback); function successCallback(stream) { // I want to send the output of this stream object to my server } 

Can anyone give a rough example of how this would be done?

The key to sending a WebRTC stream to the server is to pass an answer SDP to your peer connection that includes an address/port combination that directs the WebRTC media streams to a server. Its common with Media Resources Function (MRF) like Dialogics XMS server to route a media stream to the server for things like record/playback, transcoding and multi-way mixing/tiling. MRFs can generate an answer to a WebRTC client offer that includes all the necessary addresses and ports and many MRFs also support ICE for alternate media stream routing. If you want to have strict control over this you'll need to learn how to manipulate session descriptions (SDPs).

In general, you need to call:

peerConnection.setRemoteDescription(SdpObserver observer, SessionDescription sdp);

with the proper answer SDP to control where the WebRTC peer connection will send the media streams

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM