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

Started RenderPreviewWidget, but really not fonctionnal...

Corrected crash when launching
Added render preview widget in UI
Deleted unused VLCMediaList
parent 8e9e78d4
#include <QtDebug>
#include "VLCMediaList.h"
#include "VLCInstance.h"
using namespace LibVLCpp;
MediaList::MediaList() : m_listPlayer( NULL )
{
//Initializing media list :
m_internalPtr = libvlc_media_list_new( *(Instance::getInstance()), m_exception );
CheckVlcppException(m_exception);
//Initializing list_player :
m_listPlayer = libvlc_media_list_player_new( *(Instance::getInstance()), m_exception );
CheckVlcppException(m_exception);
//Associating player with media list :
libvlc_media_list_player_set_media_list( m_listPlayer, m_internalPtr, m_exception );
CheckVlcppException(m_exception);
//Initializing event manager :
m_eventManager = libvlc_media_list_event_manager( m_internalPtr, m_exception );
CheckVlcppException(m_exception);
initWatchedEvents();
}
MediaList::~MediaList()
{
}
MediaList::Locker::Locker( MediaList::internalPtr mediaList ) : m_mediaList( mediaList )
{
libvlc_media_list_lock( mediaList );
}
MediaList::Locker::~Locker()
{
libvlc_media_list_unlock( m_mediaList );
}
void MediaList::initWatchedEvents()
{
libvlc_event_attach( m_eventManager, libvlc_MediaListItemAdded, callbacks, this, m_exception );
CheckVlcppException( m_exception );
}
void MediaList::callbacks( const libvlc_event_t* event, void* )
{
//MediaList* self = reinterpret_cast< MediaList* >( ptr );
switch ( event->type )
{
case libvlc_MediaListPlayerStopped:
qDebug() << "Playlist stopped";
break;
default:
break ;
}
}
void MediaList::addMedia( Media* media )
{
MediaList::Locker lockMediaList( m_internalPtr );
libvlc_media_list_add_media( m_internalPtr, *media, m_exception );
CheckVlcppException(m_exception);
}
void MediaList::setMediaPlayer( MediaPlayer* mp )
{
libvlc_media_list_player_set_media_player( m_listPlayer, *mp, m_exception );
CheckVlcppException(m_exception);
}
int MediaList::count()
{
MediaList::Locker lockMediaList( m_internalPtr );
int nbElems = libvlc_media_list_count( m_internalPtr, m_exception );
CheckVlcppException( m_exception );
return nbElems;
}
void MediaList::clear()
{
MediaList::Locker lockMediaList( m_internalPtr );
//Don't call MediaList::count() since it holds a lock that's already locked just above !
int nbElems = libvlc_media_list_count( m_internalPtr, m_exception );
CheckVlcppException( m_exception );
for (int i; i < nbElems; ++i)
{
libvlc_media_list_remove_index( m_internalPtr, i, m_exception );
CheckVlcppException( m_exception );
}
}
void MediaList::play()
{
libvlc_media_list_player_play( m_listPlayer, m_exception );
CheckVlcppException( m_exception );
}
void MediaList::pause()
{
libvlc_media_list_player_pause( m_listPlayer, m_exception );
CheckVlcppException( m_exception );
}
void MediaList::stop()
{
libvlc_media_list_player_stop( m_listPlayer, m_exception );
CheckVlcppException( m_exception );
}
#ifndef VLCMEDIALIST_H
#define VLCMEDIALIST_H
#include "vlc/vlc.h"
#include "VLCException.h"
#include "VLCpp.hpp"
#include "VLCMediaPlayer.h"
namespace LibVLCpp
{
class MediaList : public Internal<libvlc_media_list_t>
{
public:
class Locker
{
public:
Locker( MediaList::internalPtr mediaList );
~Locker();
private:
MediaList::internalPtr m_mediaList;
};
MediaList();
~MediaList();
void addMedia( LibVLCpp::Media* media );
void setMediaPlayer( MediaPlayer* mp );
int count();
void clear();
void play();
void pause();
void stop();
static void callbacks( const libvlc_event_t* event, void* self );
private:
void initWatchedEvents();
MediaPlayer* m_vlcMediaPlayer;
Exception m_exception;
libvlc_media_list_player_t* m_listPlayer;
libvlc_event_manager_t* m_eventManager;
};
}
#endif // VLCMEDIALIST_H
/***************************************************************************** /*****************************************************************************
* PreviewWidget.cpp: Preview widget * ClipPreviewWidget.cpp: Preview widget
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 the VLMC team * Copyright (C) 2008-2009 the VLMC team
* *
* Authors: Geoffroy Lacarrière <geoffroylaca@gmail.com> * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
#include <QObject> #include <QObject>
#include "VLCMediaPlayer.h" #include "VLCMediaPlayer.h"
#include "VLCMediaList.h"
#include "Media.h" #include "Media.h"
//TODO: This should really share a common interface with RenderPreviewWorkflow
class ClipPreviewWidget : public QObject class ClipPreviewWidget : public QObject
{ {
Q_OBJECT Q_OBJECT
......
...@@ -141,7 +141,7 @@ void MainWindow::m_initializeDockWidgets( void ) ...@@ -141,7 +141,7 @@ void MainWindow::m_initializeDockWidgets( void )
setupLibrary(); setupLibrary();
dockManager->addDockedWidget( new PreviewWidget( this ), dockManager->addDockedWidget( new PreviewWidget( m_timeline->getMainWorkflow(), this ),
tr( "Preview" ), tr( "Preview" ),
Qt::AllDockWidgetAreas, Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures, QDockWidget::AllDockWidgetFeatures,
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "MediaListWidget.h" #include "MediaListWidget.h"
#include "Library.h" #include "Library.h"
PreviewWidget::PreviewWidget( QWidget *parent ) : PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
QWidget( parent ), QWidget( parent ),
m_ui( new Ui::PreviewWidget ), m_previewStopped( true ) m_ui( new Ui::PreviewWidget ), m_previewStopped( true )
{ {
...@@ -45,7 +45,12 @@ PreviewWidget::PreviewWidget( QWidget *parent ) : ...@@ -45,7 +45,12 @@ PreviewWidget::PreviewWidget( QWidget *parent ) :
connect( m_ui->seekSlider, SIGNAL( sliderPosChanged(int) ), this, SLOT( seekSliderMoved(int) ) ); connect( m_ui->seekSlider, SIGNAL( sliderPosChanged(int) ), this, SLOT( seekSliderMoved(int) ) );
connect( m_ui->seekSlider, SIGNAL( sliderReleased() ), this, SLOT( seekSliderReleased() ) ); connect( m_ui->seekSlider, SIGNAL( sliderReleased() ), this, SLOT( seekSliderReleased() ) );
m_clipPreview = new ClipPreviewWidget( m_ui->clipRenderWidget ); m_clipPreview = new ClipPreviewWidget( m_ui->clipPreviewRenderWidget );
m_renderPreview = new RenderPreviewWidget( mainWorkflow, m_ui->renderPreviewRenderWidget );
m_currentMode = m_ui->tabWidget->currentIndex();
qDebug() << "m_currentMode = " << m_currentMode;
connect( m_ui->tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( changedTab(int) ) );
} }
PreviewWidget::~PreviewWidget() PreviewWidget::~PreviewWidget()
...@@ -75,25 +80,28 @@ void PreviewWidget::dragEnterEvent( QDragEnterEvent* event ) ...@@ -75,25 +80,28 @@ void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
void PreviewWidget::dropEvent( QDropEvent* event ) void PreviewWidget::dropEvent( QDropEvent* event )
{ {
Media* media; if ( m_currentMode == PreviewWidget::clipPreviewMode )
if ( event->mimeData()->urls().count() == 1 )
{ {
Library* lib = Library::getInstance(); Media* media;
lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() ); if ( event->mimeData()->urls().count() == 1 )
media = lib->getMedia( event->mimeData()->urls()[0].path() ); {
Library* lib = Library::getInstance();
lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() );
media = lib->getMedia( event->mimeData()->urls()[0].path() );
}
else
media = Library::getInstance()->getMedia( QUuid( ( const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
connect( m_clipPreview, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_clipPreview, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( m_clipPreview, SIGNAL( endReached() ), this, SLOT( endReached() ) );
m_clipPreview->startPreview( media );
event->acceptProposedAction();
m_previewStopped = false;
} }
else
media = Library::getInstance()->getMedia( QUuid( ( const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
connect( m_clipPreview, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_clipPreview, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( m_clipPreview, SIGNAL( endReached() ), this, SLOT( endReached() ) );
m_clipPreview->startPreview( media );
event->acceptProposedAction();
m_previewStopped = false;
} }
void PreviewWidget::positionChanged( float newPos ) void PreviewWidget::positionChanged( float newPos )
...@@ -157,3 +165,8 @@ void PreviewWidget::endReached() ...@@ -157,3 +165,8 @@ void PreviewWidget::endReached()
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) ); m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
m_ui->seekSlider->setValue( 0 ); m_ui->seekSlider->setValue( 0 );
} }
void PreviewWidget::changedTab( int tabId )
{
qDebug() << "CHanged mode : " << tabId;
}
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
#define PREVIEWWIDGET_H #define PREVIEWWIDGET_H
#include <QWidget> #include <QWidget>
#include "Workflow/MainWorkflow.h"
#include "ClipPreviewWidget.h" #include "ClipPreviewWidget.h"
#include "RenderPreviewWidget.h"
namespace Ui { namespace Ui {
class PreviewWidget; class PreviewWidget;
...@@ -37,14 +39,19 @@ class PreviewWidget : public QWidget ...@@ -37,14 +39,19 @@ class PreviewWidget : public QWidget
Q_DISABLE_COPY( PreviewWidget ) Q_DISABLE_COPY( PreviewWidget )
public: public:
explicit PreviewWidget( QWidget* parent = NULL ); explicit PreviewWidget( MainWorkflow* mainWorkflow, QWidget* parent = NULL );
virtual ~PreviewWidget(); virtual ~PreviewWidget();
private: private:
Ui::PreviewWidget* m_ui; Ui::PreviewWidget* m_ui;
ClipPreviewWidget* m_clipPreview; ClipPreviewWidget* m_clipPreview;
RenderPreviewWidget* m_renderPreview;
bool m_endReached; bool m_endReached;
bool m_previewStopped; bool m_previewStopped;
int m_currentMode;
static const int clipPreviewMode = 0;
static const int renderPreviewMode = 1;
protected: protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
...@@ -59,6 +66,8 @@ private slots: ...@@ -59,6 +66,8 @@ private slots:
void videoPaused(); void videoPaused();
void videoPlaying(); void videoPlaying();
void endReached(); void endReached();
void changedTab( int );
}; };
#endif // PREVIEWWIDGET_H #endif // PREVIEWWIDGET_H
/*****************************************************************************
* RenderPreviewWidget.cpp: Allow a current workflow preview
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "RenderPreviewWidget.h"
RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
m_mainWorkflow( mainWorkflow )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
RenderPreviewWidget::~RenderPreviewWidget()
{
delete m_mediaPlayer;
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
void RenderPreviewWidget::__endReached()
{
qDebug() << "RenderPreviewWidget::__endReached : unimplemented";
}
void RenderPreviewWidget::__positionChanged()
{
qDebug() << "RenderPreviewWidget::__positionChanged: Unimplemented";
}
void RenderPreviewWidget::__videoPaused()
{
qDebug() << "RenderPreviewWidget::__videoPaused: Unimplemented";
}
void RenderPreviewWidget::__videoPlaying()
{
qDebug() << "RenderPreviewWidget::__videoPlaying: Unimplemented";
}
/*****************************************************************************
* RenderPreviewWidget.h: Allow a current workflow preview
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef RENDERPREVIEWWIDGET_H
#define RENDERPREVIEWWIDGET_H
#include <QObject>
#include <QWidget>
#include <QtDebug>
#include "VLCMediaPlayer.h"
#include "Workflow/MainWorkflow.h"
//TODO: This should really share a common interface with ClipPreviewWorkflow
class RenderPreviewWidget : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( RenderPreviewWidget )
public:
RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget );
~RenderPreviewWidget();
void startPreview();
void setPosition( float newPos );
void togglePlayPause();
private:
MainWorkflow* m_mainWorkflow;
LibVLCpp::MediaPlayer* m_mediaPlayer;
public slots:
void __positionChanged();
void __videoPaused();
void __videoPlaying();
void __endReached();
signals:
void stopped();
void paused();
void playing();
void positionChanged( float );
void endReached();
};
#endif // RENDERPREVIEWWIDGET_H
...@@ -35,8 +35,9 @@ class Timeline : public QWidget ...@@ -35,8 +35,9 @@ class Timeline : public QWidget
Q_DISABLE_COPY( Timeline ) Q_DISABLE_COPY( Timeline )
public: public:
explicit Timeline( QWidget *parent = 0 ); explicit Timeline( QWidget *parent = 0 );
TracksView* tracksView() { return m_tracksView; } TracksView* tracksView() { return m_tracksView; }
TracksScene* tracksScene() { return m_tracksScene; } TracksScene* tracksScene() { return m_tracksScene; }
MainWorkflow* getMainWorkflow() { return m_mainWorkflow; }
public slots: public slots:
void changeZoom( int factor ); void changeZoom( int factor );
......
...@@ -47,12 +47,17 @@ ...@@ -47,12 +47,17 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="ProjectTab"> <widget class="QWidget" name="ProjectTab">
<attribute name="title"> <attribute name="title">
<string>Project</string> <string>Project</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QWidget" name="renderPreviewRenderWidget" native="true"/>
</item>
</layout>
</widget> </widget>
<widget class="QWidget" name="ClipTab"> <widget class="QWidget" name="ClipTab">
<attribute name="title"> <attribute name="title">
...@@ -60,7 +65,7 @@ ...@@ -60,7 +65,7 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QWidget" name="clipRenderWidget" native="true"/> <widget class="QWidget" name="clipPreviewRenderWidget" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
......
...@@ -31,7 +31,6 @@ SOURCES += src/main.cpp \ ...@@ -31,7 +31,6 @@ SOURCES += src/main.cpp \
src/gui/Transcode.cpp \ src/gui/Transcode.cpp \
src/gui/Slider.cpp \ src/gui/Slider.cpp \
src/MetaDataManager.cpp \ src/MetaDataManager.cpp \
src/LibVLCpp/VLCMediaList.cpp \
src/Library.cpp \ src/Library.cpp \
src/gui/GraphicsMovieItem.cpp \ src/gui/GraphicsMovieItem.cpp \
src/gui/AbstractGraphicsMediaItem.cpp \ src/gui/AbstractGraphicsMediaItem.cpp \
...@@ -43,7 +42,8 @@ SOURCES += src/main.cpp \ ...@@ -43,7 +42,8 @@ SOURCES += src/main.cpp \
src/Workflow/ClipWorkflow.cpp \ src/Workflow/ClipWorkflow.cpp \
src/Workflow/TrackWorkflow.cpp \ src/Workflow/TrackWorkflow.cpp \
src/Workflow/MainWorkflow.cpp \ src/Workflow/MainWorkflow.cpp \
src/gui/PreviewWidget.cpp src/gui/PreviewWidget.cpp \
src/gui/RenderPreviewWidget.cpp
HEADERS += src/gui/MainWindow.h \ HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \ src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \ src/gui/LibraryWidget.h \
...@@ -66,7 +66,6 @@ HEADERS += src/gui/MainWindow.h \ ...@@ -66,7 +66,6 @@ HEADERS += src/gui/MainWindow.h \
src/gui/Transcode.h \ src/gui/Transcode.h \
src/gui/Slider.h \ src/gui/Slider.h \
src/MetaDataManager.h \ src/MetaDataManager.h \
src/LibVLCpp/VLCMediaList.h \
src/Singleton.hpp \ src/Singleton.hpp \
src/Library.h \ src/Library.h \
src/gui/AbstractGraphicsMediaItem.h \ src/gui/AbstractGraphicsMediaItem.h \
...@@ -79,7 +78,8 @@ HEADERS += src/gui/MainWindow.h \ ...@@ -79,7 +78,8 @@ HEADERS += src/gui/MainWindow.h \
src/Workflow/ClipWorkflow.h \ src/Workflow/ClipWorkflow.h \
src/Workflow/TrackWorkflow.h \ src/Workflow/TrackWorkflow.h \
src/Workflow/MainWorkflow.h \ src/Workflow/MainWorkflow.h \
src/gui/PreviewWidget.h src/gui/PreviewWidget.h \
src/gui/RenderPreviewWidget.h
FORMS += src/gui/ui/MainWindow.ui \ FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \ src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \ src/gui/ui/Preferences.ui \
......
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