Mercurial > mplayer.hg
annotate libmpdemux/demuxer.c @ 27053:3c993cb3558e
cosmetics: one more if brace placement fix
author | diego |
---|---|
date | Mon, 16 Jun 2008 11:35:20 +0000 |
parents | 79e51c2fdb00 |
children | eb7dfb6481c1 |
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) { |
27052 | 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) { |
27052 | 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++) |
27052 | 354 free(demuxer->info[i]); |
26437 | 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); |
27050 | 509 bytes += x; |
510 len -= x; | |
511 ds->buffer_pos += x; | |
26437 | 512 } |
513 } | |
514 return bytes; | |
1 | 515 } |
516 | |
17417
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
517 /** |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
518 * \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
|
519 * \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
|
520 * \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
|
521 * \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
|
522 * \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
|
523 * \return whether pattern was found |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
524 */ |
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
525 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
|
526 int *read, uint32_t pattern) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
527 { |
26437 | 528 register uint32_t head = 0xffffff00; |
529 register uint32_t pat = pattern & 0xffffff00; | |
530 int total_len = 0; | |
531 do { | |
532 register unsigned char *ds_buf = &ds->buffer[ds->buffer_size]; | |
533 int len = ds->buffer_size - ds->buffer_pos; | |
534 register long pos = -len; | |
535 if (unlikely(pos >= 0)) { // buffer is empty | |
536 ds_fill_buffer(ds); | |
537 continue; | |
538 } | |
17417
960b2fa1567e
function to read from a demuxer up to (and including) the specified
reimar
parents:
17366
diff
changeset
|
539 do { |
26437 | 540 head |= ds_buf[pos]; |
541 head <<= 8; | |
542 } while (++pos && head != pat); | |
543 len += pos; | |
544 if (total_len + len > maxlen) | |
545 len = maxlen - total_len; | |
546 len = demux_read_data(ds, mem ? &mem[total_len] : NULL, len); | |
547 total_len += len; | |
548 } while ((head != pat || total_len < 3) && total_len < maxlen && !ds->eof); | |
549 if (read) | |
550 *read = total_len; | |
551 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
|
552 } |
746 | 553 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
554 void ds_free_packs(demux_stream_t *ds) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
555 { |
26437 | 556 demux_packet_t *dp=ds->first; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
557 while (dp) { |
26437 | 558 demux_packet_t *dn=dp->next; |
559 free_demux_packet(dp); | |
560 dp=dn; | |
561 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
562 if (ds->asf_packet) { |
26437 | 563 // free unfinished .asf fragments: |
564 free(ds->asf_packet->buffer); | |
565 free(ds->asf_packet); | |
566 ds->asf_packet=NULL; | |
567 } | |
568 ds->first=ds->last=NULL; | |
569 ds->packs=0; // !!!!! | |
570 ds->bytes=0; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
571 if (ds->current) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
572 free_demux_packet(ds->current); |
26437 | 573 ds->current=NULL; |
574 ds->buffer=NULL; | |
575 ds->buffer_pos=ds->buffer_size; | |
27050 | 576 ds->pts = 0; |
577 ds->pts_bytes = 0; | |
1 | 578 } |
579 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
580 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
|
581 { |
24826 | 582 int len; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
583 if (ds->buffer_pos >= ds->buffer_size) { |
27052 | 584 if (!ds_fill_buffer(ds)) { |
1 | 585 // EOF |
586 *start = NULL; | |
587 return -1; | |
27052 | 588 } |
1 | 589 } |
26437 | 590 len=ds->buffer_size-ds->buffer_pos; |
24826 | 591 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 592 ds->buffer_pos+=len; |
24826 | 593 return len; |
1 | 594 } |
554 | 595 |
26437 | 596 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
|
597 { |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
598 int len; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
599 *pts = MP_NOPTS_VALUE; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
600 if (ds->buffer_pos >= ds->buffer_size) { |
27052 | 601 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
|
602 // EOF |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
603 *start = NULL; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
604 return -1; |
27052 | 605 } |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
606 } |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18900
diff
changeset
|
607 // 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
|
608 if (!ds->buffer_pos) |
27052 | 609 *pts = ds->current->pts; |
26437 | 610 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
|
611 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 612 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
|
613 return len; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
614 } |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18237
diff
changeset
|
615 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
616 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
|
617 { |
24826 | 618 int len; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
619 if(ds->buffer_pos >= ds->buffer_size){ |
27052 | 620 *start = NULL; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
621 if (!ds->packs) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
622 return -1; // no sub |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
623 if (!ds_fill_buffer(ds)) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
624 return -1; // EOF |
554 | 625 } |
26437 | 626 len=ds->buffer_size-ds->buffer_pos; |
24826 | 627 *start = &ds->buffer[ds->buffer_pos]; |
26437 | 628 ds->buffer_pos+=len; |
24826 | 629 return len; |
554 | 630 } |
631 | |
18309
87161f96fa66
Change common pts variables from floats to doubles. Individual demuxers
uau
parents:
18242
diff
changeset
|
632 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
|
633 { |
26437 | 634 demuxer_t* demux = ds->demuxer; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
635 while (!ds->first) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
636 if(demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES){ |
26437 | 637 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); |
638 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
639 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
|
640 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
641 if(demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES){ |
26437 | 642 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes); |
643 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | |
644 return MP_NOPTS_VALUE; | |
645 } | |
646 if(!demux_fill_buffer(demux,ds)) | |
647 return MP_NOPTS_VALUE; | |
648 } | |
649 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
|
650 } |
68cac7ecaf05
Fix frame_time for variable fps movies as it was the last frame duration.
albeu
parents:
5897
diff
changeset
|
651 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
652 // ==================================================================== |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
653 |
16175 | 654 void demuxer_help(void) |
655 { | |
26437 | 656 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
|
657 |
26437 | 658 mp_msg(MSGT_DEMUXER, MSGL_INFO, "Available demuxers:\n"); |
659 mp_msg(MSGT_DEMUXER, MSGL_INFO, " demuxer: type info: (comment)\n"); | |
660 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DEMUXERS\n"); | |
661 for (i = 0; demuxer_list[i]; i++) { | |
662 if (demuxer_list[i]->type > DEMUXER_TYPE_MAX) // Don't display special demuxers | |
663 continue; | |
664 if (demuxer_list[i]->comment && strlen(demuxer_list[i]->comment)) | |
665 mp_msg(MSGT_DEMUXER, MSGL_INFO, "%10s %2d %s (%s)\n", | |
666 demuxer_list[i]->name, demuxer_list[i]->type, demuxer_list[i]->info, demuxer_list[i]->comment); | |
667 else | |
668 mp_msg(MSGT_DEMUXER, MSGL_INFO, "%10s %2d %s\n", | |
669 demuxer_list[i]->name, demuxer_list[i]->type, demuxer_list[i]->info); | |
670 } | |
16175 | 671 } |
672 | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
14666
diff
changeset
|
673 |
16175 | 674 /** |
675 * Get demuxer type for a given demuxer name | |
676 * | |
677 * @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
|
678 * @param force will be set if demuxer should be forced. |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16310
diff
changeset
|
679 * May be NULL. |
16175 | 680 * @return DEMUXER_TYPE_xxx, -1 if error or not found |
681 */ | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16310
diff
changeset
|
682 int get_demuxer_type_from_name(char *demuxer_name, int *force) |
16175 | 683 { |
26437 | 684 int i; |
685 long type_int; | |
686 char *endptr; | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
5107
diff
changeset
|
687 |
26437 | 688 if (!demuxer_name || !demuxer_name[0]) |
689 return DEMUXER_TYPE_UNKNOWN; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
690 if (force) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
691 *force = demuxer_name[0] == '+'; |
26437 | 692 if (demuxer_name[0] == '+') |
693 demuxer_name = &demuxer_name[1]; | |
694 for (i = 0; demuxer_list[i]; i++) { | |
695 if (demuxer_list[i]->type > DEMUXER_TYPE_MAX) // Can't select special demuxers from commandline | |
696 continue; | |
697 if (strcmp(demuxer_name, demuxer_list[i]->name) == 0) | |
698 return demuxer_list[i]->type; | |
699 } | |
16175 | 700 |
26437 | 701 // No match found, try to parse name as an integer (demuxer number) |
702 type_int = strtol(demuxer_name, &endptr, 0); | |
703 if (*endptr) // Conversion failed | |
704 return -1; | |
705 if ((type_int > 0) && (type_int <= DEMUXER_TYPE_MAX)) | |
706 return (int)type_int; | |
26379 | 707 |
26437 | 708 return -1; |
16175 | 709 } |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
3786
diff
changeset
|
710 |
26437 | 711 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
|
712 |
26437 | 713 int correct_pts=0; |
714 int user_correct_pts=-1; | |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
18900
diff
changeset
|
715 |
9751
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
716 /* |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 to the right type (ex: rawaudio,rawvideo). |
25197
eb2c5925ec34
Fix typos in comments to stop them hurting my eyes
reimar
parents:
24826
diff
changeset
|
724 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
|
725 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
|
726 (ex: tv,mf). |
00c97b0891e3
Fix all demuxers wich where using a global var to enable themself.
albeu
parents:
9709
diff
changeset
|
727 */ |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
728 |
26437 | 729 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
|
730 int force, int audio_id, int video_id, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
731 int dvdsub_id, char *filename) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
732 { |
26437 | 733 demuxer_t *demuxer=NULL; |
1659 | 734 |
26437 | 735 sh_video_t *sh_video=NULL; |
736 | |
737 const demuxer_desc_t *demuxer_desc; | |
738 int fformat = 0; | |
739 int i; | |
740 | |
741 // If somebody requested a demuxer check it | |
742 if (file_format) { | |
743 if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) { | |
744 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
745 if (demuxer_desc->check_file) | |
746 fformat = demuxer_desc->check_file(demuxer); | |
747 if (force || !demuxer_desc->check_file) | |
748 fformat = demuxer_desc->type; | |
749 if (fformat != 0) { | |
750 if (fformat == demuxer_desc->type) { | |
751 demuxer_t *demux2 = demuxer; | |
752 // Move messages to demuxer detection code? | |
753 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
754 file_format = fformat; | |
755 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
756 demuxer = demux2; | |
757 goto dmx_open; | |
20303 | 758 } |
26437 | 759 } else { |
760 // Format changed after check, recurse | |
761 free_demuxer(demuxer); | |
762 return demux_open_stream(stream, fformat, force, | |
763 audio_id, video_id, dvdsub_id, filename); | |
764 } | |
20303 | 765 } |
26437 | 766 // Check failed for forced demuxer, quit |
767 free_demuxer(demuxer); | |
768 return NULL; | |
769 } | |
770 } | |
771 | |
772 // Test demuxers with safe file checks | |
773 for (i = 0; (demuxer_desc = demuxer_list[i]); i++) { | |
774 if (demuxer_desc->safe_check) { | |
775 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
776 if ((fformat = demuxer_desc->check_file(demuxer)) != 0) { | |
777 if (fformat == demuxer_desc->type) { | |
778 demuxer_t *demux2 = demuxer; | |
779 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
780 file_format = fformat; | |
781 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
782 demuxer = demux2; | |
783 goto dmx_open; | |
26379 | 784 } |
26437 | 785 } else { |
786 if (fformat == DEMUXER_TYPE_PLAYLIST) | |
787 return demuxer; // handled in mplayer.c | |
788 // Format changed after check, recurse | |
789 free_demuxer(demuxer); | |
790 demuxer=demux_open_stream(stream, fformat, force, | |
791 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
792 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
793 return demuxer; // done! |
26437 | 794 file_format = DEMUXER_TYPE_UNKNOWN; |
795 } | |
26379 | 796 } |
26437 | 797 free_demuxer(demuxer); |
798 demuxer = NULL; | |
799 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
800 } |
9006
d00997f12257
extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
8937
diff
changeset
|
801 |
26437 | 802 // If no forced demuxer perform file extension based detection |
803 // Ok. We're over the stable detectable fileformats, the next ones are a bit | |
804 // fuzzy. So by default (extension_parsing==1) try extension-based detection | |
805 // first: | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
806 if (file_format == DEMUXER_TYPE_UNKNOWN && filename && extension_parsing == 1) { |
26437 | 807 file_format=demuxer_type_by_filename(filename); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
808 if (file_format != DEMUXER_TYPE_UNKNOWN) { |
26437 | 809 // we like recursion :) |
810 demuxer=demux_open_stream(stream, file_format, force, | |
811 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
812 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
813 return demuxer; // done! |
26437 | 814 file_format=DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing... |
815 mp_msg(MSGT_DEMUXER,MSGL_V,"demuxer: continue fuzzy content-based format guessing...\n"); | |
816 } | |
817 } | |
818 | |
819 // Try detection for all other demuxers | |
820 for (i = 0; (demuxer_desc = demuxer_list[i]); i++) { | |
821 if (!demuxer_desc->safe_check && demuxer_desc->check_file) { | |
822 demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename); | |
823 if ((fformat = demuxer_desc->check_file(demuxer)) != 0) { | |
824 if (fformat == demuxer_desc->type) { | |
825 demuxer_t *demux2 = demuxer; | |
826 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc); | |
827 file_format = fformat; | |
828 if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) { | |
829 demuxer = demux2; | |
830 goto dmx_open; | |
831 } | |
832 } else { | |
833 if (fformat == DEMUXER_TYPE_PLAYLIST) | |
834 return demuxer; // handled in mplayer.c | |
835 // Format changed after check, recurse | |
836 free_demuxer(demuxer); | |
837 demuxer=demux_open_stream(stream, fformat, force, | |
838 audio_id, video_id, dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
839 if (demuxer) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
840 return demuxer; // done! |
26437 | 841 file_format = DEMUXER_TYPE_UNKNOWN; |
842 } | |
843 } | |
844 free_demuxer(demuxer); | |
845 demuxer = NULL; | |
846 } | |
847 } | |
848 | |
849 return NULL; | |
850 //====== File format recognized, set up these for compatibility: ========= | |
851 dmx_open: | |
852 | |
853 demuxer->file_format=file_format; | |
854 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
855 if ((sh_video = demuxer->video->sh) && sh_video->bih){ |
26437 | 856 int biComp=le2me_32(sh_video->bih->biCompression); |
857 mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %dx%d %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n", | |
858 (char *)&biComp, | |
859 sh_video->bih->biWidth, | |
860 sh_video->bih->biHeight, | |
861 sh_video->bih->biBitCount, | |
862 sh_video->fps, | |
863 sh_video->i_bps*0.008f, | |
864 sh_video->i_bps/1024.0f ); | |
865 } | |
866 #ifdef USE_ASS | |
867 if (ass_enabled && ass_library) { | |
868 for (i = 0; i < MAX_S_STREAMS; ++i) { | |
869 sh_sub_t* sh = demuxer->s_streams[i]; | |
870 if (sh && sh->type == 'a') { | |
871 sh->ass_track = ass_new_track(ass_library); | |
872 if (sh->ass_track && sh->extradata) | |
873 ass_process_codec_private(sh->ass_track, sh->extradata, sh->extradata_len); | |
874 } else if (sh && sh->type != 'v') | |
875 sh->ass_track = ass_default_track(ass_library); | |
876 } | |
877 } | |
878 #endif | |
879 return demuxer; | |
880 } | |
881 | |
882 char* audio_stream = NULL; | |
883 char* sub_stream = NULL; | |
9709 | 884 int audio_stream_cache = 0; |
7867 | 885 |
26437 | 886 char *demuxer_name = NULL; // parameter from -demuxer |
16175 | 887 char *audio_demuxer_name = NULL; // parameter from -audio-demuxer |
26437 | 888 char *sub_demuxer_name = NULL; // parameter from -sub-demuxer |
16175 | 889 |
7867 | 890 extern int hr_mp3_seek; |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
891 |
12835
4235ae5a2d60
cache min fill adjustment, based on patch by Jeremy Huddleston
iive
parents:
12434
diff
changeset
|
892 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
|
893 extern float stream_cache_seek_min_percent; |
12835
4235ae5a2d60
cache min fill adjustment, based on patch by Jeremy Huddleston
iive
parents:
12434
diff
changeset
|
894 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
895 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
|
896 int video_id, int dvdsub_id, char *filename) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
897 { |
26437 | 898 stream_t *as = NULL,*ss = NULL; |
899 demuxer_t *vd,*ad = NULL,*sd = NULL; | |
900 demuxer_t *res; | |
901 int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ; | |
902 int demuxer_type; | |
903 int audio_demuxer_type = 0, sub_demuxer_type = 0; | |
27050 | 904 int demuxer_force = 0, audio_demuxer_force = 0, sub_demuxer_force = 0; |
16175 | 905 |
26437 | 906 if ((demuxer_type = get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) { |
907 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-demuxer %s does not exist.\n",demuxer_name); | |
908 } | |
909 if ((audio_demuxer_type = get_demuxer_type_from_name(audio_demuxer_name, &audio_demuxer_force)) < 0) { | |
910 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-audio-demuxer %s does not exist.\n",audio_demuxer_name); | |
911 } | |
912 if ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name, &sub_demuxer_force)) < 0) { | |
913 mp_msg(MSGT_DEMUXER,MSGL_ERR,"-sub-demuxer %s does not exist.\n",sub_demuxer_name); | |
914 } | |
915 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
916 if (audio_stream) { |
26437 | 917 as = open_stream(audio_stream,0,&afmt); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
918 if (!as) { |
26437 | 919 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenAudioStream,audio_stream); |
920 return NULL; | |
26379 | 921 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
922 if (audio_stream_cache) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
923 if (!stream_enable_cache(as,audio_stream_cache * 1024,audio_stream_cache * 1024 * (stream_cache_min_percent / 100.0), |
27052 | 924 audio_stream_cache * 1024 * (stream_cache_seek_min_percent / 100.0))) { |
925 free_stream(as); | |
926 mp_msg(MSGT_DEMUXER,MSGL_ERR,"Can't enable audio stream cache\n"); | |
927 return NULL; | |
26437 | 928 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
929 } |
26437 | 930 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
931 if (sub_stream) { |
26437 | 932 ss = open_stream(sub_stream,0,&sfmt); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
933 if (!ss) { |
26437 | 934 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenSubtitlesStream,sub_stream); |
935 return NULL; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
936 } |
26437 | 937 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
938 |
26437 | 939 vd = demux_open_stream(vs, demuxer_type ? demuxer_type : file_format, |
940 demuxer_force, audio_stream ? -2 : audio_id, video_id, | |
941 sub_stream ? -2 : dvdsub_id, filename); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
942 if (!vd) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
943 if (as) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
944 free_stream(as); |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
945 if (ss) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
946 free_stream(ss); |
26437 | 947 return NULL; |
948 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
949 if (as) { |
26437 | 950 ad = demux_open_stream(as, audio_demuxer_type ? audio_demuxer_type : afmt, |
951 audio_demuxer_force, audio_id, -2, -2, audio_stream); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
952 if (!ad) { |
26437 | 953 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream); |
954 free_stream(as); | |
27053 | 955 } else if (ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3 |
26437 | 956 hr_mp3_seek=1; // Enable high res seeking |
957 } | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
958 if (ss) { |
26437 | 959 sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt, |
960 sub_demuxer_force, -2, -2, dvdsub_id, sub_stream); | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
961 if (!sd) { |
26437 | 962 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningSubtitlesDemuxerFailed,sub_stream); |
963 free_stream(ss); | |
9709 | 964 } |
26437 | 965 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
966 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
967 if (ad && sd) |
26437 | 968 res = new_demuxers_demuxer(vd,ad,sd); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
969 else if (ad) |
26437 | 970 res = new_demuxers_demuxer(vd,ad,vd); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
971 else if (sd) |
26437 | 972 res = new_demuxers_demuxer(vd,vd,sd); |
973 else | |
974 res = vd; | |
25919
382672c7480a
Allow demuxers to choose a default value for correct_pts
reimar
parents:
25883
diff
changeset
|
975 |
26437 | 976 correct_pts = user_correct_pts; |
977 if (correct_pts < 0) | |
978 correct_pts = demux_control(res, DEMUXER_CTRL_CORRECT_PTS, NULL) == DEMUXER_CTRL_OK; | |
979 return res; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
980 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
981 |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
982 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
983 void demux_flush(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
984 { |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
985 ds_free_packs(demuxer->video); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
986 ds_free_packs(demuxer->audio); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
987 ds_free_packs(demuxer->sub); |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
988 } |
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
989 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
990 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
|
991 int flags) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
992 { |
26437 | 993 demux_stream_t *d_audio=demuxer->audio; |
994 demux_stream_t *d_video=demuxer->video; | |
995 sh_audio_t *sh_audio=d_audio->sh; | |
996 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
|
997 double tmp = 0; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
998 double pts; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
999 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1000 if (!demuxer->seekable) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1001 if (demuxer->file_format == DEMUXER_TYPE_AVI) |
27052 | 1002 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekRawAVI); |
2790 | 1003 #ifdef USE_TV |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1004 else if (demuxer->file_format == DEMUXER_TYPE_TV) |
27052 | 1005 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_TVInputNotSeekable); |
2790 | 1006 #endif |
26437 | 1007 else |
27052 | 1008 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekFile); |
26437 | 1009 return 0; |
1010 } | |
1011 | |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1012 demux_flush(demuxer); |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1013 // clear demux buffers: |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1014 if (sh_audio) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1015 sh_audio->a_buffer_len=0; |
27045 | 1016 demuxer->stream->eof = 0; |
26437 | 1017 demuxer->video->eof=0; |
1018 demuxer->audio->eof=0; | |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1019 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1020 if (sh_video) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1021 sh_video->timer = 0; // !!!!!! |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1022 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1023 if (flags & SEEK_ABSOLUTE) |
26437 | 1024 pts = 0.0f; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1025 else { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1026 if (demuxer->stream_pts == MP_NOPTS_VALUE) |
26437 | 1027 goto dmx_seek; |
1028 pts = demuxer->stream_pts; | |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1029 } |
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1030 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1031 if (flags & SEEK_FACTOR) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1032 if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &tmp) == STREAM_UNSUPPORTED) |
26437 | 1033 goto dmx_seek; |
1034 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
|
1035 } else |
26437 | 1036 pts += rel_seek_secs; |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1037 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1038 if (stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != STREAM_UNSUPPORTED) { |
26437 | 1039 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
1040 return 1; | |
20748
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1041 } |
865b71a83296
now demux_seek() tries to seek aided by the stream layer, if possible
nicodvb
parents:
20319
diff
changeset
|
1042 |
26437 | 1043 dmx_seek: |
1044 if (demuxer->desc->seek) | |
1045 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
|
1046 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1047 if (sh_audio) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1048 resync_audio_stream(sh_audio); |
16877
9081ae3a702c
move resync_audio_stream after seeking to demuxer.c
reimar
parents:
16572
diff
changeset
|
1049 |
26437 | 1050 return 1; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1051 } |
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1052 |
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
|
1053 int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param) |
3050 | 1054 { |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1055 char **info = demuxer->info; |
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1056 int n = 0; |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1496
diff
changeset
|
1057 |
3050 | 1058 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1059 for (n = 0; info && info[2 * n] != NULL; n++) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1060 if (!strcasecmp(opt, info[2 * n])) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1061 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_DemuxerInfoChanged, opt, |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1062 param); |
27052 | 1063 free(info[2*n+1]); |
1064 info[2*n+1] = strdup(param); | |
1065 return 0; | |
1066 } | |
26437 | 1067 } |
27051 | 1068 |
26437 | 1069 info = demuxer->info = (char**)realloc(info,(2*(n+2))*sizeof(char*)); |
1070 info[2*n] = strdup(opt); | |
1071 info[2*n+1] = strdup(param); | |
1072 memset(&info[2*(n+1)],0,2*sizeof(char*)); | |
3050 | 1073 |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1074 return 1; |
3050 | 1075 } |
1076 | |
1077 int demux_info_print(demuxer_t *demuxer) | |
1078 { | |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1079 char **info = demuxer->info; |
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1080 int n; |
3050 | 1081 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1082 if (!info) |
26437 | 1083 return 0; |
4694
a21735031d6a
Audio file demuxer. Extended version for demuxer info.
albeu
parents:
4660
diff
changeset
|
1084 |
26437 | 1085 mp_msg(MSGT_DEMUX, MSGL_INFO,MSGTR_ClipInfo); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1086 for (n = 0; info[2 * n] != NULL; n++) { |
26437 | 1087 mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n",info[2*n],info[2*n+1]); |
1088 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n, info[2*n]); | |
1089 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
|
1090 } |
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
|
1091 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_N=%d\n", n); |
4189 | 1092 |
1093 return 0; | |
3050 | 1094 } |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1095 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1096 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
|
1097 { |
26437 | 1098 int i; |
1099 char **info = demuxer->info; | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1100 |
26437 | 1101 for(i = 0; info && info[2*i] != NULL; i++) { |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1102 if (!strcasecmp(opt, info[2 * i])) |
26437 | 1103 return info[2*i+1]; |
1104 } | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1105 |
26437 | 1106 return NULL; |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1107 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
4735
diff
changeset
|
1108 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1109 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
|
1110 { |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1111 |
16175 | 1112 if (demuxer->desc->control) |
26437 | 1113 return demuxer->desc->control(demuxer,cmd,arg); |
16175 | 1114 |
1115 return DEMUXER_CTRL_NOTIMPL; | |
8208
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 |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1119 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1120 double demuxer_get_time_length(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1121 { |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16326
diff
changeset
|
1122 double get_time_ans; |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1123 sh_video_t *sh_video = demuxer->video->sh; |
16925 | 1124 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
|
1125 // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1126 if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans) <= 0) { |
26437 | 1127 if (sh_video && sh_video->i_bps && sh_audio && sh_audio->i_bps) |
1128 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/(sh_video->i_bps+sh_audio->i_bps); | |
1129 else if (sh_video && sh_video->i_bps) | |
1130 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps; | |
1131 else if (sh_audio && sh_audio->i_bps) | |
1132 get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_audio->i_bps; | |
1133 else | |
27051 | 1134 get_time_ans=0; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1135 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1136 return get_time_ans; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1137 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1138 |
20749
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1139 /** |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1140 * \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
|
1141 * 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
|
1142 * 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
|
1143 * 0 otherwise |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1144 * \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
|
1145 */ |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1146 int demuxer_get_current_time(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1147 { |
20749
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1148 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
|
1149 sh_video_t *sh_video = demuxer->video->sh; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1150 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
|
1151 get_time_ans = demuxer->stream_pts; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1152 else if (sh_video) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1153 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
|
1154 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
|
1155 } |
eafd9953b505
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
nicodvb
parents:
20748
diff
changeset
|
1156 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1157 int demuxer_get_percent_pos(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1158 { |
14197
2ae224195625
Use demuxer_get_percent_pos for the OSD position bar
reimar
parents:
14160
diff
changeset
|
1159 int ans = 0; |
2ae224195625
Use demuxer_get_percent_pos for the OSD position bar
reimar
parents:
14160
diff
changeset
|
1160 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
|
1161 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
|
1162 if (res <= 0) { |
26437 | 1163 if (len > 0) |
1164 ans = (demuxer->filepos - demuxer->movi_start) / len; | |
1165 else | |
1166 ans = 0; | |
14502
8769fa370f83
Move generic length and percent pos calculation to demuxer.c
reimar
parents:
14276
diff
changeset
|
1167 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1168 if (ans < 0) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1169 ans = 0; |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1170 if (ans > 100) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1171 ans = 100; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1172 return ans; |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1173 } |
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8123
diff
changeset
|
1174 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1175 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
|
1176 { |
15285
39eb8a327ea9
adds a parameter to the switch_audio command to directly select a track.
reimar
parents:
15046
diff
changeset
|
1177 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
|
1178 if (res == DEMUXER_CTRL_NOTIMPL) |
26437 | 1179 index = demuxer->audio->id; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1180 if (demuxer->audio->id >= 0) |
26437 | 1181 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
|
1182 else |
26437 | 1183 demuxer->audio->sh = NULL; |
15285
39eb8a327ea9
adds a parameter to the switch_audio command to directly select a track.
reimar
parents:
15046
diff
changeset
|
1184 return index; |
15046
b7aa70b05d76
Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents:
14934
diff
changeset
|
1185 } |
19342 | 1186 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1187 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
|
1188 { |
20948 | 1189 int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_VIDEO, &index); |
1190 if (res == DEMUXER_CTRL_NOTIMPL) | |
26437 | 1191 index = demuxer->video->id; |
26089
e2f35d90ad39
Set audio->sh correctly when switching audio tracks. The same for video tracks.
eugeni
parents:
26088
diff
changeset
|
1192 if (demuxer->video->id >= 0) |
26437 | 1193 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
|
1194 else |
26437 | 1195 demuxer->video->sh = NULL; |
20948 | 1196 return index; |
1197 } | |
1198 | |
26437 | 1199 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
|
1200 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
|
1201 { |
25657 | 1202 if (!(demuxer->num_attachments & 31)) |
26437 | 1203 demuxer->attachments = realloc(demuxer->attachments, (demuxer->num_attachments + 32) * sizeof(demux_attachment_t)); |
25657 | 1204 |
1205 demuxer->attachments[demuxer->num_attachments].name = strdup(name); | |
1206 demuxer->attachments[demuxer->num_attachments].type = strdup(type); | |
1207 demuxer->attachments[demuxer->num_attachments].data = malloc(size); | |
1208 memcpy(demuxer->attachments[demuxer->num_attachments].data, data, size); | |
1209 demuxer->attachments[demuxer->num_attachments].data_size = size; | |
1210 | |
26437 | 1211 return demuxer->num_attachments ++; |
25657 | 1212 } |
1213 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1214 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
|
1215 uint64_t end) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1216 { |
19342 | 1217 if (demuxer->chapters == NULL) |
26437 | 1218 demuxer->chapters = malloc (32*sizeof(*demuxer->chapters)); |
19342 | 1219 else if (!(demuxer->num_chapters % 32)) |
26437 | 1220 demuxer->chapters = realloc (demuxer->chapters, (demuxer->num_chapters + 32) * sizeof(*demuxer->chapters)); |
19342 | 1221 |
1222 demuxer->chapters[demuxer->num_chapters].start = start; | |
1223 demuxer->chapters[demuxer->num_chapters].end = end; | |
1224 demuxer->chapters[demuxer->num_chapters].name = strdup(name); | |
1225 | |
26437 | 1226 return demuxer->num_chapters ++; |
19342 | 1227 } |
1228 | |
19435 | 1229 /** |
27051 | 1230 * \brief demuxer_seek_chapter() seeks to a chapter in two possible ways: |
19435 | 1231 * either using the demuxer->chapters structure set by the demuxer |
1232 * or asking help to the stream layer (e.g. dvd) | |
19439 | 1233 * \param chapter - chapter number wished - 0-based |
19435 | 1234 * \param mode 0: relative to current main pts, 1: absolute |
1235 * \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
|
1236 * \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
|
1237 * \param chapter_name name of chapter found (set by this function is param is not null) |
19435 | 1238 * \return -1 on error, current chapter if successful |
1239 */ | |
1240 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1241 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
|
1242 float *seek_pts, int *num_chapters, |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1243 char **chapter_name) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1244 { |
19435 | 1245 int ris; |
1246 int current, total; | |
1247 sh_video_t *sh_video = demuxer->video->sh; | |
1248 sh_audio_t *sh_audio = demuxer->audio->sh; | |
1249 | |
1250 if (!demuxer->num_chapters || !demuxer->chapters) { | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1251 if (!mode) { |
26437 | 1252 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
|
1253 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1254 return -1; |
19438
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1255 chapter += current; |
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1256 } |
263e95c47aec
support relative seeking in the stream-driven case
nicodvb
parents:
19435
diff
changeset
|
1257 |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1258 demux_flush(demuxer); |
19435 | 1259 |
26437 | 1260 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
|
1261 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
|
1262 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1263 if (sh_video) { |
19435 | 1264 ds_fill_buffer(demuxer->video); |
1265 resync_video_stream(sh_video); | |
1266 } | |
1267 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1268 if (sh_audio) { |
19435 | 1269 ds_fill_buffer(demuxer->audio); |
1270 resync_audio_stream(sh_audio); | |
1271 } | |
26437 | 1272 |
1273 //exit status may be ok, but main() doesn't have to seek itself (because e.g. dvds depend on sectors, not on pts) | |
19435 | 1274 *seek_pts = -1.0; |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1275 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1276 if (num_chapters) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1277 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
|
1278 *num_chapters = 0; |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1279 } |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1280 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1281 if (chapter_name) { |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1282 *chapter_name = NULL; |
25314
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1283 if (num_chapters && *num_chapters) { |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1284 char *tmp = malloc(16); |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1285 if (tmp) { |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1286 sprintf(tmp, " of %3d", *num_chapters); |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1287 *chapter_name = tmp; |
02e2e7a5599a
Fix memory leak that tmp allocated but maybe not used.
ulion
parents:
25266
diff
changeset
|
1288 } |
19478
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 } |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1291 |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26437
diff
changeset
|
1292 return ris != STREAM_UNSUPPORTED ? chapter : -1; |
26437 | 1293 } else { //chapters structure is set in the demuxer |
19435 | 1294 total = demuxer->num_chapters; |
1295 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1296 if (mode == 1) //absolute seeking |
19435 | 1297 current = chapter; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1298 else { //relative seeking |
19435 | 1299 uint64_t now; |
26437 | 1300 now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0.)) * 1000 + .5; |
19435 | 1301 |
1302 for (current = total - 1; current >= 0; --current) { | |
26437 | 1303 demux_chapter_t* chapter = demuxer->chapters + current; |
19435 | 1304 if (chapter->start <= now) |
1305 break; | |
1306 } | |
1307 current += chapter; | |
1308 } | |
1309 | |
1310 if (current >= total) | |
26437 | 1311 return -1; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1312 if (current < 0) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1313 current = 0; |
19435 | 1314 |
1315 *seek_pts = demuxer->chapters[current].start / 1000.0; | |
1316 | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1317 if (num_chapters) |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1318 *num_chapters = demuxer->num_chapters; |
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1319 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1320 if (chapter_name) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1321 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
|
1322 *chapter_name = strdup(demuxer->chapters[current].name); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1323 else |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1324 *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
|
1325 } |
19478
bab82c53e433
demuxer_seek_chapter() returns informations about chapters count and name
nicodvb
parents:
19439
diff
changeset
|
1326 |
19435 | 1327 return current; |
1328 } | |
1329 } | |
25358 | 1330 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1331 int demuxer_get_current_chapter(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1332 { |
25358 | 1333 int chapter = -1; |
1334 if (!demuxer->num_chapters || !demuxer->chapters) { | |
1335 if (stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, | |
1336 &chapter) == STREAM_UNSUPPORTED) | |
1337 chapter = -1; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1338 } else { |
25358 | 1339 sh_video_t *sh_video = demuxer->video->sh; |
1340 sh_audio_t *sh_audio = demuxer->audio->sh; | |
1341 uint64_t now; | |
26437 | 1342 now = (sh_video ? sh_video->pts : (sh_audio?sh_audio->pts:0))*1000+0.5; |
25358 | 1343 for (chapter = demuxer->num_chapters - 1; chapter >= 0; --chapter) { |
1344 if (demuxer->chapters[chapter].start <= now) | |
1345 break; | |
1346 } | |
1347 } | |
1348 return chapter; | |
1349 } | |
1350 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1351 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
|
1352 { |
25358 | 1353 if (demuxer->num_chapters && demuxer->chapters) { |
26437 | 1354 if (chapter >=0 && chapter < demuxer->num_chapters && |
1355 demuxer->chapters[chapter].name) | |
25358 | 1356 return strdup(demuxer->chapters[chapter].name); |
1357 } | |
1358 return NULL; | |
1359 } | |
1360 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1361 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
|
1362 { |
25358 | 1363 char *chapter_name = demuxer_chapter_name(demuxer, chapter); |
1364 if (chapter_name) { | |
1365 char *tmp = malloc(strlen(chapter_name) + 14); | |
1366 snprintf(tmp, 63, "(%d) %s", chapter + 1, chapter_name); | |
27051 | 1367 free(chapter_name); |
25358 | 1368 return tmp; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1369 } else { |
25358 | 1370 int chapter_num = demuxer_chapter_count(demuxer); |
1371 char tmp[30]; | |
1372 if (chapter_num <= 0) | |
1373 sprintf(tmp, "(%d)", chapter + 1); | |
1374 else | |
1375 sprintf(tmp, "(%d) of %d", chapter + 1, chapter_num); | |
1376 return strdup(tmp); | |
1377 } | |
1378 } | |
1379 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1380 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
|
1381 { |
25358 | 1382 if (demuxer->num_chapters && demuxer->chapters && chapter >= 0 |
26437 | 1383 && chapter < demuxer->num_chapters) { |
25358 | 1384 if (end) |
1385 *end = demuxer->chapters[chapter].end / 1000.0; | |
1386 return demuxer->chapters[chapter].start / 1000.0; | |
1387 } | |
1388 return -1.0; | |
1389 } | |
1390 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1391 int demuxer_chapter_count(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1392 { |
25358 | 1393 if (!demuxer->num_chapters || !demuxer->chapters) { |
1394 int num_chapters = 0; | |
1395 if (stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, | |
1396 &num_chapters) == STREAM_UNSUPPORTED) | |
1397 num_chapters = 0; | |
1398 return num_chapters; | |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1399 } else |
25358 | 1400 return demuxer->num_chapters; |
1401 } | |
1402 | |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1403 int demuxer_angles_count(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1404 { |
26437 | 1405 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
|
1406 |
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
|
1407 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
|
1408 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1409 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
|
1410 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
|
1411 } |
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
|
1412 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1413 int demuxer_get_current_angle(demuxer_t *demuxer) |
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1414 { |
26437 | 1415 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
|
1416 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
|
1417 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1418 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
|
1419 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
|
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 |
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
|
1422 |
27047
6ff2454fe5ec
cosmetics: Make all function declarations consistent by moving the opening
diego
parents:
27046
diff
changeset
|
1423 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
|
1424 { |
26437 | 1425 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
|
1426 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
|
1427 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
|
1428 |
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
|
1429 angles = demuxer_angles_count(demuxer); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1430 if ((angles < 1) || (angle > angles)) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1431 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
|
1432 |
26926
1e6241274552
added and reused demux_flush() instead of emptying the demux_stream buffers;
nicodvb
parents:
26876
diff
changeset
|
1433 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
|
1434 |
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
|
1435 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
|
1436 if (ris == STREAM_UNSUPPORTED) |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1437 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
|
1438 |
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
|
1439 demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1440 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
|
1441 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
|
1442 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
|
1443 } |
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
|
1444 |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1445 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
|
1446 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
|
1447 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
|
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 |
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 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
|
1451 } |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1452 |
26437 | 1453 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
|
1454 { |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1455 int i, len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1456 lang += strspn(lang, ","); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1457 while ((len = strcspn(lang, ",")) > 0) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1458 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1459 sh_audio_t* sh = d->a_streams[i]; |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1460 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
|
1461 return sh->aid; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1462 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1463 lang += len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1464 lang += strspn(lang, ","); |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1465 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1466 return -1; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1467 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1468 |
26437 | 1469 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
|
1470 { |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1471 int i, len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1472 lang += strspn(lang, ","); |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1473 while ((len = strcspn(lang, ",")) > 0) { |
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1474 for (i = 0; i < MAX_S_STREAMS; ++i) { |
26437 | 1475 sh_sub_t* sh = d->s_streams[i]; |
26086
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1476 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
|
1477 return sh->sid; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1478 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1479 lang += len; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1480 lang += strspn(lang, ","); |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1481 } |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1482 return -1; |
c9a877daca42
Demuxer-independent functions for selecting tracks based on language.
eugeni
parents:
26085
diff
changeset
|
1483 } |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1484 |
26437 | 1485 int demuxer_default_audio_track(demuxer_t* d) |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1486 { |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1487 int i; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1488 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1489 sh_audio_t* sh = d->a_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1490 if (sh && sh->default_track) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1491 return sh->aid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1492 } |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1493 for (i = 0; i < MAX_A_STREAMS; ++i) { |
26437 | 1494 sh_audio_t* sh = d->a_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1495 if (sh) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1496 return sh->aid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1497 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1498 return -1; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1499 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1500 |
26437 | 1501 int demuxer_default_sub_track(demuxer_t* d) |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1502 { |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1503 int i; |
27049
762a9c6bfb43
cosmetics: Consistently format all if, for, while constructs.
diego
parents:
27048
diff
changeset
|
1504 for (i = 0; i < MAX_S_STREAMS; ++i) { |
26437 | 1505 sh_sub_t* sh = d->s_streams[i]; |
26269
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1506 if (sh && sh->default_track) |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1507 return sh->sid; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1508 } |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1509 return -1; |
65ad20416dd7
Support 'default' attribute for audio and subtitle tracks.
eugeni
parents:
26089
diff
changeset
|
1510 } |
26437 | 1511 |