Commit b2ebd848 by xiongziliang

完善MediaRecord 类

parent 6364b147
...@@ -70,24 +70,24 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp, ...@@ -70,24 +70,24 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp,
MediaRecorder::~MediaRecorder() { MediaRecorder::~MediaRecorder() {
} }
void MediaRecorder::inputH264(void* pData, uint32_t ui32Length, uint32_t ui32TimeStamp, int iType) { void MediaRecorder::inputFrame(const Frame::Ptr &frame) {
if(_hlsMaker){ if (_hlsMaker) {
// _hlsMaker->inputH264(pData, ui32Length, ui32TimeStamp, iType); _hlsMaker->inputFrame(frame);
} }
#ifdef ENABLE_MP4V2 #ifdef ENABLE_MP4V2
if(_mp4Maker){ if (_mp4Maker) {
// _mp4Maker->inputH264(pData, ui32Length, ui32TimeStamp, iType); _mp4Maker->inputFrame(frame);
} }
#endif //ENABLE_MP4V2 #endif //ENABLE_MP4V2
} }
void MediaRecorder::inputAAC(void* pData, uint32_t ui32Length, uint32_t ui32TimeStamp) { void MediaRecorder::addTrack(const Track::Ptr &track) {
if(_hlsMaker){ if (_hlsMaker) {
// _hlsMaker->inputAAC(pData, ui32Length, ui32TimeStamp); _hlsMaker->addTrack(track);
} }
#ifdef ENABLE_MP4V2 #ifdef ENABLE_MP4V2
if(_mp4Maker){ if (_mp4Maker) {
// _mp4Maker->inputAAC(pData, ui32Length, ui32TimeStamp); _mp4Maker->addTrack(track);
} }
#endif //ENABLE_MP4V2 #endif //ENABLE_MP4V2
} }
......
...@@ -39,7 +39,7 @@ using namespace toolkit; ...@@ -39,7 +39,7 @@ using namespace toolkit;
namespace mediakit { namespace mediakit {
class MediaRecorder { class MediaRecorder : public MediaSink{
public: public:
typedef std::shared_ptr<MediaRecorder> Ptr; typedef std::shared_ptr<MediaRecorder> Ptr;
MediaRecorder(const string &strVhost, MediaRecorder(const string &strVhost,
...@@ -48,15 +48,19 @@ public: ...@@ -48,15 +48,19 @@ public:
bool enableHls = true, bool enableHls = true,
bool enableMp4 = false); bool enableMp4 = false);
virtual ~MediaRecorder(); virtual ~MediaRecorder();
protected:
/**
* 输入frame
* @param frame
*/
void inputFrame(const Frame::Ptr &frame) override ;
void inputH264( void *pData, /**
uint32_t ui32Length, * 添加track,内部会调用Track的clone方法
uint32_t ui32TimeStamp, * 只会克隆sps pps这些信息 ,而不会克隆Delegate相关关系
int iType); * @param track
*/
void inputAAC( void *pData, void addTrack(const Track::Ptr & track) override;
uint32_t ui32Length,
uint32_t ui32TimeStamp);
private: private:
std::shared_ptr<HLSMaker> _hlsMaker; std::shared_ptr<HLSMaker> _hlsMaker;
#ifdef ENABLE_MP4V2 #ifdef ENABLE_MP4V2
......
...@@ -45,7 +45,8 @@ RtmpToRtspMediaSource::~RtmpToRtspMediaSource() {} ...@@ -45,7 +45,8 @@ RtmpToRtspMediaSource::~RtmpToRtspMediaSource() {}
void RtmpToRtspMediaSource::onGetH264(const H264Frame &frame) { void RtmpToRtspMediaSource::onGetH264(const H264Frame &frame) {
if(_pRecorder){ if(_pRecorder){
_pRecorder->inputH264((char *) frame.data(), frame.size(), frame.timeStamp, frame.type); //todo(xzl) 修复此处
// _pRecorder->inputH264((char *) frame.data(), frame.size(), frame.timeStamp, frame.type);
} }
if(_pRtpMaker_h264){ if(_pRtpMaker_h264){
...@@ -54,7 +55,8 @@ void RtmpToRtspMediaSource::onGetH264(const H264Frame &frame) { ...@@ -54,7 +55,8 @@ void RtmpToRtspMediaSource::onGetH264(const H264Frame &frame) {
} }
inline void RtmpToRtspMediaSource::onGetAAC(const AACFrame &frame) { inline void RtmpToRtspMediaSource::onGetAAC(const AACFrame &frame) {
if(_pRecorder){ if(_pRecorder){
_pRecorder->inputAAC((char *) frame.buffer, frame.aac_frame_length, frame.timeStamp); //todo(xzl) 修复此处
// _pRecorder->inputAAC((char *) frame.buffer, frame.aac_frame_length, frame.timeStamp);
} }
if (_pRtpMaker_aac) { if (_pRtpMaker_aac) {
......
...@@ -90,7 +90,8 @@ void RtspToRtmpMediaSource::makeVideoConfigPkt() { ...@@ -90,7 +90,8 @@ void RtspToRtmpMediaSource::makeVideoConfigPkt() {
} }
void RtspToRtmpMediaSource::onGetH264(const H264Frame& frame) { void RtspToRtmpMediaSource::onGetH264(const H264Frame& frame) {
if(_pRecorder){ if(_pRecorder){
_pRecorder->inputH264((char *) frame.data(), frame.size(), frame.timeStamp, frame.type); //todo(xzl) 修复此处
// _pRecorder->inputH264((char *) frame.data(), frame.size(), frame.timeStamp, frame.type);
} }
uint8_t nal_type = frame.data()[4] & 0x1F; uint8_t nal_type = frame.data()[4] & 0x1F;
int8_t flags = 7; //h.264 int8_t flags = 7; //h.264
...@@ -124,7 +125,8 @@ void RtspToRtmpMediaSource::onGetH264(const H264Frame& frame) { ...@@ -124,7 +125,8 @@ void RtspToRtmpMediaSource::onGetH264(const H264Frame& frame) {
} }
void RtspToRtmpMediaSource::onGetAAC(const AACFrame& frame) { void RtspToRtmpMediaSource::onGetAAC(const AACFrame& frame) {
if(_pRecorder){ if(_pRecorder){
_pRecorder->inputAAC((char *) frame.buffer, frame.aac_frame_length, frame.timeStamp); //todo(xzl) 修复此处
// _pRecorder->inputAAC((char *) frame.buffer, frame.aac_frame_length, frame.timeStamp);
} }
RtmpPacket::Ptr rtmpPkt(new RtmpPacket); RtmpPacket::Ptr rtmpPkt(new RtmpPacket);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论