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

Corrected MetaDataManager (invalid disconnect) - Started AMEM implementation

parent 2d1ddf57
......@@ -68,6 +68,7 @@ void Clip::flushParameters()
QString param;
foreach ( param, m_parameters )
m_vlcMedia->addOption( param.toStdString().c_str() );
m_parameters.clear();
}
void Clip::addParam( const QString& param )
......
......@@ -81,6 +81,7 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
// case libvlc_MediaPlayerOpening:
// case libvlc_MediaPlayerBuffering:
case libvlc_MediaPlayerPlaying:
qDebug() << "Playing event";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
......
......@@ -36,6 +36,7 @@ void MetaDataManager::run()
{
if ( m_nextMedia )
{
qDebug() << "Laucnhing thread for a new video";
m_nextMedia = false;
m_currentClip = m_mediaList.front();
......@@ -59,7 +60,8 @@ void MetaDataManager::run()
void MetaDataManager::getMetaData()
{
disconnect( this, SLOT( getMetaData() ) );
qDebug() << "getMetaData";
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( getMetaData() ) );
m_nextMedia = true;
m_currentClip->setLength( m_mediaPlayer->getLength() );
......@@ -73,7 +75,8 @@ void MetaDataManager::getMetaData()
void MetaDataManager::renderSnapshot()
{
disconnect( this, SLOT( renderSnapshot() ) );
qDebug() << "Rendering snapshot";
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
QTemporaryFile tmp;
tmp.setAutoRemove( false );
tmp.open();
......@@ -89,34 +92,69 @@ void MetaDataManager::renderSnapshot()
void MetaDataManager::setSnapshot()
{
qDebug() << "Setting snapshot";
QPixmap* pixmap = new QPixmap( m_tmpSnapshotFilename );
if ( pixmap->isNull() )
delete pixmap;
else
m_currentClip->setSnapshot( pixmap );
disconnect( this, SLOT( setSnapshot() ) );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( startAudioDataParsing() ) );
disconnect( m_mediaPlayer, SIGNAL( snapshotTaken() ), this, SLOT( setSnapshot() ) );
//CHECKME:
//This is synchrone, but it may become asynchrone in the future...
//connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( startAudioDataParsing() ) );
qDebug() << "Stopping playback";
m_mediaPlayer->stop();
startAudioDataParsing();
}
void MetaDataManager::startAudioDataParsing()
{
qDebug() << "Starting audio parsing";
char osb[64], psb[64], csb[64], iph[64], data[64];
disconnect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( startAudioDataParsing() ) );
//Deactivating video, so that real time doesn't matter
m_currentClip->addParam( ":no-video" );
sprintf( osb, ":amem-opensb=%lld", (long long int)(intptr_t) &MetaDataManager::openSoundBuffer);
sprintf( psb, ":amem-playsb=%lld", (long long int)(intptr_t) &MetaDataManager::playSoundBuffer);
sprintf( csb, ":amem-closesb=%lld", (long long int)(intptr_t) &MetaDataManager::closeSoundBuffer);
sprintf( iph, ":amem-iph=%lld", (long long int)(intptr_t) &MetaDataManager::instanceParameterHandler);
sprintf( data, ":amem-data=%lld", (long long int)(intptr_t) this);
// m_currentClip->addParam( ":no-video" );
// m_currentClip->addParam( ":audio" );
m_currentClip->addParam( ":aout=amem" );
m_currentClip->addParam( osb );
m_currentClip->addParam( psb );
m_currentClip->addParam( csb );
m_currentClip->addParam( iph );
m_currentClip->addParam( data );
m_currentClip->flushParameters();
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( audioDataParsingStarted() ) );
qDebug() << "Starting playback again";
m_mediaPlayer->play();
//Restoring the clip at a correct value.
m_currentClip->addParam( ":video" );
// m_currentClip->addParam( ":video" );
}
void MetaDataManager::openSoundBuffer( void* datas, unsigned int* freq, unsigned int* nbChannels, unsigned int* fourCCFormat, unsigned int* frameSize )
{
qDebug() << "Opening sound buffer with freq =" << freq;
}
void MetaDataManager::playSoundBuffer( void* datas, unsigned char* buffer, size_t buffSize, unsigned int nbSample )
{
// qDebug() << "Playing sound buffer with nbSample =" << nbSample;
}
void MetaDataManager::closeSoundBuffer( void* datas )
{
qDebug() << "Closing sound buffer";
}
void MetaDataManager::audioDataParsingStarted()
void MetaDataManager::instanceParameterHandler( void*, char*, char* )
{
qDebug() << "Started";
}
......@@ -19,6 +19,14 @@ class MetaDataManager : public QThread
private:
virtual void run();
//AMEM part :
static void openSoundBuffer( void* datas, unsigned int* freq,
unsigned int* nbChannels, unsigned int* fourCCFormat,
unsigned int* frameSize );
static void playSoundBuffer( void* datas, unsigned char* buffer,
size_t buffSize, unsigned int nbSample );
static void closeSoundBuffer( void* datas );
static void instanceParameterHandler( void*, char*, char* );
private:
LibVLCpp::MediaPlayer* m_mediaPlayer;
......@@ -39,7 +47,6 @@ class MetaDataManager : public QThread
void newClipLoaded( Clip* );
void setSnapshot();
void startAudioDataParsing();
void audioDataParsingStarted();
};
#endif // METADATAMANAGER_H
......@@ -153,7 +153,7 @@ void LibraryWidget::on_pushButtonAddMedia_clicked()
break;
case 1:
insertNewMediasFromFileDialog( tr( "Open Videos" ),
tr( "Video Files" ) + " (*.mov *.avi *.mkv *.mpg *.mpeg *.wmv)" ,
tr( "Video Files" ) + " (*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4)" ,
Library::Video );
break;
case 2:
......
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