Commit 4fbc0258 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Code cleanup / normalization.

Please do not use 'this' pointer when it isn't required.
parent 2279f2d7
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#ifndef IMAGE_HPP #ifndef IMAGE_HPP
#define IMAGE_HPP #define IMAGE_HPP
...@@ -30,29 +28,29 @@ ...@@ -30,29 +28,29 @@
class Image class Image
{ {
public: public:
Image(int width, int height) Image( int width, int height )
{ {
this->_pixelsData = new uchar[width * height * 4]; m_pixelsData = new uchar[ width * height * 4 ];
this->_image = new QImage(this->_pixelsData, width, height, width * 4, QImage::Format_ARGB32); m_image = new QImage( m_pixelsData, width, height, width * 4, QImage::Format_ARGB32 );
} }
~Image() ~Image()
{ {
delete this->_image; delete m_image;
delete this->_pixelsData; delete m_pixelsData;
} }
uchar* getBuffer() uchar* getBuffer()
{ {
return this->_pixelsData; return m_pixelsData;
} }
QImage& getImage() QImage& getImage()
{ {
return *(this->_image); return *(m_image);
} }
private: private:
QImage* _image; QImage* m_image;
uchar* _pixelsData; uchar* m_pixelsData;
}; };
#endif // IMAGE_HPP #endif // IMAGE_HPP
...@@ -25,50 +25,50 @@ ...@@ -25,50 +25,50 @@
using namespace LibVLCpp; using namespace LibVLCpp;
Exception::errorCallback Exception::_errorCallback = NULL; Exception::errorCallback Exception::m_errorCallback = NULL;
void* Exception::_datas = NULL; void* Exception::m_datas = NULL;
Exception::Exception() Exception::Exception()
{ {
this->_internalPtr = new libvlc_exception_t; m_internalPtr = new libvlc_exception_t;
libvlc_exception_init(this->_internalPtr); libvlc_exception_init( m_internalPtr );
} }
Exception::~Exception() Exception::~Exception()
{ {
this->clear(); clear();
delete this->_internalPtr; delete m_internalPtr;
} }
void Exception::setErrorCallback(Exception::errorCallback handler, void* datas) void Exception::setErrorCallback( Exception::errorCallback handler, void* datas )
{ {
Exception::_datas = datas; Exception::m_datas = datas;
Exception::_errorCallback = handler; Exception::m_errorCallback = handler;
} }
const char* Exception::getErrorText() const const char* Exception::getErrorText() const
{ {
return libvlc_exception_get_message(this->_internalPtr); return libvlc_exception_get_message( m_internalPtr );
} }
void Exception::clear() void Exception::clear()
{ {
libvlc_exception_clear(this->_internalPtr); libvlc_exception_clear( m_internalPtr );
} }
int Exception::raised() const int Exception::raised() const
{ {
return libvlc_exception_raised(this->_internalPtr); return libvlc_exception_raised( m_internalPtr );
} }
void Exception::checkThrow() void Exception::checkThrow()
{ {
if (this->raised() == Exception::Raised) if ( raised() == Exception::Raised )
{ {
if (Exception::_errorCallback != NULL) if ( Exception::m_errorCallback != NULL )
Exception::_errorCallback(this->getErrorText(), Exception::_datas); Exception::m_errorCallback( getErrorText(), Exception::m_datas );
else else
qWarning() << "An exception was raised, but no error handler is set.\nError message is: " << this->getErrorText(); qWarning() << "An exception was raised, but no error handler is set.\nError message is: " << getErrorText();
this->clear(); clear();
} }
} }
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
namespace LibVLCpp namespace LibVLCpp
{ {
class Exception : public Internal<libvlc_exception_t> class Exception : public Internal< libvlc_exception_t >
{ {
public: public:
Exception(); Exception();
...@@ -44,12 +44,12 @@ namespace LibVLCpp ...@@ -44,12 +44,12 @@ namespace LibVLCpp
//error handling part : //error handling part :
//TODO: have a private error handling in which we could fall back for some specific cases //TODO: have a private error handling in which we could fall back for some specific cases
typedef void (*errorCallback)(const char* msg, void* data); typedef void (*errorCallback)( const char* msg, void* data );
static void setErrorCallback(errorCallback, void* data); static void setErrorCallback( errorCallback, void* data );
private: private:
static errorCallback _errorCallback; static errorCallback m_errorCallback;
static void* _datas; static void* m_datas;
}; };
} }
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
using namespace LibVLCpp; using namespace LibVLCpp;
Instance::Instance(int argc, const char** argv) Instance::Instance( int argc, const char** argv )
{ {
this->_internalPtr = libvlc_new(argc, argv, this->_ex); m_internalPtr = libvlc_new( argc, argv, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
namespace LibVLCpp namespace LibVLCpp
{ {
class Instance : public Internal<libvlc_instance_t> class Instance : public Internal< libvlc_instance_t >
{ {
public: public:
Instance(int argc, const char** argv); Instance( int argc, const char** argv );
private: private:
Exception _ex; Exception m_ex;
}; };
} }
......
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
using namespace LibVLCpp; using namespace LibVLCpp;
Media::Media(Instance* instance, const QString& filename) : _instance(*instance), _pixelBuffer(NULL) Media::Media( Instance* instance, const QString& filename ) : m_instance( *instance ), m_pixelBuffer( NULL )
{ {
this->_internalPtr = libvlc_media_new(this->_instance, filename.toLocal8Bit(), this->_ex); m_internalPtr = libvlc_media_new( m_instance, filename.toLocal8Bit(), m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
Media::~Media() Media::~Media()
{ {
libvlc_media_release(this->_internalPtr); libvlc_media_release( m_internalPtr );
delete[] this->_pixelBuffer; delete[] m_pixelBuffer;
delete this->_dataCtx; delete m_dataCtx;
} }
Media::DataCtx* Media::buildDataCtx() Media::DataCtx* Media::buildDataCtx()
...@@ -47,47 +47,47 @@ Media::DataCtx* Media::buildDataCtx() ...@@ -47,47 +47,47 @@ Media::DataCtx* Media::buildDataCtx()
return dataCtx; return dataCtx;
} }
void Media::addOption(const char* opt) void Media::addOption( const char* opt )
{ {
libvlc_media_add_option(this->_internalPtr, opt, this->_ex); libvlc_media_add_option( m_internalPtr, opt, m_ex);
this->_ex.checkThrow(); m_ex.checkThrow();
qDebug() << "Added media option: " << opt; qDebug() << "Added media option: " << opt;
} }
Media::DataCtx::~DataCtx() Media::DataCtx::~DataCtx()
{ {
delete this->mutex; delete mutex;
} }
void Media::setLockCallback(Media::lockCallback callback) void Media::setLockCallback( Media::lockCallback callback )
{ {
char param[64]; char param[64];
sprintf(param, ":vmem-lock=%lld", (long long int)(intptr_t)callback); sprintf( param, ":vmem-lock=%lld", (long long int)(intptr_t)callback );
this->addOption(param); addOption(param);
} }
void Media::setUnlockCallback(Media::unlockCallback callback) void Media::setUnlockCallback( Media::unlockCallback callback )
{ {
char param[64]; char param[64];
sprintf(param, ":vmem-unlock=%lld", (long long int)(intptr_t)callback); sprintf( param, ":vmem-unlock=%lld", (long long int)(intptr_t)callback );
this->addOption(param); addOption( param );
} }
void Media::setDataCtx() void Media::setDataCtx()
{ {
char param[64]; char param[64];
this->_dataCtx = new Media::DataCtx; m_dataCtx = new Media::DataCtx;
this->_dataCtx->mutex = new QMutex(); m_dataCtx->mutex = new QMutex();
this->_dataCtx->media = this; m_dataCtx->media = this;
sprintf(param, ":vmem-data=%lld", (long long int)(intptr_t)this->_dataCtx); sprintf( param, ":vmem-data=%lld", (long long int)(intptr_t)m_dataCtx );
this->addOption(param); addOption( param );
} }
void Media::outputInVmem() void Media::outputInVmem()
{ {
this->addOption(":vout=vmem"); addOption( ":vout=vmem" );
} }
void Media::outputInWindow() void Media::outputInWindow()
...@@ -95,12 +95,12 @@ void Media::outputInWindow() ...@@ -95,12 +95,12 @@ void Media::outputInWindow()
// this->addOption(); // this->addOption();
} }
void Media::setPixelBuffer(uchar* buffer) void Media::setPixelBuffer( uchar* buffer )
{ {
this->_pixelBuffer = buffer; m_pixelBuffer = buffer;
} }
uchar* Media::getPixelBuffer() uchar* Media::getPixelBuffer()
{ {
return this->_pixelBuffer; return m_pixelBuffer;
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
namespace LibVLCpp namespace LibVLCpp
{ {
class Media : public Internal<libvlc_media_t> class Media : public Internal< libvlc_media_t >
{ {
public: public:
struct DataCtx struct DataCtx
...@@ -46,27 +46,27 @@ namespace LibVLCpp ...@@ -46,27 +46,27 @@ namespace LibVLCpp
QMutex* mutex; QMutex* mutex;
Media* media; Media* media;
}; };
typedef void (*lockCallback)(Media::DataCtx* dataCtx, void **pp_ret); typedef void (*lockCallback)( Media::DataCtx* dataCtx, void **pp_ret );
typedef void (*unlockCallback)(Media::DataCtx* dataCtx); typedef void (*unlockCallback)( Media::DataCtx* dataCtx );
Media(Instance* instance, const QString& filename); Media( Instance* instance, const QString& filename );
~Media(); ~Media();
void addOption(const char* opt); void addOption( const char* opt );
void setLockCallback(Media::lockCallback); void setLockCallback( Media::lockCallback );
void setUnlockCallback(Media::unlockCallback); void setUnlockCallback( Media::unlockCallback );
void setDataCtx(); void setDataCtx();
void outputInVmem(); void outputInVmem();
void outputInWindow(); void outputInWindow();
void setPixelBuffer(uchar* buffer); void setPixelBuffer( uchar* buffer );
uchar* getPixelBuffer(); uchar* getPixelBuffer();
private: private:
DataCtx* buildDataCtx(); DataCtx* buildDataCtx();
Exception _ex; Exception m_ex;
Instance& _instance; Instance& m_instance;
DataCtx* _dataCtx; DataCtx* m_dataCtx;
uchar* _pixelBuffer; uchar* m_pixelBuffer;
}; };
} }
......
...@@ -26,68 +26,68 @@ ...@@ -26,68 +26,68 @@
using namespace LibVLCpp; using namespace LibVLCpp;
MediaPlayer::MediaPlayer(Media* media, bool playStop /* = true*/) MediaPlayer::MediaPlayer( Media* media, bool playStop /* = true*/ )
{ {
this->_internalPtr = libvlc_media_player_new_from_media(media->getInternalPtr(), this->_ex); m_internalPtr = libvlc_media_player_new_from_media( media->getInternalPtr(), m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
void MediaPlayer::play() void MediaPlayer::play()
{ {
libvlc_media_player_play(this->_internalPtr, this->_ex); libvlc_media_player_play( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
void MediaPlayer::pause() void MediaPlayer::pause()
{ {
libvlc_media_player_pause(this->_internalPtr, this->_ex); libvlc_media_player_pause( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
void MediaPlayer::stop() void MediaPlayer::stop()
{ {
libvlc_media_player_stop(this->_internalPtr, this->_ex); libvlc_media_player_stop( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
qint64 MediaPlayer::getTime() qint64 MediaPlayer::getTime()
{ {
qint64 t = libvlc_media_player_get_time(this->_internalPtr, this->_ex); qint64 t = libvlc_media_player_get_time( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
return t; return t;
} }
void MediaPlayer::setTime(qint64 time) void MediaPlayer::setTime( qint64 time )
{ {
// qDebug() << "Setting media time to " << time; // qDebug() << "Setting media time to " << time;
libvlc_media_player_set_time(this->_internalPtr, time, this->_ex); libvlc_media_player_set_time( m_internalPtr, time, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
} }
qint64 MediaPlayer::getLength() qint64 MediaPlayer::getLength()
{ {
qint64 length = libvlc_media_player_get_length(this->_internalPtr, this->_ex); qint64 length = libvlc_media_player_get_length( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
// qDebug() << "Media length: " << length; // qDebug() << "Media length: " << length;
return length; return length;
} }
void MediaPlayer::takeSnapshot(char* outputFile, unsigned int width, unsigned int heigth) void MediaPlayer::takeSnapshot( char* outputFile, unsigned int width, unsigned int heigth )
{ {
libvlc_video_take_snapshot(*this, outputFile, width, heigth, this->_ex); libvlc_video_take_snapshot( *this, outputFile, width, heigth, m_ex);
this->_ex.checkThrow(); m_ex.checkThrow();
} }
bool MediaPlayer::isPlaying() bool MediaPlayer::isPlaying()
{ {
int res = libvlc_media_player_is_playing(this->_internalPtr, this->_ex); int res = libvlc_media_player_is_playing( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
return (res == 1); return (res == 1);
} }
bool MediaPlayer::isSeekable() bool MediaPlayer::isSeekable()
{ {
int res = libvlc_media_player_is_seekable(this->_internalPtr, this->_ex); int res = libvlc_media_player_is_seekable( m_internalPtr, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
return (res == 1); return (res == 1);
} }
...@@ -33,22 +33,22 @@ ...@@ -33,22 +33,22 @@
namespace LibVLCpp namespace LibVLCpp
{ {
class MediaPlayer : public Internal<libvlc_media_player_t> class MediaPlayer : public Internal< libvlc_media_player_t >
{ {
public: public:
MediaPlayer(Media* media, bool playStop = true); MediaPlayer( Media* media, bool playStop = true );
void play(); void play();
void pause(); void pause();
void stop(); void stop();
qint64 getTime(); qint64 getTime();
void setTime(qint64 time); void setTime( qint64 time );
qint64 getLength(); qint64 getLength();
void takeSnapshot(char* outputFile, unsigned int width, unsigned int heigth); void takeSnapshot( char* outputFile, unsigned int width, unsigned int heigth );
bool isPlaying(); bool isPlaying();
bool isSeekable(); bool isSeekable();
private: private:
Exception _ex; Exception m_ex;
}; };
} }
......
...@@ -28,21 +28,21 @@ ...@@ -28,21 +28,21 @@
namespace LibVLCpp namespace LibVLCpp
{ {
template <typename T> template < typename T >
class Internal class Internal
{ {
public: public:
typedef T* internalPtr; typedef T* internalPtr;
T* getInternalPtr() T* getInternalPtr()
{ {
assert(this->_internalPtr != NULL); assert( m_internalPtr != NULL );
return this->_internalPtr; return m_internalPtr;
} }
operator T*() {return this->_internalPtr;} operator T*() { return m_internalPtr; }
protected: protected:
Internal() : _internalPtr(NULL) {} Internal() : m_internalPtr( NULL ) {}
T* _internalPtr; T* m_internalPtr;
}; };
} }
......
...@@ -3,25 +3,25 @@ ...@@ -3,25 +3,25 @@
using namespace LibVLCpp; using namespace LibVLCpp;
VlmManager::VlmManager(Instance* instance) : _instance(*instance) VlmManager::VlmManager( Instance* instance ) : m_instance( *instance )
{ {
} }
VlmMedia* VlmManager::addMedia(const QString& filename, const char* const* argv, int argc) VlmMedia* VlmManager::addMedia( const QString& filename, const char* const* argv, int argc )
{ {
VlmMedia* media = new VlmMedia(this->_instance, filename); VlmMedia* media = new VlmMedia( m_instance, filename );
libvlc_vlm_add_broadcast(this->_instance, media->getHash().toLocal8Bit(), filename.toLocal8Bit(), libvlc_vlm_add_broadcast( m_instance, media->getHash().toLocal8Bit(), filename.toLocal8Bit(),
"#duplicate{dst=display{vmem}}", "#duplicate{dst=display{vmem}}",
argc, argv, true, false, this->_ex); argc, argv, true, false, m_ex );
this->_ex.checkThrow(); m_ex.checkThrow();
this->_hashTable[media->getHash()] = media; m_hashTable[ media->getHash() ] = media;
return media; return media;
} }
VlmMedia* VlmManager::getMedia(const QString& hash) VlmMedia* VlmManager::getMedia( const QString& hash )
{ {
if ( this->_hashTable.contains(hash) == true ) if ( m_hashTable.contains( hash ) )
return this->_hashTable[hash]; return m_hashTable[ hash ];
return NULL; return NULL;
} }
...@@ -13,14 +13,14 @@ namespace LibVLCpp ...@@ -13,14 +13,14 @@ namespace LibVLCpp
class VlmManager class VlmManager
{ {
public: public:
VlmManager(Instance* instance); VlmManager( Instance* instance );
VlmMedia* addMedia(const QString& filename, const char* const* argv, int argc); VlmMedia* addMedia( const QString& filename, const char* const* argv, int argc );
VlmMedia* getMedia(const QString& hash); VlmMedia* getMedia( const QString& hash );
private: private:
QHash<QString, VlmMedia*> _hashTable; QHash< QString, VlmMedia* > m_hashTable;
Instance& _instance; Instance& m_instance;
Exception _ex; Exception m_ex;
}; };
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "Media.h" #include "Media.h"