diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-08-03 19:50:19 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-08-03 19:50:19 +0800 |
commit | b7a79709003b1f7f0451ba577576040fc03e50f9 (patch) | |
tree | b698a84bf52c40a2907ac3eaab7b0de2ba6a1055 /indra/llwebrtc | |
parent | 96d322edfcb97096f701ef11d5fdd1f1c97255ac (diff) | |
parent | b89076f0567547b9c2749595af5ae9d5f9de9f3a (diff) |
Merge branch 'webrtc-voice' into tmp
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 15 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc.h | 20 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc_impl.h | 59 |
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 |