FFmpegrtsp播放代碼剖析

rtsp url播放的時(shí)候,會(huì)根據(jù)url中是否有rtsp來判斷是否調(diào)用ff_rtsp_demuxer進(jìn)行網(wǎng)絡(luò)數(shù)據(jù)的讀取

創(chuàng)新互聯(lián)專注于康馬企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站,成都商城網(wǎng)站開發(fā)??雕R網(wǎng)站建設(shè)公司,為康馬等地區(qū)提供建站服務(wù)。全流程按需策劃設(shè)計(jì),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)

AVInputFormatff_rtsp_demuxer = {
??? .name?????????? = "rtsp",
??? .long_name????? = NULL_IF_CONFIG_SMALL("RTSP input"),
??? .priv_data_size = sizeof(RTSPState),
??? .read_probe???? = rtsp_probe,
??? .read_header??? = rtsp_read_header,
??? .read_packet??? = rtsp_read_packet,
??? .read_close???? = rtsp_read_close,
??? .read_seek????? = rtsp_read_seek,
??? .flags????????? = AVFMT_NOFILE,
??? .read_play????? = rtsp_read_play,
??? .read_pause???? = rtsp_read_pause,
??? .priv_class???? = &rtsp_demuxer_class,
};

碼流格式探測(cè)分析

>?ffplayd.exe!rtp_read(URLContext * h, unsigned char * buf, int size) 行 377?C

????(調(diào)用recvfrom讀取RTP傳輸數(shù)據(jù),transfer_func指向了rtp_read的實(shí)現(xiàn))

? ffplayd.exe!retry_transfer_wrapper(URLContext * h, unsigned char * buf, int size, int size_min, int (URLContext *, unsigned char *, int) * transfer_func) 行 376?C
??ffplayd.exe!ffurl_read(URLContext * h, unsigned char * buf, int size) 行 412?C
??ffplayd.exe!udp_read_packet(AVFormatContext * s, RTSPStream * * prtsp_st, unsigned char * buf, int buf_size, __int64 wait_end) 行 2033?C
??ffplayd.exe!read_packet(AVFormatContext * s, RTSPStream * * rtsp_st, RTSPStream * first_queue_st, __int64 wait_end) 行 2116?C
??ffplayd.exe!ff_rtsp_fetch_packet(AVFormatContext * s, AVPacket * pkt) 行 2202?C
??ffplayd.exe!rtsp_read_packet(AVFormatContext * s, AVPacket * pkt) 行 879?C
??ffplayd.exe!ff_read_packet(AVFormatContext * s, AVPacket * pkt) 行 856?C
??ffplayd.exe!read_frame_internal(AVFormatContext * s, AVPacket * pkt) 行 1582?C
??ffplayd.exe!avformat_find_stream_info(AVFormatContext * ic, AVDictionary * * options) 行 3772?C
??ffplayd.exe!read_thread(void * arg) 行 2805?C
??ffplayd.exe!SDL_RunThread(void * data) 行 283?C
??ffplayd.exe!RunThread(void * data) 行 91?C
??ffplayd.exe!RunThreadViaBeginThreadEx(void * data) 行 106?

重點(diǎn)分析函數(shù)ff_rtsp_fetch_packet,該函數(shù)調(diào)用read_packet獲取到RTP數(shù)據(jù),調(diào)用ff_rtp_parse_packet分析RTP數(shù)據(jù),去掉RTP包頭,添加起始碼,然后封裝成AVPacket,但是封裝的AVPacket并不是完整的NAL單元的視頻流,對(duì)于FU-A分包的數(shù)據(jù),仍然需要對(duì)多個(gè)AVPacket進(jìn)行重新組裝

>?ffplayd.exe!h364_handle_packet_fu_a(AVFormatContext * ctx, PayloadContext * data, AVPacket * pkt, const unsigned char * buf, int len, int * nal_counters, int nal_mask) 行 291?C

(對(duì)FU-A分包的RTP格式數(shù)據(jù),會(huì)根據(jù)是否是第一個(gè)包添加起始碼,關(guān)鍵是start_bit??? = fu_header >> 7;)
??ffplayd.exe!h364_handle_packet(AVFormatContext * ctx, PayloadContext * data, AVStream * st, AVPacket * pkt, unsigned int * timestamp, const unsigned char * buf, int len, unsigned short seq, int flags) 行 359?C
??ffplayd.exe!rtp_parse_packet_internal(RTPDemuxContext * s, AVPacket * pkt, const unsigned char * buf, int len) 行 692?C
??ffplayd.exe!rtp_parse_one_packet(RTPDemuxContext * s, AVPacket * pkt, unsigned char * * bufptr, int len) 行 841?C
??ffplayd.exe!ff_rtp_parse_packet(RTPDemuxContext * s, AVPacket * pkt, unsigned char * * bufptr, int len) 行 875?C
??ffplayd.exe!ff_rtsp_fetch_packet(AVFormatContext * s, AVPacket * pkt) 行 2217?C
??ffplayd.exe!rtsp_read_packet(AVFormatContext * s, AVPacket * pkt) 行 879?C
??ffplayd.exe!ff_read_packet(AVFormatContext * s, AVPacket * pkt) 行 856?C
??ffplayd.exe!read_frame_internal(AVFormatContext * s, AVPacket * pkt) 行 1582?C
??ffplayd.exe!av_read_frame(AVFormatContext * s, AVPacket * pkt) 行 1776?C
??ffplayd.exe!read_thread(void * arg) 行 3008?C
??ffplayd.exe!SDL_RunThread(void * data) 行 283?C
??ffplayd.exe!RunThread(void * data) 行 91?C
??ffplayd.exe!RunThreadViaBeginThreadEx(void * data) 行 106?C

av_read_frame分包代碼剖析

??ffplayd.exe!ff_combine_frame(ParseContext * pc, int next, const unsigned char * * buf, int * buf_size) 行 265?C
>?ffplayd.exe!h364_parse(AVCodecParserContext * s, AVCodecContext * avctx, const unsigned char * * poutbuf, int * poutbuf_size, const unsigned char * buf, int buf_size) 行 595?C
??ffplayd.exe!av_parser_parse2(AVCodecParserContext * s, AVCodecContext * avctx, unsigned char * * poutbuf, int * poutbuf_size, const unsigned char * buf, int buf_size, __int64 pts, __int64 dts, __int64 pos) 行 166?C
??ffplayd.exe!parse_packet(AVFormatContext * s, AVPacket * pkt, int stream_index) 行 1461?C
??ffplayd.exe!read_frame_internal(AVFormatContext * s, AVPacket * pkt) 行 1675?C
??ffplayd.exe!av_read_frame(AVFormatContext * s, AVPacket * pkt) 行 1776?C
??ffplayd.exe!read_thread(void * arg) 行 3008?C
??ffplayd.exe!SDL_RunThread(void * data) 行 283?C
??ffplayd.exe!RunThread(void * data) 行 91?C
??ffplayd.exe!RunThreadViaBeginThreadEx(void * data) 行 106?C
??[外部代碼]?

文章標(biāo)題:FFmpegrtsp播放代碼剖析
鏈接URL:http://bm7419.com/article4/gijoie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、軟件開發(fā)網(wǎng)站內(nèi)鏈、App設(shè)計(jì)、企業(yè)建站響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司