Changeset 051ce627e6f3c469ecaf98676203dc8a59cc9e57

Show
Ignore:
Timestamp:
01/05/04 13:37:52 (5 years ago)
Author:
Jon Lech Johansen <jlj@videolan.org>
git-committer:
Jon Lech Johansen <jlj@videolan.org> 1073306272 +0000
git-parent:

[d7dce9113efeb2b18e6b33324b842183cb7f0ea5]

git-author:
Jon Lech Johansen <jlj@videolan.org> 1073306272 +0000
Message:
  • ./modules/demux/mp4: DRMS support.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AUTHORS

    rd7dce91 r051ce62  
    1 # $Id: AUTHORS,v 1.100 2004/01/05 12:24:51 jlj Exp $ 
     1# $Id: AUTHORS,v 1.101 2004/01/05 12:37:52 jlj Exp $ 
    22#  
    33# The format of this file was inspired by the Linux kernel CREDITS file. 
     
    198198D: MacOS X port 
    199199D: norwegian translation 
     200D: MP4 DRMS support 
    200201S: France 
    201202 
  • modules/demux/mp4/Modules.am

    rfe17002 r051ce62  
    44    libmp4.c \ 
    55    libmp4.h \ 
     6    drms.c \ 
     7    drms.h \ 
     8    drmstables.h \ 
    69    $(NULL) 
  • modules/demux/mp4/libmp4.c

    r5ca0ebc r051ce62  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libmp4.c,v 1.39 2003/12/22 14:32:55 sam Exp $ 
     5 * $Id: libmp4.c,v 1.40 2004/01/05 12:37:52 jlj Exp $ 
    66 * 
    77 * Author: Laurent Aimar <fenrir@via.ecp.fr> 
     
    3131 
    3232#include "libmp4.h" 
     33#include "drms.h" 
    3334 
    3435/***************************************************************************** 
     
    11471148        MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 ); 
    11481149    } 
     1150 
     1151    p_box->data.p_sample_soun->p_drms = 
     1152        p_box->i_type == FOURCC_drms ? drms_alloc() : NULL; 
     1153 
     1154    if( p_box->data.p_sample_soun->p_drms ) 
     1155    { 
     1156        FILE *file; 
     1157        char *psz_homedir; 
     1158        char *psz_filename; 
     1159        uint32_t p_user_key[ 4 ]; 
     1160 
     1161        int i_ret = 0; 
     1162        vlc_bool_t b_key = VLC_FALSE; 
     1163 
     1164        psz_filename = NULL; 
     1165        psz_homedir = p_stream->p_input->p_vlc->psz_homedir; 
     1166 
     1167#define DRMS_FILENAME "drms" 
     1168 
     1169        if( psz_homedir != NULL ) 
     1170        { 
     1171            psz_filename = (char *)malloc( sizeof("/" CONFIG_DIR "/" 
     1172                                           DRMS_FILENAME) + 
     1173                                           strlen( psz_homedir ) ); 
     1174            if( psz_filename != NULL ) 
     1175            { 
     1176                sprintf( psz_filename, "%s/" CONFIG_DIR "/" DRMS_FILENAME, 
     1177                         psz_homedir ); 
     1178 
     1179                file = fopen( psz_filename, "r" ); 
     1180                if( file != NULL ) 
     1181                { 
     1182                    b_key = fread( p_user_key, sizeof(uint32_t), 
     1183                                   4, file ) == 4 ? VLC_TRUE : VLC_FALSE; 
     1184                    fclose( file ); 
     1185                } 
     1186            } 
     1187        } 
     1188 
     1189        if( b_key == VLC_FALSE ) 
     1190        { 
     1191            i_ret = drms_get_user_key( NULL, p_user_key ); 
     1192        } 
     1193 
     1194        if( !i_ret ) 
     1195        { 
     1196            if( b_key == VLC_FALSE && psz_filename != NULL ) 
     1197            { 
     1198                file = fopen( psz_filename, "w" ); 
     1199                if( file != NULL ) 
     1200                { 
     1201                    fwrite( p_user_key, sizeof(uint32_t), 4, file ); 
     1202                    fclose( file ); 
     1203                } 
     1204            } 
     1205 
     1206            i_ret = drms_init( p_box->data.p_sample_soun->p_drms, 
     1207                               DRMS_INIT_UKEY, (uint8_t *)p_user_key, 
     1208                               sizeof(p_user_key) ); 
     1209        } 
     1210 
     1211        if( psz_filename != NULL ) 
     1212        { 
     1213            free( (void *)psz_filename ); 
     1214        } 
     1215 
     1216        if( i_ret ) 
     1217        { 
     1218            drms_free( p_box->data.p_sample_soun->p_drms ); 
     1219            p_box->data.p_sample_soun->p_drms = NULL; 
     1220        } 
     1221    } 
     1222 
    11491223    MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */ 
    11501224 
     
    11581232#endif 
    11591233    MP4_READBOX_EXIT( 1 ); 
     1234} 
     1235 
     1236 
     1237static void MP4_FreeBox_sample_soun( MP4_Box_t *p_box ) 
     1238{ 
     1239    if( p_box->i_type == FOURCC_drms ) 
     1240    { 
     1241        if( p_box->data.p_sample_soun->p_drms ) 
     1242        { 
     1243            drms_free( p_box->data.p_sample_soun->p_drms ); 
     1244        } 
     1245    } 
    11601246} 
    11611247 
     
    18761962             p_box->data.p_rmvc->i_checkType ); 
    18771963#endif 
     1964 
     1965    MP4_READBOX_EXIT( 1 ); 
     1966} 
     1967 
     1968static int MP4_ReadBox_iviv( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) 
     1969{ 
     1970    MP4_READBOX_ENTER( uint8_t ); 
     1971 
     1972    if( i_read >= sizeof(uint32_t) * 4 ) 
     1973    { 
     1974        MP4_Box_t *p_drms_box = p_box; 
     1975 
     1976        do 
     1977        { 
     1978            p_drms_box = p_drms_box->p_father; 
     1979        } while( p_drms_box && p_drms_box->i_type != FOURCC_drms ); 
     1980 
     1981        if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms ) 
     1982        { 
     1983            if( drms_init( p_drms_box->data.p_sample_soun->p_drms, 
     1984                           DRMS_INIT_IVIV, p_peek, sizeof(uint32_t) * 4 ) ) 
     1985            { 
     1986                drms_free( p_drms_box->data.p_sample_soun->p_drms ); 
     1987                p_drms_box->data.p_sample_soun->p_drms = NULL; 
     1988            } 
     1989        } 
     1990    } 
     1991 
     1992    MP4_READBOX_EXIT( 1 ); 
     1993} 
     1994 
     1995static int MP4_ReadBox_name( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) 
     1996{ 
     1997    MP4_Box_t *p_drms_box = p_box; 
     1998 
     1999    MP4_READBOX_ENTER( uint8_t ); 
     2000 
     2001    do 
     2002    { 
     2003        p_drms_box = p_drms_box->p_father; 
     2004    } while( p_drms_box && p_drms_box->i_type != FOURCC_drms ); 
     2005 
     2006    if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms ) 
     2007    { 
     2008        if( drms_init( p_drms_box->data.p_sample_soun->p_drms, 
     2009                       DRMS_INIT_NAME, p_peek, strlen( p_peek ) ) ) 
     2010        { 
     2011            drms_free( p_drms_box->data.p_sample_soun->p_drms ); 
     2012            p_drms_box->data.p_sample_soun->p_drms = NULL; 
     2013        } 
     2014    } 
     2015 
     2016    MP4_READBOX_EXIT( 1 ); 
     2017} 
     2018 
     2019static int MP4_ReadBox_priv( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) 
     2020{ 
     2021    MP4_Box_t *p_drms_box = p_box; 
     2022 
     2023    MP4_READBOX_ENTER( uint8_t ); 
     2024 
     2025    do 
     2026    { 
     2027        p_drms_box = p_drms_box->p_father; 
     2028    } while( p_drms_box && p_drms_box->i_type != FOURCC_drms ); 
     2029 
     2030    if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms ) 
     2031    { 
     2032        if( drms_init( p_drms_box->data.p_sample_soun->p_drms, 
     2033                       DRMS_INIT_PRIV, p_peek, i_read ) ) 
     2034        { 
     2035            drms_free( p_drms_box->data.p_sample_soun->p_drms ); 
     2036            p_drms_box->data.p_sample_soun->p_drms = NULL; 
     2037        } 
     2038    } 
    18782039 
    18792040    MP4_READBOX_EXIT( 1 ); 
     
    20152176    { FOURCC_rmvc,  MP4_ReadBox_rmvc,           MP4_FreeBox_Common }, 
    20162177 
     2178    { FOURCC_drms,  MP4_ReadBox_sample_soun,    MP4_FreeBox_sample_soun }, 
     2179    { FOURCC_sinf,  MP4_ReadBoxContainer,       MP4_FreeBox_Common }, 
     2180    { FOURCC_schi,  MP4_ReadBoxContainer,       MP4_FreeBox_Common }, 
     2181    { FOURCC_iviv,  MP4_ReadBox_iviv,           MP4_FreeBox_Common }, 
     2182    { FOURCC_name,  MP4_ReadBox_name,           MP4_FreeBox_Common }, 
     2183    { FOURCC_priv,  MP4_ReadBox_priv,           MP4_FreeBox_Common }, 
     2184 
    20172185    /* Last entry */ 
    20182186    { 0,            NULL,                   NULL } 
  • modules/demux/mp4/libmp4.h

    r67c26fd r051ce62  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libmp4.h,v 1.17 2003/10/07 14:59:10 gbazin Exp $ 
     5 * $Id: libmp4.h,v 1.18 2004/01/05 12:37:52 jlj Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    155155#define FOURCC_wave VLC_FOURCC( 'w', 'a', 'v', 'e' ) 
    156156 
     157#define FOURCC_drms VLC_FOURCC( 'd', 'r', 'm', 's' ) 
     158#define FOURCC_sinf VLC_FOURCC( 's', 'i', 'n', 'f' ) 
     159#define FOURCC_schi VLC_FOURCC( 's', 'c', 'h', 'i' ) 
     160#define FOURCC_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' ) 
     161#define FOURCC_name VLC_FOURCC( 'n', 'a', 'm', 'e' ) 
     162#define FOURCC_priv VLC_FOURCC( 'p', 'r', 'i', 'v' ) 
     163 
    157164/* Do you want some debug information on all read boxes ? */ 
    158165#define MP4_VERBOSE  1 
     
    381388    int     i_qt_description; 
    382389    uint8_t *p_qt_description; 
     390 
     391    void    *p_drms; 
    383392 
    384393} MP4_Box_data_sample_soun_t; 
  • modules/demux/mp4/mp4.c

    r66fb3bd r051ce62  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: mp4.c,v 1.46 2003/12/20 16:22:59 gbazin Exp $ 
     5 * $Id: mp4.c,v 1.47 2004/01/05 12:37:52 jlj Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    3232#include "libmp4.h" 
    3333#include "mp4.h" 
     34#include "drms.h" 
    3435 
    3536/***************************************************************************** 
     
    458459                    MP4_TrackUnselect( p_input, &track ); 
    459460                    break; 
     461                } 
     462 
     463                if( track.p_drms != NULL ) 
     464                { 
     465                    drms_decrypt( track.p_drms, 
     466                                  (uint32_t *)p_block->p_buffer, 
     467                                  p_block->i_buffer ); 
    460468                } 
    461469 
     
    12411249    MP4_Box_t *p_smhd; 
    12421250 
     1251    MP4_Box_t *p_drms; 
     1252 
    12431253    unsigned int i; 
    12441254    char language[4]; 
     
    13221332        return; 
    13231333    } 
     1334 
     1335    p_drms = MP4_BoxGet( p_track->p_stsd, "drms" ); 
     1336    p_track->p_drms = p_drms != NULL ? 
     1337        p_drms->data.p_sample_soun->p_drms : NULL; 
    13241338 
    13251339    /* Set language */ 
  • modules/demux/mp4/mp4.h

    ree6c4f5 r051ce62  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: mp4.h,v 1.9 2003/11/27 12:32:51 fenrir Exp $ 
     5 * $Id: mp4.h,v 1.10 2004/01/05 12:37:52 jlj Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    8686    MP4_Box_t *p_stsd;  /* will contain all data to initialize decoder */ 
    8787    MP4_Box_t *p_sample;/* point on actual sdsd */ 
     88 
     89    void *p_drms; 
    8890 
    8991} track_data_mp4_t;