Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
40310f02
Commit
40310f02
authored
Mar 19, 2004
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* asf :demux -> demux2.
parent
8ac0fe38
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
193 deletions
+142
-193
modules/demux/asf/asf.c
modules/demux/asf/asf.c
+142
-193
No files found.
modules/demux/asf/asf.c
View file @
40310f02
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* asf.c : ASF demux module
* asf.c : ASF demux module
*****************************************************************************
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* Copyright (C) 2002-2003 VideoLAN
* $Id
: asf.c,v 1.51 2004/01/31 05:27:02 fenrir Exp
$
* $Id$
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
...
@@ -42,7 +42,7 @@ static void Close ( vlc_object_t * );
...
@@ -42,7 +42,7 @@ static void Close ( vlc_object_t * );
vlc_module_begin
();
vlc_module_begin
();
set_description
(
_
(
"ASF v1.0 demuxer"
)
);
set_description
(
_
(
"ASF v1.0 demuxer"
)
);
set_capability
(
"demux"
,
200
);
set_capability
(
"demux
2
"
,
200
);
set_callbacks
(
Open
,
Close
);
set_callbacks
(
Open
,
Close
);
add_shortcut
(
"asf"
);
add_shortcut
(
"asf"
);
vlc_module_end
();
vlc_module_end
();
...
@@ -51,10 +51,10 @@ vlc_module_end();
...
@@ -51,10 +51,10 @@ vlc_module_end();
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
static
int
Demux
(
input_thread
_t
*
);
static
int
Demux
(
demux
_t
*
);
static
int
Control
(
input_thread
_t
*
,
int
i_query
,
va_list
args
);
static
int
Control
(
demux
_t
*
,
int
i_query
,
va_list
args
);
typedef
struct
asf_stream_s
typedef
struct
{
{
int
i_cat
;
int
i_cat
;
...
@@ -66,18 +66,19 @@ typedef struct asf_stream_s
...
@@ -66,18 +66,19 @@ typedef struct asf_stream_s
block_t
*
p_frame
;
/* use to gather complete frame */
block_t
*
p_frame
;
/* use to gather complete frame */
}
asf_
stream
_t
;
}
asf_
track
_t
;
struct
demux_sys_t
struct
demux_sys_t
{
{
mtime_t
i_time
;
/* s */
mtime_t
i_time
;
/* s */
mtime_t
i_length
;
/* length of file file */
mtime_t
i_length
;
/* length of file file */
int64_t
i_bitrate
;
/* global file bitrate */
asf_object_root_t
*
p_root
;
asf_object_root_t
*
p_root
;
asf_object_file_properties_t
*
p_fp
;
asf_object_file_properties_t
*
p_fp
;
unsigned
int
i_
streams
;
unsigned
int
i_
track
;
asf_
stream_t
*
stream
[
128
];
asf_
track_t
*
track
[
128
];
int64_t
i_data_begin
;
int64_t
i_data_begin
;
int64_t
i_data_end
;
int64_t
i_data_end
;
...
@@ -86,50 +87,52 @@ struct demux_sys_t
...
@@ -86,50 +87,52 @@ struct demux_sys_t
};
};
static
mtime_t
GetMoviePTS
(
demux_sys_t
*
);
static
mtime_t
GetMoviePTS
(
demux_sys_t
*
);
static
int
DemuxPacket
(
input_thread_t
*
,
vlc_bool_t
b_play_audio
);
static
int
DemuxPacket
(
demux_t
*
);
/*****************************************************************************
/*****************************************************************************
* Open: check file and initializes ASF structures
* Open: check file and initializes ASF structures
*****************************************************************************/
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
uint8_t
*
p_peek
;
uint8_t
*
p_peek
;
guid_t
guid
;
guid_t
guid
;
demux_sys_t
*
p_sys
;
unsigned
int
i_stream
,
i
;
unsigned
int
i_stream
,
i
;
asf_object_content_description_t
*
p_cd
;
asf_object_content_description_t
*
p_cd
;
vlc_bool_t
b_seekable
;
vlc_bool_t
b_seekable
;
/* a little test to see if it could be a asf stream */
/* a little test to see if it could be a asf stream */
if
(
input_Peek
(
p_input
,
&
p_peek
,
16
)
<
16
)
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
16
)
<
16
)
{
{
msg_Warn
(
p_
input
,
"ASF plugin discarded (cannot peek)"
);
msg_Warn
(
p_
demux
,
"ASF plugin discarded (cannot peek)"
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
ASF_GetGUID
(
&
guid
,
p_peek
);
ASF_GetGUID
(
&
guid
,
p_peek
);
if
(
!
ASF_CmpGUID
(
&
guid
,
&
asf_object_header_guid
)
)
if
(
!
ASF_CmpGUID
(
&
guid
,
&
asf_object_header_guid
)
)
{
{
msg_Warn
(
p_
input
,
"ASF plugin discarded (not a valid file)"
);
msg_Warn
(
p_
demux
,
"ASF plugin discarded (not a valid file)"
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
/* Set p_
input field
*/
/* Set p_
demux fields
*/
p_
input
->
pf_demux
=
Demux
;
p_
demux
->
pf_demux
=
Demux
;
p_
input
->
pf_demux
_control
=
Control
;
p_
demux
->
pf
_control
=
Control
;
p_
input
->
p_demux_data
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_
demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
memset
(
p_sys
,
0
,
sizeof
(
demux_sys_t
)
);
memset
(
p_sys
,
0
,
sizeof
(
demux_sys_t
)
);
p_sys
->
i_time
=
-
1
;
p_sys
->
i_time
=
-
1
;
p_sys
->
i_length
=
0
;
p_sys
->
i_length
=
0
;
p_sys
->
i_bitrate
=
0
;
/* Now load all object ( except raw data ) */
/* Now load all object ( except raw data ) */
stream_Control
(
p_
input
->
s
,
STREAM_CAN_FASTSEEK
,
&
b_seekable
);
stream_Control
(
p_
demux
->
s
,
STREAM_CAN_FASTSEEK
,
&
b_seekable
);
if
(
(
p_sys
->
p_root
=
ASF_ReadObjectRoot
(
p_
input
->
s
,
b_seekable
))
==
NULL
)
if
(
(
p_sys
->
p_root
=
ASF_ReadObjectRoot
(
p_
demux
->
s
,
b_seekable
))
==
NULL
)
{
{
msg_Warn
(
p_
input
,
"ASF plugin discarded (not a valid file)"
);
msg_Warn
(
p_
demux
,
"ASF plugin discarded (not a valid file)"
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -137,49 +140,37 @@ static int Open( vlc_object_t * p_this )
...
@@ -137,49 +140,37 @@ static int Open( vlc_object_t * p_this )
if
(
p_sys
->
p_fp
->
i_min_data_packet_size
!=
p_sys
->
p_fp
->
i_max_data_packet_size
)
if
(
p_sys
->
p_fp
->
i_min_data_packet_size
!=
p_sys
->
p_fp
->
i_max_data_packet_size
)
{
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"ASF plugin discarded (invalid file_properties object)"
);
"ASF plugin discarded (invalid file_properties object)"
);
goto
error
;
goto
error
;
}
}
p_sys
->
i_
streams
=
ASF_CountObject
(
p_sys
->
p_root
->
p_hdr
,
p_sys
->
i_
track
=
ASF_CountObject
(
p_sys
->
p_root
->
p_hdr
,
&
asf_object_stream_properties_guid
);
&
asf_object_stream_properties_guid
);
if
(
!
p_sys
->
i_
streams
)
if
(
!
p_sys
->
i_
track
)
{
{
msg_Warn
(
p_
input
,
"ASF plugin discarded (cannot find any stream!)"
);
msg_Warn
(
p_
demux
,
"ASF plugin discarded (cannot find any stream!)"
);
goto
error
;
goto
error
;
}
}
msg_Dbg
(
p_input
,
"found %d streams"
,
p_sys
->
i_streams
);
msg_Dbg
(
p_demux
,
"found %d streams"
,
p_sys
->
i_track
);
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
if
(
input_InitStream
(
p_input
,
0
)
==
-
1
)
{
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
msg_Err
(
p_input
,
"cannot init stream"
);
goto
error
;
}
p_input
->
stream
.
i_mux_rate
=
0
;
/* updated later */
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_
streams
;
i_stream
++
)
for
(
i_stream
=
0
;
i_stream
<
p_sys
->
i_
track
;
i_stream
++
)
{
{
asf_
stream_t
*
p_stream
;
asf_
track_t
*
tk
;
asf_object_stream_properties_t
*
p_sp
;
asf_object_stream_properties_t
*
p_sp
;
p_sp
=
ASF_FindObject
(
p_sys
->
p_root
->
p_hdr
,
p_sp
=
ASF_FindObject
(
p_sys
->
p_root
->
p_hdr
,
&
asf_object_stream_properties_guid
,
&
asf_object_stream_properties_guid
,
i_stream
);
i_stream
);
p_stream
=
tk
=
p_sys
->
track
[
p_sp
->
i_stream_number
]
=
malloc
(
sizeof
(
asf_track_t
)
);
p_sys
->
stream
[
p_sp
->
i_stream_number
]
=
memset
(
tk
,
0
,
sizeof
(
asf_track_t
)
);
malloc
(
sizeof
(
asf_stream_t
)
);
memset
(
p_stream
,
0
,
sizeof
(
asf_stream_t
)
);
p_stream
->
i_time
=
-
1
;
tk
->
i_time
=
-
1
;
p_stream
->
p_sp
=
p_sp
;
tk
->
p_sp
=
p_sp
;
p_stream
->
p_es
=
NULL
;
tk
->
p_es
=
NULL
;
p_stream
->
p_frame
=
NULL
;
tk
->
p_frame
=
NULL
;
if
(
ASF_CmpGUID
(
&
p_sp
->
i_stream_type
,
&
asf_object_stream_type_audio
)
&&
if
(
ASF_CmpGUID
(
&
p_sp
->
i_stream_type
,
&
asf_object_stream_type_audio
)
&&
p_sp
->
i_type_specific_data_length
>=
sizeof
(
WAVEFORMATEX
)
-
2
)
p_sp
->
i_type_specific_data_length
>=
sizeof
(
WAVEFORMATEX
)
-
2
)
...
@@ -203,11 +194,10 @@ static int Open( vlc_object_t * p_this )
...
@@ -203,11 +194,10 @@ static int Open( vlc_object_t * p_this )
memcpy
(
fmt
.
p_extra
,
&
p_data
[
sizeof
(
WAVEFORMATEX
)],
fmt
.
i_extra
);
memcpy
(
fmt
.
p_extra
,
&
p_data
[
sizeof
(
WAVEFORMATEX
)],
fmt
.
i_extra
);
}
}
p_stream
->
i_cat
=
AUDIO_ES
;
tk
->
i_cat
=
AUDIO_ES
;
p_stream
->
p_es
=
es_out_Add
(
p_input
->
p_es_
out
,
&
fmt
);
tk
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
fmt
);
msg_Dbg
(
p_input
,
msg_Dbg
(
p_demux
,
"added new audio stream(codec:0x%x,ID:%d)"
,
"added new audio stream(codec:0x%x,ID:%d)"
,
GetWLE
(
p_data
),
p_sp
->
i_stream_number
);
GetWLE
(
p_data
),
p_sp
->
i_stream_number
);
}
}
else
if
(
ASF_CmpGUID
(
&
p_sp
->
i_stream_type
,
&
asf_object_stream_type_video
)
&&
else
if
(
ASF_CmpGUID
(
&
p_sp
->
i_stream_type
,
&
asf_object_stream_type_video
)
&&
...
@@ -229,16 +219,16 @@ static int Open( vlc_object_t * p_this )
...
@@ -229,16 +219,16 @@ static int Open( vlc_object_t * p_this )
memcpy
(
fmt
.
p_extra
,
&
p_data
[
sizeof
(
BITMAPINFOHEADER
)],
fmt
.
i_extra
);
memcpy
(
fmt
.
p_extra
,
&
p_data
[
sizeof
(
BITMAPINFOHEADER
)],
fmt
.
i_extra
);
}
}
p_stream
->
i_cat
=
VIDEO_ES
;
tk
->
i_cat
=
VIDEO_ES
;
p_stream
->
p_es
=
es_out_Add
(
p_input
->
p_es_
out
,
&
fmt
);
tk
->
p_es
=
es_out_Add
(
p_demux
->
out
,
&
fmt
);
msg_Dbg
(
p_
input
,
"added new video stream(ID:%d)"
,
msg_Dbg
(
p_
demux
,
"added new video stream(ID:%d)"
,
p_sp
->
i_stream_number
);
p_sp
->
i_stream_number
);
}
}
else
else
{
{
p_stream
->
i_cat
=
UNKNOWN_ES
;
tk
->
i_cat
=
UNKNOWN_ES
;
msg_Dbg
(
p_
input
,
"ignoring unknown stream(ID:%d)"
,
msg_Dbg
(
p_
demux
,
"ignoring unknown stream(ID:%d)"
,
p_sp
->
i_stream_number
);
p_sp
->
i_stream_number
);
}
}
}
}
...
@@ -256,13 +246,13 @@ static int Open( vlc_object_t * p_this )
...
@@ -256,13 +246,13 @@ static int Open( vlc_object_t * p_this )
/* go to first packet */
/* go to first packet */
stream_Seek
(
p_
input
->
s
,
p_sys
->
i_data_begin
);
stream_Seek
(
p_
demux
->
s
,
p_sys
->
i_data_begin
);
/* try to calculate movie time */
/* try to calculate movie time */
if
(
p_sys
->
p_fp
->
i_data_packets_count
>
0
)
if
(
p_sys
->
p_fp
->
i_data_packets_count
>
0
)
{
{
int64_t
i_count
;
int64_t
i_count
;
int64_t
i_size
=
stream_Size
(
p_
input
->
s
);
int64_t
i_size
=
stream_Size
(
p_
demux
->
s
);
if
(
p_sys
->
i_data_end
>
0
&&
i_size
>
p_sys
->
i_data_end
)
if
(
p_sys
->
i_data_end
>
0
&&
i_size
>
p_sys
->
i_data_end
)
{
{
...
@@ -280,8 +270,7 @@ static int Open( vlc_object_t * p_this )
...
@@ -280,8 +270,7 @@ static int Open( vlc_object_t * p_this )
if
(
p_sys
->
i_length
>
0
)
if
(
p_sys
->
i_length
>
0
)
{
{
p_input
->
stream
.
i_mux_rate
=
p_sys
->
i_bitrate
=
8
*
i_size
*
(
int64_t
)
1000000
/
p_sys
->
i_length
;
i_size
/
50
*
(
int64_t
)
1000000
/
p_sys
->
i_length
;
}
}
}
}
...
@@ -317,7 +306,7 @@ static int Open( vlc_object_t * p_this )
...
@@ -317,7 +306,7 @@ static int Open( vlc_object_t * p_this )
asf_object_codec_list_t
*
p_cl
=
ASF_FindObject
(
p_sys
->
p_root
->
p_hdr
,
asf_object_codec_list_t
*
p_cl
=
ASF_FindObject
(
p_sys
->
p_root
->
p_hdr
,
&
asf_object_codec_list_guid
,
0
);
&
asf_object_codec_list_guid
,
0
);
if
(
p_sys
->
stream
[
i
]
)
if
(
p_sys
->
track
[
i
]
)
{
{
vlc_meta_t
*
tk
=
vlc_meta_New
();
vlc_meta_t
*
tk
=
vlc_meta_New
();
TAB_APPEND
(
p_sys
->
meta
->
i_track
,
p_sys
->
meta
->
track
,
tk
);
TAB_APPEND
(
p_sys
->
meta
->
i_track
,
p_sys
->
meta
->
track
,
tk
);
...
@@ -343,7 +332,7 @@ static int Open( vlc_object_t * p_this )
...
@@ -343,7 +332,7 @@ static int Open( vlc_object_t * p_this )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
ASF_FreeObjectRoot
(
p_
input
->
s
,
p_sys
->
p_root
);
ASF_FreeObjectRoot
(
p_
demux
->
s
,
p_sys
->
p_root
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -352,49 +341,9 @@ error:
...
@@ -352,49 +341,9 @@ error:
/*****************************************************************************
/*****************************************************************************
* Demux: read packet and send them to decoders
* Demux: read packet and send them to decoders
*****************************************************************************/
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
p_input
)
static
int
Demux
(
demux_t
*
p_demux
)
{
{
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
vlc_bool_t
b_play_audio
;
int
i
;
/* catch seek from user */
if
(
p_input
->
stream
.
p_selected_program
->
i_synchro_state
==
SYNCHRO_REINIT
)
{
int64_t
i_offset
;
msleep
(
p_input
->
i_pts_delay
);
i_offset
=
stream_Tell
(
p_input
->
s
)
-
p_sys
->
i_data_begin
;
if
(
i_offset
<
0
)
{
i_offset
=
0
;
}
if
(
i_offset
%
p_sys
->
p_fp
->
i_min_data_packet_size
>
0
)
{
i_offset
-=
i_offset
%
p_sys
->
p_fp
->
i_min_data_packet_size
;
}
if
(
stream_Seek
(
p_input
->
s
,
i_offset
+
p_sys
->
i_data_begin
)
)
{
msg_Warn
(
p_input
,
"cannot resynch after seek (EOF?)"
);
return
-
1
;
}
p_sys
->
i_time
=
-
1
;
for
(
i
=
0
;
i
<
128
;
i
++
)
{
#define p_stream p_sys->stream[i]
if
(
p_stream
)
{
p_stream
->
i_time
=
-
1
;
}
#undef p_stream
}
}
/* Check if we need to send the audio data to decoder */
b_play_audio
=
!
p_input
->
stream
.
control
.
b_mute
;
for
(
;;
)
for
(
;;
)
{
{
...
@@ -402,12 +351,12 @@ static int Demux( input_thread_t *p_input )
...
@@ -402,12 +351,12 @@ static int Demux( input_thread_t *p_input )
mtime_t
i_time_begin
=
GetMoviePTS
(
p_sys
);
mtime_t
i_time_begin
=
GetMoviePTS
(
p_sys
);
int
i_result
;
int
i_result
;
if
(
p_
input
->
b_die
)
if
(
p_
demux
->
b_die
)
{
{
break
;
break
;
}
}
if
(
(
i_result
=
DemuxPacket
(
p_
input
,
b_play_audio
)
)
<=
0
)
if
(
(
i_result
=
DemuxPacket
(
p_
demux
)
)
<=
0
)
{
{
return
i_result
;
return
i_result
;
}
}
...
@@ -428,12 +377,10 @@ static int Demux( input_thread_t *p_input )
...
@@ -428,12 +377,10 @@ static int Demux( input_thread_t *p_input )
p_sys
->
i_time
=
GetMoviePTS
(
p_sys
);
p_sys
->
i_time
=
GetMoviePTS
(
p_sys
);
if
(
p_sys
->
i_time
>=
0
)
if
(
p_sys
->
i_time
>=
0
)
{
{
input_ClockManageRef
(
p_input
,
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_sys
->
i_time
);
p_input
->
stream
.
p_selected_program
,
p_sys
->
i_time
*
9
/
100
);
}
}
return
(
1
)
;
return
1
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -441,26 +388,26 @@ static int Demux( input_thread_t *p_input )
...
@@ -441,26 +388,26 @@ static int Demux( input_thread_t *p_input )
*****************************************************************************/
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
{
input_thread_t
*
p_input
=
(
input_thread
_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux
_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_stream
;
int
i
;
msg_Dbg
(
p_
input
,
"freeing all memory"
);
msg_Dbg
(
p_
demux
,
"freeing all memory"
);
vlc_meta_Delete
(
p_sys
->
meta
);
vlc_meta_Delete
(
p_sys
->
meta
);
ASF_FreeObjectRoot
(
p_
input
->
s
,
p_sys
->
p_root
);
ASF_FreeObjectRoot
(
p_
demux
->
s
,
p_sys
->
p_root
);
for
(
i
_stream
=
0
;
i_stream
<
128
;
i_stream
++
)
for
(
i
=
0
;
i
<
128
;
i
++
)
{
{
asf_
stream_t
*
p_stream
=
p_sys
->
stream
[
i_stream
];
asf_
track_t
*
tk
=
p_sys
->
track
[
i
];
if
(
p_stream
)
if
(
tk
)
{
{
if
(
p_stream
->
p_frame
)
if
(
tk
->
p_frame
)
{
{
block_ChainRelease
(
p_stream
->
p_frame
);
block_ChainRelease
(
tk
->
p_frame
);
}
}
free
(
p_stream
);
free
(
tk
);
}
}
}
}
free
(
p_sys
);
free
(
p_sys
);
...
@@ -469,10 +416,11 @@ static void Close( vlc_object_t * p_this )
...
@@ -469,10 +416,11 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
/*****************************************************************************
* Control:
* Control:
*****************************************************************************/
*****************************************************************************/
static
int
Control
(
input_thread_t
*
p_input
,
int
i_query
,
va_list
args
)
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int64_t
*
pi64
;
int64_t
*
pi64
;
int
i
;
vlc_meta_t
**
pp_meta
;
vlc_meta_t
**
pp_meta
;
switch
(
i_query
)
switch
(
i_query
)
...
@@ -487,8 +435,20 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
...
@@ -487,8 +435,20 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
*
pp_meta
=
vlc_meta_Duplicate
(
p_sys
->
meta
);
*
pp_meta
=
vlc_meta_Duplicate
(
p_sys
->
meta
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
case
DEMUX_SET_POSITION
:
case
DEMUX_SET_TIME
:
p_sys
->
i_time
=
-
1
;
for
(
i
=
0
;
i
<
128
;
i
++
)
{
asf_track_t
*
tk
=
p_sys
->
track
[
i
];
if
(
tk
)
tk
->
i_time
=
-
1
;
}
default:
default:
return
demux_vaControlDefault
(
p_input
,
i_query
,
args
);
return
demux2_vaControlHelper
(
p_demux
->
s
,
p_sys
->
i_data_begin
,
p_sys
->
i_data_end
,
p_sys
->
i_bitrate
,
p_sys
->
p_fp
->
i_min_data_packet_size
,
i_query
,
args
);
}
}
}
}
...
@@ -498,27 +458,27 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
...
@@ -498,27 +458,27 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
static
mtime_t
GetMoviePTS
(
demux_sys_t
*
p_sys
)
static
mtime_t
GetMoviePTS
(
demux_sys_t
*
p_sys
)
{
{
mtime_t
i_time
;
mtime_t
i_time
;
int
i
_stream
;
int
i
;
i_time
=
-
1
;
i_time
=
-
1
;
for
(
i
_stream
=
0
;
i_stream
<
128
;
i_stream
++
)
for
(
i
=
0
;
i
<
128
;
i
++
)
{
{
asf_
stream_t
*
p_stream
=
p_sys
->
stream
[
i_stream
];
asf_
track_t
*
tk
=
p_sys
->
track
[
i
];
if
(
p_stream
&&
p_stream
->
p_es
&&
p_stream
->
i_time
>
0
)
if
(
tk
&&
tk
->
p_es
&&
tk
->
i_time
>
0
)
{
{
if
(
i_time
<
0
)
if
(
i_time
<
0
)
{
{
i_time
=
p_stream
->
i_time
;
i_time
=
tk
->
i_time
;
}
}
else
else
{
{
i_time
=
__MIN
(
i_time
,
p_stream
->
i_time
);
i_time
=
__MIN
(
i_time
,
tk
->
i_time
);
}
}
}
}
}
}
return
(
i_time
)
;
return
i_time
;
}
}
#define GETVALUE2b( bits, var, def ) \
#define GETVALUE2b( bits, var, def ) \
...
@@ -531,9 +491,9 @@ static mtime_t GetMoviePTS( demux_sys_t *p_sys )
...
@@ -531,9 +491,9 @@ static mtime_t GetMoviePTS( demux_sys_t *p_sys )
default: var = def; break;\
default: var = def; break;\
}
}
static
int
DemuxPacket
(
input_thread_t
*
p_input
,
vlc_bool_t
b_play_audio
)
static
int
DemuxPacket
(
demux_t
*
p_demux
)
{
{
demux_sys_t
*
p_sys
=
p_
input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_
demux
->
p_sys
;
int
i_data_packet_min
=
p_sys
->
p_fp
->
i_min_data_packet_size
;
int
i_data_packet_min
=
p_sys
->
p_fp
->
i_min_data_packet_size
;
uint8_t
*
p_peek
;
uint8_t
*
p_peek
;
int
i_skip
;
int
i_skip
;
...
@@ -554,11 +514,10 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -554,11 +514,10 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
int
i_payload_length_type
;
int
i_payload_length_type
;
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
i_data_packet_min
)
<
i_data_packet_min
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
i_data_packet_min
)
<
i_data_packet_min
)
{
{
// EOF ?
msg_Warn
(
p_demux
,
"cannot peek while getting new packet, EOF ?"
);
msg_Warn
(
p_input
,
"cannot peek while getting new packet, EOF ?"
);
return
0
;
return
(
0
);
}
}
i_skip
=
0
;
i_skip
=
0
;
...
@@ -585,7 +544,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -585,7 +544,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
}
}
else
else
{
{
msg_Warn
(
p_
input
,
"p_peek[0]&0x80 != 0x80"
);
msg_Warn
(
p_
demux
,
"p_peek[0]&0x80 != 0x80"
);
}
}
/* sanity check */
/* sanity check */
...
@@ -625,7 +584,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -625,7 +584,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
for
(
i_payload
=
0
;
i_payload
<
i_payload_count
;
i_payload
++
)
for
(
i_payload
=
0
;
i_payload
<
i_payload_count
;
i_payload
++
)
{
{
asf_
stream_t
*
p_stream
;
asf_
track_t
*
tk
;
int
i_stream_number
;
int
i_stream_number
;
int
i_media_object_number
;
int
i_media_object_number
;
...
@@ -668,7 +627,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -668,7 +627,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
else
if
(
i_replicated_data_length
==
1
)
else
if
(
i_replicated_data_length
==
1
)
{
{
msg_Dbg
(
p_
input
,
"found compressed payload"
);
msg_Dbg
(
p_
demux
,
"found compressed payload"
);
i_pts
=
(
mtime_t
)
i_tmp
*
1000
;
i_pts
=
(
mtime_t
)
i_tmp
*
1000
;
i_pts_delta
=
(
mtime_t
)
p_peek
[
i_skip
]
*
1000
;
i_skip
++
;
i_pts_delta
=
(
mtime_t
)
p_peek
[
i_skip
]
*
1000
;
i_skip
++
;
...
@@ -698,28 +657,22 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -698,28 +657,22 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
{
{
break
;
break
;
}
}
#if 0
#if 0
msg_Dbg( p_
input
,
msg_Dbg( p_
demux
,
"payload(%d/%d) stream_number:%d media_object_number:%d media_object_offset:%d replicated_data_length:%d payload_data_length %d",
"payload(%d/%d) stream_number:%d media_object_number:%d media_object_offset:%d replicated_data_length:%d payload_data_length %d",
i_payload + 1,
i_payload + 1, i_payload_count, i_stream_number, i_media_object_number,
i_payload_count,
i_media_object_offset, i_replicated_data_length, i_payload_data_length );
i_stream_number,
i_media_object_number,
i_media_object_offset,
i_replicated_data_length,
i_payload_data_length );
#endif
#endif
if
(
!
(
p_stream
=
p_sys
->
stream
[
i_stream_number
]
)
)
if
(
(
tk
=
p_sys
->
track
[
i_stream_number
]
)
==
NULL
)
{
{
msg_Warn
(
p_
input
,
msg_Warn
(
p_
demux
,
"undeclared stream[Id 0x%x]"
,
i_stream_number
);
"undeclared stream[Id 0x%x]"
,
i_stream_number
);
i_skip
+=
i_payload_data_length
;
i_skip
+=
i_payload_data_length
;
continue
;
// over payload
continue
;
// over payload
}
}
if
(
!
p_stream
->
p_es
)
if
(
!
tk
->
p_es
)
{
{
i_skip
+=
i_payload_data_length
;
i_skip
+=
i_payload_data_length
;
continue
;
continue
;
...
@@ -746,38 +699,35 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -746,38 +699,35 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
}
}
/* FIXME I don't use i_media_object_number, sould I ? */
/* FIXME I don't use i_media_object_number, sould I ? */
if
(
p_stream
->
p_frame
&&
i_media_object_offset
==
0
)
if
(
tk
->
p_frame
&&
i_media_object_offset
==
0
)
{
{
/* send complete packet to decoder */
/* send complete packet to decoder */
block_t
*
p_gather
=
block_ChainGather
(
p_stream
->
p_frame
);
block_t
*
p_gather
=
block_ChainGather
(
tk
->
p_frame
);
es_out_Send
(
p_
input
->
p_es_out
,
p_stream
->
p_es
,
p_gather
);
es_out_Send
(
p_
demux
->
out
,
tk
->
p_es
,
p_gather
);
p_stream
->
p_frame
=
NULL
;
tk
->
p_frame
=
NULL
;
}
}
i_read
=
i_sub_payload_data_length
+
i_skip
;
i_read
=
i_sub_payload_data_length
+
i_skip
;
if
(
(
p_frag
=
stream_Block
(
p_
input
->
s
,
i_read
)
)
==
NULL
)
if
(
(
p_frag
=
stream_Block
(
p_
demux
->
s
,
i_read
)
)
==
NULL
)
{
{
msg_Warn
(
p_
input
,
"cannot read data"
);
msg_Warn
(
p_
demux
,
"cannot read data"
);
return
(
0
)
;
return
0
;
}
}
i_packet_size_left
-=
i_read
;
i_packet_size_left
-=
i_read
;
p_frag
->
p_buffer
+=
i_skip
;
p_frag
->
p_buffer
+=
i_skip
;
p_frag
->
i_buffer
-=
i_skip
;
p_frag
->
i_buffer
-=
i_skip
;
if
(
p_stream
->
p_frame
==
NULL
)
if
(
tk
->
p_frame
==
NULL
)
{
{
p_stream
->
i_time
=
tk
->
i_time
=
(
(
mtime_t
)
i_pts
+
i_payload
*
(
mtime_t
)
i_pts_delta
);
(
(
mtime_t
)
i_pts
+
i_payload
*
(
mtime_t
)
i_pts_delta
);
p_frag
->
i_pts
=
p_frag
->
i_pts
=
tk
->
i_time
;
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
p_stream
->
i_time
*
9
/
100
);
if
(
p_stream
->
i_cat
!=
VIDEO_ES
)
if
(
tk
->
i_cat
!=
VIDEO_ES
)
p_frag
->
i_dts
=
p_frag
->
i_pts
;
p_frag
->
i_dts
=
p_frag
->
i_pts
;
else
else
{
{
...
@@ -786,17 +736,16 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -786,17 +736,16 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
}
}
}
}
block_ChainAppend
(
&
p_stream
->
p_frame
,
p_frag
);
block_ChainAppend
(
&
tk
->
p_frame
,
p_frag
);
i_skip
=
0
;
i_skip
=
0
;
if
(
i_packet_size_left
>
0
)
if
(
i_packet_size_left
>
0
)
{
{
if
(
stream_Peek
(
p_
input
->
s
,
&
p_peek
,
i_packet_size_left
)
if
(
stream_Peek
(
p_
demux
->
s
,
&
p_peek
,
i_packet_size_left
)
<
i_packet_size_left
)
<
i_packet_size_left
)
{
{
// EOF ?
msg_Warn
(
p_demux
,
"cannot peek, EOF ?"
);
msg_Warn
(
p_input
,
"cannot peek, EOF ?"
);
return
0
;
return
(
0
);
}
}
}
}
}
}
...
@@ -804,26 +753,26 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
...
@@ -804,26 +753,26 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
if
(
i_packet_size_left
>
0
)
if
(
i_packet_size_left
>
0
)
{
{
if
(
stream_Read
(
p_
input
->
s
,
NULL
,
i_packet_size_left
)
if
(
stream_Read
(
p_
demux
->
s
,
NULL
,
i_packet_size_left
)
<
i_packet_size_left
)
<
i_packet_size_left
)
{
{
msg_Warn
(
p_
input
,
"cannot skip data, EOF ?"
);
msg_Warn
(
p_
demux
,
"cannot skip data, EOF ?"
);
return
(
0
)
;
return
0
;
}
}
}
}
return
(
1
)
;
return
1
;
loop_error_recovery:
loop_error_recovery:
msg_Warn
(
p_
input
,
"unsupported packet header"
);
msg_Warn
(
p_
demux
,
"unsupported packet header"
);
if
(
p_sys
->
p_fp
->
i_min_data_packet_size
!=
p_sys
->
p_fp
->
i_max_data_packet_size
)
if
(
p_sys
->
p_fp
->
i_min_data_packet_size
!=
p_sys
->
p_fp
->
i_max_data_packet_size
)
{
{
msg_Err
(
p_
input
,
"unsupported packet header, fatal error"
);
msg_Err
(
p_
demux
,
"unsupported packet header, fatal error"
);
return
(
-
1
)
;
return
-
1
;
}
}
stream_Read
(
p_
input
->
s
,
NULL
,
i_data_packet_min
);
stream_Read
(
p_
demux
->
s
,
NULL
,
i_data_packet_min
);
return
(
1
)
;
return
1
;
}
}
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