Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorvald Natvig <slicer@users.sourceforge.net>2007-10-08 14:40:05 +0400
committerThorvald Natvig <slicer@users.sourceforge.net>2007-10-08 14:40:05 +0400
commit952d3c453c6271a72fb0ab39e74b0443045f7f34 (patch)
tree7d96f85193fb47564a6a6100b1e4cf9a183791c4
parent496a6e456e23ecef71ed09e3a077f68f5b5190f3 (diff)
Autolower bandwidth on connect
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@769 05730e5d-ab1b-0410-a4ac-84af385074fa
-rw-r--r--src/Message.cpp3
-rw-r--r--src/Message.h5
-rw-r--r--src/mumble/AudioInput.cpp67
-rw-r--r--src/mumble/AudioInput.h3
-rw-r--r--src/mumble/Messages.cpp13
-rw-r--r--src/mumble/ServerHandler.cpp5
-rw-r--r--src/murmur/Messages.cpp10
7 files changed, 73 insertions, 33 deletions
diff --git a/src/Message.cpp b/src/Message.cpp
index 05cd79cf7..b7083f572 100644
--- a/src/Message.cpp
+++ b/src/Message.cpp
@@ -305,19 +305,16 @@ void MessagePingStats::restoreStream(PacketDataStream &qdsIn) {
MessageServerAuthenticate::MessageServerAuthenticate() {
iVersion = MESSAGE_STREAM_VERSION;
- iMaxBandwidth = 100000;
}
void MessageServerAuthenticate::saveStream(PacketDataStream &qdsOut) const {
qdsOut << iVersion;
- qdsOut << iMaxBandwidth;
qdsOut << qsUsername;
qdsOut << qsPassword;
}
void MessageServerAuthenticate::restoreStream(PacketDataStream &qdsIn) {
qdsIn >> iVersion;
- qdsIn >> iMaxBandwidth;
qdsIn >> qsUsername;
qdsIn >> qsPassword;
}
diff --git a/src/Message.h b/src/Message.h
index 18d79c9ff..61a395106 100644
--- a/src/Message.h
+++ b/src/Message.h
@@ -31,7 +31,7 @@
#ifndef _MESSAGE_H
#define _MESSAGE_H
-#define MESSAGE_STREAM_VERSION 3
+#define MESSAGE_STREAM_VERSION 4
#include "ACL.h"
@@ -78,7 +78,6 @@ class MessageServerAuthenticate : public Message {
void restoreStream(PacketDataStream &);
public:
int iVersion;
- int iMaxBandwidth;
QString qsUsername;
QString qsPassword;
MessageServerAuthenticate();
@@ -124,7 +123,7 @@ class MessageServerReject : public Message {
void saveStream(PacketDataStream &) const;
void restoreStream(PacketDataStream &);
public:
- enum RejectType { None, WrongVersion, InvalidUsername, WrongUserPW, WrongServerPW, UsernameInUse, BandwidthExceeded, ServerFull };
+ enum RejectType { None, WrongVersion, InvalidUsername, WrongUserPW, WrongServerPW, UsernameInUse, ServerFull };
QString qsReason;
RejectType rtType;
Message::MessageType messageType() const {
diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp
index 9d52935e6..8053f15fd 100644
--- a/src/mumble/AudioInput.cpp
+++ b/src/mumble/AudioInput.cpp
@@ -99,13 +99,20 @@ AudioInput::AudioInput() {
iSilentFrames = 0;
iHoldFrames = 0;
- int iarg=1;
- speex_encoder_ctl(esEncState,SPEEX_SET_VBR, &iarg);
+ int iArg=1;
+ float fArg=0.0;
+ speex_encoder_ctl(esEncState,SPEEX_SET_VBR, &iArg);
- iarg = 0;
+ iArg = 0;
- speex_encoder_ctl(esEncState,SPEEX_SET_VAD, &iarg);
- speex_encoder_ctl(esEncState,SPEEX_SET_DTX, &iarg);
+ speex_encoder_ctl(esEncState,SPEEX_SET_VAD, &iArg);
+ speex_encoder_ctl(esEncState,SPEEX_SET_DTX, &iArg);
+
+ fArg = g.s.iQuality;
+ speex_encoder_ctl(esEncState,SPEEX_SET_VBR_QUALITY, &fArg);
+
+ iArg = g.s.iComplexity;
+ speex_encoder_ctl(esEncState,SPEEX_SET_COMPLEXITY, &iArg);
bResetProcessor = true;
@@ -124,6 +131,10 @@ AudioInput::AudioInput() {
iBitrate = 0;
dPeakMic = dPeakSignal = dPeakSpeaker = 0.0;
+ if (g.uiSession && (getMaxBandwidth() > g.iMaxBandwidth)) {
+ setMaxBandwidth(g.iMaxBandwidth);
+ }
+
bRunning = false;
}
@@ -157,7 +168,7 @@ int AudioInput::getMaxBandwidth() {
audiorate /= 400/g.s.iFramesPerPacket;
// Overhead
- audiorate += 20 + 8 + 7 + 3;
+ audiorate += 20 + 8 + 4 + 3 + 1 + 2;
if (g.s.bTransmitPosition)
audiorate += 12;
@@ -170,6 +181,43 @@ int AudioInput::getMaxBandwidth() {
return audiorate;
}
+void AudioInput::setMaxBandwidth(int bytespersec) {
+ int audiorate;
+
+ if (bytespersec == 0) {
+ float fArg=g.s.iQuality;
+ speex_encoder_ctl(esEncState,SPEEX_SET_VBR_QUALITY, &fArg);
+ return;
+ }
+
+ do {
+ float f = 10.0;
+ speex_encoder_ctl(esEncState, SPEEX_GET_VBR_QUALITY, &f);
+ speex_encoder_ctl(esEncState, SPEEX_GET_BITRATE, &audiorate);
+
+ if (f <= 1.9)
+ return;
+
+ audiorate /= 400/g.s.iFramesPerPacket;
+
+ // Overhead
+ audiorate += 20 + 8 + 4 + 3 + 1 + 2;
+
+ if (g.s.bTransmitPosition)
+ audiorate += 12;
+
+ if (g.s.bTCPCompat)
+ audiorate += 12;
+
+ audiorate = (audiorate * 50) / g.s.iFramesPerPacket;
+
+ if (audiorate > bytespersec) {
+ f -= 1.0;
+ speex_encoder_ctl(esEncState, SPEEX_SET_VBR_QUALITY, &f);
+ }
+ } while (audiorate > bytespersec);
+}
+
void AudioInput::encodeAudioFrame() {
int iArg;
float fArg;
@@ -259,13 +307,6 @@ void AudioInput::encodeAudioFrame() {
bResetProcessor = false;
}
-
- fArg = g.s.iQuality;
- speex_encoder_ctl(esEncState,SPEEX_SET_VBR_QUALITY, &fArg);
-
- iArg = g.s.iComplexity;
- speex_encoder_ctl(esEncState,SPEEX_SET_COMPLEXITY, &iArg);
-
int iIsSpeech;
if (bHasSpeaker) {
diff --git a/src/mumble/AudioInput.h b/src/mumble/AudioInput.h
index de33b5ba2..baec2c899 100644
--- a/src/mumble/AudioInput.h
+++ b/src/mumble/AudioInput.h
@@ -95,7 +95,8 @@ class AudioInput : public QThread {
return bPreviousVoice;
};
- int getMaxBandwidth();
+ static int getMaxBandwidth();
+ void setMaxBandwidth(int bytespersec);
AudioInput();
~AudioInput();
diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp
index 6a27faac9..1521c2d81 100644
--- a/src/mumble/Messages.cpp
+++ b/src/mumble/Messages.cpp
@@ -292,6 +292,19 @@ void MainWindow::msgServerSync(Connection *, MessageServerSync *msg) {
g.l->log(Log::Information, msg->qsWelcomeText);
pmModel->ensureSelfVisible();
+ AudioInputPtr ai = g.ai;
+ if (ai) {
+ int bw = ai->getMaxBandwidth();
+ if (bw > msg->iMaxBandwidth) {
+ g.l->log(Log::Information, MainWindow::tr("Server maximum bandwidth is only %1 kbit/s. Quality auto-adjusted.").arg(msg->iMaxBandwidth / 125));
+ ai->setMaxBandwidth(g.iMaxBandwidth);
+ } else {
+ ai->setMaxBandwidth(0);
+ }
+ }
+
+
+
bool found = false;
QStringList qlChans = qsDesiredChannel.split(QLatin1String("/"));
Channel *chan = Channel::get(0);
diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp
index fb2ee6435..83792f2c7 100644
--- a/src/mumble/ServerHandler.cpp
+++ b/src/mumble/ServerHandler.cpp
@@ -288,14 +288,9 @@ void ServerHandler::serverConnectionConnected() {
qscCert = cConnection->peerCertificateChain();
qscCipher = cConnection->sessionCipher();
- AudioInputPtr ai = g.ai;
MessageServerAuthenticate msaMsg;
msaMsg.qsUsername = qsUserName;
msaMsg.qsPassword = qsPassword;
- if (ai)
- msaMsg.iMaxBandwidth = ai->getMaxBandwidth();
- else
- msaMsg.iMaxBandwidth = 0;
cConnection->sendMessage(&msaMsg);
diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp
index c9656c231..3d586ef26 100644
--- a/src/murmur/Messages.cpp
+++ b/src/murmur/Messages.cpp
@@ -130,12 +130,6 @@ void Server::msgServerAuthenticate(Connection *cCon, MessageServerAuthenticate *
}
}
- if (msg->iMaxBandwidth > iMaxBandwidth) {
- msr.qsReason = QString::fromLatin1("Your maximum bandwidth(%1 kbit/s) above server limit (%2 kbit/s)").arg(msg->iMaxBandwidth/125.0).arg(iMaxBandwidth/125.0);
- msr.rtType = MessageServerReject::BandwidthExceeded;
- ok = false;
- }
-
if ((id != 0) && (qhUsers.count() > iMaxUsers)) {
msr.qsReason = QString::fromLatin1("Server is full (max %1 users)").arg(iMaxUsers);
msr.rtType = MessageServerReject::ServerFull;
@@ -665,12 +659,12 @@ void Server::msgTextMessage(Connection *cCon, MessageTextMessage *msg) {
Channel *c = qhChannels.value(msg->iChannel);
if (!c)
return;
-
+
if (! ChanACL::hasPermission(uSource, c, ChanACL::Speak | ChanACL::AltSpeak, acCache)) {
PERM_DENIED(uSource, c, ChanACL::Speak);
return;
}
-
+
QSet<Channel *> chans;
QQueue<Channel *> q;
q << c;