完成mp4/hls录制代码适配

This commit is contained in:
xiongziliang 2018-10-28 00:26:26 +08:00
parent b2ebd84848
commit 4876e9ff5c
3 changed files with 11 additions and 17 deletions

View File

@ -29,6 +29,7 @@
#include "RtspMuxer/RtspMediaSourceMuxer.h" #include "RtspMuxer/RtspMediaSourceMuxer.h"
#include "RtmpMuxer/RtmpMediaSourceMuxer.h" #include "RtmpMuxer/RtmpMediaSourceMuxer.h"
#include "MediaFile/MediaRecorder.h"
class MultiMediaSourceMuxer : public FrameWriterInterface{ class MultiMediaSourceMuxer : public FrameWriterInterface{
public: public:
@ -37,9 +38,13 @@ public:
MultiMediaSourceMuxer(const string &vhost, MultiMediaSourceMuxer(const string &vhost,
const string &strApp, const string &strApp,
const string &strId, const string &strId,
float dur_sec = 0.0){ float dur_sec = 0.0,
bool bEanbleHls = true,
bool bEnableMp4 = false){
_rtmp = std::make_shared<RtmpMediaSourceMuxer>(vhost,strApp,strId,std::make_shared<TitleMete>(dur_sec)); _rtmp = std::make_shared<RtmpMediaSourceMuxer>(vhost,strApp,strId,std::make_shared<TitleMete>(dur_sec));
_rtsp = std::make_shared<RtspMediaSourceMuxer>(vhost,strApp,strId,std::make_shared<TitleSdp>(dur_sec)); _rtsp = std::make_shared<RtspMediaSourceMuxer>(vhost,strApp,strId,std::make_shared<TitleSdp>(dur_sec));
_record = std::make_shared<MediaRecorder>(vhost,strApp,strId,bEanbleHls,bEnableMp4);
} }
virtual ~MultiMediaSourceMuxer(){} virtual ~MultiMediaSourceMuxer(){}
@ -51,6 +56,7 @@ public:
void addTrack(const Track::Ptr & track) { void addTrack(const Track::Ptr & track) {
_rtmp->addTrack(track); _rtmp->addTrack(track);
_rtsp->addTrack(track); _rtsp->addTrack(track);
_record->addTrack(track);
} }
/** /**
@ -60,6 +66,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override { void inputFrame(const Frame::Ptr &frame) override {
_rtmp->inputFrame(frame); _rtmp->inputFrame(frame);
_rtsp->inputFrame(frame); _rtsp->inputFrame(frame);
_record->inputFrame(frame);
} }
/** /**
@ -85,6 +92,7 @@ public:
private: private:
RtmpMediaSourceMuxer::Ptr _rtmp; RtmpMediaSourceMuxer::Ptr _rtmp;
RtspMediaSourceMuxer::Ptr _rtsp; RtspMediaSourceMuxer::Ptr _rtsp;
MediaRecorder::Ptr _record;
}; };

View File

@ -123,22 +123,8 @@ private:
}; };
#endif //0 #endif //0
class DevChannelNew : public MultiMediaSourceMuxer
{
public:
typedef std::shared_ptr<DevChannelNew> Ptr;
DevChannelNew(const char *strVhost, typedef MultiMediaSourceMuxer DevChannel;
const char *strApp,
const char *strId,
float fDuration = 0,
bool bEanbleHls = true,
bool bEnableMp4 = false):
MultiMediaSourceMuxer(strVhost,strApp,strId,fDuration){};
virtual ~DevChannelNew(){}
};
typedef DevChannelNew DevChannel;
} /* namespace mediakit */ } /* namespace mediakit */

View File

@ -48,7 +48,7 @@ public:
bool enableHls = true, bool enableHls = true,
bool enableMp4 = false); bool enableMp4 = false);
virtual ~MediaRecorder(); virtual ~MediaRecorder();
protected:
/** /**
* frame * frame
* @param frame * @param frame