9 _moduleLogger = logging.getLogger("channel.call")
13 telepathy.server.ChannelTypeStreamedMedia,
14 telepathy.server.ChannelInterfaceCallState,
15 telepathy.server.ChannelInterfaceGroup,
18 def __init__(self, connection, manager, props, contactHandle):
19 self._manager = manager
23 # Older python-telepathy way
24 telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
26 # Newer python-telepathy way
27 telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, manager, props)
28 telepathy.server.ChannelInterfaceCallState.__init__(self)
29 telepathy.server.ChannelInterfaceGroup.__init__(self)
30 self._contactHandle = contactHandle
31 self._implement_property_get(
32 telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA,
34 "InitialAudio": self.initial_audio,
35 "InitialVideo": self.initial_video,
39 def initial_audio(self):
42 def initial_video(self):
45 @gtk_toolbox.log_exception(_moduleLogger)
50 telepathy.server.ChannelTypeStreamedMedia.Close(self)
51 if self._manager.channel_exists(self._props):
52 # Older python-telepathy requires doing this manually
53 self._manager.remove_channel(self)
54 self.remove_from_connection()
56 @gtk_toolbox.log_exception(_moduleLogger)
57 def ListStreams(self):
59 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
63 @gtk_toolbox.log_exception(_moduleLogger)
64 def RemoveStreams(self, streams):
66 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
68 raise telepathy.errors.NotImplemented("Cannot remove a stream")
70 @gtk_toolbox.log_exception(_moduleLogger)
71 def RequestStreamDirection(self, stream, streamDirection):
73 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
75 @note Since streams are short lived, not bothering to implement this
77 _moduleLogger.info("A request was made to change the stream direction")
78 raise telepathy.errors.NotImplemented("Cannot change directions")
80 @gtk_toolbox.log_exception(_moduleLogger)
81 def RequestStreams(self, contactId, streamTypes):
83 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
85 @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
87 contact = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
88 assert self._contactHandle == contact, "%r != %r" % (self._contactHandle, contact)
89 contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
91 self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
92 self._conn.session.backend.call(contactNumber)
93 self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
96 streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
97 streamDirection = telepathy.constants.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL
98 pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
99 return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
101 @gtk_toolbox.log_exception(_moduleLogger)
102 def GetCallStates(self):
104 For org.freedesktop.Telepathy.Channel.Interface.CallState
106 Get the current call states for all contacts involved in this call.
107 @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
109 return {self._contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}