What can I do with stream from OnAddStream in the PeerConnectionObserver ? WebRTC native c++ api

285 views
Skip to first unread message

Khalil Claybon

unread,
Apr 4, 2018, 2:23:00 AM4/4/18
to discuss-webrtc
Hi I am able to connect and open up a data channel using webrtc native api running locally on my computer and some javascript in my browser. From there I can get media stream in the browser and attach it to the peer connection, and as expected the peer connection observer now has the stream also. Where I am stumped is now what can I do with this stream. Ideally I would like to get the binary data from the stream and write it to a file or send it else where. What are the steps to use the native c++ api to decode a stream and get the raw binary data. In my peer connection server this is where I am stuck. I've looked at many examples and the closest thing I see is the objc example which uses a video sink, but I am quite lost. Anyone with more experience using the native c++ api please help.

class PeerConnectionObserver : public webrtc::PeerConnectionObserver {
...
   // Override adding a stream.
   void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream ) {

      //TODO now that I have the stream what do I do ?

      std::cout << "OnAddStream " << stream->label();
     // rtc::scoped_refptr<VideoTrackInterface> video_track = stream->getVideoTracks()[0];
     // VideoSourceInterface* GetSource() video->
   }
...
}

Akshay Shah

unread,
Apr 7, 2018, 2:48:33 AM4/7/18
to discuss-webrtc
Hi Khalil,

Did you find any way to do it? I too want to achieve the same.

Khalil Claybon

unread,
Apr 9, 2018, 12:14:00 PM4/9/18
to discuss-webrtc
No still haven't found a way. Somone on stack overflow said you must implement a fake Audio and Video device. But I haven't gotten back to this, when I do if I find answer I will upload sample code please do the same! :)

Samir N

unread,
Apr 18, 2018, 5:47:54 AM4/18/18
to discuss-webrtc
I am also trying to get the native WebRTC API to work as a gateway - to extract just the RTP/RTCP processing, jitter handling and related issues.
Is any of the work that you have done open sourced? Will save me a lot of time -:)


On Wednesday, April 4, 2018 at 11:53:00 AM UTC+5:30, Khalil Claybon wrote:
Reply all
Reply to author
Forward
0 new messages