arek - in flumotion/trunk: . flumotion/component/consumers/disker

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Fri Jul 6 17:58:47 CEST 2007


Author: arek
Date: Fri Jul  6 17:58:45 2007
New Revision: 5304

Added:
   flumotion/trunk/flumotion/component/consumers/disker/disker_plug.py
Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/consumers/disker/disker.py
   flumotion/trunk/flumotion/component/consumers/disker/disker.xml
Log:
	* flumotion/component/consumers/disker/disker.py
	  (Disker.change_filename, Disker.stop_recording,
	  Disker._plug_recording_started, Disker._plug_recording_stopped):
	Add disker plug hooks. Remove duplication of code of the
	stop_recording() method.
	* flumotion/component/consumers/disker/disker_plug.py:
	Add base class for disker plugs.
	* flumotion/component/consumers/disker/disker.xml:
	Add disker plug registry entries.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Fri Jul  6 17:58:45 2007
@@ -1,3 +1,17 @@
+2007-07-06  Arek Korbik  <arkadini at gmail.com>
+
+	* flumotion/component/consumers/disker/disker.py
+	  (Disker.change_filename, Disker.stop_recording,
+	  Disker._plug_recording_started, Disker._plug_recording_stopped):
+	Add disker plug hooks. Remove duplication of code of the
+	stop_recording() method.
+
+	* flumotion/component/consumers/disker/disker_plug.py:
+	Add base class for disker plugs.
+
+	* flumotion/component/consumers/disker/disker.xml:
+	Add disker plug registry entries.
+
 2007-07-04  Andy Wingo  <wingo at pobox.com>
 
 	* flumotion/common/registry.py (RegistryDirectory._getFileLists):

Modified: flumotion/trunk/flumotion/component/consumers/disker/disker.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/disker/disker.py	(original)
+++ flumotion/trunk/flumotion/component/consumers/disker/disker.py	Fri Jul  6 17:58:45 2007
@@ -209,18 +209,12 @@
         else:
             ext = 'data'
         
+        self.stop_recording()
+
         sink = self.get_element('fdsink')
         if sink.get_state() == gst.STATE_NULL:
             sink.set_state(gst.STATE_READY)
 
-        if self.file:
-            self.file.flush()
-            sink.emit('remove', self.file.fileno())
-            self.file = None
-            if self.symlink_to_last_recording:
-                self.update_symlink(self.location,
-                                    self.symlink_to_last_recording)
-
         filename = ""
         if not filenameTemplate:
             filenameTemplate = self._defaultFilenameTemplate
@@ -238,6 +232,7 @@
                                        % (self.location,))))
             self.addMessage(m)
             return
+        self._plug_recording_started(self.file, self.location)
         sink.emit('add', self.file.fileno())
         self.uiState.set('filename', self.location)
         self.uiState.set('recording', True)
@@ -276,6 +271,7 @@
         if self.file:
             self.file.flush()
             sink.emit('remove', self.file.fileno())
+            self._plug_recording_stopped(self.file, self.location)
             self.file = None
             self.uiState.set('filename', None)
             self.uiState.set('recording', False)
@@ -393,6 +389,20 @@
         else:
             self.warning("Cannot parse ICAL; neccesary modules not installed")
 
+    def _plug_recording_started(self, file, location):
+        socket = 'flumotion.component.consumers.disker.disker_plug.DiskerPlug'
+        for plug in self.plugs[socket]:
+            self.debug('invoking recording_started on '
+                       'plug %r on socket %s', plug, socket)
+            plug.recording_started(file, location)
+
+    def _plug_recording_stopped(self, file, location):
+        socket = 'flumotion.component.consumers.disker.disker_plug.DiskerPlug'
+        for plug in self.plugs[socket]:
+            self.debug('invoking recording_stopped on '
+                       'plug %r on socket %s', plug, socket)
+            plug.recording_stopped(file, location)
+
     def _markers_event_probe(self, element, event):
         if event.type == gst.EVENT_CUSTOM_DOWNSTREAM:
             evt_struct = event.get_structure()

Modified: flumotion/trunk/flumotion/component/consumers/disker/disker.xml
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/disker/disker.xml	(original)
+++ flumotion/trunk/flumotion/component/consumers/disker/disker.xml	Fri Jul  6 17:58:45 2007
@@ -15,7 +15,11 @@
         <entry type="admin/text" location="admin_text.py"
               function="UIClass" />
       </entries>
-      
+
+      <sockets>
+        <socket type="flumotion.component.consumers.disker.disker_plug.DiskerPlug" />
+      </sockets>
+
       <properties>
         <property name="directory" type="string" required="yes" />
         <property name="rotate-type" type="string" required="no"
@@ -90,6 +94,19 @@
             </directory>
         </directories>
      </bundle>
+
+    <bundle name="disker-plug">
+      <dependencies>
+        <dependency name="base-plugs" />
+        <dependency name="disker-base"/>
+      </dependencies>
+      <directories>
+        <directory name="flumotion/component/consumers/disker">
+          <filename location="disker_plug.py"/>
+        </directory>
+      </directories>
+    </bundle>
+
   </bundles>
 
 </registry> 

Added: flumotion/trunk/flumotion/component/consumers/disker/disker_plug.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/consumers/disker/disker_plug.py	Fri Jul  6 17:58:45 2007
@@ -0,0 +1,51 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+
+from flumotion.component.plugs import base
+
+
+class DiskerPlug(base.ComponentPlug):
+    """
+    Base class for disker plugs.
+    """
+
+    def recording_started(self, file, location):
+        """
+        Called before disker starts writing data to a new file.
+
+        @param file:     the file object
+        @type  file:     file
+        @param location: the location of the file
+        @type  location: str
+        """
+        pass
+
+    def recording_stopped(self, file, location):
+        """
+        Called after disker stops writing data to a file.
+
+        @param file:     the file object
+        @type  file:     file
+        @param location: the location of the file
+        @type  location: str
+        """
+        pass


More information about the flumotion-commit mailing list