1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import os
23 import gst
24
25 from flumotion.component import feedcomponent
26 from flumotion.common import log, messages, errors
27 from twisted.internet.protocol import ServerFactory, Protocol
28 from twisted.internet import defer, reactor
29
30 __version__ = "$Rev$"
31
32
33
34
35
37 """ Dumb Protocol, doesn't do anything """
38
40 """ Stop reading/writing """
41 if self.factory.component.currentTransport:
42
43 self.transport.loseConnection()
44 return
45 self.transport.stopReading()
46 self.transport.stopWriting()
47 self.factory.component.setUnixTransport(self.transport)
48
49
50
51
52
53 -class UnixDomainDumbFactory(ServerFactory):
54
55 protocol = DumbProtocol
56
57 - def __init__(self, component):
59
60
61
62
63 -class UnixDomainProvider(feedcomponent.ParseLaunchComponent):
64
66 self.factory = None
67 self.socketPath = None
68 self.currentTransport = None
69
70 - def setUnixTransport(self, transport):
71 self.debug("got transport %r [fd:%d]" % (
72 transport, transport.fileno()))
73 self.currentTransport = transport
74
75
76 fdsrc = self.pipeline.get_by_name("fdsrc")
77 fdsrc.props.fd = transport.fileno()
78
79
80
81
82 self.link()
83
84 - def get_pipeline_string(self, properties):
85 """ return the pipeline """
86 return 'fdsrc name=fdsrc ! gdpdepay'
87
89 props = self.config['properties']
90 self.socketPath = props.get('path')
91 self.factory = UnixDomainDumbFactory(self)
92
93
94 self.pipeline.set_state(gst.STATE_READY)
95
96
97 if os.path.exists(self.socketPath):
98 os.unlink(self.socketPath)
99
100 self.log("Starting to listen on UNIX : %s" % self.socketPath)
101 reactor.listenUNIX(self.socketPath, self.factory)
102
103