[vlc-devel] [RFC 1/3] rtp: parse vorbis identification header
Pierre Ynard
linkfanel at yahoo.fr
Thu Nov 18 05:54:37 CET 2010
diff --git a/modules/access/rtp/xiph.c b/modules/access/rtp/xiph.c
index 03ef83a..7a27e79 100644
--- a/modules/access/rtp/xiph.c
+++ b/modules/access/rtp/xiph.c
@@ -79,7 +79,8 @@ static void vorbis_destroy (demux_t *demux, void *data)
}
/* Convert configuration from RTP to VLC format */
-static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len)
+static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len,
+ es_format_t *p_fmt)
{
/* Headers number */
if (len == 0)
@@ -111,6 +112,13 @@ static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len)
return -1;
setuplen = len - (idlen + cmtlen);
+ /* Parse identification header */
+ if (idlen < 29)
+ return -1;
+ p_fmt->audio.i_channels = buf[11];
+ p_fmt->audio.i_rate = GetDWLE(buf + 12);
+ p_fmt->i_bitrate = GetDWLE(buf + 20);
+
/* Create the VLC extra format header */
unsigned sizes[3] = {
idlen, cmtlen, setuplen
@@ -235,13 +248,15 @@ static void vorbis_decode (demux_t *demux, void *data, block_t *block)
if (self->ident == ident)
break; /* Ignore config retransmission */
+ es_format_t fmt;
+ es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_VORBIS);
+
void *extv;
- ssize_t extc = vorbis_header (&extv, block->p_buffer, len);
+ ssize_t extc = vorbis_header (&extv, block->p_buffer,
+ len, &fmt);
if (extc < 0)
break;
- es_format_t fmt;
- es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_VORBIS);
fmt.p_extra = extv;
fmt.i_extra = extc;
codec_destroy (demux, self->id);
--
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."
More information about the vlc-devel
mailing list