问题描述
根据 webrtc 在 google cricket 上的讨论组主题::VideoCapture 将很快被弃用.要自定义视频源,我们应该实现 VideoTrackSourceInterface.我尝试实现接口,但没有奏效.当我有一个框架时,我实现了接口,然后调用事件 OnFrame(const webrtc::VideoFrame& frame) 如下:
According to webrtc discuss group topic at google cricket::VideoCapture will be deprecated soon. To customize a video source, we should implement VideoTrackSourceInterface. I tried implementing the Interface and didn't work. I implemented the interface an when I have a frame then called the event OnFrame(const webrtc::VideoFrame& frame) as following:
void StreamSource::OnFrame(const webrtc::VideoFrame& frame)
{
rtc::scoped_refptr<webrtc::VideoFrameBuffer buffer(frame.video_frame_buffer());
broadcaster_.OnFrame(frame);
}在事件 AddStreams() 中的 Conductor.cc 中,我通过以下代码创建了一个视频源:
}In conductor.cc at the event AddStreams() I create a videosource by the following code :
rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
peer_connection_factory_->CreateVideoTrack( kVideoLabel,new mystream::StreamSource()));
我的视频无法在浏览器中播放.我做错了什么?
My video does not play in the browser. What I'm doing wrong?
推荐答案
我使用了基类 AdaptedVideoTrackSource 并创建了一个方法 FrameCaptured,它是从我的线程中调用的,在这个方法中我调用了 OnFrame 方法.一切正常!!!
I used the base class AdaptedVideoTrackSource and I created a method FrameCaptured it's is called from my thread in this method I call the method OnFrame. It's work fine !!!
class StreamSource : public rtc::AdaptedVideoTrackSource
{
void OnFrameCaptured(const webrtc::VideoFrame& frame);
}
void StreamSource::OnFrameCaptured(const webrtc::VideoFrame& frame)
{
OnFrame(frame);
}
这篇关于自定义视频捕获原生 webrtc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!