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 798182 aa5431fa17f006ccff3f958f79d7b6695c47b1ad
parent 798181 7228c1667435807e974eab7a8f98c9219c23615d
child 798183 d203db6261e38cf02390a38b13d1d10ff02d68bc
push id110687
push userachronop@gmail.com
push dateTue, 22 May 2018 14:13:17 +0000
reviewerspehrsons
bugs1404977
milestone62.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
@@ -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;
 }
 
 /**