mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-12-02 00:12:33 +08:00
parent
f833bfb031
commit
e03d15053d
@ -22,17 +22,24 @@ namespace mediakit {
|
|||||||
MP4Demuxer::MP4Demuxer() {}
|
MP4Demuxer::MP4Demuxer() {}
|
||||||
|
|
||||||
MP4Demuxer::~MP4Demuxer() {
|
MP4Demuxer::~MP4Demuxer() {
|
||||||
_mov_reader = nullptr;
|
closeMP4();
|
||||||
closeFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MP4Demuxer::openMP4(const string &file) {
|
void MP4Demuxer::openMP4(const string &file) {
|
||||||
openFile(file.data(),"rb+");
|
closeMP4();
|
||||||
_mov_reader = createReader();
|
|
||||||
|
_mp4_file = std::make_shared<MP4FileDisk>();
|
||||||
|
_mp4_file->openFile(file.data(), "rb+");
|
||||||
|
_mov_reader = _mp4_file->createReader();
|
||||||
getAllTracks();
|
getAllTracks();
|
||||||
_duration_ms = mov_reader_getduration(_mov_reader.get());
|
_duration_ms = mov_reader_getduration(_mov_reader.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MP4Demuxer::closeMP4() {
|
||||||
|
_mov_reader.reset();
|
||||||
|
_mp4_file.reset();
|
||||||
|
}
|
||||||
|
|
||||||
int MP4Demuxer::getAllTracks() {
|
int MP4Demuxer::getAllTracks() {
|
||||||
static mov_reader_trackinfo_t s_on_track = {
|
static mov_reader_trackinfo_t s_on_track = {
|
||||||
[](void *param, uint32_t track, uint8_t object, int width, int height, const void *extra, size_t bytes) {
|
[](void *param, uint32_t track, uint8_t object, int width, int height, const void *extra, size_t bytes) {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "Util/ResourcePool.h"
|
#include "Util/ResourcePool.h"
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
class MP4Demuxer : public MP4FileDisk, public TrackSource{
|
class MP4Demuxer : public TrackSource {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<MP4Demuxer> Ptr;
|
typedef std::shared_ptr<MP4Demuxer> Ptr;
|
||||||
|
|
||||||
@ -32,6 +32,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void openMP4(const string &file);
|
void openMP4(const string &file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 关闭 mp4 文件
|
||||||
|
*/
|
||||||
|
void closeMP4();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移动时间轴至某处
|
* 移动时间轴至某处
|
||||||
* @param stamp_ms 预期的时间轴位置,单位毫秒
|
* @param stamp_ms 预期的时间轴位置,单位毫秒
|
||||||
@ -67,7 +72,8 @@ private:
|
|||||||
Frame::Ptr makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int64_t pts, int64_t dts);
|
Frame::Ptr makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int64_t pts, int64_t dts);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Reader _mov_reader;
|
MP4FileDisk::Ptr _mp4_file;
|
||||||
|
MP4FileDisk::Reader _mov_reader;
|
||||||
uint64_t _duration_ms = 0;
|
uint64_t _duration_ms = 0;
|
||||||
map<int, Track::Ptr> _track_to_codec;
|
map<int, Track::Ptr> _track_to_codec;
|
||||||
ResourcePool<BufferRaw> _buffer_pool;
|
ResourcePool<BufferRaw> _buffer_pool;
|
||||||
|
Loading…
Reference in New Issue
Block a user