summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-02 19:36:11 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-02 19:36:11 +0800
commitad9e004037349b75b992c142c1cbcff50765ba6c (patch)
tree7fc422ead94e01e1d2fd976366b9ca2cec0e8518 /indra/llwebrtc
parent06e8f0c443c1ba7858d000c6d695b7e988e02053 (diff)
parent5f66a15142083a047ac945da94f167c24c95f49a (diff)
Merge remote-tracking branch 'secondlife/release/webrtc-voice' into webrtc-voice
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp15
-rw-r--r--indra/llwebrtc/llwebrtc.h20
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h59
3 files changed, 82 insertions, 12 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index b776591b23..e533783d33 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -154,7 +154,8 @@ void LLCustomProcessor::Process(webrtc::AudioBuffer *audio_in)
// LLWebRTCImpl implementation
//
-LLWebRTCImpl::LLWebRTCImpl() :
+LLWebRTCImpl::LLWebRTCImpl(LLWebRTCLogCallback* logCallback) :
+ mLogSink(new LLWebRTCLogSink(logCallback)),
mPeerCustomProcessor(nullptr),
mMute(true),
mTuningMode(false),
@@ -173,6 +174,7 @@ void LLWebRTCImpl::init()
// Normal logging is rather spammy, so turn it off.
rtc::LogMessage::LogToDebug(rtc::LS_NONE);
rtc::LogMessage::SetLogToStderr(true);
+ rtc::LogMessage::AddLogToStream(mLogSink, rtc::LS_VERBOSE);
mTaskQueueFactory = webrtc::CreateDefaultTaskQueueFactory();
@@ -314,6 +316,7 @@ void LLWebRTCImpl::terminate()
mPeerDeviceModule = nullptr;
mTaskQueueFactory = nullptr;
});
+ rtc::LogMessage::RemoveLogToStream(mLogSink);
}
//
@@ -460,7 +463,7 @@ void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceMo
{
device_module->SetPlayoutDevice(webrtc::AudioDeviceModule::kDefaultDevice);
}
- else
+ else
{
device_module->SetPlayoutDevice(device);
}
@@ -658,7 +661,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
// Most peer connection (signaling) happens on
// the signaling thread.
-LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
+LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
mWebRTCImpl(nullptr),
mPeerConnection(nullptr),
mMute(false),
@@ -1173,7 +1176,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface *
{
observer->OnOfferAvailable(mangled_sdp);
}
-
+
mPeerConnection->SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>(
webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, mangled_sdp)),
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>(this));
@@ -1329,9 +1332,9 @@ void freePeerConnection(LLWebRTCPeerConnectionInterface* peer_connection)
}
-void init()
+void init(LLWebRTCLogCallback* logCallback)
{
- gWebRTCImpl = new LLWebRTCImpl();
+ gWebRTCImpl = new LLWebRTCImpl(logCallback);
gWebRTCImpl->init();
}
diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h
index f447ea990a..c6fdb909dd 100644
--- a/indra/llwebrtc/llwebrtc.h
+++ b/indra/llwebrtc/llwebrtc.h
@@ -56,6 +56,20 @@
namespace llwebrtc
{
+class LLWebRTCLogCallback
+{
+public:
+ typedef enum {
+ LOG_LEVEL_VERBOSE = 0,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_ERROR
+ } LogLevel;
+
+ virtual void LogMessage(LogLevel level, const std::string& message) = 0;
+};
+
+
// LLWebRTCVoiceDevice is a simple representation of the
// components of a device, used to communicate this
// information to the viewer.
@@ -129,7 +143,7 @@ class LLWebRTCDeviceInterface
};
virtual void setAudioConfig(AudioConfig config) = 0;
-
+
// instructs webrtc to refresh the device list.
virtual void refreshDevices() = 0;
@@ -231,7 +245,7 @@ class LLWebRTCSignalingObserver
class LLWebRTCPeerConnectionInterface
{
public:
-
+
struct InitOptions
{
// equivalent of PeerConnectionInterface::IceServer
@@ -262,7 +276,7 @@ class LLWebRTCPeerConnectionInterface
// exports.
// This library must be initialized before use.
-LLSYMEXPORT void init();
+LLSYMEXPORT void init(LLWebRTCLogCallback* logSink);
// And should be terminated as part of shutdown.
LLSYMEXPORT void terminate();
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index eb675f4062..bc9b7762dd 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -69,6 +69,54 @@ namespace llwebrtc
class LLWebRTCPeerConnectionImpl;
+class LLWebRTCLogSink : public rtc::LogSink {
+public:
+ LLWebRTCLogSink(LLWebRTCLogCallback* callback) :
+ mCallback(callback)
+ {
+ }
+
+ // Destructor: close the log file
+ ~LLWebRTCLogSink() override
+ {
+ }
+
+ void OnLogMessage(const std::string& msg,
+ rtc::LoggingSeverity severity) override
+ {
+ if (mCallback)
+ {
+ switch(severity)
+ {
+ case rtc::LS_VERBOSE:
+ mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
+ break;
+ case rtc::LS_INFO:
+ mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
+ break;
+ case rtc::LS_WARNING:
+ mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
+ break;
+ case rtc::LS_ERROR:
+ mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ void OnLogMessage(const std::string& message) override
+ {
+ if (mCallback)
+ {
+ mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, message);
+ }
+ }
+
+private:
+ LLWebRTCLogCallback* mCallback;
+};
// Implements a class allowing capture of audio data
// to determine audio level of the microphone.
@@ -142,8 +190,11 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface
#endif
{
public:
- LLWebRTCImpl();
- ~LLWebRTCImpl() {}
+ LLWebRTCImpl(LLWebRTCLogCallback* logCallback);
+ ~LLWebRTCImpl()
+ {
+ delete mLogSink;
+ }
void init();
void terminate();
@@ -235,6 +286,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface
void setRecording(bool recording);
protected:
+ LLWebRTCLogSink* mLogSink;
+
// The native webrtc threads
std::unique_ptr<rtc::Thread> mNetworkThread;
std::unique_ptr<rtc::Thread> mWorkerThread;
@@ -242,7 +295,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface
// The factory that allows creation of native webrtc PeerConnections.
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory;
-
+
rtc::scoped_refptr<webrtc::AudioProcessing> mAudioProcessingModule;
// more native webrtc stuff