Bug 1404977 - Part 5 - Allow querying the number of input channels from a WebRTCAudioDataListener. r?pehrsons
MozReview-Commit-ID: JkpEZOJpOTl
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -112,16 +112,21 @@ public:
* Input data from a microphone (or other audio source. This is not
* guaranteed to be in any particular size chunks.
*/
virtual void NotifyInputData(MediaStreamGraph* aGraph,
const AudioDataValue* aBuffer, size_t aFrames,
TrackRate aRate, uint32_t aChannels) = 0;
/**
+ * Number of audio input channels.
+ */
+ virtual uint32_t InputChannelCount() = 0;
+
+ /**
* Called when the underlying audio device has changed.
*/
virtual void DeviceChanged() = 0;
};
class AudioDataListener : public AudioDataListenerInterface {
protected:
// Protected destructor, to discourage deletion outside of Release():
--- a/dom/media/webrtc/MediaEngineWebRTC.h
+++ b/dom/media/webrtc/MediaEngineWebRTC.h
@@ -172,16 +172,18 @@ public:
uint32_t aChannels) override;
void NotifyInputData(MediaStreamGraph* aGraph,
const AudioDataValue* aBuffer,
size_t aFrames,
TrackRate aRate,
uint32_t aChannels) override;
+ uint32_t InputChannelCount() override;
+
void DeviceChanged() override;
void Shutdown();
private:
Mutex mMutex;
RefPtr<MediaEngineWebRTCMicrophoneSource> mAudioSource;
};
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -82,16 +82,26 @@ void
WebRTCAudioDataListener::DeviceChanged()
{
MutexAutoLock lock(mMutex);
if (mAudioSource) {
mAudioSource->DeviceChanged();
}
}
+uint32_t
+WebRTCAudioDataListener::InputChannelCount()
+{
+ MutexAutoLock lock(mMutex);
+ if (mAudioSource) {
+ return mAudioSource->InputChannelCount();
+ }
+ return 0;
+}
+
void
WebRTCAudioDataListener::Shutdown()
{
MutexAutoLock lock(mMutex);
mAudioSource = nullptr;
}
/**