Commit 90c26e78 authored by Laurent Aimar's avatar Laurent Aimar

demux: implementation of demux2_vaControlHelper.

parent 743502eb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* demux.c * demux.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * Copyright (C) 1999-2004 VideoLAN
* $Id: demux.c,v 1.11 2004/01/31 05:25:36 fenrir Exp $ * $Id: demux.c,v 1.12 2004/03/03 12:01:38 fenrir Exp $
* *
* Author: Laurent Aimar <fenrir@via.ecp.fr> * Author: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -266,3 +266,89 @@ void demux2_Delete( demux_t *p_demux ) ...@@ -266,3 +266,89 @@ void demux2_Delete( demux_t *p_demux )
vlc_object_destroy( p_demux ); vlc_object_destroy( p_demux );
} }
/*****************************************************************************
* demux2_vaControlHelper:
*****************************************************************************/
int demux2_vaControlHelper( stream_t *s,
int64_t i_start, int64_t i_end,
int i_bitrate, int i_align,
int i_query, va_list args )
{
int64_t i_tell;
double f, *pf;
int64_t i64, *pi64;
if( i_end < 0 ) i_end = stream_Size( s );
if( i_start < 0 ) i_start = 0;
if( i_align <= 0 ) i_align = 1;
i_tell = stream_Tell( s );
switch( i_query )
{
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( i_bitrate > 0 && i_end > i_start )
{
*pi64 = I64C(8000000) * (i_end - i_start) / i_bitrate;
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( i_bitrate > 0 && i_end > i_start )
{
*pi64 = I64C(8000000) * (i_tell - i_start) / i_bitrate;
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_GET_POSITION:
pf = (double*)va_arg( args, double * );
if( i_start < i_end )
{
*pf = (double)( i_tell - i_start ) /
(double)( i_end - i_start );
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_SET_POSITION:
f = (double)va_arg( args, double );
if( i_start < i_end && f >= 0.0 && f <= 1.0 )
{
int64_t i_block = (f * ( i_end - i_start )) / i_align;
if( stream_Seek( s, i_start + i_block * i_align ) )
{
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_SET_TIME:
i64 = (int64_t)va_arg( args, int64_t );
if( i_bitrate > 0 && i64 >= 0 )
{
int64_t i_block = i64 * i_bitrate / I64C(8000000) / i_align;
if( stream_Seek( s, i_start + i_block * i_align ) )
{
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_GET_FPS:
case DEMUX_GET_META:
return VLC_EGENERIC;
default:
msg_Err( s, "unknown query in demux_vaControlDefault" );
return VLC_EGENERIC;
}
}
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