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

Code cosmetic for snapshot generation

parent bebe174e
......@@ -72,32 +72,17 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
MediaPlayer* self = reinterpret_cast<MediaPlayer*>( ptr );
switch ( event->type )
{
// case libvlc_MediaMetaChanged:
// case libvlc_MediaSubItemAdded:
// case libvlc_MediaDurationChanged:
// case libvlc_MediaPreparsedChanged:
// case libvlc_MediaFreed:
// case libvlc_MediaStateChanged:
// case libvlc_MediaPlayerNothingSpecial:
// case libvlc_MediaPlayerOpening:
// case libvlc_MediaPlayerBuffering:
case libvlc_MediaPlayerPlaying:
qDebug() << "Playing event";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
// qDebug() << "Paused event";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
// qDebug() << "Stopped event";
self->emit stopped();
// case libvlc_MediaPlayerForward:
// case libvlc_MediaPlayerBackward:
break;
case libvlc_MediaPlayerEndReached:
self->emit endReached();
// case libvlc_MediaPlayerEncounteredError:
break;
case libvlc_MediaPlayerTimeChanged:
//self->timeChangedFilter();
......@@ -109,26 +94,20 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
case libvlc_MediaPlayerLengthChanged:
self->emit lengthChanged();
break;
// case libvlc_MediaPlayerSeekableChanged:
// case libvlc_MediaPlayerPausableChanged:
// case libvlc_MediaListItemAdded:
// case libvlc_MediaListWillAddItem:
// case libvlc_MediaListItemDeleted:
// case libvlc_MediaListWillDeleteItem:
// case libvlc_MediaListViewItemAdded:
// case libvlc_MediaListViewWillAddItem:
// case libvlc_MediaListViewItemDeleted:
// case libvlc_MediaListViewWillDeleteItem:
// case libvlc_MediaListPlayerPlayed:
// case libvlc_MediaListPlayerNextItemSet:
// case libvlc_MediaListPlayerStopped:
// case libvlc_MediaDiscovererStarted:
// case libvlc_MediaDiscovererEnded:
// case libvlc_MediaPlayerTitleChanged:
case libvlc_MediaPlayerSnapshotTaken:
self->emit snapshotTaken();
break;
case libvlc_MediaPlayerSeekableChanged:
case libvlc_MediaPlayerPausableChanged:
case libvlc_MediaPlayerTitleChanged:
case libvlc_MediaPlayerNothingSpecial:
case libvlc_MediaPlayerOpening:
case libvlc_MediaPlayerBuffering:
case libvlc_MediaPlayerForward:
case libvlc_MediaPlayerBackward:
case libvlc_MediaPlayerEncounteredError:
default:
qDebug() << "Unknown mediaPlayerEvent: " << event->type;
break;
}
}
......@@ -185,7 +164,7 @@ qint64 MediaPlayer::getLength()
return length;
}
void MediaPlayer::takeSnapshot( char* outputFile, unsigned int width, unsigned int heigth )
void MediaPlayer::takeSnapshot( const char* outputFile, unsigned int width, unsigned int heigth )
{
libvlc_video_take_snapshot( *this, outputFile, width, heigth, m_ex );
CheckVlcppException( m_ex );
......
......@@ -48,7 +48,7 @@ namespace LibVLCpp
float getPosition();
void setPosition( float pos );
qint64 getLength();
void takeSnapshot( char* outputFile, unsigned int width, unsigned int heigth );
void takeSnapshot( const char* outputFile, unsigned int width, unsigned int heigth );
bool isPlaying();
bool isSeekable();
void setDrawable( void* hwnd );
......
......@@ -34,7 +34,6 @@ MetaDataManager::MetaDataManager() : m_renderWidget( NULL ),
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
connect( Library::getInstance(), SIGNAL( newMediaLoaded( Media* ) ),this, SLOT( newMediaLoaded( Media* ) ) );
m_tmpSnapshotFilename = new char[512];
m_renderWidget = new QWidget();
m_mediaPlayer->setDrawable( m_renderWidget->winId() );
}
......@@ -45,7 +44,6 @@ MetaDataManager::~MetaDataManager()
delete m_mediaPlayer;
if (m_renderWidget)
delete m_renderWidget;
delete[] m_tmpSnapshotFilename;
}
void MetaDataManager::newMediaLoaded( Media* item )
......@@ -86,7 +84,6 @@ void MetaDataManager::run()
void MetaDataManager::getMetaData()
{
qDebug() << "Entering getMetaData()";
m_mediaIsPlaying = false;
m_lengthHasChanged = false;
......@@ -106,13 +103,13 @@ void MetaDataManager::renderSnapshot()
QTemporaryFile tmp;
tmp.setAutoRemove( false );
tmp.open();
strncpy(m_tmpSnapshotFilename, tmp.fileName().toStdString().c_str(), tmp.fileName().length());
m_tmpSnapshotFilename = tmp.fileName();
connect( m_mediaPlayer, SIGNAL( snapshotTaken() ), this, SLOT( setSnapshot() ) );
//The slot should be triggered in this methode
m_mediaPlayer->takeSnapshot( m_tmpSnapshotFilename, 32, 32 );
m_mediaPlayer->takeSnapshot( m_tmpSnapshotFilename.toStdString().c_str()
, 32, 32 );
//Snapshot slot should has been called (but maybe not in next version...)
}
......@@ -123,6 +120,10 @@ void MetaDataManager::setSnapshot()
delete pixmap;
else
m_currentClip->setSnapshot( pixmap );
//TODO : we shouldn't have to do this... patch vlc to get a memory snapshot.
QFile tmp( m_tmpSnapshotFilename );
tmp.remove();
disconnect( m_mediaPlayer, SIGNAL( snapshotTaken() ), this, SLOT( setSnapshot() ) );
//CHECKME:
......
......@@ -76,7 +76,7 @@ class MetaDataManager : public QThread, public Singleton<MetaDataManager>
bool m_nextMedia;
Media* m_currentClip;
//FIXME: Won't work in asynchrone mode
char* m_tmpSnapshotFilename;
QString m_tmpSnapshotFilename;
bool m_mediaIsPlaying;
bool m_lengthHasChanged;
......
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