Commit e8a60338 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Adding hasAudioTrack and hasVideoTrack methods in Media

parent a6db7c6f
......@@ -266,3 +266,15 @@ QString MediaPlayer::getLoadedMRL()
char* str = libvlc_media_get_mrl( media );
return QString( str );
}
bool
MediaPlayer::hasVideoTrack()
{
return ( libvlc_video_get_track_count( m_internalPtr, m_ex ) > 0 );
}
bool
MediaPlayer::hasAudioTrack()
{
return ( libvlc_audio_get_track_count( m_internalPtr, m_ex ) > 0 );
}
......@@ -62,6 +62,8 @@ namespace LibVLCpp
bool hasVout();
const QString& getLoadedFileName() const;
QString getLoadedMRL();
bool hasVideoTrack();
bool hasAudioTrack();
private:
static void callbacks( const libvlc_event_t* event, void* self );
......
......@@ -46,7 +46,9 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_width( 0 ),
m_height( 0 ),
m_fps( .0f ),
m_baseClip( NULL )
m_baseClip( NULL ),
m_hasVideo( false ),
m_hasAudio( false )
{
if ( uuid.length() == 0 )
m_uuid = QUuid::createUuid();
......@@ -273,3 +275,22 @@ void Media::removeClip( const QUuid& uuid )
{
m_clips.remove( uuid );
}
bool
Media::hasAudioTrack() const
{
return m_hasAudio;
}
bool
Media::hasVideoTrack() const
{
return m_hasVideo;
}
void
Media::setTracksAvailable( bool video, bool audio )
{
m_hasVideo = video;
m_hasAudio = audio;
}
......@@ -114,6 +114,10 @@ public:
const QUuid& getUuid() const;
void setUuid( const QUuid& uuid );
bool hasAudioTrack() const;
bool hasVideoTrack() const;
void setTracksAvailable( bool video, bool audio );
FileType getFileType() const;
static const QString VideoExtensions;
static const QString AudioExtensions;
......@@ -163,6 +167,8 @@ protected:
Clip* m_baseClip;
QHash<QUuid, Clip*> m_clips;
QList<int>* m_audioValueList;
bool m_hasVideo;
bool m_hasAudio;
signals:
void metaDataComputed( Media* );
......
......@@ -27,6 +27,7 @@
#include "vlmc.h"
#include "MetaDataWorker.h"
#include "Library.h"
#include "SettingsManager.h"
#include <QThreadPool>
#include <QRunnable>
......@@ -117,9 +118,18 @@ void MetaDataWorker::metaDataAvailable()
m_media->setFps( Clip::DefaultFPS );
}
}
else
{
const SettingValue *val = SettingsManager::getInstance()->getValue( "project", "VideoProjectFPS" );
Q_ASSERT_X( val != NULL, "MetaDataWorker", "Can't operate without a project FPS value ");
m_media->setFps( val->get().toDouble() );
}
m_media->setLength( m_mediaPlayer->getLength() );
m_media->emitMetaDataComputed();
m_media->setTracksAvailable( m_mediaPlayer->hasVideoTrack(),
m_mediaPlayer->hasAudioTrack() );
m_media->setNbFrames( (m_media->getLengthMS() / 1000) * m_media->getFps() );
//Setting time for snapshot :
if ( m_media->getFileType() == Media::Video ||
......
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