Commit 8d693ca9 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Removed old Vlm binding. Merged Media.cpp

parent 0e2a2bad
#include "VlmManager.h"
#include <QString>
using namespace LibVLCpp;
VlmManager::VlmManager( Instance* instance ) : m_instance( *instance )
{
}
VlmMedia* VlmManager::addMedia( const QString& filename, const char* const* argv, int argc )
{
VlmMedia* media = new VlmMedia( m_instance, filename );
libvlc_vlm_add_broadcast( m_instance, media->getHash().toLocal8Bit(), filename.toLocal8Bit(),
"#duplicate{dst=display{vmem}}",
argc, argv, true, false, m_ex );
m_ex.checkThrow();
m_hashTable[ media->getHash() ] = media;
return media;
}
VlmMedia* VlmManager::getMedia( const QString& hash )
{
if ( m_hashTable.contains( hash ) )
return m_hashTable[ hash ];
return NULL;
}
#ifndef VLM_H
#define VLM_H
#include <QString>
#include <QHash>
#include "VLCException.h"
#include "VLCInstance.h"
#include "VlmMedia.h"
namespace LibVLCpp
{
class VlmManager
{
public:
VlmManager( Instance* instance );
VlmMedia* addMedia( const QString& filename, const char* const* argv, int argc );
VlmMedia* getMedia( const QString& hash );
private:
QHash< QString, VlmMedia* > m_hashTable;
Instance& m_instance;
Exception m_ex;
};
}
#endif // VLM_H
#include <QtDebug>
#include <QCryptographicHash>
#include "vlc/vlc.h"
#include "VlmMedia.h"
using namespace LibVLCpp;
VlmMedia::VlmMedia(Instance& instance, const QString& filename) : _instance(instance)
{
QByteArray hash = QCryptographicHash::hash(filename.toAscii(), QCryptographicHash::Md5);
//To have a printable value :
this->_hash = hash.toHex();
}
const QString& VlmMedia::getHash() const
{
return this->_hash;
}
void VlmMedia::play()
{
libvlc_vlm_play_media(this->_instance, this->_hash.toLocal8Bit(), this->_ex);
this->_ex.checkThrow();
}
int VlmMedia::getLength()
{
int length = libvlc_vlm_get_media_instance_length(this->_instance, this->_hash.toLocal8Bit(), 0, this->_ex);
this->_ex.checkThrow();
return length;
}
#ifndef VLMMEDIA_H
#define VLMMEDIA_H
#include <QString>
#include "VLCInstance.h"
#include "VLCException.h"
namespace LibVLCpp
{
class VlmMedia
{
public:
VlmMedia(Instance& inst, const QString& filename);
const QString& getHash() const;
int getLength();
void play();
private:
Instance& _instance;
Exception _ex;
QString _hash;
};
}
#endif // VLMMEDIA_H
......@@ -25,7 +25,7 @@
#include "Media.h"
Media::Media( const QString& mrl ) : m_mrl( mrl ), m_snapshot( NULL ), m_isThreadLaunched( false ), m_isThreadFinished( false )
Media::Media( const QString& mrl ) : m_mrl( mrl ), m_snapshot( NULL )
{
char const *vlc_argv[] =
{
......@@ -78,7 +78,6 @@ void Media::run()
{
m_isMediaInitialized = true;
emit mediaReady();
m_isThreadFinished = true;
m_vlcMediaPlayer->pause();
return ;
}
......
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