Commit b2ebd848 by xiongziliang

完善MediaRecord 类

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