Bug 1358662 - Add Span support to MediaRawData. r=jya draft
authorRalph Giles <giles@mozilla.com>
Fri, 21 Apr 2017 16:12:55 -0700
changeset 571594 ba5d8f6c328c6c2039e69851c32aafd000d87b4c
parent 571593 7876422fb86708fb0f60ec09b2c37ff3478fe784
child 571595 9db898692a1a0fdcd471971498c12e7f70d8c3e9
push id56862
push userbmo:giles@thaumas.net
push dateWed, 03 May 2017 00:23:00 +0000
reviewersjya
bugs1358662
milestone55.0a1
Bug 1358662 - Add Span support to MediaRawData. r=jya MozReview-Commit-ID: A3bHPlk0MQi
dom/media/MediaData.h
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -9,16 +9,17 @@
 #include "AudioSampleFormat.h"
 #include "ImageTypes.h"
 #include "nsSize.h"
 #include "mozilla/gfx/Rect.h"
 #include "nsRect.h"
 #include "nsIMemoryReporter.h"
 #include "SharedBuffer.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/Span.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "nsTArray.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/PodOperations.h"
 #include "TimeUnits.h"
 
 namespace mozilla {
@@ -657,16 +658,18 @@ public:
   size_t Size() const { return mBuffer.Length(); }
   size_t AlphaSize() const { return mAlphaBuffer.Length(); }
   size_t ComputedSizeOfIncludingThis() const
   {
     return sizeof(*this)
            + mBuffer.ComputedSizeOfExcludingThis()
            + mAlphaBuffer.ComputedSizeOfExcludingThis();
   }
+  // Access the buffer as a Span.
+  operator Span<const uint8_t>() { return MakeSpan(Data(), Size()); }
 
   const CryptoSample& mCrypto;
   RefPtr<MediaByteBuffer> mExtraData;
 
   // Used by the Vorbis decoder and Ogg demuxer.
   // Indicates that this is the last packet of the stream.
   bool mEOS = false;