summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrav90 <travawine@protonmail.ch>2017-05-09 01:43:00 -0500
committertrav90 <travawine@protonmail.ch>2017-05-09 01:43:00 -0500
commit53be86de7129bedb3f2bffb013efd0009c3e1a22 (patch)
treeba9b8e7d4571a65a412619c6cee3ef0c11594844
parent65cbb7cfe862f15765608d2c97e91e71d39e7d3f (diff)
downloadpalemoon-gre-53be86de7129bedb3f2bffb013efd0009c3e1a22.tar.gz
Add SharedTrackInfo object
-rw-r--r--dom/media/MediaData.cpp4
-rw-r--r--dom/media/MediaData.h3
-rw-r--r--dom/media/MediaInfo.h51
3 files changed, 55 insertions, 3 deletions
diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp
index 95fb2663d..ddcbd9efd 100644
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -518,6 +518,7 @@ MediaRawData::Clone() const
s->mKeyframe = mKeyframe;
s->mExtraData = mExtraData;
s->mCryptoInternal = mCryptoInternal;
+ s->mTrackInfo = mTrackInfo;
if (mSize) {
if (!s->EnsureCapacity(mSize)) {
return nullptr;
@@ -566,9 +567,6 @@ MediaRawData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t size = aMallocSizeOf(this);
- if (mExtraData) {
- size += aMallocSizeOf(mExtraData.get());
- }
size += aMallocSizeOf(mBuffer.get());
return size;
}
diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h
index 6eb1797e5..ccda8469a 100644
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -24,6 +24,7 @@ class ImageContainer;
class MediaLargeByteBuffer;
class MediaByteBuffer;
+class SharedTrackInfo;
// Container that holds media samples.
class MediaData {
@@ -383,6 +384,8 @@ public:
const CryptoSample& mCrypto;
nsRefPtr<MediaByteBuffer> mExtraData;
+ nsRefPtr<SharedTrackInfo> mTrackInfo;
+
// Return a deep copy or nullptr if out of memory.
virtual already_AddRefed<MediaRawData> Clone() const;
// Create a MediaRawDataWriter for this MediaRawData. The caller must
diff --git a/dom/media/MediaInfo.h b/dom/media/MediaInfo.h
index 2fc22f43a..d8fe7740e 100644
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -374,6 +374,57 @@ public:
EncryptionInfo mCrypto;
};
+class SharedTrackInfo {
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedTrackInfo)
+public:
+ SharedTrackInfo(const TrackInfo& aOriginal, uint32_t aStreamID)
+ : mInfo(aOriginal.Clone())
+ , mStreamSourceID(aStreamID)
+ , mMimeType(mInfo->mMimeType)
+ {
+ }
+
+ uint32_t GetID() const
+ {
+ return mStreamSourceID;
+ }
+
+ const TrackInfo* operator*() const
+ {
+ return mInfo.get();
+ }
+
+ const TrackInfo* operator->() const
+ {
+ MOZ_ASSERT(mInfo.get(), "dereferencing a UniquePtr containing nullptr");
+ return mInfo.get();
+ }
+
+ const AudioInfo* GetAsAudioInfo() const
+ {
+ return mInfo ? mInfo->GetAsAudioInfo() : nullptr;
+ }
+
+ const VideoInfo* GetAsVideoInfo() const
+ {
+ return mInfo ? mInfo->GetAsVideoInfo() : nullptr;
+ }
+
+ const TextInfo* GetAsTextInfo() const
+ {
+ return mInfo ? mInfo->GetAsTextInfo() : nullptr;
+ }
+
+private:
+ ~SharedTrackInfo() {};
+ UniquePtr<TrackInfo> mInfo;
+ // A unique ID, guaranteed to change when changing streams.
+ uint32_t mStreamSourceID;
+
+public:
+ const nsAutoCString& mMimeType;
+};
+
} // namespace mozilla
#endif // MediaInfo_h