Bug 1431221 - P6. Add channel map information to AudioInfo. r=padenot draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 22 Jan 2018 15:21:09 +0100
changeset 771688 441a36597cfe66581dd4d68ca2554345ab1338c0
parent 771687 d464bd1a8cccda9786a438aac7ea464989c53a34
child 771689 eddbd1f0c6e97794a1ce071ff21bf4c528a9b461
push id103752
push userbmo:jyavenard@mozilla.com
push dateFri, 23 Mar 2018 17:52:32 +0000
reviewerspadenot
bugs1431221
milestone61.0a1
Bug 1431221 - P6. Add channel map information to AudioInfo. r=padenot MozReview-Commit-ID: 2zOvciLFtAr
dom/media/MediaData.h
dom/media/MediaInfo.h
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -390,19 +390,21 @@ class AudioData : public MediaData
 public:
 
   AudioData(int64_t aOffset,
             const media::TimeUnit& aTime,
             const media::TimeUnit& aDuration,
             uint32_t aFrames,
             AlignedAudioBuffer&& aData,
             uint32_t aChannels,
-            uint32_t aRate)
+            uint32_t aRate,
+            uint32_t aChannelMap = AudioConfig::ChannelLayout::UNKNOWN_MAP)
     : MediaData(sType, aOffset, aTime, aDuration, aFrames)
     , mChannels(aChannels)
+    , mChannelMap(aChannelMap)
     , mRate(aRate)
     , mAudioData(Move(aData))
   {
   }
 
   static const Type sType = AUDIO_DATA;
   static const char* sTypeName;
 
@@ -420,16 +422,21 @@ public:
   // If mAudioBuffer is null, creates it from mAudioData.
   void EnsureAudioBuffer();
 
   // To check whether mAudioData has audible signal, it's used to distinguish
   // the audiable data and silent data.
   bool IsAudible() const;
 
   const uint32_t mChannels;
+  // The AudioConfig::ChannelLayout map. Channels are ordered as per SMPTE
+  // definition. A value of UNKNOWN_MAP indicates unknown layout.
+  // ChannelMap is an unsigned bitmap compatible with Windows' WAVE and FFmpeg
+  // channel map.
+  const AudioConfig::ChannelLayout::ChannelMap mChannelMap;
   const uint32_t mRate;
   // At least one of mAudioBuffer/mAudioData must be non-null.
   // mChannels channels, each with mFrames frames
   RefPtr<SharedBuffer> mAudioBuffer;
   // mFrames frames, each with mChannels values
   AlignedAudioBuffer mAudioData;
 
 protected:
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -350,28 +350,30 @@ private:
 class AudioInfo : public TrackInfo
 {
 public:
   AudioInfo()
     : TrackInfo(kAudioTrack, NS_LITERAL_STRING("1"), NS_LITERAL_STRING("main"),
                 EmptyString(), EmptyString(), true, 1)
     , mRate(0)
     , mChannels(0)
+    , mChannelMap(AudioConfig::ChannelLayout::UNKNOWN_MAP)
     , mBitDepth(0)
     , mProfile(0)
     , mExtendedProfile(0)
     , mCodecSpecificConfig(new MediaByteBuffer)
     , mExtraData(new MediaByteBuffer)
   {
   }
 
   AudioInfo(const AudioInfo& aOther)
     : TrackInfo(aOther)
     , mRate(aOther.mRate)
     , mChannels(aOther.mChannels)
+    , mChannelMap(aOther.mChannelMap)
     , mBitDepth(aOther.mBitDepth)
     , mProfile(aOther.mProfile)
     , mExtendedProfile(aOther.mExtendedProfile)
     , mCodecSpecificConfig(aOther.mCodecSpecificConfig)
     , mExtraData(aOther.mExtraData)
   {
   }
 
@@ -398,16 +400,21 @@ public:
     return MakeUnique<AudioInfo>(*this);
   }
 
   // Sample rate.
   uint32_t mRate;
 
   // Number of audio channels.
   uint32_t mChannels;
+  // The AudioConfig::ChannelLayout map. Channels are ordered as per SMPTE
+  // definition. A value of UNKNOWN_MAP indicates unknown layout.
+  // ChannelMap is an unsigned bitmap compatible with Windows' WAVE and FFmpeg
+  // channel map.
+  AudioConfig::ChannelLayout::ChannelMap mChannelMap;
 
   // Bits per sample.
   uint32_t mBitDepth;
 
   // Codec profile.
   int8_t mProfile;
 
   // Extended codec profile.