[vlc-commits] demux: mkv: prepare for new event handling
Filip Roséen
git at videolan.org
Fri Jul 20 09:37:38 CEST 2018
vlc | branch: master | Filip Roséen <filip at atch.se> | Thu Jul 19 19:41:13 2018 +0200| [94ba16af77dda4511e7752786860a50d1992a154] | committer: Thomas Guillem
demux: mkv: prepare for new event handling
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94ba16af77dda4511e7752786860a50d1992a154
---
modules/demux/mkv/events.cpp | 30 +++++++++++++++++++++++++++
modules/demux/mkv/events.hpp | 37 ++++++++++++++++++++++++++++++++++
modules/demux/mkv/matroska_segment.cpp | 6 ++++++
3 files changed, 73 insertions(+)
diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
index d890dada46..483d98fe56 100644
--- a/modules/demux/mkv/events.cpp
+++ b/modules/demux/mkv/events.cpp
@@ -29,6 +29,8 @@
#include <vlc_actions.h>
#include <vlc_threads.h>
+#include <algorithm>
+
namespace mkv {
event_thread_t::event_thread_t(demux_t *p_demux) : p_demux(p_demux)
@@ -173,6 +175,13 @@ void event_thread_t::EventThread()
if( p_vout && ( b_moved || b_clicked ) )
HandleMouseEvent( p_vout );
+ while( !pending_events.empty() )
+ {
+ /* TODO: handle events here */
+ pending_events.pop_front();
+ }
+
+
b_vout = false;
vlc_mutex_unlock( &lock );
@@ -438,5 +447,26 @@ void event_thread_t::HandleMouseEvent( vlc_object_t* p_vout )
b_clicked = false;
}
+void event_thread_t::AddES( es_out_id_t* es, int category )
+{
+ vlc_mutex_locker lock_guard( &lock );
+
+ es_list.push_back( ESInfo( es, category, *this ) );
+ es_list_t::reverse_iterator info = es_list.rbegin();
+
+ /* TODO:
+ * - subscribe to events if required,
+ * - use &*info as callback data if necessary
+ **/
+
+ VLC_UNUSED( info );
+}
+
+void event_thread_t::DelES( es_out_id_t* es )
+{
+ vlc_mutex_locker lock_guard( &lock );
+ es_list.erase( std::find( es_list.begin(), es_list.end(), es ) );
+}
+
} // namespace
diff --git a/modules/demux/mkv/events.hpp b/modules/demux/mkv/events.hpp
index 1ed207659d..1a94a13cc2 100644
--- a/modules/demux/mkv/events.hpp
+++ b/modules/demux/mkv/events.hpp
@@ -30,6 +30,8 @@
#include "dvd_types.hpp"
+#include <list>
+
namespace mkv {
struct demux_sys_t;
@@ -43,7 +45,36 @@ public:
void SetPci(const pci_t *data);
void ResetPci();
+ void AddES( es_out_id_t* es, int category );
+ void DelES( es_out_id_t* es );
+
private:
+ struct ESInfo {
+ ESInfo( es_out_id_t* es, int category, event_thread_t& owner )
+ : es( es )
+ , category( category )
+ , owner( owner )
+ { }
+
+ bool operator==( es_out_id_t* es ) const {
+ return this->es == es;
+ }
+
+ es_out_id_t* es;
+ int category;
+ event_thread_t& owner;
+ };
+
+ struct EventInfo {
+ enum {
+ /* XXX: event type */
+ } type;
+
+ union {
+ /* XXX: event specific data */
+ };
+ };
+
void EventThread();
static void *EventThread(void *);
@@ -67,6 +98,12 @@ private:
int i_key_action;
bool b_vout;
pci_t pci_packet;
+
+ typedef std::list<ESInfo> es_list_t;
+ es_list_t es_list;
+
+ typedef std::list<EventInfo> pending_events_t;
+ pending_events_t pending_events;
};
} // namespace
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index c8ce568a81..06a57f612f 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1121,8 +1121,13 @@ bool matroska_segment_c::ESCreate()
}
if( !track.p_es )
+ {
track.p_es = es_out_Add( sys.demuxer.out, &track.fmt );
+ if( track.p_es )
+ sys.ev.AddES( track.p_es, track.fmt.i_cat );
+ }
+
/* Turn on a subtitles track if it has been flagged as default -
* but only do this if no subtitles track has already been engaged,
* either by an earlier 'default track' (??) or by default
@@ -1157,6 +1162,7 @@ void matroska_segment_c::ESDestroy( )
if( track.p_es != NULL )
{
es_out_Del( sys.demuxer.out, track.p_es );
+ sys.ev.DelES( track.p_es );
track.p_es = NULL;
}
}
More information about the vlc-commits
mailing list