mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
简化代码
This commit is contained in:
parent
3b3e037ef0
commit
fa030fa0cc
@ -135,9 +135,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
|
|||||||
WarnL << "添加AAC Track失败:" << track_id;
|
WarnL << "添加AAC Track失败:" << track_id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = track_id;
|
||||||
info.track_id = track_id;
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CodecH264: {
|
case CodecH264: {
|
||||||
@ -170,9 +168,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
|
|||||||
WarnL << "添加H264 Track失败:" << track_id;
|
WarnL << "添加H264 Track失败:" << track_id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = track_id;
|
||||||
info.track_id = track_id;
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CodecH265: {
|
case CodecH265: {
|
||||||
@ -205,9 +201,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
|
|||||||
WarnL << "添加H265 Track失败:" << track_id;
|
WarnL << "添加H265 Track失败:" << track_id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = track_id;
|
||||||
info.track_id = track_id;
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -40,11 +40,11 @@ void Stamp::revise(uint32_t dts, uint32_t pts, int64_t &dts_out, int64_t &pts_ou
|
|||||||
//记录第一次时间戳,后面好计算时间戳增量
|
//记录第一次时间戳,后面好计算时间戳增量
|
||||||
_start_dts = dts;
|
_start_dts = dts;
|
||||||
_first = false;
|
_first = false;
|
||||||
_ticker = std::make_shared<SmoothTicker>();
|
_ticker.resetTime();
|
||||||
}
|
}
|
||||||
if (!dts) {
|
if (!dts) {
|
||||||
//没有解码时间戳,我们生成解码时间戳
|
//没有解码时间戳,我们生成解码时间戳
|
||||||
dts = _ticker->elapsedTime();
|
dts = _ticker.elapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
//相对时间戳
|
//相对时间戳
|
||||||
|
@ -44,7 +44,7 @@ private:
|
|||||||
int64_t _start_dts = 0;
|
int64_t _start_dts = 0;
|
||||||
int64_t _dts_inc = 0;
|
int64_t _dts_inc = 0;
|
||||||
bool _first = true;
|
bool _first = true;
|
||||||
std::shared_ptr<SmoothTicker> _ticker;
|
SmoothTicker _ticker;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
@ -42,19 +42,13 @@ TsMuxer::~TsMuxer() {
|
|||||||
void TsMuxer::addTrack(const Track::Ptr &track) {
|
void TsMuxer::addTrack(const Track::Ptr &track) {
|
||||||
switch (track->getCodecId()){
|
switch (track->getCodecId()){
|
||||||
case CodecH264: {
|
case CodecH264: {
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H264, nullptr, 0);
|
||||||
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H264, nullptr, 0);
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
} break;
|
} break;
|
||||||
case CodecH265: {
|
case CodecH265: {
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H265, nullptr, 0);
|
||||||
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H265, nullptr, 0);
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
}break;
|
}break;
|
||||||
case CodecAAC: {
|
case CodecAAC: {
|
||||||
track_info info;
|
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AAC, nullptr, 0);
|
||||||
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AAC, nullptr, 0);
|
|
||||||
_codec_to_trackid[track->getCodecId()] = info;
|
|
||||||
}break;
|
}break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,7 @@ using namespace toolkit;
|
|||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
class TsMuxer {
|
class TsMuxer : public MediaSink {
|
||||||
public:
|
public:
|
||||||
TsMuxer();
|
TsMuxer();
|
||||||
virtual ~TsMuxer();
|
virtual ~TsMuxer();
|
||||||
|
Loading…
Reference in New Issue
Block a user