diff options
author | Andreas Heinchen <heinchen@users.sourceforge.net> | 2003-05-04 21:45:45 +0000 |
---|---|---|
committer | Andreas Heinchen <heinchen@users.sourceforge.net> | 2003-05-04 21:45:45 +0000 |
commit | 5d0be2a8f965700f212bcdde70b9957cb3344bb0 (patch) | |
tree | 66e9ce725f5744afe54cf7bfc2ffa124cdb7864a | |
parent | 77ba136d5f5cb3f83156ad45a752e1f503001f65 (diff) | |
download | xine-lib-5d0be2a8f965700f212bcdde70b9957cb3344bb0.tar.gz xine-lib-5d0be2a8f965700f212bcdde70b9957cb3344bb0.tar.bz2 |
get_optional_data now handles spulang
CVS patchset: 4769
CVS date: 2003/05/04 21:45:45
-rw-r--r-- | src/demuxers/demux_ogg.c | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 1ab858d95..eda40554f 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_ogg.c,v 1.94 2003/05/04 18:01:22 heinchen Exp $ + * $Id: demux_ogg.c,v 1.95 2003/05/04 21:45:45 heinchen Exp $ * * demultiplexer for ogg streams * @@ -97,6 +97,7 @@ typedef struct demux_ogg_s { int64_t factor[MAX_STREAMS]; int64_t quotient[MAX_STREAMS]; int resync[MAX_STREAMS]; + char *language[MAX_STREAMS]; int64_t start_pts; @@ -474,9 +475,30 @@ static void send_ogg_buf (demux_ogg_t *this, printf ("demux_ogg: Textstream-header-packet\n"); #endif } else if (op->packet[0] == PACKET_TYPE_COMMENT ) { + + char *comment; + #ifdef LOG printf ("demux_ogg: Textstream-comment-packet\n"); #endif + + vorbis_comment vc; + vorbis_comment_init(&vc); + vorbis_info vi; + vorbis_info_init(&vi); + + /*make libvorbis think, this vi is initialized*/ + vi.rate=1; + + if ( vorbis_synthesis_headerin(&vi, &vc, op) >= 0) { + comment=*vc.user_comments; + if ( !strncasecmp ("LANGUAGE=", comment,8) ) { + this->language[stream_num]=strdup (comment + strlen ("LANGUAGE=") ); + } + } + vorbis_comment_clear(&vc); + vorbis_info_clear(&vi); + } else { subtitle = (char *)&op->packet[hdrlen + 1]; @@ -1178,6 +1200,11 @@ static void demux_ogg_dispose (demux_plugin_t *this_gen) { for (i=0; i<this->num_streams; i++) { ogg_stream_clear(&this->oss[i]); + + if (this->language) { + free (this->language); + this->language[i]=0; + } } ogg_sync_clear(&this->oy); @@ -1320,12 +1347,41 @@ static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) { } static uint32_t demux_ogg_get_capabilities(demux_plugin_t *this_gen) { - return DEMUX_CAP_NOCAP; + return DEMUX_CAP_SPULANG; } static int demux_ogg_get_optional_data(demux_plugin_t *this_gen, void *data, int data_type) { - return DEMUX_OPTIONAL_UNSUPPORTED; + + demux_ogg_t *this = (demux_ogg_t *) this_gen; + + char *str=(char *) data; + int channel = *((int *)data); + int stream_num; + + switch (data_type) { + case DEMUX_OPTIONAL_DATA_SPULANG: + if (channel==-1) { + strcpy( str, "none"); + return DEMUX_OPTIONAL_SUCCESS; + } else if ((channel>=0) && (channel<this->num_streams)) { + for (stream_num=0; stream_num<this->num_streams; stream_num++) { + if (this->buf_types[stream_num]==BUF_SPU_OGM+channel) { + + if (this->language[stream_num]) { + sprintf(str, "%s", this->language[stream_num]); + return DEMUX_OPTIONAL_SUCCESS; + } else { + sprintf(str, "channel %d",channel); + return DEMUX_OPTIONAL_SUCCESS; + } + } + } + return DEMUX_OPTIONAL_UNSUPPORTED; + } + default: + return DEMUX_OPTIONAL_UNSUPPORTED; + } } static demux_plugin_t *open_plugin (demux_class_t *class_gen, |