webrtc(2) 数据源和数据输出点

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/NB_vol_1/article/details/82117829

数据源和数据输出点

本文分析webrtc的数据源和数据输出点:

  • 数据源
  • 数据输出点

数据源

VideoSourceInterface 表示一个数据源,即某一个模块可以从VideoSourceInterface获取数据

数据源可以产生数据,一般的音视频capture都是它的子类

template <typename VideoFrameT>
class VideoSourceInterface {
 public:
  virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,
                               const VideoSinkWants& wants) = 0;
  // RemoveSink must guarantee that at the time the method returns,
  // there is no current and no future calls to VideoSinkInterface::OnFrame.
  virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0;
 protected:
  virtual ~VideoSourceInterface() {}
};
  • 核心接口:void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,const VideoSinkWants& wants),设置一个数据输出点(VideoSinkInterface),数据输出点用于把数据传输到下一个模块。
  • 作用:数据源模可以产生数据,一般来说Capture就是一个数据源;产生数据之后,可以通过数据输出点把数据传输到下一个模块,一般来说是编码器模块。

数据输出点

VideoSinkInterface 表示一个数据输出,某个模块产生的数据可以通过VideoSinkInterface输出或者传输到别的模块

template <typename VideoFrameT>
class VideoSinkInterface {
 public:
  virtual ~VideoSinkInterface() = default;
  virtual void OnFrame(const VideoFrameT& frame) = 0;
  // Should be called by the source when it discards the frame due to rate
  // limiting.
  virtual void OnDiscardedFrame() {}
};
  • 核心接口:void OnFrame(const VideoFrameT& frame),数据产生的模块,调用OnFrame把数据传送到下一个模块或者输出
  • 作用:相当于模块之间的数据传输通道,有利于模块之间解耦。VideoSinkInterface主要用于Capture与编码器、解码器与render之间的数据传输。

猜你喜欢

转载自blog.csdn.net/NB_vol_1/article/details/82117829