1 ////////// Routines (with C-linkage) that interface between "MPlayer"
2 ////////// and the "LIVE555 Streaming Media" libraries:
5 // on MinGW, we must include windows.h before the things it conflicts
6 #ifdef __MINGW32__ // with. they are each protected from
7 #include <windows.h> // windows.h, but not the other way around.
12 #include "demux_rtp_internal.h"
14 #include "BasicUsageEnvironment.hh"
15 #include "liveMedia.hh"
16 #include "GroupsockHelper.hh"
19 // A data structure representing input data for each stream:
20 class ReadBufferQueue
{
22 ReadBufferQueue(MediaSubsession
* subsession
, demuxer_t
* demuxer
,
24 virtual ~ReadBufferQueue();
26 FramedSource
* readSource() const { return fReadSource
; }
27 RTPSource
* rtpSource() const { return fRTPSource
; }
28 demuxer_t
* ourDemuxer() const { return fOurDemuxer
; }
29 char const* tag() const { return fTag
; }
31 char blockingFlag
; // used to implement synchronous reads
33 // For A/V synchronization:
34 Boolean prevPacketWasSynchronized
;
36 ReadBufferQueue
** otherQueue
;
38 // The 'queue' actually consists of just a single "demux_packet_t"
39 // (because the underlying OS does the actual queueing/buffering):
42 // However, we sometimes inspect buffers before delivering them.
43 // For this, we maintain a queue of pending buffers:
44 void savePendingBuffer(demux_packet_t
* dp
);
45 demux_packet_t
* getPendingBuffer();
47 // For H264 over rtsp using AVParser, the next packet has to be saved
48 demux_packet_t
* nextpacket
;
51 demux_packet_t
* pendingDPHead
;
52 demux_packet_t
* pendingDPTail
;
54 FramedSource
* fReadSource
;
55 RTPSource
* fRTPSource
;
56 demuxer_t
* fOurDemuxer
;
57 char const* fTag
; // used for debugging
60 // A structure of RTP-specific state, kept so that we can cleanly
62 typedef struct RTPState
{
63 char const* sdpDescription
;
64 RTSPClient
* rtspClient
;
66 MediaSession
* mediaSession
;
67 ReadBufferQueue
* audioBufferQueue
;
68 ReadBufferQueue
* videoBufferQueue
;
70 struct timeval firstSyncTime
;
73 extern "C" char* network_username
;
74 extern "C" char* network_password
;
75 static char* openURL_rtsp(RTSPClient
* client
, char const* url
) {
76 // If we were given a user name (and optional password), then use them:
77 if (network_username
!= NULL
) {
78 char const* password
= network_password
== NULL
? "" : network_password
;
79 return client
->describeWithPassword(url
, network_username
, password
);
81 return client
->describeURL(url
);
85 static char* openURL_sip(SIPClient
* client
, char const* url
) {
86 // If we were given a user name (and optional password), then use them:
87 if (network_username
!= NULL
) {
88 char const* password
= network_password
== NULL
? "" : network_password
;
89 return client
->inviteWithPassword(url
, network_username
, password
);
91 return client
->invite(url
);
95 int rtspStreamOverTCP
= 0;
98 extern "C" int audio_id
, video_id
, dvdsub_id
;
99 extern "C" demuxer_t
* demux_open_rtp(demuxer_t
* demuxer
) {
100 struct MPOpts
*opts
= demuxer
->opts
;
101 Boolean success
= False
;
103 TaskScheduler
* scheduler
= BasicTaskScheduler::createNew();
104 if (scheduler
== NULL
) break;
105 UsageEnvironment
* env
= BasicUsageEnvironment::createNew(*scheduler
);
106 if (env
== NULL
) break;
108 RTSPClient
* rtspClient
= NULL
;
109 SIPClient
* sipClient
= NULL
;
111 if (demuxer
== NULL
|| demuxer
->stream
== NULL
) break; // shouldn't happen
112 demuxer
->stream
->eof
= 0; // just in case
114 // Look at the stream's 'priv' field to see if we were initiated
115 // via a SDP description:
116 char* sdpDescription
= (char*)(demuxer
->stream
->priv
);
117 if (sdpDescription
== NULL
) {
118 // We weren't given a SDP description directly, so assume that
119 // we were given a RTSP or SIP URL:
120 char const* protocol
= demuxer
->stream
->streaming_ctrl
->url
->protocol
;
121 char const* url
= demuxer
->stream
->streaming_ctrl
->url
->url
;
123 if (strcmp(protocol
, "rtsp") == 0) {
124 rtspClient
= RTSPClient::createNew(*env
, verbose
, "MPlayer");
125 if (rtspClient
== NULL
) {
126 fprintf(stderr
, "Failed to create RTSP client: %s\n",
127 env
->getResultMsg());
130 sdpDescription
= openURL_rtsp(rtspClient
, url
);
132 unsigned char desiredAudioType
= 0; // PCMU (use 3 for GSM)
133 sipClient
= SIPClient::createNew(*env
, desiredAudioType
, NULL
,
135 if (sipClient
== NULL
) {
136 fprintf(stderr
, "Failed to create SIP client: %s\n",
137 env
->getResultMsg());
140 sipClient
->setClientStartPortNum(8000);
141 sdpDescription
= openURL_sip(sipClient
, url
);
144 if (sdpDescription
== NULL
) {
145 fprintf(stderr
, "Failed to get a SDP description from URL \"%s\": %s\n",
146 url
, env
->getResultMsg());
151 // Now that we have a SDP description, create a MediaSession from it:
152 MediaSession
* mediaSession
= MediaSession::createNew(*env
, sdpDescription
);
153 if (mediaSession
== NULL
) break;
156 // Create a 'RTPState' structure containing the state that we just created,
157 // and store it in the demuxer's 'priv' field, for future reference:
158 RTPState
* rtpState
= new RTPState
;
159 rtpState
->sdpDescription
= sdpDescription
;
160 rtpState
->rtspClient
= rtspClient
;
161 rtpState
->sipClient
= sipClient
;
162 rtpState
->mediaSession
= mediaSession
;
163 rtpState
->audioBufferQueue
= rtpState
->videoBufferQueue
= NULL
;
165 rtpState
->firstSyncTime
.tv_sec
= rtpState
->firstSyncTime
.tv_usec
= 0;
166 demuxer
->priv
= rtpState
;
168 int audiofound
= 0, videofound
= 0;
169 // Create RTP receivers (sources) for each subsession:
170 MediaSubsessionIterator
iter(*mediaSession
);
171 MediaSubsession
* subsession
;
172 unsigned desiredReceiveBufferSize
;
173 while ((subsession
= iter
.next()) != NULL
) {
174 // Ignore any subsession that's not audio or video:
175 if (strcmp(subsession
->mediumName(), "audio") == 0) {
177 fprintf(stderr
, "Additional subsession \"audio/%s\" skipped\n", subsession
->codecName());
180 desiredReceiveBufferSize
= 100000;
181 } else if (strcmp(subsession
->mediumName(), "video") == 0) {
183 fprintf(stderr
, "Additional subsession \"video/%s\" skipped\n", subsession
->codecName());
186 desiredReceiveBufferSize
= 2000000;
192 subsession
->setClientPortNum (rtsp_port
);
194 if (!subsession
->initiate()) {
195 fprintf(stderr
, "Failed to initiate \"%s/%s\" RTP subsession: %s\n", subsession
->mediumName(), subsession
->codecName(), env
->getResultMsg());
197 fprintf(stderr
, "Initiated \"%s/%s\" RTP subsession on port %d\n", subsession
->mediumName(), subsession
->codecName(), subsession
->clientPortNum());
199 // Set the OS's socket receive buffer sufficiently large to avoid
200 // incoming packets getting dropped between successive reads from this
201 // subsession's demuxer. Depending on the bitrate(s) that you expect,
202 // you may wish to tweak the "desiredReceiveBufferSize" values above.
203 int rtpSocketNum
= subsession
->rtpSource()->RTPgs()->socketNum();
204 int receiveBufferSize
205 = increaseReceiveBufferTo(*env
, rtpSocketNum
,
206 desiredReceiveBufferSize
);
208 fprintf(stderr
, "Increased %s socket receive buffer to %d bytes \n",
209 subsession
->mediumName(), receiveBufferSize
);
212 if (rtspClient
!= NULL
) {
213 // Issue a RTSP "SETUP" command on the chosen subsession:
214 if (!rtspClient
->setupMediaSubsession(*subsession
, False
,
215 rtspStreamOverTCP
)) break;
216 if (!strcmp(subsession
->mediumName(), "audio"))
218 if (!strcmp(subsession
->mediumName(), "video"))
224 if (rtspClient
!= NULL
) {
225 // Issue a RTSP aggregate "PLAY" command on the whole session:
226 if (!rtspClient
->playMediaSession(*mediaSession
)) break;
227 } else if (sipClient
!= NULL
) {
228 sipClient
->sendACK(); // to start the stream flowing
231 // Now that the session is ready to be read, do additional
232 // MPlayer codec-specific initialization on each subsession:
234 while ((subsession
= iter
.next()) != NULL
) {
235 if (subsession
->readSource() == NULL
) continue; // not reading this
238 if (strcmp(subsession
->mediumName(), "audio") == 0) {
239 rtpState
->audioBufferQueue
240 = new ReadBufferQueue(subsession
, demuxer
, "audio");
241 rtpState
->audioBufferQueue
->otherQueue
= &(rtpState
->videoBufferQueue
);
242 rtpCodecInitialize_audio(demuxer
, subsession
, flags
);
243 } else if (strcmp(subsession
->mediumName(), "video") == 0) {
244 rtpState
->videoBufferQueue
245 = new ReadBufferQueue(subsession
, demuxer
, "video");
246 rtpState
->videoBufferQueue
->otherQueue
= &(rtpState
->audioBufferQueue
);
247 rtpCodecInitialize_video(demuxer
, subsession
, flags
);
249 rtpState
->flags
|= flags
;
253 if (!success
) return NULL
; // an error occurred
255 // Hack: If audio and video are demuxed together on a single RTP stream,
256 // then create a new "demuxer_t" structure to allow the higher-level
257 // code to recognize this:
258 if (demux_is_multiplexed_rtp_stream(demuxer
)) {
259 stream_t
* s
= new_ds_stream(demuxer
->video
);
260 demuxer_t
* od
= demux_open(opts
, s
, DEMUXER_TYPE_UNKNOWN
,
261 audio_id
, video_id
, dvdsub_id
, NULL
);
262 demuxer
= new_demuxers_demuxer(od
, od
, od
);
268 extern "C" int demux_is_mpeg_rtp_stream(demuxer_t
* demuxer
) {
269 // Get the RTP state that was stored in the demuxer's 'priv' field:
270 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
272 return (rtpState
->flags
&RTPSTATE_IS_MPEG12_VIDEO
) != 0;
275 extern "C" int demux_is_multiplexed_rtp_stream(demuxer_t
* demuxer
) {
276 // Get the RTP state that was stored in the demuxer's 'priv' field:
277 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
279 return (rtpState
->flags
&RTPSTATE_IS_MULTIPLEXED
) != 0;
282 static demux_packet_t
* getBuffer(demuxer_t
* demuxer
, demux_stream_t
* ds
,
283 Boolean mustGetNewData
,
284 float& ptsBehind
); // forward
286 extern "C" int demux_rtp_fill_buffer(demuxer_t
* demuxer
, demux_stream_t
* ds
) {
287 // Get a filled-in "demux_packet" from the RTP source, and deliver it.
288 // Note that this is called as a synchronous read operation, so it needs
289 // to block in the (hopefully infrequent) case where no packet is
290 // immediately available.
294 demux_packet_t
* dp
= getBuffer(demuxer
, ds
, False
, ptsBehind
); // blocking
295 if (dp
== NULL
) return 0;
297 if (demuxer
->stream
->eof
) return 0; // source stream has closed down
299 // Before using this packet, check to make sure that its presentation
300 // time is not far behind the other stream (if any). If it is,
301 // then we discard this packet, and get another instead. (The rest of
302 // MPlayer doesn't always do a good job of synchronizing when the
303 // audio and video streams get this far apart.)
304 // (We don't do this when streaming over TCP, because then the audio and
305 // video streams are interleaved.)
306 // (Also, if the stream is *excessively* far behind, then we allow
307 // the packet, because in this case it probably means that there was
308 // an error in the source's timestamp synchronization.)
309 const float ptsBehindThreshold
= 1.0; // seconds
310 const float ptsBehindLimit
= 60.0; // seconds
311 if (ptsBehind
< ptsBehindThreshold
||
312 ptsBehind
> ptsBehindLimit
||
313 rtspStreamOverTCP
) { // packet's OK
314 ds_add_packet(ds
, dp
);
318 #ifdef DEBUG_PRINT_DISCARDED_PACKETS
319 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
320 ReadBufferQueue
* bufferQueue
= ds
== demuxer
->video
? rtpState
->videoBufferQueue
: rtpState
->audioBufferQueue
;
321 fprintf(stderr
, "Discarding %s packet (%fs behind)\n", bufferQueue
->tag(), ptsBehind
);
323 free_demux_packet(dp
); // give back this packet, and get another one
329 Boolean
awaitRTPPacket(demuxer_t
* demuxer
, demux_stream_t
* ds
,
330 unsigned char*& packetData
, unsigned& packetDataLen
,
332 // Similar to "demux_rtp_fill_buffer()", except that the "demux_packet"
333 // is not delivered to the "demux_stream".
335 demux_packet_t
* dp
= getBuffer(demuxer
, ds
, True
, ptsBehind
); // blocking
336 if (dp
== NULL
) return False
;
338 packetData
= dp
->buffer
;
339 packetDataLen
= dp
->len
;
345 static void teardownRTSPorSIPSession(RTPState
* rtpState
); // forward
347 extern "C" void demux_close_rtp(demuxer_t
* demuxer
) {
348 // Reclaim all RTP-related state:
350 // Get the RTP state that was stored in the demuxer's 'priv' field:
351 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
352 if (rtpState
== NULL
) return;
354 teardownRTSPorSIPSession(rtpState
);
356 UsageEnvironment
* env
= NULL
;
357 TaskScheduler
* scheduler
= NULL
;
358 if (rtpState
->mediaSession
!= NULL
) {
359 env
= &(rtpState
->mediaSession
->envir());
360 scheduler
= &(env
->taskScheduler());
362 Medium::close(rtpState
->mediaSession
);
363 Medium::close(rtpState
->rtspClient
);
364 Medium::close(rtpState
->sipClient
);
365 delete rtpState
->audioBufferQueue
;
366 delete rtpState
->videoBufferQueue
;
367 delete rtpState
->sdpDescription
;
370 env
->reclaim(); delete scheduler
;
373 ////////// Extra routines that help implement the above interface functions:
375 #define MAX_RTP_FRAME_SIZE 50000
376 // >= the largest conceivable frame composed from one or more RTP packets
378 static void afterReading(void* clientData
, unsigned frameSize
,
379 unsigned /*numTruncatedBytes*/,
380 struct timeval presentationTime
,
381 unsigned /*durationInMicroseconds*/) {
383 if (frameSize
>= MAX_RTP_FRAME_SIZE
) {
384 fprintf(stderr
, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
387 ReadBufferQueue
* bufferQueue
= (ReadBufferQueue
*)clientData
;
388 demuxer_t
* demuxer
= bufferQueue
->ourDemuxer();
389 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
391 if (frameSize
> 0) demuxer
->stream
->eof
= 0;
393 demux_packet_t
* dp
= bufferQueue
->dp
;
395 if (bufferQueue
->readSource()->isAMRAudioSource())
397 else if (bufferQueue
== rtpState
->videoBufferQueue
&&
398 ((sh_video_t
*)demuxer
->video
->sh
)->format
== mmioFOURCC('H','2','6','4')) {
405 resize_demux_packet(dp
, frameSize
+ headersize
);
407 // Set the packet's presentation time stamp, depending on whether or
408 // not our RTP source's timestamps have been synchronized yet:
409 Boolean hasBeenSynchronized
410 = bufferQueue
->rtpSource()->hasBeenSynchronizedUsingRTCP();
411 if (hasBeenSynchronized
) {
412 if (verbose
> 0 && !bufferQueue
->prevPacketWasSynchronized
) {
413 fprintf(stderr
, "%s stream has been synchronized using RTCP \n",
417 struct timeval
* fst
= &(rtpState
->firstSyncTime
); // abbrev
418 if (fst
->tv_sec
== 0 && fst
->tv_usec
== 0) {
419 *fst
= presentationTime
;
422 // For the "pts" field, use the time differential from the first
423 // synchronized time, rather than absolute time, in order to avoid
424 // round-off errors when converting to a float:
425 dp
->pts
= presentationTime
.tv_sec
- fst
->tv_sec
426 + (presentationTime
.tv_usec
- fst
->tv_usec
)/1000000.0;
427 bufferQueue
->prevPacketPTS
= dp
->pts
;
429 if (verbose
> 0 && bufferQueue
->prevPacketWasSynchronized
) {
430 fprintf(stderr
, "%s stream is no longer RTCP-synchronized \n",
434 // use the previous packet's "pts" once again:
435 dp
->pts
= bufferQueue
->prevPacketPTS
;
437 bufferQueue
->prevPacketWasSynchronized
= hasBeenSynchronized
;
439 dp
->pos
= demuxer
->filepos
;
440 demuxer
->filepos
+= frameSize
+ headersize
;
442 // Signal any pending 'doEventLoop()' call on this queue:
443 bufferQueue
->blockingFlag
= ~0;
446 static void onSourceClosure(void* clientData
) {
447 ReadBufferQueue
* bufferQueue
= (ReadBufferQueue
*)clientData
;
448 demuxer_t
* demuxer
= bufferQueue
->ourDemuxer();
450 demuxer
->stream
->eof
= 1;
452 // Signal any pending 'doEventLoop()' call on this queue:
453 bufferQueue
->blockingFlag
= ~0;
456 static demux_packet_t
* getBuffer(demuxer_t
* demuxer
, demux_stream_t
* ds
,
457 Boolean mustGetNewData
,
459 // Begin by finding the buffer queue that we want to read from:
460 // (Get this from the RTP state, which we stored in
461 // the demuxer's 'priv' field)
462 RTPState
* rtpState
= (RTPState
*)(demuxer
->priv
);
463 ReadBufferQueue
* bufferQueue
= NULL
;
467 if (demuxer
->stream
->eof
) return NULL
;
469 if (ds
== demuxer
->video
) {
470 bufferQueue
= rtpState
->videoBufferQueue
;
471 if (((sh_video_t
*)ds
->sh
)->format
== mmioFOURCC('H','2','6','4'))
473 } else if (ds
== demuxer
->audio
) {
474 bufferQueue
= rtpState
->audioBufferQueue
;
475 if (bufferQueue
->readSource()->isAMRAudioSource())
478 fprintf(stderr
, "(demux_rtp)getBuffer: internal error: unknown stream\n");
482 if (bufferQueue
== NULL
|| bufferQueue
->readSource() == NULL
) {
483 fprintf(stderr
, "(demux_rtp)getBuffer failed: no appropriate RTP subsession has been set up\n");
487 demux_packet_t
* dp
= NULL
;
488 if (!mustGetNewData
) {
489 // Check whether we have a previously-saved buffer that we can use:
490 dp
= bufferQueue
->getPendingBuffer();
492 ptsBehind
= 0.0; // so that we always accept this data
497 // Allocate a new packet buffer, and arrange to read into it:
498 if (!bufferQueue
->nextpacket
) {
499 dp
= new_demux_packet(MAX_RTP_FRAME_SIZE
);
500 bufferQueue
->dp
= dp
;
501 if (dp
== NULL
) return NULL
;
504 #ifdef CONFIG_LIBAVCODEC
505 extern AVCodecParserContext
* h264parserctx
;
506 int consumed
, poutbuf_size
= 1;
507 const uint8_t *poutbuf
= NULL
;
511 if (!bufferQueue
->nextpacket
) {
513 // Schedule the read operation:
514 bufferQueue
->blockingFlag
= 0;
515 bufferQueue
->readSource()->getNextFrame(&dp
->buffer
[headersize
], MAX_RTP_FRAME_SIZE
- headersize
,
516 afterReading
, bufferQueue
,
517 onSourceClosure
, bufferQueue
);
518 // Block ourselves until data becomes available:
519 TaskScheduler
& scheduler
520 = bufferQueue
->readSource()->envir().taskScheduler();
521 int delay
= 10000000;
522 if (bufferQueue
->prevPacketPTS
* 1.05 > rtpState
->mediaSession
->playEndTime())
524 task
= scheduler
.scheduleDelayedTask(delay
, onSourceClosure
, bufferQueue
);
525 scheduler
.doEventLoop(&bufferQueue
->blockingFlag
);
526 scheduler
.unscheduleDelayedTask(task
);
527 if (demuxer
->stream
->eof
) {
528 free_demux_packet(dp
);
532 if (headersize
== 1) // amr
534 ((AMRAudioSource
*)bufferQueue
->readSource())->lastFrameHeader();
535 #ifdef CONFIG_LIBAVCODEC
537 bufferQueue
->dp
= dp
= bufferQueue
->nextpacket
;
538 bufferQueue
->nextpacket
= NULL
;
540 if (headersize
== 3 && h264parserctx
) { // h264
541 consumed
= h264parserctx
->parser
->parser_parse(h264parserctx
,
543 &poutbuf
, &poutbuf_size
,
544 dp
->buffer
, dp
->len
);
546 if (!consumed
&& !poutbuf_size
)
551 free_demux_packet(dp
);
552 bufferQueue
->dp
= dp
= new_demux_packet(MAX_RTP_FRAME_SIZE
);
554 bufferQueue
->nextpacket
= dp
;
555 bufferQueue
->dp
= dp
= new_demux_packet(poutbuf_size
);
556 memcpy(dp
->buffer
, poutbuf
, poutbuf_size
);
560 } while (!poutbuf_size
);
563 // Set the "ptsBehind" result parameter:
564 if (bufferQueue
->prevPacketPTS
!= 0.0
565 && bufferQueue
->prevPacketWasSynchronized
566 && *(bufferQueue
->otherQueue
) != NULL
567 && (*(bufferQueue
->otherQueue
))->prevPacketPTS
!= 0.0
568 && (*(bufferQueue
->otherQueue
))->prevPacketWasSynchronized
) {
569 ptsBehind
= (*(bufferQueue
->otherQueue
))->prevPacketPTS
570 - bufferQueue
->prevPacketPTS
;
575 if (mustGetNewData
) {
576 // Save this buffer for future reads:
577 bufferQueue
->savePendingBuffer(dp
);
583 static void teardownRTSPorSIPSession(RTPState
* rtpState
) {
584 MediaSession
* mediaSession
= rtpState
->mediaSession
;
585 if (mediaSession
== NULL
) return;
586 if (rtpState
->rtspClient
!= NULL
) {
587 rtpState
->rtspClient
->teardownMediaSession(*mediaSession
);
588 } else if (rtpState
->sipClient
!= NULL
) {
589 rtpState
->sipClient
->sendBYE();
593 ////////// "ReadBuffer" and "ReadBufferQueue" implementation:
595 ReadBufferQueue::ReadBufferQueue(MediaSubsession
* subsession
,
596 demuxer_t
* demuxer
, char const* tag
)
597 : prevPacketWasSynchronized(False
), prevPacketPTS(0.0), otherQueue(NULL
),
598 dp(NULL
), nextpacket(NULL
),
599 pendingDPHead(NULL
), pendingDPTail(NULL
),
600 fReadSource(subsession
== NULL
? NULL
: subsession
->readSource()),
601 fRTPSource(subsession
== NULL
? NULL
: subsession
->rtpSource()),
602 fOurDemuxer(demuxer
), fTag(strdup(tag
)) {
605 ReadBufferQueue::~ReadBufferQueue() {
608 // Free any pending buffers (that never got delivered):
609 demux_packet_t
* dp
= pendingDPHead
;
611 demux_packet_t
* dpNext
= dp
->next
;
613 free_demux_packet(dp
);
618 void ReadBufferQueue::savePendingBuffer(demux_packet_t
* dp
) {
619 // Keep this buffer around, until MPlayer asks for it later:
620 if (pendingDPTail
== NULL
) {
621 pendingDPHead
= pendingDPTail
= dp
;
623 pendingDPTail
->next
= dp
;
629 demux_packet_t
* ReadBufferQueue::getPendingBuffer() {
630 demux_packet_t
* dp
= pendingDPHead
;
632 pendingDPHead
= dp
->next
;
633 if (pendingDPHead
== NULL
) pendingDPTail
= NULL
;
641 static int demux_rtp_control(struct demuxer_st
*demuxer
, int cmd
, void *arg
) {
642 double endpts
= ((RTPState
*)demuxer
->priv
)->mediaSession
->playEndTime();
645 case DEMUXER_CTRL_GET_TIME_LENGTH
:
647 return DEMUXER_CTRL_DONTKNOW
;
648 *((double *)arg
) = endpts
;
649 return DEMUXER_CTRL_OK
;
651 case DEMUXER_CTRL_GET_PERCENT_POS
:
653 return DEMUXER_CTRL_DONTKNOW
;
654 *((int *)arg
) = (int)(((RTPState
*)demuxer
->priv
)->videoBufferQueue
->prevPacketPTS
*100/endpts
);
655 return DEMUXER_CTRL_OK
;
658 return DEMUXER_CTRL_NOTIMPL
;
662 demuxer_desc_t demuxer_desc_rtp
= {
663 "LIVE555 RTP demuxer",
667 "requires LIVE555 Streaming Media library",
671 demux_rtp_fill_buffer
,