Bug 1358662 - Add Span support to MediaRawData. r=jya
MozReview-Commit-ID: A3bHPlk0MQi
--- 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;