Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
9e8103e9
Commit
9e8103e9
authored
Mar 10, 2014
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added active and proposed properties to StreamContainer
parent
dd4ddd93
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
12 deletions
+35
-12
sessions.py
blink/sessions.py
+35
-12
No files found.
blink/sessions.py
View file @
9e8103e9
...
@@ -212,7 +212,14 @@ class StreamSet(object):
...
@@ -212,7 +212,14 @@ class StreamSet(object):
return
self
.
_stream_map
.
get
(
key
,
default
)
return
self
.
_stream_map
.
get
(
key
,
default
)
class
StreamContainer
(
object
):
class
StreamMap
(
dict
):
def
__init__
(
self
):
super
(
StreamMap
,
self
)
.
__init__
()
self
.
active_map
=
{}
self
.
proposed_map
=
{}
class
StreamContainerView
(
object
):
def
__init__
(
self
,
session
,
stream_map
):
def
__init__
(
self
,
session
,
stream_map
):
self
.
_session
=
session
self
.
_session
=
session
self
.
_stream_map
=
stream_map
self
.
_stream_map
=
stream_map
...
@@ -241,22 +248,35 @@ class StreamContainer(object):
...
@@ -241,22 +248,35 @@ class StreamContainer(object):
def
get
(
self
,
key
,
default
=
None
):
def
get
(
self
,
key
,
default
=
None
):
return
self
.
_stream_map
.
get
(
key
,
default
)
return
self
.
_stream_map
.
get
(
key
,
default
)
class
StreamContainer
(
StreamContainerView
):
@
property
def
active
(
self
):
return
StreamContainerView
(
self
.
_session
,
self
.
_stream_map
.
active_map
)
@
property
def
proposed
(
self
):
return
StreamContainerView
(
self
.
_session
,
self
.
_stream_map
.
proposed_map
)
def
add
(
self
,
stream
):
def
add
(
self
,
stream
):
notification_center
=
NotificationCenter
()
assert
stream
not
in
self
old_stream
=
self
.
_stream_map
.
get
(
stream
.
type
,
None
)
if
old_stream
is
not
None
:
notification_center
.
remove_observer
(
self
.
_session
,
sender
=
old_stream
)
stream
.
blink_session
=
self
.
_session
stream
.
blink_session
=
self
.
_session
self
.
_stream_map
[
stream
.
type
]
=
stream
self
.
_stream_map
[
stream
.
type
]
=
self
.
_stream_map
.
proposed_map
[
stream
.
type
]
=
stream
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
.
_session
,
sender
=
stream
)
notification_center
.
add_observer
(
self
.
_session
,
sender
=
stream
)
def
remove
(
self
,
stream
):
def
remove
(
self
,
stream
):
# is it a good choice to silently ignore removing a stream that is not in the container? -Dan
assert
stream
in
self
if
stream
in
self
:
self
.
_stream_map
.
pop
(
stream
.
type
)
self
.
_stream_map
.
pop
(
stream
.
type
)
self
.
_stream_map
.
active_map
.
pop
(
stream
.
type
,
None
)
self
.
_stream_map
.
proposed_map
.
pop
(
stream
.
type
,
None
)
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
notification_center
.
remove_observer
(
self
.
_session
,
sender
=
stream
)
notification_center
.
remove_observer
(
self
.
_session
,
sender
=
stream
)
def
set_active
(
self
,
stream
):
assert
stream
in
self
self
.
_stream_map
.
active_map
[
stream
.
type
]
=
self
.
_stream_map
.
proposed_map
.
pop
(
stream
.
type
)
def
extend
(
self
,
iterable
):
def
extend
(
self
,
iterable
):
for
item
in
iterable
:
for
item
in
iterable
:
self
.
add
(
item
)
self
.
add
(
item
)
...
@@ -276,7 +296,7 @@ class defaultweakobjectmap(weakobjectmap):
...
@@ -276,7 +296,7 @@ class defaultweakobjectmap(weakobjectmap):
class
StreamListDescriptor
(
object
):
class
StreamListDescriptor
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
values
=
defaultweakobjectmap
(
dict
)
self
.
values
=
defaultweakobjectmap
(
StreamMap
)
def
__get__
(
self
,
obj
,
objtype
):
def
__get__
(
self
,
obj
,
objtype
):
if
obj
is
None
:
if
obj
is
None
:
...
@@ -802,6 +822,8 @@ class BlinkSession(QObject):
...
@@ -802,6 +822,8 @@ class BlinkSession(QObject):
def
_NH_SIPSessionDidStart
(
self
,
notification
):
def
_NH_SIPSessionDidStart
(
self
,
notification
):
for
stream
in
set
(
self
.
streams
)
.
difference
(
notification
.
data
.
streams
):
for
stream
in
set
(
self
.
streams
)
.
difference
(
notification
.
data
.
streams
):
self
.
streams
.
remove
(
stream
)
self
.
streams
.
remove
(
stream
)
for
stream
in
self
.
streams
:
self
.
streams
.
set_active
(
stream
)
if
self
.
state
not
in
(
'ending'
,
'ended'
,
'deleted'
):
if
self
.
state
not
in
(
'ending'
,
'ended'
,
'deleted'
):
self
.
state
=
'connected'
self
.
state
=
'connected'
self
.
timer
.
start
()
self
.
timer
.
start
()
...
@@ -841,6 +863,7 @@ class BlinkSession(QObject):
...
@@ -841,6 +863,7 @@ class BlinkSession(QObject):
self
.
state
=
'connected'
self
.
state
=
'connected'
for
stream
in
proposed_streams
:
for
stream
in
proposed_streams
:
if
stream
in
accepted_streams
:
if
stream
in
accepted_streams
:
self
.
streams
.
set_active
(
stream
)
notification
.
center
.
post_notification
(
'BlinkSessionDidAddStream'
,
sender
=
self
,
data
=
NotificationData
(
stream
=
stream
))
notification
.
center
.
post_notification
(
'BlinkSessionDidAddStream'
,
sender
=
self
,
data
=
NotificationData
(
stream
=
stream
))
else
:
else
:
self
.
streams
.
remove
(
stream
)
self
.
streams
.
remove
(
stream
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment