annotate libmpdemux/demux_demuxers.c @ 16784:7a6e909c223e

minor typo
author diego
date Mon, 17 Oct 2005 08:50:04 +0000
parents f443f849531b
children 9dd44ff7ec32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
3
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
4 #include <stdlib.h>
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
5 #include <stdio.h>
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
6 #include "stream.h"
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
7 #include "demuxer.h"
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
8 #include "stheader.h"
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
9
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
10 typedef struct dd_priv {
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
11 demuxer_t* vd;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
12 demuxer_t* ad;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
13 demuxer_t* sd;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
14 } dd_priv_t;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
15
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
16 extern demuxer_desc_t demuxer_desc_demuxers;
4765
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
17
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
18 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
19 demuxer_t* ret;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
20 dd_priv_t* priv;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
21
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
22 ret = (demuxer_t*)calloc(1,sizeof(demuxer_t));
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
23
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
24 priv = (dd_priv_t*)malloc(sizeof(dd_priv_t));
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
25 priv->vd = vd;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
26 priv->ad = ad;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
27 priv->sd = sd;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
28 ret->priv = priv;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
29
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
30 ret->type = ret->file_format = DEMUXER_TYPE_DEMUXERS;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
31 // Video is the most important :-)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
32 ret->stream = vd->stream;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
33 ret->seekable = vd->seekable && ad->seekable && sd->seekable;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
34
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
35 ret->video = vd->video;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
36 ret->audio = ad->audio;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
37 ret->sub = sd->sub;
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
38
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
39 ret->desc = &demuxer_desc_demuxers;
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
40
4765
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
41 return ret;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
42 }
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
43
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
44 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
45 dd_priv_t* priv;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
46
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
47 priv=demux->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 if(ds->demuxer == priv->vd)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
50 return demux_fill_buffer(priv->vd,ds);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
51 else if(ds->demuxer == priv->ad)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
52 return demux_fill_buffer(priv->ad,ds);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
53 else if(ds->demuxer == priv->sd)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
54 return demux_fill_buffer(priv->sd,ds);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
55
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
56 printf("Demux demuxers fill_buffer error : bad demuxer : not vd, ad nor sd\n");
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
57 return 0;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
58 }
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
59
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
60 static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) {
4765
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
61 dd_priv_t* priv;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
62 float pos;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
63 priv=demuxer->priv;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
64
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
65 priv->ad->stream->eof = 0;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
66 priv->sd->stream->eof = 0;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
67
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
68 // Seek video
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
69 demux_seek(priv->vd,rel_seek_secs,flags);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
70 // Get the new pos
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
71 pos = demuxer->video->pts;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
72
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
73 if(priv->ad != priv->vd) {
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
74 sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh;
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
75 demux_seek(priv->ad,pos,1);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
76 // In case the demuxer don't set pts
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
77 if(!demuxer->audio->pts)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
78 demuxer->audio->pts = pos-((ds_tell_pts(demuxer->audio)-sh->a_in_buffer_len)/(float)sh->i_bps);
8056
324b6e5387be A-V sync cleanup: sh_audio->timer replaced by sh_audio->delay, it contains
arpi
parents: 5812
diff changeset
79 sh->delay = 0;
4765
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
80 }
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 if(priv->sd != priv->vd)
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
83 demux_seek(priv->sd,pos,1);
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
84
d0c2c8af46b4 Demuxers demuxer support for using external audiofile (or muxed subtitles).
albeu
parents:
diff changeset
85 }
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
86
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
87 static void demux_close_demuxers(demuxer_t* demuxer) {
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
88 int i;
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
89 dd_priv_t* priv = demuxer->priv;
9710
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
90 stream_t *s;
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
91
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
92 if(priv->vd)
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
93 free_demuxer(priv->vd);
9710
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
94 if(priv->ad && priv->ad != priv->vd) {
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
95 // That's a hack to free the audio file stream
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
96 // It's ok atm but we shouldn't free that here
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
97 s = priv->ad->stream;
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
98 free_demuxer(priv->ad);
9710
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
99 free_stream(s);
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
100 } if(priv->sd && priv->sd != priv->vd && priv->sd != priv->ad) {
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
101 s = priv->sd->stream;
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
102 free_demuxer(priv->sd);
9710
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
103 free_stream(s);
e3db09ae5154 Free the stream of the audio and subtitle demuxer.
albeu
parents: 8056
diff changeset
104 }
5812
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
105
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
106 free(priv);
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
107 }
f9d23c2aa6b7 Uninit added
albeu
parents: 4765
diff changeset
108
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
109
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
110 demuxer_desc_t demuxer_desc_demuxers = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
111 "Demuxers demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
112 "", // Not selectable
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
113 "",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
114 "?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
115 "internal use only",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
116 DEMUXER_TYPE_DEMUXERS,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
117 0, // no autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
118 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
119 demux_demuxers_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
120 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
121 demux_close_demuxers,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
122 demux_demuxers_seek,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
123 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 9710
diff changeset
124 };