From fadef1cac3c44bf43d9eb4574b1fcb60de08d3b5 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 16 Jun 2021 11:39:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B7=BB=E5=8A=A0track?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/Decoder.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Rtp/Decoder.cpp b/src/Rtp/Decoder.cpp index 60b04baa..5c011ae8 100644 --- a/src/Rtp/Decoder.cpp +++ b/src/Rtp/Decoder.cpp @@ -103,19 +103,16 @@ static const char *getCodecName(int codec_id) { void DecoderImp::onStream(int stream, int codecid, const void *extra, size_t bytes, int finish){ switch (codecid) { case PSI_STREAM_H264: { - InfoL << "got video track: H264"; onTrack(std::make_shared()); break; } case PSI_STREAM_H265: { - InfoL << "got video track: H265"; onTrack(std::make_shared()); break; } case PSI_STREAM_AAC: { - InfoL<< "got audio track: AAC"; onTrack(std::make_shared()); break; } @@ -123,14 +120,12 @@ void DecoderImp::onStream(int stream, int codecid, const void *extra, size_t byt case PSI_STREAM_AUDIO_G711A: case PSI_STREAM_AUDIO_G711U: { auto codec = codecid == PSI_STREAM_AUDIO_G711A ? CodecG711A : CodecG711U; - InfoL << "got audio track: G711"; //G711传统只支持 8000/1/16的规格,FFmpeg貌似做了扩展,但是这里不管它了 onTrack(std::make_shared(codec, 8000, 1, 16)); break; } case PSI_STREAM_AUDIO_OPUS: { - InfoL << "got audio track: opus"; onTrack(std::make_shared()); break; } @@ -223,8 +218,11 @@ void DecoderImp::onStream(int stream,int codecid,const void *extra,size_t bytes, #endif void DecoderImp::onTrack(const Track::Ptr &track) { - _tracks[track->getTrackType()] = track; - _sink->addTrack(track); + if (!_tracks[track->getTrackType()]) { + _tracks[track->getTrackType()] = track; + _sink->addTrack(track); + InfoL << "got track: " << track->getCodecName(); + } } void DecoderImp::onFrame(const Frame::Ptr &frame) {