<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi ! Is there any example/pseudocode  how to create RTP stream <br>with custom binary data ?<br>My code looks like:<br><br><div><font face="monospace, monospace">bool init_data_stream() {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">    </span>ConfigReader *cfg = ConfigReader::getInstance();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>int nRet = avformat_alloc_output_context2(&m_pDataOC, nullptr, "rtp", cfg->dataUrl);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">  </span>if((m_pDataOC == nullptr) || (nRet != 0)) {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">            </span>return false;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">  </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>m_osData = new OutputStream();</font></div><div><font face="monospace, monospace"><span style="white-space:pre"> </span>m_osData->st = avformat_new_stream(m_pDataOC, nullptr);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>m_osData->st->time_base    = { 1, 1000 };</font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>m_osData->st->r_frame_rate = frame_rate;</font></div><div><span style="white-space:pre"><font face="monospace, monospace"> </font></span></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>m_osData->st->codecpar->codec_type = AVMEDIA_TYPE_DATA;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>m_osData->st->codecpar->codec_id    = AV_CODEC_ID_MPEG2TS;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">  </span>av_dump_format(m_pDataOC, 0, cfg->dataUrl, 1);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>AVDictionary* options = 0;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>nRet = avio_open2(&m_pDataOC->pb, cfg->dataUrl, AVIO_FLAG_WRITE, nullptr, &options);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>if(nRet != 0) {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">                </span>return false;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">  </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>nRet = avformat_write_header(m_pDataOC, nullptr);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>if(nRet < 0) {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">              </span>m_osData = nullptr;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">            </span>return false;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">  </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>return true;</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>then  </div><div> <br></div><div><div><font face="monospace, monospace">uint8_t sendData(uint8_t *pDataBuf, const size_t &size) {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">   </span>uint8_t nResD = 0;</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>if(pDataBuf && size && m_osData) {</font></div><div><font face="monospace, monospace"><span style="white-space:pre">             </span>AVPacket pkt = { 0 };</font></div><div><font face="monospace, monospace"><span style="white-space:pre">          </span>av_init_packet(&pkt);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">              </span>nResD = av_packet_from_data(&pkt, pDataBuf, size);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">         </span>pkt.pts = av_rescale_q(m_osData->next_pts++, frame_rate, m_osData->st->time_base);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">            </span>pkt.duration = av_rescale_q(1, frame_rate, m_osData->st->time_base);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">             </span>nResD = av_interleaved_write_frame(m_pDataOC, &pkt); // <- CRASH</font></div><div><font face="monospace, monospace"><span style="white-space:pre">                </span>av_packet_unref(&pkt);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>}</font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>return  nResD;</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>Thanks.</div><br clear="all"><div> <br></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-family:arial;font-size:small"><span style="font-family:"Courier New";color:rgb(0,0,0);background-color:transparent">--</span></div><div style="font-size:small"><font color="#000000" face="Courier New">theFast</font></div><div style="font-family:arial;font-size:small"><font face="Courier New"><u><a href="mailto:fas.ysk@gmail.com" target="_blank">fas.ysk@gmail.com</a></u></font></div><div style="font-family:arial;font-size:small"><br></div></div></div></div></div></div></div></div>