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

Remove metadata from Media class and expose it through the source.

parent 2a013d21
......@@ -28,6 +28,7 @@
#include "Clip.h"
#include "ClipMetadataDisplayer.h"
#include "ClipRenderer.h"
#include "ISource.h"
#include "Library.h"
#include "Media.h"
#include "MediaCellView.h"
......@@ -238,7 +239,7 @@ ImportController::accept()
collapseAllButCurrentPath();
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
{
if ( clip->getMedia()->lengthMS() == 0 && clip->getMedia()->inputType() == Media::File )
if ( clip->getMedia()->source()->length() == 0 && clip->getMedia()->inputType() == Media::File )
invalidMedias = true;
Library::getInstance()->addClip( clip );
}
......@@ -260,7 +261,7 @@ ImportController::handleInvalidMedias()
{
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
{
if ( clip->getMedia()->lengthMS() == 0 && clip->getMedia()->inputType() == Media::File )
if ( clip->getMedia()->source()->length() == 0 && clip->getMedia()->inputType() == Media::File )
{
Transcoder *transcoder = new Transcoder( clip->getMedia() );
connect( transcoder, SIGNAL( done() ), transcoder, SLOT( deleteLater() ) );
......
......@@ -26,6 +26,7 @@
#include "Clip.h"
#include "ClipProperty.h"
#include "ISource.h"
#include "Library.h"
#include "Media.h"
#include "MetaDataManager.h"
......@@ -98,7 +99,7 @@ MediaCellView::metadataComputingStarted( const Media *media )
void
MediaCellView::metadataUpdated( const Media *media )
{
setLength( media->lengthMS() );
setLength( media->source()->length() );
m_ui->thumbnail->setEnabled( true );
//If the media is a Video or an Image, we must wait for the snapshot to be computer
//before allowing deletion.
......
......@@ -23,6 +23,7 @@
#include "ClipMetadataDisplayer.h"
#include "Clip.h"
#include "ISource.h"
#include "Media.h"
#include <QTime>
......@@ -41,19 +42,20 @@ ClipMetadataDisplayer::metadataUpdated( const Media *media )
QTime duration;
duration = duration.addSecs( m_watchedClip->lengthSecond() );
const Backend::ISource* source = media->source();
updateInterface();
//Duration
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( media->fileInfo()->fileName() );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( media->width() )
+ " x " + QString::number( media->height() ) );
m_ui->resolutionValueLabel->setText( QString::number( source->width() )
+ " x " + QString::number( source->height() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( media->fps() ) );
m_ui->fpsValueLabel->setText( QString::number( source->fps() ) );
//nb tracks :
m_ui->nbVideoTracksValueLabel->setText( QString::number( media->nbVideoTracks() ) );
m_ui->nbAudioTracksValueLabel->setText( QString::number( media->nbAudioTracks() ) );
m_ui->nbVideoTracksValueLabel->setText( QString::number( source->nbVideoTracks() ) );
m_ui->nbAudioTracksValueLabel->setText( QString::number( source->nbAudioTracks() ) );
//Path:
m_ui->pathValueLabel->setText( media->fileInfo()->absoluteFilePath() );
//Workspace:
......@@ -118,8 +120,9 @@ ClipMetadataDisplayer::workspaceStateChanged( bool state )
void
ClipMetadataDisplayer::updateInterface()
{
m_ui->fpsLabel->setVisible( m_watchedMedia->hasVideoTrack() );
m_ui->fpsValueLabel->setVisible( m_watchedMedia->hasVideoTrack() );
m_ui->resolutionLabel->setVisible( m_watchedMedia->hasVideoTrack() );
m_ui->resolutionValueLabel->setVisible( m_watchedMedia->hasVideoTrack() );
bool visible = m_watchedMedia->source()->hasVideo();
m_ui->fpsLabel->setVisible( visible );
m_ui->fpsValueLabel->setVisible( visible );
m_ui->resolutionLabel->setVisible( visible );
m_ui->resolutionValueLabel->setVisible( visible );
}
......@@ -24,6 +24,7 @@
#include "GraphicsAudioItem.h"
#include "ClipHelper.h"
#include "ISource.h"
#include "Media.h"
#include "TracksView.h"
#include "Timeline.h"
......@@ -37,7 +38,7 @@
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) :
AbstractGraphicsMediaItem( clip )
{
QTime length = QTime().addMSecs( clip->getMedia()->lengthMS() );
QTime length = QTime().addMSecs( clip->getMedia()->source()->length() );
QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
"<br><b>Length:</b> %2" )
.arg( clip->getMedia()->fileName() )
......@@ -50,7 +51,7 @@ GraphicsAudioItem::GraphicsAudioItem( ClipHelper* ch ) :
{
setFlags( QGraphicsItem::ItemIsSelectable );
QTime length = QTime().addMSecs( ch->clip()->getMedia()->lengthMS() );
QTime length = QTime().addMSecs( ch->clip()->getMedia()->source()->length() );
QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
"<br><b>Length:</b> %2" )
.arg( ch->clip()->getMedia()->fileName() )
......
......@@ -23,6 +23,7 @@
#include "Clip.h"
#include "ClipHelper.h"
#include "GraphicsMovieItem.h"
#include "ISource.h"
#include "Media.h"
#include "TracksView.h"
#include "Timeline.h"
......@@ -36,7 +37,7 @@
GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) :
AbstractGraphicsMediaItem( clip )
{
QTime length = QTime().addMSecs( clip->getMedia()->lengthMS() );
QTime length = QTime().addMSecs( clip->getMedia()->source()->length() );
QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
"<br><b>Length:</b> %2" )
.arg( clip->getMedia()->fileName() )
......@@ -47,7 +48,7 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) :
GraphicsMovieItem::GraphicsMovieItem( ClipHelper* ch ) :
AbstractGraphicsMediaItem( ch )
{
QTime length = QTime().addMSecs( ch->clip()->getMedia()->lengthMS() );
QTime length = QTime().addMSecs( ch->clip()->getMedia()->source()->length() );
QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
"<br><b>Length:</b> %2" )
.arg( ch->clip()->getMedia()->fileName() )
......
......@@ -32,6 +32,7 @@
#include "GraphicsCursorItem.h"
#include "GraphicsTrack.h"
#include "Helper.h"
#include "ISource.h"
#include "Library.h"
#include "Media.h"
//Ugly part {
......@@ -374,14 +375,17 @@ TracksView::clipDragEnterEvent( QDragEnterEvent *event )
{
const QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
Clip *clip = Library::getInstance()->clip( fullId );
if ( !clip ) return;
if ( clip->getMedia()->hasAudioTrack() == false &&
clip->getMedia()->hasVideoTrack() == false )
if ( clip == NULL )
return;
bool hasVideo = clip->getMedia()->source()->hasVideo();
bool hasAudio = clip->getMedia()->source()->hasAudio();
if ( hasAudio == false && hasVideo == false )
return ;
if ( clip->getMedia()->hasAudioTrack() == true )
if ( hasAudio == true )
{
if ( m_dragAudioItem ) delete m_dragAudioItem;
if ( m_dragAudioItem )
delete m_dragAudioItem;
m_dragAudioItem = new GraphicsAudioItem( clip );
m_dragAudioItem->m_tracksView = this;
m_dragAudioItem->setHeight( m_dragAudioItem->itemHeight() );
......@@ -389,9 +393,10 @@ TracksView::clipDragEnterEvent( QDragEnterEvent *event )
connect( m_dragAudioItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
if ( clip->getMedia()->hasVideoTrack() == true )
if ( hasVideo == true )
{
if ( m_dragVideoItem ) delete m_dragVideoItem;
if ( m_dragVideoItem )
delete m_dragVideoItem;
m_dragVideoItem = new GraphicsMovieItem( clip );
m_dragVideoItem->m_tracksView = this;
m_dragVideoItem->setHeight( m_dragVideoItem->itemHeight() );
......@@ -400,10 +405,9 @@ TracksView::clipDragEnterEvent( QDragEnterEvent *event )
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
// Group the items together
if ( clip->getMedia()->hasAudioTrack() == true &&
clip->getMedia()->hasVideoTrack() == true )
if ( hasVideo == true && hasAudio == true )
m_dragVideoItem->group( m_dragAudioItem );
if ( clip->getMedia()->hasVideoTrack() == false )
if ( hasVideo == false )
moveItem( m_dragAudioItem, event->pos() );
else
moveItem( m_dragVideoItem, event->pos() );
......
......@@ -25,6 +25,7 @@
*/
#include "Clip.h"
#include "ISource.h"
#include "Library.h"
#include "Media.h"
#include "Workspace.h"
......@@ -107,7 +108,7 @@ Clip::computeLength()
{
if ( m_media->inputType() == Media::File )
{
float fps = m_media->fps();
float fps = m_media->source()->fps();
if ( fps < 0.1f )
fps = Clip::DefaultFPS;
m_length = m_end - m_begin;
......
......@@ -54,14 +54,8 @@ const QString Media::streamPrefix = "stream://";
Media::Media(const QString &path ) :
m_fileInfo( NULL ),
m_lengthMS( 0 ),
m_nbFrames( 0 ),
m_width( 0 ),
m_height( 0 ),
m_fps( .0f ),
m_baseClip( NULL ),
m_nbAudioTracks( 0 ),
m_nbVideoTracks( 0 ),
m_metadataComputed( false ),
m_inWorkspace( false )
{
......@@ -98,54 +92,6 @@ Media::fileInfo() const
return m_fileInfo;
}
void
Media::setLength( qint64 length )
{
m_lengthMS = length;
}
qint64
Media::lengthMS() const
{
return m_lengthMS;
}
int
Media::width() const
{
return m_width;
}
void
Media::setWidth( int width )
{
m_width = width;
}
int
Media::height() const
{
return m_height;
}
void
Media::setHeight( int height )
{
m_height = height;
}
float
Media::fps() const
{
return m_fps;
}
void
Media::setFps( float fps )
{
m_fps = fps;
}
Media::FileType
Media::fileType() const
{
......@@ -200,40 +146,10 @@ Media::source()
return m_source;
}
bool
Media::hasAudioTrack() const
{
return ( m_nbAudioTracks > 0 );
}
bool
Media::hasVideoTrack() const
{
return ( m_nbVideoTracks > 0 );
}
void
Media::setNbAudioTrack( int nbTrack )
{
m_nbAudioTracks = nbTrack;
}
void
Media::setNbVideoTrack( int nbTracks )
{
m_nbVideoTracks = nbTracks;
}
int
Media::nbAudioTracks() const
{
return m_nbAudioTracks;
}
int
Media::nbVideoTracks() const
const Backend::ISource*
Media::source() const
{
return m_nbVideoTracks;
return m_source;
}
bool
......
......@@ -85,7 +85,8 @@ public:
const QFileInfo *fileInfo() const;
const QString &mrl() const;
const QString &fileName() const;
Backend::ISource* source();
Backend::ISource *source();
const Backend::ISource *source() const;
/**
* \brief Set this media's path.
*
......@@ -93,38 +94,10 @@ public:
*/
void setFilePath( const QString& path );
/**
\return Returns the length of this media (ie the
video duration) in milliseconds.
*/
qint64 lengthMS() const;
/**
\brief This methods is most of an entry point for the
MetadataManager than enything else.
If you use it to set a inconsistant media length
you'll just have to blame yourself !
*/
void setLength( qint64 length );
void setNbFrames( qint64 nbFrames );
int width() const;
void setWidth( int width );
int height() const;
void setHeight( int height );
float fps() const;
void setFps( float fps );
qint64 nbFrames() const;
bool hasAudioTrack() const;
bool hasVideoTrack() const;
void setNbAudioTrack( int nbTrack );
void setNbVideoTrack( int nbTrack );
int nbAudioTracks() const;
int nbVideoTracks() const;
FileType fileType() const;
void setFileType( FileType type );
......@@ -156,17 +129,11 @@ protected:
Backend::ISource* m_source;
QString m_mrl;
QFileInfo* m_fileInfo;
qint64 m_lengthMS;
qint64 m_nbFrames;
unsigned int m_width;
unsigned int m_height;
float m_fps;
FileType m_fileType;
InputType m_inputType;
QString m_fileName;
Clip* m_baseClip;
int m_nbAudioTracks;
int m_nbVideoTracks;
bool m_metadataComputed;
bool m_inWorkspace;
QString m_workspacePath;
......
......@@ -177,7 +177,7 @@ ClipRenderer::previousFrame()
if ( m_paused == false )
togglePlayPause( true );
/* FIXME: Implement a better way to render previous frame */
qint64 interval = static_cast<qint64>( qCeil(1000.0f * 2.0f / m_selectedClip->getMedia()->fps() ) );
qint64 interval = static_cast<qint64>( qCeil(1000.0f * 2.0f / m_selectedClip->getMedia()->source()->fps() ) );
m_sourceRenderer->setTime( m_sourceRenderer->time() - interval );
m_sourceRenderer->nextFrame();
}
......@@ -193,7 +193,7 @@ qint64
ClipRenderer::getLengthMs() const
{
if ( m_selectedClip )
return ( qRound64( (qreal)( m_end - m_begin ) / m_selectedClip->getMedia()->fps() * 1000.0 ) );
return ( qRound64( (qreal)( m_end - m_begin ) / m_selectedClip->getMedia()->source()->fps() * 1000.0 ) );
return 0;
}
......@@ -216,14 +216,14 @@ ClipRenderer::getCurrentFrame() const
if ( m_clipLoaded == false || m_isRendering == false || m_selectedClip == NULL )
return 0;
return qRound64( (qreal)m_sourceRenderer->time() / 1000 *
(qreal)m_selectedClip->getMedia()->fps() );
(qreal)m_selectedClip->getMedia()->source()->fps() );
}
float
ClipRenderer::getFps() const
{
if ( m_selectedClip != NULL )
return m_selectedClip->getMedia()->fps();
return m_selectedClip->getMedia()->source()->fps();
return 0.0f;
}
......@@ -239,7 +239,7 @@ ClipRenderer::previewWidgetCursorChanged( qint64 newFrame )
if ( m_isRendering == true )
{
newFrame += m_begin;
qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedClip->getMedia()->fps() );
qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedClip->getMedia()->source()->fps() );
m_sourceRenderer->setTime( nbSeconds * 1000 );
}
}
......@@ -260,7 +260,7 @@ ClipRenderer::__videoStopped()
void
ClipRenderer::__timeChanged( qint64 time )
{
float fps = m_selectedClip->getMedia()->fps();
float fps = m_selectedClip->getMedia()->source()->fps();
qint64 f = qRound64( (qreal)time / 1000.0 * fps );
if ( f >= m_end )
return ;
......
......@@ -103,7 +103,7 @@ ClipWorkflow::adjustBegin()
m_clipHelper->clip()->getMedia()->fileType() == Media::Audio )
{
m_renderer->setTime( m_clipHelper->begin() /
m_clipHelper->clip()->getMedia()->fps() * 1000 );
m_clipHelper->clip()->getMedia()->source()->fps() * 1000 );
}
}
......
......@@ -26,6 +26,7 @@
#include "ImageClipWorkflow.h"
#include "Clip.h"
#include "ClipHelper.h"
#include "ISource.h"
#include "ISourceRenderer.h"
#include "MainWorkflow.h"
#include "Media.h"
......@@ -74,7 +75,7 @@ ImageClipWorkflow::getOutput( ClipWorkflow::GetMode, qint64 currentFrame )
QMutexLocker lock( m_renderLock );
quint32 *buff = applyFilters( m_buffer, currentFrame,
currentFrame * 1000.0 / clip()->getMedia()->fps() );
currentFrame * 1000.0 / clip()->getMedia()->source()->fps() );
if ( buff != NULL )
{
m_effectFrame->setBuffer( buff );
......
......@@ -29,6 +29,7 @@
#include "EffectInstance.h"
#include "EffectHelper.h"
#include "ImageClipWorkflow.h"
#include "ISource.h"
#include "MainWorkflow.h"
#include "Media.h"
#include "Types.h"
......@@ -507,8 +508,9 @@ TrackWorkflow::clear()
void
TrackWorkflow::adjustClipTime( qint64 currentFrame, qint64 start, ClipWorkflow* cw )
{
qint64 nbMs = ( currentFrame - start ) / cw->clip()->getMedia()->fps() * 1000;
qint64 beginInMs = cw->getClipHelper()->begin() / cw->clip()->getMedia()->fps() * 1000;
float fps = cw->clip()->getMedia()->source()->fps();
qint64 nbMs = ( currentFrame - start ) / fps * 1000;
qint64 beginInMs = cw->getClipHelper()->begin() / fps * 1000;
qint64 startFrame = beginInMs + nbMs;
cw->setTime( startFrame );
}
......
......@@ -24,6 +24,7 @@
#include "EffectInstance.h"
#include "MainWorkflow.h"
#include "Media.h"
#include "ISource.h"
#include "ISourceRenderer.h"
#include "SettingsManager.h"
#include "VideoClipWorkflow.h"
......@@ -119,7 +120,7 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame )
buff = m_computedBuffers.head();
quint32 *newFrame = applyFilters( buff, currentFrame,
currentFrame * 1000.0 / clip()->getMedia()->fps() );
currentFrame * 1000.0 / clip()->getMedia()->source()->fps() );
if ( newFrame != NULL )
buff->setBuffer( newFrame );
......
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