summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2024-08-01 15:42:22 -0700
committerBrad Linden <brad@lindenlab.com>2024-08-01 15:42:22 -0700
commit0ff2bd1a405e4b7f3af5f815d02124017f23d468 (patch)
tree465b18c3087cf437a9d8ee124ddab4c7cb2dc633 /indra/llwebrtc
parentf9377566b9d1f2aba6aa10bfee0f9a67221debff (diff)
parent002be0f24321164a74ef2a88c656b7cb0968c7d3 (diff)
Merge remote-tracking branch 'origin/release/2024.06-atlasaurus' into develop
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp9
-rw-r--r--indra/llwebrtc/llwebrtc.h18
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h57
3 files changed, 77 insertions, 7 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 6dc632aba4..2c890acbdb 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();
@@ -312,6 +314,7 @@ void LLWebRTCImpl::terminate()
mPeerDeviceModule = nullptr;
mTaskQueueFactory = nullptr;
});
+ rtc::LogMessage::RemoveLogToStream(mLogSink);
}
//
@@ -1327,9 +1330,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 62b40636d2..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.
@@ -230,7 +244,7 @@ class LLWebRTCSignalingObserver
// allows for management of this peer connection.
class LLWebRTCPeerConnectionInterface
{
-public:
+ public:
struct InitOptions
{
@@ -262,7 +276,7 @@ public:
// 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 c1acd77275..9504e6573b 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.
@@ -139,8 +187,11 @@ class LLCustomProcessor : public webrtc::CustomProcessing
class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceSink
{
public:
- LLWebRTCImpl();
- ~LLWebRTCImpl() {}
+ LLWebRTCImpl(LLWebRTCLogCallback* logCallback);
+ ~LLWebRTCImpl()
+ {
+ delete mLogSink;
+ }
void init();
void terminate();
@@ -228,6 +279,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
void setRecording(bool recording);
protected:
+ LLWebRTCLogSink* mLogSink;
+
// The native webrtc threads
std::unique_ptr<rtc::Thread> mNetworkThread;
std::unique_ptr<rtc::Thread> mWorkerThread;