Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
90c26e78
Commit
90c26e78
authored
Mar 03, 2004
by
Laurent Aimar
Browse files
demux: implementation of demux2_vaControlHelper.
parent
743502eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/input/demux.c
View file @
90c26e78
...
...
@@ -2,7 +2,7 @@
* demux.c
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
* $Id: demux.c,v 1.1
1
2004/0
1/31 05:25
:3
6
fenrir Exp $
* $Id: demux.c,v 1.1
2
2004/0
3/03 12:01
:3
8
fenrir Exp $
*
* Author: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -266,3 +266,89 @@ void demux2_Delete( demux_t *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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment