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: 6306 $"
31
32
33
35 """ Dumb Protocol, doesn't do anything """
36
38 """ Stop reading/writing """
39 if self.factory.component.currentTransport:
40
41 self.transport.loseConnection()
42 return
43 self.transport.stopReading()
44 self.transport.stopWriting()
45 self.factory.component.setUnixTransport(self.transport)
46
47
48
49 -class UnixDomainDumbFactory(ServerFactory):
50
51 protocol = DumbProtocol
52
53 - def __init__(self, component):
55
56
57 -class UnixDomainProvider(feedcomponent.ParseLaunchComponent):
58
60 self.factory = None
61 self.socketPath = None
62 self.currentTransport = None
63
64 - def setUnixTransport(self, transport):
65 self.debug("got transport %r [fd:%d]" % (transport, transport.fileno()))
66 self.currentTransport = transport
67
68
69 fdsrc = self.pipeline.get_by_name("fdsrc")
70 fdsrc.props.fd = transport.fileno()
71
72
73
74
75 self.link()
76
77 - def get_pipeline_string(self, properties):
78 """ return the pipeline """
79 return 'fdsrc name=fdsrc ! gdpdepay'
80
82 props = self.config['properties']
83 self.socketPath = props.get('path')
84 self.factory = UnixDomainDumbFactory(self)
85
86
87 self.pipeline.set_state(gst.STATE_READY)
88
89
90 if os.path.exists(self.socketPath):
91 os.unlink(self.socketPath)
92
93 self.log("Starting to listen on UNIX : %s" % self.socketPath)
94 reactor.listenUNIX(self.socketPath, self.factory)
95
96