2

Is there a way (or hack) to let me use a "custom" video capturer to create a VideoTrack and provide frames to it ?

The classic way to build a VideoTrack is :

Get a VideoCapturer Instance :

std::unique_ptr<cricket::VideoCapturer> capturer;

Create a VideoSource with a provided capturer :

 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> videoSource = peer_connection_factory_->CreateVideoSource(std::move(capturer), NULL);

Create a VideoTrack using the VideoSource :

rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track;

video_track = peer_connection_factory_->CreateVideoTrack(kVideoLabel, videoSource);

I was wondering if there is a way to override step one, instead of using the native one, using a custom capturer, so that i can provide the frames to the video track using a callback. That will let me use any video source (file, yuv stream...) and be very flexible.

Any advice on this one ?

This question is a C++ reference to : Create a WebRTC VideoTrack with a “custom” Capturer on Android with libjingle

Hakeem El Bakka-lee
  • 756
  • 1
  • 7
  • 23

1 Answers1

2

I finally found a way to make my own native C++ Video Capture. Basically you have to override some functions from webrtc::I420BufferInterface and cricket::VideoCapturer. If someone wants any further explanations please feel free to ask.

Hakeem El Bakka-lee
  • 756
  • 1
  • 7
  • 23
  • Can you please explain further on what to do to make it work? I'm not restricted to implementing a C++ capturer, a Java one would also work. – Jack Apr 01 '19 at 21:51
  • Hi Hakeem, can you please share an example? I am trying to use a RTSP stream to create a VideoCapture source. There is a library called JavaCV which can give me RTSP stream to fragments. Now I need to find a way to integrate the frames/fragments into WebRTC – Mujtaba Sep 20 '19 at 09:49
  • Hi Hakeem, I'm also trying to achieve the same in C++. Could you please direct me to some documentation or a sample? – iamrameshkumar Nov 29 '19 at 13:49
  • Hi could you please provide some more details? Thanks! – ch271828n Jun 12 '20 at 13:10