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
22 telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
23 telepathy.server.ChannelInterfaceCallState.__init__(self)
24 telepathy.server.ChannelInterfaceGroup.__init__(self)
25 self._contactHandle = contactHandle
26 self._implement_property_get(
27 telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA,
29 "InitialAudio": self.initial_audio,
30 "InitialVideo": self.initial_video,
34 def initial_audio(self):
37 def initial_video(self):
40 @gtk_toolbox.log_exception(_moduleLogger)
45 telepathy.server.ChannelTypeStreamedMedia.Close(self)
46 if self._manager.channel_exists(self._props):
47 # Older python-telepathy requires doing this manually
48 self._manager.remove_channel(self)
49 self.remove_from_connection()
51 @gtk_toolbox.log_exception(_moduleLogger)
52 def ListStreams(self):
54 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
58 @gtk_toolbox.log_exception(_moduleLogger)
59 def RemoveStreams(self, streams):
61 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
63 raise telepathy.errors.NotImplemented("Cannot remove a stream")
65 @gtk_toolbox.log_exception(_moduleLogger)
66 def RequestStreamDirection(self, stream, streamDirection):
68 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
70 @note Since streams are short lived, not bothering to implement this
72 _moduleLogger.info("A request was made to change the stream direction")
73 raise telepathy.errors.NotImplemented("Cannot change directions")
75 @gtk_toolbox.log_exception(_moduleLogger)
76 def RequestStreams(self, contactId, streamTypes):
78 For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
80 @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
82 contact = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
83 assert self._contactHandle == contact, "%r != %r" % (self._contactHandle, contact)
84 contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
86 self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
87 self._conn.session.backend.call(contactNumber)
88 self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
91 streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
92 streamDirection = telepathy.constants.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL
93 pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
94 return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
96 @gtk_toolbox.log_exception(_moduleLogger)
97 def GetCallStates(self):
99 For org.freedesktop.Telepathy.Channel.Interface.CallState
101 Get the current call states for all contacts involved in this call.
102 @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
104 return {self._contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}