Commit dd638015 authored by Mohana Datta Yelugoti's avatar Mohana Datta Yelugoti Committed by Alexandru Băluț

render: Disable stream while rendering if timeline doesn't contain stream

If timeline contains only audio, in the render dialog video box
is disabled. Similar thing happens if the timeline contains only
video, then the audio box is disabled.

Fixes #2257
parent d32d0276
Pipeline #43965 failed with stages
in 56 minutes and 49 seconds
......@@ -591,9 +591,6 @@ class RenderDialog(Loggable):
preset_table.attach(text_widget, 1, 0, 1, 1)
text_widget.show()
self.video_output_checkbutton.props.active = self.project.video_profile.is_enabled()
self.audio_output_checkbutton.props.active = self.project.audio_profile.is_enabled()
self.__automatically_use_proxies = builder.get_object(
"automatically_use_proxies")
......@@ -609,6 +606,14 @@ class RenderDialog(Loggable):
self.window.set_icon_name("system-run-symbolic")
self.window.set_transient_for(self.app.gui)
media_types = self.project.ges_timeline.ui.media_types
self.audio_output_checkbutton.props.active = media_types & GES.TrackType.AUDIO
self._update_audio_widgets_sensitivity()
self.video_output_checkbutton.props.active = media_types & GES.TrackType.VIDEO
self._update_video_widgets_sensitivity()
def _rendering_settings_changed_cb(self, unused_project, unused_item):
"""Handles Project metadata changes."""
self.updateResolution()
......@@ -662,6 +667,24 @@ class RenderDialog(Loggable):
set_combo_value(self.channels_combo, self.project.audiochannels)
set_combo_value(self.sample_rate_combo, self.project.audiorate)
def _update_audio_widgets_sensitivity(self):
active = self.audio_output_checkbutton.get_active()
self.channels_combo.set_sensitive(active)
self.sample_rate_combo.set_sensitive(active)
self.audio_encoder_combo.set_sensitive(active)
self.audio_settings_button.set_sensitive(active)
self.project.audio_profile.set_enabled(active)
self.__updateRenderButtonSensitivity()
def _update_video_widgets_sensitivity(self):
active = self.video_output_checkbutton.get_active()
self.scale_spinbutton.set_sensitive(active)
self.frame_rate_combo.set_sensitive(active)
self.video_encoder_combo.set_sensitive(active)
self.video_settings_button.set_sensitive(active)
self.project.video_profile.set_enabled(active)
self.__updateRenderButtonSensitivity()
def _displayRenderSettings(self):
"""Displays the settings available only in the RenderDialog."""
# Video settings
......@@ -1168,22 +1191,10 @@ class RenderDialog(Loggable):
dialog.window.run()
def _audioOutputCheckbuttonToggledCb(self, unused_audio):
active = self.audio_output_checkbutton.get_active()
self.channels_combo.set_sensitive(active)
self.sample_rate_combo.set_sensitive(active)
self.audio_encoder_combo.set_sensitive(active)
self.audio_settings_button.set_sensitive(active)
self.project.audio_profile.set_enabled(active)
self.__updateRenderButtonSensitivity()
self._update_audio_widgets_sensitivity()
def _videoOutputCheckbuttonToggledCb(self, unused_video):
active = self.video_output_checkbutton.get_active()
self.scale_spinbutton.set_sensitive(active)
self.frame_rate_combo.set_sensitive(active)
self.video_encoder_combo.set_sensitive(active)
self.video_settings_button.set_sensitive(active)
self.project.video_profile.set_enabled(active)
self.__updateRenderButtonSensitivity()
self._update_video_widgets_sensitivity()
def __updateRenderButtonSensitivity(self):
video_enabled = self.video_output_checkbutton.get_active()
......
......@@ -308,17 +308,12 @@ class Layer(Gtk.Layout, Zoomable, Loggable):
# Cannot find more types than these.
break
if not (self.media_types & GES.TrackType.AUDIO) and not (self.media_types & GES.TrackType.VIDEO):
# An empty layer only shows the video strip.
self.media_types = GES.TrackType.VIDEO
height = 0
if self.media_types & GES.TrackType.AUDIO:
height += LAYER_HEIGHT / 2
if self.media_types & GES.TrackType.VIDEO:
height += LAYER_HEIGHT / 2
if (self.media_types & GES.TrackType.AUDIO) and (self.media_types & GES.TrackType.VIDEO):
self.props.height_request = LAYER_HEIGHT
else:
# If the layer is empty, set layer's height to default height.
self.props.height_request = LAYER_HEIGHT / 2
self.props.height_request = height
if hasattr(self.ges_layer, "control_ui") and self.ges_layer.control_ui:
self.ges_layer.control_ui.update(self.media_types)
......
......@@ -399,6 +399,24 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self.app.settings.connect("edgeSnapDeadbandChanged",
self.__snap_distance_changed_cb)
@property
def media_types(self):
"""Gets the media types present in the layers.
Returns:
GES.TrackType: The type of media available in the timeline.
"""
media_types = GES.TrackType(0)
for ges_layer in self.ges_timeline.get_layers():
media_types |= ges_layer.ui.media_types
if ((media_types & GES.TrackType.AUDIO) and
(media_types & GES.TrackType.VIDEO)):
break
return media_types
def resetSelectionGroup(self):
self.debug("Reset selection group")
if self.current_group:
......
......@@ -36,11 +36,11 @@ THICK = LAYER_HEIGHT
class BaseTestTimeline(common.TestCase):
"""Test case with tools for setting up a timeline."""
def add_clip(self, layer, start, inpoint=0, duration=10):
def add_clip(self, layer, start, inpoint=0, duration=10, clip_type=GES.TrackType.UNKNOWN):
"""Creates a clip on the specified layer."""
asset = GES.UriClipAsset.request_sync(
common.get_sample_uri("tears_of_steel.webm"))
return layer.add_asset(asset, start, inpoint, duration, GES.TrackType.UNKNOWN)
return layer.add_asset(asset, start, inpoint, duration, clip_type)
def addClipsSimple(self, timeline, num_clips):
"""Creates a number of clips on a new layer."""
......@@ -150,6 +150,39 @@ class TestLayers(BaseTestTimeline):
self.assertEqual(len(timeline.__on_separators), 1,
"The separators must be forgotten only in dragEnd()")
def test_media_types(self):
timeline_container = create_timeline_container()
timeline = timeline_container.timeline
ges_layer_1 = timeline.ges_timeline.append_layer()
ges_layer_2 = timeline.ges_timeline.append_layer()
# Timeline should contain no media_types.
self.assertEqual(timeline.media_types, GES.TrackType(0))
# Timeline should now contain only audio media type.
ges_clip_audio = self.add_clip(ges_layer_1, 10, clip_type=GES.TrackType.AUDIO)
self.assertEqual(timeline.media_types, GES.TrackType.AUDIO)
ges_layer_1.remove_clip(ges_clip_audio)
ges_clip_video = self.add_clip(ges_layer_2, 20, clip_type=GES.TrackType.VIDEO)
self.assertEqual(timeline.media_types, GES.TrackType.VIDEO)
# Timeline should contain no media_types.
ges_layer_2.remove_clip(ges_clip_video)
self.assertEqual(timeline.media_types, GES.TrackType(0))
# Timeline should contain both clips.
ges_clip_audio = self.add_clip(ges_layer_1, 10, clip_type=GES.TrackType.AUDIO)
ges_clip_video = self.add_clip(ges_layer_2, 20, clip_type=GES.TrackType.VIDEO)
self.assertEqual(timeline.media_types,
GES.TrackType.VIDEO | GES.TrackType.AUDIO)
# Timeline should contain no clips.
ges_layer_1.remove_clip(ges_clip_audio)
ges_layer_2.remove_clip(ges_clip_video)
self.assertEqual(timeline.media_types, GES.TrackType(0))
def test_create_layer(self):
self.check_create_layer([0, 0, 0, 0], [3, 2, 1, 0])
self.check_create_layer([0, 1, 1, 1], [0, 3, 2, 1])
......
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