Bug 1208371 - Introduce MediaStreamTrack logs. r=roc,jib
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:21 +0800
changeset 292062 987bb0e75a341e0d0968520ee2c47cf06eda4395
parent 292061 aeffc7ef6fea01e6b6f99f665dc75864e4e00d6e
child 292063 e7e2b6a1275e97899c48f0e3154aac6788c060e0
push id30152
push userkwierso@gmail.com
push dateThu, 07 Apr 2016 20:42:20 +0000
treeherdermozilla-central@06678484909c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, jib
bugs1208371
milestone48.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 1208371 - Introduce MediaStreamTrack logs. r=roc,jib MozReview-Commit-ID: d1Fogpb6MO
dom/media/MediaStreamTrack.cpp
--- a/dom/media/MediaStreamTrack.cpp
+++ b/dom/media/MediaStreamTrack.cpp
@@ -4,23 +4,34 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaStreamTrack.h"
 
 #include "DOMMediaStream.h"
 #include "nsIUUIDGenerator.h"
 #include "nsServiceManagerUtils.h"
 
+#ifdef LOG
+#undef LOG
+#endif
+
+static PRLogModuleInfo* gMediaStreamTrackLog;
+#define LOG(type, msg) MOZ_LOG(gMediaStreamTrackLog, type, msg)
+
 namespace mozilla {
 namespace dom {
 
 MediaStreamTrack::MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID, const nsString& aLabel)
   : mOwningStream(aStream), mTrackID(aTrackID), mLabel(aLabel), mEnded(false), mEnabled(true)
 {
 
+  if (!gMediaStreamTrackLog) {
+    gMediaStreamTrackLog = PR_NewLogModule("MediaStreamTrack");
+  }
+
   nsresult rv;
   nsCOMPtr<nsIUUIDGenerator> uuidgen =
     do_GetService("@mozilla.org/uuid-generator;1", &rv);
 
   nsID uuid;
   memset(&uuid, 0, sizeof(uuid));
   if (uuidgen) {
     uuidgen->GenerateUUIDInPlace(&uuid);
@@ -47,27 +58,40 @@ void
 MediaStreamTrack::GetId(nsAString& aID) const
 {
   aID = mID;
 }
 
 void
 MediaStreamTrack::SetEnabled(bool aEnabled)
 {
+  LOG(LogLevel::Info, ("MediaStreamTrack %p %s",
+                       this, aEnabled ? "Enabled" : "Disabled"));
+
   mEnabled = aEnabled;
   mOwningStream->SetTrackEnabled(mTrackID, aEnabled);
 }
 
 void
 MediaStreamTrack::Stop()
 {
+  LOG(LogLevel::Info, ("MediaStreamTrack %p Stop()", this));
+
   mOwningStream->StopTrack(mTrackID);
 }
 
 already_AddRefed<Promise>
 MediaStreamTrack::ApplyConstraints(const MediaTrackConstraints& aConstraints,
                                    ErrorResult &aRv)
 {
+  if (MOZ_LOG_TEST(gMediaStreamTrackLog, LogLevel::Info)) {
+    nsString str;
+    aConstraints.ToJSON(str);
+
+    LOG(LogLevel::Info, ("MediaStreamTrack %p ApplyConstraints() with "
+                         "constraints %s", this, NS_ConvertUTF16toUTF8(str).get()));
+  }
+
   return GetStream()->ApplyConstraintsToTrack(mTrackID, aConstraints, aRv);
 }
 
 } // namespace dom
 } // namespace mozilla