[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux/mkv: use a specialized EbmlStream that only uses VLC streams

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Mar 10 06:48:26 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
13745ebf by Steve Lhomme at 2024-03-10T06:18:24+00:00
demux/mkv: use a specialized EbmlStream that only uses VLC streams

- - - - -
3d136a03 by Steve Lhomme at 2024-03-10T06:18:24+00:00
demux/mkv: avoid dynamic_cast to check EOF

We know we have a VLC stream, we can use its special methods.

- - - - -


6 changed files:

- modules/demux/mkv/Ebml_parser.cpp
- modules/demux/mkv/Ebml_parser.hpp
- modules/demux/mkv/matroska_segment.cpp
- modules/demux/mkv/matroska_segment.hpp
- modules/demux/mkv/mkv.hpp
- modules/demux/mkv/stream_io_callback.hpp


Changes:

=====================================
modules/demux/mkv/Ebml_parser.cpp
=====================================
@@ -30,7 +30,7 @@ namespace mkv {
 /*****************************************************************************
  * Ebml Stream parser
  *****************************************************************************/
-EbmlParser::EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux ) :
+EbmlParser::EbmlParser( matroska_iostream_c *es, EbmlElement *el_start, demux_t *p_demux ) :
     p_demux( p_demux ),
     m_es( es ),
     mi_level( 1 ),
@@ -62,7 +62,7 @@ EbmlParser::~EbmlParser( void )
     }
 }
 
-void EbmlParser::reconstruct( EbmlStream* es, EbmlElement* el_start, demux_t* p_demux )
+void EbmlParser::reconstruct( matroska_iostream_c* es, EbmlElement* el_start, demux_t* p_demux )
 {
     this->~EbmlParser();
 
@@ -212,8 +212,7 @@ next:
 
         if( m_el[mi_level] == NULL )
         {
-            vlc_stream_io_callback *io_callback = dynamic_cast<vlc_stream_io_callback *>(&m_es->I_O());
-            if ( i_max_read != UINT64_MAX && io_callback != NULL && !io_callback->IsEOF() )
+            if ( i_max_read != UINT64_MAX && !m_es->I_O().IsEOF() )
             {
                 msg_Dbg(p_demux, "found nothing, go up");
                 i_ulev = 1;


=====================================
modules/demux/mkv/Ebml_parser.hpp
=====================================
@@ -34,10 +34,10 @@ namespace mkv {
 class EbmlParser
 {
   public:
-    EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux );
+    EbmlParser( matroska_iostream_c *es, EbmlElement *el_start, demux_t *p_demux );
     ~EbmlParser( void );
 
-    void reconstruct( EbmlStream*, EbmlElement*, demux_t*);
+    void reconstruct( matroska_iostream_c*, EbmlElement*, demux_t*);
 
     void Up( void );
     void Down( void );
@@ -55,7 +55,7 @@ class EbmlParser
     static const int M_EL_MAXSIZE = 10;
 
     demux_t     *p_demux;
-    EbmlStream  *m_es;
+    matroska_iostream_c  *m_es;
     int          mi_level;
     EbmlElement *m_el[M_EL_MAXSIZE];
 


=====================================
modules/demux/mkv/matroska_segment.cpp
=====================================
@@ -33,7 +33,7 @@
 
 namespace mkv {
 
-matroska_segment_c::matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream, KaxSegment *p_seg )
+matroska_segment_c::matroska_segment_c( demux_sys_t & demuxer, matroska_iostream_c & estream, KaxSegment *p_seg )
     :segment(p_seg)
     ,es(estream)
     ,i_timescale(MKVD_TIMECODESCALE)


=====================================
modules/demux/mkv/matroska_segment.hpp
=====================================
@@ -82,11 +82,11 @@ public:
     typedef std::map<mkv_track_t::track_id_t, std::unique_ptr<mkv_track_t>> tracks_map_t;
     typedef std::vector<Tag>            tags_t;
 
-    matroska_segment_c( demux_sys_t &, EbmlStream &, KaxSegment * );
+    matroska_segment_c( demux_sys_t &, matroska_iostream_c &, KaxSegment * );
     virtual ~matroska_segment_c();
 
     KaxSegment              *segment;
-    EbmlStream              & es;
+    matroska_iostream_c     & es;
 
     /* time scale */
     uint64_t                i_timescale;


=====================================
modules/demux/mkv/mkv.hpp
=====================================
@@ -134,7 +134,7 @@ struct matroska_stream_c
     bool isUsed() const;
 
     vlc_stream_io_callback io_callback;
-    EbmlStream         estream;
+    matroska_iostream_c    estream;
 
     std::vector<matroska_segment_c*> segments;
 };


=====================================
modules/demux/mkv/stream_io_callback.hpp
=====================================
@@ -31,6 +31,7 @@
 #include <vlc_demux.h>
 
 #include <ebml/IOCallback.h>
+#include <ebml/EbmlStream.h>
 
 using namespace libebml;
 
@@ -64,6 +65,23 @@ class vlc_stream_io_callback: public IOCallback
     void     close           ( void ) override { return; }
 };
 
+class matroska_iostream_c : public EbmlStream
+{
+public:
+    matroska_iostream_c(vlc_stream_io_callback & io)
+        :EbmlStream(io)
+    {}
+
+    inline vlc_stream_io_callback & I_O() {
+        return static_cast<vlc_stream_io_callback &>(EbmlStream::I_O());
+    }
+
+private:
+    // hide generic method
+    using EbmlStream::I_O;
+};
+
+
 } // namespace
 
 #endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dba5d5969af029cc475e6cd124a2d4845339fb19...3d136a03dfb42923bcc113a4ab1c0cb087494c14

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dba5d5969af029cc475e6cd124a2d4845339fb19...3d136a03dfb42923bcc113a4ab1c0cb087494c14
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list