mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 03:31:45 +08:00
常数改成枚举
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "HLSMaker.h"
|
||||
#include "Util/File.h"
|
||||
#include "Util/uv_errno.h"
|
||||
#include "Extension/H264.h"
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
@@ -136,9 +137,10 @@ void HLSMaker::inputH264(void *data, uint32_t length, uint32_t timeStamp) {
|
||||
_ui32LastStamp = timeStamp;
|
||||
}
|
||||
int stampInc = timeStamp - _ui32LastStamp;
|
||||
auto type = ((uint8_t*)data)[4] & 0x1F;
|
||||
auto type = H264_TYPE(((uint8_t*)data)[4]);
|
||||
|
||||
switch (type) {
|
||||
case 7: //SPS
|
||||
case H264Frame::NAL_SPS: //SPS
|
||||
if (stampInc >= _ui32SegmentDuration * 1000) {
|
||||
_ui32LastStamp = timeStamp;
|
||||
//关闭文件
|
||||
@@ -156,11 +158,11 @@ void HLSMaker::inputH264(void *data, uint32_t length, uint32_t timeStamp) {
|
||||
}
|
||||
write_index_file(_ui64TsCnt - _ui32NumSegments, _ui64TsCnt, 0);
|
||||
}
|
||||
case 1: //P
|
||||
case H264Frame::NAL_B_P: //P
|
||||
//insert aud frame before p and SPS frame
|
||||
_ts.inputH264("\x0\x0\x0\x1\x9\xf0", 6, timeStamp * 90);
|
||||
case 5: //IDR
|
||||
case 8: //PPS
|
||||
case H264Frame::NAL_IDR: //IDR
|
||||
case H264Frame::NAL_PPS: //PPS
|
||||
_ts.inputH264((char *) data, length, timeStamp * 90);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -76,10 +76,10 @@ Mp4Maker::~Mp4Maker() {
|
||||
}
|
||||
|
||||
void Mp4Maker::inputH264(void *pData, uint32_t ui32Length, uint32_t ui32TimeStamp){
|
||||
auto iType = ((uint8_t*)pData)[0] & 0x1F;
|
||||
auto iType = H264_TYPE(((uint8_t*)pData)[0]);
|
||||
switch (iType) {
|
||||
case 1: //P
|
||||
case 5: { //IDR
|
||||
case H264Frame::NAL_B_P: //P
|
||||
case H264Frame::NAL_IDR: { //IDR
|
||||
if (_strLastVideo.size()) {
|
||||
int64_t iTimeInc = (int64_t)ui32TimeStamp - (int64_t)_ui32LastVideoTime;
|
||||
iTimeInc = MAX(0,MIN(iTimeInc,500));
|
||||
@@ -115,9 +115,8 @@ void Mp4Maker::inputAAC(void *pData, uint32_t ui32Length, uint32_t ui32TimeStamp
|
||||
|
||||
void Mp4Maker::inputH264_l(void *pData, uint32_t ui32Length, uint32_t ui32Duration) {
|
||||
GET_CONFIG_AND_REGISTER(uint32_t,recordSec,Record::kFileSecond);
|
||||
|
||||
auto iType = ((uint8_t*)pData)[4] & 0x1F;
|
||||
if(iType == 5 && (_hMp4 == MP4_INVALID_FILE_HANDLE || _ticker.elapsedTime() > recordSec * 1000)){
|
||||
auto iType = H264_TYPE(((uint8_t*)pData)[4]);
|
||||
if(iType == H264Frame::NAL_IDR && (_hMp4 == MP4_INVALID_FILE_HANDLE || _ticker.elapsedTime() > recordSec * 1000)){
|
||||
//在I帧率处新建MP4文件
|
||||
//如果文件未创建或者文件超过10分钟则创建新文件
|
||||
createFile();
|
||||
|
||||
Reference in New Issue
Block a user