Bug 1168674: [ogg] P8. Fix metadata retrieval. r=brion+1012
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 27 Jul 2016 12:22:31 +1000
changeset 307412 70cda19d2159974d13842a905b42ca5f973267ca
parent 307411 435bf9dd44f33169ca3111608b1d43aacdd92496
child 307413 39bc955ad2fa5b1a230270f8cbfdfb018fe43b59
push id30509
push usercbook@mozilla.com
push dateSun, 31 Jul 2016 15:40:21 +0000
treeherdermozilla-central@221b74c48363 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrion
bugs1168674
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1168674: [ogg] P8. Fix metadata retrieval. r=brion+1012 MozReview-Commit-ID: BMUNy4zyWMz
dom/media/ogg/OggDemuxer.cpp
dom/media/ogg/OggDemuxer.h
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -514,34 +514,48 @@ OggDemuxer::SetupMediaTracksInfo(const n
       if (msgInfo) {
         InitTrack(msgInfo,
                   &mInfo.mAudio,
                   mVorbisState == vorbisState);
       }
 
       mInfo.mAudio.mRate = vorbisState->mInfo.rate;
       mInfo.mAudio.mChannels = vorbisState->mInfo.channels;
+      FillTags(&mInfo.mAudio, vorbisState->GetTags());
     } else if (codecState->GetType() == OggCodecState::TYPE_OPUS) {
       OpusState* opusState = static_cast<OpusState*>(codecState);
       if (!(mOpusState && mOpusState->mSerial == opusState->mSerial)) {
         continue;
       }
 
       if (msgInfo) {
         InitTrack(msgInfo,
                   &mInfo.mAudio,
                   mOpusState == opusState);
       }
 
       mInfo.mAudio.mRate = opusState->mRate;
       mInfo.mAudio.mChannels = opusState->mChannels;
+      FillTags(&mInfo.mAudio, opusState->GetTags());
     }
   }
 }
 
+void
+OggDemuxer::FillTags(TrackInfo* aInfo, MetadataTags* aTags)
+{
+  if (!aTags) {
+    return;
+  }
+  nsAutoPtr<MetadataTags> tags(aTags);
+  for (auto iter = aTags->Iter(); !iter.Done(); iter.Next()) {
+    aInfo->mTags.AppendElement(MetadataTag(iter.Key(), iter.Data()));
+  }
+}
+
 nsresult
 OggDemuxer::ReadMetadata()
 {
   OGG_DEBUG("OggDemuxer::ReadMetadata called!");
 
   // We read packets until all bitstreams have read all their header packets.
   // We record the offset of the first non-header page so that we know
   // what page to seek to when seeking to the media start.
--- a/dom/media/ogg/OggDemuxer.h
+++ b/dom/media/ogg/OggDemuxer.h
@@ -208,16 +208,17 @@ private:
   void BuildSerialList(nsTArray<uint32_t>& aTracks);
 
   // Setup target bitstreams for decoding.
   void SetupTargetTheora(TheoraState* aTheoraState, OggHeaders& aHeaders);
   void SetupTargetVorbis(VorbisState* aVorbisState, OggHeaders& aHeaders);
   void SetupTargetOpus(OpusState* aOpusState, OggHeaders& aHeaders);
   void SetupTargetSkeleton();
   void SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials);
+  void FillTags(TrackInfo* aInfo, MetadataTags* aTags);
 
   // Compute an ogg page's checksum
   ogg_uint32_t GetPageChecksum(ogg_page* aPage);
 
   // Get the end time of aEndOffset. This is the playback position we'd reach
   // after playback finished at aEndOffset.
   int64_t RangeEndTime(int64_t aEndOffset);