Commit e93bed1a authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - VLM: simplifications.

parent 270d869d
...@@ -47,13 +47,15 @@ static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" }; ...@@ -47,13 +47,15 @@ static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
VLMDialog *VLMDialog::instance = NULL; VLMDialog *VLMDialog::instance = NULL;
VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
vlmWrapper = new VLMWrapper( p_intf ); p_vlm = vlm_New( p_intf );
if( !vlmWrapper->AttachVLM() )
if( !p_vlm )
{ {
msg_Warn( p_intf, "Couldn't build VLM object "); msg_Warn( p_intf, "Couldn't build VLM object ");
return; return;
} }
vlmWrapper = new VLMWrapper( p_vlm );
// UI stuff // UI stuff
ui.setupUi( this ); ui.setupUi( this );
...@@ -137,7 +139,10 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -137,7 +139,10 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
VLMDialog::~VLMDialog() VLMDialog::~VLMDialog()
{ {
delete vlmWrapper; /* FIXME :you have to destroy vlm here to close
* but we shouldn't destroy vlm here in case somebody else wants it */
if( p_vlm )
vlm_Delete( p_vlm );
} }
void VLMDialog::showScheduleWidget( int i ) void VLMDialog::showScheduleWidget( int i )
...@@ -190,13 +195,13 @@ void VLMDialog::addVLMItem() ...@@ -190,13 +195,13 @@ void VLMDialog::addVLMItem()
typeShortName = "Bcast"; typeShortName = "Bcast";
vlmAwidget = new VLMBroadcast( name, inputText, outputText, vlmAwidget = new VLMBroadcast( name, inputText, outputText,
b_checked, b_looped, this ); b_checked, b_looped, this );
VLMWrapper::AddBroadcast( vlmWrapper->GetVLM(), name, inputText, outputText, b_checked, b_looped ); //VLMWrapper::AddBroadcast( vlmWrapper->p_vlc, name, inputText, outputText, b_checked, b_looped );
break; break;
case QVLM_VOD: case QVLM_VOD:
typeShortName = "VOD"; typeShortName = "VOD";
vlmAwidget = new VLMVod( name, inputText, outputText, vlmAwidget = new VLMVod( name, inputText, outputText,
b_checked, ui.muxLedit->text(), this ); b_checked, ui.muxLedit->text(), this );
VLMWrapper::AddVod( vlmWrapper->GetVLM(), name, inputText, outputText, b_checked ); ///VLMWrapper::AddVod( vlmWrapper->GetVLM(), name, inputText, outputText, b_checked );
break; break;
case QVLM_Schedule: case QVLM_Schedule:
typeShortName = "Sched"; typeShortName = "Sched";
...@@ -398,7 +403,7 @@ VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, ...@@ -398,7 +403,7 @@ VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
void VLMBroadcast::update() void VLMBroadcast::update()
{ {
VLMWrapper::EditBroadcast( THEVLM, name, input, output, b_enabled, b_looped ); //VLMWrapper::EditBroadcast( VLMWrapper::p_vlm, name, input, output, b_enabled, b_looped );
if( b_looped ) if( b_looped )
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_all.png" ) ) ); loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_all.png" ) ) );
else else
...@@ -409,12 +414,12 @@ void VLMBroadcast::togglePlayPause() ...@@ -409,12 +414,12 @@ void VLMBroadcast::togglePlayPause()
{ {
if( b_playing = true ) if( b_playing = true )
{ {
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastPause ); // VLMWrapper::ControlBroadcast( VLMWrapper::p_vlm, name, ControlBroadcastPause );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/pause_16px.png" ) ) ); playButton->setIcon( QIcon( QPixmap( ":/pixmaps/pause_16px.png" ) ) );
} }
else else
{ {
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastPlay ); //VLMWrapper::ControlBroadcast( VLMWrapper::p_vlm, name, ControlBroadcastPlay );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) ); playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
} }
b_playing = !b_playing; b_playing = !b_playing;
...@@ -428,7 +433,7 @@ void VLMBroadcast::toggleLoop() ...@@ -428,7 +433,7 @@ void VLMBroadcast::toggleLoop()
void VLMBroadcast::stop() void VLMBroadcast::stop()
{ {
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastStop ); //VLMWrapper::ControlBroadcast( VLMWrapper::p_vlm, name, ControlBroadcastStop );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) ); playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
} }
...@@ -465,34 +470,24 @@ VLMVod::VLMVod( QString name, QString input, QString output, ...@@ -465,34 +470,24 @@ VLMVod::VLMVod( QString name, QString input, QString output,
void VLMVod::update() void VLMVod::update()
{ {
muxLabel->setText( mux ); muxLabel->setText( mux );
VLMWrapper::EditVod( THEVLM, name, input, output, b_enabled, mux ); //VLMWrapper::EditVod( p_vlm, name, input, output, b_enabled, mux );
} }
/******************* /*******************
* VLMWrapper * VLMWrapper
*******************/ *******************/
VLMWrapper::VLMWrapper( intf_thread_t *_p_intf ) vlm_t * VLMWrapper::p_vlm = NULL;
{
p_intf = _p_intf;
p_vlm = vlm_New( p_intf );
}
VLMWrapper::~VLMWrapper() VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
{ {
/* FIXME :you have to destroy vlm here to close p_vlm = _p_vlm;
* but we shouldn't destroy vlm here in case somebody else wants it */
if( p_vlm )
vlm_Delete( p_vlm );
} }
bool VLMWrapper::AttachVLM() VLMWrapper::~VLMWrapper()
{ {}
p_vlm = vlm_New( p_intf );
return (p_vlm ? true: false );
}
void VLMWrapper::AddBroadcast( vlm_t *p_vlm, const QString name, QString input, void VLMWrapper::AddBroadcast( const QString name, QString input,
QString output, QString output,
bool b_enabled, bool b_loop ) bool b_enabled, bool b_loop )
{ {
...@@ -500,10 +495,10 @@ void VLMWrapper::AddBroadcast( vlm_t *p_vlm, const QString name, QString input, ...@@ -500,10 +495,10 @@ void VLMWrapper::AddBroadcast( vlm_t *p_vlm, const QString name, QString input,
QString command = "new \"" + name + "\" broadcast"; QString command = "new \"" + name + "\" broadcast";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message ); vlm_MessageDelete( message );
EditBroadcast( p_vlm, name, input, output, b_enabled, b_loop ); EditBroadcast( name, input, output, b_enabled, b_loop );
} }
void VLMWrapper::EditBroadcast( vlm_t *p_vlm, const QString name, const QString input, void VLMWrapper::EditBroadcast( const QString name, const QString input,
const QString output, const QString output,
bool b_enabled, bool b_loop ) bool b_enabled, bool b_loop )
{ {
...@@ -536,7 +531,7 @@ void VLMWrapper::EditBroadcast( vlm_t *p_vlm, const QString name, const QString ...@@ -536,7 +531,7 @@ void VLMWrapper::EditBroadcast( vlm_t *p_vlm, const QString name, const QString
} }
} }
void VLMWrapper::ControlBroadcast( vlm_t *p_vlm, const QString name, int BroadcastStatus, void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus,
unsigned int seek ) unsigned int seek )
{ {
vlm_message_t *message; vlm_message_t *message;
...@@ -561,7 +556,7 @@ void VLMWrapper::ControlBroadcast( vlm_t *p_vlm, const QString name, int Broadca ...@@ -561,7 +556,7 @@ void VLMWrapper::ControlBroadcast( vlm_t *p_vlm, const QString name, int Broadca
vlm_MessageDelete( message ); vlm_MessageDelete( message );
} }
void VLMWrapper::AddVod( vlm_t *p_vlm, const QString name, const QString input, void VLMWrapper::AddVod( const QString name, const QString input,
const QString output, const QString output,
bool b_enabled, const QString mux ) bool b_enabled, const QString mux )
{ {
...@@ -569,10 +564,10 @@ void VLMWrapper::AddVod( vlm_t *p_vlm, const QString name, const QString input, ...@@ -569,10 +564,10 @@ void VLMWrapper::AddVod( vlm_t *p_vlm, const QString name, const QString input,
QString command = "new \"" + name + "\" vod"; QString command = "new \"" + name + "\" vod";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message ); vlm_MessageDelete( message );
EditVod( p_vlm, name, input, output, b_enabled, mux ); EditVod( name, input, output, b_enabled, mux );
} }
void VLMWrapper::EditVod( vlm_t *p_vlm, const QString name, const QString input, void VLMWrapper::EditVod( const QString name, const QString input,
const QString output, const QString output,
bool b_enabled, bool b_enabled,
const QString mux ) const QString mux )
......
...@@ -60,7 +60,6 @@ class QSpinBox; ...@@ -60,7 +60,6 @@ class QSpinBox;
class VLMAWidget; class VLMAWidget;
class VLMWrapper; class VLMWrapper;
#define THEVLM parent->vlmWrapper->GetVLM()
class VLMDialog : public QVLCFrame class VLMDialog : public QVLCFrame
{ {
...@@ -75,7 +74,7 @@ public: ...@@ -75,7 +74,7 @@ public:
virtual ~VLMDialog(); virtual ~VLMDialog();
VLMWrapper *vlmWrapper; VLMWrapper *vlmWrapper;
vlm_t *p_vlm;
private: private:
VLMDialog( intf_thread_t * ); VLMDialog( intf_thread_t * );
static VLMDialog *instance; static VLMDialog *instance;
...@@ -105,33 +104,29 @@ private slots: ...@@ -105,33 +104,29 @@ private slots:
class VLMWrapper class VLMWrapper
{ {
public: public:
VLMWrapper( intf_thread_t * ); VLMWrapper( vlm_t * );
virtual ~VLMWrapper(); virtual ~VLMWrapper();
bool AttachVLM(); static void AddBroadcast( const QString, const QString, const QString,
static void AddBroadcast( vlm_t *, const QString, const QString, const QString,
bool b_enabled = true, bool b_enabled = true,
bool b_loop = false ); bool b_loop = false );
static void EditBroadcast( vlm_t *, const QString, const QString, const QString, static void EditBroadcast( const QString, const QString, const QString,
bool b_enabled = true, bool b_enabled = true,
bool b_loop = false ); bool b_loop = false );
static void AddVod( vlm_t *, const QString, const QString, const QString, static void AddVod( const QString, const QString, const QString,
bool b_enabled = true, QString mux = "" ); bool b_enabled = true, QString mux = "" );
static void EditVod( vlm_t *, const QString, const QString, const QString, static void EditVod( const QString, const QString, const QString,
bool b_enabled = true, QString mux = "" ); bool b_enabled = true, QString mux = "" );
static void ControlBroadcast( vlm_t *, const QString, int, unsigned int seek = 0 ); static void ControlBroadcast( const QString, int, unsigned int seek = 0 );
vlm_t * GetVLM(){ return p_vlm;}
/* We don't have yet the accessors in the core, so the following is commented */ /* We don't have yet the accessors in the core, so the following is commented */
//unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; } //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
/* vlm_media_t *GetMedia( int i ) /* vlm_media_t *GetMedia( int i )
{ if( p_vlm ) return p_vlm->media[i]; return NULL; }*/ { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
private: private:
vlm_t *p_vlm; static vlm_t *p_vlm;
intf_thread_t *p_intf;
}; };
class VLMAWidget : public QGroupBox class VLMAWidget : public QGroupBox
......
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