Commit 208e377c authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored track counting.

Adding track count to clip property window
parent a87971d5
......@@ -51,7 +51,11 @@ ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
ui->fpsValueLabel->setText( QString::number( m_clip->getParent()->getFps() ) );
//Snapshot
ui->snapshotLabel->setPixmap( m_clip->getParent()->getSnapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
//nb tracks :
ui->nbVideoTracksValueLabel->setText(
QString::number( m_clip->getParent()->getNbVideoTracks() ) );
ui->nbAudioTracksValueLabel->setText(
QString::number( m_clip->getParent()->getNbAudioTracks() ) );
//Metatags
const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
Q_ASSERT( button != NULL);
......
......@@ -176,6 +176,7 @@ void TracksView::deleteMedia( const QUuid& uuid )
void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::TrackType trackType, qint64 start )
{
qDebug() << "adding media item";
Q_ASSERT( clip );
// If there is not enough tracks to insert
......@@ -204,7 +205,7 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::Tra
if ( track + 1 == m_numAudioTrack )
addAudioTrack();
}
qDebug() << "check for existence in timeline";
// Is the clip already existing in the timeline ?
QList<QGraphicsItem*> trackItems = getTrack( trackType, track )->childItems();;
for ( int i = 0; i < trackItems.size(); ++i )
......@@ -216,6 +217,7 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::Tra
return;
}
qDebug() << "connecting split";
AbstractGraphicsMediaItem* item = 0;
if ( trackType == MainWorkflow::VideoTrack )
{
......@@ -232,6 +234,7 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::Tra
item = new GraphicsAudioItem( clip );
}
qDebug() << "doing stuffs";
item->m_tracksView = this;
item->setHeight( tracksHeight() );
item->setParentItem( getTrack( trackType, track ) );
......
......@@ -50,7 +50,7 @@
</size>
</property>
<property name="text">
<string>TextLabel</string>
<string/>
</property>
</widget>
</item>
......@@ -156,6 +156,34 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="nbVideoTracks">
<property name="text">
<string>Number of video tracks</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="nbAudioTracks">
<property name="text">
<string>Number of audio tracks</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="nbVideoTracksValueLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="nbAudioTracksValueLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -267,14 +267,18 @@ QString MediaPlayer::getLoadedMRL()
return QString( str );
}
bool
MediaPlayer::hasVideoTrack()
int
MediaPlayer::getNbAudioTrack()
{
return ( libvlc_video_get_track_count( m_internalPtr, m_ex ) > 0 );
int res = libvlc_audio_get_track_count( m_internalPtr, m_ex );
CheckVlcppException( m_ex );
return res;
}
bool
MediaPlayer::hasAudioTrack()
int
MediaPlayer::getNbVideoTrack()
{
return ( libvlc_audio_get_track_count( m_internalPtr, m_ex ) > 0 );
int res = libvlc_video_get_track_count( m_internalPtr, m_ex );
CheckVlcppException( m_ex );
return res;
}
......@@ -62,8 +62,8 @@ namespace LibVLCpp
bool hasVout();
const QString& getLoadedFileName() const;
QString getLoadedMRL();
bool hasVideoTrack();
bool hasAudioTrack();
int getNbAudioTrack();
int getNbVideoTrack();
private:
static void callbacks( const libvlc_event_t* event, void* self );
......
......@@ -47,8 +47,8 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_height( 0 ),
m_fps( .0f ),
m_baseClip( NULL ),
m_hasVideo( false ),
m_hasAudio( false )
m_nbAudioTracks( 0 ),
m_nbVideoTracks( 0 )
{
if ( uuid.length() == 0 )
m_uuid = QUuid::createUuid();
......@@ -277,20 +277,37 @@ void Media::removeClip( const QUuid& uuid )
}
bool
Media::hasAudioTrack() const
Media::hasAudioTrack() const
{
return m_hasAudio;
return ( m_nbAudioTracks > 0 );
}
bool
Media::hasVideoTrack() const
{
return m_hasVideo;
return ( m_nbVideoTracks > 0);
}
void
Media::setTracksAvailable( bool video, bool audio )
Media::setNbAudioTrack( int nbTrack )
{
m_hasVideo = video;
m_hasAudio = audio;
m_nbAudioTracks = nbTrack;
}
void
Media::setNbVideoTrack( int nbTracks )
{
m_nbVideoTracks = nbTracks;
}
int
Media::getNbAudioTracks() const
{
return m_nbAudioTracks;
}
int
Media::getNbVideoTracks() const
{
return m_nbVideoTracks;
}
......@@ -116,7 +116,10 @@ public:
bool hasAudioTrack() const;
bool hasVideoTrack() const;
void setTracksAvailable( bool video, bool audio );
void setNbAudioTrack( int nbTrack );
void setNbVideoTrack( int nbTrack );
int getNbAudioTracks() const;
int getNbVideoTracks() const;
FileType getFileType() const;
static const QString VideoExtensions;
......@@ -167,8 +170,8 @@ protected:
Clip* m_baseClip;
QHash<QUuid, Clip*> m_clips;
QList<int>* m_audioValueList;
bool m_hasVideo;
bool m_hasAudio;
int m_nbAudioTracks;
int m_nbVideoTracks;
signals:
void metaDataComputed( Media* );
......
......@@ -126,8 +126,8 @@ void MetaDataWorker::metaDataAvailable()
}
m_media->setLength( m_mediaPlayer->getLength() );
m_media->setTracksAvailable( m_mediaPlayer->hasVideoTrack(),
m_mediaPlayer->hasAudioTrack() );
m_media->setNbAudioTrack( m_mediaPlayer->getNbAudioTrack() );
m_media->setNbVideoTrack( m_mediaPlayer->getNbVideoTrack() );
m_media->setNbFrames( (m_media->getLengthMS() / 1000) * m_media->getFps() );
m_media->emitMetaDataComputed();
......
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