Commit 6a73dfba authored by Dan Pascu's avatar Dan Pascu

Added packet loss info and made the displayed session info adaptive

parent 3d7b4d08
...@@ -24,6 +24,15 @@ class SessionItem(object): ...@@ -24,6 +24,15 @@ class SessionItem(object):
self.streams = streams self.streams = streams
self.widget = Null self.widget = Null
self.conference = None self.conference = None
self.type = None
self.codec_info = ''
self.tls = False
self.srtp = False
self.latency = 0
self.packet_loss = 0
def __reduce__(self):
return (self.__class__, (self.name, self.uri, self.streams), None)
def _get_conference(self): def _get_conference(self):
return self.__dict__['conference'] return self.__dict__['conference']
...@@ -41,8 +50,77 @@ class SessionItem(object): ...@@ -41,8 +50,77 @@ class SessionItem(object):
conference = property(_get_conference, _set_conference) conference = property(_get_conference, _set_conference)
del _get_conference, _set_conference del _get_conference, _set_conference
def __reduce__(self): def _get_type(self):
return (self.__class__, (self.name, self.uri, self.streams), None) return self.__dict__['type']
def _set_type(self, value):
if self.__dict__.get('type', Null) == value:
return
self.__dict__['type'] = value
self.widget.stream_info_label.session_type = value
type = property(_get_type, _set_type)
del _get_type, _set_type
def _get_codec_info(self):
return self.__dict__['codec_info']
def _set_codec_info(self, value):
if self.__dict__.get('codec_info', None) == value:
return
self.__dict__['codec_info'] = value
self.widget.stream_info_label.codec_info = value
codec_info = property(_get_codec_info, _set_codec_info)
del _get_codec_info, _set_codec_info
def _get_tls(self):
return self.__dict__['tls']
def _set_tls(self, value):
if self.__dict__.get('tls', None) == value:
return
self.__dict__['tls'] = value
self.widget.tls_label.setVisible(bool(value))
tls = property(_get_tls, _set_tls)
del _get_tls, _set_tls
def _get_srtp(self):
return self.__dict__['srtp']
def _set_srtp(self, value):
if self.__dict__.get('srtp', None) == value:
return
self.__dict__['srtp'] = value
self.widget.srtp_label.setVisible(bool(value))
srtp = property(_get_srtp, _set_srtp)
del _get_srtp, _set_srtp
def _get_latency(self):
return self.__dict__['latency']
def _set_latency(self, value):
if self.__dict__.get('latency', None) == value:
return
self.__dict__['latency'] = value
self.widget.latency_label.value = value
latency = property(_get_latency, _set_latency)
del _get_latency, _set_latency
def _get_packet_loss(self):
return self.__dict__['packet_loss']
def _set_packet_loss(self, value):
if self.__dict__.get('packet_loss', None) == value:
return
self.__dict__['packet_loss'] = value
self.widget.packet_loss_label.value = value
packet_loss = property(_get_packet_loss, _set_packet_loss)
del _get_packet_loss, _set_packet_loss
class Conference(object): class Conference(object):
...@@ -90,6 +168,9 @@ class SessionWidget(base_class, ui_class): ...@@ -90,6 +168,9 @@ class SessionWidget(base_class, ui_class):
font = self.latency_label.font() font = self.latency_label.font()
font.setPointSizeF(self.status_label.fontInfo().pointSizeF() - 1) font.setPointSizeF(self.status_label.fontInfo().pointSizeF() - 1)
self.latency_label.setFont(font) self.latency_label.setFont(font)
font = self.packet_loss_label.font()
font.setPointSizeF(self.status_label.fontInfo().pointSizeF() - 1)
self.packet_loss_label.setFont(font)
self.mute_button.type = LeftSegment self.mute_button.type = LeftSegment
self.hold_button.type = MiddleSegment self.hold_button.type = MiddleSegment
self.record_button.type = MiddleSegment self.record_button.type = MiddleSegment
...@@ -106,10 +187,13 @@ class SessionWidget(base_class, ui_class): ...@@ -106,10 +187,13 @@ class SessionWidget(base_class, ui_class):
self.record_button.pressed.connect(self._tool_button_pressed) self.record_button.pressed.connect(self._tool_button_pressed)
self.hangup_button.pressed.connect(self._tool_button_pressed) self.hangup_button.pressed.connect(self._tool_button_pressed)
self.mute_button.hide() self.mute_button.hide()
#self.srtp_label.hide()
#self.tls_label.hide()
#self.latency_label.hide()
self.address_label.setText(session.name or session.uri) self.address_label.setText(session.name or session.uri)
self.stream_info_label.session_type = session.type
self.stream_info_label.session_type = session.codec_info
self.latency_label.value = session.latency
self.packet_loss_label.value = session.packet_loss
self.tls_label.setVisible(bool(session.tls))
self.srtp_label.setVisible(bool(session.srtp))
def _get_selected(self): def _get_selected(self):
return self.__dict__['selected'] return self.__dict__['selected']
...@@ -234,6 +318,7 @@ class DraggedSessionWidget(base_class, ui_class): ...@@ -234,6 +318,7 @@ class DraggedSessionWidget(base_class, ui_class):
self.tls_label.hide() self.tls_label.hide()
self.srtp_label.hide() self.srtp_label.hide()
self.latency_label.hide() self.latency_label.hide()
self.packet_loss_label.hide()
self.duration_label.hide() self.duration_label.hide()
self.stream_info_label.setText(u'') self.stream_info_label.setText(u'')
self.address_label.setText(session_widget.address_label.text()) self.address_label.setText(session_widget.address_label.text())
...@@ -438,6 +523,24 @@ class SessionModel(QAbstractListModel): ...@@ -438,6 +523,24 @@ class SessionModel(QAbstractListModel):
conference = Conference() conference = Conference()
self.sessions[2].conference = conference self.sessions[2].conference = conference
self.sessions[3].conference = conference self.sessions[3].conference = conference
session = self.sessions[0]
session.type, session.codec_info = 'HD Audio', 'speex 32kHz'
session.tls, session.srtp, session.latency, session.packet_loss = True, True, 100, 20
session = self.sessions[1]
session.type, session.codec_info = 'HD Audio', 'speex 32kHz'
session.tls, session.srtp, session.latency, session.packet_loss = True, True, 80, 20
session = self.sessions[2]
session.type, session.codec_info = 'HD Audio', 'speex 32kHz'
session.tls, session.srtp, session.latency, session.packet_loss = True, False, 150, 0
session = self.sessions[3]
session.type, session.codec_info = 'HD Audio', 'speex 32kHz'
session.tls, session.srtp, session.latency, session.packet_loss = False, False, 180, 20
session = self.sessions[4]
session.type, session.codec_info = 'Video', 'H.264 512kbit, PCM 8kHz'
session.tls, session.srtp, session.latency, session.packet_loss = True, True, 0, 0
session = self.sessions[5]
session.type, session.codec_info = 'Audio', 'PCM 8kHz'
session.tls, session.srtp, session.latency, session.packet_loss = True, True, 540, 50
class ContextMenuActions(object): class ContextMenuActions(object):
......
# Copyright (c) 2010 AG Projects. See LICENSE for details. # Copyright (c) 2010 AG Projects. See LICENSE for details.
# #
__all__ = ['IconSelector', 'LatencyLabel', 'PacketLossLabel', 'StreamInfoLabel']
import os import os
from PyQt4.QtCore import Qt from PyQt4.QtCore import Qt
from PyQt4.QtGui import QFileDialog, QLabel, QPixmap from PyQt4.QtGui import QFileDialog, QFontMetrics, QLabel, QPixmap
from blink.resources import ApplicationData, Resources from blink.resources import ApplicationData, Resources
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
...@@ -44,3 +46,89 @@ class IconSelector(QLabel): ...@@ -44,3 +46,89 @@ class IconSelector(QLabel):
super(IconSelector, self).mouseReleaseEvent(event) super(IconSelector, self).mouseReleaseEvent(event)
class StreamInfoLabel(QLabel):
def __init__(self, parent=None):
super(StreamInfoLabel, self).__init__(parent)
self.session_type = None
self.codec_info = ''
def _get_session_type(self):
return self.__dict__['session_type']
def _set_session_type(self, value):
self.__dict__['session_type'] = value
self.update_content()
session_type = property(_get_session_type, _set_session_type)
del _get_session_type, _set_session_type
def _get_codec_info(self):
return self.__dict__['codec_info']
def _set_codec_info(self, value):
self.__dict__['codec_info'] = value
self.update_content()
codec_info = property(_get_codec_info, _set_codec_info)
del _get_codec_info, _set_codec_info
def resizeEvent(self, event):
super(StreamInfoLabel, self).resizeEvent(event)
self.update_content()
def update_content(self):
if self.session_type and self.codec_info:
text = u'%s (%s)' % (self.session_type, self.codec_info)
if self.width() < QFontMetrics(self.font()).width(text):
text = self.session_type
else:
text = self.session_type or u''
self.setText(text)
class LatencyLabel(QLabel):
def __init__(self, parent=None):
super(LatencyLabel, self).__init__(parent)
self.treshold = 99
self.value = 0
def _get_value(self):
return self.__dict__['value']
def _set_value(self, value):
self.__dict__['value'] = value
if value > self.treshold:
text = u'Latency %sms' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text)
self.show()
else:
self.hide()
value = property(_get_value, _set_value)
del _get_value, _set_value
class PacketLossLabel(QLabel):
def __init__(self, parent=None):
super(PacketLossLabel, self).__init__(parent)
self.treshold = 0
self.value = 0
def _get_value(self):
return self.__dict__['value']
def _set_value(self, value):
self.__dict__['value'] = value
if value > self.treshold:
text = u'Packet loss %s%%' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text)
self.show()
else:
self.hide()
value = property(_get_value, _set_value)
del _get_value, _set_value
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
<customwidget> <customwidget>
<class>IconSelector</class> <class>IconSelector</class>
<extends>QLabel</extends> <extends>QLabel</extends>
<header>blink.widgets.iconselector</header> <header>blink.widgets.labels</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<number>1</number> <number>1</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="stream_info_label"> <widget class="StreamInfoLabel" name="stream_info_label">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -164,7 +164,104 @@ ...@@ -164,7 +164,104 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="latency_label"> <widget class="PacketLossLabel" name="packet_loss_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>14</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>118</red>
<green>118</green>
<blue>117</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>118</red>
<green>118</green>
<blue>117</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Packet loss 20%</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="LatencyLabel" name="latency_label">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -528,6 +625,21 @@ QToolButton:pressed { ...@@ -528,6 +625,21 @@ QToolButton:pressed {
<extends>QToolButton</extends> <extends>QToolButton</extends>
<header>blink.widgets.buttons</header> <header>blink.widgets.buttons</header>
</customwidget> </customwidget>
<customwidget>
<class>StreamInfoLabel</class>
<extends>QLabel</extends>
<header>blink.widgets.labels</header>
</customwidget>
<customwidget>
<class>LatencyLabel</class>
<extends>QLabel</extends>
<header>blink.widgets.labels</header>
</customwidget>
<customwidget>
<class>PacketLossLabel</class>
<extends>QLabel</extends>
<header>blink.widgets.labels</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment