mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-14 03:55:58 +08:00
完善mp4推流
This commit is contained in:
@@ -41,19 +41,56 @@ namespace mediakit {
|
||||
class MediaReader : public std::enable_shared_from_this<MediaReader> ,public MediaSourceEvent{
|
||||
public:
|
||||
typedef std::shared_ptr<MediaReader> Ptr;
|
||||
MediaReader(const string &strVhost,const string &strApp, const string &strId);
|
||||
virtual ~MediaReader();
|
||||
static MediaSource::Ptr onMakeMediaSource(const string &strSchema,const string &strVhost,const string &strApp, const string &strId);
|
||||
public:
|
||||
bool seekTo(uint32_t ui32Stamp) override;
|
||||
bool close() override;
|
||||
|
||||
/**
|
||||
* 流化一个mp4文件,使之转换成RtspMediaSource和RtmpMediaSource
|
||||
* @param strVhost 虚拟主机
|
||||
* @param strApp 应用名
|
||||
* @param strId 流id
|
||||
* @param filePath 文件路径,如果为空则根据配置文件和上面参数自动生成,否则使用指定的文件
|
||||
*/
|
||||
MediaReader(const string &strVhost,const string &strApp, const string &strId,const string &filePath = "");
|
||||
/**
|
||||
* 开始流化MP4文件,需要指出的是,MediaReader对象一经过调用startReadMP4方法,它的强引用会自持有,
|
||||
* 意思是在文件流化结束之前或中断之前,MediaReader对象是不会被销毁的(不管有没有被外部对象持有)
|
||||
*/
|
||||
void startReadMP4();
|
||||
|
||||
/**
|
||||
* 设置时移偏移量
|
||||
* @param ui32Stamp 偏移量,单位毫秒
|
||||
* @return
|
||||
*/
|
||||
bool seekTo(uint32_t ui32Stamp) override;
|
||||
|
||||
/**
|
||||
* 关闭MediaReader的流化进程,会触发该对象放弃自持有
|
||||
* @return
|
||||
*/
|
||||
bool close() override;
|
||||
|
||||
/**
|
||||
* 自动生成MediaReader对象然后查找相关的MediaSource对象
|
||||
* @param strSchema 协议名
|
||||
* @param strVhost 虚拟主机
|
||||
* @param strApp 应用名
|
||||
* @param strId 流id
|
||||
* @param filePath 文件路径,如果为空则根据配置文件和上面参数自动生成,否则使用指定的文件
|
||||
* @param checkApp 是否检查app,防止服务器上文件被乱访问
|
||||
* @return MediaSource
|
||||
*/
|
||||
static MediaSource::Ptr onMakeMediaSource(const string &strSchema,
|
||||
const string &strVhost,
|
||||
const string &strApp,
|
||||
const string &strId,
|
||||
const string &filePath = "",
|
||||
bool checkApp = true);
|
||||
#ifdef ENABLE_MP4V2
|
||||
private:
|
||||
void seek(uint32_t iSeekTime,bool bReStart = true);
|
||||
inline void setSeekTime(uint32_t iSeekTime);
|
||||
inline uint32_t getVideoCurrentTime();
|
||||
void startReadMP4();
|
||||
inline MP4SampleId getVideoSampleId(int iTimeInc = 0);
|
||||
inline MP4SampleId getAudioSampleId(int iTimeInc = 0);
|
||||
bool readSample(int iTimeInc, bool justSeekSyncFrame);
|
||||
|
||||
Reference in New Issue
Block a user