Skip to content
Snippets Groups Projects

demux: mkv: separate Chapter Codec implementations

Merged Steve Lhomme requested to merge robUx4/vlc:codec-split into master
All threads resolved!
3 files
+ 0
4
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 88
64
@@ -24,8 +24,8 @@
#include "mkv.hpp"
#include "demux.hpp"
#include "events.hpp"
#include "chapter_command_dvd.hpp"
#include <vlc_actions.h>
#include <vlc_threads.h>
#include <algorithm>
@@ -40,52 +40,67 @@ event_thread_t::event_thread_t(demux_t *p_demux) : p_demux(p_demux)
}
event_thread_t::~event_thread_t()
{
ResetPci();
AbortThread();
}
void event_thread_t::SetPci(const pci_t *data)
void event_thread_t::SendData( mkv_track_t &track, block_t * p_block )
{
demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
vlc_mutex_locker l(&lock);
if ( track.codec == "B_VOBBTN")
{
if( p_block->i_size > 0)
{
QueueEvent( EventInfo{ p_block } );
return; // the block will be released later
}
}
if(es_list.empty())
return;
block_Release( p_block );
}
auto interpretor = p_sys->GetDVDInterpretor();
if (!interpretor)
void event_thread_t::EnsureThreadLocked()
{
if (is_running || b_abort)
return;
interpretor->SetPci( data );
if( !is_running )
{
b_abort = false;
is_running = !vlc_clone( &thread, EventThread, this );
}
is_running = !vlc_clone( &thread, EventThread, this );
}
void event_thread_t::ResetPci()
void event_thread_t::AbortThread()
{
if( !is_running )
return;
vlc_mutex_lock( &lock );
b_abort = true;
vlc_cond_signal( &wait );
vlc_mutex_unlock( &lock );
{
vlc_mutex_locker lock_guard(&lock);
b_abort = true;
vlc_cond_signal( &wait );
}
vlc_join( thread, NULL );
is_running = false;
}
int event_thread_t::SendEventNav( int nav_query )
int event_thread_t::SendEventNav( demux_query_e nav_query )
{
NavivationKey key;
switch( nav_query )
{
case DEMUX_NAV_LEFT: key = NavivationKey::LEFT; break;
case DEMUX_NAV_RIGHT: key = NavivationKey::RIGHT; break;
case DEMUX_NAV_UP: key = NavivationKey::UP; break;
case DEMUX_NAV_DOWN: key = NavivationKey::DOWN; break;
case DEMUX_NAV_ACTIVATE: key = NavivationKey::OK; break;
case DEMUX_NAV_MENU: key = NavivationKey::MENU; break;
case DEMUX_NAV_POPUP: key = NavivationKey::POPUP; break;
default:
assert(false); // invalid navigation query received
return VLC_ENOTSUP;
}
if( !is_running )
return VLC_EGENERIC;
vlc_mutex_locker lock_guard( &lock );
pending_events.push_back( EventInfo( nav_query ) );
vlc_cond_signal( &wait );
QueueEvent( EventInfo{ key } );
return VLC_SUCCESS;
}
@@ -93,15 +108,11 @@ int event_thread_t::SendEventNav( int nav_query )
void event_thread_t::EventMouse( vlc_mouse_t const* new_state, void* userdata )
{
ESInfo* info = static_cast<ESInfo*>( userdata );
vlc_mutex_locker lock_guard( &info->owner.lock );
if( !new_state )
return vlc_mouse_Init( &info->mouse_state );
info->owner.pending_events.push_back(
EventInfo( info, info->mouse_state, *new_state ) );
vlc_cond_signal( &info->owner.wait );
info->owner.QueueEvent( EventInfo{ info->mouse_state, *new_state } );
info->mouse_state = *new_state;
}
@@ -121,8 +132,13 @@ void event_thread_t::EventThread()
while( !pending_events.empty() )
{
EventInfo const& ev = pending_events.front();
const EventInfo ev = pending_events.front();
pending_events.pop_front();
if(es_list.empty())
break;
vlc_mutex_unlock( &lock );
switch( ev.type )
{
case EventInfo::ESMouseEvent:
@@ -132,9 +148,12 @@ void event_thread_t::EventThread()
case EventInfo::ActionEvent:
HandleKeyEvent( ev );
break;
}
pending_events.pop_front();
case EventInfo::ButtonDataEvent:
HandleButtonData( ev );
break;
}
vlc_mutex_lock( &lock );
}
}
@@ -151,36 +170,21 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
{
msg_Dbg( p_demux, "Handle Key Event");
NavivationKey key;
switch( ev.nav.query )
{
case DEMUX_NAV_LEFT: key = NavivationKey::LEFT;
case DEMUX_NAV_RIGHT: key = NavivationKey::RIGHT;
case DEMUX_NAV_UP: key = NavivationKey::UP;
case DEMUX_NAV_DOWN: key = NavivationKey::DOWN;
case DEMUX_NAV_ACTIVATE: key = NavivationKey::OK;
default: return;
}
HandleKeyEvent( key );
HandleKeyEvent( ev.nav.key );
}
void event_thread_t::HandleKeyEvent( NavivationKey key )
{
demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
vlc_mutex_locker demux_lock ( &p_sys->lock_demuxer );
auto interpretor = p_sys->GetDVDInterpretor();
if (!interpretor)
return;
vlc_mutex_unlock( &lock );
vlc_mutex_lock( &p_sys->lock_demuxer );
// process the button action
interpretor->HandleKeyEvent( key );
vlc_mutex_unlock( &p_sys->lock_demuxer );
vlc_mutex_lock( &lock );
}
void event_thread_t::HandleMouseEvent( EventInfo const& event )
@@ -199,21 +203,37 @@ void event_thread_t::HandleMouseEvent( EventInfo const& event )
}
}
void event_thread_t::HandleMousePressed( unsigned x, unsigned y )
void event_thread_t::HandleButtonData( EventInfo const& event )
{
HandleButtonData( event.button_data.get() );
}
void event_thread_t::HandleButtonData( block_t *p_block )
{
demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
vlc_mutex_locker demux_lock ( &p_sys->lock_demuxer );
auto interpretor = p_sys->GetDVDInterpretor();
if (!interpretor)
return;
interpretor->SetPci( &p_block->p_buffer[1], p_block->i_size - 1 );
}
void event_thread_t::HandleMousePressed( unsigned x, unsigned y )
{
demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
msg_Dbg( p_demux, "Handle Mouse Event: Mouse clicked x(%d)*y(%d)", x, y);
vlc_mutex_unlock( &lock );
vlc_mutex_lock( &p_sys->lock_demuxer );
vlc_mutex_locker demux_lock ( &p_sys->lock_demuxer );
auto interpretor = p_sys->GetDVDInterpretor();
if (!interpretor)
return;
interpretor->HandleMousePressed( x, y );
vlc_mutex_unlock( &p_sys->lock_demuxer );
vlc_mutex_lock( &lock );
}
void event_thread_t::SetHighlight( vlc_spu_highlight_t & spu_hl )
@@ -221,24 +241,28 @@ void event_thread_t::SetHighlight( vlc_spu_highlight_t & spu_hl )
/* TODO: only control relevant SPU_ES given who fired the event */
for( auto it : es_list )
{
if( it.category != SPU_ES )
if( it.track.fmt.i_cat != SPU_ES )
continue;
es_out_Control( p_demux->out, ES_OUT_SPU_SET_HIGHLIGHT, it.es, &spu_hl );
es_out_Control( p_demux->out, ES_OUT_SPU_SET_HIGHLIGHT, it.track.p_es, &spu_hl );
}
}
bool event_thread_t::AddES( es_out_id_t* es, int category )
bool event_thread_t::AddTrack( mkv_track_t & track )
{
es_out_id_t* es = track.p_es;
int category = track.fmt.i_cat;
vlc_mutex_locker lock_guard( &lock );
es_list.push_front( ESInfo( es, category, *this ) );
es_list.push_front( ESInfo( track, *this ) );
es_list_t::iterator info = es_list.begin();
if( category == VIDEO_ES )
{
if( es_out_Control( p_demux->out, ES_OUT_VOUT_SET_MOUSE_EVENT,
es, EventMouse, static_cast<void*>( &*info ) ) )
es, static_cast<vlc_mouse_event>(EventMouse),
static_cast<void*>( &*info ) ) )
{
msg_Warn( p_demux, "Unable to subscribe to mouse events" );
es_list.erase( info );
@@ -248,10 +272,10 @@ bool event_thread_t::AddES( es_out_id_t* es, int category )
return true;
}
void event_thread_t::DelES( es_out_id_t* es )
void event_thread_t::DelTrack( mkv_track_t &track )
{
vlc_mutex_locker lock_guard( &lock );
es_list_t::iterator info = std::find( es_list.begin(), es_list.end(), es );
es_list_t::iterator info = std::find( es_list.begin(), es_list.end(), track );
if( info != es_list.end() )
es_list.erase( info );
}
Loading