Mercurial > mplayer.hg
annotate libmpdemux/demux_nemesi.c @ 31645:9666dd193544
Fix calculation of global_sub_size.
author | reimar |
---|---|
date | Sun, 11 Jul 2010 17:53:44 +0000 |
parents | cd81fce1f010 |
children | 319657dba8e1 |
rev | line source |
---|---|
24564 | 1 /* |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
2 * Copyright (C) 2007 Alessandro Molina <amol.wrk@gmail.com> |
24564 | 3 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
4 * This file is part of MPlayer. |
24564 | 5 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
9 * (at your option) any later version. |
24564 | 10 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
14 * GNU General Public License for more details. |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
15 * |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25965
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
24564 | 19 */ |
25267 | 20 #include <stdlib.h> |
21 #include <stdio.h> | |
22 #include "stream/stream.h" | |
23 #include "demuxer.h" | |
24564 | 24 #include "stheader.h" |
25 #define HAVE_STRUCT_SOCKADDR_STORAGE | |
26 #include "nemesi/rtsp.h" | |
27 #include "nemesi/rtp.h" | |
24856 | 28 #include <sched.h> |
24564 | 29 |
31282 | 30 int rtsp_transport_http = 0; |
24564 | 31 int rtsp_transport_tcp = 0; |
32 int rtsp_transport_sctp = 0; | |
25156 | 33 int rtsp_port = 0; |
24564 | 34 |
25103 | 35 typedef struct { |
36 char * mime; | |
37 unsigned int fourcc; | |
38 } MIMEto4CC; | |
39 | |
40 #define NMS_MAX_FORMATS 16 | |
41 | |
42 MIMEto4CC supported_audio[NMS_MAX_FORMATS] = { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27023
diff
changeset
|
43 {"MPA", 0x55}, |
25103 | 44 {"vorbis", mmioFOURCC('v','r','b','s')}, |
25104 | 45 {"mpeg4-generic", mmioFOURCC('M','P','4','A')}, |
25103 | 46 {NULL, 0}, |
47 }; | |
48 | |
49 MIMEto4CC supported_video[NMS_MAX_FORMATS] = { | |
50 {"MPV", mmioFOURCC('M','P','E','G')}, | |
25116 | 51 {"theora",mmioFOURCC('t','h','e','o')}, |
25103 | 52 {"H264", mmioFOURCC('H','2','6','4')}, |
53 {"H263-1998", mmioFOURCC('H','2','6','3')}, | |
54 {"MP4V-ES", mmioFOURCC('M','P','4','V')}, | |
55 {NULL, 0}, | |
56 }; | |
57 | |
24564 | 58 typedef enum { NEMESI_SESSION_VIDEO, |
59 NEMESI_SESSION_AUDIO } Nemesi_SessionType; | |
60 | |
61 typedef struct { | |
62 rtsp_ctrl * rtsp; | |
63 rtp_session * session[2]; | |
64 rtp_frame first_pkt[2]; | |
65 double time[2]; | |
66 double seek; | |
67 } Nemesi_DemuxerStreamData; | |
68 | |
24997 | 69 |
70 #define STYPE_TO_DS(demuxer, stype) \ | |
71 ((stype) == NEMESI_SESSION_VIDEO ? (demuxer)->video : (demuxer)->audio) | |
72 | |
73 #define DS_TO_STYPE(demuxer, ds) \ | |
74 ((ds) == (demuxer)->video ? NEMESI_SESSION_VIDEO : NEMESI_SESSION_AUDIO) | |
75 | |
76 #define INVERT_STYPE(stype) ((stype + 1) % 2) | |
77 | |
25103 | 78 static unsigned int get4CC(MIMEto4CC * supported_formats, char const * format) |
79 { | |
80 unsigned i; | |
81 | |
82 for(i = 0; i < NMS_MAX_FORMATS; ++i) { | |
83 if (!supported_formats[i].mime) | |
84 return 0; | |
85 else if ( strcmp(supported_formats[i].mime, format) == 0 ) | |
86 return supported_formats[i].fourcc; | |
87 } | |
88 | |
89 return 0; | |
90 } | |
24997 | 91 |
92 static rtp_ssrc *wait_for_packets(Nemesi_DemuxerStreamData * ndsd, Nemesi_SessionType stype) | |
93 { | |
94 rtp_ssrc *ssrc = NULL; | |
95 | |
96 /* Wait for prebuffering (prebuffering must be enabled in nemesi) */ | |
97 int terminated = rtp_fill_buffers(rtsp_get_rtp_th(ndsd->rtsp)); | |
98 | |
99 /* Wait for the ssrc to be registered, if prebuffering is on in nemesi | |
100 this will just get immediatly the correct ssrc */ | |
101 if (!terminated) { | |
102 while ( !(ssrc = rtp_session_get_ssrc(ndsd->session[stype], ndsd->rtsp)) ) | |
103 sched_yield(); | |
104 } | |
105 | |
106 return ssrc; | |
107 } | |
108 | |
24564 | 109 static void link_session_and_fetch_conf(Nemesi_DemuxerStreamData * ndsd, |
110 Nemesi_SessionType stype, | |
111 rtp_session * sess, | |
112 rtp_buff * buff, unsigned int * fps) | |
113 { | |
25965 | 114 extern double force_fps; |
24855
2c790baff42c
Update to use newer libnemesi, should fix desync, fps guessing may fail now
lu_zero
parents:
24625
diff
changeset
|
115 rtp_ssrc *ssrc = NULL; |
24564 | 116 rtp_frame * fr = &ndsd->first_pkt[stype]; |
117 rtp_buff trash_buff; | |
25010 | 118 int must_prefetch = ((fps != NULL) || (buff != NULL)) ? 1 : 0; |
24564 | 119 |
120 ndsd->session[stype] = sess; | |
121 | |
24997 | 122 ssrc = wait_for_packets(ndsd, stype); |
24564 | 123 |
25010 | 124 if ( ((ssrc) && (must_prefetch)) ) { |
24997 | 125 if (buff == NULL) |
126 buff = &trash_buff; | |
24856 | 127 |
128 rtp_fill_buffer(ssrc, fr, buff); //Prefetch the first packet | |
24564 | 129 |
24998 | 130 /* Packet prefecthing must be done anyway or we won't be |
131 able to get the metadata, but fps calculation happens | |
132 only if the user didn't specify the FPS */ | |
25010 | 133 if ( ((!force_fps) && (fps != NULL)) ) { |
24998 | 134 while ( *fps <= 0 ) { |
135 //Wait more pkts to calculate FPS and try again | |
136 sched_yield(); | |
137 *fps = rtp_get_fps(ssrc); | |
138 } | |
139 } | |
24564 | 140 } |
141 } | |
142 | |
25267 | 143 static demuxer_t* demux_open_rtp(demuxer_t* demuxer) |
24564 | 144 { |
145 nms_rtsp_hints hints; | |
146 char * url = demuxer->stream->streaming_ctrl->url->url; | |
147 rtsp_ctrl * ctl; | |
148 RTSP_Error reply; | |
149 rtsp_medium * media; | |
150 Nemesi_DemuxerStreamData * ndsd = calloc(1, sizeof(Nemesi_DemuxerStreamData)); | |
151 | |
152 memset(&hints,0,sizeof(hints)); | |
25156 | 153 if (rtsp_port) hints.first_rtp_port = rtsp_port; |
24564 | 154 if (rtsp_transport_tcp) { |
155 hints.pref_rtsp_proto = TCP; | |
156 hints.pref_rtp_proto = TCP; | |
157 } | |
158 if (rtsp_transport_sctp) { | |
159 hints.pref_rtsp_proto = SCTP; | |
160 hints.pref_rtp_proto = SCTP; | |
161 } | |
162 | |
163 mp_msg(MSGT_DEMUX, MSGL_INFO, "Initializing libNemesi\n"); | |
164 if ((ctl = rtsp_init(&hints)) == NULL) { | |
165 free(ndsd); | |
166 return STREAM_ERROR; | |
167 } | |
168 | |
169 ndsd->rtsp = ctl; | |
170 demuxer->priv = ndsd; | |
171 //nms_verbosity_set(1); | |
172 | |
173 mp_msg(MSGT_DEMUX, MSGL_INFO, "Opening: %s\n", url); | |
174 if (rtsp_open(ctl, url)) { | |
175 mp_msg(MSGT_DEMUX, MSGL_ERR, "rtsp_open failed.\n"); | |
176 return demuxer; | |
177 } | |
178 | |
179 reply = rtsp_wait(ctl); | |
180 if (reply.got_error) { | |
181 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
182 "OPEN Error from the server: %s\n", | |
183 reply.message.reply_str); | |
184 return demuxer; | |
185 } | |
186 | |
187 rtsp_play(ctl, 0, 0); | |
188 reply = rtsp_wait(ctl); | |
189 if (reply.got_error) { | |
190 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
191 "PLAY Error from the server: %s\n", | |
192 reply.message.reply_str); | |
193 return demuxer; | |
194 } | |
195 | |
25490 | 196 if (!ctl->rtsp_queue) |
197 return demuxer; | |
198 | |
24564 | 199 media = ctl->rtsp_queue->media_queue; |
200 for (; media; media=media->next) { | |
201 sdp_medium_info * info = media->medium_info; | |
202 rtp_session * sess = media->rtp_sess; | |
25011 | 203 rtp_buff buff; |
24564 | 204 |
205 int media_format = atoi(info->fmts); | |
206 rtp_pt * ptinfo = rtp_get_pt_info(sess, media_format); | |
207 char const * format_name = ptinfo ? ptinfo->name : NULL; | |
208 | |
25011 | 209 memset(&buff, 0, sizeof(rtp_buff)); |
210 | |
24564 | 211 if (sess->parsers[media_format] == NULL) { |
212 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
213 "libNemesi unsupported media format: %s\n", | |
214 format_name ? format_name : info->fmts); | |
215 continue; | |
216 } | |
217 else { | |
218 mp_msg(MSGT_DEMUX, MSGL_INFO, | |
219 "libNemesi supported media: %s\n", | |
220 format_name); | |
221 } | |
222 | |
223 if (ptinfo->type == AU) { | |
224 if (ndsd->session[NEMESI_SESSION_AUDIO] == NULL) { | |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
31282
diff
changeset
|
225 sh_audio_t* sh_audio = new_sh_audio(demuxer,0, NULL); |
25011 | 226 WAVEFORMATEX* wf; |
24564 | 227 demux_stream_t* d_audio = demuxer->audio; |
27023 | 228 demuxer->audio->id = 0; |
24564 | 229 |
230 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as AUDIO stream...\n"); | |
231 | |
232 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_AUDIO, | |
25011 | 233 sess, &buff, NULL); |
234 | |
235 if (buff.len) { | |
236 wf = calloc(1,sizeof(WAVEFORMATEX)+buff.len); | |
237 wf->cbSize = buff.len; | |
238 memcpy(wf+1, buff.data, buff.len); | |
239 } else { | |
240 wf = calloc(1,sizeof(WAVEFORMATEX)); | |
241 } | |
24564 | 242 |
243 sh_audio->wf = wf; | |
244 d_audio->sh = sh_audio; | |
245 sh_audio->ds = d_audio; | |
246 wf->nSamplesPerSec = 0; | |
247 | |
25103 | 248 wf->wFormatTag = |
249 sh_audio->format = get4CC(supported_audio, format_name); | |
250 if ( !(wf->wFormatTag) ) | |
24564 | 251 mp_msg(MSGT_DEMUX, MSGL_WARN, |
252 "Unknown MPlayer format code for MIME" | |
253 " type \"audio/%s\"\n", format_name); | |
254 } else { | |
255 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
256 "There is already an audio session registered," | |
257 " ignoring...\n"); | |
258 } | |
259 } else if (ptinfo->type == VI) { | |
25012 | 260 if (ndsd->session[NEMESI_SESSION_VIDEO] == NULL) { |
24564 | 261 sh_video_t* sh_video; |
262 BITMAPINFOHEADER* bih; | |
263 demux_stream_t* d_video; | |
264 int fps = 0; | |
265 | |
266 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as VIDEO stream...\n"); | |
267 | |
268 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_VIDEO, | |
269 sess, &buff, &fps); | |
270 | |
271 if (buff.len) { | |
272 bih = calloc(1,sizeof(BITMAPINFOHEADER)+buff.len); | |
273 bih->biSize = sizeof(BITMAPINFOHEADER)+buff.len; | |
274 memcpy(bih+1, buff.data, buff.len); | |
275 } else { | |
276 bih = calloc(1,sizeof(BITMAPINFOHEADER)); | |
277 bih->biSize = sizeof(BITMAPINFOHEADER); | |
278 } | |
279 | |
280 sh_video = new_sh_video(demuxer,0); | |
281 sh_video->bih = bih; | |
282 d_video = demuxer->video; | |
283 d_video->sh = sh_video; | |
284 sh_video->ds = d_video; | |
285 | |
24856 | 286 if (fps) { |
24564 | 287 sh_video->fps = fps; |
24856 | 288 sh_video->frametime = 1.0/fps; |
289 } | |
24564 | 290 |
25103 | 291 bih->biCompression = |
292 sh_video->format = get4CC(supported_video, format_name); | |
293 if ( !(bih->biCompression) ) { | |
24564 | 294 mp_msg(MSGT_DEMUX, MSGL_WARN, |
295 "Unknown MPlayer format code for MIME" | |
296 " type \"video/%s\"\n", format_name); | |
297 } | |
298 } else { | |
299 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
300 "There is already a video session registered," | |
301 " ignoring...\n"); | |
302 } | |
303 } else { | |
304 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported media type\n"); | |
305 } | |
306 } | |
307 | |
308 demuxer->stream->eof = 0; | |
309 | |
310 return demuxer; | |
311 } | |
312 | |
313 static int get_data_for_session(Nemesi_DemuxerStreamData * ndsd, | |
24997 | 314 Nemesi_SessionType stype, rtp_ssrc * ssrc, |
315 rtp_frame * fr) | |
24564 | 316 { |
24997 | 317 if (ndsd->first_pkt[stype].len != 0) { |
318 fr->data = ndsd->first_pkt[stype].data; | |
319 fr->time_sec = ndsd->first_pkt[stype].time_sec; | |
320 fr->len = ndsd->first_pkt[stype].len; | |
321 ndsd->first_pkt[stype].len = 0; | |
322 return RTP_FILL_OK; | |
323 } else { | |
324 rtp_buff buff; | |
325 return rtp_fill_buffer(ssrc, fr, &buff); | |
326 } | |
327 } | |
24564 | 328 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27023
diff
changeset
|
329 static void stream_add_packet(Nemesi_DemuxerStreamData * ndsd, |
24997 | 330 Nemesi_SessionType stype, |
331 demux_stream_t* ds, rtp_frame * fr) | |
332 { | |
333 demux_packet_t* dp = new_demux_packet(fr->len); | |
334 memcpy(dp->buffer, fr->data, fr->len); | |
24564 | 335 |
24997 | 336 fr->time_sec += ndsd->seek; |
337 ndsd->time[stype] = dp->pts = fr->time_sec; | |
338 | |
339 ds_add_packet(ds, dp); | |
24564 | 340 } |
341 | |
25267 | 342 static int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds) |
24564 | 343 { |
344 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
345 Nemesi_SessionType stype; | |
24997 | 346 rtp_ssrc * ssrc; |
24564 | 347 rtp_frame fr; |
348 | |
24997 | 349 if ( (!ndsd->rtsp->rtsp_queue) || (demuxer->stream->eof) ) { |
24564 | 350 mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n"); |
351 demuxer->stream->eof = 1; | |
352 return 0; | |
353 } | |
354 | |
25103 | 355 memset(&fr, 0, sizeof(fr)); |
356 | |
24997 | 357 stype = DS_TO_STYPE(demuxer, ds); |
358 if ( (ssrc = wait_for_packets(ndsd, stype)) == NULL ) { | |
359 mp_msg(MSGT_DEMUX, MSGL_INFO, "Bye...\n"); | |
360 demuxer->stream->eof = 1; | |
24564 | 361 return 0; |
362 } | |
363 | |
24997 | 364 if(!get_data_for_session(ndsd, stype, ssrc, &fr)) |
365 stream_add_packet(ndsd, stype, ds, &fr); | |
366 else { | |
367 stype = INVERT_STYPE(stype); | |
25013
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
368 |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
369 //Must check if we actually have a stream of the other type |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
370 if (!ndsd->session[stype]) |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
371 return 1; |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
372 |
24997 | 373 ds = STYPE_TO_DS(demuxer, stype); |
374 ssrc = wait_for_packets(ndsd, stype); | |
375 | |
376 if(!get_data_for_session(ndsd, stype, ssrc, &fr)) | |
377 stream_add_packet(ndsd, stype, ds, &fr); | |
24564 | 378 } |
379 | |
380 return 1; | |
381 } | |
382 | |
383 | |
25267 | 384 static void demux_close_rtp(demuxer_t* demuxer) |
24564 | 385 { |
386 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
387 rtsp_ctrl * ctl = ndsd->rtsp; | |
388 RTSP_Error err; | |
389 | |
390 mp_msg(MSGT_DEMUX, MSGL_INFO, "Closing libNemesi RTSP Stream...\n"); | |
391 | |
392 if (ndsd == NULL) | |
393 return; | |
394 | |
395 free(ndsd); | |
396 | |
397 if (rtsp_close(ctl)) { | |
398 err = rtsp_wait(ctl); | |
399 if (err.got_error) | |
400 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
401 "Error Closing Stream: %s\n", | |
402 err.message.reply_str); | |
403 } | |
404 | |
405 rtsp_uninit(ctl); | |
406 } | |
407 | |
408 static void demux_seek_rtp(demuxer_t *demuxer, float rel_seek_secs, | |
409 float audio_delay, int flags) | |
410 { | |
411 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
412 rtsp_ctrl * ctl = ndsd->rtsp; | |
413 sdp_attr * r_attr = NULL; | |
414 sdp_range r = {0, 0}; | |
415 double time = ndsd->time[NEMESI_SESSION_VIDEO] ? | |
416 ndsd->time[NEMESI_SESSION_VIDEO] : | |
417 ndsd->time[NEMESI_SESSION_AUDIO]; | |
418 | |
419 if (!ctl->rtsp_queue) | |
420 return; | |
421 | |
422 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range"); | |
423 if (r_attr) | |
424 r = sdp_parse_range(r_attr->value); | |
425 | |
426 //flags & 1 -> absolute seek | |
427 //flags & 2 -> percent seek | |
428 if (flags == 0) { | |
429 time += rel_seek_secs; | |
430 if (time < r.begin) | |
431 time = r.begin; | |
432 else if (time > r.end) | |
433 time = r.end; | |
434 ndsd->seek = time; | |
435 | |
436 mp_msg(MSGT_DEMUX,MSGL_WARN,"libNemesi SEEK %f on %f - %f)\n", | |
437 time, r.begin, r.end); | |
438 | |
439 if (!rtsp_seek(ctl, time, 0)) { | |
440 RTSP_Error err = rtsp_wait(ctl); | |
441 if (err.got_error) { | |
442 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
443 "Error Performing Seek: %s\n", | |
444 err.message.reply_str); | |
445 demuxer->stream->eof = 1; | |
446 } | |
447 else | |
448 mp_msg(MSGT_DEMUX, MSGL_INFO, "Seek, performed\n"); | |
449 } | |
450 else { | |
451 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unable to pause stream to perform seek\n"); | |
452 demuxer->stream->eof = 1; | |
453 } | |
454 } | |
455 else | |
456 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported seek type\n"); | |
457 } | |
458 | |
30644
390c8d36d463
Drop weird and unnecessary _s/_st suffixes from demuxer struct names.
diego
parents:
29263
diff
changeset
|
459 static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg) |
24564 | 460 { |
461 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
462 rtsp_ctrl * ctl = ndsd->rtsp; | |
463 sdp_attr * r_attr = NULL; | |
464 sdp_range r = {0, 0}; | |
465 double time = ndsd->time[NEMESI_SESSION_VIDEO] ? | |
466 ndsd->time[NEMESI_SESSION_VIDEO] : | |
467 ndsd->time[NEMESI_SESSION_AUDIO]; | |
468 | |
469 if (!ctl->rtsp_queue) | |
470 return DEMUXER_CTRL_DONTKNOW; | |
471 | |
472 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range"); | |
473 if (r_attr) | |
474 r = sdp_parse_range(r_attr->value); | |
475 | |
476 switch (cmd) { | |
477 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
478 if (r.end == 0) | |
479 return DEMUXER_CTRL_DONTKNOW; | |
480 | |
481 *((double *)arg) = ((double)r.end) - ((double)r.begin); | |
482 return DEMUXER_CTRL_OK; | |
483 | |
484 case DEMUXER_CTRL_GET_PERCENT_POS: | |
485 if (r.end == 0) | |
486 return DEMUXER_CTRL_DONTKNOW; | |
487 | |
488 *((int *)arg) = (int)( time * 100 / (r.end - r.begin) ); | |
489 return DEMUXER_CTRL_OK; | |
490 default: | |
491 return DEMUXER_CTRL_DONTKNOW; | |
492 } | |
493 } | |
494 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25490
diff
changeset
|
495 const demuxer_desc_t demuxer_desc_rtp_nemesi = { |
25270 | 496 "libnemesi RTP demuxer", |
497 "nemesi", | |
24564 | 498 "", |
499 "Alessandro Molina", | |
25270 | 500 "requires libnemesi", |
25266
239330301b33
Make libnemesi use specific struct and DEMUXER_TYPE
lu_zero
parents:
25156
diff
changeset
|
501 DEMUXER_TYPE_RTP_NEMESI, |
24564 | 502 0, // no autodetect |
503 NULL, | |
504 demux_rtp_fill_buffer, | |
505 demux_open_rtp, | |
506 demux_close_rtp, | |
507 demux_seek_rtp, | |
508 demux_rtp_control | |
509 }; |