Mercurial > mplayer.hg
annotate libmpdemux/demux_nemesi.c @ 36802:621b61818a0f
configure: add -Zhigh-mem linker flag for OS/2
x264 encoder crashes due to memory allocation failure. This fixes the problem.
author | komh |
---|---|
date | Thu, 20 Feb 2014 13:59:34 +0000 |
parents | dba1b5aa72c1 |
children | 92dd1764392a |
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 */ |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
33858
diff
changeset
|
20 |
25267 | 21 #include <stdlib.h> |
22 #include <stdio.h> | |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
33858
diff
changeset
|
23 |
25267 | 24 #include "stream/stream.h" |
32059
319657dba8e1
Replace force_fps extern declaration by mpcommon.h #include.
diego
parents:
31609
diff
changeset
|
25 #include "mpcommon.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
33858
diff
changeset
|
26 #include "mp_msg.h" |
25267 | 27 #include "demuxer.h" |
24564 | 28 #include "stheader.h" |
29 #include "nemesi/rtsp.h" | |
30 #include "nemesi/rtp.h" | |
24856 | 31 #include <sched.h> |
24564 | 32 |
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 { | |
24855
2c790baff42c
Update to use newer libnemesi, should fix desync, fps guessing may fail now
lu_zero
parents:
24625
diff
changeset
|
114 rtp_ssrc *ssrc = NULL; |
24564 | 115 rtp_frame * fr = &ndsd->first_pkt[stype]; |
116 rtp_buff trash_buff; | |
25010 | 117 int must_prefetch = ((fps != NULL) || (buff != NULL)) ? 1 : 0; |
24564 | 118 |
119 ndsd->session[stype] = sess; | |
120 | |
24997 | 121 ssrc = wait_for_packets(ndsd, stype); |
24564 | 122 |
25010 | 123 if ( ((ssrc) && (must_prefetch)) ) { |
24997 | 124 if (buff == NULL) |
125 buff = &trash_buff; | |
24856 | 126 |
127 rtp_fill_buffer(ssrc, fr, buff); //Prefetch the first packet | |
24564 | 128 |
24998 | 129 /* Packet prefecthing must be done anyway or we won't be |
130 able to get the metadata, but fps calculation happens | |
131 only if the user didn't specify the FPS */ | |
25010 | 132 if ( ((!force_fps) && (fps != NULL)) ) { |
24998 | 133 while ( *fps <= 0 ) { |
134 //Wait more pkts to calculate FPS and try again | |
135 sched_yield(); | |
136 *fps = rtp_get_fps(ssrc); | |
137 } | |
138 } | |
24564 | 139 } |
140 } | |
141 | |
25267 | 142 static demuxer_t* demux_open_rtp(demuxer_t* demuxer) |
24564 | 143 { |
144 nms_rtsp_hints hints; | |
145 char * url = demuxer->stream->streaming_ctrl->url->url; | |
146 rtsp_ctrl * ctl; | |
147 RTSP_Error reply; | |
148 rtsp_medium * media; | |
149 Nemesi_DemuxerStreamData * ndsd = calloc(1, sizeof(Nemesi_DemuxerStreamData)); | |
150 | |
151 memset(&hints,0,sizeof(hints)); | |
25156 | 152 if (rtsp_port) hints.first_rtp_port = rtsp_port; |
24564 | 153 if (rtsp_transport_tcp) { |
154 hints.pref_rtsp_proto = TCP; | |
155 hints.pref_rtp_proto = TCP; | |
156 } | |
157 if (rtsp_transport_sctp) { | |
158 hints.pref_rtsp_proto = SCTP; | |
159 hints.pref_rtp_proto = SCTP; | |
160 } | |
161 | |
162 mp_msg(MSGT_DEMUX, MSGL_INFO, "Initializing libNemesi\n"); | |
163 if ((ctl = rtsp_init(&hints)) == NULL) { | |
164 free(ndsd); | |
165 return STREAM_ERROR; | |
166 } | |
167 | |
168 ndsd->rtsp = ctl; | |
169 demuxer->priv = ndsd; | |
170 //nms_verbosity_set(1); | |
171 | |
172 mp_msg(MSGT_DEMUX, MSGL_INFO, "Opening: %s\n", url); | |
173 if (rtsp_open(ctl, url)) { | |
174 mp_msg(MSGT_DEMUX, MSGL_ERR, "rtsp_open failed.\n"); | |
175 return demuxer; | |
176 } | |
177 | |
178 reply = rtsp_wait(ctl); | |
179 if (reply.got_error) { | |
180 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
181 "OPEN Error from the server: %s\n", | |
182 reply.message.reply_str); | |
183 return demuxer; | |
184 } | |
185 | |
186 rtsp_play(ctl, 0, 0); | |
187 reply = rtsp_wait(ctl); | |
188 if (reply.got_error) { | |
189 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
190 "PLAY Error from the server: %s\n", | |
191 reply.message.reply_str); | |
192 return demuxer; | |
193 } | |
194 | |
25490 | 195 if (!ctl->rtsp_queue) |
196 return demuxer; | |
197 | |
24564 | 198 media = ctl->rtsp_queue->media_queue; |
199 for (; media; media=media->next) { | |
200 sdp_medium_info * info = media->medium_info; | |
201 rtp_session * sess = media->rtp_sess; | |
25011 | 202 rtp_buff buff; |
24564 | 203 |
204 int media_format = atoi(info->fmts); | |
205 rtp_pt * ptinfo = rtp_get_pt_info(sess, media_format); | |
206 char const * format_name = ptinfo ? ptinfo->name : NULL; | |
207 | |
25011 | 208 memset(&buff, 0, sizeof(rtp_buff)); |
209 | |
24564 | 210 if (sess->parsers[media_format] == NULL) { |
211 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
212 "libNemesi unsupported media format: %s\n", | |
213 format_name ? format_name : info->fmts); | |
214 continue; | |
215 } | |
216 else { | |
217 mp_msg(MSGT_DEMUX, MSGL_INFO, | |
218 "libNemesi supported media: %s\n", | |
219 format_name); | |
220 } | |
221 | |
222 if (ptinfo->type == AU) { | |
223 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
|
224 sh_audio_t* sh_audio = new_sh_audio(demuxer,0, NULL); |
25011 | 225 WAVEFORMATEX* wf; |
24564 | 226 demux_stream_t* d_audio = demuxer->audio; |
27023 | 227 demuxer->audio->id = 0; |
24564 | 228 |
229 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as AUDIO stream...\n"); | |
230 | |
231 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_AUDIO, | |
25011 | 232 sess, &buff, NULL); |
233 | |
32125 | 234 wf = calloc(1,sizeof(*wf)+buff.len); |
235 wf->cbSize = buff.len; | |
236 memcpy(wf+1, buff.data, buff.len); | |
24564 | 237 |
238 sh_audio->wf = wf; | |
239 d_audio->sh = sh_audio; | |
240 sh_audio->ds = d_audio; | |
241 wf->nSamplesPerSec = 0; | |
242 | |
25103 | 243 wf->wFormatTag = |
244 sh_audio->format = get4CC(supported_audio, format_name); | |
245 if ( !(wf->wFormatTag) ) | |
24564 | 246 mp_msg(MSGT_DEMUX, MSGL_WARN, |
247 "Unknown MPlayer format code for MIME" | |
248 " type \"audio/%s\"\n", format_name); | |
249 } else { | |
250 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
251 "There is already an audio session registered," | |
252 " ignoring...\n"); | |
253 } | |
254 } else if (ptinfo->type == VI) { | |
25012 | 255 if (ndsd->session[NEMESI_SESSION_VIDEO] == NULL) { |
24564 | 256 sh_video_t* sh_video; |
257 BITMAPINFOHEADER* bih; | |
258 demux_stream_t* d_video; | |
259 int fps = 0; | |
260 | |
261 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as VIDEO stream...\n"); | |
262 | |
263 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_VIDEO, | |
264 sess, &buff, &fps); | |
265 | |
32125 | 266 bih = calloc(1,sizeof(*bih)+buff.len); |
267 bih->biSize = sizeof(*bih)+buff.len; | |
268 memcpy(bih+1, buff.data, buff.len); | |
24564 | 269 |
270 sh_video = new_sh_video(demuxer,0); | |
271 sh_video->bih = bih; | |
272 d_video = demuxer->video; | |
273 d_video->sh = sh_video; | |
274 sh_video->ds = d_video; | |
275 | |
24856 | 276 if (fps) { |
24564 | 277 sh_video->fps = fps; |
24856 | 278 sh_video->frametime = 1.0/fps; |
279 } | |
24564 | 280 |
25103 | 281 bih->biCompression = |
282 sh_video->format = get4CC(supported_video, format_name); | |
283 if ( !(bih->biCompression) ) { | |
24564 | 284 mp_msg(MSGT_DEMUX, MSGL_WARN, |
285 "Unknown MPlayer format code for MIME" | |
286 " type \"video/%s\"\n", format_name); | |
287 } | |
288 } else { | |
289 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
290 "There is already a video session registered," | |
291 " ignoring...\n"); | |
292 } | |
293 } else { | |
294 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported media type\n"); | |
295 } | |
296 } | |
297 | |
298 demuxer->stream->eof = 0; | |
299 | |
300 return demuxer; | |
301 } | |
302 | |
303 static int get_data_for_session(Nemesi_DemuxerStreamData * ndsd, | |
24997 | 304 Nemesi_SessionType stype, rtp_ssrc * ssrc, |
305 rtp_frame * fr) | |
24564 | 306 { |
24997 | 307 if (ndsd->first_pkt[stype].len != 0) { |
308 fr->data = ndsd->first_pkt[stype].data; | |
309 fr->time_sec = ndsd->first_pkt[stype].time_sec; | |
310 fr->len = ndsd->first_pkt[stype].len; | |
311 ndsd->first_pkt[stype].len = 0; | |
312 return RTP_FILL_OK; | |
313 } else { | |
314 rtp_buff buff; | |
315 return rtp_fill_buffer(ssrc, fr, &buff); | |
316 } | |
317 } | |
24564 | 318 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27023
diff
changeset
|
319 static void stream_add_packet(Nemesi_DemuxerStreamData * ndsd, |
24997 | 320 Nemesi_SessionType stype, |
321 demux_stream_t* ds, rtp_frame * fr) | |
322 { | |
323 demux_packet_t* dp = new_demux_packet(fr->len); | |
324 memcpy(dp->buffer, fr->data, fr->len); | |
24564 | 325 |
24997 | 326 fr->time_sec += ndsd->seek; |
327 ndsd->time[stype] = dp->pts = fr->time_sec; | |
328 | |
329 ds_add_packet(ds, dp); | |
24564 | 330 } |
331 | |
25267 | 332 static int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds) |
24564 | 333 { |
334 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
335 Nemesi_SessionType stype; | |
24997 | 336 rtp_ssrc * ssrc; |
24564 | 337 rtp_frame fr; |
338 | |
24997 | 339 if ( (!ndsd->rtsp->rtsp_queue) || (demuxer->stream->eof) ) { |
24564 | 340 mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n"); |
341 demuxer->stream->eof = 1; | |
342 return 0; | |
343 } | |
344 | |
25103 | 345 memset(&fr, 0, sizeof(fr)); |
346 | |
24997 | 347 stype = DS_TO_STYPE(demuxer, ds); |
348 if ( (ssrc = wait_for_packets(ndsd, stype)) == NULL ) { | |
349 mp_msg(MSGT_DEMUX, MSGL_INFO, "Bye...\n"); | |
350 demuxer->stream->eof = 1; | |
24564 | 351 return 0; |
352 } | |
353 | |
24997 | 354 if(!get_data_for_session(ndsd, stype, ssrc, &fr)) |
355 stream_add_packet(ndsd, stype, ds, &fr); | |
356 else { | |
357 stype = INVERT_STYPE(stype); | |
25013
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
358 |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
359 //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
|
360 if (!ndsd->session[stype]) |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
361 return 1; |
dc6b7ad240db
Check for second stream presence, fixes single stream playback (from amol)
lu_zero
parents:
25012
diff
changeset
|
362 |
24997 | 363 ds = STYPE_TO_DS(demuxer, stype); |
364 ssrc = wait_for_packets(ndsd, stype); | |
365 | |
366 if(!get_data_for_session(ndsd, stype, ssrc, &fr)) | |
367 stream_add_packet(ndsd, stype, ds, &fr); | |
24564 | 368 } |
369 | |
370 return 1; | |
371 } | |
372 | |
373 | |
25267 | 374 static void demux_close_rtp(demuxer_t* demuxer) |
24564 | 375 { |
376 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
377 rtsp_ctrl * ctl = ndsd->rtsp; | |
378 RTSP_Error err; | |
379 | |
380 mp_msg(MSGT_DEMUX, MSGL_INFO, "Closing libNemesi RTSP Stream...\n"); | |
381 | |
382 if (ndsd == NULL) | |
383 return; | |
384 | |
385 free(ndsd); | |
386 | |
387 if (rtsp_close(ctl)) { | |
388 err = rtsp_wait(ctl); | |
389 if (err.got_error) | |
390 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
391 "Error Closing Stream: %s\n", | |
392 err.message.reply_str); | |
393 } | |
394 | |
395 rtsp_uninit(ctl); | |
396 } | |
397 | |
398 static void demux_seek_rtp(demuxer_t *demuxer, float rel_seek_secs, | |
399 float audio_delay, int flags) | |
400 { | |
401 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
402 rtsp_ctrl * ctl = ndsd->rtsp; | |
403 sdp_attr * r_attr = NULL; | |
404 sdp_range r = {0, 0}; | |
405 double time = ndsd->time[NEMESI_SESSION_VIDEO] ? | |
406 ndsd->time[NEMESI_SESSION_VIDEO] : | |
407 ndsd->time[NEMESI_SESSION_AUDIO]; | |
408 | |
409 if (!ctl->rtsp_queue) | |
410 return; | |
411 | |
412 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range"); | |
413 if (r_attr) | |
414 r = sdp_parse_range(r_attr->value); | |
415 | |
416 //flags & 1 -> absolute seek | |
417 //flags & 2 -> percent seek | |
418 if (flags == 0) { | |
419 time += rel_seek_secs; | |
420 if (time < r.begin) | |
421 time = r.begin; | |
422 else if (time > r.end) | |
423 time = r.end; | |
424 ndsd->seek = time; | |
425 | |
426 mp_msg(MSGT_DEMUX,MSGL_WARN,"libNemesi SEEK %f on %f - %f)\n", | |
427 time, r.begin, r.end); | |
428 | |
429 if (!rtsp_seek(ctl, time, 0)) { | |
430 RTSP_Error err = rtsp_wait(ctl); | |
431 if (err.got_error) { | |
432 mp_msg(MSGT_DEMUX, MSGL_ERR, | |
433 "Error Performing Seek: %s\n", | |
434 err.message.reply_str); | |
435 demuxer->stream->eof = 1; | |
436 } | |
437 else | |
438 mp_msg(MSGT_DEMUX, MSGL_INFO, "Seek, performed\n"); | |
439 } | |
440 else { | |
441 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unable to pause stream to perform seek\n"); | |
442 demuxer->stream->eof = 1; | |
443 } | |
444 } | |
445 else | |
446 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported seek type\n"); | |
447 } | |
448 | |
30644
390c8d36d463
Drop weird and unnecessary _s/_st suffixes from demuxer struct names.
diego
parents:
29263
diff
changeset
|
449 static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg) |
24564 | 450 { |
451 Nemesi_DemuxerStreamData * ndsd = demuxer->priv; | |
452 rtsp_ctrl * ctl = ndsd->rtsp; | |
453 sdp_attr * r_attr = NULL; | |
454 sdp_range r = {0, 0}; | |
455 double time = ndsd->time[NEMESI_SESSION_VIDEO] ? | |
456 ndsd->time[NEMESI_SESSION_VIDEO] : | |
457 ndsd->time[NEMESI_SESSION_AUDIO]; | |
458 | |
459 if (!ctl->rtsp_queue) | |
460 return DEMUXER_CTRL_DONTKNOW; | |
461 | |
462 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range"); | |
463 if (r_attr) | |
464 r = sdp_parse_range(r_attr->value); | |
465 | |
466 switch (cmd) { | |
467 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
468 if (r.end == 0) | |
469 return DEMUXER_CTRL_DONTKNOW; | |
470 | |
471 *((double *)arg) = ((double)r.end) - ((double)r.begin); | |
472 return DEMUXER_CTRL_OK; | |
473 | |
474 case DEMUXER_CTRL_GET_PERCENT_POS: | |
475 if (r.end == 0) | |
476 return DEMUXER_CTRL_DONTKNOW; | |
477 | |
478 *((int *)arg) = (int)( time * 100 / (r.end - r.begin) ); | |
479 return DEMUXER_CTRL_OK; | |
480 default: | |
481 return DEMUXER_CTRL_DONTKNOW; | |
482 } | |
483 } | |
484 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25490
diff
changeset
|
485 const demuxer_desc_t demuxer_desc_rtp_nemesi = { |
25270 | 486 "libnemesi RTP demuxer", |
487 "nemesi", | |
24564 | 488 "", |
489 "Alessandro Molina", | |
25270 | 490 "requires libnemesi", |
25266
239330301b33
Make libnemesi use specific struct and DEMUXER_TYPE
lu_zero
parents:
25156
diff
changeset
|
491 DEMUXER_TYPE_RTP_NEMESI, |
24564 | 492 0, // no autodetect |
493 NULL, | |
494 demux_rtp_fill_buffer, | |
495 demux_open_rtp, | |
496 demux_close_rtp, | |
497 demux_seek_rtp, | |
498 demux_rtp_control | |
499 }; |