简化代码

This commit is contained in:
xiongziliang 2019-08-22 16:54:30 +08:00
parent 3b3e037ef0
commit fa030fa0cc
5 changed files with 10 additions and 22 deletions

View File

@ -135,9 +135,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
WarnL << "添加AAC Track失败:" << track_id;
return;
}
track_info info;
info.track_id = track_id;
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = track_id;
}
break;
case CodecH264: {
@ -170,9 +168,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
WarnL << "添加H264 Track失败:" << track_id;
return;
}
track_info info;
info.track_id = track_id;
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = track_id;
}
break;
case CodecH265: {
@ -205,9 +201,7 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
WarnL << "添加H265 Track失败:" << track_id;
return;
}
track_info info;
info.track_id = track_id;
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = track_id;
}
break;
default:

View File

@ -40,11 +40,11 @@ void Stamp::revise(uint32_t dts, uint32_t pts, int64_t &dts_out, int64_t &pts_ou
//记录第一次时间戳,后面好计算时间戳增量
_start_dts = dts;
_first = false;
_ticker = std::make_shared<SmoothTicker>();
_ticker.resetTime();
}
if (!dts) {
//没有解码时间戳,我们生成解码时间戳
dts = _ticker->elapsedTime();
dts = _ticker.elapsedTime();
}
//相对时间戳

View File

@ -44,7 +44,7 @@ private:
int64_t _start_dts = 0;
int64_t _dts_inc = 0;
bool _first = true;
std::shared_ptr<SmoothTicker> _ticker;
SmoothTicker _ticker;
};
}//namespace mediakit

View File

@ -42,19 +42,13 @@ TsMuxer::~TsMuxer() {
void TsMuxer::addTrack(const Track::Ptr &track) {
switch (track->getCodecId()){
case CodecH264: {
track_info info;
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H264, nullptr, 0);
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H264, nullptr, 0);
} break;
case CodecH265: {
track_info info;
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H265, nullptr, 0);
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H265, nullptr, 0);
}break;
case CodecAAC: {
track_info info;
info.track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AAC, nullptr, 0);
_codec_to_trackid[track->getCodecId()] = info;
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AAC, nullptr, 0);
}break;
default:
break;

View File

@ -38,7 +38,7 @@ using namespace toolkit;
namespace mediakit {
class TsMuxer {
class TsMuxer : public MediaSink {
public:
TsMuxer();
virtual ~TsMuxer();