+
+/****************
+ * VLMBroadcast
+ ****************/
+VLMBroadcast::VLMBroadcast( const QString& _name, const QString& _input,
+ const QString& _output, bool _enabled,
+ bool _looped, VLMDialog *_parent )
+ : VLMAWidget( _name, _input, _output,
+ _enabled, _parent, QVLM_Broadcast )
+{
+ nameLabel->setText( qtr("Broadcast: ") + name );
+ type = QVLM_Broadcast;
+ b_looped = _looped;
+
+ playButton = new QToolButton;
+ playButton->setIcon( QIcon( ":/menu/play" ) );
+ objLayout->addWidget( playButton, 1, 0 );
+ b_playing = true;
+
+ QToolButton *stopButton = new QToolButton;
+ stopButton->setIcon( QIcon( ":/toolbar/stop_b" ) );
+ objLayout->addWidget( stopButton, 1, 1 );
+
+ loopButton = new QToolButton;
+ objLayout->addWidget( loopButton, 1, 2 );
+
+ BUTTONACT( playButton, togglePlayPause() );
+ BUTTONACT( stopButton, stop() );
+ BUTTONACT( loopButton, toggleLoop() );
+
+ update();
+}
+
+void VLMBroadcast::update()
+{
+ VLMWrapper::EditBroadcast( name, input, output, b_enabled, b_looped );
+ if( b_looped )
+ loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
+ else
+ loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) );
+}
+
+void VLMBroadcast::togglePlayPause()
+{
+ if( b_playing )
+ {
+ VLMWrapper::ControlBroadcast( name, ControlBroadcastPause );
+ playButton->setIcon( QIcon( ":/menu/pause" ) );
+ }
+ else
+ {
+ VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay );
+ playButton->setIcon( QIcon( ":/menu/play" ) );
+ }
+ b_playing = !b_playing;
+}
+
+void VLMBroadcast::toggleLoop()
+{
+ b_enabled = !b_enabled;
+ update();
+}
+
+void VLMBroadcast::stop()
+{
+ VLMWrapper::ControlBroadcast( name, ControlBroadcastStop );
+ playButton->setIcon( QIcon( ":/menu/play" ) );
+}
+
+/****************
+ * VLMSchedule
+ ****************/
+VLMSchedule::VLMSchedule( const QString& name, const QString& input,
+ const QString& output, QDateTime _schetime,
+ QDateTime _schedate, int _scherepeatnumber,
+ int _repeatDays, bool enabled, VLMDialog *parent )
+ : VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
+{
+ nameLabel->setText( qtr("Schedule: ") + name );
+ schetime = _schetime;
+ schedate = _schedate;
+ rNumber = _scherepeatnumber;
+ rDays = _repeatDays;
+ type = QVLM_Schedule;
+ update();
+}
+
+void VLMSchedule::update()
+{
+ VLMWrapper::EditSchedule( name, input, output, schetime, schedate,
+ rNumber, rDays, b_enabled);
+}
+
+/****************
+ * VLMVOD
+ ****************/
+VLMVod::VLMVod( const QString& name, const QString& input, const QString& output,
+ bool enabled, const QString& _mux, VLMDialog *parent)
+ : VLMAWidget( name, input, output, enabled, parent, QVLM_VOD )
+{
+ nameLabel->setText( qtr("VOD: ") + name );
+
+ mux = _mux;
+ muxLabel = new QLabel;
+ objLayout->addWidget( muxLabel, 1, 0 );
+
+ update();
+}
+
+void VLMVod::update()
+{
+ muxLabel->setText( mux );
+ VLMWrapper::EditVod( name, input, output, b_enabled, mux );
+}
+
+
+/*******************
+ * VLMWrapper
+ *******************/
+vlm_t * VLMWrapper::p_vlm = NULL;
+
+VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
+{
+ p_vlm = _p_vlm;
+}
+
+VLMWrapper::~VLMWrapper()
+{
+ p_vlm = NULL;
+}
+
+void VLMWrapper::AddBroadcast( const QString& name, const QString& input,
+ const 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( name, input, output, b_enabled, b_loop );
+}
+
+void VLMWrapper::EditBroadcast( 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::EnableItem( const QString& name, bool b_enable )
+{
+ vlm_message_t *message;
+ QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+}
+
+void VLMWrapper::ControlBroadcast( const QString& name, int BroadcastStatus,
+ unsigned int seek )
+{
+ vlm_message_t *message;
+
+ QString command = "control \"" + 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( 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( name, input, output, b_enabled, mux );
+}
+
+void VLMWrapper::EditVod( 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 );
+ }
+}
+
+void VLMWrapper::AddSchedule( const QString& name, const QString& input,
+ const QString& output, QDateTime _schetime,
+ QDateTime _schedate,
+ int _scherepeatnumber, int _repeatDays,
+ bool b_enabled, const QString& mux )
+{
+ vlm_message_t *message;
+ QString command = "new \"" + name + "\" schedule";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ EditSchedule( name, input, output, _schetime, _schedate,
+ _scherepeatnumber, _repeatDays, b_enabled, mux );
+}
+
+void VLMWrapper::EditSchedule( const QString& name, const QString& input,
+ const QString& output, QDateTime _schetime,
+ QDateTime _schedate, int _scherepeatnumber,
+ int _repeatDays, 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 );
+ }
+
+ command = "setup \"" + name + "\" date \"" +
+ _schedate.toString( "yyyy/MM/dd" )+ "-" +
+ _schetime.toString( "hh:mm:ss" ) + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+
+ if( _scherepeatnumber > 0 )
+ {
+ command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+
+ if( _repeatDays > 0 )
+ {
+ command = "setup \"" + name + "\" period \"" + _repeatDays + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+}
+
+void VLMDialog::toggleVisible()
+{
+ QList<VLMAWidget *>::iterator it;
+ for( it = vlmItems.begin(); it != vlmItems.end(); it++ )
+ {
+ VLMAWidget *item = *it;
+ delete item;
+ item = NULL;
+ }
+ vlmItems.clear();
+ ui.vlmListItem->clear();
+ mediasPopulator();
+ QVLCDialog::toggleVisible();
+}
+
+
+#endif