Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start of supporting HDV over firewire. #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions flumotion/component/producers/firewire/firewire.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# See comments in gstdvdec.c for details on the dv format.



class Firewire(feedcomponent.ParseLaunchComponent):

def do_check(self):
Expand Down Expand Up @@ -75,12 +76,22 @@ def get_pipeline_string(self, props):
if props.get('scaled-width', None) is not None:
self.warnDeprecatedProperties(['scaled-width'])

self.is_square = props.get('is-square', False)
is_hdv = props.get('is-hdv', False)

# HDV streams generally have square pixels, while normal DV streams don't.
self.is_square = props.get('is-square', is_hdv)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

720p HDV has square pixels, but it's not the case for 1080i HDV I guess. Is it safe to set options as square pixels?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal 1080i has square pixels right? Is it just 1080i HDV which doesn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://en.wikipedia.org/wiki/HDV#Specifications says HDV 1080i has pixel aspect ratio of 1.33, not sure about normal 1080i.

self.width = props.get('width', 0)
self.height = props.get('height', 0)

decoder = props.get('decoder', 'dvdec')
if not self.is_square and not self.height:
self.height = int(576 * self.width/720.) # assuming PAL
if is_hdv:
# HDV we assume 16:9
self.height = int(self.width*16/9)
else:
# DV we assume PAL ratios
self.height = int(576 * self.width/720.)

self.add_borders = props.get('add-borders', True)
guid = "guid=%s" % props.get('guid', 0)
self.deintMode = props.get('deinterlace-mode', 'auto')
Expand All @@ -96,17 +107,30 @@ def get_pipeline_string(self, props):
# replace it with videotestsrc of the same size and PAR, so we can
# unittest the pipeline
# need a queue in case tcpserversink blocks somehow
template = ('dv1394src %s'
' ! tee name=t'
' ! queue leaky=2 max-size-time=1000000000'
' ! dvdemux name=demux'
' demux. ! queue ! %s name=decoder'
' ! @feeder:video@'
' demux. ! queue ! audio/x-raw-int '
' ! volume name=setvolume'
' ! level name=volumelevel message=true '
' ! @feeder:audio@'
' t. ! queue ! @feeder:dv@' % (guid, decoder))
if is_hdv:
template = ('hdv1394src %s'
' ! tee name=t'
' ! queue leaky=2 max-size-time=1000000000'
' ! mpegtsdemux name=demux'
' demux. ! queue ! mpeg2dec name=decoder'
' ! @feeder:video@'
' demux. ! queue ! mad ! audio/x-raw-int '
' ! volume name=setvolume'
' ! level name=volumelevel message=true '
' ! @feeder:audio@'
' t. ! queue ! @feeder:hdv@' % (guid,))
else:
template = ('dv1394src %s'
' ! tee name=t'
' ! queue leaky=2 max-size-time=1000000000'
' ! dvdemux name=demux'
' demux. ! queue ! %s name=decoder'
' ! @feeder:video@'
' demux. ! queue ! audio/x-raw-int '
' ! volume name=setvolume'
' ! level name=volumelevel message=true '
' ! @feeder:audio@'
' t. ! queue ! @feeder:dv@' % (guid, decoder))

return template

Expand Down
2 changes: 2 additions & 0 deletions flumotion/component/producers/firewire/firewire.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
feeder="video" />

<properties>
<property name="is-hdv" type="bool"
_description="Whether the camera output is HDV rather then DV." />
<property name="height" type="int"
_description="The height to scale to." />
<property name="width" type="int"
Expand Down
55 changes: 38 additions & 17 deletions flumotion/component/producers/firewire/wizard.glade
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.6 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="window1">
<property name="title" translatable="yes">window1</property>
<child>
Expand All @@ -12,7 +12,7 @@
<widget class="GtkFrame" id="frame_device">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
Expand All @@ -28,6 +28,19 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="hdv">
<property name="label" translatable="yes">HDV</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
Expand All @@ -48,13 +61,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame_camera_settings">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment12">
<property name="visible">True</property>
Expand Down Expand Up @@ -92,7 +106,7 @@
<widget class="GtkFrame" id="frame_scaling">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
Expand All @@ -114,6 +128,7 @@
<packing>
<property name="expand">False</property>
<property name="padding">6</property>
<property name="position">0</property>
</packing>
</child>
<child>
Expand All @@ -132,16 +147,17 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="is_square">
<property name="label" translatable="yes">Convert to s_quare pixels</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip" translatable="yes">Recommended if you are outputting to a computer screen</property>
<property name="label" translatable="yes">Convert to s_quare pixels</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_is_square_toggled"/>
Expand Down Expand Up @@ -169,13 +185,14 @@
</widget>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame_width_correction">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
Expand All @@ -186,22 +203,25 @@
<property name="visible">True</property>
<child>
<widget class="GtkRadioButton" id="radiobutton_width_none">
<property name="label" translatable="yes">_No width correction</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_No width correction</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_radiobutton_width_none_toggled"/>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radiobutton_width_stretch">
<property name="label" translatable="yes">_Stretch to multiple of 8 pixels</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Stretch to multiple of 8 pixels</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton_width_none</property>
<signal name="toggled" handler="on_radiobutton_width_stretch_toggled"/>
Expand All @@ -212,11 +232,11 @@
</child>
<child>
<widget class="GtkRadioButton" id="radiobutton_width_pad">
<property name="label" translatable="yes">_Pad to multiple of 8 pixels</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Pad to multiple of 8 pixels</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton_width_none</property>
Expand Down Expand Up @@ -256,7 +276,7 @@
<widget class="GtkFrame" id="frame_capture">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
Expand All @@ -276,6 +296,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -329,7 +350,7 @@
<widget class="GtkFrame" id="frame_output_format">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment13">
<property name="visible">True</property>
Expand Down
26 changes: 22 additions & 4 deletions flumotion/component/producers/firewire/wizard_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class FireWireProducer(AudioProducer, VideoProducer):
def __init__(self):
super(FireWireProducer, self).__init__()

self.properties.is_hdv = False
self.properties.is_square = True
self.properties.framerate = 12.5
self.properties.decoder = 'ffdec_dvvideo'
Expand Down Expand Up @@ -197,13 +198,21 @@ def _populateDevices(self):
msg = messages.Info(T_(N_('Checking for Firewire devices...')),
mid='firewire-check')
self.wizard.add_msg(msg)

self._devices = {}
self._populateDevicesFor('dv1394src', False)
self._populateDevicesFor('hdv1394src', True)

def _populateDevicesFor(self, src, hdv):
d = self.runInWorker('flumotion.worker.checks.device',
'fetchDevices', 'firewire-check',
['dv1394src'], 'guid')
[src], 'guid')

def firewireCheckDone(devices):
self.wizard.clear_msg('firewire-check')
self.guid.prefill(devices)
for device in devices:
self._devices[device] = hdv
self.guid.prefill(self._devices.keys())

def trapRemoteFailure(failure):
failure.trap(errors.RemoteRunFailure)
Expand All @@ -223,8 +232,17 @@ def _runChecks(self):
mid='firewire-check')
self.wizard.add_msg(msg)

guid = self.guid.get_selected()
try:
hdv = self._devices[guid]
except KeyError:
hdv = False

# Change the checkbox...
self.hdv.set_selected(hdv)

d = self.runInWorker('flumotion.worker.checks.gst010', 'check1394',
mid='firewire-check', guid=self.guid.get_selected())
mid='firewire-check', guid=guid)

def chooseDecoder(missing):
if 'ffdec_dvvideo' in missing and 'dvdec' not in missing:
Expand Down Expand Up @@ -311,7 +329,7 @@ def setup(self):
self.guid.data_type = int
self.framerate.data_type = float
self.add_proxy(self.model.properties,
['guid', 'framerate', 'is_square'])
['guid', 'is_hdv', 'framerate', 'is_square'])


class FireWireAudioStep(_FireWireCommon, AudioProducerStep):
Expand Down