Mercurial > mplayer.hg
annotate libmpdemux/demux_demuxers.c @ 19264:3826d2cfa4b0
There is a reference to a file COPYRIGHT that we do not include, so paste
the contents of COPYRIGHT into the file header.
author | diego |
---|---|
date | Sun, 30 Jul 2006 22:17:25 +0000 |
parents | a8e681ad7c90 |
children | 672123d27ae3 |
rev | line source |
---|---|
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
1 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
2 #include "config.h" |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
3 #include "mp_msg.h" |
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
4 #include "help_mp.h" |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
5 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
6 #include <stdlib.h> |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
7 #include <stdio.h> |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
8 #include "stream.h" |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
9 #include "demuxer.h" |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
10 #include "stheader.h" |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
11 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
12 typedef struct dd_priv { |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
13 demuxer_t* vd; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
14 demuxer_t* ad; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
15 demuxer_t* sd; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
16 } dd_priv_t; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
17 |
16175 | 18 extern demuxer_desc_t demuxer_desc_demuxers; |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
19 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
20 demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd) { |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
21 demuxer_t* ret; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
22 dd_priv_t* priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
23 |
18885 | 24 ret = calloc(1,sizeof(demuxer_t)); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
25 |
18885 | 26 priv = malloc(sizeof(dd_priv_t)); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
27 priv->vd = vd; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
28 priv->ad = ad; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
29 priv->sd = sd; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
30 ret->priv = priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
31 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
32 ret->type = ret->file_format = DEMUXER_TYPE_DEMUXERS; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
33 // Video is the most important :-) |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
34 ret->stream = vd->stream; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
35 ret->seekable = vd->seekable && ad->seekable && sd->seekable; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
36 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
37 ret->video = vd->video; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
38 ret->audio = ad->audio; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
39 ret->sub = sd->sub; |
16175 | 40 |
41 ret->desc = &demuxer_desc_demuxers; | |
42 | |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
43 return ret; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
44 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
45 |
16175 | 46 static int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds) { |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
47 dd_priv_t* priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
48 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
49 priv=demux->priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
50 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
51 if(ds->demuxer == priv->vd) |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
52 return demux_fill_buffer(priv->vd,ds); |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
53 else if(ds->demuxer == priv->ad) |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
54 return demux_fill_buffer(priv->ad,ds); |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
55 else if(ds->demuxer == priv->sd) |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
56 return demux_fill_buffer(priv->sd,ds); |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
57 |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
58 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MPDEMUX_DEMUXERS_FillBufferError); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
59 return 0; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
60 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
61 |
17636 | 62 static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags) { |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
63 dd_priv_t* priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
64 float pos; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
65 priv=demuxer->priv; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
66 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
67 priv->ad->stream->eof = 0; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
68 priv->sd->stream->eof = 0; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
69 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
70 // Seek video |
17636 | 71 demux_seek(priv->vd,rel_seek_secs,audio_delay,flags); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
72 // Get the new pos |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
73 pos = demuxer->video->pts; |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
74 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
75 if(priv->ad != priv->vd) { |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
76 sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh; |
17636 | 77 demux_seek(priv->ad,pos,audio_delay,1); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
78 // In case the demuxer don't set pts |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
79 if(!demuxer->audio->pts) |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
80 demuxer->audio->pts = pos-((ds_tell_pts(demuxer->audio)-sh->a_in_buffer_len)/(float)sh->i_bps); |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
81 } |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
82 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
83 if(priv->sd != priv->vd) |
17636 | 84 demux_seek(priv->sd,pos,audio_delay,1); |
4765
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
85 |
d0c2c8af46b4
Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff
changeset
|
86 } |
5812 | 87 |
16175 | 88 static void demux_close_demuxers(demuxer_t* demuxer) { |
5812 | 89 dd_priv_t* priv = demuxer->priv; |
9710 | 90 stream_t *s; |
5812 | 91 |
92 if(priv->vd) | |
93 free_demuxer(priv->vd); | |
9710 | 94 if(priv->ad && priv->ad != priv->vd) { |
95 // That's a hack to free the audio file stream | |
96 // It's ok atm but we shouldn't free that here | |
97 s = priv->ad->stream; | |
5812 | 98 free_demuxer(priv->ad); |
9710 | 99 free_stream(s); |
100 } if(priv->sd && priv->sd != priv->vd && priv->sd != priv->ad) { | |
101 s = priv->sd->stream; | |
5812 | 102 free_demuxer(priv->sd); |
9710 | 103 free_stream(s); |
104 } | |
5812 | 105 |
106 free(priv); | |
107 } | |
108 | |
16175 | 109 |
16876
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
110 static int demux_demuxers_control(demuxer_t *demuxer,int cmd, void *arg){ |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
111 dd_priv_t* priv = demuxer->priv; |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
112 switch (cmd) { |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
113 case DEMUXER_CTRL_GET_TIME_LENGTH: |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
114 *((double *)arg) = demuxer_get_time_length(priv->vd); |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
115 return DEMUXER_CTRL_OK; |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
116 case DEMUXER_CTRL_GET_PERCENT_POS: |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
117 *((int *)arg) = demuxer_get_percent_pos(priv->vd); |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
118 return DEMUXER_CTRL_OK; |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
119 } |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
120 return DEMUXER_CTRL_NOTIMPL; |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
121 } |
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
122 |
16175 | 123 demuxer_desc_t demuxer_desc_demuxers = { |
124 "Demuxers demuxer", | |
125 "", // Not selectable | |
126 "", | |
127 "?", | |
128 "internal use only", | |
129 DEMUXER_TYPE_DEMUXERS, | |
130 0, // no autodetect | |
131 NULL, | |
132 demux_demuxers_fill_buffer, | |
133 NULL, | |
134 demux_close_demuxers, | |
135 demux_demuxers_seek, | |
16876
9dd44ff7ec32
Provide DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS.
reimar
parents:
16291
diff
changeset
|
136 demux_demuxers_control |
16175 | 137 }; |