mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
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:
parent
260da99955
commit
94317d1a39
6 changed files with 147 additions and 30 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue