import sys
-from time import time, gmtime, strftime
+from time import time, localtime, strftime
import gi
gi.require_version('Gtk', '3.0')
import gstconf
-formatted_date = strftime('%Y_%m_%d', gmtime())
+formatted_date = strftime('%Y_%m_%d', localtime())
metadata = {'speaker_name':'NC',
'session_title':'NC',
'organisation':'NC',}
self.win.show_all()
self.xid = self.videowidget.get_property('window').get_xid()
-
- self.pipel = gstconf.New_user_pipeline()
+ self.create_pipeline_instance()
+
+ def create_pipeline_instance(self, feed='main'):
+ """Creates pipeline instance and attaches it to GUI."""
+ self.pipel = gstconf.New_user_pipeline(feed)
bus = gstconf.get_gstreamer_bus()
bus.connect('sync-message::element', self.on_sync_message)
bus.connect('message', self.on_message)
- ## Try to use 'sync-message::element' instead of 'message''
-
+ # Try to use 'sync-message::element' instead of 'message'
+
+ def create_backup_pipeline(self):
+ labelname = self.stream_button.get_label()
+ if labelname == 'ON AIR':
+ self.create_pipeline_instance(feed='backup')
+ self.pipel.stream_play()
+
def on_sync_message(self, bus, message):
if message.get_structure().get_name() == 'prepare-window-handle':
# Watching for feed loss during streaming:
t = message.type
if t == Gst.MessageType.ERROR:
- self.create_backup_pipeline()
- #pass
-
- def create_backup_pipeline(self):
- labelname = self.stream_button.get_label()
- if labelname == 'ON AIR':
- self.pipel = gstconf.New_user_pipeline(feed='backup',)
- bus = gstconf.get_gstreamer_bus()
- bus.connect('sync-message::element', self.on_sync_message)
- self.pipel.stream_play()
- print('[WARNING] Backup pipeline started.')
+ err, debug = message.parse_error()
+ if '(651)' not in debug:
+ self.pipel.stream_stop()
+ self.create_backup_pipeline()
def on_stream_clicked(self, widget):
labelname = self.stream_button.get_label()
if labelname == 'Stream':
+ if self.pipel.feed == 'backup':
+ # Get back to main feed:
+ self.create_pipeline_instance()
self.clean_entry_fields()
self.pipel.stream_play()
-## self.pipel.get_stream_state()
self.stream_button.set_label('ON AIR')
start_time = time()
elif labelname == 'ON AIR':
self.pipel.stream_stop()
self.stream_button.set_label('Stream')
## self.build_filename()
-
-
+
## In this state, this function freeze the streaming if the fields are NOT completed
def build_filename(self):
"""Get text in entries, check if empty and apply formatting if needed."""
self.speakerinfo_entry.set_text('')
self.sessioninfo_entry.set_text('')
- # Returns the meter deflection percentage given a db value
def iec_scale(self, db):
+ """Returns the meter deflection percentage given a db value."""
pct = 0.0
if db < -70.0: