RAWVIDEO_DEFAULT = PATHNAME + 'RAWVIDEO_DEFAULT'
STREAM_DEFAULT = PATHNAME + 'STREAM_DEFAULT'
BACKUP_SUFFIX = '_BACKUP'
+FAILED_SUFFIX = '_FAILED_'
+fail_counter = 1
AUDIO_BACKUP = AUDIO_DEFAULT + BACKUP_SUFFIX
RAWVIDEO_BACKUP = RAWVIDEO_DEFAULT + BACKUP_SUFFIX
STREAM_BACKUP = STREAM_DEFAULT + BACKUP_SUFFIX
def __init__(self, feed='main'):
self.feed = feed
-## if self.feed == 'main':
self.user_pipeline = self.create_gstreamer_pipeline()
-## elif self.feed == 'backup':
-## self.user_pipeline = self.create_gstreamer_pipeline(feed='backup')
def create_video_sources(self):
"""Create video inputs from various sources."""
def create_audio_sources(self):
"""Create audio inputs from various sources."""
self.audiosrc = Gst.ElementFactory.make('pulsesrc', 'audiosrc')
-## self.videosrc.set_property('latency', 0)
self.audiosrc.set_property('device', AUDIO_INPUT)
def create_audiolevel_plugin(self):
self.disksink_audio.set_property('location', AUDIO_DEFAULT)
self.disksink_stream = Gst.ElementFactory.make('filesink')
self.disksink_stream.set_property('location', STREAM_DEFAULT)
-
+ if self.feed == 'backup':
+ self.disksink_rawvideo.set_property('location', RAWVIDEO_BACKUP)
+ self.disksink_audio.set_property('location', AUDIO_BACKUP)
+ self.disksink_stream.set_property('location', STREAM_BACKUP)
+
def create_streamsink(self):
"""Create streamable output elements."""
# To local screen:
self.streampipe.set_state(Gst.State.NULL)
print(INFO, gettime(), 'STOPPED State resquested')
- def get_stream_state(self):
- print(self.streampipe.get_state(self))
-##[FIXME] return self.streampipe.get_state()
-
- def set_filenames(self, string):
+ def set_filenames(self, string, streamfailed=False):
"""Sets filename and location for each sink."""
+ global fail_counter
filename = string
audio = PATHNAME + filename + '_AUDIO'
rawvideo = PATHNAME + filename + '_RAWVIDEO'
stream = PATHNAME + filename + '_STREAM'
+ print('FEED STATE: ', self.feed)
if self.feed == 'main':
- rename(AUDIO_DEFAULT, audio)
- rename(RAWVIDEO_DEFAULT, rawvideo)
- rename(STREAM_DEFAULT, stream)
+ if streamfailed and filename:
+ audio = audio + FAILED_SUFFIX + str(fail_counter)
+ rawvideo = rawvideo + FAILED_SUFFIX + str(fail_counter)
+ stream = stream + FAILED_SUFFIX + str(fail_counter)
+ rename(AUDIO_DEFAULT, audio)
+ rename(RAWVIDEO_DEFAULT, rawvideo)
+ rename(STREAM_DEFAULT, stream)
+ fail_counter += 1
+ elif streamfailed:
+ audio = AUDIO_DEFAULT + FAILED_SUFFIX + str(fail_counter)
+ rawvideo = RAWVIDEO_DEFAULT + FAILED_SUFFIX + str(fail_counter)
+ stream = STREAM_DEFAULT + FAILED_SUFFIX + str(fail_counter)
+ rename(AUDIO_DEFAULT, audio)
+ rename(RAWVIDEO_DEFAULT, rawvideo)
+ rename(STREAM_DEFAULT, stream)
+ fail_counter += 1
+ else:
+ rename(AUDIO_DEFAULT, audio)
+ rename(RAWVIDEO_DEFAULT, rawvideo)
+ rename(STREAM_DEFAULT, stream)
elif self.feed == 'backup':
+ print('INSIDE BACKUP RENAMING')
rename(AUDIO_BACKUP, audio)
rename(RAWVIDEO_BACKUP, rawvideo)
rename(STREAM_BACKUP, stream)
+ def rename_files():
+ pass
+
def get_gstreamer_bus():
return bus