int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds) { Nemesi_DemuxerStreamData * ndsd = demuxer->priv; Nemesi_SessionType stype; rtsp_ctrl * ctl = ndsd->rtsp; rtp_thread * rtp_th = rtsp_get_rtp_th(ctl); rtp_frame fr; demux_packet_t* dp; if ( (!ctl->rtsp_queue) || (demuxer->stream->eof) || (rtp_fill_buffers(rtp_th)) ) { mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n"); demuxer->stream->eof = 1; return 0; } if (ds == demuxer->video) stype = NEMESI_SESSION_VIDEO; else if (ds == demuxer->audio) stype = NEMESI_SESSION_AUDIO; else return 0; if(!get_data_for_session(ndsd, stype, &fr)) { dp = new_demux_packet(fr.len); memcpy(dp->buffer, fr.data, fr.len); fr.time_sec += ndsd->seek; ndsd->time[stype] = dp->pts = fr.time_sec; ds_add_packet(ds, dp); } else { stype = (stype + 1) % 2; if (stype == NEMESI_SESSION_VIDEO) ds = demuxer->video; else ds = demuxer->audio; if(!get_data_for_session(ndsd, stype, &fr)) { dp = new_demux_packet(fr.len); memcpy(dp->buffer, fr.data, fr.len); fr.time_sec += ndsd->seek; ndsd->time[stype] = dp->pts = fr.time_sec; ds_add_packet(ds, dp); } } return 1; }
static int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds) { Nemesi_DemuxerStreamData * ndsd = demuxer->priv; Nemesi_SessionType stype; rtp_ssrc * ssrc; rtp_frame fr; if ( (!ndsd->rtsp->rtsp_queue) || (demuxer->stream->eof) ) { mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n"); demuxer->stream->eof = 1; return 0; } memset(&fr, 0, sizeof(fr)); stype = DS_TO_STYPE(demuxer, ds); if ( (ssrc = wait_for_packets(ndsd, stype)) == NULL ) { mp_msg(MSGT_DEMUX, MSGL_INFO, "Bye...\n"); demuxer->stream->eof = 1; return 0; } if(!get_data_for_session(ndsd, stype, ssrc, &fr)) stream_add_packet(ndsd, stype, ds, &fr); else { stype = INVERT_STYPE(stype); //Must check if we actually have a stream of the other type if (!ndsd->session[stype]) return 1; ds = STYPE_TO_DS(demuxer, stype); ssrc = wait_for_packets(ndsd, stype); if(!get_data_for_session(ndsd, stype, ssrc, &fr)) stream_add_packet(ndsd, stype, ds, &fr); } return 1; }