Changeset 14c5e914ffb2ca51676a2d6c6b081a8e324fe47e

Show
Ignore:
Timestamp:
01/03/07 17:52:12 (2 years ago)
Author:
Damien Fouilleul <damienf@videolan.org>
git-committer:
Damien Fouilleul <damienf@videolan.org> 1172767932 +0000
git-parent:

[df02a09ad6a85226a23d29443c671398b5debedf]

git-author:
Damien Fouilleul <damienf@videolan.org> 1172767932 +0000
Message:

- mp4 demux: support for iTunes/Quicktime META info

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/mp4/libmp4.c

    r072cd3c r14c5e91  
    20882088 
    20892089    MP4_GET2BYTES( i_length ); 
    2090     MP4_GET2BYTES( i_dummy ); 
    20912090 
    20922091    if( i_length > 0 ) 
    20932092    { 
     2093        MP4_GET2BYTES( i_dummy ); 
    20942094        if( i_length > i_read ) i_length = i_read; 
    20952095 
     
    21072107#endif 
    21082108    } 
     2109    else 
     2110    { 
     2111        /* try iTune/Quicktime format, rewind to start */ 
     2112        p_peek -= 2; i_read += 2; 
     2113        // we are expecting a 'data' box 
     2114        uint32_t i_data_len; 
     2115        uint32_t i_data_tag; 
     2116 
     2117        MP4_GET4BYTES( i_data_len ); 
     2118        if( i_data_len > i_read ) i_data_len = i_read; 
     2119        MP4_GETFOURCC( i_data_tag ); 
     2120        if( (i_data_len > 0) && (i_data_tag == VLC_FOURCC('d', 'a', 't', 'a')) ) 
     2121        { 
     2122            /* data box contains a version/flags field */ 
     2123            uint32_t i_version; 
     2124            uint32_t i_reserved; 
     2125            MP4_GET4BYTES( i_version ); 
     2126            MP4_GET4BYTES( i_reserved ); 
     2127            // version should be 0, flags should be 1 for text, 0 for data 
     2128            if( i_version == 0x00000001 ) 
     2129            { 
     2130                // the rest is the text 
     2131                i_data_len -= 12; 
     2132                p_box->data.p_0xa9xxx->psz_text = malloc( i_data_len + 1 ); 
     2133 
     2134                memcpy( p_box->data.p_0xa9xxx->psz_text, 
     2135                        p_peek, i_data_len ); 
     2136                p_box->data.p_0xa9xxx->psz_text[i_data_len] = '\0'; 
     2137#ifdef MP4_VERBOSE 
     2138        msg_Dbg( p_stream, 
     2139                 "read box: \"%4.4s\" text=`%s'", 
     2140                 (char*)&p_box->i_type, 
     2141                 p_box->data.p_0xa9xxx->psz_text ); 
     2142#endif 
     2143            } 
     2144            else 
     2145            { 
     2146                // TODO: handle data values for ID3 tag values, track num or cover art,etc... 
     2147            } 
     2148        } 
     2149    } 
    21092150 
    21102151    MP4_READBOX_EXIT( 1 ); 
     
    21132154{ 
    21142155    FREENULL( p_box->data.p_0xa9xxx->psz_text ); 
     2156} 
     2157 
     2158static int MP4_ReadBox_meta( stream_t *p_stream, MP4_Box_t *p_box ) 
     2159{ 
     2160    uint8_t meta_data[8]; 
     2161    int i_actually_read; 
     2162 
     2163    // skip over box header 
     2164    i_actually_read = stream_Read( p_stream, meta_data, 8 ); 
     2165    if( i_actually_read < 8 ) 
     2166        return 0; 
     2167 
     2168    /* meta content starts with a 4 byte version/flags value (should be 0) */ 
     2169    i_actually_read = stream_Read( p_stream, meta_data, 4 ); 
     2170    if( i_actually_read < 4 ) 
     2171        return 0; 
     2172 
     2173    /* then it behaves like a container */ 
     2174    return MP4_ReadBoxContainerRaw( p_stream, p_box ); 
    21152175} 
    21162176 
     
    21852245    { FOURCC_gmhd,  MP4_ReadBoxContainer,   MP4_FreeBox_Common }, 
    21862246    { FOURCC_wave,  MP4_ReadBoxContainer,   MP4_FreeBox_Common }, 
     2247    { FOURCC_ilst,  MP4_ReadBoxContainer,   MP4_FreeBox_Common }, 
    21872248 
    21882249    /* specific box */ 
     
    23392400    { FOURCC_0xa9com,MP4_ReadBox_0xa9xxx,       MP4_FreeBox_0xa9xxx }, 
    23402401 
     2402    /* iTunes/Quicktime meta info */ 
     2403    { FOURCC_meta,  MP4_ReadBox_meta,       MP4_FreeBox_Common }, 
     2404 
    23412405    /* Last entry */ 
    23422406    { 0,             MP4_ReadBox_default,       NULL } 
  • modules/demux/mp4/libmp4.h

    rf64ef86 r14c5e91  
    210210#define FOURCC_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' ) 
    211211 
     212#define FOURCC_meta VLC_FOURCC( 'm', 'e', 't', 'a' ) 
     213#define FOURCC_ilst VLC_FOURCC( 'i', 'l', 's', 't' ) 
     214 
    212215/* Do you want some debug information on all read boxes ? */ 
    213216#define MP4_VERBOSE  1 
  • modules/demux/mp4/mp4.c

    rf64ef86 r14c5e91  
    784784        { 
    785785            vlc_meta_t *p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t*); 
    786             MP4_Box_t  *p_udta   = MP4_BoxGet( p_sys->p_root, "/moov/udta" ); 
    787786            MP4_Box_t  *p_0xa9xxx; 
     787 
     788            MP4_Box_t  *p_udta = MP4_BoxGet( p_sys->p_root, "/moov/udta/meta/ilst" ); 
    788789            if( p_udta == NULL ) 
    789790            { 
    790                 return VLC_EGENERIC; 
    791             } 
     791                p_udta = MP4_BoxGet( p_sys->p_root, "/moov/udta" ); 
     792                if( p_udta == NULL ) 
     793                { 
     794                    return VLC_EGENERIC; 
     795                } 
     796            } 
     797 
    792798            for( p_0xa9xxx = p_udta->p_first; p_0xa9xxx != NULL; 
    793799                 p_0xa9xxx = p_0xa9xxx->p_next ) 
    794800            { 
    795801                char *psz_utf; 
     802 
    796803                if( !p_0xa9xxx || !p_0xa9xxx->data.p_0xa9xxx ) 
    797804                    continue; 
     
    806813                { 
    807814                case FOURCC_0xa9nam: /* Full name */ 
    808                     vlc_meta_SetArtist( p_meta, psz_utf ); 
     815                    vlc_meta_SetTitle( p_meta, psz_utf ); 
    809816                    break; 
    810817                case FOURCC_0xa9aut: 
     
    827834                    break; 
    828835 
     836                case FOURCC_0xa9alb: /* Album */ 
     837                    vlc_meta_SetAlbum( p_meta, psz_utf ); 
     838                    break; 
     839 
    829840                case FOURCC_0xa9swr: 
    830841                case FOURCC_0xa9inf: /* Information */ 
    831                 case FOURCC_0xa9alb: /* Album */ 
    832842                case FOURCC_0xa9dir: /* Director */ 
    833843                case FOURCC_0xa9dis: /* Disclaimer */