From: David Testé Date: Tue, 8 Mar 2016 22:17:47 +0000 (+0100) Subject: Modifying filename building. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3d4734cb00f130609f614b3204e78db256a553bf;p=libre-streamer.git Modifying filename building. --- diff --git a/stream_2016/gstconf.py b/stream_2016/gstconf.py index ab93f1d..fd8dc3e 100755 --- a/stream_2016/gstconf.py +++ b/stream_2016/gstconf.py @@ -31,6 +31,8 @@ AUDIO_DEFAULT = PATHNAME + 'AUDIO_DEFAULT' 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 @@ -46,10 +48,7 @@ class New_user_pipeline(): 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.""" @@ -95,7 +94,6 @@ class New_user_pipeline(): 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): @@ -112,7 +110,11 @@ class New_user_pipeline(): 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: @@ -405,25 +407,44 @@ class New_user_pipeline(): 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