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
fe574e12
Commit
fe574e12
authored
Aug 26, 2003
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* mkv : use stream_*
parent
d1ff1b96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
154 deletions
+103
-154
modules/demux/mkv.cpp
modules/demux/mkv.cpp
+103
-154
No files found.
modules/demux/mkv.cpp
View file @
fe574e12
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
* mkv.cpp : matroska demuxer
*****************************************************************************
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.2
3 2003/08/25 20:47:41
fenrir Exp $
* $Id: mkv.cpp,v 1.2
4 2003/08/26 18:11:02
fenrir Exp $
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <codecs.h>
/* BITMAPINFOHEADER, WAVEFORMATEX */
#include <codecs.h>
/* BITMAPINFOHEADER, WAVEFORMATEX */
#include "iso_lang.h"
#include "iso_lang.h"
#include "ninput.h"
#include <iostream>
#include <iostream>
#include <cassert>
#include <cassert>
...
@@ -84,17 +85,12 @@
...
@@ -84,17 +85,12 @@
using
namespace
LIBMATROSKA_NAMESPACE
;
using
namespace
LIBMATROSKA_NAMESPACE
;
using
namespace
std
;
using
namespace
std
;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Activate
(
vlc_object_t
*
);
static
void
Deactivate
(
vlc_object_t
*
);
static
int
Demux
(
input_thread_t
*
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
vlc_module_begin
();
vlc_module_begin
();
add_category_hint
(
N_
(
"mkv-demuxer"
),
NULL
,
VLC_TRUE
);
add_category_hint
(
N_
(
"mkv-demuxer"
),
NULL
,
VLC_TRUE
);
add_bool
(
"mkv-seek-percent"
,
1
,
NULL
,
add_bool
(
"mkv-seek-percent"
,
1
,
NULL
,
...
@@ -103,11 +99,17 @@ vlc_module_begin();
...
@@ -103,11 +99,17 @@ vlc_module_begin();
set_description
(
_
(
"mka/mkv stream demuxer"
)
);
set_description
(
_
(
"mka/mkv stream demuxer"
)
);
set_capability
(
"demux"
,
50
);
set_capability
(
"demux"
,
50
);
set_callbacks
(
Activate
,
Deactivat
e
);
set_callbacks
(
Open
,
Clos
e
);
add_shortcut
(
"mka"
);
add_shortcut
(
"mka"
);
add_shortcut
(
"mkv"
);
add_shortcut
(
"mkv"
);
vlc_module_end
();
vlc_module_end
();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
input_thread_t
*
);
static
void
Seek
(
input_thread_t
*
,
mtime_t
i_date
,
int
i_percent
);
/*****************************************************************************
/*****************************************************************************
* Stream managment
* Stream managment
...
@@ -115,11 +117,11 @@ vlc_module_end();
...
@@ -115,11 +117,11 @@ vlc_module_end();
class
vlc_stream_io_callback
:
public
IOCallback
class
vlc_stream_io_callback
:
public
IOCallback
{
{
private:
private:
input_thread_t
*
p_input
;
stream_t
*
s
;
vlc_bool_t
mb_eof
;
vlc_bool_t
mb_eof
;
public:
public:
vlc_stream_io_callback
(
input_thread
_t
*
);
vlc_stream_io_callback
(
stream
_t
*
);
virtual
uint32_t
read
(
void
*
p_buffer
,
size_t
i_size
);
virtual
uint32_t
read
(
void
*
p_buffer
,
size_t
i_size
);
virtual
void
setFilePointer
(
int64_t
i_offset
,
seek_mode
mode
=
seek_beginning
);
virtual
void
setFilePointer
(
int64_t
i_offset
,
seek_mode
mode
=
seek_beginning
);
...
@@ -232,6 +234,8 @@ typedef struct
...
@@ -232,6 +234,8 @@ typedef struct
struct
demux_sys_t
struct
demux_sys_t
{
{
stream_t
*
s
;
vlc_stream_io_callback
*
in
;
vlc_stream_io_callback
*
in
;
EbmlStream
*
es
;
EbmlStream
*
es
;
EbmlParser
*
ep
;
EbmlParser
*
ep
;
...
@@ -280,9 +284,9 @@ static void InformationsCreate ( input_thread_t *p_input );
...
@@ -280,9 +284,9 @@ static void InformationsCreate ( input_thread_t *p_input );
static
char
*
LanguageGetName
(
const
char
*
psz_code
);
static
char
*
LanguageGetName
(
const
char
*
psz_code
);
/*****************************************************************************
/*****************************************************************************
*
Activate
: initializes matroska demux structures
*
Open
: initializes matroska demux structures
*****************************************************************************/
*****************************************************************************/
static
int
Activate
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
demux_sys_t
*
p_sys
;
...
@@ -294,14 +298,6 @@ static int Activate( vlc_object_t * p_this )
...
@@ -294,14 +298,6 @@ static int Activate( vlc_object_t * p_this )
EbmlElement
*
el
=
NULL
,
*
el1
=
NULL
,
*
el2
=
NULL
,
*
el3
=
NULL
,
*
el4
=
NULL
;
EbmlElement
*
el
=
NULL
,
*
el1
=
NULL
,
*
el2
=
NULL
,
*
el3
=
NULL
,
*
el4
=
NULL
;
/* Initialize access plug-in structures. */
if
(
p_input
->
i_mtu
==
0
)
{
/* Improve speed. */
p_input
->
i_bufsize
=
INPUT_DEFAULT_BUFSIZE
;
}
/* Set the demux function */
/* Set the demux function */
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux
=
Demux
;
...
@@ -313,7 +309,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -313,7 +309,8 @@ static int Activate( vlc_object_t * p_this )
}
}
/* is a valid file */
/* is a valid file */
if
(
p_peek
[
0
]
!=
0x1a
||
p_peek
[
1
]
!=
0x45
||
p_peek
[
2
]
!=
0xdf
||
p_peek
[
3
]
!=
0xa3
)
if
(
p_peek
[
0
]
!=
0x1a
||
p_peek
[
1
]
!=
0x45
||
p_peek
[
2
]
!=
0xdf
||
p_peek
[
3
]
!=
0xa3
)
{
{
msg_Warn
(
p_input
,
"matroska module discarded "
msg_Warn
(
p_input
,
"matroska module discarded "
"(invalid header 0x%.2x%.2x%.2x%.2x)"
,
"(invalid header 0x%.2x%.2x%.2x%.2x)"
,
...
@@ -321,10 +318,16 @@ static int Activate( vlc_object_t * p_this )
...
@@ -321,10 +318,16 @@ static int Activate( vlc_object_t * p_this )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_input
->
p_demux_data
=
p_sys
=
(
demux_sys_t
*
)
malloc
(
sizeof
(
demux_sys_t
)
);
p_input
->
p_demux_data
=
p_sys
=
(
demux_sys_t
*
)
malloc
(
sizeof
(
demux_sys_t
)
);
memset
(
p_sys
,
0
,
sizeof
(
demux_sys_t
)
);
memset
(
p_sys
,
0
,
sizeof
(
demux_sys_t
)
);
p_sys
->
in
=
new
vlc_stream_io_callback
(
p_input
);
if
(
(
p_sys
->
s
=
stream_OpenInput
(
p_input
)
)
==
NULL
)
{
msg_Err
(
p_input
,
"cannot create stream"
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
p_sys
->
in
=
new
vlc_stream_io_callback
(
p_sys
->
s
);
p_sys
->
es
=
new
EbmlStream
(
*
p_sys
->
in
);
p_sys
->
es
=
new
EbmlStream
(
*
p_sys
->
in
);
p_sys
->
f_duration
=
-
1
;
p_sys
->
f_duration
=
-
1
;
p_sys
->
i_timescale
=
MKVD_TIMECODESCALE
;
p_sys
->
i_timescale
=
MKVD_TIMECODESCALE
;
...
@@ -338,7 +341,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -338,7 +341,8 @@ static int Activate( vlc_object_t * p_this )
p_sys
->
b_cues
=
VLC_FALSE
;
p_sys
->
b_cues
=
VLC_FALSE
;
p_sys
->
i_index
=
0
;
p_sys
->
i_index
=
0
;
p_sys
->
i_index_max
=
1024
;
p_sys
->
i_index_max
=
1024
;
p_sys
->
index
=
(
mkv_index_t
*
)
malloc
(
sizeof
(
mkv_index_t
)
*
p_sys
->
i_index_max
);
p_sys
->
index
=
(
mkv_index_t
*
)
malloc
(
sizeof
(
mkv_index_t
)
*
p_sys
->
i_index_max
);
p_sys
->
psz_muxing_application
=
NULL
;
p_sys
->
psz_muxing_application
=
NULL
;
p_sys
->
psz_writing_application
=
NULL
;
p_sys
->
psz_writing_application
=
NULL
;
...
@@ -350,6 +354,7 @@ static int Activate( vlc_object_t * p_this )
...
@@ -350,6 +354,7 @@ static int Activate( vlc_object_t * p_this )
{
{
msg_Err
(
p_input
,
"failed to create EbmlStream"
);
msg_Err
(
p_input
,
"failed to create EbmlStream"
);
delete
p_sys
->
in
;
delete
p_sys
->
in
;
stream_Release
(
p_sys
->
s
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -404,7 +409,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -404,7 +409,8 @@ static int Activate( vlc_object_t * p_this )
dur
.
ReadData
(
p_sys
->
es
->
I_O
()
);
dur
.
ReadData
(
p_sys
->
es
->
I_O
()
);
p_sys
->
f_duration
=
float
(
dur
);
p_sys
->
f_duration
=
float
(
dur
);
msg_Dbg
(
p_input
,
"| | + Duration=%f"
,
p_sys
->
f_duration
);
msg_Dbg
(
p_input
,
"| | + Duration=%f"
,
p_sys
->
f_duration
);
}
}
else
if
(
EbmlId
(
*
el2
)
==
KaxMuxingApp
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el2
)
==
KaxMuxingApp
::
ClassInfos
.
GlobalId
)
{
{
...
@@ -414,7 +420,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -414,7 +420,8 @@ static int Activate( vlc_object_t * p_this )
p_sys
->
psz_muxing_application
=
UTF8ToStr
(
UTFstring
(
mapp
)
);
p_sys
->
psz_muxing_application
=
UTF8ToStr
(
UTFstring
(
mapp
)
);
msg_Dbg
(
p_input
,
"| | + Muxing Application=%s"
,
p_sys
->
psz_muxing_application
);
msg_Dbg
(
p_input
,
"| | + Muxing Application=%s"
,
p_sys
->
psz_muxing_application
);
}
}
else
if
(
EbmlId
(
*
el2
)
==
KaxWritingApp
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el2
)
==
KaxWritingApp
::
ClassInfos
.
GlobalId
)
{
{
...
@@ -424,7 +431,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -424,7 +431,8 @@ static int Activate( vlc_object_t * p_this )
p_sys
->
psz_writing_application
=
UTF8ToStr
(
UTFstring
(
wapp
)
);
p_sys
->
psz_writing_application
=
UTF8ToStr
(
UTFstring
(
wapp
)
);
msg_Dbg
(
p_input
,
"| | + Wrinting Application=%s"
,
p_sys
->
psz_writing_application
);
msg_Dbg
(
p_input
,
"| | + Wrinting Application=%s"
,
p_sys
->
psz_writing_application
);
}
}
else
if
(
EbmlId
(
*
el2
)
==
KaxSegmentFilename
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el2
)
==
KaxSegmentFilename
::
ClassInfos
.
GlobalId
)
{
{
...
@@ -434,7 +442,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -434,7 +442,8 @@ static int Activate( vlc_object_t * p_this )
p_sys
->
psz_segment_filename
=
UTF8ToStr
(
UTFstring
(
sfn
)
);
p_sys
->
psz_segment_filename
=
UTF8ToStr
(
UTFstring
(
sfn
)
);
msg_Dbg
(
p_input
,
"| | + Segment Filename=%s"
,
p_sys
->
psz_segment_filename
);
msg_Dbg
(
p_input
,
"| | + Segment Filename=%s"
,
p_sys
->
psz_segment_filename
);
}
}
else
if
(
EbmlId
(
*
el2
)
==
KaxTitle
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el2
)
==
KaxTitle
::
ClassInfos
.
GlobalId
)
{
{
...
@@ -521,14 +530,16 @@ static int Activate( vlc_object_t * p_this )
...
@@ -521,14 +530,16 @@ static int Activate( vlc_object_t * p_this )
tnum
.
ReadData
(
p_sys
->
es
->
I_O
()
);
tnum
.
ReadData
(
p_sys
->
es
->
I_O
()
);
tk
.
i_number
=
uint32
(
tnum
);
tk
.
i_number
=
uint32
(
tnum
);
msg_Dbg
(
p_input
,
"| | | + Track Number=%u"
,
uint32
(
tnum
)
);
msg_Dbg
(
p_input
,
"| | | + Track Number=%u"
,
uint32
(
tnum
)
);
}
}
else
if
(
EbmlId
(
*
el3
)
==
KaxTrackUID
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el3
)
==
KaxTrackUID
::
ClassInfos
.
GlobalId
)
{
{
KaxTrackUID
&
tuid
=
*
(
KaxTrackUID
*
)
el3
;
KaxTrackUID
&
tuid
=
*
(
KaxTrackUID
*
)
el3
;
tuid
.
ReadData
(
p_sys
->
es
->
I_O
()
);
tuid
.
ReadData
(
p_sys
->
es
->
I_O
()
);
msg_Dbg
(
p_input
,
"| | | + Track UID=%u"
,
uint32
(
tuid
)
);
msg_Dbg
(
p_input
,
"| | | + Track UID=%u"
,
uint32
(
tuid
)
);
}
}
else
if
(
EbmlId
(
*
el3
)
==
KaxTrackType
::
ClassInfos
.
GlobalId
)
else
if
(
EbmlId
(
*
el3
)
==
KaxTrackType
::
ClassInfos
.
GlobalId
)
{
{
...
@@ -844,14 +855,16 @@ static int Activate( vlc_object_t * p_this )
...
@@ -844,14 +855,16 @@ static int Activate( vlc_object_t * p_this )
}
}
else
else
{
{
msg_Dbg
(
p_input
,
"| | | + Unknown (%s)"
,
typeid
(
*
el3
).
name
()
);
msg_Dbg
(
p_input
,
"| | | + Unknown (%s)"
,
typeid
(
*
el3
).
name
()
);
}
}
}
}
p_sys
->
ep
->
Up
();
p_sys
->
ep
->
Up
();
}
}
else
else
{
{
msg_Dbg
(
p_input
,
"| | + Unknown (%s)"
,
typeid
(
*
el2
).
name
()
);
msg_Dbg
(
p_input
,
"| | + Unknown (%s)"
,
typeid
(
*
el2
).
name
()
);
}
}
#undef tk
#undef tk
}
}
...
@@ -890,7 +903,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -890,7 +903,8 @@ static int Activate( vlc_object_t * p_this )
}
}
else
else
{
{
msg_Dbg
(
p_input
,
"| | | + Unknown (%s)"
,
typeid
(
*
el
).
name
()
);
msg_Dbg
(
p_input
,
"| | | + Unknown (%s)"
,
typeid
(
*
el
).
name
()
);
}
}
}
}
p_sys
->
ep
->
Up
();
p_sys
->
ep
->
Up
();
...
@@ -899,17 +913,20 @@ static int Activate( vlc_object_t * p_this )
...
@@ -899,17 +913,20 @@ static int Activate( vlc_object_t * p_this )
{
{
if
(
id
==
KaxCues
::
ClassInfos
.
GlobalId
)
if
(
id
==
KaxCues
::
ClassInfos
.
GlobalId
)
{
{
msg_Dbg
(
p_input
,
"| | | = cues at "
I64Fd
,
i_pos
);
msg_Dbg
(
p_input
,
"| | | = cues at "
I64Fd
,
i_pos
);
p_sys
->
i_cues_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
p_sys
->
i_cues_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
}
}
else
if
(
id
==
KaxChapters
::
ClassInfos
.
GlobalId
)
else
if
(
id
==
KaxChapters
::
ClassInfos
.
GlobalId
)
{
{
msg_Dbg
(
p_input
,
"| | | = chapters at "
I64Fd
,
i_pos
);
msg_Dbg
(
p_input
,
"| | | = chapters at "
I64Fd
,
i_pos
);
p_sys
->
i_chapters_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
p_sys
->
i_chapters_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
}
}
else
if
(
id
==
KaxTags
::
ClassInfos
.
GlobalId
)
else
if
(
id
==
KaxTags
::
ClassInfos
.
GlobalId
)
{
{
msg_Dbg
(
p_input
,
"| | | = tags at "
I64Fd
,
i_pos
);
msg_Dbg
(
p_input
,
"| | | = tags at "
I64Fd
,
i_pos
);
p_sys
->
i_tags_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
p_sys
->
i_tags_position
=
p_sys
->
segment
->
GetGlobalPosition
(
i_pos
);
}
}
...
@@ -917,7 +934,8 @@ static int Activate( vlc_object_t * p_this )
...
@@ -917,7 +934,8 @@ static int Activate( vlc_object_t * p_this )
}
}
else
else
{
{
msg_Dbg
(
p_input
,
"| | + Unknown (%s)"
,
typeid
(
*
el
).
name
()
);
msg_Dbg
(
p_input
,
"| | + Unknown (%s)"
,
typeid
(
*
el
).
name
()
);
}
}
}
}
p_sys
->
ep
->
Up
();
p_sys
->
ep
->
Up
();
...
@@ -970,14 +988,20 @@ static int Activate( vlc_object_t * p_this )
...
@@ -970,14 +988,20 @@ static int Activate( vlc_object_t * p_this )
}
}
/* *** Load the cue if found *** */
/* *** Load the cue if found *** */
if
(
p_sys
->
i_cues_position
>=
0
&&
p_input
->
stream
.
b_seekable
)
if
(
p_sys
->
i_cues_position
>=
0
)
{
{
LoadCues
(
p_input
);
vlc_bool_t
b_seekable
;
stream_Control
(
p_sys
->
s
,
STREAM_CAN_FASTSEEK
,
&
b_seekable
);
if
(
b_seekable
)
{
LoadCues
(
p_input
);
}
}
}
if
(
!
p_sys
->
b_cues
||
p_sys
->
i_index
<=
0
)
if
(
!
p_sys
->
b_cues
||
p_sys
->
i_index
<=
0
)
{
{
msg_Warn
(
p_input
,
"no cues/empty cues found
->
seek won't be precise"
);
msg_Warn
(
p_input
,
"no cues/empty cues found
->
seek won't be precise"
);
IndexAppendCluster
(
p_input
,
p_sys
->
cluster
);
IndexAppendCluster
(
p_input
,
p_sys
->
cluster
);
...
@@ -999,16 +1023,14 @@ static int Activate( vlc_object_t * p_this )
...
@@ -999,16 +1023,14 @@ static int Activate( vlc_object_t * p_this )
goto
error
;
goto
error
;
}
}
p_input
->
stream
.
p_selected_program
=
p_input
->
stream
.
pp_programs
[
0
];
p_input
->
stream
.
p_selected_program
=
p_input
->
stream
.
pp_programs
[
0
];
p_input
->
stream
.
i_mux_rate
=
0
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
if
(
p_sys
->
f_duration
>
1001.0
)
if
(
p_sys
->
f_duration
>
1001.0
)
{
{
mtime_t
i_duration
=
(
mtime_t
)(
p_sys
->
f_duration
/
1000.0
);
mtime_t
i_duration
=
(
mtime_t
)(
p_sys
->
f_duration
/
1000.0
);
p_input
->
stream
.
i_mux_rate
=
p_input
->
stream
.
p_selected_area
->
i_size
/
50
/
i_duration
;
p_input
->
stream
.
i_mux_rate
=
stream_Size
(
p_sys
->
s
)
/
50
/
i_duration
;
}
}
else
{
p_input
->
stream
.
i_mux_rate
=
0
;
}
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
/* add all es */
/* add all es */
msg_Dbg
(
p_input
,
"found %d es"
,
p_sys
->
i_track
);
msg_Dbg
(
p_input
,
"found %d es"
,
p_sys
->
i_track
);
...
@@ -1289,14 +1311,15 @@ static int Activate( vlc_object_t * p_this )
...
@@ -1289,14 +1311,15 @@ static int Activate( vlc_object_t * p_this )
error:
error:
delete
p_sys
->
es
;
delete
p_sys
->
es
;
delete
p_sys
->
in
;
delete
p_sys
->
in
;
stream_Release
(
p_sys
->
s
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
/*****************************************************************************
/*****************************************************************************
*
Deactivat
e: frees unused data
*
Clos
e: frees unused data
*****************************************************************************/
*****************************************************************************/
static
void
Deactivat
e
(
vlc_object_t
*
p_this
)
static
void
Clos
e
(
vlc_object_t
*
p_this
)
{
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
demux_sys_t
*
p_sys
=
p_input
->
p_demux_data
;
...
@@ -1332,6 +1355,7 @@ static void Deactivate( vlc_object_t *p_this )
...
@@ -1332,6 +1355,7 @@ static void Deactivate( vlc_object_t *p_this )
delete
p_sys
->
ep
;
delete
p_sys
->
ep
;
delete
p_sys
->
es
;
delete
p_sys
->
es
;
delete
p_sys
->
in
;
delete
p_sys
->
in
;
stream_Release
(
p_sys
->
s
);
free
(
p_sys
);
free
(
p_sys
);
}
}
...
@@ -1663,7 +1687,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
...
@@ -1663,7 +1687,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
/* seek without index or without date */
/* seek without index or without date */
if
(
config_GetInt
(
p_input
,
"mkv-seek-percent"
)
||
!
p_sys
->
b_cues
||
i_date
<
0
)
if
(
config_GetInt
(
p_input
,
"mkv-seek-percent"
)
||
!
p_sys
->
b_cues
||
i_date
<
0
)
{
{
int64_t
i_pos
=
i_percent
*
p_input
->
stream
.
p_selected_area
->
i_size
/
100
;
int64_t
i_pos
=
i_percent
*
stream_Size
(
p_sys
->
s
)
/
100
;
msg_Dbg
(
p_input
,
"imprecise way of seeking"
);
msg_Dbg
(
p_input
,
"imprecise way of seeking"
);
for
(
i_index
=
0
;
i_index
<
p_sys
->
i_index
;
i_index
++
)
for
(
i_index
=
0
;
i_index
<
p_sys
->
i_index
;
i_index
++
)
...
@@ -1722,9 +1746,12 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
...
@@ -1722,9 +1746,12 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
}
}
msg_Dbg
(
p_input
,
"seek got "
I64Fd
" (%d%%)"
,
msg_Dbg
(
p_input
,
"seek got "
I64Fd
" (%d%%)"
,
p_sys
->
index
[
i_index
].
i_time
,
(
int
)(
100
*
p_sys
->
index
[
i_index
].
i_position
/
p_input
->
stream
.
p_selected_area
->
i_size
)
);
p_sys
->
index
[
i_index
].
i_time
,
(
int
)(
100
*
p_sys
->
index
[
i_index
].
i_position
/
stream_Size
(
p_sys
->
s
)
)
);
p_sys
->
in
->
setFilePointer
(
p_sys
->
index
[
i_index
].
i_position
,
seek_beginning
);
p_sys
->
in
->
setFilePointer
(
p_sys
->
index
[
i_index
].
i_position
,
seek_beginning
);
}
}
/* now parse until key frame */
/* now parse until key frame */
...
@@ -1803,12 +1830,12 @@ static int Demux( input_thread_t * p_input )
...
@@ -1803,12 +1830,12 @@ static int Demux( input_thread_t * p_input )
i_date
=
(
mtime_t
)
1000000
*
i_date
=
(
mtime_t
)
1000000
*
(
mtime_t
)
i_duration
*
(
mtime_t
)
i_duration
*
(
mtime_t
)
p_sys
->
in
->
getFilePointer
()
/
(
mtime_t
)
p_sys
->
in
->
getFilePointer
()
/
(
mtime_t
)
p_input
->
stream
.
p_selected_area
->
i_size
;
(
mtime_t
)
stream_Size
(
p_sys
->
s
)
;
}
}
if
(
p_input
->
stream
.
p_selected_area
->
i_size
>
0
)
if
(
stream_Size
(
p_sys
->
s
)
>
0
)
{
{
i_percent
=
100
*
p_sys
->
in
->
getFilePointer
()
/
i_percent
=
100
*
p_sys
->
in
->
getFilePointer
()
/
p_input
->
stream
.
p_selected_area
->
i_size
;
stream_Size
(
p_sys
->
s
)
;
}
}
Seek
(
p_input
,
i_date
,
i_percent
);
Seek
(
p_input
,
i_date
,
i_percent
);
...
@@ -1863,129 +1890,50 @@ static int Demux( input_thread_t * p_input )
...
@@ -1863,129 +1890,50 @@ static int Demux( input_thread_t * p_input )
/*****************************************************************************
/*****************************************************************************
* Stream managment
* Stream managment
*****************************************************************************/
*****************************************************************************/
vlc_stream_io_callback
::
vlc_stream_io_callback
(
input_thread_t
*
p_input
_
)
vlc_stream_io_callback
::
vlc_stream_io_callback
(
stream_t
*
s
_
)
{
{
p_input
=
p_input
_
;
s
=
s
_
;
mb_eof
=
VLC_FALSE
;
mb_eof
=
VLC_FALSE
;
}
}
uint32_t
vlc_stream_io_callback
::
read
(
void
*
p_buffer
,
size_t
i_size
)
uint32_t
vlc_stream_io_callback
::
read
(
void
*
p_buffer
,
size_t
i_size
)
{
{
data_packet_t
*
p_data
;
if
(
i_size
<=
0
||
mb_eof
)
int
i_count
;
int
i_read
=
0
;
if
(
!
i_size
||
mb_eof
)
{
{
return
0
;
return
0
;
}
}
do
return
stream_Read
(
s
,
p_buffer
,
i_size
);
{
i_count
=
input_SplitBuffer
(
p_input
,
&
p_data
,
__MIN
(
i_size
,
10240
)
);
if
(
i_count
<=
0
)
{
return
i_read
;
}
memcpy
(
p_buffer
,
p_data
->
p_payload_start
,
i_count
);
input_DeletePacket
(
p_input
->
p_method_data
,
p_data
);
(
uint8_t
*
)
p_buffer
+=
i_count
;
i_size
-=
i_count
;
i_read
+=
i_count
;
}
while
(
i_size
);
return
i_read
;
}
}
void
vlc_stream_io_callback
::
setFilePointer
(
int64_t
i_offset
,
seek_mode
mode
)
void
vlc_stream_io_callback
::
setFilePointer
(
int64_t
i_offset
,
seek_mode
mode
)
{
{
int64_t
i_pos
;
int64_t
i_pos
;
int64_t
i_last
;
i_last
=
getFilePointer
();
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
switch
(
mode
)
switch
(
mode
)
{
{
case
seek_beginning
:
case
seek_beginning
:
i_pos
=
i_offset
;
i_pos
=
i_offset
;
break
;
break
;
case
seek_end
:
case
seek_end
:
i_pos
=
p_input
->
stream
.
p_selected_area
->
i_size
-
i_offset
;
i_pos
=
stream_Size
(
s
)
-
i_offset
;
break
;
break
;
default:
default:
i_pos
=
i_last
+
i_offset
;
i_pos
=
stream_Tell
(
s
)
+
i_offset
;
break
;
break
;
}
}
if
(
i_pos
<
0
||
if
(
i_pos
<
0
||
i_pos
>=
stream_Size
(
s
)
)
(
i_pos
>
p_input
->
stream
.
p_selected_area
->
i_size
&&
p_input
->
stream
.
p_selected_area
->
i_size
!=
0
)
)
{
{
msg_Err
(
p_input
,
"seeking to wrong place (i_pos="
I64Fd
")"
,
i_pos
);
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
mb_eof
=
VLC_TRUE
;
mb_eof
=
VLC_TRUE
;
return
;
return
;
}
}
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
mb_eof
=
VLC_FALSE
;
mb_eof
=
VLC_FALSE
;
if
(
stream_Seek
(
s
,
i_pos
)
)
if
(
i_pos
==
i_last
)
{
return
;
}
msg_Dbg
(
p_input
,
"####################seek new="
I64Fd
" old="
I64Fd
,
i_pos
,
getFilePointer
()
);
if
(
p_input
->
stream
.
b_seekable
&&
(
/*p_input->stream.i_method == INPUT_METHOD_FILE ||*/
i_pos
<
i_last
||
i_pos
-
i_last
>
p_input
->
i_bufsize
/
4
)
)
{
input_AccessReinit
(
p_input
);
p_input
->
pf_seek
(
p_input
,
i_pos
);
}
else
if
(
i_pos
>
i_last
)
{
{
data_packet_t
*
p_data
;
int
i_skip
=
i_pos
-
i_last
;
if
(
i_skip
>
1024
)
{
msg_Warn
(
p_input
,
"will skip %d bytes, slow"
,
i_skip
);
}
while
(
i_skip
>
0
)
{
int
i_read
;
i_read
=
input_SplitBuffer
(
p_input
,
&
p_data
,
__MIN
(
4096
,
i_skip
)
);
if
(
i_read
<=
0
)
{
msg_Err
(
p_input
,
"seek failed"
);
mb_eof
=
VLC_TRUE
;
return
;
}
i_skip
-=
i_read
;
input_DeletePacket
(
p_input
->
p_method_data
,
p_data
);
if
(
i_read
==
0
&&
i_skip
>
0
)
{
msg_Err
(
p_input
,
"seek failed"
);
mb_eof
=
VLC_TRUE
;
return
;
}
}
}
else
{
msg_Err
(
p_input
,
"cannot seek or emulate seek to "
I64Fd
" from "
I64Fd
,
i_pos
,
i_last
);
mb_eof
=
VLC_TRUE
;
mb_eof
=
VLC_TRUE
;
}
}
return
;
}
}
size_t
vlc_stream_io_callback
::
write
(
const
void
*
p_buffer
,
size_t
i_size
)
size_t
vlc_stream_io_callback
::
write
(
const
void
*
p_buffer
,
size_t
i_size
)
{
{
...
@@ -1993,13 +1941,7 @@ size_t vlc_stream_io_callback::write( const void *p_buffer, size_t i_size )
...
@@ -1993,13 +1941,7 @@ size_t vlc_stream_io_callback::write( const void *p_buffer, size_t i_size )
}
}
uint64_t
vlc_stream_io_callback
::
getFilePointer
(
void
)
uint64_t
vlc_stream_io_callback
::
getFilePointer
(
void
)
{
{
uint64_t
i_pos
;
return
stream_Tell
(
s
);
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
i_pos
=
p_input
->
stream
.
p_selected_area
->
i_tell
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
return
i_pos
;
}
}
void
vlc_stream_io_callback
::
close
(
void
)
void
vlc_stream_io_callback
::
close
(
void
)
{
{
...
@@ -2473,9 +2415,16 @@ static void InformationsCreate( input_thread_t *p_input )
...
@@ -2473,9 +2415,16 @@ static void InformationsCreate( input_thread_t *p_input )
#undef tk
#undef tk
}
}
if
(
p_sys
->
i_tags_position
>=
0
&&
p_input
->
stream
.
b_seekable
)
if
(
p_sys
->
i_tags_position
>=
0
)
{
{
LoadTags
(
p_input
);
vlc_bool_t
b_seekable
;
stream_Control
(
p_sys
->
s
,
STREAM_CAN_FASTSEEK
,
&
b_seekable
);
if
(
b_seekable
)
{
LoadTags
(
p_input
);
}
}
}
}
}
...
...
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