mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-21 08:22:21 +08:00
ENABLE_MEDIAFILE宏拆分为ENABLE_HLS和ENABLE_MP4V2
This commit is contained in:
@@ -16,7 +16,7 @@ using namespace ZL::Util;
|
||||
namespace ZL {
|
||||
namespace MediaFile {
|
||||
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
MediaReader::MediaReader(const string &strApp, const string &strId) {
|
||||
static string recordPath = mINI::Instance()[Config::Record::kFilePath];
|
||||
auto strFileName = recordPath + "/" + strApp + "/" + strId;
|
||||
@@ -301,10 +301,10 @@ void MediaReader::seek(int iSeekTime,bool bReStart){
|
||||
}
|
||||
}
|
||||
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
RtspMediaSource::Ptr MediaReader::onMakeRtsp(const string &strApp, const string &strId) {
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
static string appName = mINI::Instance()[Config::Record::kAppName];
|
||||
if (strApp != appName) {
|
||||
return nullptr;
|
||||
@@ -319,12 +319,12 @@ RtspMediaSource::Ptr MediaReader::onMakeRtsp(const string &strApp, const string
|
||||
}
|
||||
#else
|
||||
return nullptr;
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
}
|
||||
|
||||
RtmpMediaSource::Ptr MediaReader::onMakeRtmp(const string &strApp, const string &strId) {
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
static string appName = mINI::Instance()[Config::Record::kAppName];
|
||||
if (strApp != appName) {
|
||||
return nullptr;
|
||||
@@ -339,7 +339,7 @@ RtmpMediaSource::Ptr MediaReader::onMakeRtmp(const string &strApp, const string
|
||||
}
|
||||
#else
|
||||
return nullptr;
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "Rtsp/RtspMediaSource.h"
|
||||
#include "Rtmp/RtmpMediaSource.h"
|
||||
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
#include <mp4v2/mp4v2.h>
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
using namespace ZL::DEV;
|
||||
using namespace ZL::Rtsp;
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
static RtmpMediaSource::Ptr onMakeRtmp(const string &strApp, const string &strId);
|
||||
private:
|
||||
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
MP4FileHandle m_hMP4File = MP4_INVALID_FILE_HANDLE;
|
||||
MP4TrackId m_video_trId = MP4_INVALID_TRACK_ID;
|
||||
uint32_t m_video_ms = 0;
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
inline bool readAudioSample(int iTimeInc = 0);
|
||||
inline void writeH264(uint8_t *pucData,int iLen,uint32_t uiStamp);
|
||||
inline void writeAAC(uint8_t *pucData,int iLen,uint32_t uiStamp);
|
||||
#endif
|
||||
#endif //ENABLE_MP4V2
|
||||
};
|
||||
|
||||
} /* namespace MediaFile */
|
||||
|
||||
@@ -19,42 +19,47 @@ namespace ZL {
|
||||
namespace MediaFile {
|
||||
|
||||
MediaRecorder::MediaRecorder(const string &strApp,const string &strId,const std::shared_ptr<PlayerBase> &pPlayer) {
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_HLS
|
||||
static string hlsPrefix = mINI::Instance()[Config::Http::kHttpPrefix];
|
||||
static string hlsPath = mINI::Instance()[Config::Hls::kFilePath];
|
||||
static uint32_t hlsBufSize = mINI::Instance()[Config::Hls::kFileBufSize].as<uint32_t>();
|
||||
static uint32_t hlsDuration = mINI::Instance()[Config::Hls::kSegmentDuration].as<uint32_t>();
|
||||
static uint32_t hlsNum = mINI::Instance()[Config::Hls::kSegmentNum].as<uint32_t>();
|
||||
|
||||
m_hlsMaker.reset(new HLSMaker(hlsPath + "/" + strApp + "/" + strId + "/hls.m3u8",
|
||||
hlsPrefix + "/" + strApp + "/" + strId + "/",
|
||||
hlsBufSize,hlsDuration,hlsNum));
|
||||
#endif //ENABLE_HLS
|
||||
|
||||
#ifdef ENABLE_MP4V2
|
||||
static string recordPath = mINI::Instance()[Config::Record::kFilePath];
|
||||
static string recordAppName = mINI::Instance()[Config::Record::kAppName];
|
||||
|
||||
|
||||
m_hlsMaker.reset(new HLSMaker(hlsPath + "/" + strApp + "/" + strId + "/hls.m3u8",
|
||||
hlsPrefix + "/" + strApp + "/" + strId + "/",
|
||||
hlsBufSize,hlsDuration,hlsNum));
|
||||
|
||||
m_mp4Maker.reset(new Mp4Maker(recordPath + "/" + recordAppName + "/" + strApp + "/" + strId + "/",
|
||||
strApp,strId,pPlayer));
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
}
|
||||
|
||||
MediaRecorder::~MediaRecorder() {
|
||||
}
|
||||
|
||||
void MediaRecorder::inputH264(void* pData, uint32_t ui32Length, uint32_t ui32TimeStamp, int iType) {
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_HLS
|
||||
m_hlsMaker->inputH264(pData, ui32Length, ui32TimeStamp * 90, iType);
|
||||
m_mp4Maker->inputH264(pData, ui32Length, ui32TimeStamp, iType);
|
||||
#endif //ENABLE_HLS
|
||||
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
m_mp4Maker->inputH264(pData, ui32Length, ui32TimeStamp, iType);
|
||||
#endif //ENABLE_MP4V2
|
||||
}
|
||||
|
||||
void MediaRecorder::inputAAC(void* pData, uint32_t ui32Length, uint32_t ui32TimeStamp) {
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_HLS
|
||||
m_hlsMaker->inputAAC(pData, ui32Length, ui32TimeStamp * 90);
|
||||
#endif //ENABLE_HLS
|
||||
|
||||
#ifdef ENABLE_MP4V2
|
||||
m_mp4Maker->inputAAC(pData, ui32Length, ui32TimeStamp);
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
}
|
||||
|
||||
} /* namespace MediaFile */
|
||||
|
||||
@@ -10,10 +10,14 @@
|
||||
|
||||
#include <memory>
|
||||
#include "Player/PlayerBase.h"
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
|
||||
#ifdef ENABLE_MP4V2
|
||||
#include "Mp4Maker.h"
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
#ifdef ENABLE_HLS
|
||||
#include "HLSMaker.h"
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_HLS
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Player;
|
||||
@@ -37,10 +41,14 @@ public:
|
||||
uint32_t ui32Length,
|
||||
uint32_t ui32TimeStamp);
|
||||
private:
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
|
||||
#ifdef ENABLE_HLS
|
||||
std::shared_ptr<HLSMaker> m_hlsMaker;
|
||||
#endif //ENABLE_HLS
|
||||
|
||||
#ifdef ENABLE_MP4V2
|
||||
std::shared_ptr<Mp4Maker> m_mp4Maker;
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -187,4 +187,4 @@ void Mp4Maker::closeFile() {
|
||||
} /* namespace ZL */
|
||||
|
||||
|
||||
#endif //ENABLE_MEDIAFILE
|
||||
#endif //ENABLE_MP4V2
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef MP4MAKER_H_
|
||||
#define MP4MAKER_H_
|
||||
|
||||
#ifdef ENABLE_MEDIAFILE
|
||||
#ifdef ENABLE_MP4V2
|
||||
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
@@ -77,6 +77,6 @@ private:
|
||||
} /* namespace MediaFile */
|
||||
} /* namespace ZL */
|
||||
|
||||
#endif ///ENABLE_MEDIAFILE
|
||||
#endif ///ENABLE_MP4V2
|
||||
|
||||
#endif /* MP4MAKER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user