mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-08 11:57:48 +08:00
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
|
*
|
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|
*
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef ZLMEDIAKIT_MP4MUXER_H
|
|
#define ZLMEDIAKIT_MP4MUXER_H
|
|
|
|
#ifdef ENABLE_MP4
|
|
|
|
#include "Common/MediaSink.h"
|
|
#include "Extension/AAC.h"
|
|
#include "Extension/H264.h"
|
|
#include "Extension/H265.h"
|
|
#include "Common/Stamp.h"
|
|
#include "MP4.h"
|
|
|
|
namespace mediakit{
|
|
|
|
class MP4Muxer : public MediaSinkInterface, public MP4File{
|
|
public:
|
|
MP4Muxer(const char *file);
|
|
~MP4Muxer() override;
|
|
|
|
/**
|
|
* 添加已经ready状态的track
|
|
*/
|
|
void addTrack(const Track::Ptr & track) override;
|
|
/**
|
|
* 输入帧
|
|
*/
|
|
void inputFrame(const Frame::Ptr &frame) override;
|
|
|
|
/**
|
|
* 重置所有track
|
|
*/
|
|
void resetTracks() override ;
|
|
|
|
private:
|
|
void openMP4();
|
|
void closeMP4();
|
|
|
|
private:
|
|
struct track_info{
|
|
int track_id = -1;
|
|
Stamp stamp;
|
|
};
|
|
unordered_map<int,track_info> _codec_to_trackid;
|
|
List<Frame::Ptr> _frameCached;
|
|
bool _started = false;
|
|
bool _have_video = false;
|
|
MP4File::Writer _mov_writter;
|
|
string _file_name;
|
|
};
|
|
|
|
}//namespace mediakit
|
|
#endif//#ifdef ENABLE_MP4
|
|
#endif //ZLMEDIAKIT_MP4MUXER_H
|