added graph display of instantly required bandwidth for VOIP, in preparation to chosing new video codec. GUI layout needs to be sorted.

This commit is contained in:
csoler 2015-08-07 21:40:48 -04:00
parent d5c33f5631
commit ec67ee0e00
6 changed files with 147 additions and 30 deletions

View File

@ -39,6 +39,7 @@
//#include "NetworkConfig.h"
#include "audiodevicehelper.h"
#include "AudioWizard.h"
#include "gui/common/RSGraphWidget.h"
#include <interface/rsVOIP.h>
#define iroundf(x) ( static_cast<int>(x) )
@ -51,6 +52,59 @@ void AudioInputDialog::showEvent(QShowEvent *) {
qtTick->start(20);
}*/
class voipGraphSource: public RSGraphSource
{
public:
voipGraphSource() {}
void setVideoInput(QVideoInputDevice *vid) { video_input = vid ; }
virtual QString displayName(int) const { return tr("Required bandwidth") ;}
virtual QString displayValue(float v) const
{
if(v < 1000)
return QString::number(v,10,2) + " B/s" ;
else if(v < 1000*1024)
return QString::number(v/1024,10,2) + " KB/s" ;
else
return QString::number(v/(1024*1024),10,2) + " MB/s" ;
}
virtual void getValues(std::map<std::string,float>& vals) const
{
RsVOIPDataChunk chunk ;
uint32_t total_size = 0 ;
vals.clear() ;
while(video_input && video_input->getNextEncodedPacket(chunk))
{
total_size += chunk.size ;
chunk.clear() ;
}
vals[std::string("bw")] = (float)total_size ;
}
private:
QVideoInputDevice *video_input ;
};
void voipGraph::setVoipSource(voipGraphSource *gs)
{
_src = gs ;
RSGraphWidget::setSource(gs) ;
}
voipGraph::voipGraph(QWidget *parent)
: RSGraphWidget(parent)
{
setFlags(RSGraphWidget::RSGRAPH_FLAGS_SHOW_LEGEND) ;
setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
_src = NULL ;
}
/** Constructor */
AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
@ -71,11 +125,21 @@ AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags)
//
videoInput = new QVideoInputDevice(this) ;
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
videoInput->setVideoEncoder(NULL) ;
videoInput->setVideoEncoder(new JPEGVideoEncoder()) ;
graph_source = new voipGraphSource ;
ui.voipBwGraph->setSource(graph_source);
graph_source->setVideoInput(videoInput) ;
graph_source->setCollectionTimeLimit(1000*300) ;
graph_source->start() ;
}
AudioInputConfig::~AudioInputConfig()
{
graph_source->stop() ;
graph_source->setVideoInput(NULL) ;
std::cerr << "Deleting audioInputConfig object" << std::endl;
if(videoInput != NULL)
{

View File

@ -35,10 +35,27 @@
#include "retroshare-gui/configpage.h"
#include "ui_AudioInputConfig.h"
#include "SpeexProcessor.h"
#include "VideoProcessor.h"
#include "AudioStats.h"
#include "gui/common/RSGraphWidget.h"
class voipGraphSource ;
class voipGraph: public RSGraphWidget
{
public:
voipGraph(QWidget *parent) ;
voipGraphSource *voipSource() const { return _src ; }
void setVoipSource(voipGraphSource *gs) ;
private:
voipGraphSource *_src ;
};
#include "ui_AudioInputConfig.h"
class AudioInputConfig : public ConfigPage
{
@ -54,6 +71,7 @@ class AudioInputConfig : public ConfigPage
QVideoInputDevice *videoInput ;
bool loaded;
voipGraphSource *graph_source ;
protected:
QTimer *qtTick;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<height>406</height>
<width>1155</width>
<height>713</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -348,33 +348,49 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Video Processing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QVideoOutputDevice" name="videoDisplay">
<property name="minimumSize">
<size>
<width>170</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Video Processing</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QVideoOutputDevice" name="videoDisplay">
<property name="minimumSize">
<size>
<width>170</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="voipGraph" name="voipBwGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
@ -397,6 +413,12 @@
<header>gui/QVideoDevice.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>voipGraph</class>
<extends>QFrame</extends>
<header>gui/AudioInputConfig.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>qcbTransmit</tabstop>

View File

@ -88,7 +88,10 @@ void QVideoInputDevice::grabFrame()
bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk)
{
return _video_encoder->nextPacket(chunk) ;
if(_video_encoder)
return _video_encoder->nextPacket(chunk) ;
else
return false ;
}
QVideoInputDevice::~QVideoInputDevice()

View File

@ -56,6 +56,8 @@ struct RsVOIPDataChunk
void *data ; // create/delete using malloc/free.
uint32_t size ;
RsVOIPDataType type ; // video or audio
void clear() ;
};
class RsVOIP

View File

@ -147,6 +147,14 @@ RsServiceInfo p3VOIP::getServiceInfo()
TURTLE_MIN_MINOR_VERSION);
}
void RsVOIPDataChunk::clear()
{
if(data)
free(data) ;
data=NULL;
size=0 ;
}
int p3VOIP::tick()
{
#ifdef DEBUG_VOIP