Commit 5412c088 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Make LibVLCpp (almost) Qt free

The only parth that remains is the define do determine which of the
set_xwindow/hwnd/nsobject function to use when setting a render widget
parent c3d13814
......@@ -25,6 +25,10 @@
#include "VLCMediaPlayer.h"
#include <QList>
#include <QMutex>
#include <QWaitCondition>
namespace Backend
{
namespace VLC
......
......@@ -24,7 +24,6 @@
#define VLCINSTANCE_H
#include "VLCpp.hpp"
#include "Singleton.hpp"
struct libvlc_instance_t;
......
......@@ -30,13 +30,13 @@
using namespace LibVLCpp;
Media::Media( LibVLCpp::Instance* instance, const QString& filename )
Media::Media(LibVLCpp::Instance* instance, const char *filename )
: m_tracks( NULL )
, m_nbTracks( 0 )
, m_mrl( NULL )
{
m_internalPtr = libvlc_media_new_location( *instance, filename.toLocal8Bit() );
m_internalPtr = libvlc_media_new_location( *instance, filename);
}
Media::Media( LibVLCpp::Media &media )
......@@ -61,12 +61,6 @@ Media::addOption( const char* opt )
libvlc_media_add_option_flag( m_internalPtr, opt, libvlc_media_option_trusted );
}
void
Media::addOption(const QString &opt)
{
libvlc_media_add_option_flag( m_internalPtr, opt.toLocal8Bit(), libvlc_media_option_trusted );
}
void
Media::setVideoLockCallback( void* callback )
{
......
......@@ -25,8 +25,6 @@
#include "vlc/vlc.h"
#include <QString>
#include "VLCpp.hpp"
namespace LibVLCpp
......@@ -37,11 +35,10 @@ namespace LibVLCpp
{
public:
Media( Instance* instance, const QString& filename );
Media( Instance* instance, const char* filename );
Media(Media &media );
~Media();
void addOption( const char* opt );
void addOption( const QString& opt );
void setVideoLockCallback( void* );
void setVideoUnlockCallback( void* );
void setAudioLockCallback( void* );
......
......@@ -23,7 +23,6 @@
#include "VLCMediaPlayer.h"
#include "VLCInstance.h"
#include "VLCMedia.h"
#include "VlmcDebug.h"
#include <QtGlobal>
......@@ -117,15 +116,14 @@ MediaPlayer::setVolume( int volume )
return libvlc_audio_set_volume( m_internalPtr, volume );
}
qint64
int64_t
MediaPlayer::getTime()
{
qint64 t = libvlc_media_player_get_time( m_internalPtr );
return t;
return libvlc_media_player_get_time( m_internalPtr );
}
void
MediaPlayer::setTime( qint64 time )
MediaPlayer::setTime( int64_t time )
{
libvlc_media_player_set_time( m_internalPtr, time );
}
......@@ -142,7 +140,7 @@ MediaPlayer::setPosition( float pos )
libvlc_media_player_set_position( m_internalPtr, pos );
}
qint64
int64_t
MediaPlayer::getLength()
{
return libvlc_media_player_get_length( m_internalPtr );
......@@ -185,7 +183,7 @@ MediaPlayer::setMedia( Media* media )
}
void
MediaPlayer::getSize( quint32 *outWidth, quint32 *outHeight )
MediaPlayer::getSize( unsigned int *outWidth, unsigned int *outHeight )
{
libvlc_video_get_size( m_internalPtr, 0, outWidth, outHeight );
}
......@@ -208,14 +206,6 @@ MediaPlayer::hasVout()
return libvlc_media_player_has_vout( m_internalPtr ) > 0;
}
QString
MediaPlayer::getLoadedMRL()
{
Media::internalPtr media = libvlc_media_player_get_media( m_internalPtr );
char* str = libvlc_media_get_mrl( media );
return QString( str );
}
int
MediaPlayer::getNbAudioTrack()
{
......@@ -236,22 +226,26 @@ MediaPlayer::setKeyInput( bool enabled )
libvlc_video_set_key_input( m_internalPtr, enabled );
}
void MediaPlayer::setAudioOutput(const char *module)
void
MediaPlayer::setAudioOutput(const char *module)
{
libvlc_audio_output_set( m_internalPtr, module );
}
void MediaPlayer::disableTitle()
void
MediaPlayer::disableTitle()
{
libvlc_media_player_set_video_title_display( *this, libvlc_position_disable, 0 );
}
void MediaPlayer::setupVmemCallbacks(libvlc_video_lock_cb lock, libvlc_video_unlock_cb unlock, libvlc_video_display_cb display, void *data)
void
MediaPlayer::setupVmemCallbacks(libvlc_video_lock_cb lock, libvlc_video_unlock_cb unlock, libvlc_video_display_cb display, void *data)
{
libvlc_video_set_callbacks( *this, lock, unlock, display, data );
}
void MediaPlayer::setupVmem(const char *chroma, unsigned int width, unsigned int height, unsigned int pitch)
void
MediaPlayer::setupVmem(const char *chroma, unsigned int width, unsigned int height, unsigned int pitch)
{
libvlc_video_set_format( *this, chroma, width, height, pitch );
}
......@@ -23,12 +23,6 @@
#ifndef VLCMEDIAPLAYER_H
#define VLCMEDIAPLAYER_H
#include <QList>
#include <QMutex>
#include <QObject>
#include <QString>
#include <QWaitCondition>
#include "VLCpp.hpp"
#include "vlc/vlc.h"
......@@ -55,25 +49,23 @@ namespace LibVLCpp
void stop();
int getVolume();
int setVolume( int volume );
qint64 getTime();
void setTime( qint64 time );
int64_t getTime();
void setTime(int64_t time );
float getPosition();
void setPosition( float pos );
/**
\return The length, in milliseconds.
*/
qint64 getLength();
int64_t getLength();
void takeSnapshot( const char* outputFile, unsigned int width, unsigned int heigth );
bool isPlaying();
bool isSeekable();
void setDrawable( void* drawable );
void setMedia(Media* media);
void getSize( quint32 *outWidth, quint32 *outHeight);
void getSize( unsigned int *outWidth, unsigned int *outHeight);
float getFps();
void nextFrame();
bool hasVout();
const QString& getLoadedFileName() const;
QString getLoadedMRL();
int getNbAudioTrack();
int getNbVideoTrack();
void setKeyInput( bool enabled );
......@@ -85,14 +77,6 @@ namespace LibVLCpp
unsigned int height, unsigned int pitch );
void configureWaitForEvent(const QList<int> &toWait,
const QList<int> &cancel,
CheckEventCallback callback = NULL );
void configureWaitForEvent(int, const QList<int> &cancel,
CheckEventCallback callback = NULL );
void setName(const char *name );
void registerEvents( libvlc_callback_t callback, void* data );
void unregisterEvents( libvlc_callback_t callback, void* data );
const char* eventName( libvlc_event_type_t event ) const;
......
......@@ -41,7 +41,9 @@ VLCSource::VLCSource( VLCBackend* backend, const QString& path )
, m_isParsed( false )
, m_nbFrames( 0 )
{
m_media = new LibVLCpp::Media( backend->vlcInstance(), "file://" + path );
char buffer[256];
sprintf( buffer, "file://%s", qPrintable( path ) );
m_media = new LibVLCpp::Media( backend->vlcInstance(), buffer );
}
VLCSource::~VLCSource()
......
......@@ -56,14 +56,14 @@ VLCSourceRenderer::VLCSourceRenderer( VLCBackend* backendInstance, const VLCMemo
char inputSlave[256];
char audioParameters[256];
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%f/1:cookie=0:codec=%s:cat=2:caching=0",
sprintf( videoString, "imem://width=%i:height=%i:dar=%s:fps=%f/1:cookie=0:codec=%s:cat=2:caching=0",
source->width(), source->height(), qPrintable( source->aspectRatio() ), source->fps(), "RV32" );
sprintf( audioParameters, "cookie=1:cat=1:codec=f32l:samplerate=%u:channels=%u:caching=0",
source->sampleRate(), source->numberChannels() );
strcpy( inputSlave, ":input-slave=imem://" );
strcat( inputSlave, audioParameters );
m_media = new LibVLCpp::Media( backendInstance->vlcInstance(), "imem://" + QString( videoString ) );
m_media = new LibVLCpp::Media( backendInstance->vlcInstance(), videoString );
setOption( inputSlave );
initMediaPlayer();
}
......@@ -154,7 +154,7 @@ void
VLCSourceRenderer::setOption( const QString &option )
{
Q_ASSERT( m_media != NULL );
m_media->addOption( option );
m_media->addOption( qPrintable( option ) );
}
void
......
......@@ -23,6 +23,9 @@
#ifndef VLCVMEMRENDERER_H
#define VLCVMEMRENDERER_H
#include <QMutex>
#include <QWaitCondition>
#include "VLCSourceRenderer.h"
class QImage;
......
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