static void link_session_and_fetch_conf(Nemesi_DemuxerStreamData * ndsd, Nemesi_SessionType stype, rtp_session * sess, rtp_buff * buff, unsigned int * fps) { extern float force_fps; rtp_ssrc *ssrc; rtsp_ctrl * ctl = ndsd->rtsp; rtp_frame * fr = &ndsd->first_pkt[stype]; rtp_buff trash_buff; ndsd->session[stype] = sess; if (buff == NULL) buff = &trash_buff; if ( (buff != NULL) || (fps != NULL) ) { rtp_fill_buffers(rtsp_get_rtp_th(ctl)); for (ssrc = rtp_active_ssrc_queue(rtsp_get_rtp_queue(ctl)); ssrc; ssrc = rtp_next_active_ssrc(ssrc)) { if (ssrc->rtp_sess == sess) { rtp_fill_buffer(ssrc, fr, buff); break; } } if ( (force_fps == 0.0) && (fps != NULL) ) { rtp_fill_buffers(rtsp_get_rtp_th(ctl)); *fps = rtp_get_fps(ssrc); } } }
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 rtp_ssrc *wait_for_packets(Nemesi_DemuxerStreamData * ndsd, Nemesi_SessionType stype) { rtp_ssrc *ssrc = NULL; /* Wait for prebuffering (prebuffering must be enabled in nemesi) */ int terminated = rtp_fill_buffers(rtsp_get_rtp_th(ndsd->rtsp)); /* Wait for the ssrc to be registered, if prebuffering is on in nemesi this will just get immediatly the correct ssrc */ if (!terminated) { while ( !(ssrc = rtp_session_get_ssrc(ndsd->session[stype], ndsd->rtsp)) ) sched_yield(); } return ssrc; }