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