From 036b36f012ed3a09c08e1227187c9785fd8fcf21 Mon Sep 17 00:00:00 2001 From: "3503207480@qq.com" <3503207480@qq.com> Date: Fri, 30 Aug 2019 11:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注释,说明 --- src/Common/MediaSink.cpp | 2 +- src/Common/MediaSource.cpp | 3 ++- src/Extension/AAC.h | 2 +- src/Extension/H264Rtmp.h | 1 + src/Extension/H264Rtp.cpp | 23 ++++++++++++++++++++--- src/Extension/H264Rtp.h | 2 ++ src/Extension/H265Rtp.h | 2 ++ src/Http/HttpSession.cpp | 1 + src/Rtmp/RtmpPlayer.h | 6 +++--- src/Rtsp/RtspMuxer.cpp | 2 +- src/Rtsp/RtspPlayer.h | 2 +- src/Rtsp/RtspSession.cpp | 3 ++- 12 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/Common/MediaSink.cpp b/src/Common/MediaSink.cpp index 4d45f82e..b2263e54 100644 --- a/src/Common/MediaSink.cpp +++ b/src/Common/MediaSink.cpp @@ -70,7 +70,7 @@ void MediaSink::inputFrame(const Frame::Ptr &frame) { it->second->inputFrame(frame); if(!_allTrackReady && !_trackReadyCallback.empty() && it->second->ready()){ - //Track由未就绪状态装换成就绪状态,我们就触发onTrackReady回调 + //Track由未就绪状态转换成就绪状态,我们就触发onTrackReady回调 auto it_callback = _trackReadyCallback.find(codec_id); if(it_callback != _trackReadyCallback.end()){ it_callback->second(); diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 7f1535a6..cb668f37 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -123,6 +123,7 @@ MediaSource::Ptr MediaSource::find( lock_guard lock(g_mtxMediaSrc); MediaSource::Ptr ret; + //查找某一媒体源,找到后返回 searchMedia(schema, vhost, app, id, [&](SchemaVhostAppStreamMap::iterator &it0 , VhostAppStreamMap::iterator &it1, @@ -138,7 +139,7 @@ MediaSource::Ptr MediaSource::find( return true; }); if(!ret && bMake){ - //查找某一媒体源,找到后返回 + //未查找媒体源,则创建一个 ret = MediaReader::onMakeMediaSource(schema, vhost,app,id); } return ret; diff --git a/src/Extension/AAC.h b/src/Extension/AAC.h index 2af513f6..6c8bca5d 100644 --- a/src/Extension/AAC.h +++ b/src/Extension/AAC.h @@ -48,7 +48,7 @@ string makeAdtsConfig(const uint8_t *pcAdts); void getAACInfo(const AACFrame &adts,int &iSampleRate,int &iChannel); - /** +/** * aac帧,包含adts头 */ class AACFrame : public Frame { diff --git a/src/Extension/H264Rtmp.h b/src/Extension/H264Rtmp.h index ed015e76..68802d68 100644 --- a/src/Extension/H264Rtmp.h +++ b/src/Extension/H264Rtmp.h @@ -36,6 +36,7 @@ using namespace toolkit; namespace mediakit{ /** * h264 Rtmp解码类 + * 将 h264 over rtmp 解复用出 h264-Frame */ class H264RtmpDecoder : public RtmpCodec ,public ResourcePoolHelper { public: diff --git a/src/Extension/H264Rtp.cpp b/src/Extension/H264Rtp.cpp index 51581c6c..8a961e34 100644 --- a/src/Extension/H264Rtp.cpp +++ b/src/Extension/H264Rtp.cpp @@ -90,7 +90,24 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { * Type==7:SPS frame * Type==8:PPS frame */ + /* + RTF3984 5.2节 Common Structure of the RTP Payload Format + Table 1. Summary of NAL unit types and their payload structures + Type Packet Type name Section + --------------------------------------------------------- + 0 undefined - + 1-23 NAL unit Single NAL unit packet per H.264 5.6 + 24 STAP-A Single-time aggregation packet 5.7.1 + 25 STAP-B Single-time aggregation packet 5.7.1 + 26 MTAP16 Multi-time aggregation packet 5.7.2 + 27 MTAP24 Multi-time aggregation packet 5.7.2 + 28 FU-A Fragmentation unit 5.8 + 29 FU-B Fragmentation unit 5.8 + 30-31 undefined - + + + */ const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset; int length = rtppack->size() - rtppack->offset; NALU nal; @@ -145,7 +162,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { FU fu; MakeFU(frame[1], fu); if (fu.S) { - //该帧的第一个rtp包 + //该帧的第一个rtp包 FU-A start char tmp = (nal.forbidden_zero_bit << 7 | nal.nal_ref_idc << 5 | fu.type); _h264frame->buffer.assign("\x0\x0\x0\x1", 4); _h264frame->buffer.push_back(tmp); @@ -164,14 +181,14 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { } if (!fu.E) { - //该帧的中间rtp包 + //该帧的中间rtp包 FU-A mid _h264frame->buffer.append((char *)frame + 2, length - 2); //该函数return时,保存下当前sequence,以便下次对比seq是否连续 _lastSeq = rtppack->sequence; return false; } - //该帧最后一个rtp包 + //该帧最后一个rtp包 FU-A end _h264frame->buffer.append((char *)frame + 2, length - 2); _h264frame->timeStamp = rtppack->timeStamp; auto key = _h264frame->keyFrame(); diff --git a/src/Extension/H264Rtp.h b/src/Extension/H264Rtp.h index 09f2346d..94ad7c46 100644 --- a/src/Extension/H264Rtp.h +++ b/src/Extension/H264Rtp.h @@ -36,6 +36,8 @@ namespace mediakit{ /** * h264 rtp解码类 + * 将 h264 over rtsp-rtp 解复用出 h264-Frame + * rfc3984 */ class H264RtpDecoder : public RtpCodec , public ResourcePoolHelper { public: diff --git a/src/Extension/H265Rtp.h b/src/Extension/H265Rtp.h index f243baf2..fbe84031 100644 --- a/src/Extension/H265Rtp.h +++ b/src/Extension/H265Rtp.h @@ -37,6 +37,8 @@ namespace mediakit{ /** * h265 rtp解码类 + * 将 h265 over rtsp-rtp 解复用出 h265-Frame + * 《草案(H265-over-RTP)draft-ietf-payload-rtp-h265-07.pdf》 */ class H265RtpDecoder : public RtpCodec , public ResourcePoolHelper { public: diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 55a27ba7..4f9118c5 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -490,6 +490,7 @@ inline void HttpSession::Handle_Req_GET(int64_t &content_len) { //再看看是否为http-flv直播请求 if(checkLiveFlvStream()){ + //若是,return! return; } diff --git a/src/Rtmp/RtmpPlayer.h b/src/Rtmp/RtmpPlayer.h index 142ab5fb..7d479d1e 100644 --- a/src/Rtmp/RtmpPlayer.h +++ b/src/Rtmp/RtmpPlayer.h @@ -44,7 +44,7 @@ using namespace toolkit; using namespace mediakit::Client; namespace mediakit { - +//实现了rtmp播放器协议部分的功能,及数据接收功能 class RtmpPlayer:public PlayerBase, public TcpClient, public RtmpProtocol{ public: typedef std::shared_ptr Ptr; @@ -63,11 +63,11 @@ protected: void onMediaData_l(const RtmpPacket::Ptr &chunkData); void onPlayResult_l(const SockException &ex); - //for Tcpclient + //form Tcpclient void onRecv(const Buffer::Ptr &pBuf) override; void onConnect(const SockException &err) override; void onErr(const SockException &ex) override; - //fro RtmpProtocol + //from RtmpProtocol void onRtmpChunk(RtmpPacket &chunkData) override; void onStreamDry(uint32_t ui32StreamId) override; void onSendRawData(const Buffer::Ptr &buffer) override{ diff --git a/src/Rtsp/RtspMuxer.cpp b/src/Rtsp/RtspMuxer.cpp index c78a7e5c..9f4da62a 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -39,7 +39,7 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title){ } void RtspMuxer::onTrackReady(const Track::Ptr &track) { - //根据track生产sdp + //根据track生成sdp Sdp::Ptr sdp = track->getSdp(); if (!sdp) { return; diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index 90a30fa3..5977539b 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -46,7 +46,7 @@ using namespace toolkit; namespace mediakit { -//实现了rtsp播放器协议部分的功能 +//实现了rtsp播放器协议部分的功能,及数据接收功能 class RtspPlayer: public PlayerBase,public TcpClient, public RtspSplitter, public RtpReceiver { public: typedef std::shared_ptr Ptr; diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 2eb8d616..eb0fa6e8 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -361,10 +361,11 @@ void RtspSession::onAuthSuccess() { strongSelf->shutdown(SockException(Err_shutdown,err)); return; } - //找到了响应的rtsp流 + //找到了相应的rtsp流 strongSelf->_aTrackInfo = SdpParser(rtsp_src->getSdp()).getAvailableTrack(); if (strongSelf->_aTrackInfo.empty()) { //该流无效 + DebugL << "无trackInfo,该流无效"; strongSelf->send_StreamNotFound(); strongSelf->shutdown(SockException(Err_shutdown,"can not find any availabe track in sdp")); return;