Commit 43fa9b20 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

VLCMedia: Allow video and audio codec to be queried.

parent c8fb73a1
......@@ -31,7 +31,8 @@
using namespace LibVLCpp;
Media::Media( const QString& filename ) :
m_fileName( filename )
m_fileName( filename ),
m_tracksInfo( NULL )
{
m_internalPtr = libvlc_media_new_location( *(LibVLCpp::Instance::getInstance()),
filename.toLocal8Bit() );
......@@ -39,6 +40,8 @@ Media::Media( const QString& filename ) :
Media::~Media()
{
// tracks info gets allocated by vlc, so we use free.
free( m_tracksInfo );
libvlc_media_release( m_internalPtr );
}
......@@ -108,3 +111,33 @@ Media::getFileName() const
{
return m_fileName;
}
void
Media::parse()
{
libvlc_media_parse( *this );
}
void
Media::fetchTrackInfo()
{
m_nbTracks = libvlc_media_get_tracks_info( *this, &m_tracksInfo );
}
unsigned int
Media::videoCodec() const
{
for ( int i = 0; i < m_nbTracks; ++i )
if ( m_tracksInfo[i].i_type == libvlc_track_video )
return m_tracksInfo[i].i_codec;
return 0;
}
unsigned int
Media::audioCodec() const
{
for ( int i = 0; i < m_nbTracks; ++i )
if ( m_tracksInfo[i].i_type == libvlc_track_video )
return m_tracksInfo[i].i_codec;
return 0;
}
......@@ -46,9 +46,17 @@ namespace LibVLCpp
void setVideoDataCtx( void* dataCtx );
void setAudioDataCtx( void* dataCtx );
const QString& getFileName() const;
void parse();
void fetchTrackInfo();
unsigned int videoCodec() const;
unsigned int audioCodec() const;
private:
QString m_fileName;
QString m_fileName;
libvlc_media_track_info_t *m_tracksInfo;
// this has not to be equal to nb video tracks + nb audio tracks.
// it is only meant to use when iterating over m_tracksInfo
int m_nbTracks;
};
}
......
......@@ -82,7 +82,11 @@ MetaDataWorker::run()
emit failed( m_media );
}
else
{
// parse some extra meta data from the media itself :
m_media->vlcMedia()->parse();
metaDataAvailable();
}
}
void
......
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