Commit c3d17338 authored by Adrien Maglo's avatar Adrien Maglo Committed by Thomas Guillem

demux: mp4: support the 360 spherical video box

It is defined by the Spherical Video specification v1 from Google.
https://github.com/google/spatial-media/blob/master/docs/spherical-video-rfc.mdSigned-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 08d26ea0
...@@ -345,6 +345,16 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample ) ...@@ -345,6 +345,16 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
break; break;
} }
/* Set 360 video mode */
const MP4_Box_t *p_uuid = MP4_BoxGet( p_track->p_track, "uuid" );
for( ; p_uuid; p_uuid = p_uuid->p_next)
{
if( p_uuid->i_type == ATOM_uuid
&& !CmpUUID( &p_uuid->i_uuid, &XML360BoxUUID )
&& p_uuid->data.p_360 )
p_track->fmt.video.projection_mode = p_uuid->data.p_360->i_projection_mode;
}
/* It's a little ugly but .. there are special cases */ /* It's a little ugly but .. there are special cases */
switch( p_sample->i_type ) switch( p_sample->i_type )
{ {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_stream.h> /* vlc_stream_Peek*/ #include <vlc_stream.h> /* vlc_stream_Peek*/
#include <vlc_strings.h> /* vlc_ascii_tolower */
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
# include <zlib.h> /* for compressed moov */ # include <zlib.h> /* for compressed moov */
...@@ -712,12 +713,45 @@ static int MP4_ReadBox_tfrf( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -712,12 +713,45 @@ static int MP4_ReadBox_tfrf( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 ); MP4_READBOX_EXIT( 1 );
} }
static int MP4_ReadBox_XML360( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_360_t, NULL );
MP4_Box_data_360_t *p_360_data = p_box->data.p_360;
/* Copy the string for pattern matching as it does not end
with a '\0' in the stream. */
char *psz_rdf = strndup((char *)p_peek, i_read);
if ( unlikely( !psz_rdf ) )
MP4_READBOX_EXIT( 0 );
/* Try to find the string "GSpherical:Spherical" because the v1
spherical video spec says the tag must be there. */
if ( strcasestr( psz_rdf, "Gspherical:Spherical" ) )
p_360_data->i_projection_mode = PROJECTION_MODE_EQUIRECTANGULAR;
/* Try to find the stero mode. */
if ( strcasestr( psz_rdf, "left-right" ) )
msg_Dbg( p_stream, "Left-right stereo mode" );
if ( strcasestr( psz_rdf, "top-bottom" ) )
msg_Dbg( p_stream, "Top-bottom stereo mode" );
free( psz_rdf );
MP4_READBOX_EXIT( 1 );
}
static int MP4_ReadBox_uuid( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_uuid( stream_t *p_stream, MP4_Box_t *p_box )
{ {
if( !CmpUUID( &p_box->i_uuid, &TfrfBoxUUID ) ) if( !CmpUUID( &p_box->i_uuid, &TfrfBoxUUID ) )
return MP4_ReadBox_tfrf( p_stream, p_box ); return MP4_ReadBox_tfrf( p_stream, p_box );
if( !CmpUUID( &p_box->i_uuid, &TfxdBoxUUID ) ) if( !CmpUUID( &p_box->i_uuid, &TfxdBoxUUID ) )
return MP4_ReadBox_tfxd( p_stream, p_box ); return MP4_ReadBox_tfxd( p_stream, p_box );
if( !CmpUUID( &p_box->i_uuid, &XML360BoxUUID ) )
return MP4_ReadBox_XML360( p_stream, p_box );
#ifdef MP4_VERBOSE #ifdef MP4_VERBOSE
msg_Warn( p_stream, "Unknown uuid type box: " msg_Warn( p_stream, "Unknown uuid type box: "
......
...@@ -1538,6 +1538,11 @@ typedef struct ...@@ -1538,6 +1538,11 @@ typedef struct
uint32_t i_blob; uint32_t i_blob;
} MP4_Box_data_data_t; } MP4_Box_data_data_t;
typedef struct
{
uint32_t i_projection_mode;
} MP4_Box_data_360_t;
/* /*
typedef struct MP4_Box_data__s typedef struct MP4_Box_data__s
{ {
...@@ -1643,6 +1648,8 @@ typedef union MP4_Box_data_s ...@@ -1643,6 +1648,8 @@ typedef union MP4_Box_data_s
MP4_Box_data_strf_t *p_strf; /* flip4mac Little endian video config */ MP4_Box_data_strf_t *p_strf; /* flip4mac Little endian video config */
MP4_Box_data_ASF_t *p_asf; /* flip4mac asf streams indicator */ MP4_Box_data_ASF_t *p_asf; /* flip4mac asf streams indicator */
MP4_Box_data_360_t *p_360;
/* for generic handlers */ /* for generic handlers */
MP4_Box_data_string_t *p_string; MP4_Box_data_string_t *p_string;
MP4_Box_data_binary_t *p_binary; MP4_Box_data_binary_t *p_binary;
...@@ -1801,6 +1808,10 @@ static const UUID_t TfxdBoxUUID = { ...@@ -1801,6 +1808,10 @@ static const UUID_t TfxdBoxUUID = {
{ 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6, { 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } }; 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } };
static const UUID_t XML360BoxUUID = {
{ 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd } };
/***************************************************************************** /*****************************************************************************
* MP4_BoxGetNextChunk : Parse the entire moof box. * MP4_BoxGetNextChunk : Parse the entire moof box.
***************************************************************************** *****************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment