Bug 1423241 - Add logging for a captured MediaDecoder. r=jya
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 23 Nov 2018 15:03:21 +0000
changeset 507065 0e6607a8aaf61a549f669821dd74f084f9ff6854
parent 507064 3ec97b5fccd710460f860a8e4f0d43f251392c00
child 507066 3db9a18c3061815fd97a84d5389bae91cc8ef31a
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1423241
milestone65.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 1423241 - Add logging for a captured MediaDecoder. r=jya Differential Revision: https://phabricator.services.mozilla.com/D12286
dom/media/MediaDecoderStateMachine.cpp
dom/media/mediasink/OutputStreamManager.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3767,30 +3767,33 @@ void MediaDecoderStateMachine::RemoveOut
 }
 
 void MediaDecoderStateMachine::EnsureOutputStreamManager(
     MediaStreamGraph* aGraph, const Maybe<MediaInfo>& aLoadedInfo) {
   MOZ_ASSERT(NS_IsMainThread());
   if (mOutputStreamManager) {
     return;
   }
+  LOG("Starting output track allocations at id %d", mNextOutputStreamTrackID);
   mOutputStreamManager = new OutputStreamManager(
       aGraph->CreateSourceStream(), mNextOutputStreamTrackID,
       mOutputStreamPrincipal, mOutputStreamCORSMode, mAbstractMainThread);
   if (!aLoadedInfo) {
     return;
   }
   TrackID mirroredTrackIDAllocation = mNextOutputStreamTrackID;
   if (aLoadedInfo->HasAudio()) {
     mOutputStreamManager->AddTrack(mirroredTrackIDAllocation++,
                                    MediaSegment::AUDIO);
+    LOG("Pre-created audio track with id %d", mirroredTrackIDAllocation - 1);
   }
   if (aLoadedInfo->HasVideo()) {
     mOutputStreamManager->AddTrack(mirroredTrackIDAllocation++,
                                    MediaSegment::VIDEO);
+    LOG("Pre-created video track with id %d", mirroredTrackIDAllocation - 1);
   }
 }
 
 void MediaDecoderStateMachine::SetNextOutputStreamTrackID(
     TrackID aNextTrackID) {
   MOZ_ASSERT(NS_IsMainThread());
   LOG("SetNextOutputStreamTrackID aNextTrackID=%d", aNextTrackID);
   mNextOutputStreamTrackID = aNextTrackID;
--- a/dom/media/mediasink/OutputStreamManager.cpp
+++ b/dom/media/mediasink/OutputStreamManager.cpp
@@ -8,16 +8,19 @@
 
 #include "DOMMediaStream.h"
 #include "MediaStreamGraph.h"
 #include "mozilla/dom/MediaStreamTrack.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 
+#define LOG(level, msg, ...) \
+  MOZ_LOG(gMediaDecoderLog, level, (msg, ##__VA_ARGS__))
+
 class DecodedStreamTrackSource : public dom::MediaStreamTrackSource {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DecodedStreamTrackSource,
                                            dom::MediaStreamTrackSource)
 
   explicit DecodedStreamTrackSource(OutputStreamManager* aManager,
                                     OutputStreamData* aData, TrackID aTrackID,
@@ -97,16 +100,20 @@ OutputStreamData::~OutputStreamData() {
   }
 }
 
 void OutputStreamData::AddTrack(TrackID aTrackID, MediaSegment::Type aType,
                                 nsIPrincipal* aPrincipal, CORSMode aCORSMode,
                                 bool aAsyncAddTrack) {
   MOZ_ASSERT(NS_IsMainThread());
 
+  LOG(LogLevel::Debug, "Adding output %s track with id %d to MediaStream %p%s",
+      aType == MediaSegment::AUDIO ? "audio" : "video", aTrackID,
+      mDOMStream.get(), aAsyncAddTrack ? " (async)" : "");
+
   RefPtr<dom::MediaStreamTrackSource> source = new DecodedStreamTrackSource(
       mManager, this, aTrackID, aPrincipal, aCORSMode, mAbstractMainThread);
   RefPtr<dom::MediaStreamTrack> track =
       mDOMStream->CreateDOMTrack(aTrackID, aType, source);
   mTracks.AppendElement(track);
   if (aAsyncAddTrack) {
     GetMainThreadEventTarget()->Dispatch(
         NewRunnableMethod<RefPtr<dom::MediaStreamTrack>>(
@@ -115,16 +122,19 @@ void OutputStreamData::AddTrack(TrackID 
   } else {
     mDOMStream->AddTrackInternal(track);
   }
 }
 
 void OutputStreamData::RemoveTrack(TrackID aTrackID) {
   MOZ_ASSERT(NS_IsMainThread());
 
+  LOG(LogLevel::Debug, "Removing output track with id %d from MediaStream %p",
+      aTrackID, mDOMStream.get());
+
   RefPtr<dom::MediaStreamTrack> track =
       mDOMStream->FindOwnedDOMTrack(mInputStream, aTrackID);
   MOZ_DIAGNOSTIC_ASSERT(track);
   mTracks.RemoveElement(track);
   GetMainThreadEventTarget()->Dispatch(
       NewRunnableMethod("MediaStreamTrack::OverrideEnded", track,
                         &dom::MediaStreamTrack::OverrideEnded));
 }
@@ -157,29 +167,33 @@ OutputStreamManager::OutputStreamManager
 }
 
 void OutputStreamManager::Add(DOMMediaStream* aDOMStream) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mSourceStream->IsDestroyed());
   // All streams must belong to the same graph.
   MOZ_ASSERT(mSourceStream->Graph() == aDOMStream->GetInputStream()->Graph());
 
+  LOG(LogLevel::Info, "Adding MediaStream %p", aDOMStream);
+
   OutputStreamData* p = mStreams
                             .AppendElement(new OutputStreamData(
                                 this, mAbstractMainThread, aDOMStream))
                             ->get();
   for (const Pair<TrackID, MediaSegment::Type>& pair : mLiveTracks) {
     p->AddTrack(pair.first(), pair.second(), mPrincipal, mCORSMode, false);
   }
 }
 
 void OutputStreamManager::Remove(DOMMediaStream* aDOMStream) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mSourceStream->IsDestroyed());
 
+  LOG(LogLevel::Info, "Removing MediaStream %p", aDOMStream);
+
   mStreams.ApplyIf(
       aDOMStream, 0, StreamComparator(),
       [&](const UniquePtr<OutputStreamData>& aData) {
         for (const Pair<TrackID, MediaSegment::Type>& pair : mLiveTracks) {
           aData->RemoveTrack(pair.first());
         }
       },
       []() { MOZ_ASSERT_UNREACHABLE("Didn't exist"); });
@@ -219,25 +233,29 @@ size_t OutputStreamManager::NumberOfTrac
   return mLiveTracks.Length();
 }
 
 void OutputStreamManager::AddTrack(TrackID aTrackID, MediaSegment::Type aType) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mSourceStream->IsDestroyed());
   MOZ_ASSERT(!HasTrack(aTrackID));
 
+  LOG(LogLevel::Info, "Adding %s track with id %d",
+      aType == MediaSegment::AUDIO ? "audio" : "video", aTrackID);
+
   mLiveTracks.AppendElement(MakePair(aTrackID, aType));
   for (const auto& data : mStreams) {
     data->AddTrack(aTrackID, aType, mPrincipal, mCORSMode, true);
   }
 }
 
 void OutputStreamManager::RemoveTrack(TrackID aTrackID) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mSourceStream->IsDestroyed());
+  LOG(LogLevel::Info, "Removing track with id %d", aTrackID);
   DebugOnly<bool> rv = mLiveTracks.RemoveElement(aTrackID, TrackIDComparator());
   MOZ_ASSERT(rv);
   for (const auto& data : mStreams) {
     data->RemoveTrack(aTrackID);
   }
 }
 
 void OutputStreamManager::RemoveTracks() {
@@ -308,9 +326,11 @@ void OutputStreamManager::SetPlaying(boo
   mPlaying = aPlaying;
   if (mPlaying) {
     mSourceStream->Resume();
   } else {
     mSourceStream->Suspend();
   }
 }
 
+#undef LOG
+
 }  // namespace mozilla