Mercurial > mplayer.hg
annotate libmpdemux/demuxer.c @ 27049:762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
author | diego |
---|---|
date | Mon, 16 Jun 2008 10:31:05 +0000 |
parents | d28fa58e931e |
children | c9609bfa816a |
rev | line source |
---|---|
1 | 1 //=================== DEMUXER v2.5 ========================= |
2 | |
1430 | 3 #include <stdio.h> |
4 #include <stdlib.h> | |
3150 | 5 #include <string.h> |
1430 | 6 #include <unistd.h> |
7 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1421
diff
changeset
|
8 #include <sys/types.h> |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1421
diff
changeset
|
9 #include <sys/stat.h> |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1421
diff
changeset
|
10 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
11 #include "config.h" |
1567 | 12 #include "mp_msg.h" |
1584 | 13 #include "help_mp.h" |
17012 | 14 #include "m_config.h" |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
15 |
17200
a1b8eeffdfcd
include fastmemcpy.h before stream.h, so it is used for the stream_read
reimar
parents:
17012
diff
changeset
|
16 #include "libvo/fastmemcpy.h" |
a1b8eeffdfcd
include fastmemcpy.h before stream.h, so it is used for the stream_read
reimar
parents:
17012
diff
changeset
|
17 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22488
diff
changeset
|
18 #include "stream/stream.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
19 #include "demuxer.h" |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
20 #include "stheader.h" |
4551 | 21 #include "mf.h" |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
22 |
17012 | 23 #include "libaf/af_format.h" |
5084 | 24 |
25654
0190aa38aae2
Init and destroy ass_tracks in demuxer.c based on sh_sub->type value.
eugeni
parents:
25652
diff
changeset
|
25 #ifdef USE_ASS |
0190aa38aae2
Init and destroy ass_tracks in demuxer.c based on sh_sub->type value.
eugeni
parents:
25652
diff
changeset
|
26 #include "libass/ass.h" |
0190aa38aae2
Init and destroy ass_tracks in demuxer.c based on sh_sub->type value.
eugeni
parents:
25652
diff
changeset
|
27 #include "libass/ass_mp.h" |
0190aa38aae2
Init and destroy ass_tracks in demuxer.c based on sh_sub->type value.
eugeni
parents:
25652
diff
changeset
|
28 #endif |
0190aa38aae2
Init and destroy ass_tracks in demuxer.c based on sh_sub->type value.
eugeni
parents:
25652
diff
changeset
|
29 |
22142
84f95595f31f
Fix a few gcc warnings, approved by Diego and Reimar.
rathann
parents:
21809
diff
changeset
|
30 extern void resync_video_stream(sh_video_t *sh_video); |
16877
9081ae3a702c
move resync_audio_stream after seeking to demuxer.c
reimar
parents:
16572
diff
changeset
|
31 extern void resync_audio_stream(sh_audio_t *sh_audio); |
16175 | 32 |
33 // Demuxer list | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
34 extern const demuxer_desc_t demuxer_desc_rawaudio; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
35 extern const demuxer_desc_t demuxer_desc_rawvideo; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
36 extern const demuxer_desc_t demuxer_desc_tv; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
37 extern const demuxer_desc_t demuxer_desc_mf; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
38 extern const demuxer_desc_t demuxer_desc_avi; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
39 extern const demuxer_desc_t demuxer_desc_y4m; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
40 extern const demuxer_desc_t demuxer_desc_asf; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
41 extern const demuxer_desc_t demuxer_desc_nuv; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
42 extern const demuxer_desc_t demuxer_desc_real; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
43 extern const demuxer_desc_t demuxer_desc_smjpeg; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
44 extern const demuxer_desc_t demuxer_desc_matroska; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
45 extern const demuxer_desc_t demuxer_desc_realaudio; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
46 extern const demuxer_desc_t demuxer_desc_vqf; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
47 extern const demuxer_desc_t demuxer_desc_mov; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
48 extern const demuxer_desc_t demuxer_desc_vivo; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
49 extern const demuxer_desc_t demuxer_desc_fli; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
50 extern const demuxer_desc_t demuxer_desc_film; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
51 extern const demuxer_desc_t demuxer_desc_roq; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
52 extern const demuxer_desc_t demuxer_desc_gif; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
53 extern const demuxer_desc_t demuxer_desc_ogg; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
54 extern const demuxer_desc_t demuxer_desc_avs; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
55 extern const demuxer_desc_t demuxer_desc_pva; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
56 extern const demuxer_desc_t demuxer_desc_nsv; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
57 extern const demuxer_desc_t demuxer_desc_mpeg_ts; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
58 extern const demuxer_desc_t demuxer_desc_lmlm4; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
59 extern const demuxer_desc_t demuxer_desc_mpeg_ps; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
60 extern const demuxer_desc_t demuxer_desc_mpeg_pes; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
61 extern const demuxer_desc_t demuxer_desc_mpeg_es; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
62 extern const demuxer_desc_t demuxer_desc_mpeg_gxf; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
63 extern const demuxer_desc_t demuxer_desc_mpeg4_es; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
64 extern const demuxer_desc_t demuxer_desc_h264_es; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
65 extern const demuxer_desc_t demuxer_desc_rawdv; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
66 extern const demuxer_desc_t demuxer_desc_mpc; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
67 extern const demuxer_desc_t demuxer_desc_audio; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
68 extern const demuxer_desc_t demuxer_desc_xmms; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
69 extern const demuxer_desc_t demuxer_desc_mpeg_ty; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
70 extern const demuxer_desc_t demuxer_desc_rtp; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
71 extern const demuxer_desc_t demuxer_desc_rtp_nemesi; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
72 extern const demuxer_desc_t demuxer_desc_lavf; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
73 extern const demuxer_desc_t demuxer_desc_lavf_preferred; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
74 extern const demuxer_desc_t demuxer_desc_aac; |
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25706
diff
changeset
|
75 extern const demuxer_desc_t demuxer_desc_nut; |
16175 | 76 |
25876
edfe8baed49f
copy note on new demuxers and codecs to the top of the array as well to be
ivo
parents:
25872
diff
changeset
|
77 /* Please do not add any new demuxers here. If you want to implement a new |
25880
4df11ac927fc
clarify comments/docs about lav* being the preferred place to implement new
ivo
parents:
25876
diff
changeset
|
78 * demuxer, add it to libavformat, except for wrappers around external |
4df11ac927fc
clarify comments/docs about lav* being the preferred place to implement new
ivo
parents:
25876
diff
changeset
|
79 * libraries and demuxers requiring binary support. */ |
25876
edfe8baed49f
copy note on new demuxers and codecs to the top of the array as well to be
ivo
parents:
25872
diff
changeset
|
80 |
26437 | 81 const demuxer_desc_t* const demuxer_list[] = { |
82 &demuxer_desc_rawaudio, | |
83 &demuxer_desc_rawvideo, | |
16175 | 84 #ifdef USE_TV |
26437 | 85 &demuxer_desc_tv, |
16175 | 86 #endif |
26437 | 87 &demuxer_desc_mf, |
23121
a257dd426da5
Simplify preprocessor directives: There is a general variable for
diego
parents:
23072
diff
changeset
|
88 #ifdef USE_LIBAVFORMAT |
26437 | 89 &demuxer_desc_lavf_preferred, |
23069
93948eb0280f
demuxer_desc_lavf_preferred depends on USE_LIBAVFORMAT or USE_LIBAVFORMAT_SO
nicodvb
parents:
22971
diff
changeset
|
90 #endif |
26437 | 91 &demuxer_desc_avi, |
92 &demuxer_desc_y4m, | |
93 &demuxer_desc_asf, | |
94 &demuxer_desc_nsv, | |
95 &demuxer_desc_nuv, | |
96 &demuxer_desc_real, | |
97 &demuxer_desc_smjpeg, | |
98 &demuxer_desc_matroska, | |
99 &demuxer_desc_realaudio, | |
100 &demuxer_desc_vqf, | |
101 &demuxer_desc_mov, | |
102 &demuxer_desc_vivo, | |
103 &demuxer_desc_fli, | |
104 &demuxer_desc_film, | |
105 &demuxer_desc_roq, | |
16175 | 106 #ifdef HAVE_GIF |
26437 | 107 &demuxer_desc_gif, |
16175 | 108 #endif |
109 #ifdef HAVE_OGGVORBIS | |
26437 | 110 &demuxer_desc_ogg, |
16175 | 111 #endif |
112 #ifdef USE_WIN32DLL | |
26437 | 113 &demuxer_desc_avs, |
16175 | 114 #endif |
26437 | 115 &demuxer_desc_pva, |
116 &demuxer_desc_mpeg_ts, | |
117 &demuxer_desc_lmlm4, | |
118 &demuxer_desc_mpeg_ps, | |
119 &demuxer_desc_mpeg_pes, | |
120 &demuxer_desc_mpeg_es, | |
121 &demuxer_desc_mpeg_gxf, | |
122 &demuxer_desc_mpeg4_es, | |
123 &demuxer_desc_h264_es, | |
124 &demuxer_desc_audio, | |
125 &demuxer_desc_mpeg_ty, | |
25266
239330301b33
Make libnemesi use specific struct and DEMUXER_TYPE
lu_zero
parents:
25197
diff
changeset
|
126 #ifdef STREAMING_LIVE555 |
26437 | 127 &demuxer_desc_rtp, |
16175 | 128 #endif |
25266
239330301b33
Make libnemesi use specific struct and DEMUXER_TYPE
lu_zero
parents:
25197
diff
changeset
|
129 #ifdef LIBNEMESI |
26437 | 130 &demuxer_desc_rtp_nemesi, |
25266
239330301b33
Make libnemesi use specific struct and DEMUXER_TYPE
lu_zero
parents:
25197
diff
changeset
|
131 #endif |
23121
a257dd426da5
Simplify preprocessor directives: There is a general variable for
diego
parents:
23072
diff
changeset
|
132 #ifdef USE_LIBAVFORMAT |
26437 | 133 &demuxer_desc_lavf, |
16175 | 134 #endif |
26873
a90971b955af
Move native musepack demuxer further down in demuxer list
reimar
parents:
26758
diff
changeset
|
135 #ifdef MUSEPACK |
a90971b955af
Move native musepack demuxer further down in demuxer list
reimar
parents:
26758
diff
changeset
|
136 &demuxer_desc_mpc, |
a90971b955af
Move native musepack demuxer further down in demuxer list
reimar
parents:
26758
diff
changeset
|
137 #endif |
18900
0b53e6d1b27f
move some ill-behaving demuxers further down the list
reimar
parents:
18708
diff
changeset
|
138 #ifdef HAVE_LIBDV095 |
26437 | 139 &demuxer_desc_rawdv, |
18900
0b53e6d1b27f
move some ill-behaving demuxers further down the list
reimar
parents:
18708
diff
changeset
|
140 #endif |
26437 | 141 &demuxer_desc_aac, |
19861 | 142 #ifdef HAVE_LIBNUT |
26437 | 143 &demuxer_desc_nut, |
19861 | 144 #endif |
18900
0b53e6d1b27f
move some ill-behaving demuxers further down the list
reimar
parents:
18708
diff
changeset
|
145 #ifdef HAVE_XMMS |
26437 | 146 &demuxer_desc_xmms, |
18900
0b53e6d1b27f
move some ill-behaving demuxers further down the list
reimar
parents:
18708
diff
changeset
|
147 #endif |
26437 | 148 /* Please do not add any new demuxers here. If you want to implement a new |
149 * demuxer, add it to libavformat, except for wrappers around external | |
150 * libraries and demuxers requiring binary support. */ | |
151 NULL | |
16175 | 152 }; |
153 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
154 void free_demuxer_stream(demux_stream_t *ds) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
155 { |
1643 | 156 ds_free_packs(ds); |
157 free(ds); | |
158 } | |
159 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
160 demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
161 { |
26437 | 162 demux_stream_t* ds=malloc(sizeof(demux_stream_t)); |
163 ds->buffer_pos=ds->buffer_size=0; | |
164 ds->buffer=NULL; | |
165 ds->pts=0; | |
166 ds->pts_bytes=0; | |
167 ds->eof=0; | |
168 ds->pos=0; | |
169 ds->dpos=0; | |
170 ds->pack_no=0; | |
27045 | 171 |
26437 | 172 ds->packs=0; |
173 ds->bytes=0; | |
174 ds->first=ds->last=ds->current=NULL; | |
175 ds->id=id; | |
176 ds->demuxer=demuxer; | |
27045 | 177 |
26437 | 178 ds->asf_seq=-1; |
179 ds->asf_packet=NULL; | |
27045 | 180 |
26437 | 181 ds->ss_mul=ds->ss_div=0; |
27045 | 182 |
26437 | 183 ds->sh=NULL; |
184 return ds; | |
1 | 185 } |
186 | |
16175 | 187 |
188 /** | |
189 * Get demuxer description structure for a given demuxer type | |
190 * | |
191 * @param file_format type of the demuxer | |
192 * @return structure for the demuxer, NULL if not found | |
193 */ | |
26437 | 194 static const demuxer_desc_t* get_demuxer_desc_from_type(int file_format) |
16175 | 195 { |
26437 | 196 int i; |
16175 | 197 |
26437 | 198 for (i = 0; demuxer_list[i]; i++) |
199 if (file_format == demuxer_list[i]->type) | |
200 return demuxer_list[i]; | |
16175 | 201 |
26437 | 202 return NULL; |
16175 | 203 } |
204 | |
205 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
206 demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
207 int s_id, char *filename) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
208 { |
26437 | 209 demuxer_t *d=malloc(sizeof(demuxer_t)); |
210 memset(d,0,sizeof(demuxer_t)); | |
211 d->stream=stream; | |
212 d->stream_pts = MP_NOPTS_VALUE; | |
213 d->reference_clock = MP_NOPTS_VALUE; | |
214 d->movi_start=stream->start_pos; | |
215 d->movi_end=stream->end_pos; | |
216 d->seekable=1; | |
217 d->synced=0; | |
218 d->filepos=0; | |
219 d->audio=new_demuxer_stream(d,a_id); | |
220 d->video=new_demuxer_stream(d,v_id); | |
221 d->sub=new_demuxer_stream(d,s_id); | |
222 d->type=type; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
223 if (type) |
26437 | 224 if (!(d->desc = get_demuxer_desc_from_type(type))) |
225 mp_msg(MSGT_DEMUXER,MSGL_ERR,"BUG! Invalid demuxer type in new_demuxer(), big troubles ahead."); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
226 if (filename) // Filename hack for avs_check_file |
26437 | 227 d->filename=strdup(filename); |
228 stream_reset(stream); | |
229 stream_seek(stream,stream->start_pos); | |
230 return d; | |
1 | 231 } |
232 | |
24022
4d576e0ed40b
When a new subtitle stream becomes available check if it is the one that
reimar
parents:
23865
diff
changeset
|
233 extern int dvdsub_id; |
4d576e0ed40b
When a new subtitle stream becomes available check if it is the one that
reimar
parents:
23865
diff
changeset
|
234 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
235 sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
236 { |
26437 | 237 if (id > MAX_S_STREAMS - 1 || id < 0) { |
238 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested sub stream id overflow (%d > %d)\n", | |
239 id, MAX_S_STREAMS); | |
240 return NULL; | |
241 } | |
242 if (demuxer->s_streams[id]) | |
243 mp_msg(MSGT_DEMUXER, MSGL_WARN, "Sub stream %i redefined\n", id); | |
244 else { | |
245 sh_sub_t *sh = calloc(1, sizeof(sh_sub_t)); | |
246 demuxer->s_streams[id] = sh; | |
247 sh->sid = sid; | |
248 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid); | |
249 } | |
250 return demuxer->s_streams[id]; | |
20872
a8b42366e68a
Make subtitle stream handling more similar to audio and video streams.
reimar
parents:
20851
diff
changeset
|
251 } |
a8b42366e68a
Make subtitle stream handling more similar to audio and video streams.
reimar
parents:
20851
diff
changeset
|
252 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
253 void free_sh_sub(sh_sub_t *sh) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
254 { |
23592 | 255 mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_sub at %p\n", sh); |
26085 | 256 free(sh->extradata); |
25702
c4275201a489
Add a forgotten #ifdef USE_ASS around ass_free_track
reimar
parents:
25657
diff
changeset
|
257 #ifdef USE_ASS |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
258 if (sh->ass_track) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
259 ass_free_track(sh->ass_track); |
25702
c4275201a489
Add a forgotten #ifdef USE_ASS around ass_free_track
reimar
parents:
25657
diff
changeset
|
260 #endif |
26082 | 261 free(sh->lang); |
23592 | 262 free(sh); |
263 } | |
264 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
265 sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer, int id, int aid) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
266 { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
267 if (id > MAX_A_STREAMS-1 || id < 0) { |
26437 | 268 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n", |
269 id, MAX_A_STREAMS); | |
270 return NULL; | |
4642 | 271 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
272 if (demuxer->a_streams[id]) |
26437 | 273 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
274 else { |
26874 | 275 sh_audio_t *sh = calloc(1, sizeof(sh_audio_t)); |
26437 | 276 mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundAudioStream,id); |
26874 | 277 demuxer->a_streams[id] = sh; |
26875
c276296cb6f8
Simplify/make new_sh behaviour more consistent when a stream gets redefined.
reimar
parents:
26874
diff
changeset
|
278 sh->aid = aid; |
26876 | 279 sh->ds = demuxer->audio; |
13357
c605df89ca9f
moved sh_audio initialization from dec_audio to demuxer.c to fix
reimar
parents:
13301
diff
changeset
|
280 // set some defaults |
26437 | 281 sh->samplesize=2; |
282 sh->sample_format=AF_FORMAT_S16_NE; | |
283 sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/ | |
284 sh->pts=MP_NOPTS_VALUE; | |
285 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid); | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
286 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
287 return demuxer->a_streams[id]; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
288 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
289 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
290 void free_sh_audio(demuxer_t *demuxer, int id) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
291 { |
18708
9e2b300db17b
Change free_sh_audio() to take demuxer and stream id as parameters
uau
parents:
18404
diff
changeset
|
292 sh_audio_t *sh = demuxer->a_streams[id]; |
9e2b300db17b
Change free_sh_audio() to take demuxer and stream id as parameters
uau
parents:
18404
diff
changeset
|
293 demuxer->a_streams[id] = NULL; |
26437 | 294 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_audio at %p\n",sh); |
26085 | 295 free(sh->wf); |
296 free(sh->codecdata); | |
26082 | 297 free(sh->lang); |
1643 | 298 free(sh); |
299 } | |
300 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
301 sh_video_t* new_sh_video_vid(demuxer_t *demuxer, int id, int vid) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
302 { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
303 if (id > MAX_V_STREAMS - 1 || id < 0) { |
26437 | 304 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n", |
305 id, MAX_V_STREAMS); | |
306 return NULL; | |
4642 | 307 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
308 if (demuxer->v_streams[id]) |
26437 | 309 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
310 else { |
26875
c276296cb6f8
Simplify/make new_sh behaviour more consistent when a stream gets redefined.
reimar
parents:
26874
diff
changeset
|
311 sh_video_t *sh = calloc(1, sizeof(sh_video_t)); |
26437 | 312 mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id); |
26875
c276296cb6f8
Simplify/make new_sh behaviour more consistent when a stream gets redefined.
reimar
parents:
26874
diff
changeset
|
313 demuxer->v_streams[id] = sh; |
c276296cb6f8
Simplify/make new_sh behaviour more consistent when a stream gets redefined.
reimar
parents:
26874
diff
changeset
|
314 sh->vid = vid; |
26876 | 315 sh->ds = demuxer->video; |
26437 | 316 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
317 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
318 return demuxer->v_streams[id]; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
319 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
320 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
321 void free_sh_video(sh_video_t *sh) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
322 { |
26437 | 323 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_video at %p\n",sh); |
26085 | 324 free(sh->bih); |
1643 | 325 free(sh); |
326 } | |
327 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
328 void free_demuxer(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
329 { |
1643 | 330 int i; |
26437 | 331 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing demuxer at %p\n",demuxer); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
332 if (demuxer->desc->close) |
26437 | 333 demuxer->desc->close(demuxer); |
16175 | 334 // Very ugly hack to make it behave like old implementation |
335 if (demuxer->desc->type == DEMUXER_TYPE_DEMUXERS) | |
26437 | 336 goto skip_streamfree; |
1643 | 337 // free streams: |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
338 for (i = 0; i < MAX_A_STREAMS; i++) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
339 if (demuxer->a_streams[i]) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
340 free_sh_audio(demuxer, i); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
341 for (i = 0; i < MAX_V_STREAMS; i++) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
342 if (demuxer->v_streams[i]) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
343 free_sh_video(demuxer->v_streams[i]); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
344 for (i = 0; i < MAX_S_STREAMS; i++) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
345 if (demuxer->s_streams[i]) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
346 free_sh_sub(demuxer->s_streams[i]); |
1643 | 347 // free demuxers: |
348 free_demuxer_stream(demuxer->audio); | |
349 free_demuxer_stream(demuxer->video); | |
5412 | 350 free_demuxer_stream(demuxer->sub); |
26437 | 351 skip_streamfree: |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
352 if (demuxer->info) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
353 for (i = 0; demuxer->info[i] != NULL; i++) |
26437 | 354 free(demuxer->info[i]); |
355 free(demuxer->info); | |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
356 } |
26085 | 357 free(demuxer->filename); |
19342 | 358 if (demuxer->chapters) { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
359 for (i = 0; i<demuxer->num_chapters; i++) |
26437 | 360 free(demuxer->chapters[i].name); |
361 free(demuxer->chapters); | |
19342 | 362 } |
25657 | 363 if (demuxer->attachments) { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
364 for (i = 0; i<demuxer->num_attachments; i++) { |
26437 | 365 free(demuxer->attachments[i].name); |
366 free(demuxer->attachments[i].type); | |
367 free(demuxer->attachments[i].data); | |
368 } | |
369 free(demuxer->attachments); | |
25657 | 370 } |
1643 | 371 free(demuxer); |
372 } | |
373 | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
374 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
375 void ds_add_packet(demux_stream_t *ds, demux_packet_t *dp) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
376 { |
1 | 377 // append packet to DS stream: |
378 ++ds->packs; | |
26437 | 379 ds->bytes+=dp->len; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
380 if (ds->last) { |
26437 | 381 // next packet in stream |
382 ds->last->next=dp; | |
383 ds->last=dp; | |
1 | 384 } else { |
26437 | 385 // first packet in stream |
386 ds->first=ds->last=dp; | |
1 | 387 } |
26437 | 388 mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n", |
389 (ds==ds->demuxer->audio)?"d_audio":"d_video", | |
390 dp->len,dp->pts,(unsigned int)dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs); | |
1 | 391 } |
392 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
393 void ds_read_packet(demux_stream_t *ds, stream_t *stream, int len, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
394 double pts, off_t pos, int flags) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
395 { |
26437 | 396 demux_packet_t* dp=new_demux_packet(len); |
397 len = stream_read(stream,dp->buffer,len); | |
10891
65ed62e138fa
Fixed 'reading after EOF'. demuxers didn't check, how many they've read!
lumag
parents:
10882
diff
changeset
|
398 resize_demux_packet(dp, len); |
27045 | 399 dp->pts = pts; |
26437 | 400 dp->pos=pos; |
401 dp->flags=flags; | |
1 | 402 // append packet to DS stream: |
26437 | 403 ds_add_packet(ds,dp); |
1 | 404 } |
405 | |
406 // return value: | |
407 // 0 = EOF or no stream found or invalid type | |
408 // 1 = successfully read a packet | |
409 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
410 int demux_fill_buffer(demuxer_t *demux, demux_stream_t *ds) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
411 { |
26437 | 412 // Note: parameter 'ds' can be NULL! |
413 return demux->desc->fill_buffer(demux, ds); | |
1 | 414 } |
415 | |
416 // return value: | |
417 // 0 = EOF | |
25197
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
418 // 1 = successful |
26037 | 419 #define MAX_ACUMULATED_PACKETS 64 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
420 int ds_fill_buffer(demux_stream_t *ds) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
421 { |
26437 | 422 demuxer_t *demux=ds->demuxer; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
423 if (ds->current) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
424 free_demux_packet(ds->current); |
26437 | 425 ds->current=NULL; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
426 if (mp_msg_test(MSGT_DEMUXER,MSGL_DBG3)) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
427 if (ds == demux->audio) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
428 mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_fill_buffer(d_audio) called\n"); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
429 else if (ds == demux->video) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
430 mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_fill_buffer(d_video) called\n"); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
431 else if (ds == demux->sub) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
432 mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_fill_buffer(d_sub) called\n"); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
433 else |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
434 mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_fill_buffer(unknown 0x%X) called\n", (unsigned int) ds); |
26437 | 435 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
436 while (1) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
437 if (ds->packs) { |
26437 | 438 demux_packet_t *p=ds->first; |
26071
449ad51bd8c7
in ds_fill_buffer() disabled the code that demuxes until the arrival of the right reference_clock
nicodvb
parents:
26037
diff
changeset
|
439 #if 0 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
440 if (demux->reference_clock != MP_NOPTS_VALUE) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
441 if ((p->pts != MP_NOPTS_VALUE) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
442 && (p->pts > demux->reference_clock) |
26437 | 443 && (ds->packs < MAX_ACUMULATED_PACKETS)) { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
444 if (demux_fill_buffer(demux,ds)) |
26437 | 445 continue; |
446 } | |
447 } | |
26071
449ad51bd8c7
in ds_fill_buffer() disabled the code that demuxes until the arrival of the right reference_clock
nicodvb
parents:
26037
diff
changeset
|
448 #endif |
26437 | 449 // copy useful data: |
450 ds->buffer=p->buffer; | |
451 ds->buffer_pos=0; | |
452 ds->buffer_size=p->len; | |
453 ds->pos=p->pos; | |
454 ds->dpos+=p->len; // !!! | |
455 ++ds->pack_no; | |
456 if (p->pts != MP_NOPTS_VALUE) { | |
457 ds->pts=p->pts; | |
458 ds->pts_bytes=0; | |
459 } | |
460 ds->pts_bytes+=p->len; // !!! | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
461 if (p->stream_pts != MP_NOPTS_VALUE) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
462 demux->stream_pts = p->stream_pts; |
26437 | 463 ds->flags=p->flags; |
464 // unlink packet: | |
465 ds->bytes-=p->len; | |
466 ds->current=p; | |
467 ds->first=p->next; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
468 if (!ds->first) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
469 ds->last = NULL; |
26437 | 470 --ds->packs; |
27048 | 471 return 1; |
1 | 472 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
473 if (demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES) { |
26437 | 474 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); |
475 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
476 break; | |
477 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
478 if (demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES) { |
26437 | 479 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes); |
480 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
481 break; | |
482 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
483 if (!demux_fill_buffer(demux,ds)) { |
26437 | 484 mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"ds_fill_buffer()->demux_fill_buffer() failed\n"); |
485 break; // EOF | |
486 } | |
487 } | |
488 ds->buffer_pos=ds->buffer_size=0; | |
489 ds->buffer=NULL; | |
490 mp_msg(MSGT_DEMUXER,MSGL_V,"ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video"); | |
491 ds->eof=1; | |
492 return 0; | |
1 | 493 } |
494 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
495 int demux_read_data(demux_stream_t *ds, unsigned char *mem, int len) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
496 { |
26437 | 497 int x; |
498 int bytes=0; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
499 while (len > 0) { |
26437 | 500 x=ds->buffer_size-ds->buffer_pos; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
501 if (x == 0) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
502 if (!ds_fill_buffer(ds)) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
503 return bytes; |
26437 | 504 } else { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
505 if (x > len) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
506 x = len; |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
507 if (mem) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
508 fast_memcpy(mem + bytes, &ds->buffer[ds->buffer_pos], x); |
26437 | 509 bytes+=x;len-=x;ds->buffer_pos+=x; |
510 } | |
511 } | |
512 return bytes; | |
1 | 513 } |
514 | |
17417
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
515 /** |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
516 * \brief read data until the given 3-byte pattern is encountered, up to maxlen |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
517 * \param mem memory to read data into, may be NULL to discard data |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
518 * \param maxlen maximum number of bytes to read |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
519 * \param read number of bytes actually read |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
520 * \param pattern pattern to search for (lowest 8 bits are ignored) |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
521 * \return whether pattern was found |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
522 */ |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
523 int demux_pattern_3(demux_stream_t *ds, unsigned char *mem, int maxlen, |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
524 int *read, uint32_t pattern) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
525 { |
26437 | 526 register uint32_t head = 0xffffff00; |
527 register uint32_t pat = pattern & 0xffffff00; | |
528 int total_len = 0; | |
529 do { | |
530 register unsigned char *ds_buf = &ds->buffer[ds->buffer_size]; | |
531 int len = ds->buffer_size - ds->buffer_pos; | |
532 register long pos = -len; | |
533 if (unlikely(pos >= 0)) { // buffer is empty | |
534 ds_fill_buffer(ds); | |
535 continue; | |
536 } | |
17417
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
537 do { |
26437 | 538 head |= ds_buf[pos]; |
539 head <<= 8; | |
540 } while (++pos && head != pat); | |
541 len += pos; | |
542 if (total_len + len > maxlen) | |
543 len = maxlen - total_len; | |
544 len = demux_read_data(ds, mem ? &mem[total_len] : NULL, len); | |
545 total_len += len; | |
546 } while ((head != pat || total_len < 3) && total_len < maxlen && !ds->eof); | |
547 if (read) | |
548 *read = total_len; | |
549 return total_len >= 3 && head == pat; | |
17417
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
550 } |
746 | 551 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
552 void ds_free_packs(demux_stream_t *ds) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
553 { |
26437 | 554 demux_packet_t *dp=ds->first; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
555 while (dp) { |
26437 | 556 demux_packet_t *dn=dp->next; |
557 free_demux_packet(dp); | |
558 dp=dn; | |
559 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
560 if (ds->asf_packet) { |
26437 | 561 // free unfinished .asf fragments: |
562 free(ds->asf_packet->buffer); | |
563 free(ds->asf_packet); | |
564 ds->asf_packet=NULL; | |
565 } | |
566 ds->first=ds->last=NULL; | |
567 ds->packs=0; // !!!!! | |
568 ds->bytes=0; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
569 if (ds->current) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
570 free_demux_packet(ds->current); |
26437 | 571 ds->current=NULL; |
572 ds->buffer=NULL; | |
573 ds->buffer_pos=ds->buffer_size; | |
574 ds->pts=0; ds->pts_bytes=0; | |
1 | 575 } |
576 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
577 int ds_get_packet(demux_stream_t *ds, unsigned char **start) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
578 { |
24826 | 579 int len; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
580 if (ds->buffer_pos >= ds->buffer_size) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
581 if (!ds_fill_buffer(ds)) { |
1 | 582 // EOF |
583 *start = NULL; | |
584 return -1; | |
26437 | 585 } |
1 | 586 } |
26437 | 587 len=ds->buffer_size-ds->buffer_pos; |
24826 | 588 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 589 ds->buffer_pos+=len; |
24826 | 590 return len; |
1 | 591 } |
554 | 592 |
26437 | 593 int ds_get_packet_pts(demux_stream_t *ds,unsigned char **start, double *pts) |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
594 { |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
595 int len; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
596 *pts = MP_NOPTS_VALUE; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
597 if (ds->buffer_pos >= ds->buffer_size) { |
26437 | 598 if (!ds_fill_buffer(ds)) { |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
599 // EOF |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
600 *start = NULL; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
601 return -1; |
26437 | 602 } |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
603 } |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18900
diff
changeset
|
604 // Return pts unless this read starts from the middle of a packet |
25956
7e4a2ab8b61c
Change to always use MP_NOPTS_VALUE (instead of sometimes 0) for unknown pts.
reimar
parents:
25919
diff
changeset
|
605 if (!ds->buffer_pos) |
26437 | 606 *pts = ds->current->pts; |
607 len=ds->buffer_size-ds->buffer_pos; | |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
608 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 609 ds->buffer_pos+=len; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
610 return len; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
611 } |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
612 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
613 int ds_get_packet_sub(demux_stream_t *ds, unsigned char **start) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
614 { |
24826 | 615 int len; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
616 if(ds->buffer_pos >= ds->buffer_size){ |
26437 | 617 *start = NULL; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
618 if (!ds->packs) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
619 return -1; // no sub |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
620 if (!ds_fill_buffer(ds)) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
621 return -1; // EOF |
554 | 622 } |
26437 | 623 len=ds->buffer_size-ds->buffer_pos; |
24826 | 624 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 625 ds->buffer_pos+=len; |
24826 | 626 return len; |
554 | 627 } |
628 | |
18309
87161f96fa66
Change common pts variables from floats to doubles. Individual demuxers
uau
parents:
18242
diff
changeset
|
629 double ds_get_next_pts(demux_stream_t *ds) |
87161f96fa66
Change common pts variables from floats to doubles. Individual demuxers
uau
parents:
18242
diff
changeset
|
630 { |
26437 | 631 demuxer_t* demux = ds->demuxer; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
632 while (!ds->first) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
633 if(demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES){ |
26437 | 634 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); |
635 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
636 return MP_NOPTS_VALUE; | |
5930
68cac7ecaf05
Fix frame_time for variable fps movies as it was the last frame duration.
albeu
parents:
5897
diff
changeset
|
637 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
638 if(demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES){ |
26437 | 639 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes); |
640 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
641 return MP_NOPTS_VALUE; | |
642 } | |
643 if(!demux_fill_buffer(demux,ds)) | |
644 return MP_NOPTS_VALUE; | |
645 } | |
646 return ds->first->pts; | |
5930
68cac7ecaf05
Fix frame_time for variable fps movies as it was the last frame duration.
albeu
parents:
5897
diff
changeset
|
647 } |
68cac7ecaf05
Fix frame_time for variable fps movies as it was the last frame duration.
albeu
parents:
5897
diff
changeset
|
648 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
649 // ==================================================================== |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
650 |
16175 | 651 void demuxer_help(void) |
652 { | |
26437 | 653 int i; |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
654 |
26437 | 655 mp_msg(MSGT_DEMUXER, MSGL_INFO, "Available demuxers:\n"); |
656 mp_msg(MSGT_DEMUXER, MSGL_INFO, " demuxer: type info: (comment)\n"); | |
657 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DEMUXERS\n"); | |
658 for (i = 0; demuxer_list[i]; i++) { | |
659 if (demuxer_list[i]->type > DEMUXER_TYPE_MAX) // Don't display special demuxers | |
660 continue; | |
661 if (demuxer_list[i]->comment && strlen(demuxer_list[i]->comment)) | |
662 mp_msg(MSGT_DEMUXER, MSGL_INFO, "%10s %2d %s (%s)\n", | |
663 demuxer_list[i]->name, demuxer_list[i]->type, demuxer_list[i]->info, demuxer_list[i]->comment); | |
664 else | |
665 mp_msg(MSGT_DEMUXER, MSGL_INFO, "%10s %2d %s\n", | |
666 demuxer_list[i]->name, demuxer_list[i]->type, demuxer_list[i]->info); | |
667 } | |
16175 | 668 } |
669 | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
14666
diff
changeset
|
670 |
16175 | 671 /** |
672 * Get demuxer type for a given demuxer name | |
673 * | |
674 * @param demuxer_name string with demuxer name of demuxer number | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16310
diff
changeset
|
675 * @param force will be set if demuxer should be forced. |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16310
diff
changeset
|
676 * May be NULL. |
16175 | 677 * @return DEMUXER_TYPE_xxx, -1 if error or not found |
678 */ | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16310
diff
changeset
|
679 int get_demuxer_type_from_name(char *demuxer_name, int *force) |
16175 | 680 { |
26437 | 681 int i; |
682 long type_int; | |
683 char *endptr; | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
5107
diff
changeset
|
684 |
26437 | 685 if (!demuxer_name || !demuxer_name[0]) |
686 return DEMUXER_TYPE_UNKNOWN; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
687 if (force) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
688 *force = demuxer_name[0] == '+'; |
26437 | 689 if (demuxer_name[0] == '+') |
690 demuxer_name = &demuxer_name[1]; | |
691 for (i = 0; demuxer_list[i]; i++) { | |
692 if (demuxer_list[i]->type > DEMUXER_TYPE_MAX) // Can't select special demuxers from commandline | |
693 continue; | |
694 if (strcmp(demuxer_name, demuxer_list[i]->name) == 0) | |
695 return demuxer_list[i]->type; | |
696 } | |
16175 | 697 |
26437 | 698 // No match found, try to parse name as an integer (demuxer number) |
699 type_int = strtol(demuxer_name, &endptr, 0); | |
700 if (*endptr) // Conversion failed | |
701 return -1; | |
702 if ((type_int > 0) && (type_int <= DEMUXER_TYPE_MAX)) | |
703 return (int)type_int; | |
26379 | 704 |
26437 | 705 return -1; |
16175 | 706 } |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
3786
diff
changeset
|
707 |
26437 | 708 int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6192
diff
changeset
|
709 |
26437 | 710 int correct_pts=0; |
711 int user_correct_pts=-1; | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18900
diff
changeset
|
712 |
9751
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
713 /* |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
714 NOTE : Several demuxers may be opened at the same time so |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
715 demuxers should NEVER rely on an external var to enable them |
25197
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
716 self. If a demuxer can't do any auto-detection it should only use |
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
717 file_format. The user can explicitly set file_format with the -demuxer |
9751
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
718 option so there is really no need for another extra var. |
25197
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
719 For convenience an option can be added to set file_format directly |
9751
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
720 to the right type (ex: rawaudio,rawvideo). |
25197
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
721 Also the stream can override the file_format so a demuxer which rely |
9751
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
722 on a special stream type can set file_format at the stream level |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
723 (ex: tv,mf). |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
724 */ |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
725 |
26437 | 726 static demuxer_t* demux_open_stream(stream_t *stream, int file_format, |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
727 int force, int audio_id, int video_id, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
728 int dvdsub_id, char *filename) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
729 { |
26437 | 730 demuxer_t *demuxer=NULL; |
1659 | 731 |
26437 | 732 sh_video_t *sh_video=NULL; |
733 | |
734 const demuxer_desc_t *demuxer_desc; | |
735 int fformat = 0; | |
736 int i; | |
737 | |
738 // If somebody requested a demuxer check it | |
739 if (file_format) { | |
740 if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) { | |
741 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
742 if (demuxer_desc->check_file) | |
743 fformat = demuxer_desc->check_file(demuxer); | |
744 if (force || !demuxer_desc->check_file) | |
745 fformat = demuxer_desc->type; | |
746 if (fformat != 0) { | |
747 if (fformat == demuxer_desc->type) { | |
748 demuxer_t *demux2 = demuxer; | |
749 // Move messages to demuxer detection code? | |
750 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
751 file_format = fformat; | |
752 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
753 demuxer = demux2; | |
754 goto dmx_open; | |
20303 | 755 } |
26437 | 756 } else { |
757 // Format changed after check, recurse | |
758 free_demuxer(demuxer); | |
759 return demux_open_stream(stream, fformat, force, | |
760 audio_id, video_id, dvdsub_id, filename); | |
761 } | |
20303 | 762 } |
26437 | 763 // Check failed for forced demuxer, quit |
764 free_demuxer(demuxer); | |
765 return NULL; | |
766 } | |
767 } | |
768 | |
769 // Test demuxers with safe file checks | |
770 for (i = 0; (demuxer_desc = demuxer_list[i]); i++) { | |
771 if (demuxer_desc->safe_check) { | |
772 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
773 if ((fformat = demuxer_desc->check_file(demuxer)) != 0) { | |
774 if (fformat == demuxer_desc->type) { | |
775 demuxer_t *demux2 = demuxer; | |
776 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
777 file_format = fformat; | |
778 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
779 demuxer = demux2; | |
780 goto dmx_open; | |
26379 | 781 } |
26437 | 782 } else { |
783 if (fformat == DEMUXER_TYPE_PLAYLIST) | |
784 return demuxer; // handled in mplayer.c | |
785 // Format changed after check, recurse | |
786 free_demuxer(demuxer); | |
787 demuxer=demux_open_stream(stream, fformat, force, | |
788 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
789 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
790 return demuxer; // done! |
26437 | 791 file_format = DEMUXER_TYPE_UNKNOWN; |
792 } | |
26379 | 793 } |
26437 | 794 free_demuxer(demuxer); |
795 demuxer = NULL; | |
796 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
797 } |
9006
d00997f12257
extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
8937
diff
changeset
|
798 |
26437 | 799 // If no forced demuxer perform file extension based detection |
800 // Ok. We're over the stable detectable fileformats, the next ones are a bit | |
801 // fuzzy. So by default (extension_parsing==1) try extension-based detection | |
802 // first: | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
803 if (file_format == DEMUXER_TYPE_UNKNOWN && filename && extension_parsing == 1) { |
26437 | 804 file_format=demuxer_type_by_filename(filename); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
805 if (file_format != DEMUXER_TYPE_UNKNOWN) { |
26437 | 806 // we like recursion :) |
807 demuxer=demux_open_stream(stream, file_format, force, | |
808 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
809 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
810 return demuxer; // done! |
26437 | 811 file_format=DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing... |
812 mp_msg(MSGT_DEMUXER,MSGL_V,"demuxer: continue fuzzy content-based format guessing...\n"); | |
813 } | |
814 } | |
815 | |
816 // Try detection for all other demuxers | |
817 for (i = 0; (demuxer_desc = demuxer_list[i]); i++) { | |
818 if (!demuxer_desc->safe_check && demuxer_desc->check_file) { | |
819 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
820 if ((fformat = demuxer_desc->check_file(demuxer)) != 0) { | |
821 if (fformat == demuxer_desc->type) { | |
822 demuxer_t *demux2 = demuxer; | |
823 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
824 file_format = fformat; | |
825 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
826 demuxer = demux2; | |
827 goto dmx_open; | |
828 } | |
829 } else { | |
830 if (fformat == DEMUXER_TYPE_PLAYLIST) | |
831 return demuxer; // handled in mplayer.c | |
832 // Format changed after check, recurse | |
833 free_demuxer(demuxer); | |
834 demuxer=demux_open_stream(stream, fformat, force, | |
835 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
836 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
837 return demuxer; // done! |
26437 | 838 file_format = DEMUXER_TYPE_UNKNOWN; |
839 } | |
840 } | |
841 free_demuxer(demuxer); | |
842 demuxer = NULL; | |
843 } | |
844 } | |
845 | |
846 return NULL; | |
847 //====== File format recognized, set up these for compatibility: ========= | |
848 dmx_open: | |
849 | |
850 demuxer->file_format=file_format; | |
851 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
852 if ((sh_video = demuxer->video->sh) && sh_video->bih){ |
26437 | 853 int biComp=le2me_32(sh_video->bih->biCompression); |
854 mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %dx%d %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n", | |
855 (char *)&biComp, | |
856 sh_video->bih->biWidth, | |
857 sh_video->bih->biHeight, | |
858 sh_video->bih->biBitCount, | |
859 sh_video->fps, | |
860 sh_video->i_bps*0.008f, | |
861 sh_video->i_bps/1024.0f ); | |
862 } | |
863 #ifdef USE_ASS | |
864 if (ass_enabled && ass_library) { | |
865 for (i = 0; i < MAX_S_STREAMS; ++i) { | |
866 sh_sub_t* sh = demuxer->s_streams[i]; | |
867 if (sh && sh->type == 'a') { | |
868 sh->ass_track = ass_new_track(ass_library); | |
869 if (sh->ass_track && sh->extradata) | |
870 ass_process_codec_private(sh->ass_track, sh->extradata, sh->extradata_len); | |
871 } else if (sh && sh->type != 'v') | |
872 sh->ass_track = ass_default_track(ass_library); | |
873 } | |
874 } | |
875 #endif | |
876 return demuxer; | |
877 } | |
878 | |
879 char* audio_stream = NULL; | |
880 char* sub_stream = NULL; | |
9709 | 881 int audio_stream_cache = 0; |
7867 | 882 |
26437 | 883 char *demuxer_name = NULL; // parameter from -demuxer |
16175 | 884 char *audio_demuxer_name = NULL; // parameter from -audio-demuxer |
26437 | 885 char *sub_demuxer_name = NULL; // parameter from -sub-demuxer |
16175 | 886 |
7867 | 887 extern int hr_mp3_seek; |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
888 |
12835
4235ae5a2d60
cache min fill adjustment, based on patch by Jeremy Huddleston
iive
parents:
12434
diff
changeset
|
889 extern float stream_cache_min_percent; |
16152
10a69a812eff
remove unused cache-prefill and create cache-seek-min that controls when seek_long is prefered over waiting for cache to fill
iive
parents:
15958
diff
changeset
|
890 extern float stream_cache_seek_min_percent; |
12835
4235ae5a2d60
cache min fill adjustment, based on patch by Jeremy Huddleston
iive
parents:
12434
diff
changeset
|
891 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
892 demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
893 int video_id, int dvdsub_id, char *filename) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
894 { |
26437 | 895 stream_t *as = NULL,*ss = NULL; |
896 demuxer_t *vd,*ad = NULL,*sd = NULL; | |
897 demuxer_t *res; | |
898 int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ; | |
899 int demuxer_type; | |
900 int audio_demuxer_type = 0, sub_demuxer_type = 0; | |
901 int demuxer_force = 0, audio_demuxer_force = 0, | |
902 sub_demuxer_force = 0; | |
16175 | 903 |
26437 | 904 if ((demuxer_type = get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) { |
905 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-demuxer %s does not exist.\n",demuxer_name); | |
906 } | |
907 if ((audio_demuxer_type = get_demuxer_type_from_name(audio_demuxer_name, &audio_demuxer_force)) < 0) { | |
908 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-audio-demuxer %s does not exist.\n",audio_demuxer_name); | |
909 } | |
910 if ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name, &sub_demuxer_force)) < 0) { | |
911 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-sub-demuxer %s does not exist.\n",sub_demuxer_name); | |
912 } | |
913 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
914 if (audio_stream) { |
26437 | 915 as = open_stream(audio_stream,0,&afmt); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
916 if (!as) { |
26437 | 917 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenAudioStream,audio_stream); |
918 return NULL; | |
26379 | 919 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
920 if (audio_stream_cache) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
921 if (!stream_enable_cache(as,audio_stream_cache * 1024,audio_stream_cache * 1024 * (stream_cache_min_percent / 100.0), |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
922 audio_stream_cache * 1024 * (stream_cache_seek_min_percent / 100.0))) { |
26437 | 923 free_stream(as); |
924 mp_msg(MSGT_DEMUXER,MSGL_ERR,"Can't enable audio stream cache\n"); | |
925 return NULL; | |
926 } | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
927 } |
26437 | 928 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
929 if (sub_stream) { |
26437 | 930 ss = open_stream(sub_stream,0,&sfmt); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
931 if (!ss) { |
26437 | 932 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenSubtitlesStream,sub_stream); |
933 return NULL; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
934 } |
26437 | 935 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
936 |
26437 | 937 vd = demux_open_stream(vs, demuxer_type ? demuxer_type : file_format, |
938 demuxer_force, audio_stream ? -2 : audio_id, video_id, | |
939 sub_stream ? -2 : dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
940 if (!vd) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
941 if (as) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
942 free_stream(as); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
943 if (ss) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
944 free_stream(ss); |
26437 | 945 return NULL; |
946 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
947 if (as) { |
26437 | 948 ad = demux_open_stream(as, audio_demuxer_type ? audio_demuxer_type : afmt, |
949 audio_demuxer_force, audio_id, -2, -2, audio_stream); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
950 if (!ad) { |
26437 | 951 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream); |
952 free_stream(as); | |
9709 | 953 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
954 else if (ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3 |
26437 | 955 hr_mp3_seek=1; // Enable high res seeking |
956 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
957 if (ss) { |
26437 | 958 sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt, |
959 sub_demuxer_force, -2, -2, dvdsub_id, sub_stream); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
960 if (!sd) { |
26437 | 961 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningSubtitlesDemuxerFailed,sub_stream); |
962 free_stream(ss); | |
9709 | 963 } |
26437 | 964 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
965 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
966 if (ad && sd) |
26437 | 967 res = new_demuxers_demuxer(vd,ad,sd); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
968 else if (ad) |
26437 | 969 res = new_demuxers_demuxer(vd,ad,vd); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
970 else if (sd) |
26437 | 971 res = new_demuxers_demuxer(vd,vd,sd); |
972 else | |
973 res = vd; | |
25919
382672c7480a
Allow demuxers to choose a default value for correct_pts
reimar
parents:
25883
diff
changeset
|
974 |
26437 | 975 correct_pts = user_correct_pts; |
976 if (correct_pts < 0) | |
977 correct_pts = demux_control(res, DEMUXER_CTRL_CORRECT_PTS, NULL) == DEMUXER_CTRL_OK; | |
978 return res; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
979 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
980 |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
981 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
982 void demux_flush(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
983 { |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
984 ds_free_packs(demuxer->video); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
985 ds_free_packs(demuxer->audio); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
986 ds_free_packs(demuxer->sub); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
987 } |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
988 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
989 int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
990 int flags) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
991 { |
26437 | 992 demux_stream_t *d_audio=demuxer->audio; |
993 demux_stream_t *d_video=demuxer->video; | |
994 sh_audio_t *sh_audio=d_audio->sh; | |
995 sh_video_t *sh_video=d_video->sh; | |
20851
6602a90a06ec
consistency fix: STREAM_CTRL_GET_TIME_LENGTH and STREAM_CTRL_GET_CURRENT_TIME now return time in (double) seconds
nicodvb
parents:
20841
diff
changeset
|
996 double tmp = 0; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
997 double pts; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
998 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
999 if (!demuxer->seekable) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1000 if (demuxer->file_format == DEMUXER_TYPE_AVI) |
26437 | 1001 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekRawAVI); |
2790 | 1002 #ifdef USE_TV |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1003 else if (demuxer->file_format == DEMUXER_TYPE_TV) |
26437 | 1004 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_TVInputNotSeekable); |
2790 | 1005 #endif |
26437 | 1006 else |
1007 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekFile); | |
1008 return 0; | |
1009 } | |
1010 | |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1011 demux_flush(demuxer); |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1012 // clear demux buffers: |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1013 if (sh_audio) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1014 sh_audio->a_buffer_len=0; |
27045 | 1015 demuxer->stream->eof = 0; |
26437 | 1016 demuxer->video->eof=0; |
1017 demuxer->audio->eof=0; | |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1018 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1019 if (sh_video) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1020 sh_video->timer = 0; // !!!!!! |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1021 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1022 if (flags & SEEK_ABSOLUTE) |
26437 | 1023 pts = 0.0f; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1024 else { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1025 if (demuxer->stream_pts == MP_NOPTS_VALUE) |
26437 | 1026 goto dmx_seek; |
1027 pts = demuxer->stream_pts; | |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1028 } |
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1029 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1030 if (flags & SEEK_FACTOR) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1031 if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &tmp) == STREAM_UNSUPPORTED) |
26437 | 1032 goto dmx_seek; |
1033 pts += tmp * rel_seek_secs; | |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1034 } else |
26437 | 1035 pts += rel_seek_secs; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1036 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1037 if (stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != STREAM_UNSUPPORTED) { |
26437 | 1038 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
1039 return 1; | |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1040 } |
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1041 |
26437 | 1042 dmx_seek: |
1043 if (demuxer->desc->seek) | |
1044 demuxer->desc->seek(demuxer,rel_seek_secs,audio_delay,flags); | |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1045 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1046 if (sh_audio) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1047 resync_audio_stream(sh_audio); |
16877
9081ae3a702c
move resync_audio_stream after seeking to demuxer.c
reimar
parents:
16572
diff
changeset
|
1048 |
26437 | 1049 return 1; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1050 } |
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1051 |
19053
75327b24e06f
marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18917
diff
changeset
|
1052 int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param) |
3050 | 1053 { |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1054 char **info = demuxer->info; |
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1055 int n = 0; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1056 |
3050 | 1057 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1058 for (n = 0; info && info[2 * n] != NULL; n++) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1059 if (!strcasecmp(opt, info[2 * n])) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1060 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_DemuxerInfoChanged, opt, |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1061 param); |
26437 | 1062 free(info[2*n+1]); |
1063 info[2*n+1] = strdup(param); | |
1064 return 0; | |
1065 } | |
1066 } | |
1067 | |
1068 info = demuxer->info = (char**)realloc(info,(2*(n+2))*sizeof(char*)); | |
1069 info[2*n] = strdup(opt); | |
1070 info[2*n+1] = strdup(param); | |
1071 memset(&info[2*(n+1)],0,2*sizeof(char*)); | |
3050 | 1072 |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1073 return 1; |
3050 | 1074 } |
1075 | |
1076 int demux_info_print(demuxer_t *demuxer) | |
1077 { | |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1078 char **info = demuxer->info; |
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1079 int n; |
3050 | 1080 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1081 if (!info) |
26437 | 1082 return 0; |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1083 |
26437 | 1084 mp_msg(MSGT_DEMUX, MSGL_INFO,MSGTR_ClipInfo); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1085 for (n = 0; info[2 * n] != NULL; n++) { |
26437 | 1086 mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n",info[2*n],info[2*n+1]); |
1087 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n, info[2*n]); | |
1088 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_VALUE%d=%s\n", n, info[2*n+1]); | |
15789
32d9c8a0a02b
adds some more -identify output, patch by kiriuja < mplayer DASH patches PAM en DASH directo POUM net>
gpoirier
parents:
15780
diff
changeset
|
1089 } |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18128
diff
changeset
|
1090 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_N=%d\n", n); |
4189 | 1091 |
1092 return 0; | |
3050 | 1093 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1094 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1095 char *demux_info_get(demuxer_t *demuxer, const char *opt) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1096 { |
26437 | 1097 int i; |
1098 char **info = demuxer->info; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1099 |
26437 | 1100 for(i = 0; info && info[2*i] != NULL; i++) { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1101 if (!strcasecmp(opt, info[2 * i])) |
26437 | 1102 return info[2*i+1]; |
1103 } | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1104 |
26437 | 1105 return NULL; |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1106 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1107 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1108 int demux_control(demuxer_t *demuxer, int cmd, void *arg) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1109 { |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1110 |
16175 | 1111 if (demuxer->desc->control) |
26437 | 1112 return demuxer->desc->control(demuxer,cmd,arg); |
16175 | 1113 |
1114 return DEMUXER_CTRL_NOTIMPL; | |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1115 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1116 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1117 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1118 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1119 double demuxer_get_time_length(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1120 { |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16326
diff
changeset
|
1121 double get_time_ans; |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1122 sh_video_t *sh_video = demuxer->video->sh; |
16925 | 1123 sh_audio_t *sh_audio = demuxer->audio->sh; |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1124 // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1125 if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans) <= 0) { |
26437 | 1126 if (sh_video && sh_video->i_bps && sh_audio && sh_audio->i_bps) |
1127 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/(sh_video->i_bps+sh_audio->i_bps); | |
1128 else if (sh_video && sh_video->i_bps) | |
1129 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps; | |
1130 else if (sh_audio && sh_audio->i_bps) | |
1131 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_audio->i_bps; | |
1132 else | |
1133 get_time_ans=0; | |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1134 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1135 return get_time_ans; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1136 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1137 |
20749
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1138 /** |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1139 * \brief demuxer_get_current_time() returns the time of the current play in three possible ways: |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1140 * either when the stream reader satisfies STREAM_CTRL_GET_CURRENT_TIME (e.g. dvd) |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1141 * or using sh_video->pts when the former method fails |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1142 * 0 otherwise |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1143 * \return the current play time |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1144 */ |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1145 int demuxer_get_current_time(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1146 { |
20749
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1147 double get_time_ans = 0; |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1148 sh_video_t *sh_video = demuxer->video->sh; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1149 if (demuxer->stream_pts != MP_NOPTS_VALUE) |
21782
99ab6c41eb1e
use demuxer->stream_pts rather than stream_control(STREAM_CTRL_GET_CURRENT_TIME)
nicodvb
parents:
21780
diff
changeset
|
1150 get_time_ans = demuxer->stream_pts; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1151 else if (sh_video) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1152 get_time_ans = sh_video->pts; |
20749
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1153 return (int) get_time_ans; |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1154 } |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1155 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1156 int demuxer_get_percent_pos(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1157 { |
14197
2ae224195625
Use demuxer_get_percent_pos for the OSD position bar
reimar
parents:
14160
diff
changeset
|
1158 int ans = 0; |
2ae224195625
Use demuxer_get_percent_pos for the OSD position bar
reimar
parents:
14160
diff
changeset
|
1159 int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans); |
2ae224195625
Use demuxer_get_percent_pos for the OSD position bar
reimar
parents:
14160
diff
changeset
|
1160 int len = (demuxer->movi_end - demuxer->movi_start) / 100; |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1161 if (res <= 0) { |
26437 | 1162 if (len > 0) |
1163 ans = (demuxer->filepos - demuxer->movi_start) / len; | |
1164 else | |
1165 ans = 0; | |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1166 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1167 if (ans < 0) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1168 ans = 0; |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1169 if (ans > 100) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1170 ans = 100; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1171 return ans; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1172 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1173 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1174 int demuxer_switch_audio(demuxer_t *demuxer, int index) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1175 { |
15285
39eb8a327ea9
adds a parameter to the switch_audio command to directly select a track.
reimar
parents:
15046
diff
changeset
|
1176 int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index); |
39eb8a327ea9
adds a parameter to the switch_audio command to directly select a track.
reimar
parents:
15046
diff
changeset
|
1177 if (res == DEMUXER_CTRL_NOTIMPL) |
26437 | 1178 index = demuxer->audio->id; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1179 if (demuxer->audio->id >= 0) |
26437 | 1180 demuxer->audio->sh = demuxer->a_streams[demuxer->audio->id]; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1181 else |
26437 | 1182 demuxer->audio->sh = NULL; |
15285
39eb8a327ea9
adds a parameter to the switch_audio command to directly select a track.
reimar
parents:
15046
diff
changeset
|
1183 return index; |
15046
b7aa70b05d76
Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents:
14934
diff
changeset
|
1184 } |
19342 | 1185 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1186 int demuxer_switch_video(demuxer_t *demuxer, int index) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1187 { |
20948 | 1188 int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_VIDEO, &index); |
1189 if (res == DEMUXER_CTRL_NOTIMPL) | |
26437 | 1190 index = demuxer->video->id; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1191 if (demuxer->video->id >= 0) |
26437 | 1192 demuxer->video->sh = demuxer->v_streams[demuxer->video->id]; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1193 else |
26437 | 1194 demuxer->video->sh = NULL; |
20948 | 1195 return index; |
1196 } | |
1197 | |
26437 | 1198 int demuxer_add_attachment(demuxer_t* demuxer, const char* name, |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1199 const char* type, const void* data, size_t size) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1200 { |
25657 | 1201 if (!(demuxer->num_attachments & 31)) |
26437 | 1202 demuxer->attachments = realloc(demuxer->attachments, (demuxer->num_attachments + 32) * sizeof(demux_attachment_t)); |
25657 | 1203 |
1204 demuxer->attachments[demuxer->num_attachments].name = strdup(name); | |
1205 demuxer->attachments[demuxer->num_attachments].type = strdup(type); | |
1206 demuxer->attachments[demuxer->num_attachments].data = malloc(size); | |
1207 memcpy(demuxer->attachments[demuxer->num_attachments].data, data, size); | |
1208 demuxer->attachments[demuxer->num_attachments].data_size = size; | |
1209 | |
26437 | 1210 return demuxer->num_attachments ++; |
25657 | 1211 } |
1212 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1213 int demuxer_add_chapter(demuxer_t *demuxer, const char *name, uint64_t start, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1214 uint64_t end) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1215 { |
19342 | 1216 if (demuxer->chapters == NULL) |
26437 | 1217 demuxer->chapters = malloc (32*sizeof(*demuxer->chapters)); |
19342 | 1218 else if (!(demuxer->num_chapters % 32)) |
26437 | 1219 demuxer->chapters = realloc (demuxer->chapters, (demuxer->num_chapters + 32) * sizeof(*demuxer->chapters)); |
19342 | 1220 |
1221 demuxer->chapters[demuxer->num_chapters].start = start; | |
1222 demuxer->chapters[demuxer->num_chapters].end = end; | |
1223 demuxer->chapters[demuxer->num_chapters].name = strdup(name); | |
1224 | |
26437 | 1225 return demuxer->num_chapters ++; |
19342 | 1226 } |
1227 | |
19435 | 1228 /** |
26437 | 1229 * \brief demuxer_seek_chapter() seeks to a chapter in two possible ways: |
19435 | 1230 * either using the demuxer->chapters structure set by the demuxer |
1231 * or asking help to the stream layer (e.g. dvd) | |
19439 | 1232 * \param chapter - chapter number wished - 0-based |
19435 | 1233 * \param mode 0: relative to current main pts, 1: absolute |
1234 * \param seek_pts set by the function to the pts to seek to (if demuxer->chapters is set) | |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1235 * \param num_chapters number of chapters present (set by this function is param is not null) |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1236 * \param chapter_name name of chapter found (set by this function is param is not null) |
19435 | 1237 * \return -1 on error, current chapter if successful |
1238 */ | |
1239 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1240 int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1241 float *seek_pts, int *num_chapters, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1242 char **chapter_name) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1243 { |
19435 | 1244 int ris; |
1245 int current, total; | |
1246 sh_video_t *sh_video = demuxer->video->sh; | |
1247 sh_audio_t *sh_audio = demuxer->audio->sh; | |
1248 | |
1249 if (!demuxer->num_chapters || !demuxer->chapters) { | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1250 if (!mode) { |
26437 | 1251 ris = stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, ¤t); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1252 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1253 return -1; |
19438
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1254 chapter += current; |
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1255 } |
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1256 |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1257 demux_flush(demuxer); |
19435 | 1258 |
26437 | 1259 ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER, &chapter); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1260 if (ris != STREAM_UNSUPPORTED) |
20839
950ea3171afc
in demux_seek() if STREAM_CTRL_SEEK_TO_CHAPTER suceeds call DEMUXER_CTRL_RESYNC to notify the demuxer of the change
nicodvb
parents:
20749
diff
changeset
|
1261 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1262 if (sh_video) { |
19435 | 1263 ds_fill_buffer(demuxer->video); |
1264 resync_video_stream(sh_video); | |
1265 } | |
1266 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1267 if (sh_audio) { |
19435 | 1268 ds_fill_buffer(demuxer->audio); |
1269 resync_audio_stream(sh_audio); | |
1270 } | |
26437 | 1271 |
1272 //exit status may be ok, but main() doesn't have to seek itself (because e.g. dvds depend on sectors, not on pts) | |
19435 | 1273 *seek_pts = -1.0; |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1274 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1275 if (num_chapters) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1276 if (stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, num_chapters) == STREAM_UNSUPPORTED) |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1277 *num_chapters = 0; |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1278 } |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1279 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1280 if (chapter_name) { |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1281 *chapter_name = NULL; |
25314
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1282 if (num_chapters && *num_chapters) { |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1283 char *tmp = malloc(16); |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1284 if (tmp) { |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1285 sprintf(tmp, " of %3d", *num_chapters); |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1286 *chapter_name = tmp; |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1287 } |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1288 } |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1289 } |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1290 |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26437
diff
changeset
|
1291 return ris != STREAM_UNSUPPORTED ? chapter : -1; |
26437 | 1292 } else { //chapters structure is set in the demuxer |
19435 | 1293 total = demuxer->num_chapters; |
1294 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1295 if (mode == 1) //absolute seeking |
19435 | 1296 current = chapter; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1297 else { //relative seeking |
19435 | 1298 uint64_t now; |
26437 | 1299 now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0.)) * 1000 + .5; |
19435 | 1300 |
1301 for (current = total - 1; current >= 0; --current) { | |
26437 | 1302 demux_chapter_t* chapter = demuxer->chapters + current; |
19435 | 1303 if (chapter->start <= now) |
1304 break; | |
1305 } | |
1306 current += chapter; | |
1307 } | |
1308 | |
1309 if (current >= total) | |
26437 | 1310 return -1; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1311 if (current < 0) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1312 current = 0; |
19435 | 1313 |
1314 *seek_pts = demuxer->chapters[current].start / 1000.0; | |
1315 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1316 if (num_chapters) |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1317 *num_chapters = demuxer->num_chapters; |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1318 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1319 if (chapter_name) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1320 if (demuxer->chapters[current].name) |
19479
8dd04ec733f5
100l: *chapter_name was copied from the pointer rather than strupd()-ed (and next free()d in mplayer.c
nicodvb
parents:
19478
diff
changeset
|
1321 *chapter_name = strdup(demuxer->chapters[current].name); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1322 else |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1323 *chapter_name = NULL; |
19479
8dd04ec733f5
100l: *chapter_name was copied from the pointer rather than strupd()-ed (and next free()d in mplayer.c
nicodvb
parents:
19478
diff
changeset
|
1324 } |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1325 |
19435 | 1326 return current; |
1327 } | |
1328 } | |
25358 | 1329 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1330 int demuxer_get_current_chapter(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1331 { |
25358 | 1332 int chapter = -1; |
1333 if (!demuxer->num_chapters || !demuxer->chapters) { | |
1334 if (stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, | |
1335 &chapter) == STREAM_UNSUPPORTED) | |
1336 chapter = -1; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1337 } else { |
25358 | 1338 sh_video_t *sh_video = demuxer->video->sh; |
1339 sh_audio_t *sh_audio = demuxer->audio->sh; | |
1340 uint64_t now; | |
26437 | 1341 now = (sh_video ? sh_video->pts : (sh_audio?sh_audio->pts:0))*1000+0.5; |
25358 | 1342 for (chapter = demuxer->num_chapters - 1; chapter >= 0; --chapter) { |
1343 if (demuxer->chapters[chapter].start <= now) | |
1344 break; | |
1345 } | |
1346 } | |
1347 return chapter; | |
1348 } | |
1349 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1350 char *demuxer_chapter_name(demuxer_t *demuxer, int chapter) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1351 { |
25358 | 1352 if (demuxer->num_chapters && demuxer->chapters) { |
26437 | 1353 if (chapter >=0 && chapter < demuxer->num_chapters && |
1354 demuxer->chapters[chapter].name) | |
25358 | 1355 return strdup(demuxer->chapters[chapter].name); |
1356 } | |
1357 return NULL; | |
1358 } | |
1359 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1360 char *demuxer_chapter_display_name(demuxer_t *demuxer, int chapter) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1361 { |
25358 | 1362 char *chapter_name = demuxer_chapter_name(demuxer, chapter); |
1363 if (chapter_name) { | |
1364 char *tmp = malloc(strlen(chapter_name) + 14); | |
1365 snprintf(tmp, 63, "(%d) %s", chapter + 1, chapter_name); | |
26437 | 1366 free(chapter_name); |
25358 | 1367 return tmp; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1368 } else { |
25358 | 1369 int chapter_num = demuxer_chapter_count(demuxer); |
1370 char tmp[30]; | |
1371 if (chapter_num <= 0) | |
1372 sprintf(tmp, "(%d)", chapter + 1); | |
1373 else | |
1374 sprintf(tmp, "(%d) of %d", chapter + 1, chapter_num); | |
1375 return strdup(tmp); | |
1376 } | |
1377 } | |
1378 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1379 float demuxer_chapter_time(demuxer_t *demuxer, int chapter, float *end) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1380 { |
25358 | 1381 if (demuxer->num_chapters && demuxer->chapters && chapter >= 0 |
26437 | 1382 && chapter < demuxer->num_chapters) { |
25358 | 1383 if (end) |
1384 *end = demuxer->chapters[chapter].end / 1000.0; | |
1385 return demuxer->chapters[chapter].start / 1000.0; | |
1386 } | |
1387 return -1.0; | |
1388 } | |
1389 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1390 int demuxer_chapter_count(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1391 { |
25358 | 1392 if (!demuxer->num_chapters || !demuxer->chapters) { |
1393 int num_chapters = 0; | |
1394 if (stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, | |
1395 &num_chapters) == STREAM_UNSUPPORTED) | |
1396 num_chapters = 0; | |
1397 return num_chapters; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1398 } else |
25358 | 1399 return demuxer->num_chapters; |
1400 } | |
1401 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1402 int demuxer_angles_count(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1403 { |
26437 | 1404 int ris, angles=-1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1405 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1406 ris = stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_ANGLES, &angles); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1407 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1408 return -1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1409 return angles; |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1410 } |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1411 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1412 int demuxer_get_current_angle(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1413 { |
26437 | 1414 int ris, curr_angle=-1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1415 ris = stream_control(demuxer->stream, STREAM_CTRL_GET_ANGLE, &curr_angle); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1416 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1417 return -1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1418 return curr_angle; |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1419 } |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1420 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1421 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1422 int demuxer_set_angle(demuxer_t *demuxer, int angle) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1423 { |
26437 | 1424 int ris, angles=-1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1425 sh_video_t *sh_video = demuxer->video->sh; |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1426 sh_audio_t *sh_audio = demuxer->audio->sh; |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1427 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1428 angles = demuxer_angles_count(demuxer); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1429 if ((angles < 1) || (angle > angles)) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1430 return -1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1431 |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1432 demux_flush(demuxer); |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1433 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1434 ris = stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1435 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1436 return -1; |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1437 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1438 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1439 if (sh_video) { |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1440 ds_fill_buffer(demuxer->video); |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1441 resync_video_stream(sh_video); |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1442 } |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1443 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1444 if (sh_audio) { |
25575
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1445 ds_fill_buffer(demuxer->audio); |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1446 resync_audio_stream(sh_audio); |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1447 } |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1448 |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1449 return angle; |
f94eee219ee0
wrapper functions to get/set angle: the wrapping is needed to RESYNC the demuxer; patch by oattila chello hu
nicodvb
parents:
25444
diff
changeset
|
1450 } |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1451 |
26437 | 1452 int demuxer_audio_track_by_lang(demuxer_t* d, char* lang) |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1453 { |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1454 int i, len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1455 lang += strspn(lang, ","); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1456 while ((len = strcspn(lang, ",")) > 0) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1457 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1458 sh_audio_t* sh = d->a_streams[i]; |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1459 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1460 return sh->aid; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1461 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1462 lang += len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1463 lang += strspn(lang, ","); |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1464 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1465 return -1; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1466 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1467 |
26437 | 1468 int demuxer_sub_track_by_lang(demuxer_t* d, char* lang) |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1469 { |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1470 int i, len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1471 lang += strspn(lang, ","); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1472 while ((len = strcspn(lang, ",")) > 0) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1473 for (i = 0; i < MAX_S_STREAMS; ++i) { |
26437 | 1474 sh_sub_t* sh = d->s_streams[i]; |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1475 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1476 return sh->sid; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1477 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1478 lang += len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1479 lang += strspn(lang, ","); |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1480 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1481 return -1; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1482 } |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1483 |
26437 | 1484 int demuxer_default_audio_track(demuxer_t* d) |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1485 { |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1486 int i; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1487 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1488 sh_audio_t* sh = d->a_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1489 if (sh && sh->default_track) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1490 return sh->aid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1491 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1492 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1493 sh_audio_t* sh = d->a_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1494 if (sh) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1495 return sh->aid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1496 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1497 return -1; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1498 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1499 |
26437 | 1500 int demuxer_default_sub_track(demuxer_t* d) |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1501 { |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1502 int i; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1503 for (i = 0; i < MAX_S_STREAMS; ++i) { |
26437 | 1504 sh_sub_t* sh = d->s_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1505 if (sh && sh->default_track) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1506 return sh->sid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1507 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1508 return -1; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1509 } |
26437 | 1510 |