This repository has been archived by the owner on Jun 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaStream.py
82 lines (60 loc) · 2.49 KB
/
MediaStream.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright (C) 2009-2011 AG Projects. See LICENSE for details.
#
__all__ = ['MediaStream', 'STATE_IDLE', 'STATE_DNS_LOOKUP', 'STATE_DNS_FAILED', 'STATE_CONNECTING',
'STATE_CONNECTED', 'STATE_FAILED', 'STATE_FINISHED', 'STREAM_IDLE', 'STREAM_WAITING_DNS_LOOKUP', 'STREAM_RINGING', 'STREAM_ADDING',
'STREAM_CONNECTING', 'STREAM_PROPOSING', 'STREAM_CONNECTED', 'STREAM_DISCONNECTING', 'STREAM_CANCELLING', 'STREAM_FAILED', 'STREAM_INCOMING']
from application.notification import NotificationCenter, NotificationData
from Foundation import NSObject
from AppKit import NSApp
STATE_IDLE = "IDLE"
STATE_DNS_LOOKUP = "DNS_LOOKUP"
STATE_DNS_FAILED = "DNS_FAILED"
STATE_CONNECTING = "CONNECTING"
STATE_CONNECTED = "CONNECTED"
STATE_FAILED = "FAILED"
STATE_FINISHED = "FINISHED"
STREAM_IDLE = "IDLE"
STREAM_WAITING_DNS_LOOKUP = "WAITING_DNS_LOOKUP"
STREAM_RINGING = "RINGING"
STREAM_ADDING = "ADDING"
STREAM_CONNECTING = "CONNECTING"
STREAM_PROPOSING = "PROPOSING"
STREAM_CONNECTED = "CONNECTED"
STREAM_DISCONNECTING = "DISCONNECTING"
STREAM_CANCELLING = "CANCELLING"
STREAM_FAILED = "FAILED"
STREAM_INCOMING = "INCOMING"
class MediaStream(NSObject):
sessionController = None
stream = None
status = None
def __new__(cls, *args, **kwargs):
return cls.alloc().initWithOwner_stream_(*args)
def initWithOwner_stream_(self, owner, stream):
self = super(MediaStream, self).init()
if self:
self.sessionController = owner
self.stream = stream
return self
def changeStatus(self, newstate, fail_reason=None):
NotificationCenter().post_notification("BlinkStreamHandlerChangedState", sender=self, data=NotificationData(state=newstate, detail=fail_reason))
@property
def isConnecting(self):
return self.status in (STREAM_WAITING_DNS_LOOKUP, STREAM_RINGING, STREAM_PROPOSING, STREAM_ADDING, STREAM_CONNECTING, STREAM_INCOMING)
@property
def session(self):
return self.sessionController.session
@property
def sessionControllersManager(self):
return NSApp.delegate().contactsWindowController.sessionControllersManager
@property
def remoteParty(self):
return self.sessionController.remoteParty if self.sessionController else '?'
def reset(self):
self.status = STREAM_IDLE
def removeFromSession(self):
self.sessionController.removeStreamHandler(self)
def sessionRinging(self):
pass
def sessionStateChanged(self, newstate, detail):
pass