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 @@
*****************************************************************************/
#include "dialogs/vlm.hpp"
#include <vlc_streaming.h>
#include <QString>
#include <QComboBox>
......@@ -49,6 +48,13 @@ VLMDialog *VLMDialog::instance = NULL;
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.setupUi( this );
ui.saveButton->hide();
......@@ -129,7 +135,10 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
BUTTONACT( ui.saveButton, saveModifications() );
}
VLMDialog::~VLMDialog(){}
VLMDialog::~VLMDialog()
{
delete vlmWrapper;
}
void VLMDialog::showScheduleWidget( int i )
{
......@@ -171,6 +180,7 @@ void VLMDialog::addVLMItem()
QString inputText = ui.inputLedit->text();
QString outputText = ui.outputLedit->text();
bool b_checked = ui.enableCheck->isChecked();
bool b_looped = ui.loopBCast->isChecked();
VLMAWidget * vlmAwidget;
......@@ -179,12 +189,14 @@ void VLMDialog::addVLMItem()
case QVLM_Broadcast:
typeShortName = "Bcast";
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;
case QVLM_VOD:
typeShortName = "VOD";
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;
case QVLM_Schedule:
typeShortName = "Sched";
......@@ -217,23 +229,12 @@ void VLMDialog::clearWidgets()
date->setDate( QDate::currentDate() );
ui.enableCheck->setChecked( true );
ui.nameLedit->setReadOnly( false );
ui.loopBCast->setChecked( false );
ui.muxLedit->clear();
ui.saveButton->hide();
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 */
void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
{
......@@ -260,14 +261,53 @@ void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
ui.outputLedit->setText( vlmObj->output );
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.addButton->hide();
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,
......@@ -319,63 +359,244 @@ void VLMAWidget::del()
parent->removeVLMItem( this );
}
//FIXME, remove me before release
void VLMAWidget::enterEvent( QEvent *event )
{
printf( "test" );
}
/****************
* VLMBroadcast
****************/
VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
bool _enabled, VLMDialog *_parent)
bool _enabled, bool _looped, VLMDialog *_parent)
: VLMAWidget( _name, _input, _output,
_enabled, _parent, QVLM_Broadcast )
{
nameLabel->setText( "Broadcast: " + name );
type = QVLM_Broadcast;
QToolButton *playButton = new QToolButton;
b_looped = _looped;
playButton = new QToolButton;
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
objLayout->addWidget( playButton, 1, 0 );
b_playing = true;
QToolButton *stopButton = new QToolButton;
stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) );
objLayout->addWidget( stopButton, 1, 1 );
QToolButton *loopButton = new QToolButton;
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
loopButton = new QToolButton;
objLayout->addWidget( loopButton, 1, 2 );
BUTTONACT( playButton, togglePlayPause() );
BUTTONACT( stopButton, stop() );
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()
{
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()
{
b_enabled = !b_enabled;
update();
}
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 );
}
VLMSchedule::VLMSchedule( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input,
output, enabled, parent, QVLM_Schedule )
void VLMSchedule::update()
{
nameLabel->setText( "Schedule: " + name );
}
/****************
* VLMVOD
****************/
VLMVod::VLMVod( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input,
output, enabled, parent, QVLM_VOD )
bool enabled, QString _mux, VLMDialog *parent)
: VLMAWidget( name, input, output, enabled, parent, QVLM_VOD )
{
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 @@
#define _VLM_DIALOG_H_
#include <vlc/vlc.h>
#include <vlc_vlm.h>
#include "ui/vlm.h"
#include "util/qvlcframe.hpp"
......@@ -36,6 +37,13 @@ enum{
QVLM_VOD
};
enum{
ControlBroadcastPlay,
ControlBroadcastPause,
ControlBroadcastStop,
ControlBroadcastSeek
};
class QComboBox;
class QVBoxLayout;
class QStackedWidget;
......@@ -50,6 +58,9 @@ class QHBoxLayout;
class QDateTimeEdit;
class QSpinBox;
class VLMAWidget;
class VLMWrapper;
#define THEVLM parent->vlmWrapper->GetVLM()
class VLMDialog : public QVLCFrame
{
......@@ -63,6 +74,8 @@ public:
};
virtual ~VLMDialog();
VLMWrapper *vlmWrapper;
private:
VLMDialog( intf_thread_t * );
static VLMDialog *instance;
......@@ -89,12 +102,46 @@ private slots:
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
{
Q_OBJECT
friend class VLMDialog;
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:
QLabel *nameLabel;
QString name;
......@@ -113,10 +160,15 @@ private slots:
class VLMBroadcast : public VLMAWidget
{
Q_OBJECT
friend class VLMDialog;
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:
bool b_looped;
bool b_playing;
QToolButton *loopButton, *playButton;
private slots:
void stop();
void togglePlayPause();
......@@ -125,16 +177,23 @@ private slots:
class VLMVod : public VLMAWidget
{
Q_OBJECT
friend class VLMDialog;
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:
QString mux;
QLabel *muxLabel;
};
class VLMSchedule : public VLMAWidget
{
friend class VLMDialog;
public:
VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
void update();
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