Merge remote-tracking branch 'upstream/master' into v0.6-TorControl

This commit is contained in:
csoler 2021-08-15 15:07:58 +02:00
commit 3de68bf5e5
17 changed files with 857 additions and 602 deletions

View File

@ -4,7 +4,6 @@ MINIUPNPC_VERSION=2.0
OPENSSL_VERSION=1.1.1h OPENSSL_VERSION=1.1.1h
SPEEX_VERSION=1.2.0 SPEEX_VERSION=1.2.0
SPEEXDSP_VERSION=1.2rc3 SPEEXDSP_VERSION=1.2rc3
OPENCV_VERSION=4.5.0
LIBXML2_VERSION=2.9.7 LIBXML2_VERSION=2.9.7
LIBXSLT_VERSION=1.1.32 LIBXSLT_VERSION=1.1.32
CURL_VERSION=7.58.0 CURL_VERSION=7.58.0
@ -19,7 +18,7 @@ DOWNLOAD_PATH?=download
BUILD_PATH=build BUILD_PATH=build
LIBS_PATH?=libs LIBS_PATH?=libs
all: dirs zlib bzip2 miniupnpc openssl speex speexdsp opencv libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson xapian copylibs all: dirs zlib bzip2 miniupnpc openssl speex speexdsp libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson xapian copylibs
download: \ download: \
$(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \ $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz \
@ -28,7 +27,6 @@ download: \
$(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz \ $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz \
$(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz \ $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz \
$(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz \ $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz \
$(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz \
$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz \ $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz \
$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz \ $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz \
$(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz \ $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz \
@ -187,31 +185,6 @@ $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP
rm -r -f speexdsp-$(SPEEXDSP_VERSION) rm -r -f speexdsp-$(SPEEXDSP_VERSION)
mv $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION) mv $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION)
opencv: $(BUILD_PATH)/opencv-$(OPENCV_VERSION)
$(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz:
wget --no-check-certificate https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz -O $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
$(BUILD_PATH)/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
# prepare
rm -r -f $(BUILD_PATH)/opencv-*
tar xvf $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
# Remove version numbers from libraries. Is there a switch?
sed -i -e's/\(ocv_update(OPENCV_DLLVERSION \).*$$/\1"")/' opencv-$(OPENCV_VERSION)/CMakeLists.txt
# build
mkdir -p opencv-$(OPENCV_VERSION)/build
#cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/../../build"
cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_CXX11=ON -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DSTRSAFE_NO_DEPRECATE" -DCMAKE_INSTALL_PREFIX="`pwd`/install"
cd opencv-$(OPENCV_VERSION)/build && make install
# copy files
mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include
cp -r opencv-$(OPENCV_VERSION)/build/install/include/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/include/
mkdir -p $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv
cp -r opencv-$(OPENCV_VERSION)/build/install/x64/mingw/staticlib/* $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp/lib/opencv/
# cleanup
rm -r -f opencv-$(OPENCV_VERSION)
mv $(BUILD_PATH)/opencv-$(OPENCV_VERSION).tmp $(BUILD_PATH)/opencv-$(OPENCV_VERSION)
libxml2: $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) libxml2: $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION)
$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz: $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz:

View File

@ -142,7 +142,6 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
retroshare/rsmsgs.h \ retroshare/rsmsgs.h \
retroshare/rsnotify.h \ retroshare/rsnotify.h \
retroshare/rspeers.h \ retroshare/rspeers.h \
retroshare/rsrank.h \
retroshare/rsstatus.h \ retroshare/rsstatus.h \
retroshare/rsturtle.h \ retroshare/rsturtle.h \
retroshare/rsbanlist.h \ retroshare/rsbanlist.h \
@ -353,13 +352,13 @@ HEADERS += ft/ftchunkmap.h \
ft/ftturtlefiletransferitem.h ft/ftturtlefiletransferitem.h
HEADERS += crypto/chacha20.h \ HEADERS += crypto/chacha20.h \
crypto/rsaes.h \ crypto/rsaes.h \
crypto/hashstream.h \ crypto/hashstream.h \
crypto/rscrypto.h crypto/rscrypto.h
HEADERS += directory_updater.h \ HEADERS += file_sharing/directory_updater.h \
directory_list.h \ file_sharing/directory_list.h \
p3filelists.h file_sharing/p3filelists.h
HEADERS += chat/distantchat.h \ HEADERS += chat/distantchat.h \
chat/p3chatservice.h \ chat/p3chatservice.h \
@ -421,7 +420,7 @@ HEADERS += grouter/groutercache.h \
retroshare/rsgrouter.h \ retroshare/rsgrouter.h \
grouter/grouteritems.h \ grouter/grouteritems.h \
grouter/p3grouter.h \ grouter/p3grouter.h \
grouter/rsgroutermatrix.h \ grouter/groutermatrix.h \
grouter/groutertypes.h \ grouter/groutertypes.h \
grouter/grouterclientservice.h grouter/grouterclientservice.h
@ -434,7 +433,6 @@ HEADERS += rsitems/rsitem.h \
rsitems/rsmsgitems.h \ rsitems/rsmsgitems.h \
serialiser/rsserial.h \ serialiser/rsserial.h \
rsitems/rsserviceids.h \ rsitems/rsserviceids.h \
serialiser/rsserviceitems.h \
rsitems/rsstatusitems.h \ rsitems/rsstatusitems.h \
serialiser/rstlvaddrs.h \ serialiser/rstlvaddrs.h \
serialiser/rstlvbase.h \ serialiser/rstlvbase.h \

View File

@ -41,7 +41,7 @@ static const uint32_t RS_HISTORY_TYPE_PRIVATE = 1 ;
static const uint32_t RS_HISTORY_TYPE_LOBBY = 2 ; static const uint32_t RS_HISTORY_TYPE_LOBBY = 2 ;
static const uint32_t RS_HISTORY_TYPE_DISTANT = 3 ; static const uint32_t RS_HISTORY_TYPE_DISTANT = 3 ;
class HistoryMsg class HistoryMsg: RsSerializable
{ {
public: public:
HistoryMsg() HistoryMsg()
@ -52,7 +52,18 @@ public:
recvTime = 0; recvTime = 0;
} }
public: virtual void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx) override
{
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(chatPeerId);
RS_SERIAL_PROCESS(incoming);
RS_SERIAL_PROCESS(peerId);
RS_SERIAL_PROCESS(peerName);
RS_SERIAL_PROCESS(sendTime);
RS_SERIAL_PROCESS(recvTime);
RS_SERIAL_PROCESS(message);
}
uint32_t msgId; uint32_t msgId;
RsPeerId chatPeerId; RsPeerId chatPeerId;
bool incoming; bool incoming;
@ -71,20 +82,80 @@ class RsHistory
{ {
public: public:
virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0; virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0;
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
/*!
* @brief Retrieves the history of messages for a given chatId
* @jsonapi{development}
* @param[in] chatPeerId Chat Id for which the history needs to be retrieved
* @param[out] msgs retrieved messages
* @param[in] loadCount maximum number of messages to get
* @return true if messages can be retrieved, false otherwise.
*/
virtual bool getMessages(const ChatId& chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
/*!
* @brief Retrieves a specific message from the history
* @jsonapi{development}
* @param[in] msgId Id of the message to get
* @param[out] msg retrieved message
* @return true if message can be retrieved, false otherwise.
*/
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0; virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
virtual void clear(const ChatId &chatPeerId) = 0;
virtual bool getEnable(uint32_t chat_type) = 0; /*!
virtual void setEnable(uint32_t chat_type, bool enable) = 0; * @brief Remove messages from the history
* @jsonapi{development}
* @param[in] msgIds list of messages to remove
*/
virtual void removeMessages(const std::list<uint32_t>& msgIds) = 0;
/*!
* @brief clears the message history for a given chat peer
* @jsonapi{development}
* @param[in] chatPeerID Id of the chat/peer for which the history needs to be wiped
*/
virtual void clear(const ChatId &chatPeerId) = 0;
/*!
* @brief Get whether chat history is enabled or not
* @jsonapi{development}
* @param[in] chat_type Type of chat (see list of constants above)
* @return true when the information is available
*/
virtual bool getEnable(uint32_t chat_type) = 0;
/*!
* @brief Set whether chat history is enabled or not
* @jsonapi{development}
* @param[in] chat_type Type of chat (see list of constants above)
* @param[in] enabled Desired state of the variable
*/
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
/*!
* @brief Retrieves the maximum storage time period for messages in history
* @return max storage duration of chat.
*/
virtual uint32_t getMaxStorageDuration() = 0; virtual uint32_t getMaxStorageDuration() = 0;
virtual void setMaxStorageDuration(uint32_t seconds) = 0; /*!
* @brief Sets the maximum storage time period for messages in history
* @param[in] seconds max storage duration time in seconds
*/
virtual void setMaxStorageDuration(uint32_t seconds) = 0;
// 0 = no limit, >0 count of saved messages /*!
virtual uint32_t getSaveCount(uint32_t chat_type) = 0; * @brief Gets the maximum number of messages to save
virtual void setSaveCount(uint32_t chat_type, uint32_t count) = 0; * @param[in] chat_type Type of chat for that number limit
* @return maximum number of messages to save
*/
virtual uint32_t getSaveCount(uint32_t chat_type) = 0;
/*!
* @brief Sets the maximum number of messages to save
* @param[in] chat_type Type of chat for that number limit
* @param[in] count Max umber of messages, 0 meaning indefinitly
*/
virtual void setSaveCount(uint32_t chat_type, uint32_t count) = 0;
}; };
#endif #endif

View File

@ -4,7 +4,8 @@
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> * * Copyright (C) 2019-2021 Gioacchino Mazzurco <gio@eigenlab.org> *
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -131,23 +132,25 @@ struct RsGxsIdGroup : RsSerializable
// ??? 160 bits. // ??? 160 bits.
Sha1CheckSum mPgpIdHash; Sha1CheckSum mPgpIdHash;
// Need a signature as proof - otherwise anyone could add others Hashes.
// This is a string, as the length is variable.
std::string mPgpIdSign;
// Recognition Strings. MAX# defined above. /** Need a signature as proof - otherwise anyone could add others Hashes.
* This is a string, as the length is variable.
* TODO: Thing like this should actually be a byte array (pointer+size),
* using an std::string breaks the JSON serialization, as a workaround this
* field is ignored by JSON serial operations */
std::string mPgpIdSign;
/// Unused
RS_DEPRECATED std::list<std::string> mRecognTags; RS_DEPRECATED std::list<std::string> mRecognTags;
// Avatar RsGxsImage mImage; /// Avatar
RsGxsImage mImage ; rstime_t mLastUsageTS;
rstime_t mLastUsageTS ;
// Not Serialised - for GUI's benefit. bool mPgpLinked;
bool mPgpLinked; bool mPgpKnown;
bool mPgpKnown; bool mIsAContact;
bool mIsAContact; // change that into flags one day RsPgpId mPgpId;
RsPgpId mPgpId; GxsReputation mReputation;
GxsReputation mReputation;
/// @see RsSerializable /// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,

View File

@ -3,7 +3,9 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2012 by Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2021 Gioacchino Mazzurco <gio@eigenlab.org> *
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -19,8 +21,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef RS_GXS_IDENTITY_ITEMS_H #pragma once
#define RS_GXS_IDENTITY_ITEMS_H
#include <map> #include <map>
@ -57,15 +58,20 @@ public:
bool toGxsIdGroup(RsGxsIdGroup &group, bool moveImage); bool toGxsIdGroup(RsGxsIdGroup &group, bool moveImage);
Sha1CheckSum mPgpIdHash; Sha1CheckSum mPgpIdHash;
// Need a signature as proof - otherwise anyone could add others Hashes.
// This is a string, as the length is variable.
std::string mPgpIdSign;
// Recognition Strings. MAX# defined above. /** Need a signature as proof - otherwise anyone could add others Hashes.
std::list<std::string> mRecognTags; * This is a string, as the length is variable.
* TODO: this should actually be a byte array (pointer+size), using an
* std::string breaks the JSON serialization.
* Be careful refactoring this as it may break retrocompatibility as this
* item is sent over the network */
std::string mPgpIdSign;
// Avatar /// Unused
RsTlvImage mImage ; RS_DEPRECATED std::list<std::string> mRecognTags;
/// Avatar
RsTlvImage mImage;
}; };
struct RsGxsIdLocalInfoItem : public RsGxsIdItem struct RsGxsIdLocalInfoItem : public RsGxsIdItem
@ -89,5 +95,3 @@ public:
virtual RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ; virtual RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ;
}; };
#endif /* RS_GXS_IDENTITY_ITEMS_H */

View File

@ -2,7 +2,8 @@
* libretroshare/src/services: p3idservice.cc * * libretroshare/src/services: p3idservice.cc *
* * * *
* Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2017-2019 Gioacchino Mazzurco <gio@altermundi.net> * * Copyright (C) 2017-2021 Gioacchino Mazzurco <gio@altermundi.net> *
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -4960,7 +4961,21 @@ void RsGxsIdGroup::serial_process(
{ {
RS_SERIAL_PROCESS(mMeta); RS_SERIAL_PROCESS(mMeta);
RS_SERIAL_PROCESS(mPgpIdHash); RS_SERIAL_PROCESS(mPgpIdHash);
RS_SERIAL_PROCESS(mPgpIdSign); switch(j)
{
/* mPgpIdSign is declared as std::string but it is a disguised raw memory
* chunk, serializing it as plain string breaks JSON and eventually
* teminals if it get printed, it should have been declared as a raw memory
* chunk in the first place, but as of today just ignoring it in *JSON and
* PRINT operations seems a reasonable workaround */
case RsGenericSerializer::SerializeJob::PRINT: // [[fallthrough]]
case RsGenericSerializer::SerializeJob::TO_JSON: // [[fallthrough]]
case RsGenericSerializer::SerializeJob::FROM_JSON:
break;
default:
RS_SERIAL_PROCESS(mPgpIdSign);
break;
}
RS_SERIAL_PROCESS(mImage); RS_SERIAL_PROCESS(mImage);
RS_SERIAL_PROCESS(mLastUsageTS); RS_SERIAL_PROCESS(mLastUsageTS);
RS_SERIAL_PROCESS(mPgpKnown); RS_SERIAL_PROCESS(mPgpKnown);

View File

@ -4,8 +4,8 @@
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2004-2007 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2004-2007 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2020 Gioacchino Mazzurco <gio@eigenlab.org> * * Copyright (C) 2020-2021 Gioacchino Mazzurco <gio@eigenlab.org> *
* Copyright (C) 2020 Asociación Civil Altermundi <info@altermundi.net> * * Copyright (C) 2020-2021 Asociación Civil Altermundi <info@altermundi.net> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -64,6 +64,26 @@
* #define RSDIR_DEBUG 1 * #define RSDIR_DEBUG 1
****/ ****/
#if __cplusplus < 201703L
bool std::filesystem::create_directories(const std::string& path)
{
for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos;
lastIndex = path.find('/', lastIndex) )
{
std::string&& curDir = path.substr(0, ++lastIndex);
if(!RsDirUtil::checkCreateDirectory(curDir))
{
RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir
<< " of: " << path << std::endl;
return false;
}
}
return true;
}
#else
# include <filesystem>
#endif // __cplusplus < 201703L
std::string RsDirUtil::getTopDir(const std::string& dir) std::string RsDirUtil::getTopDir(const std::string& dir)
{ {
std::string top; std::string top;
@ -528,24 +548,6 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir)
return true; return true;
} }
#if __cplusplus < 201703L
bool std::filesystem::create_directories(const std::string& path)
{
for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos;
lastIndex = path.find('/', lastIndex) )
{
std::string&& curDir = path.substr(0, ++lastIndex);
if(!RsDirUtil::checkCreateDirectory(curDir))
{
RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir
<< " of: " << path << std::endl;
return false;
}
}
return true;
}
#endif // __cplusplus < 201703L
std::string RsDirUtil::removeSymLinks(const std::string& path) std::string RsDirUtil::removeSymLinks(const std::string& path)
{ {
#if defined(WINDOWS_SYS) || defined(__APPLE__) || defined(__ANDROID__) #if defined(WINDOWS_SYS) || defined(__APPLE__) || defined(__ANDROID__)

View File

@ -53,7 +53,6 @@ linux-* {
PKGCONFIG += libavcodec libavutil PKGCONFIG += libavcodec libavutil
PKGCONFIG += speex speexdsp PKGCONFIG += speex speexdsp
PKGCONFIG += opencv4
} else { } else {
LIBS += -lspeex -lspeexdsp -lavcodec -lavutil LIBS += -lspeex -lspeexdsp -lavcodec -lavutil
} }
@ -64,39 +63,6 @@ win32 {
DEPENDPATH += . $$INC_DIR DEPENDPATH += . $$INC_DIR
INCLUDEPATH += . $$INC_DIR INCLUDEPATH += . $$INC_DIR
USE_PRECOMPILED_LIBS =
for(lib, RS_LIB_DIR) {
#message(Scanning $$lib)
isEmpty(USE_PRECOMPILED_LIBS) {
exists($$lib/opencv/libopencv_core.a) {
message(Get pre-compiled opencv libraries here:)
message($$lib/opencv)
LIBS += -L"$$lib/opencv"
USE_PRECOMPILED_LIBS = 1
}
exists($$lib/libopencv_core.dll.a) {
message(Get pre-compiled opencv libraries here:)
message($$lib)
LIBS += -L"$$lib"
USE_PRECOMPILED_LIBS = 1
}
}
}
isEmpty(USE_PRECOMPILED_LIBS) {
message(Use system opencv libraries.)
}
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio -lopencv_imgcodecs -llibwebp -llibtiff -llibpng -llibopenjp2 -lIlmImf
LIBS += -lole32 -loleaut32 -luuid -lvfw32
# Check for msys2
!isEmpty(PREFIX_MSYS2) {
message(Use msys2 opencv4.)
INCLUDEPATH += "$${PREFIX_MSYS2}/include/opencv4"
} else {
LIBS += -llibjpeg-turbo -lzlib
}
} }
#################################### MacOSX ##################################### #################################### MacOSX #####################################
@ -105,30 +71,6 @@ macx {
DEPENDPATH += . $$INC_DIR DEPENDPATH += . $$INC_DIR
INCLUDEPATH += . $$INC_DIR INCLUDEPATH += . $$INC_DIR
#OPENCV_VERSION = "249"
USE_PRECOMPILED_LIBS =
for(lib, LIB_DIR) {
#message(Scanning $$lib)
exists( $$lib/opencv/libopencv_core*.dylib) {
isEmpty(USE_PRECOMPILED_LIBS) {
message(Get pre-compiled opencv libraries here:)
message($$lib)
LIBS += -L"$$lib/opencv"
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
USE_PRECOMPILED_LIBS = 1
}
}
exists( $$lib/libopencv_videoio*.dylib) {
message(videoio found in opencv libraries.)
message($$lib)
LIBS += -lopencv_videoio
}
}
isEmpty(USE_PRECOMPILED_LIBS) {
message(Use system opencv libraries.)
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
}
} }
@ -138,9 +80,9 @@ QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS
QMAKE_CXXFLAGS *= -Wall QMAKE_CXXFLAGS *= -Wall
SOURCES = VOIPPlugin.cpp \ SOURCES = VOIPPlugin.cpp \
gui/VOIPConfigPanel.cpp \
services/p3VOIP.cc \ services/p3VOIP.cc \
services/rsVOIPItems.cc \ services/rsVOIPItems.cc \
gui/AudioInputConfig.cpp \
gui/AudioStats.cpp \ gui/AudioStats.cpp \
gui/AudioWizard.cpp \ gui/AudioWizard.cpp \
gui/SpeexProcessor.cpp \ gui/SpeexProcessor.cpp \
@ -154,9 +96,9 @@ SOURCES = VOIPPlugin.cpp \
gui/VOIPToasterNotify.cpp gui/VOIPToasterNotify.cpp
HEADERS = VOIPPlugin.h \ HEADERS = VOIPPlugin.h \
gui/VOIPConfigPanel.h \
services/p3VOIP.h \ services/p3VOIP.h \
services/rsVOIPItems.h \ services/rsVOIPItems.h \
gui/AudioInputConfig.h \
gui/AudioStats.h \ gui/AudioStats.h \
gui/AudioWizard.h \ gui/AudioWizard.h \
gui/SpeexProcessor.h \ gui/SpeexProcessor.h \
@ -170,9 +112,10 @@ HEADERS = VOIPPlugin.h \
gui/VOIPToasterNotify.h \ gui/VOIPToasterNotify.h \
interface/rsVOIP.h interface/rsVOIP.h
FORMS = gui/AudioInputConfig.ui \ FORMS = \
gui/AudioStats.ui \ gui/AudioStats.ui \
gui/AudioWizard.ui \ gui/AudioWizard.ui \
gui/VOIPConfigPanel.ui \
gui/VOIPToasterItem.ui gui/VOIPToasterItem.ui
TARGET = VOIP TARGET = VOIP

View File

@ -31,14 +31,13 @@
#include "VOIPPlugin.h" #include "VOIPPlugin.h"
#include "interface/rsVOIP.h" #include "interface/rsVOIP.h"
#include "gui/AudioInputConfig.h" #include "gui/VOIPConfigPanel.h"
#include "gui/VOIPChatWidgetHolder.h" #include "gui/VOIPChatWidgetHolder.h"
#include "gui/VOIPGUIHandler.h" #include "gui/VOIPGUIHandler.h"
#include "gui/VOIPNotify.h" #include "gui/VOIPNotify.h"
#include "gui/SoundManager.h" #include "gui/SoundManager.h"
#include "gui/chat/ChatWidget.h" #include "gui/chat/ChatWidget.h"
#include <opencv2/opencv.hpp>
#include <speex/speex.h> #include <speex/speex.h>
#define IMAGE_VOIP ":/images/talking_on.svg" #define IMAGE_VOIP ":/images/talking_on.svg"
@ -113,7 +112,7 @@ ConfigPage *VOIPPlugin::qt_config_page() const
// The config pages are deleted when config is closed, so it's important not to static the // The config pages are deleted when config is closed, so it's important not to static the
// created object. // created object.
// //
return new AudioInputConfig() ; return new VOIPConfigPanel() ;
} }
QDialog *VOIPPlugin::qt_about_page() const QDialog *VOIPPlugin::qt_about_page() const
@ -188,8 +187,6 @@ std::string VOIPPlugin::getPluginName() const
void VOIPPlugin::getLibraries(std::list<RsLibraryInfo> &libraries) void VOIPPlugin::getLibraries(std::list<RsLibraryInfo> &libraries)
{ {
libraries.push_back(RsLibraryInfo("OpenCV", CV_VERSION));
const char *speexVersion = NULL; const char *speexVersion = NULL;
if (speex_lib_ctl(SPEEX_LIB_GET_VERSION_STRING, &speexVersion) == 0 && speexVersion) { if (speex_lib_ctl(SPEEX_LIB_GET_VERSION_STRING, &speexVersion) == 0 && speexVersion) {
libraries.push_back(RsLibraryInfo("Speex", speexVersion)); libraries.push_back(RsLibraryInfo("Speex", speexVersion));

View File

@ -25,7 +25,7 @@
#include <QPainter> #include <QPainter>
#include "AudioStats.h" #include "AudioStats.h"
#include "AudioInputConfig.h" #include "VOIPConfigPanel.h"
//#include "Global.h" //#include "Global.h"
//#include "smallft.h" //#include "smallft.h"

View File

@ -202,7 +202,16 @@
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QWidget" name="qwVAD" native="true"> <widget class="QWidget" name="qwVAD" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>

View File

@ -18,15 +18,18 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc/types_c.h>
#include <QTimer> #include <QTimer>
#include <QPainter> #include <QPainter>
#include <QImageReader>
#include <QBuffer>
#include <QCamera>
#include <QCameraInfo>
#include <QCameraImageCapture>
#include "QVideoDevice.h" #include "QVideoDevice.h"
#include "VideoProcessor.h" #include "VideoProcessor.h"
// #define DEBUG_QVIDEODEVICE 1
QVideoInputDevice::QVideoInputDevice(QWidget *parent) QVideoInputDevice::QVideoInputDevice(QWidget *parent)
:QObject(parent) :QObject(parent)
{ {
@ -36,16 +39,28 @@ QVideoInputDevice::QVideoInputDevice(QWidget *parent)
_echo_output_device = NULL ; _echo_output_device = NULL ;
} }
bool QVideoInputDevice::stopped() QVideoInputDevice::~QVideoInputDevice()
{
stop() ;
_video_processor = NULL ;
delete _image_capture;
delete _capture_device;
delete _timer;
}
bool QVideoInputDevice::stopped() const
{ {
return _timer == NULL ; return _timer == NULL ;
} }
void QVideoInputDevice::stop() void QVideoInputDevice::stop()
{ {
_capture_device_info = QCameraInfo();
if(_timer != NULL) if(_timer != NULL)
{ {
QObject::disconnect(_timer,SIGNAL(timeout()),this,SLOT(grabFrame())) ; _capture_device->stop();
_timer->stop() ; _timer->stop() ;
delete _timer ; delete _timer ;
_timer = NULL ; _timer = NULL ;
@ -53,57 +68,118 @@ void QVideoInputDevice::stop()
if(_capture_device != NULL) if(_capture_device != NULL)
{ {
// the camera will be deinitialized automatically in VideoCapture destructor // the camera will be deinitialized automatically in VideoCapture destructor
_capture_device->release(); delete _image_capture ;
delete _capture_device ; delete _capture_device ;
_capture_device = NULL ; _capture_device = NULL ;
} _image_capture = NULL ;
}
if(_echo_output_device != NULL)
_echo_output_device->showFrameOff() ;
} }
void QVideoInputDevice::start() void QVideoInputDevice::getAvailableDevices(QList<QString>& device_desc)
{
device_desc.clear();
QList<QCameraInfo> dev_list = QCameraInfo::availableCameras();
for(auto& cam:dev_list)
device_desc.push_back(cam.deviceName());
}
void QVideoInputDevice::start(const QString& description)
{ {
// make sure everything is re-initialised // make sure everything is re-initialised
// //
stop() ; stop() ;
// Initialise la capture QCameraInfo caminfo ;
static const int cam_id = 0 ;
_capture_device = new cv::VideoCapture(cam_id);
if(!_capture_device->isOpened()) if(description.isNull())
{ caminfo = QCameraInfo::defaultCamera();
std::cerr << "Cannot initialise camera. Something's wrong." << std::endl; else
return ; {
} auto cam_list = QCameraInfo::availableCameras();
_timer = new QTimer ; for(auto& s:cam_list)
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(grabFrame())) ; if(s.deviceName() == description)
caminfo = s;
}
_timer->start(50) ; // 10 images per second. if(caminfo.isNull())
{
std::cerr << "No video camera available in this system!" << std::endl;
return ;
}
_capture_device_info = caminfo;
_capture_device = new QCamera(caminfo);
if(_capture_device->error() != QCamera::NoError)
{
emit cameraCaptureInfo(CANNOT_INITIALIZE_CAMERA,_capture_device->error());
std::cerr << "Cannot initialise camera. Something's wrong." << std::endl;
return;
}
_capture_device->setCaptureMode(QCamera::CaptureStillImage);
if(_capture_device->error() == QCamera::NoError)
emit cameraCaptureInfo(CAMERA_IS_READY,QCamera::NoError);
_image_capture = new QCameraImageCapture(_capture_device);
if(!_image_capture->isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer))
{
emit cameraCaptureInfo(CAMERA_IS_READY,QCamera::NoError);
delete _capture_device;
delete _image_capture;
return;
}
_image_capture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
QObject::connect(_image_capture,SIGNAL(imageAvailable(int,QVideoFrame)),this,SLOT(grabFrame(int,QVideoFrame)));
QObject::connect(this,SIGNAL(cameraCaptureInfo(CameraStatus,QCamera::Error)),this,SLOT(errorHandling(CameraStatus,QCamera::Error)));
_timer = new QTimer ;
QObject::connect(_timer,SIGNAL(timeout()),_image_capture,SLOT(capture())) ;
_timer->start(50) ; // 10 images per second.
_capture_device->start();
} }
void QVideoInputDevice::grabFrame() void QVideoInputDevice::errorHandling(CameraStatus status,QCamera::Error error)
{ {
if(!_timer) #ifdef DEBUG_QVIDEODEVICE
return ; std::cerr << "Received msg from camera capture: status=" << (int)status << " error=" << (int)error << std::endl;
#endif
cv::Mat frame; if(status == CANNOT_INITIALIZE_CAMERA)
if(!_capture_device->read(frame))
{ {
std::cerr << "(EE) Cannot capture image from camera. Something's wrong." << std::endl; std::cerr << "Cannot initialize camera. Make sure to install package libqt5multimedia5-plugins, as this is a common cause for camera not being found." << std::endl;
return ; }
}
void QVideoInputDevice::grabFrame(int id,QVideoFrame frame)
{
if(frame.size().isEmpty())
{
std::cerr << "Empty frame!" ;
return;
} }
// get the image data frame.map(QAbstractVideoBuffer::ReadOnly);
QByteArray data((const char *)frame.bits(), frame.mappedBytes());
QBuffer buffer;
buffer.setData(data);
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer, "JPG");
reader.setScaledSize(QSize(640,480));
QImage image(reader.read());
if(frame.channels() != 3) #ifdef DEBUG_QVIDEODEVICE
{ std::cerr << "Frame " << id << ". Pixel format: " << frame.pixelFormat() << ". Size: " << image.size().width() << " x " << image.size().height() << std::endl; // if(frame.pixelFormat() != QVideoFrame::Format_Jpeg)
std::cerr << "(EE) expected 3 channels. Got " << frame.channels() << std::endl; #endif
return ;
}
// convert to RGB and copy to new buffer, because cvQueryFrame tells us to not modify the buffer
cv::Mat img_rgb;
cv::cvtColor(frame, img_rgb, CV_BGR2RGB);
QImage image = QImage(img_rgb.data,img_rgb.cols,img_rgb.rows,QImage::Format_RGB888);
if(_video_processor != NULL) if(_video_processor != NULL)
{ {
@ -128,16 +204,12 @@ bool QVideoInputDevice::getNextEncodedPacket(RsVOIPDataChunk& chunk)
uint32_t QVideoInputDevice::currentBandwidth() const uint32_t QVideoInputDevice::currentBandwidth() const
{ {
return _video_processor->currentBandwidthOut() ; if(stopped())
return 0;
else
return _video_processor->currentBandwidthOut() ;
} }
QVideoInputDevice::~QVideoInputDevice()
{
stop() ;
_video_processor = NULL ;
}
QVideoOutputDevice::QVideoOutputDevice(QWidget *parent) QVideoOutputDevice::QVideoOutputDevice(QWidget *parent)
: QLabel(parent) : QLabel(parent)
{ {
@ -152,7 +224,9 @@ void QVideoOutputDevice::showFrameOff()
void QVideoOutputDevice::showFrame(const QImage& img) void QVideoOutputDevice::showFrame(const QImage& img)
{ {
#ifdef DEBUG_QVIDEODEVICE
std::cerr << "img.size = " << img.width() << " x " << img.height() << std::endl; std::cerr << "img.size = " << img.width() << " x " << img.height() << std::endl;
#endif
setPixmap(QPixmap::fromImage(img).scaled( QSize(height()*4/3,height()),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)) ; setPixmap(QPixmap::fromImage(img).scaled( QSize(height()*4/3,height()),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)) ;
} }

View File

@ -21,13 +21,14 @@
#pragma once #pragma once
#include <QLabel> #include <QLabel>
#include <QCamera>
#include <QCameraInfo>
#include "interface/rsVOIP.h" #include "interface/rsVOIP.h"
#include "opencv2/opencv.hpp"
#include "gui/VideoProcessor.h" #include "gui/VideoProcessor.h"
class VideoEncoder ; class VideoEncoder ;
class QCameraImageCapture;
// Responsible from displaying the video. The source of the video is // Responsible from displaying the video. The source of the video is
// a VideoDecoder object, which uses a codec. // a VideoDecoder object, which uses a codec.
@ -49,7 +50,7 @@ class QVideoInputDevice: public QObject
Q_OBJECT Q_OBJECT
public: public:
QVideoInputDevice(QWidget *parent = 0) ; QVideoInputDevice(QWidget *parent = 0) ;
~QVideoInputDevice() ; ~QVideoInputDevice() ;
// Captured images are sent to this encoder. Can be NULL. // Captured images are sent to this encoder. Can be NULL.
@ -71,19 +72,35 @@ class QVideoInputDevice: public QObject
// control // control
void start() ; void start(const QString &description = QString()) ;
void stop() ; void stop() ;
bool stopped(); bool stopped() const;
enum CameraStatus {
CAMERA_IS_READY = 0x00,
CANNOT_INITIALIZE_CAMERA = 0x01,
CAMERA_CANNOT_GRAB_FRAMES = 0x02
};
// Gets the list of available devices. The id string for each device can be used when creating a QVideoDevice
static void getAvailableDevices(QList<QString>& device_desc);
QString currentCameraDescriptionString() const { return _capture_device_info.deviceName(); }
protected slots: protected slots:
void grabFrame() ; void grabFrame(int id, QVideoFrame f) ;
void errorHandling(CameraStatus status,QCamera::Error error);
signals: signals:
void networkPacketReady() ; void networkPacketReady() ;
void cameraCaptureInfo(CameraStatus status,QCamera::Error qt_cam_err_code);
private: private:
VideoProcessor *_video_processor ; VideoProcessor *_video_processor ;
QTimer *_timer ; QTimer *_timer ;
cv::VideoCapture *_capture_device ; QCamera *_capture_device;
QCameraImageCapture *_image_capture;
QCameraInfo _capture_device_info;
QVideoOutputDevice *_echo_output_device ; QVideoOutputDevice *_echo_output_device ;

View File

@ -19,14 +19,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#pragma once
#include "AudioStats.h" #include "AudioStats.h"
#include "AudioInputConfig.h" #include "VOIPConfigPanel.h"
#include "audiodevicehelper.h" #include "audiodevicehelper.h"
#include "AudioWizard.h" #include "AudioWizard.h"
#include "gui/VideoProcessor.h" #include "gui/VideoProcessor.h"
#include "gui/common/RSGraphWidget.h" #include "gui/VideoProcessor.h"
#include "util/misc.h"
#include "util/RsProtectedTimer.h" #include "util/RsProtectedTimer.h"
#include <interface/rsVOIP.h> #include <interface/rsVOIP.h>
@ -80,7 +80,7 @@ voipGraph::voipGraph(QWidget *parent)
} }
/** Constructor */ /** Constructor */
AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags) VOIPConfigPanel::VOIPConfigPanel(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
{ {
std::cerr << "Creating audioInputConfig object" << std::endl; std::cerr << "Creating audioInputConfig object" << std::endl;
@ -92,19 +92,57 @@ AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags)
inputAudioProcessor = NULL; inputAudioProcessor = NULL;
inputAudioDevice = NULL; inputAudioDevice = NULL;
abSpeech = NULL;
qtTick = NULL; qtTick = NULL;
ui.qcbTransmit->addItem(tr("Continuous"), RsVOIP::AudioTransmitContinous);
ui.qcbTransmit->addItem(tr("Voice Activity"), RsVOIP::AudioTransmitVAD);
ui.qcbTransmit->addItem(tr("Push To Talk"), RsVOIP::AudioTransmitPushToTalk);
ui.abSpeech->qcBelow = Qt::red;
ui.abSpeech->qcInside = Qt::yellow;
ui.abSpeech->qcAbove = Qt::green;
QList<QString> input_devices;
QVideoInputDevice::getAvailableDevices(input_devices);
ui.inputDevice_CB->clear();
ui.inputDevice_CB->addItem(tr("[No video]"),QString(""));
for(auto& s:input_devices)
ui.inputDevice_CB->addItem(s,QVariant(s));
if(!input_devices.empty())
whileBlocking(ui.inputDevice_CB)->setCurrentIndex(1); // select default cam
connect( ui.qsTransmitHold, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsTransmitHold_valueChanged(int) ) );
connect( ui.qsNoise, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsNoise_valueChanged(int) ) );
connect( ui.qsAmp, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsAmp_valueChanged(int) ) );
connect( ui.qcbTransmit, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_qcbTransmit_currentIndexChanged(int) ) );
connect( ui.inputDevice_CB, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_changedCurrentInputDevice(int) ) );
}
void VOIPConfigPanel::showEvent(QShowEvent *)
{
std::cerr << "Creating the audio pipeline" << std::endl;
inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice();
inputAudioDevice->start(inputAudioProcessor);
connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(emptyBuffer()));
std::cerr << "Creating the video pipeline" << std::endl;
// Create the video pipeline. // Create the video pipeline.
// //
videoInput = new QVideoInputDevice(this) ; videoInput = new QVideoInputDevice(this) ;
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
videoProcessor = new VideoProcessor() ; videoProcessor = new VideoProcessor() ;
videoProcessor->setDisplayTarget(NULL) ; videoProcessor->setDisplayTarget(NULL) ;
videoProcessor->setMaximumBandwidth(ui.availableBW_SB->value()) ; videoProcessor->setMaximumBandwidth(ui.availableBW_SB->value()) ;
videoInput->setVideoProcessor(videoProcessor) ; videoInput->setVideoProcessor(videoProcessor) ;
graph_source = new voipGraphSource ; graph_source = new voipGraphSource ;
@ -114,17 +152,43 @@ AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags)
graph_source->setCollectionTimeLimit(1000*300) ; graph_source->setCollectionTimeLimit(1000*300) ;
graph_source->start() ; graph_source->start() ;
if(ui.showEncoded_CB->isChecked())
{
videoInput->setEchoVideoTarget(nullptr) ;
videoProcessor->setDisplayTarget(ui.videoDisplay) ;
}
else
{
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
videoProcessor->setDisplayTarget(nullptr);
}
QObject::connect(ui.showEncoded_CB,SIGNAL(toggled(bool)),this,SLOT(togglePreview(bool))) ; QObject::connect(ui.showEncoded_CB,SIGNAL(toggled(bool)),this,SLOT(togglePreview(bool))) ;
QObject::connect(ui.availableBW_SB,SIGNAL(valueChanged(double)),this,SLOT(updateAvailableBW(double))) ; QObject::connect(ui.availableBW_SB,SIGNAL(valueChanged(double)),this,SLOT(updateAvailableBW(double))) ;
loadSettings();
qtTick = new RsProtectedTimer(this);
connect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) );
qtTick->start(20);
videoInput->start();
} }
void AudioInputConfig::updateAvailableBW(double r) void VOIPConfigPanel::hideEvent(QHideEvent *)
{
std::cerr << "Deleting the video pipeline" << std::endl;
clearPipeline();
}
void VOIPConfigPanel::updateAvailableBW(double r)
{ {
std::cerr << "Setting max bandwidth to " << r << " KB/s" << std::endl; std::cerr << "Setting max bandwidth to " << r << " KB/s" << std::endl;
videoProcessor->setMaximumBandwidth((uint32_t)(r*1024)) ; videoProcessor->setMaximumBandwidth((uint32_t)(r*1024)) ;
} }
void AudioInputConfig::togglePreview(bool b) void VOIPConfigPanel::togglePreview(bool b)
{ {
if(b) if(b)
{ {
@ -138,148 +202,98 @@ void AudioInputConfig::togglePreview(bool b)
} }
} }
AudioInputConfig::~AudioInputConfig() VOIPConfigPanel::~VOIPConfigPanel()
{ {
disconnect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) ); clearPipeline();
}
graph_source->stop() ;
graph_source->setVideoInput(NULL) ; void VOIPConfigPanel::clearPipeline()
{
delete qtTick;
graph_source->stop() ;
graph_source->setVideoInput(NULL) ;
graph_source=nullptr; // is deleted by setSource below. This is a bad design.
ui.voipBwGraph->setSource(nullptr);
std::cerr << "Deleting audioInputConfig object" << std::endl; std::cerr << "Deleting audioInputConfig object" << std::endl;
if(videoInput != NULL) if(videoInput != NULL)
{ {
videoInput->stop() ; videoInput->stop() ;
delete videoInput ; delete videoInput ;
videoInput = nullptr;
} }
delete videoProcessor;
videoProcessor = nullptr;
if (inputAudioDevice) { if (inputAudioDevice) {
inputAudioDevice->stop(); inputAudioDevice->stop();
delete inputAudioDevice ; delete inputAudioDevice ;
inputAudioDevice = NULL ; inputAudioDevice = nullptr ;
} }
if(inputAudioProcessor) if(inputAudioProcessor)
{ {
delete inputAudioProcessor ; delete inputAudioProcessor ;
inputAudioProcessor = NULL ; inputAudioProcessor = nullptr ;
} }
} }
/** Loads the settings for this page */ void VOIPConfigPanel::load()
void AudioInputConfig::load()
{ {
//connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
//connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
qtTick = new RsProtectedTimer(this);
connect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) );
qtTick->start(20);
/*if (AudioInputRegistrar::qmNew) {
QList<QString> keys = AudioInputRegistrar::qmNew->keys();
foreach(QString key, keys) {
qcbSystem->addItem(key);
}
}
qcbSystem->setEnabled(qcbSystem->count() > 1);*/
ui.qcbTransmit->addItem(tr("Continuous"), RsVOIP::AudioTransmitContinous);
ui.qcbTransmit->addItem(tr("Voice Activity"), RsVOIP::AudioTransmitVAD);
ui.qcbTransmit->addItem(tr("Push To Talk"), RsVOIP::AudioTransmitPushToTalk);
abSpeech = new AudioBar();
abSpeech->qcBelow = Qt::red;
abSpeech->qcInside = Qt::yellow;
abSpeech->qcAbove = Qt::green;
//abSpeech->setGeometry(9,20,50,10);
ui.qwVadLayout_2->addWidget(abSpeech,0,0,1,0);
//on_qcbPushClick_clicked(g.s.bPushClick);
//ui.on_Tick_timeout();
loadSettings();
} }
/** Loads the settings for this page */
void AudioInputConfig::loadSettings() { void VOIPConfigPanel::loadSettings()
/*QList<QString> keys; {
ui.qcbTransmit->setCurrentIndex(rsVOIP->getVoipATransmit());
on_qcbTransmit_currentIndexChanged(rsVOIP->getVoipATransmit());
ui.qsTransmitHold->setValue(rsVOIP->getVoipVoiceHold());
on_qsTransmitHold_valueChanged(rsVOIP->getVoipVoiceHold());
ui.qsTransmitMin->setValue(rsVOIP->getVoipfVADmin());
ui.qsTransmitMax->setValue(rsVOIP->getVoipfVADmax());
ui.qcbEchoCancel->setChecked(rsVOIP->getVoipEchoCancel());
if (AudioInputRegistrar::qmNew) if (rsVOIP->getVoipiNoiseSuppress() != 0)
keys=AudioInputRegistrar::qmNew->keys(); ui.qsNoise->setValue(-rsVOIP->getVoipiNoiseSuppress());
else else
keys.clear(); ui.qsNoise->setValue(14);
i=keys.indexOf(AudioInputRegistrar::current);
if (i >= 0)
loadComboBox(qcbSystem, i);
loadCheckBox(qcbExclusive, r.bExclusiveInput);*/ on_qsNoise_valueChanged(-rsVOIP->getVoipiNoiseSuppress());
//qlePushClickPathOn->setText(r.qsPushClickOn); ui.qsAmp->setValue(20000 - rsVOIP->getVoipiMinLoudness());
//qlePushClickPathOff->setText(r.qsPushClickOff); on_qsAmp_valueChanged(20000 - rsVOIP->getVoipiMinLoudness());
/*loadComboBox(qcbTransmit, r.atTransmit); loaded = true;
loadSlider(qsTransmitHold, r.iVoiceHold);
loadSlider(qsTransmitMin, iroundf(r.fVADmin * 32767.0f + 0.5f));
loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f));
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket/2 + 1));
loadSlider(qsDoublePush, iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));*/
ui.qcbTransmit->setCurrentIndex(rsVOIP->getVoipATransmit());
on_qcbTransmit_currentIndexChanged(rsVOIP->getVoipATransmit());
ui.qsTransmitHold->setValue(rsVOIP->getVoipVoiceHold());
on_qsTransmitHold_valueChanged(rsVOIP->getVoipVoiceHold());
ui.qsTransmitMin->setValue(rsVOIP->getVoipfVADmin());
ui.qsTransmitMax->setValue(rsVOIP->getVoipfVADmax());
ui.qcbEchoCancel->setChecked(rsVOIP->getVoipEchoCancel());
//ui.qsDoublePush->setValue(iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));
//loadCheckBox(qcbPushClick, r.bPushClick);
//loadSlider(qsQuality, r.iQuality);
if (rsVOIP->getVoipiNoiseSuppress() != 0)
ui.qsNoise->setValue(-rsVOIP->getVoipiNoiseSuppress());
else
ui.qsNoise->setValue(14);
on_qsNoise_valueChanged(-rsVOIP->getVoipiNoiseSuppress());
ui.qsAmp->setValue(20000 - rsVOIP->getVoipiMinLoudness());
on_qsAmp_valueChanged(20000 - rsVOIP->getVoipiMinLoudness());
//loadSlider(qsIdle, r.iIdleTime);
/*int echo = 0;
if (r.bEcho)
echo = r.bEchoMulti ? 2 : 1;
loadComboBox(qcbEcho, echo);*/
connect( ui.qsTransmitHold, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsTransmitHold_valueChanged(int) ) );
connect( ui.qsNoise, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsNoise_valueChanged(int) ) );
connect( ui.qsAmp, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsAmp_valueChanged(int) ) );
connect( ui.qcbTransmit, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_qcbTransmit_currentIndexChanged(int) ) );
loaded = true;
std::cerr << "AudioInputConfig:: starting video." << std::endl;
videoInput->start() ;
} }
bool AudioInputConfig::save(QString &/*errmsg*/) {//mainly useless beacause saving occurs in realtime bool VOIPConfigPanel::save(QString &/*errmsg*/)
//s.iQuality = qsQuality->value(); {
rsVOIP->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value()); //mainly useless beacause saving occurs in realtime
rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value()); //s.iQuality = qsQuality->value();
rsVOIP->setVoipVoiceHold(ui.qsTransmitHold->value()); rsVOIP->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value());
rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value()); rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value());
rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value()); rsVOIP->setVoipVoiceHold(ui.qsTransmitHold->value());
/*s.uiDoublePush = qsDoublePush->value() * 1000;*/ rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value());
rsVOIP->setVoipATransmit(static_cast<RsVOIP::enumAudioTransmit>(ui.qcbTransmit->currentIndex() )); rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value());
rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); /*s.uiDoublePush = qsDoublePush->value() * 1000;*/
rsVOIP->setVoipATransmit(static_cast<RsVOIP::enumAudioTransmit>(ui.qcbTransmit->currentIndex() ));
rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
return true; return true;
} }
void AudioInputConfig::on_qsTransmitHold_valueChanged(int v) { void VOIPConfigPanel::on_qsTransmitHold_valueChanged(int v) {
float val = static_cast<float>(v * FRAME_SIZE); float val = static_cast<float>(v * FRAME_SIZE);
val = val / SAMPLING_RATE; val = val / SAMPLING_RATE;
ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2)); ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2));
rsVOIP->setVoipVoiceHold(v); rsVOIP->setVoipVoiceHold(v);
} }
void AudioInputConfig::on_qsNoise_valueChanged(int v) { void VOIPConfigPanel::on_qsNoise_valueChanged(int v) {
QPalette pal; QPalette pal;
if (v < 15) { if (v < 15) {
@ -292,19 +306,19 @@ void AudioInputConfig::on_qsNoise_valueChanged(int v) {
rsVOIP->setVoipiNoiseSuppress(- ui.qsNoise->value()); rsVOIP->setVoipiNoiseSuppress(- ui.qsNoise->value());
} }
void AudioInputConfig::on_qsAmp_valueChanged(int v) { void VOIPConfigPanel::on_qsAmp_valueChanged(int v) {
v = 20000 - v; v = 20000 - v;
float d = 20000.0f/static_cast<float>(v); float d = 20000.0f/static_cast<float>(v);
ui.qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2)); ui.qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2));
rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value()); rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value());
} }
void AudioInputConfig::on_qcbEchoCancel_clicked() { void VOIPConfigPanel::on_qcbEchoCancel_clicked() {
rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
} }
void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) { void VOIPConfigPanel::on_qcbTransmit_currentIndexChanged(int v) {
switch (v) { switch (v) {
case 0: case 0:
ui.qswTransmit->setCurrentWidget(ui.qwContinuous); ui.qswTransmit->setCurrentWidget(ui.qwContinuous);
@ -321,34 +335,25 @@ void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) {
} }
void AudioInputConfig::on_Tick_timeout() void VOIPConfigPanel::on_Tick_timeout()
{ {
if (!inputAudioProcessor) // update the sound capture bar
{
inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
if (!inputAudioDevice) { ui.abSpeech->iBelow = ui.qsTransmitMin->value();
inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice(); ui.abSpeech->iAbove = ui.qsTransmitMax->value();
}
inputAudioDevice->start(inputAudioProcessor);
connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(emptyBuffer()));
}
abSpeech->iBelow = ui.qsTransmitMin->value(); if (loaded) {
abSpeech->iAbove = ui.qsTransmitMax->value(); rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value());
if (loaded) { rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value());
rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value()); }
rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value());
}
abSpeech->iValue = iroundf(inputAudioProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f); ui.abSpeech->iValue = iroundf(inputAudioProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
ui.abSpeech->update();
// also transmit encoded video
abSpeech->update();
// also transmit encoded video
RsVOIPDataChunk chunk ; RsVOIPDataChunk chunk ;
while((!videoInput->stopped()) && videoInput->getNextEncodedPacket(chunk)) while((!videoInput->stopped()) && videoInput->getNextEncodedPacket(chunk))
{ {
videoProcessor->receiveEncodedData(chunk) ; videoProcessor->receiveEncodedData(chunk) ;
@ -356,14 +361,103 @@ void AudioInputConfig::on_Tick_timeout()
} }
} }
void AudioInputConfig::emptyBuffer() { void VOIPConfigPanel::emptyBuffer() {
while(inputAudioProcessor->hasPendingPackets()) { while(inputAudioProcessor->hasPendingPackets()) {
inputAudioProcessor->getNetworkPacket(); //that will purge the buffer inputAudioProcessor->getNetworkPacket(); //that will purge the buffer
} }
} }
void AudioInputConfig::on_qpbAudioWizard_clicked() { void VOIPConfigPanel::on_qpbAudioWizard_clicked() {
AudioWizard aw(this); AudioWizard aw(this);
aw.exec(); aw.exec();
loadSettings(); loadSettings();
} }
void VOIPConfigPanel::on_changedCurrentInputDevice(int i)
{
QString s = dynamic_cast<QComboBox*>(sender())->itemData(i).toString();
videoInput->stop();
// check that the camera still exists
QList<QString> input_devices;
QVideoInputDevice::getAvailableDevices(input_devices);
for(const QString& cams:input_devices)
if(s == cams)
{
std::cerr << "Switching to camera \"" << s.toStdString() << "\"" << std::endl;
videoInput->start(s);
return;
}
// if not, re-create the ComboBox
checkAvailableCameras();
}
void VOIPConfigPanel::checkAvailableCameras()
{
// save current camera
QString current_cam = videoInput->currentCameraDescriptionString();
// Check that the list of cams we had previously is the same than the list of available camera.
QList<QString> input_devices;
QVideoInputDevice::getAvailableDevices(input_devices);
bool same = true;
if(input_devices.size() != ui.inputDevice_CB->count())
same = false;
if(same)
{
int n=0;
for(auto& s:input_devices)
{
if(ui.inputDevice_CB->itemData(n).toString() != s)
{
same = false;
break;
}
n++;
}
}
// If not, re-add them to the comboBox and make sure to re-select the same camera.
if(!same)
{
whileBlocking(ui.inputDevice_CB)->clear(); // remove existing entries
whileBlocking(ui.inputDevice_CB)->addItem(tr("[No video]"),QString(""));
int n=0;
int found_index = -1;
for(auto& s:input_devices)
{
whileBlocking(ui.inputDevice_CB)->addItem(s,QVariant(s));
if(s == current_cam)
found_index = n;
n++;
}
if(found_index >= 0)
ui.inputDevice_CB->setCurrentIndex(found_index);
else
ui.inputDevice_CB->setCurrentIndex(0); // no video
}
}

View File

@ -19,7 +19,6 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#pragma once #pragma once
#pragma once
#include <QAudioInput> #include <QAudioInput>
#include <QWidget> #include <QWidget>
@ -46,9 +45,9 @@ private:
voipGraphSource *_src ; voipGraphSource *_src ;
}; };
#include "ui_AudioInputConfig.h" #include "ui_VOIPConfigPanel.h"
class AudioInputConfig : public ConfigPage class VOIPConfigPanel : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
@ -60,33 +59,37 @@ class AudioInputConfig : public ConfigPage
//VideoDecoder *videoDecoder ; //VideoDecoder *videoDecoder ;
//VideoEncoder *videoEncoder ; //VideoEncoder *videoEncoder ;
QVideoInputDevice *videoInput ; QVideoInputDevice *videoInput ;
VideoProcessor *videoProcessor ; VideoProcessor *videoProcessor ;
bool loaded; bool loaded;
QString currentCameraDescription;
voipGraphSource *graph_source ; voipGraphSource *graph_source ;
protected: protected:
QTimer *qtTick; QTimer *qtTick;
/*void hideEvent(QHideEvent *event);
void showEvent(QShowEvent *event);*/
void clearPipeline();
public: public:
/** Default Constructor */ /** Default Constructor */
AudioInputConfig(QWidget * parent = 0, Qt::WindowFlags flags = 0); VOIPConfigPanel(QWidget * parent = 0, Qt::WindowFlags flags = 0);
/** Default Destructor */ /** Default Destructor */
~AudioInputConfig(); ~VOIPConfigPanel();
/** Saves the changes on this page */ /** Saves the changes on this page */
virtual bool save(QString &errmsg); virtual bool save(QString &errmsg)override ;
/** Loads the settings for this page */ /** Loads the settings for this page */
virtual void load(); virtual void load()override ;
virtual QPixmap iconPixmap() const { return QPixmap(":/images/talking_on.svg") ; } virtual QPixmap iconPixmap() const override { return QPixmap(":/images/talking_on.svg") ; }
virtual QString pageName() const { return tr("VOIP") ; } virtual QString pageName() const override { return tr("VOIP") ; }
virtual QString helpText() const { return ""; } virtual QString helpText() const override { return ""; }
virtual void showEvent(QShowEvent *) override;
virtual void hideEvent(QHideEvent *event) override;
private slots: private slots:
void updateAvailableBW(double r); void on_changedCurrentInputDevice(int i);
void checkAvailableCameras();
void updateAvailableBW(double r);
void loadSettings(); void loadSettings();
void emptyBuffer(); void emptyBuffer();
void togglePreview(bool) ; void togglePreview(bool) ;

View File

@ -10,50 +10,289 @@
<height>832</height> <height>832</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QPushButton" name="qpbAudioWizard"> <widget class="QGroupBox" name="groupBox">
<property name="text"> <property name="title">
<string>Audio Wizard</string> <string>Video</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Input device:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="inputDevice_CB"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Available bandwidth:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="availableBW_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use this field to simulate the maximum bandwidth available so as to preview what the encoded video will look like with the corresponding compression rate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string>KB/s</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showEncoded_CB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Display encoded (and then decoded) frame, to check the codec's quality. If not selected, the image above only shows the frame that is grabbed from your camera.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>preview</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="qgbTransmission"> <widget class="QGroupBox" name="qgbAudio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string>Transmission</string> <string>Audio</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0"> <item>
<widget class="QLabel" name="qliTransmit"> <widget class="QLabel" name="qlNoise">
<property name="text"> <property name="minimumSize">
<string>&amp;Transmit</string> <size>
<width>30</width>
<height>0</height>
</size>
</property> </property>
<property name="buddy"> <property name="text">
<cstring>qcbTransmit</cstring> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="2"> <item>
<widget class="QComboBox" name="qcbTransmit"> <widget class="QSlider" name="qsNoise">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip"> <property name="toolTip">
<string>When to transmit your speech</string> <string>Noise suppression</string>
</property> </property>
<property name="whatsThis"> <property name="whatsThis">
<string>&lt;b&gt;This sets when speech should be transmitted.&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Continuous&lt;/i&gt; - All the time&lt;br /&gt;&lt;i&gt;Voice Activity&lt;/i&gt; - When you are speaking clearly.&lt;br /&gt;&lt;i&gt;Push To Talk&lt;/i&gt; - When you hold down the hotkey set under &lt;i&gt;Shortcuts&lt;/i&gt;.</string> <string>&lt;b&gt;This sets the amount of noise suppression to apply.&lt;/b&gt;&lt;br /&gt;The higher this value, the more aggressively stationary noise will be suppressed.</string>
</property>
<property name="minimum">
<number>14</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="3"> <item>
<widget class="QLabel" name="qliNoise">
<property name="text">
<string>Noise Suppression</string>
</property>
<property name="buddy">
<cstring>qsNoise</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qlAmp">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="qsAmp">
<property name="toolTip">
<string>Maximum amplification of input sound</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;Maximum amplification of input.&lt;/b&gt;&lt;br /&gt;RetroShare normalizes the input volume before compressing, and this sets how much it's allowed to amplify.&lt;br /&gt;The actual level is continually updated based on your current speech pattern, but it will never go above the level specified here.&lt;br /&gt;If the &lt;i&gt;Microphone loudness&lt;/i&gt; level of the audio statistics hover around 100%, you probably want to set this to 2.0 or so, but if, like most people, you are unable to reach 100%, set this to something much higher.&lt;br /&gt;Ideally, set it so &lt;i&gt;Microphone Loudness * Amplification Factor &gt;= 100&lt;/i&gt;, even when you're speaking really soft.&lt;br /&gt;&lt;br /&gt;Note that there is no harm in setting this to maximum, but RetroShare will start picking up other conversations if you leave it to auto-tune to that level.</string>
</property>
<property name="maximum">
<number>19500</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="pageStep">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qliAmp">
<property name="text">
<string>Amplification</string>
</property>
<property name="buddy">
<cstring>qsAmp</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="qcbEchoCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Echo Cancellation Processing</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="qliTransmit">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Transmit:</string>
</property>
<property name="buddy">
<cstring>qcbTransmit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="qcbTransmit">
<property name="toolTip">
<string>When to transmit your speech</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;This sets when speech should be transmitted.&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Continuous&lt;/i&gt; - All the time&lt;br /&gt;&lt;i&gt;Voice Activity&lt;/i&gt; - When you are speaking clearly.&lt;br /&gt;&lt;i&gt;Push To Talk&lt;/i&gt; - When you hold down the hotkey set under &lt;i&gt;Shortcuts&lt;/i&gt;.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="qpbAudioWizard">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Audio Wizard</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="qswTransmit"> <widget class="QStackedWidget" name="qswTransmit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="qwPTT"> <widget class="QWidget" name="qwPTT">
<layout class="QGridLayout"> <layout class="QGridLayout">
@ -231,218 +470,21 @@
<widget class="QWidget" name="qwContinuous"/> <widget class="QWidget" name="qwContinuous"/>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="qgbAudio">
<property name="title">
<string>Audio Processing</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="qliNoise">
<property name="text">
<string>Noise Suppression</string>
</property>
<property name="buddy">
<cstring>qsNoise</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="qsNoise">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Noise suppression</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;This sets the amount of noise suppression to apply.&lt;/b&gt;&lt;br /&gt;The higher this value, the more aggressively stationary noise will be suppressed.</string>
</property>
<property name="minimum">
<number>14</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="qlNoise">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="qliAmp">
<property name="text">
<string>Amplification</string>
</property>
<property name="buddy">
<cstring>qsAmp</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="qsAmp">
<property name="toolTip">
<string>Maximum amplification of input sound</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;Maximum amplification of input.&lt;/b&gt;&lt;br /&gt;RetroShare normalizes the input volume before compressing, and this sets how much it's allowed to amplify.&lt;br /&gt;The actual level is continually updated based on your current speech pattern, but it will never go above the level specified here.&lt;br /&gt;If the &lt;i&gt;Microphone loudness&lt;/i&gt; level of the audio statistics hover around 100%, you probably want to set this to 2.0 or so, but if, like most people, you are unable to reach 100%, set this to something much higher.&lt;br /&gt;Ideally, set it so &lt;i&gt;Microphone Loudness * Amplification Factor &gt;= 100&lt;/i&gt;, even when you're speaking really soft.&lt;br /&gt;&lt;br /&gt;Note that there is no harm in setting this to maximum, but RetroShare will start picking up other conversations if you leave it to auto-tune to that level.</string>
</property>
<property name="maximum">
<number>19500</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="pageStep">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="qlAmp">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="qcbEchoCancel">
<property name="text">
<string>Echo Cancellation Processing</string>
</property>
<property name="tristate">
<bool>false</bool>
</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> <item>
<widget class="QVideoOutputDevice" name="videoDisplay"> <widget class="AudioBar" name="abSpeech" native="true"/>
<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> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <spacer name="verticalSpacer_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Available bandwidth:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="availableBW_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use this field to simulate the maximum bandwidth available so as to preview what the encoded video will look like with the corresponding compression rate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string>KB/s</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="showEncoded_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Display encoded (and then decoded) frame, to check the codec's quality. If not selected, the image above only shows the frame that is grabbed from your camera.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>preview</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>1</width> <width>20</width>
<height>151</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -459,12 +501,17 @@
<customwidget> <customwidget>
<class>voipGraph</class> <class>voipGraph</class>
<extends>QFrame</extends> <extends>QFrame</extends>
<header>gui/AudioInputConfig.h</header> <header>gui/VOIPConfigPanel.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AudioBar</class>
<extends>QWidget</extends>
<header>gui/AudioStats.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>qcbTransmit</tabstop>
<tabstop>qsDoublePush</tabstop> <tabstop>qsDoublePush</tabstop>
<tabstop>qsTransmitHold</tabstop> <tabstop>qsTransmitHold</tabstop>
<tabstop>qsTransmitMin</tabstop> <tabstop>qsTransmitMin</tabstop>

View File

@ -1583,7 +1583,12 @@ void ChatWidget::addSmiley()
smiley += QString(" "); smiley += QString(" ");
// add preceding space when needed (not at start of text or preceding space already exists) // add preceding space when needed (not at start of text or preceding space already exists)
QString plainText = ui->chatTextEdit->toPlainText(); QString plainText = ui->chatTextEdit->toPlainText();
QChar start = plainText[ui->chatTextEdit->textCursor().position() - 1];
int startPosition = ui->chatTextEdit->textCursor().position();
if (startPosition > 0)
startPosition -= 1;
QChar start = plainText[startPosition];
if(!ui->chatTextEdit->textCursor().atStart() && start != QChar(' ')) if(!ui->chatTextEdit->textCursor().atStart() && start != QChar(' '))
smiley = QString(" ") + smiley; smiley = QString(" ") + smiley;