[vlc-commits] demux: mkv: add a version of the demuxer that trust Cues
Steve Lhomme
git at videolan.org
Mon Oct 5 08:39:28 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 2 13:14:33 2020 +0200| [4f6479c24274926447d1c3fdbf445535aaf7bfa8] | committer: Steve Lhomme
demux: mkv: add a version of the demuxer that trust Cues
It can only be loaded with the proper name, it is not automatically loaded.
It is necessary to know when opening the module because we start parsing the
Matroska data to find the mandatory headers and the Cues may be parsed during
that time.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f6479c24274926447d1c3fdbf445535aaf7bfa8
---
modules/demux/mkv/demux.hpp | 5 ++++-
modules/demux/mkv/matroska_segment.cpp | 4 +++-
modules/demux/mkv/mkv.cpp | 23 ++++++++++++++++++++---
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index e684279071..e5d53596e4 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -39,7 +39,7 @@ class chapter_item_c;
struct demux_sys_t
{
public:
- demux_sys_t( demux_t & demux )
+ demux_sys_t( demux_t & demux, bool trust_cues )
:demuxer(demux)
,b_seekable(false)
,b_fastseekable(false)
@@ -54,6 +54,7 @@ public:
,p_current_vsegment(NULL)
,dvd_interpretor( *this )
,i_duration(-1)
+ ,trust_cues(trust_cues)
,ev(&demux)
{
vlc_mutex_init( &lock_demuxer );
@@ -89,6 +90,8 @@ public:
/* duration of the stream */
vlc_tick_t i_duration;
+ const bool trust_cues;
+
matroska_segment_c *FindSegment( const EbmlBinary & uid ) const;
virtual_chapter_c *BrowseCodecPrivate( unsigned int codec_id,
bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 57cc84c816..da5473f576 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -216,7 +216,9 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
if( ! b_invalid_cue && tracks.find( track_id ) != tracks.end() )
{
- level = SegmentSeeker::Seekpoint::QUESTIONABLE; // TODO: var_InheritBool( ..., "mkv-trust-cues" );
+ level = sys.trust_cues ?
+ SegmentSeeker::Seekpoint::TRUSTED :
+ SegmentSeeker::Seekpoint::QUESTIONABLE;
}
_seeker.add_seekpoint( track_id,
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 82f464a74a..9157d36d3e 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -44,6 +44,7 @@ extern "C" {
*****************************************************************************/
namespace mkv {
static int Open ( vlc_object_t * );
+static int OpenTrusted ( vlc_object_t * );
static void Close( vlc_object_t * );
} // namespace
@@ -84,6 +85,11 @@ vlc_module_begin ()
add_file_extension("mka")
add_file_extension("mks")
add_file_extension("mkv")
+
+ add_submodule()
+ set_callbacks( OpenTrusted, Close )
+ set_capability( "demux", 0 )
+ add_shortcut( "mka_trusted", "mkv_trusted" )
vlc_module_end ()
namespace mkv {
@@ -97,9 +103,8 @@ static int Seek ( demux_t *, vlc_tick_t i_mk_date, double f_percent, virtual_
/*****************************************************************************
* Open: initializes matroska demux structures
*****************************************************************************/
-static int Open( vlc_object_t * p_this )
+static int OpenInternal( demux_t *p_demux, bool trust_cues )
{
- demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
matroska_stream_c *p_stream;
matroska_segment_c *p_segment;
@@ -117,7 +122,7 @@ static int Open( vlc_object_t * p_this )
/* Set the demux function */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
- p_demux->p_sys = p_sys = new demux_sys_t( *p_demux );
+ p_demux->p_sys = p_sys = new demux_sys_t( *p_demux, trust_cues );
vlc_stream_Control( p_demux->s, STREAM_CAN_SEEK, &p_sys->b_seekable );
if ( !p_sys->b_seekable || vlc_stream_Control(
@@ -270,6 +275,18 @@ error:
return VLC_EGENERIC;
}
+static int Open( vlc_object_t *p_this )
+{
+ demux_t *p_demux = (demux_t*)p_this;
+ return OpenInternal( p_demux, false );
+}
+
+static int OpenTrusted( vlc_object_t *p_this )
+{
+ demux_t *p_demux = (demux_t*)p_this;
+ return OpenInternal( p_demux, true );
+}
+
/*****************************************************************************
* Close: frees unused data
*****************************************************************************/
More information about the vlc-commits
mailing list