<div dir="ltr">Hello everyone,<div><br></div><div>In the beginning, we use libortp to implement our rtsp server.</div><div>Unfortunately, libortp costs too much cpu resource when we send rtp packet.</div><div>So, I'm planing to porting our code to new library, libffmpeg.</div>
<div><br></div><div>RTSP server would be included rtsp, rtp and rtcp protocols.</div><div>Rtsp protocol has been done in our server and we don't need the rtcp protocol.</div><div>Last rtp, I initial rtp protocol by rtp container like below.</div>
<div><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> ff.oc = avformat_alloc_context();</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> ff.fmt = <span style="background-color:rgb(0,217,0)">av_</span>guess_format(<span style="color:rgb(183,44,23)">"rtp"</span>, <span style="color:rgb(183,44,23)">NULL</span>, <span style="color:rgb(183,44,23)">NULL</span>);</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(0,165,0)"> ff.oc->oformat = ff.fmt;</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)">
video_st = av_new_stream(ff->oc, VIDEO_INDEX);</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc = video_st->codec;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->codec_id = CODEC_ID_H264;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->codec_type = CODEC_TYPE_VIDEO;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->bit_rate = <span style="color:rgb(183,44,23)">2048</span> * <span style="color:rgb(183,44,23)">1024</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->width = <span style="color:rgb(183,44,23)">640</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->height = <span style="color:rgb(183,44,23)">480</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->time_base.den = <span style="color:rgb(183,44,23)">30</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->time_base.num = <span style="color:rgb(183,44,23)">1</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->gop_size = <span style="color:rgb(183,44,23)">30</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->pix_fmt = PIX_FMT_YUV420P;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->max_b_frames = <span style="color:rgb(183,44,23)">0</span>;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> oVcc->priv_data = <span style="color:rgb(183,44,23)">0</span>;</p></div><div>Then, I send rtp out.</div><div><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)">
<span style="background-color:rgb(0,217,0)"> AV</span>Packet sePacket;</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(0,165,0)"> <span style="background-color:rgb(0,217,0)">av</span>_init_packet(&sePacket); </p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> sePacket.flags |= PKT_FLAG_KEY;</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> sePacket.stream_index = VIDEO_INDEX;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> sePacket.data = pSrc;</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> sePacket.size = left;</p>
<p style="margin:0px;font-size:16px;font-family:Monaco;color:rgb(73,42,216);background-color:rgb(243,231,195)"><span style="color:rgb(0,0,0)"> </span>sePacket.pts = 0;</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)">
<span style="background-color:rgb(0,217,0)">av</span>_write_frame(ff->oc, &sePacket);</p><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)"> <span style="background-color:rgb(0,217,0)">av</span>_free_packet(&sePacket);</p>
</div><div>Actually, VLC can receive the rtp data I send.</div><div>But VLC can not decode it.</div><div><br></div><div>My question is:</div><div>1. the pSrc is totally H264 data, should I do something before calling av_write_frame???</div>
<div>2. Who has the sample code or any suggestion, please help me out??</div><div><br></div><div>Thanks a lot.</div><div><br></div><div><p style="margin:0px;font-size:16px;font-family:Monaco;background-color:rgb(243,231,195)">
<br></p></div></div>