[vlc-devel] [PATCH] Smooth Streaming: read PacketSize attribute in manifest
Frédéric Yhuel
yhuelf at gmail.com
Thu Sep 27 17:24:37 CEST 2012
PacketSize == nBlockAlign attribute of WaveFormatEx structure.
We also remove the AvgBytesPerSec attribute of the quality_level_t
structure, since it is equal to the Bitrate attribute (divided per 8).
---
modules/demux/mp4/libmp4.c | 1 -
modules/demux/mp4/libmp4.h | 1 -
modules/demux/mp4/mp4.c | 2 +-
modules/stream_filter/smooth/downloader.c | 13 ++++++-------
modules/stream_filter/smooth/smooth.c | 3 ++-
modules/stream_filter/smooth/smooth.h | 1 -
6 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index afd4dd1..8bdb535 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -516,7 +516,6 @@ static int MP4_ReadBox_stra( stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_stra->BitsPerSample );
MP4_GET4BYTES( p_stra->PacketSize );
MP4_GET4BYTES( p_stra->AudioTag );
- MP4_GET4BYTES( p_stra->AvgBytesPerSec );
MP4_GET2BYTES( p_stra->nBlockAlign );
MP4_GET1BYTE( i_reserved );
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 22ede26..a8d0b2e 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1140,7 +1140,6 @@ typedef struct
uint32_t MaxWidth;
uint32_t MaxHeight;
uint32_t SamplingRate;
- uint32_t AvgBytesPerSec;
uint32_t Channels;
uint32_t BitsPerSample;
uint32_t PacketSize;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index d2e0530..e210d4d 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3207,7 +3207,7 @@ static int MP4_frg_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_
fmt->audio.i_bitspersample = p_data->BitsPerSample;
fmt->audio.i_blockalign = p_data->nBlockAlign;
- fmt->i_bitrate = p_data->AvgBytesPerSec * 8;
+ fmt->i_bitrate = p_data->Bitrate;
ret = MP4_SetCodecExtraData( fmt, p_data );
if( ret != VLC_SUCCESS )
diff --git a/modules/stream_filter/smooth/downloader.c b/modules/stream_filter/smooth/downloader.c
index f019af2..793cb68 100644
--- a/modules/stream_filter/smooth/downloader.c
+++ b/modules/stream_filter/smooth/downloader.c
@@ -277,8 +277,8 @@ static int get_new_chunks( stream_t *s, chunk_t *ck )
return VLC_SUCCESS;
}
-#define STRA_SIZE 342
-#define SMOO_SIZE (STRA_SIZE * 3 + 24) /* 1050 */
+#define STRA_SIZE 338
+#define SMOO_SIZE (STRA_SIZE * 3 + 24) /* 1038 */
/* SmooBox is a very simple MP4 box, used only to pass information
* to the demux layer. As this box is not aimed to travel accross networks,
@@ -358,14 +358,13 @@ static int build_smoo_box( stream_t *s, uint8_t *smoo_box )
((uint32_t *)stra_box)[22] = bswap32( qlvl->BitsPerSample );
((uint32_t *)stra_box)[23] = bswap32( qlvl->PacketSize );
((uint32_t *)stra_box)[24] = bswap32( qlvl->AudioTag );
- ((uint32_t *)stra_box)[25] = bswap32( qlvl->AvgBytesPerSec );
- ((uint16_t *)stra_box)[52] = bswap16( qlvl->nBlockAlign );
+ ((uint16_t *)stra_box)[50] = bswap16( qlvl->nBlockAlign );
- stra_box[106] = stra_box[107] = stra_box[108] = 0; /* reserved */
+ stra_box[102] = stra_box[103] = stra_box[104] = 0; /* reserved */
assert( strlen( qlvl->CodecPrivateData ) < 512 );
- stra_box[109] = strlen( qlvl->CodecPrivateData ) / 2;
+ stra_box[105] = strlen( qlvl->CodecPrivateData ) / 2;
uint8_t *binary_cpd = decode_string_hex_to_binary( qlvl->CodecPrivateData );
- memcpy( stra_box + 110, binary_cpd, stra_box[109] );
+ memcpy( stra_box + 106, binary_cpd, stra_box[105] );
free( binary_cpd );
}
diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index 08bf8ed..07e8391 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -247,6 +247,8 @@ static int parse_Manifest( stream_t *s )
ql->Index = strtol( value, NULL, 10 );
if( !strcmp( name, "Bitrate" ) )
ql->Bitrate = strtoull( value, NULL, 10 );
+ if( !strcmp( name, "PacketSize" ) )
+ ql->nBlockAlign = strtoull( value, NULL, 10 );
if( !strcmp( name, "FourCC" ) )
ql->FourCC = VLC_FOURCC( value[0], value[1],
value[2], value[3] );
@@ -263,7 +265,6 @@ static int parse_Manifest( stream_t *s )
ql->Channels = ((uint16_t *)WaveFormatEx)[1];
ql->SamplingRate = ((uint32_t *)WaveFormatEx)[1];
- ql->AvgBytesPerSec = ((uint32_t *)WaveFormatEx)[2];
ql->nBlockAlign = ((uint16_t *)WaveFormatEx)[6];
ql->BitsPerSample = ((uint16_t *)WaveFormatEx)[7];
free( WaveFormatEx );
diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h
index 6d85567..da92cc0 100644
--- a/modules/stream_filter/smooth/smooth.h
+++ b/modules/stream_filter/smooth/smooth.h
@@ -60,7 +60,6 @@ typedef struct quality_level_s
unsigned MaxWidth;
unsigned MaxHeight;
unsigned SamplingRate;
- unsigned AvgBytesPerSec;
unsigned Channels;
unsigned BitsPerSample;
unsigned PacketSize;
--
1.7.9.5
More information about the vlc-devel
mailing list