diff options
author | trav90 <travawine@protonmail.ch> | 2017-05-09 01:43:00 -0500 |
---|---|---|
committer | trav90 <travawine@protonmail.ch> | 2017-05-09 01:43:00 -0500 |
commit | 53be86de7129bedb3f2bffb013efd0009c3e1a22 (patch) | |
tree | ba9b8e7d4571a65a412619c6cee3ef0c11594844 | |
parent | 65cbb7cfe862f15765608d2c97e91e71d39e7d3f (diff) | |
download | palemoon-gre-53be86de7129bedb3f2bffb013efd0009c3e1a22.tar.gz |
Add SharedTrackInfo object
-rw-r--r-- | dom/media/MediaData.cpp | 4 | ||||
-rw-r--r-- | dom/media/MediaData.h | 3 | ||||
-rw-r--r-- | dom/media/MediaInfo.h | 51 |
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 |