Bug 1404977 - Part 5 - Allow querying the number of input channels from a WebRTCAudioDataListener. r?pehrsons draft
authorPaul Adenot <paul@paul.cx>
Mon, 30 Apr 2018 15:30:58 +0200
changeset 824191 b2a62ffcb87272c43b0e9df9f2e19a066712f8d2
parent 824190 58812e76fe85819f60848f38eb8739d2d5290484
child 824192 31daa50cd025087a9470ae78413f4beafb48427e
push id117838
push userpaul@paul.cx
push dateMon, 30 Jul 2018 10:13:15 +0000
reviewerspehrsons
bugs1404977
milestone63.0a1
Bug 1404977 - Part 5 - Allow querying the number of input channels from a WebRTCAudioDataListener. r?pehrsons MozReview-Commit-ID: JkpEZOJpOTl
dom/media/MediaStreamGraph.h
dom/media/webrtc/MediaEngineWebRTC.h
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- 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
@@ -180,16 +180,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;
 }
 
 /**