Commit 8631de07 authored by Ilkka Ollakka's avatar Ilkka Ollakka

livehttp: show segment specific iv/key location if they have changed

parent 311a7a8d
...@@ -160,6 +160,7 @@ typedef struct output_segment ...@@ -160,6 +160,7 @@ typedef struct output_segment
char *psz_key_uri; char *psz_key_uri;
char *psz_duration; char *psz_duration;
uint32_t i_segment_number; uint32_t i_segment_number;
uint8_t aes_ivs[16];
} output_segment_t; } output_segment_t;
struct sout_access_out_sys_t struct sout_access_out_sys_t
...@@ -441,25 +442,37 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t ...@@ -441,25 +442,37 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
fclose( fp ); fclose( fp );
return -1; return -1;
} }
char *psz_current_uri=NULL;
if( p_sys->key_uri )
for ( uint32_t i = i_firstseg; i <= p_sys->i_segment; i++ )
{
//scale to 0..numsegs-1
uint32_t index = i-i_firstseg;
output_segment_t *segment = (output_segment_t *)vlc_array_item_at_index( p_sys->segments_t, index );
if( p_sys->key_uri &&
( !psz_current_uri || strcmp( psz_current_uri, segment->psz_key_uri ) )
)
{ {
int ret = 0; int ret = 0;
free( psz_current_uri );
psz_current_uri = strdup( segment->psz_key_uri );
if( p_sys->b_generate_iv ) if( p_sys->b_generate_iv )
{ {
unsigned long long iv_hi = 0, iv_lo = 0; unsigned long long iv_hi = 0, iv_lo = 0;
for( unsigned short i = 0; i < 8; i++ ) for( unsigned short i = 0; i < 8; i++ )
{ {
iv_hi |= p_sys->aes_ivs[i] & 0xff; iv_hi |= segment->aes_ivs[i] & 0xff;
iv_hi <<= 8; iv_hi <<= 8;
iv_lo |= p_sys->aes_ivs[8+i] & 0xff; iv_lo |= segment->aes_ivs[8+i] & 0xff;
iv_lo <<= 8; iv_lo <<= 8;
} }
ret = fprintf( fp, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\",IV=0X%16.16llx%16.16llx\n", ret = fprintf( fp, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\",IV=0X%16.16llx%16.16llx\n",
p_sys->key_uri, iv_hi, iv_lo ); segment->psz_key_uri, iv_hi, iv_lo );
} else { } else {
ret = fprintf( fp, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"\n", p_sys->key_uri ); ret = fprintf( fp, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"\n", segment->psz_key_uri );
} }
if( ret < 0 ) if( ret < 0 )
{ {
...@@ -469,13 +482,6 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t ...@@ -469,13 +482,6 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
} }
} }
for ( uint32_t i = i_firstseg; i <= p_sys->i_segment; i++ )
{
//scale to 0..numsegs-1
uint32_t index = i-i_firstseg;
output_segment_t *segment = (output_segment_t *)vlc_array_item_at_index( p_sys->segments_t, index );
val = fprintf( fp, "#EXTINF:%s,\n%s\n", segment->psz_duration, segment->psz_uri); val = fprintf( fp, "#EXTINF:%s,\n%s\n", segment->psz_duration, segment->psz_uri);
if ( val < 0 ) if ( val < 0 )
{ {
...@@ -483,6 +489,7 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t ...@@ -483,6 +489,7 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
return -1; return -1;
} }
} }
free( psz_current_uri );
if ( b_isend ) if ( b_isend )
{ {
...@@ -728,6 +735,8 @@ static ssize_t openNextFile( sout_access_out_t *p_access, sout_access_out_sys_t ...@@ -728,6 +735,8 @@ static ssize_t openNextFile( sout_access_out_t *p_access, sout_access_out_sys_t
{ {
segment->psz_key_uri = strdup( p_sys->key_uri ); segment->psz_key_uri = strdup( p_sys->key_uri );
CryptKey( p_access, i_newseg ); CryptKey( p_access, i_newseg );
if( p_sys->b_generate_iv )
memcpy( segment->aes_ivs, p_sys->aes_ivs, sizeof(uint8_t)*16 );
} }
msg_Dbg( p_access, "Successfully opened livehttp file: %s (%"PRIu32")" , segment->psz_filename, i_newseg ); msg_Dbg( p_access, "Successfully opened livehttp file: %s (%"PRIu32")" , segment->psz_filename, i_newseg );
......
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