Commit 7f84c8c8 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

MKV: misc simplifications, renaming and privatizations

parent 2e56d2ef
......@@ -316,7 +316,7 @@ bool chapter_item_c::EnterAndLeave( chapter_item_c *p_item, bool b_final_enter )
{
if ( !p_common_parent->b_is_leaving && p_common_parent->Leave( false ) )
return true;
p_common_parent = p_common_parent->psz_parent;
p_common_parent = p_common_parent->p_parent;
}
// enter from the parent to <this>
......
......@@ -58,17 +58,18 @@ public:
,i_seekpoint_num(-1)
,b_display_seekpoint(true)
,b_user_display(false)
,psz_parent(NULL)
,p_parent(NULL)
,b_is_leaving(false)
{}
virtual ~chapter_item_c();
int64_t RefreshChapters( bool b_ordered, int64_t i_prev_user_time );
int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level = 0 );
int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level );
virtual chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current, bool & b_found );
void Append( const chapter_item_c & edition );
chapter_item_c * FindChapter( int64_t i_find_uid );
virtual chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
const void *p_cookie,
......@@ -76,7 +77,7 @@ public:
std::string GetCodecName( bool f_for_title = false ) const;
bool ParentOf( const chapter_item_c & item ) const;
int16 GetTitleNumber( ) const;
int64_t i_start_time, i_end_time;
int64_t i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */
std::vector<chapter_item_c*> sub_chapters;
......@@ -85,14 +86,15 @@ public:
bool b_display_seekpoint;
bool b_user_display;
std::string psz_name;
chapter_item_c *psz_parent;
chapter_item_c *p_parent;
bool b_is_leaving;
std::vector<chapter_codec_cmds_c*> codecs;
static bool CompareTimecode( const chapter_item_c * itemA, const chapter_item_c * itemB )
{
return ( itemA->i_user_start_time < itemB->i_user_start_time || (itemA->i_user_start_time == itemB->i_user_start_time && itemA->i_user_end_time < itemB->i_user_end_time) );
return ( itemA->i_user_start_time < itemB->i_user_start_time ||
(itemA->i_user_start_time == itemB->i_user_start_time && itemA->i_user_end_time < itemB->i_user_end_time) );
}
bool Enter( bool b_do_subchapters );
......@@ -106,12 +108,12 @@ public:
chapter_edition_c()
:b_ordered(false)
{}
void RefreshChapters( );
mtime_t Duration() const;
std::string GetMainName() const;
chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current );
bool b_ordered;
};
......
......@@ -501,7 +501,7 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
return NULL;
}
matroska_stream_c *p_stream1 = new matroska_stream_c( *this );
matroska_stream_c *p_stream1 = new matroska_stream_c();
while (p_l0 != 0)
{
......
......@@ -96,7 +96,7 @@ public:
EbmlParser *ep;
bool b_preloaded;
bool Preload( );
bool Preload();
bool PreloadFamily( const matroska_segment_c & segment );
void InformationCreate();
void Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position );
......
......@@ -952,7 +952,7 @@ void matroska_segment_c::ParseChapterAtom( int i_level, KaxChapterAtom *ca, chap
{
chapter_item_c *new_sub_chapter = new chapter_item_c();
ParseChapterAtom( i_level+1, static_cast<KaxChapterAtom *>(l), *new_sub_chapter );
new_sub_chapter->psz_parent = &chapters;
new_sub_chapter->p_parent = &chapters;
chapters.sub_chapters.push_back( new_sub_chapter );
}
}
......@@ -972,28 +972,19 @@ void matroska_segment_c::ParseAttachments( KaxAttachments *attachments )
while( attachedFile && ( attachedFile->GetSize() > 0 ) )
{
std::string psz_mime_type = GetChild<KaxMimeType>( *attachedFile );
KaxFileName &file_name = GetChild<KaxFileName>( *attachedFile );
KaxFileData &img_data = GetChild<KaxFileData>( *attachedFile );
attachment_c *new_attachment = new attachment_c( ToUTF8( UTFstring( GetChild<KaxFileName>( *attachedFile ) ) ),
GetChild<KaxMimeType>( *attachedFile ),
img_data.GetSize() );
attachment_c *new_attachment = new attachment_c();
if( new_attachment )
if( new_attachment->init() )
{
new_attachment->psz_file_name = ToUTF8( UTFstring( file_name ) );
new_attachment->psz_mime_type = psz_mime_type;
new_attachment->i_size = img_data.GetSize();
new_attachment->p_data = malloc( img_data.GetSize() );
if( new_attachment->p_data )
{
memcpy( new_attachment->p_data, img_data.GetBuffer(), img_data.GetSize() );
sys.stored_attachments.push_back( new_attachment );
}
else
{
delete new_attachment;
}
memcpy( new_attachment->p_data, img_data.GetBuffer(), img_data.GetSize() );
sys.stored_attachments.push_back( new_attachment );
}
else
{
delete new_attachment;
}
attachedFile = &GetNextChild<KaxAttached>( *attachments, *attachedFile );
......
......@@ -76,7 +76,7 @@ class demux_sys_t;
static int Demux ( demux_t * );
static int Control( demux_t *, int, va_list );
static void Seek ( demux_t *, mtime_t i_date, double f_percent, chapter_item_c *psz_chapter );
static void Seek ( demux_t *, mtime_t i_date, double f_percent, chapter_item_c *p_chapter );
/*****************************************************************************
* Open: initializes matroska demux structures
......@@ -123,8 +123,8 @@ static int Open( vlc_object_t * p_this )
}
p_sys->streams.push_back( p_stream );
p_stream->p_in = p_io_callback;
p_stream->p_es = p_io_stream;
p_stream->p_io_callback = p_io_callback;
p_stream->p_estream = p_io_stream;
for (size_t i=0; i<p_stream->segments.size(); i++)
{
......@@ -214,8 +214,8 @@ static int Open( vlc_object_t * p_this )
}
else
{
p_stream->p_in = p_file_io;
p_stream->p_es = p_estream;
p_stream->p_io_callback = p_file_io;
p_stream->p_estream = p_estream;
p_sys->streams.push_back( p_stream );
}
}
......@@ -297,8 +297,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
for( size_t i = 0; i < p_sys->stored_attachments.size(); i++ )
{
attachment_c *a = p_sys->stored_attachments[i];
(*ppp_attach)[i] = vlc_input_attachment_New( a->psz_file_name.c_str(), a->psz_mime_type.c_str(), NULL,
a->p_data, a->i_size );
(*ppp_attach)[i] = vlc_input_attachment_New( a->fileName(), a->mimeType(), NULL,
a->p_data, a->size() );
}
return VLC_SUCCESS;
......@@ -397,7 +397,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
}
/* Seek */
static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_item_c *psz_chapter )
static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_item_c *p_chapter )
{
demux_sys_t *p_sys = p_demux->p_sys;
virtual_segment_c *p_vsegment = p_sys->p_current_segment;
......@@ -453,7 +453,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_it
}
}
p_vsegment->Seek( *p_demux, i_date, i_time_offset, psz_chapter, i_global_position );
p_vsegment->Seek( *p_demux, i_date, i_time_offset, p_chapter, i_global_position );
}
/* Utility function for BlockDecode */
......
......@@ -127,44 +127,48 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
class attachment_c
{
public:
attachment_c()
:p_data(NULL)
,i_size(0)
{}
virtual ~attachment_c()
attachment_c( std::string _psz_file_name, std::string _psz_mime_type, int _i_size )
:i_size(_i_size)
,psz_file_name( _psz_file_name)
,psz_mime_type( _psz_mime_type)
{
free( p_data );
p_data = NULL;
}
virtual ~attachment_c() { free( p_data ); }
/* Allocs the data space. Returns true if allocation went ok */
bool init()
{
p_data = malloc( i_size );
return (p_data != NULL);
}
const char* fileName() { return psz_file_name.c_str(); }
const char* mimeType() { return psz_mime_type.c_str(); }
int size() { return i_size; }
std::string psz_file_name;
std::string psz_mime_type;
void *p_data;
private:
int i_size;
std::string psz_file_name;
std::string psz_mime_type;
};
class matroska_segment_c;
class matroska_stream_c
{
public:
matroska_stream_c( demux_sys_t & demuxer )
:p_in(NULL)
,p_es(NULL)
,sys(demuxer)
{}
matroska_stream_c() :p_io_callback(NULL) ,p_estream(NULL) {}
virtual ~matroska_stream_c()
{
delete p_in;
delete p_es;
delete p_io_callback;
delete p_estream;
}
IOCallback *p_in;
EbmlStream *p_es;
IOCallback *p_io_callback;
EbmlStream *p_estream;
std::vector<matroska_segment_c*> segments;
demux_sys_t & sys;
};
......
......@@ -203,30 +203,30 @@ void virtual_segment_c::AppendUID( const EbmlBinary * p_UID )
linked_uids.push_back( *(KaxSegmentUID*)(p_UID) );
}
void virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *psz_chapter, int64_t i_global_position )
void virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *p_chapter, int64_t i_global_position )
{
demux_sys_t *p_sys = demuxer.p_sys;
size_t i;
// find the actual time for an ordered edition
if ( psz_chapter == NULL )
if ( p_chapter == NULL )
{
if ( CurrentEdition() && CurrentEdition()->b_ordered )
{
/* 1st, we need to know in which chapter we are */
psz_chapter = (*p_editions)[i_current_edition]->FindTimecode( i_date, p_current_chapter );
p_chapter = (*p_editions)[i_current_edition]->FindTimecode( i_date, p_current_chapter );
}
}
if ( psz_chapter != NULL )
if ( p_chapter != NULL )
{
p_current_chapter = psz_chapter;
p_sys->i_chapter_time = i_time_offset = psz_chapter->i_user_start_time - psz_chapter->i_start_time;
if ( psz_chapter->i_seekpoint_num > 0 )
p_current_chapter = p_chapter;
p_sys->i_chapter_time = i_time_offset = p_chapter->i_user_start_time - p_chapter->i_start_time;
if ( p_chapter->i_seekpoint_num > 0 )
{
demuxer.info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
demuxer.info.i_title = p_sys->i_current_title = i_sys_title;
demuxer.info.i_seekpoint = psz_chapter->i_seekpoint_num - 1;
demuxer.info.i_seekpoint = p_chapter->i_seekpoint_num - 1;
}
}
......
......@@ -51,7 +51,7 @@ public:
void AddSegments( std::vector<matroska_segment_c*> segments );
void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *psz_chapter, int64_t i_global_position );
void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *p_chapter, int64_t i_global_position );
mtime_t Duration() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment