/*****************************************************************************
* ogg.c : ogg stream demux module for vlc
*****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_input.h>
+#include <vlc_demux.h>
#include <ogg/ogg.h>
-#include "codecs.h"
-#include "vlc_bits.h"
+#include <vlc_codecs.h>
+#include <vlc_bits.h>
/*****************************************************************************
* Module descriptor
static void Close( vlc_object_t * );
vlc_module_begin();
- set_description( _("Ogg stream demuxer" ) );
+ set_shortname ( "OGG" );
+ set_description( _("OGG demuxer" ) );
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_DEMUX );
set_capability( "demux2", 50 );
/* bitrate */
int i_bitrate;
+
+ /* attachments */
+ int i_attachments;
+ input_attachment_t **attachments;
};
/* OggDS headers for the new header format (used in ogm files) */
static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t *)p_this;
+ input_thread_t *p_input;
demux_sys_t *p_sys;
- uint8_t *p_peek;
+ const uint8_t *p_peek;
/* Check if we are dealing with an ogg stream */
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
- if( strcmp( p_demux->psz_demux, "ogg" ) && memcmp( p_peek, "OggS", 4 ) )
+ if( !p_demux->b_force && memcmp( p_peek, "OggS", 4 ) )
{
return VLC_EGENERIC;
}
/* Begnning of stream, tell the demux to look for elementary streams. */
p_sys->i_eos = 0;
+
+ p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+ if( p_input )
+ {
+ p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+ if( !p_demux->p_private )
+ {
+ vlc_object_release( p_input );
+ return VLC_ENOMEM;
+ }
+ module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
+ if( p_meta )
+ {
+ demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+ vlc_meta_Merge( input_GetItem(p_input)->p_meta,
+ p_demux_meta->p_meta );
+ vlc_meta_Delete( p_demux_meta->p_meta );
+ module_Unneed( p_demux, p_meta );
+ p_sys->i_attachments = p_demux_meta->i_attachments;
+ p_sys->attachments = p_demux_meta->attachments;
+ }
+ vlc_object_release( p_input );
+ free( p_demux->p_private );
+ }
+
/* Initialize the Ogg physical bitstream parser */
ogg_sync_init( &p_sys->oy );
Ogg_EndOfStream( p_demux );
+ int i;
+ for( i = 0; i < p_sys->i_attachments; i++ )
+ free( p_sys->attachments[i] );
+ TAB_CLEAN( p_sys->i_attachments, p_sys->attachments);
+
free( p_sys );
}
demux_sys_t *p_sys = p_demux->p_sys;
int64_t *pi64;
int i;
+ input_attachment_t ***ppp_attach;
+ int *pi_int;
switch( i_query )
{
}
ogg_sync_reset( &p_sys->oy );
+ case DEMUX_GET_ATTACHMENTS:
+ ppp_attach =
+ (input_attachment_t***)va_arg( args, input_attachment_t*** );
+ pi_int = (int*)va_arg( args, int * );
+
+ if( p_sys->i_attachments <= 0 )
+ return VLC_EGENERIC;
+
+ *pi_int = p_sys->i_attachments;
+ *ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachments );
+ for( i = 0; i < p_sys->i_attachments; i++ )
+ (*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] );
+ return VLC_SUCCESS;
+
default:
return demux2_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
1, i_query, args );
! memcmp ( &p_oggpacket->packet[0], "Annodex", 7 ) )
{
/* it's an Annodex packet -- skip it (do nothing) */
- return;
+ return;
}
else if( p_oggpacket->bytes >= 7 &&
! memcmp ( &p_oggpacket->packet[0], "AnxData", 7 ) )
{
/* it's an AnxData packet -- skip it (do nothing) */
- return;
+ return;
}
if( p_stream->fmt.i_codec == VLC_FOURCC( 's','u','b','t' ) &&
}
if( p_oggpacket->bytes - 1 - i_header_len > 2 ||
( p_oggpacket->packet[i_header_len + 1] != ' ' &&
- p_oggpacket->packet[i_header_len + 1] != 0 &&
+ p_oggpacket->packet[i_header_len + 1] != 0 &&
p_oggpacket->packet[i_header_len + 1] != '\n' &&
p_oggpacket->packet[i_header_len + 1] != '\r' ) )
{
/* we are guaranteed that the first header field will be
* the content-type (by the Annodex standard) */
content_type_string[0] = '\0';
- if( !strncasecmp( &p_oggpacket->packet[28], "Content-Type: ", 14 ) )
+ if( !strncasecmp( (char*)(&p_oggpacket->packet[28]), "Content-Type: ", 14 ) )
{
uint8_t *p = memchr( &p_oggpacket->packet[42], '\r',
p_oggpacket->bytes - 1 );
if( p && p[0] == '\r' && p[1] == '\n' )
- sscanf( &p_oggpacket->packet[42], "%1024s\r\n",
+ sscanf( (char*)(&p_oggpacket->packet[42]), "%1024s\r\n",
content_type_string );
}