diff --git a/src/Common/MediaSink.h b/src/Common/MediaSink.h index 3d313f2a..a2c043a7 100644 --- a/src/Common/MediaSink.h +++ b/src/Common/MediaSink.h @@ -37,6 +37,10 @@ using namespace toolkit; namespace mediakit{ +/** + * 该类的作用是等待Track ready()返回true也就是就绪后再通知派生类进行下一步的操作 + * 目的是输入Frame前由Track截取处理下,以便获取有效的信息(譬如sps pps aa_cfg) + */ class MediaSink : public FrameWriterInterface , public std::enable_shared_from_this{ public: typedef std::shared_ptr Ptr; diff --git a/src/Player/Frame.h b/src/Player/Frame.h index a9c8c405..b7a1547b 100644 --- a/src/Player/Frame.h +++ b/src/Player/Frame.h @@ -52,6 +52,9 @@ typedef enum { TrackMax = 0x7FFF } TrackType; +/** + * 编码信息的抽象接口 + */ class CodecInfo { public: typedef std::shared_ptr Ptr; @@ -70,6 +73,9 @@ public: virtual CodecId getCodecId() const = 0; }; +/** + * 帧类型的抽象接口 + */ class Frame : public Buffer, public CodecInfo{ public: typedef std::shared_ptr Ptr; @@ -92,6 +98,10 @@ public: virtual bool keyFrame() const = 0; }; +/** + * 循环池辅助类 + * @tparam T + */ template class ResourcePoolHelper{ public: @@ -107,6 +117,9 @@ private: ResourcePool _pool; }; +/** + * 写帧接口的抽闲接口 + */ class FrameWriterInterface { public: typedef std::shared_ptr Ptr; @@ -120,11 +133,18 @@ public: virtual void inputFrame(const Frame::Ptr &frame) = 0; }; +/** + * 写帧接口转function,辅助类 + */ class FrameWriterInterfaceHelper : public FrameWriterInterface { public: typedef std::shared_ptr Ptr; typedef std::function onWriteFrame; + /** + * inputFrame后触发onWriteFrame回调 + * @param cb + */ FrameWriterInterfaceHelper(const onWriteFrame& cb){ _writeCallback = cb; } @@ -165,6 +185,9 @@ public: virtual void setFrameRing(const RingType::Ptr &ring) = 0; }; +/** + * 帧环形缓存 + */ class FrameRing : public FrameRingInterface{ public: typedef std::shared_ptr Ptr; @@ -202,6 +225,9 @@ protected: RingType::Ptr _frameRing; }; +/** + * 支持代理转发的帧环形缓存 + */ class FrameRingInterfaceDelegate : public FrameRing { public: typedef std::shared_ptr Ptr; diff --git a/src/Player/Track.h b/src/Player/Track.h index 7d40dbfd..c9a34326 100644 --- a/src/Player/Track.h +++ b/src/Player/Track.h @@ -37,6 +37,9 @@ using namespace toolkit; namespace mediakit{ +/** + * 媒体通道描述类,也支持帧输入输出 + */ class Track : public FrameRingInterfaceDelegate , public CodecInfo{ public: typedef std::shared_ptr Ptr; @@ -45,25 +48,30 @@ public: virtual ~Track(){} /** - * 是否准备好 + * 是否准备好,准备好才能获取譬如sps pps等信息 * @return */ virtual bool ready() = 0; /** * 克隆接口,用于复制本对象用 + * 在调用该接口时只会复制派生类的信息 + * 环形缓存和代理关系不能拷贝,否则会关系紊乱 * @return */ virtual Track::Ptr clone() = 0; /** - * 复制拷贝,只能拷贝一些描述信息, + * 复制拷贝,只能拷贝派生类的信息, * 环形缓存和代理关系不能拷贝,否则会关系紊乱 * @param that */ Track(const Track &that){} }; +/** + * 视频通道描述Track类,支持获取宽高fps信息 + */ class VideoTrack : public Track { public: typedef std::shared_ptr Ptr; @@ -89,6 +97,9 @@ public: virtual float getVideoFps() const = 0; }; +/** + * 音频Track派生类,支持采样率通道数,采用位数信息 + */ class AudioTrack : public Track { public: typedef std::shared_ptr Ptr; @@ -114,6 +125,9 @@ public: virtual int getAudioChannel() const = 0; }; +/** + * 264视频通道 + */ class H264Track : public VideoTrack{ public: typedef std::shared_ptr Ptr; @@ -270,6 +284,9 @@ private: float _fps = 0; }; +/** + * aac音频通道 + */ class AACTrack : public AudioTrack{ public: typedef std::shared_ptr Ptr;