Commit 28ff8dc8 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - VLM update. Add the actual vlm queries, the modifications and so on for VOD and Broadcast.

parent 84939716
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*****************************************************************************/ *****************************************************************************/
#include "dialogs/vlm.hpp" #include "dialogs/vlm.hpp"
#include <vlc_streaming.h>
#include <QString> #include <QString>
#include <QComboBox> #include <QComboBox>
...@@ -49,6 +48,13 @@ VLMDialog *VLMDialog::instance = NULL; ...@@ -49,6 +48,13 @@ 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 );
if( !vlmWrapper->AttachVLM() )
{
msg_Warn( p_intf, "Couldn't build VLM object ");
return;
}
// UI stuff // UI stuff
ui.setupUi( this ); ui.setupUi( this );
ui.saveButton->hide(); ui.saveButton->hide();
...@@ -129,7 +135,10 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -129,7 +135,10 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
BUTTONACT( ui.saveButton, saveModifications() ); BUTTONACT( ui.saveButton, saveModifications() );
} }
VLMDialog::~VLMDialog(){} VLMDialog::~VLMDialog()
{
delete vlmWrapper;
}
void VLMDialog::showScheduleWidget( int i ) void VLMDialog::showScheduleWidget( int i )
{ {
...@@ -171,6 +180,7 @@ void VLMDialog::addVLMItem() ...@@ -171,6 +180,7 @@ void VLMDialog::addVLMItem()
QString inputText = ui.inputLedit->text(); QString inputText = ui.inputLedit->text();
QString outputText = ui.outputLedit->text(); QString outputText = ui.outputLedit->text();
bool b_checked = ui.enableCheck->isChecked(); bool b_checked = ui.enableCheck->isChecked();
bool b_looped = ui.loopBCast->isChecked();
VLMAWidget * vlmAwidget; VLMAWidget * vlmAwidget;
...@@ -179,12 +189,14 @@ void VLMDialog::addVLMItem() ...@@ -179,12 +189,14 @@ void VLMDialog::addVLMItem()
case QVLM_Broadcast: case QVLM_Broadcast:
typeShortName = "Bcast"; typeShortName = "Bcast";
vlmAwidget = new VLMBroadcast( name, inputText, outputText, vlmAwidget = new VLMBroadcast( name, inputText, outputText,
b_checked, this ); b_checked, b_looped, this );
VLMWrapper::AddBroadcast( vlmWrapper->GetVLM(), 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, this ); b_checked, ui.muxLedit->text(), this );
VLMWrapper::AddVod( vlmWrapper->GetVLM(), name, inputText, outputText, b_checked );
break; break;
case QVLM_Schedule: case QVLM_Schedule:
typeShortName = "Sched"; typeShortName = "Sched";
...@@ -217,23 +229,12 @@ void VLMDialog::clearWidgets() ...@@ -217,23 +229,12 @@ void VLMDialog::clearWidgets()
date->setDate( QDate::currentDate() ); date->setDate( QDate::currentDate() );
ui.enableCheck->setChecked( true ); ui.enableCheck->setChecked( true );
ui.nameLedit->setReadOnly( false ); ui.nameLedit->setReadOnly( false );
ui.loopBCast->setChecked( false );
ui.muxLedit->clear();
ui.saveButton->hide(); ui.saveButton->hide();
ui.addButton->show(); ui.addButton->show();
} }
void VLMDialog::saveModifications()
{
VLMAWidget *vlmObj = vlmItems.at( currentIndex );
if( vlmObj )
{
vlmObj->input = ui.inputLedit->text();
vlmObj->output = ui.outputLedit->text();
vlmObj->setChecked( ui.enableCheck->isChecked() );
vlmObj->b_enabled = ui.enableCheck->isChecked();
}
clearWidgets();
}
/* Object Modification */ /* Object Modification */
void VLMDialog::removeVLMItem( VLMAWidget *vlmObj ) void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
{ {
...@@ -260,14 +261,53 @@ void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj ) ...@@ -260,14 +261,53 @@ void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
ui.outputLedit->setText( vlmObj->output ); ui.outputLedit->setText( vlmObj->output );
ui.enableCheck->setChecked( vlmObj->b_enabled ); ui.enableCheck->setChecked( vlmObj->b_enabled );
switch( vlmObj->type )
{
case QVLM_Broadcast:
ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped );
break;
case QVLM_VOD:
ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
break;
case QVLM_Schedule:
//(qobject_cast<VLMSchedule *>)
break;
}
ui.nameLedit->setReadOnly( true ); ui.nameLedit->setReadOnly( true );
ui.addButton->hide(); ui.addButton->hide();
ui.saveButton->show(); ui.saveButton->show();
} }
void VLMDialog::saveModifications()
{
VLMAWidget *vlmObj = vlmItems.at( currentIndex );
if( vlmObj )
{
vlmObj->input = ui.inputLedit->text();
vlmObj->output = ui.outputLedit->text();
vlmObj->setChecked( ui.enableCheck->isChecked() );
vlmObj->b_enabled = ui.enableCheck->isChecked();
switch( vlmObj->type )
{
case QVLM_Broadcast:
(qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked();
break;
case QVLM_VOD:
(qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
break;
case QVLM_Schedule:
break;
// vlmObj->
}
vlmObj->update(); /* It should call the correct function is VLMAWidget
is abstract, but I am far from sure... FIXME ? */
}
clearWidgets();
}
/********************************* /*********************************
* VLMAWidget * VLMAWidget - Abstract class
********************************/ ********************************/
VLMAWidget::VLMAWidget( QString _name, VLMAWidget::VLMAWidget( QString _name,
...@@ -319,63 +359,244 @@ void VLMAWidget::del() ...@@ -319,63 +359,244 @@ void VLMAWidget::del()
parent->removeVLMItem( this ); parent->removeVLMItem( this );
} }
//FIXME, remove me before release
void VLMAWidget::enterEvent( QEvent *event )
{
printf( "test" );
}
/****************
* VLMBroadcast
****************/
VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
bool _enabled, VLMDialog *_parent) bool _enabled, bool _looped, VLMDialog *_parent)
: VLMAWidget( _name, _input, _output, : VLMAWidget( _name, _input, _output,
_enabled, _parent, QVLM_Broadcast ) _enabled, _parent, QVLM_Broadcast )
{ {
nameLabel->setText( "Broadcast: " + name ); nameLabel->setText( "Broadcast: " + name );
type = QVLM_Broadcast; type = QVLM_Broadcast;
QToolButton *playButton = new QToolButton; b_looped = _looped;
playButton = new QToolButton;
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) ); playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
objLayout->addWidget( playButton, 1, 0 ); objLayout->addWidget( playButton, 1, 0 );
b_playing = true;
QToolButton *stopButton = new QToolButton; QToolButton *stopButton = new QToolButton;
stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) ); stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) );
objLayout->addWidget( stopButton, 1, 1 ); objLayout->addWidget( stopButton, 1, 1 );
QToolButton *loopButton = new QToolButton; loopButton = new QToolButton;
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
objLayout->addWidget( loopButton, 1, 2 ); objLayout->addWidget( loopButton, 1, 2 );
BUTTONACT( playButton, togglePlayPause() ); BUTTONACT( playButton, togglePlayPause() );
BUTTONACT( stopButton, stop() ); BUTTONACT( stopButton, stop() );
BUTTONACT( loopButton, toggleLoop() ); BUTTONACT( loopButton, toggleLoop() );
update();
} }
void VLMBroadcast::update()
{
VLMWrapper::EditBroadcast( THEVLM, name, input, output, b_enabled, b_looped );
if( b_looped )
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_all.png" ) ) );
else
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
}
void VLMBroadcast::togglePlayPause() void VLMBroadcast::togglePlayPause()
{ {
if( b_playing = true )
{
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastPause );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/pause_16px.png" ) ) );
}
else
{
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastPlay );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
}
b_playing = !b_playing;
} }
void VLMBroadcast::toggleLoop() void VLMBroadcast::toggleLoop()
{ {
b_enabled = !b_enabled;
update();
} }
void VLMBroadcast::stop() void VLMBroadcast::stop()
{ {
VLMWrapper::ControlBroadcast( THEVLM, name, ControlBroadcastStop );
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
} }
void VLMAWidget::enterEvent( QEvent *event ) /****************
* VLMSchedule
****************/
VLMSchedule::VLMSchedule( QString name, QString input, QString output,
bool enabled, VLMDialog *parent)
: VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
{ {
printf( "test" ); nameLabel->setText( "Schedule: " + name );
} }
void VLMSchedule::update()
VLMSchedule::VLMSchedule( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input,
output, enabled, parent, QVLM_Schedule )
{ {
nameLabel->setText( "Schedule: " + name );
} }
/****************
* VLMVOD
****************/
VLMVod::VLMVod( QString name, QString input, QString output, VLMVod::VLMVod( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input, bool enabled, QString _mux, VLMDialog *parent)
output, enabled, parent, QVLM_VOD ) : VLMAWidget( name, input, output, enabled, parent, QVLM_VOD )
{ {
nameLabel->setText( "VOD:" + name ); nameLabel->setText( "VOD:" + name );
mux = _mux;
muxLabel = new QLabel;
objLayout->addWidget( muxLabel, 1, 0 );
update();
}
void VLMVod::update()
{
muxLabel->setText( mux );
VLMWrapper::EditVod( THEVLM, name, input, output, b_enabled, mux );
}
/*******************
* VLMWrapper
*******************/
VLMWrapper::VLMWrapper( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
p_vlm = vlm_New( p_intf );
}
VLMWrapper::~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 );
}
bool VLMWrapper::AttachVLM()
{
p_vlm = vlm_New( p_intf );
return (p_vlm ? true: false );
}
void VLMWrapper::AddBroadcast( vlm_t *p_vlm, const QString name, QString input,
QString output,
bool b_enabled, bool b_loop )
{
vlm_message_t *message;
QString command = "new \"" + name + "\" broadcast";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
EditBroadcast( p_vlm, name, input, output, b_enabled, b_loop );
}
void VLMWrapper::EditBroadcast( vlm_t *p_vlm, const QString name, const QString input,
const QString output,
bool b_enabled, bool b_loop )
{
vlm_message_t *message;
QString command;
command = "setup \"" + name + "\" inputdel all";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
command = "setup \"" + name + "\" input \"" + input + "\"";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
if( !output.isEmpty() )
{
command = "setup \"" + name + "\" output \"" + output + "\"";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
if( b_enabled )
{
command = "setup \"" + name + "\" enabled";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
if( b_loop )
{
command = "setup \"" + name + "\" loop";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
}
void VLMWrapper::ControlBroadcast( vlm_t *p_vlm, const QString name, int BroadcastStatus,
unsigned int seek )
{
vlm_message_t *message;
QString command = "setup \"" + name;
switch( BroadcastStatus )
{
case ControlBroadcastPlay:
command += " play";
break;
case ControlBroadcastPause:
command += " pause";
break;
case ControlBroadcastStop:
command += " stop";
break;
case ControlBroadcastSeek:
command += " seek" + seek;
break;
}
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
void VLMWrapper::AddVod( vlm_t *p_vlm, const QString name, const QString input,
const QString output,
bool b_enabled, const QString mux )
{
vlm_message_t *message;
QString command = "new \"" + name + "\" vod";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
EditVod( p_vlm, name, input, output, b_enabled, mux );
}
void VLMWrapper::EditVod( vlm_t *p_vlm, const QString name, const QString input,
const QString output,
bool b_enabled,
const QString mux )
{
vlm_message_t *message;
QString command = "setup \"" + name + "\" input \"" + input + "\"";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
if( !output.isEmpty() )
{
command = "setup \"" + name + "\" output \"" + output + "\"";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
if( b_enabled )
{
command = "setup \"" + name + "\" enabled";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
if( !mux.isEmpty() )
{
command = "setup \"" + name + "\" mux \"" + mux + "\"";
vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
vlm_MessageDelete( message );
}
} }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define _VLM_DIALOG_H_ #define _VLM_DIALOG_H_
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc_vlm.h>
#include "ui/vlm.h" #include "ui/vlm.h"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
...@@ -36,6 +37,13 @@ enum{ ...@@ -36,6 +37,13 @@ enum{
QVLM_VOD QVLM_VOD
}; };
enum{
ControlBroadcastPlay,
ControlBroadcastPause,
ControlBroadcastStop,
ControlBroadcastSeek
};
class QComboBox; class QComboBox;
class QVBoxLayout; class QVBoxLayout;
class QStackedWidget; class QStackedWidget;
...@@ -50,6 +58,9 @@ class QHBoxLayout; ...@@ -50,6 +58,9 @@ class QHBoxLayout;
class QDateTimeEdit; class QDateTimeEdit;
class QSpinBox; class QSpinBox;
class VLMAWidget; class VLMAWidget;
class VLMWrapper;
#define THEVLM parent->vlmWrapper->GetVLM()
class VLMDialog : public QVLCFrame class VLMDialog : public QVLCFrame
{ {
...@@ -63,6 +74,8 @@ public: ...@@ -63,6 +74,8 @@ public:
}; };
virtual ~VLMDialog(); virtual ~VLMDialog();
VLMWrapper *vlmWrapper;
private: private:
VLMDialog( intf_thread_t * ); VLMDialog( intf_thread_t * );
static VLMDialog *instance; static VLMDialog *instance;
...@@ -89,12 +102,46 @@ private slots: ...@@ -89,12 +102,46 @@ private slots:
void selectVLMItem( int ); void selectVLMItem( int );
}; };
class VLMWrapper
{
public:
VLMWrapper( intf_thread_t * );
virtual ~VLMWrapper();
bool AttachVLM();
static void AddBroadcast( vlm_t *, const QString, const QString, const QString,
bool b_enabled = true,
bool b_loop = false );
static void EditBroadcast( vlm_t *, const QString, const QString, const QString,
bool b_enabled = true,
bool b_loop = false );
static void AddVod( vlm_t *, const QString, const QString, const QString,
bool b_enabled = true, QString mux = "" );
static void EditVod( vlm_t *, const QString, const QString, const QString,
bool b_enabled = true, QString mux = "" );
static void ControlBroadcast( vlm_t *, 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 */
//unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
/* vlm_media_t *GetMedia( int i )
{ if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
private:
vlm_t *p_vlm;
intf_thread_t *p_intf;
};
class VLMAWidget : public QGroupBox class VLMAWidget : public QGroupBox
{ {
Q_OBJECT Q_OBJECT
friend class VLMDialog; friend class VLMDialog;
public: public:
VLMAWidget( QString name, QString input, QString output, bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast ); VLMAWidget( QString name, QString input, QString output,
bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
virtual void update() = 0;
protected: protected:
QLabel *nameLabel; QLabel *nameLabel;
QString name; QString name;
...@@ -113,10 +160,15 @@ private slots: ...@@ -113,10 +160,15 @@ private slots:
class VLMBroadcast : public VLMAWidget class VLMBroadcast : public VLMAWidget
{ {
Q_OBJECT Q_OBJECT
friend class VLMDialog;
public: public:
VLMBroadcast( QString name, QString input, QString output, bool _enable, VLMDialog *parent ); VLMBroadcast( QString name, QString input, QString output,
bool _enable, bool _loop, VLMDialog *parent );
void update();
private: private:
bool b_looped; bool b_looped;
bool b_playing;
QToolButton *loopButton, *playButton;
private slots: private slots:
void stop(); void stop();
void togglePlayPause(); void togglePlayPause();
...@@ -125,16 +177,23 @@ private slots: ...@@ -125,16 +177,23 @@ private slots:
class VLMVod : public VLMAWidget class VLMVod : public VLMAWidget
{ {
Q_OBJECT
friend class VLMDialog;
public: public:
VLMVod( QString name, QString input, QString output, bool _enable, VLMDialog *parent ); VLMVod( QString name, QString input, QString output,
bool _enable, QString _mux, VLMDialog *parent );
void update();
private: private:
QString mux; QString mux;
QLabel *muxLabel;
}; };
class VLMSchedule : public VLMAWidget class VLMSchedule : public VLMAWidget
{ {
friend class VLMDialog;
public: public:
VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent ); VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
void update();
private: private:
}; };
......
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