Commit 862e02d6 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

A data parsing (really really) small start.

Some cosmetic on VLCpp::MediaPlayer
CheckVLCppException now prints the current function where the exception has been
thrown.
parent d778aa78
......@@ -61,14 +61,14 @@ int Exception::raised() const
return libvlc_exception_raised( m_internalPtr );
}
void Exception::checkThrow( const char* file, int line )
void Exception::checkThrow( const char* file, int line, const char* funcName )
{
if ( raised() == Exception::Raised )
{
if ( Exception::m_errorCallback != NULL )
Exception::m_errorCallback( getErrorText(), Exception::m_datas );
else
qWarning() << "A VLC exception was raised in" << file << " at line " << line << ": \"" << getErrorText() << "\"";
qWarning() << "A VLC exception was raised in" << file << ":" << line << '(' << funcName << "):" << getErrorText() << "\"";
clear();
}
}
......@@ -26,7 +26,7 @@
#include "vlc/vlc.h"
#include "VLCpp.hpp"
#define CheckVlcppException(ex) (ex.checkThrow(__FILE__, __LINE__))
#define CheckVlcppException(ex) (ex.checkThrow(__FILE__, __LINE__, __func__))
namespace LibVLCpp
{
......@@ -39,7 +39,7 @@ namespace LibVLCpp
const char* getErrorText() const;
void clear();
int raised() const;
void checkThrow( const char* file, int line );
void checkThrow( const char* file, int line, const char* funcName );
static const int Raised = 1;
static const int NotRaised = 0;
......
......@@ -30,7 +30,7 @@ using namespace LibVLCpp;
MediaPlayer::MediaPlayer()
{
m_internalPtr = libvlc_media_player_new( LibVLCpp::Instance::getInstance()->getInternalPtr(), m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
// Initialize the event manager
p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex );
......@@ -48,7 +48,7 @@ MediaPlayer::MediaPlayer()
MediaPlayer::MediaPlayer( Media* media )
{
m_internalPtr = libvlc_media_player_new_from_media( media->getInternalPtr(), m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
// Initialize the event manager
p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex );
......@@ -131,85 +131,85 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
void MediaPlayer::play()
{
libvlc_media_player_play( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
void MediaPlayer::pause()
{
qDebug() << "Pausing media";
libvlc_media_player_pause( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
void MediaPlayer::stop()
{
libvlc_media_player_stop( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
qint64 MediaPlayer::getTime()
{
qint64 t = libvlc_media_player_get_time( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return t;
}
void MediaPlayer::setTime( qint64 time )
{
libvlc_media_player_set_time( m_internalPtr, time, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
float MediaPlayer::getPosition()
{
float p = libvlc_media_player_get_position( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return p;
}
void MediaPlayer::setPosition( float pos )
{
libvlc_media_player_set_position( m_internalPtr, pos, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
qint64 MediaPlayer::getLength()
{
qint64 length = libvlc_media_player_get_length( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return length;
}
void MediaPlayer::takeSnapshot( char* outputFile, unsigned int width, unsigned int heigth )
{
libvlc_video_take_snapshot( *this, outputFile, width, heigth, m_ex);
CheckVlcppException(m_ex);
libvlc_video_take_snapshot( *this, outputFile, width, heigth, m_ex );
CheckVlcppException( m_ex );
}
bool MediaPlayer::isPlaying()
{
int res = libvlc_media_player_is_playing( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return (res == 1);
}
bool MediaPlayer::isSeekable()
{
int res = libvlc_media_player_is_seekable( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return (res == 1);
}
void MediaPlayer::setDrawable( void* hwnd )
{
libvlc_media_player_set_hwnd( m_internalPtr, hwnd, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
void MediaPlayer::setDrawable( uint32_t drawable )
{
libvlc_media_player_set_xwindow( m_internalPtr, drawable, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
void MediaPlayer::timeChangedFilter()
......@@ -226,19 +226,19 @@ void MediaPlayer::timeChangedFilter()
void MediaPlayer::setMedia( Media* media )
{
libvlc_media_player_set_media( m_internalPtr, media->getInternalPtr(), m_ex);
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
}
int MediaPlayer::getWidth()
{
int width = libvlc_video_get_width( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return width;
}
int MediaPlayer::getHeight()
{
int height = libvlc_video_get_height( m_internalPtr, m_ex );
CheckVlcppException(m_ex);
CheckVlcppException( m_ex );
return height;
}
......@@ -60,6 +60,7 @@ void MetaDataManager::run()
void MetaDataManager::getMetaData()
{
disconnect( this, SLOT( getMetaData() ) );
m_nextMedia = true;
m_currentClip->setLength( m_mediaPlayer->getLength() );
m_currentClip->setWidth( m_mediaPlayer->getWidth() );
......@@ -94,5 +95,28 @@ void MetaDataManager::setSnapshot()
else
m_currentClip->setSnapshot( pixmap );
disconnect( this, SLOT( setSnapshot() ) );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( startAudioDataParsing() ) );
m_mediaPlayer->stop();
}
void MetaDataManager::startAudioDataParsing()
{
disconnect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( startAudioDataParsing() ) );
//Deactivating video, so that real time doesn't matter
m_currentClip->addParam( ":no-video" );
m_currentClip->flushParameters();
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( audioDataParsingStarted() ) );
m_mediaPlayer->play();
//Restoring the clip at a correct value.
m_currentClip->addParam( ":video" );
}
void MetaDataManager::audioDataParsingStarted()
{
qDebug() << "Started";
}
......@@ -38,6 +38,8 @@ class MetaDataManager : public QThread
void getMetaData();
void newClipLoaded( Clip* );
void setSnapshot();
void startAudioDataParsing();
void audioDataParsingStarted();
};
#endif // METADATAMANAGER_H
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