Add media stream release logging
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Mar 2019 05:21:43 +0000 (05:21 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Mar 2019 05:21:43 +0000 (05:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195823
Source/WebCore:

<rdar://problem/48939406>

Reviewed by Youenn Fablet.

No new tests, no behavioral change.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::MediaStream):
(WebCore::MediaStream::clone):
(WebCore::MediaStream::addTrack):
(WebCore::MediaStream::removeTrack):
(WebCore::MediaStream::addTrackFromPlatform):
(WebCore::MediaStream::setIsActive):
(WebCore::MediaStream::mediaCanStart):
(WebCore::MediaStream::startProducingData):
(WebCore::MediaStream::stopProducingData):
(WebCore::MediaStream::endCaptureTracks):
(WebCore::MediaStream::stop):
(WebCore::MediaStream::logChannel const):
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack):
(WebCore::MediaStreamTrack::logChannel const):
* Modules/mediastream/MediaStreamTrack.h:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addTrack):
(WebCore::LibWebRTCMediaEndpoint::sourceFromNewReceiver):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::AudioContext):
(WebCore::nextLogIdentifier): Deleted.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::nextLogIdentifier): Deleted.
* html/HTMLMediaElement.h:
* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::PlatformMediaSession):
(WebCore::nextLogIdentifier): Deleted.
* platform/audio/PlatformMediaSession.h:
* platform/graphics/IntSize.cpp:
(WebCore::IntSize::toJSONObject const):
(WebCore::IntSize::toJSONString const):
* platform/graphics/IntSize.h:
(WTF::LogArgument<WebCore::IntSize>::toString):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::addTrack):
(WebCore::MediaStreamPrivate::removeTrack):
(WebCore::MediaStreamPrivate::startProducingData):
(WebCore::MediaStreamPrivate::stopProducingData):
(WebCore::MediaStreamPrivate::setCaptureTracksMuted):
(WebCore::MediaStreamPrivate::trackMutedChanged):
(WebCore::MediaStreamPrivate::trackEnabledChanged):
(WebCore::MediaStreamPrivate::trackStarted):
(WebCore::MediaStreamPrivate::trackEnded):
(WebCore::MediaStreamPrivate::setLogger):
(WebCore::MediaStreamPrivate::logChannel const):
* platform/mediastream/MediaStreamPrivate.h:
* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::setLogger):
(WebCore::MediaStreamTrackPrivate::logChannel const):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeIncomingAudioSource.cpp:
(WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource):
(WebCore::RealtimeIncomingAudioSource::logChannel const): Deleted.
(WebCore::RealtimeIncomingAudioSource::logger const): Deleted.
* platform/mediastream/RealtimeIncomingAudioSource.h:
(WebCore::RealtimeIncomingAudioSource::setLogger): Deleted.
* platform/mediastream/RealtimeIncomingVideoSource.cpp:
(WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource):
(WebCore::RealtimeIncomingVideoSource::logChannel const): Deleted.
(WebCore::RealtimeIncomingVideoSource::logger const): Deleted.
* platform/mediastream/RealtimeIncomingVideoSource.h:
(WebCore::RealtimeIncomingVideoSource::setLogger): Deleted.
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::RealtimeMediaSource):
(WebCore::RealtimeMediaSource::setInterrupted):
(WebCore::RealtimeMediaSource::setMuted):
(WebCore::RealtimeMediaSource::notifyMutedChange):
(WebCore::RealtimeMediaSource::notifySettingsDidChangeObservers):
(WebCore::RealtimeMediaSource::videoSampleAvailable):
(WebCore::RealtimeMediaSource::start):
(WebCore::RealtimeMediaSource::stop):
(WebCore::RealtimeMediaSource::captureFailed):
(WebCore::RealtimeMediaSource::applyConstraint):
(WebCore::RealtimeMediaSource::supportsConstraints):
(WebCore::RealtimeMediaSource::applyConstraints):
(WebCore::RealtimeMediaSource::setSize):
(WebCore::RealtimeMediaSource::setIntrinsicSize):
(WebCore::RealtimeMediaSource::setFrameRate):
(WebCore::RealtimeMediaSource::setAspectRatio):
(WebCore::RealtimeMediaSource::setFacingMode):
(WebCore::RealtimeMediaSource::setVolume):
(WebCore::RealtimeMediaSource::setSampleRate):
(WebCore::RealtimeMediaSource::setSampleSize):
(WebCore::RealtimeMediaSource::setEchoCancellation):
(WebCore::RealtimeMediaSource::setLogger):
(WebCore::RealtimeMediaSource::logChannel const):
(WebCore::convertEnumerationToString):
* platform/mediastream/RealtimeMediaSource.h:
(WTF::LogArgument<WebCore::RealtimeMediaSource::Type>::toString):
* platform/mediastream/RealtimeMediaSourceSettings.cpp:
(WebCore::RealtimeMediaSourceSettings::convertFlagsToString):
(WebCore::convertEnumerationToString):
* platform/mediastream/RealtimeMediaSourceSettings.h:
(WTF::LogArgument<WebCore::RealtimeMediaSourceSettings::VideoFacingMode>::toString):
(WTF::LogArgument<OptionSet<WebCore::RealtimeMediaSourceSettings::Flag>>::toString):
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
(WebCore::RealtimeOutgoingAudioSource::logChannel const):
(WebCore::RealtimeOutgoingAudioSource::logger const): Deleted.
* platform/mediastream/RealtimeOutgoingAudioSource.h:
(WebCore::RealtimeOutgoingAudioSource::setLogger): Deleted.
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
(WebCore::RealtimeOutgoingVideoSource::sendOneBlackFrame):
(WebCore::RealtimeOutgoingVideoSource::sendFrame):
(WebCore::RealtimeOutgoingVideoSource::logChannel const):
(WebCore::RealtimeOutgoingVideoSource::logger const): Deleted.
* platform/mediastream/RealtimeOutgoingVideoSource.h:
(WebCore::RealtimeOutgoingVideoSource::setLogger): Deleted.
* platform/mediastream/RealtimeVideoSource.cpp:
(WebCore::RealtimeVideoSource::setSizeAndFrameRate):
(WebCore::SizeAndFrameRate::toJSONObject const):
(WebCore::SizeAndFrameRate::toJSONString const):
* platform/mediastream/RealtimeVideoSource.h:
(WTF::LogArgument<WebCore::SizeAndFrameRate>::toString):
* platform/mediastream/mac/AVVideoCaptureSource.h:
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::clearSession):
(WebCore::AVVideoCaptureSource::startProducingData):
(WebCore::AVVideoCaptureSource::stopProducingData):
(WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset):
(WebCore::AVVideoCaptureSource::setupSession):
(WebCore::AVVideoCaptureSource::frameDurationForFrameRate):
(WebCore::AVVideoCaptureSource::setupCaptureSession):
(WebCore::AVVideoCaptureSource::captureSessionIsRunningDidChange):
(WebCore::AVVideoCaptureSource::captureDeviceSuspendedDidChange):
(WebCore::AVVideoCaptureSource::captureSessionRuntimeError):
(WebCore::AVVideoCaptureSource::captureSessionBeginInterruption):
(WebCore::AVVideoCaptureSource::captureSessionEndInterruption):
(WebCore::AVVideoCaptureSource::deviceDisconnected):
(-[WebCoreAVVideoCaptureSourceObserver observeValueForKeyPath:ofObject:change:context:]):
(-[WebCoreAVVideoCaptureSourceObserver deviceConnectedDidChange:]):
(-[WebCoreAVVideoCaptureSourceObserver sessionRuntimeError:]):
(-[WebCoreAVVideoCaptureSourceObserver beginSessionInterrupted:]):
(-[WebCoreAVVideoCaptureSourceObserver endSessionInterrupted:]):
(WebCore::AVVideoCaptureSource::initializeSession): Deleted.
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioSharedUnit::setupAudioUnit):
(WebCore::CoreAudioSharedUnit::verifyIsCapturing):
(WebCore::CoreAudioSharedUnit::captureFailed):
(WebCore::CoreAudioCaptureSource::initializeToStartProducingData):
(WebCore::CoreAudioCaptureSource::addEchoCancellationSource):
(WebCore::CoreAudioCaptureSource::removeEchoCancellationSource):
(WebCore::CoreAudioCaptureSource::startProducingData):
(WebCore::CoreAudioCaptureSource::stopProducingData):
(WebCore::CoreAudioCaptureSource::scheduleReconfiguration):
(WebCore::CoreAudioCaptureSource::beginInterruption):
(WebCore::CoreAudioCaptureSource::endInterruption):
* platform/mediastream/mac/CoreAudioCaptureSource.h:
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream):
(WebCore::ScreenDisplayCaptureSourceMac::startProducingData):
(WebCore::ScreenDisplayCaptureSourceMac::stopProducingData):
(WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream):

Source/WTF:

Reviewed by Youenn Fablet.

* wtf/LoggerHelper.h: Add LOG_IF variants that check a condition before logging.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

40 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/LoggerHelper.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/audio/PlatformMediaSession.cpp
Source/WebCore/platform/audio/PlatformMediaSession.h
Source/WebCore/platform/graphics/IntSize.cpp
Source/WebCore/platform/graphics/IntSize.h
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h
Source/WebCore/platform/mediastream/RealtimeIncomingAudioSource.cpp
Source/WebCore/platform/mediastream/RealtimeIncomingAudioSource.h
Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h
Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeVideoSource.h
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm

index 73ee642..b1eafa2 100644 (file)
@@ -1,3 +1,12 @@
+2019-03-15  Eric Carlson  <eric.carlson@apple.com>
+
+        Add media stream release logging
+        https://bugs.webkit.org/show_bug.cgi?id=195823
+
+        Reviewed by Youenn Fablet.
+
+        * wtf/LoggerHelper.h: Add LOG_IF variants that check a condition before logging.
+
 2019-03-15  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r243008.
index e826474..d03afe6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <wtf/CryptographicallyRandomNumber.h>
 #include <wtf/Logger.h>
 
 namespace WTF {
@@ -45,17 +46,28 @@ public:
 #define ALWAYS_LOG(...)     logger().logAlways(logChannel(), __VA_ARGS__)
 #define ERROR_LOG(...)      logger().error(logChannel(), __VA_ARGS__)
 #define WARNING_LOG(...)    logger().warning(logChannel(), __VA_ARGS__)
-#define NOTICE_LOG(...)     logger().notice(logChannel(), __VA_ARGS__)
 #define INFO_LOG(...)       logger().info(logChannel(), __VA_ARGS__)
 #define DEBUG_LOG(...)      logger().debug(logChannel(), __VA_ARGS__)
 #define WILL_LOG(_level_)   logger().willLog(logChannel(), _level_)
 
+#define ALWAYS_LOG_IF(condition, ...)     if (condition) logger().logAlways(logChannel(), __VA_ARGS__)
+#define ERROR_LOG_IF(condition, ...)      if (condition) logger().error(logChannel(), __VA_ARGS__)
+#define WARNING_LOG_IF(condition, ...)    if (condition) logger().warning(logChannel(), __VA_ARGS__)
+#define INFO_LOG_IF(condition, ...)       if (condition) logger().info(logChannel(), __VA_ARGS__)
+#define DEBUG_LOG_IF(condition, ...)      if (condition) logger().debug(logChannel(), __VA_ARGS__)
+
     const void* childLogIdentifier(uint64_t identifier) const
     {
         static const int64_t parentMask = 0xffffffffffff0000l;
         static const int64_t maskLowerWord = 0xffffl;
         return reinterpret_cast<const void*>((reinterpret_cast<uint64_t>(logIdentifier()) & parentMask) | (identifier & maskLowerWord));
     }
+
+    static const void* uniqueLogIdentifier()
+    {
+        static uint64_t logIdentifier = cryptographicallyRandomNumber();
+        return reinterpret_cast<const void*>(++logIdentifier);
+    }
 #else
 
 #define LOGIDENTIFIER (WTF::nullopt)
index d0c87cf..d725095 100644 (file)
@@ -1,3 +1,173 @@
+2019-03-15  Eric Carlson  <eric.carlson@apple.com>
+
+        Add media stream release logging
+        https://bugs.webkit.org/show_bug.cgi?id=195823
+        <rdar://problem/48939406>
+
+        Reviewed by Youenn Fablet.
+
+        No new tests, no behavioral change.
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::MediaStream):
+        (WebCore::MediaStream::clone):
+        (WebCore::MediaStream::addTrack):
+        (WebCore::MediaStream::removeTrack):
+        (WebCore::MediaStream::addTrackFromPlatform):
+        (WebCore::MediaStream::setIsActive):
+        (WebCore::MediaStream::mediaCanStart):
+        (WebCore::MediaStream::startProducingData):
+        (WebCore::MediaStream::stopProducingData):
+        (WebCore::MediaStream::endCaptureTracks):
+        (WebCore::MediaStream::stop):
+        (WebCore::MediaStream::logChannel const):
+        * Modules/mediastream/MediaStream.h:
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::MediaStreamTrack):
+        (WebCore::MediaStreamTrack::logChannel const):
+        * Modules/mediastream/MediaStreamTrack.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::addTrack):
+        (WebCore::LibWebRTCMediaEndpoint::sourceFromNewReceiver):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::AudioContext):
+        (WebCore::nextLogIdentifier): Deleted.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::nextLogIdentifier): Deleted.
+        * html/HTMLMediaElement.h:
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::PlatformMediaSession::PlatformMediaSession):
+        (WebCore::nextLogIdentifier): Deleted.
+        * platform/audio/PlatformMediaSession.h:
+        * platform/graphics/IntSize.cpp:
+        (WebCore::IntSize::toJSONObject const):
+        (WebCore::IntSize::toJSONString const):
+        * platform/graphics/IntSize.h:
+        (WTF::LogArgument<WebCore::IntSize>::toString):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::addTrack):
+        (WebCore::MediaStreamPrivate::removeTrack):
+        (WebCore::MediaStreamPrivate::startProducingData):
+        (WebCore::MediaStreamPrivate::stopProducingData):
+        (WebCore::MediaStreamPrivate::setCaptureTracksMuted):
+        (WebCore::MediaStreamPrivate::trackMutedChanged):
+        (WebCore::MediaStreamPrivate::trackEnabledChanged):
+        (WebCore::MediaStreamPrivate::trackStarted):
+        (WebCore::MediaStreamPrivate::trackEnded):
+        (WebCore::MediaStreamPrivate::setLogger):
+        (WebCore::MediaStreamPrivate::logChannel const):
+        * platform/mediastream/MediaStreamPrivate.h:
+        * platform/mediastream/MediaStreamTrackPrivate.cpp:
+        (WebCore::MediaStreamTrackPrivate::setLogger):
+        (WebCore::MediaStreamTrackPrivate::logChannel const):
+        * platform/mediastream/MediaStreamTrackPrivate.h:
+        * platform/mediastream/RealtimeIncomingAudioSource.cpp:
+        (WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource):
+        (WebCore::RealtimeIncomingAudioSource::logChannel const): Deleted.
+        (WebCore::RealtimeIncomingAudioSource::logger const): Deleted.
+        * platform/mediastream/RealtimeIncomingAudioSource.h:
+        (WebCore::RealtimeIncomingAudioSource::setLogger): Deleted.
+        * platform/mediastream/RealtimeIncomingVideoSource.cpp:
+        (WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource):
+        (WebCore::RealtimeIncomingVideoSource::logChannel const): Deleted.
+        (WebCore::RealtimeIncomingVideoSource::logger const): Deleted.
+        * platform/mediastream/RealtimeIncomingVideoSource.h:
+        (WebCore::RealtimeIncomingVideoSource::setLogger): Deleted.
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::RealtimeMediaSource):
+        (WebCore::RealtimeMediaSource::setInterrupted):
+        (WebCore::RealtimeMediaSource::setMuted):
+        (WebCore::RealtimeMediaSource::notifyMutedChange):
+        (WebCore::RealtimeMediaSource::notifySettingsDidChangeObservers):
+        (WebCore::RealtimeMediaSource::videoSampleAvailable):
+        (WebCore::RealtimeMediaSource::start):
+        (WebCore::RealtimeMediaSource::stop):
+        (WebCore::RealtimeMediaSource::captureFailed):
+        (WebCore::RealtimeMediaSource::applyConstraint):
+        (WebCore::RealtimeMediaSource::supportsConstraints):
+        (WebCore::RealtimeMediaSource::applyConstraints):
+        (WebCore::RealtimeMediaSource::setSize):
+        (WebCore::RealtimeMediaSource::setIntrinsicSize):
+        (WebCore::RealtimeMediaSource::setFrameRate):
+        (WebCore::RealtimeMediaSource::setAspectRatio):
+        (WebCore::RealtimeMediaSource::setFacingMode):
+        (WebCore::RealtimeMediaSource::setVolume):
+        (WebCore::RealtimeMediaSource::setSampleRate):
+        (WebCore::RealtimeMediaSource::setSampleSize):
+        (WebCore::RealtimeMediaSource::setEchoCancellation):
+        (WebCore::RealtimeMediaSource::setLogger):
+        (WebCore::RealtimeMediaSource::logChannel const):
+        (WebCore::convertEnumerationToString):
+        * platform/mediastream/RealtimeMediaSource.h:
+        (WTF::LogArgument<WebCore::RealtimeMediaSource::Type>::toString):
+        * platform/mediastream/RealtimeMediaSourceSettings.cpp:
+        (WebCore::RealtimeMediaSourceSettings::convertFlagsToString):
+        (WebCore::convertEnumerationToString):
+        * platform/mediastream/RealtimeMediaSourceSettings.h:
+        (WTF::LogArgument<WebCore::RealtimeMediaSourceSettings::VideoFacingMode>::toString):
+        (WTF::LogArgument<OptionSet<WebCore::RealtimeMediaSourceSettings::Flag>>::toString):
+        * platform/mediastream/RealtimeOutgoingAudioSource.cpp:
+        (WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
+        (WebCore::RealtimeOutgoingAudioSource::logChannel const):
+        (WebCore::RealtimeOutgoingAudioSource::logger const): Deleted.
+        * platform/mediastream/RealtimeOutgoingAudioSource.h:
+        (WebCore::RealtimeOutgoingAudioSource::setLogger): Deleted.
+        * platform/mediastream/RealtimeOutgoingVideoSource.cpp:
+        (WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
+        (WebCore::RealtimeOutgoingVideoSource::sendOneBlackFrame):
+        (WebCore::RealtimeOutgoingVideoSource::sendFrame):
+        (WebCore::RealtimeOutgoingVideoSource::logChannel const):
+        (WebCore::RealtimeOutgoingVideoSource::logger const): Deleted.
+        * platform/mediastream/RealtimeOutgoingVideoSource.h:
+        (WebCore::RealtimeOutgoingVideoSource::setLogger): Deleted.
+        * platform/mediastream/RealtimeVideoSource.cpp:
+        (WebCore::RealtimeVideoSource::setSizeAndFrameRate):
+        (WebCore::SizeAndFrameRate::toJSONObject const):
+        (WebCore::SizeAndFrameRate::toJSONString const):
+        * platform/mediastream/RealtimeVideoSource.h:
+        (WTF::LogArgument<WebCore::SizeAndFrameRate>::toString):
+        * platform/mediastream/mac/AVVideoCaptureSource.h:
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::clearSession):
+        (WebCore::AVVideoCaptureSource::startProducingData):
+        (WebCore::AVVideoCaptureSource::stopProducingData):
+        (WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset):
+        (WebCore::AVVideoCaptureSource::setupSession):
+        (WebCore::AVVideoCaptureSource::frameDurationForFrameRate):
+        (WebCore::AVVideoCaptureSource::setupCaptureSession):
+        (WebCore::AVVideoCaptureSource::captureSessionIsRunningDidChange):
+        (WebCore::AVVideoCaptureSource::captureDeviceSuspendedDidChange):
+        (WebCore::AVVideoCaptureSource::captureSessionRuntimeError):
+        (WebCore::AVVideoCaptureSource::captureSessionBeginInterruption):
+        (WebCore::AVVideoCaptureSource::captureSessionEndInterruption):
+        (WebCore::AVVideoCaptureSource::deviceDisconnected):
+        (-[WebCoreAVVideoCaptureSourceObserver observeValueForKeyPath:ofObject:change:context:]):
+        (-[WebCoreAVVideoCaptureSourceObserver deviceConnectedDidChange:]):
+        (-[WebCoreAVVideoCaptureSourceObserver sessionRuntimeError:]):
+        (-[WebCoreAVVideoCaptureSourceObserver beginSessionInterrupted:]):
+        (-[WebCoreAVVideoCaptureSourceObserver endSessionInterrupted:]):
+        (WebCore::AVVideoCaptureSource::initializeSession): Deleted.
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioSharedUnit::setupAudioUnit):
+        (WebCore::CoreAudioSharedUnit::verifyIsCapturing):
+        (WebCore::CoreAudioSharedUnit::captureFailed):
+        (WebCore::CoreAudioCaptureSource::initializeToStartProducingData):
+        (WebCore::CoreAudioCaptureSource::addEchoCancellationSource):
+        (WebCore::CoreAudioCaptureSource::removeEchoCancellationSource):
+        (WebCore::CoreAudioCaptureSource::startProducingData):
+        (WebCore::CoreAudioCaptureSource::stopProducingData):
+        (WebCore::CoreAudioCaptureSource::scheduleReconfiguration):
+        (WebCore::CoreAudioCaptureSource::beginInterruption):
+        (WebCore::CoreAudioCaptureSource::endInterruption):
+        * platform/mediastream/mac/CoreAudioCaptureSource.h:
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
+        (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream):
+        (WebCore::ScreenDisplayCaptureSourceMac::startProducingData):
+        (WebCore::ScreenDisplayCaptureSourceMac::stopProducingData):
+        (WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream):
+
 2019-03-15  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: remove agent as observer when disabling
index 18f2587..3de834c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011, 2012, 2015 Ericsson AB. All rights reserved.
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
@@ -78,10 +78,19 @@ MediaStream::MediaStream(ScriptExecutionContext& context, const MediaStreamTrack
     : ActiveDOMObject(&context)
     , m_private(MediaStreamPrivate::create(createTrackPrivateVector(tracks)))
     , m_mediaSession(PlatformMediaSession::create(*this))
+#if !RELEASE_LOG_DISABLED
+    , m_logger(document()->logger())
+    , m_logIdentifier(uniqueLogIdentifier())
+#endif
 {
     // This constructor preserves MediaStreamTrack instances and must be used by calls originating
     // from the JavaScript MediaStream constructor.
 
+#if !RELEASE_LOG_DISABLED
+    ALWAYS_LOG(LOGIDENTIFIER);
+    m_private->setLogger(logger(), logIdentifier());
+#endif
+
     for (auto& track : tracks) {
         track->addObserver(*this);
         m_trackSet.add(track->id(), track);
@@ -97,7 +106,15 @@ MediaStream::MediaStream(ScriptExecutionContext& context, Ref<MediaStreamPrivate
     : ActiveDOMObject(&context)
     , m_private(WTFMove(streamPrivate))
     , m_mediaSession(PlatformMediaSession::create(*this))
-{
+#if !RELEASE_LOG_DISABLED
+    , m_logger(document()->logger())
+    , m_logIdentifier(uniqueLogIdentifier())
+#endif
+{
+#if !RELEASE_LOG_DISABLED
+    ALWAYS_LOG(LOGIDENTIFIER);
+    m_private->setLogger(logger(), logIdentifier());
+#endif
     setIsActive(m_private->active());
     if (document()->page() && document()->page()->isMediaCaptureMuted())
         m_private->setCaptureTracksMuted(true);
@@ -129,6 +146,8 @@ MediaStream::~MediaStream()
 
 RefPtr<MediaStream> MediaStream::clone()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     MediaStreamTrackVector clonedTracks;
     clonedTracks.reserveInitialCapacity(m_trackSet.size());
 
@@ -140,6 +159,8 @@ RefPtr<MediaStream> MediaStream::clone()
 
 void MediaStream::addTrack(MediaStreamTrack& track)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier());
+
     if (!internalAddTrack(track, StreamModifier::DomAPI))
         return;
 
@@ -149,6 +170,8 @@ void MediaStream::addTrack(MediaStreamTrack& track)
 
 void MediaStream::removeTrack(MediaStreamTrack& track)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier());
+
     if (!internalRemoveTrack(track.id(), StreamModifier::DomAPI))
         return;
 
@@ -207,6 +230,8 @@ void MediaStream::didRemoveTrack(MediaStreamTrackPrivate& trackPrivate)
 
 void MediaStream::addTrackFromPlatform(Ref<MediaStreamTrack>&& track)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, track->logIdentifier());
+
     auto* privateTrack = &track->privateTrack();
     internalAddTrack(WTFMove(track), StreamModifier::Platform);
     m_private->addTrack(privateTrack, MediaStreamPrivate::NotifyClientOption::Notify);
@@ -255,12 +280,16 @@ void MediaStream::setIsActive(bool active)
     if (m_isActive == active)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, active);
+
     m_isActive = active;
     statusDidChange();
 }
 
 void MediaStream::mediaCanStart(Document& document)
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     ASSERT_UNUSED(document, &document == this->document());
     ASSERT(m_isWaitingUntilMediaCanStart);
     if (m_isWaitingUntilMediaCanStart) {
@@ -275,9 +304,11 @@ void MediaStream::startProducingData()
     if (!document || !document->page())
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     // If we can't start a load right away, start it later.
     if (!document->page()->canStartMedia()) {
-        LOG(Media, "MediaStream::startProducingData(%p) - not allowed to start in background, waiting", this);
+        ALWAYS_LOG(LOGIDENTIFIER, "not allowed to start in background, waiting");
         if (m_isWaitingUntilMediaCanStart)
             return;
 
@@ -301,6 +332,9 @@ void MediaStream::stopProducingData()
 {
     if (!m_isProducingData)
         return;
+
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     m_isProducingData = false;
 
     m_mediaSession->canProduceAudioChanged();
@@ -310,6 +344,8 @@ void MediaStream::stopProducingData()
 
 void MediaStream::endCaptureTracks()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     for (auto& track : m_trackSet.values()) {
         if (track->isCaptureTrack())
             track->stopTrack(MediaStreamTrack::StopMode::PostEvent);
@@ -482,6 +518,13 @@ bool MediaStream::hasPendingActivity() const
     return m_isActive;
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& MediaStream::logChannel() const
+{
+    return LogWebRTC;
+}
+#endif
+    
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 1c1ae11..c0553ae 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011, 2015 Ericsson AB. All rights reserved.
- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
 #include "Timer.h"
 #include "URLRegistry.h"
 #include <wtf/HashMap.h>
+#include <wtf/LoggerHelper.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
@@ -55,6 +56,9 @@ class MediaStream final
     , public MediaStreamPrivate::Observer
     , private MediaCanStartListener
     , private PlatformMediaSessionClient
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
     , public RefCounted<MediaStream> {
 public:
     class Observer {
@@ -119,6 +123,13 @@ protected:
     MediaStream(ScriptExecutionContext&, const MediaStreamTrackVector&);
     MediaStream(ScriptExecutionContext&, Ref<MediaStreamPrivate>&&);
 
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final { return m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    WTFLogChannel& logChannel() const final;
+    const char* logClassName() const final { return "MediaStream"; }
+#endif
+
 private:
 
     // EventTarget
@@ -175,6 +186,11 @@ private:
 
     MediaProducer::MediaStateFlags m_state { MediaProducer::IsNotPlaying };
 
+#if !RELEASE_LOG_DISABLED
+    Ref<Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
+
     bool m_isActive { false };
     bool m_isProducingData { false };
     bool m_isWaitingUntilMediaCanStart { false };
index 9ca7725..dbb547e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011, 2015 Ericsson AB. All rights reserved.
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
@@ -54,10 +54,18 @@ Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context,
 MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
     : ActiveDOMObject(&context)
     , m_private(WTFMove(privateTrack))
+#if !RELEASE_LOG_DISABLED
+    , m_logger(document()->logger())
+    , m_logIdentifier(uniqueLogIdentifier())
+#endif
     , m_taskQueue(context)
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     suspendIfNeeded();
 
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
     m_private->addObserver(*this);
 
     if (auto document = this->document())
@@ -489,6 +497,13 @@ Document* MediaStreamTrack::document() const
     return downcast<Document>(scriptExecutionContext());
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& MediaStreamTrack::logChannel() const
+{
+    return LogWebRTC;
+}
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 4982cb0..37bff72 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011, 2015 Ericsson AB. All rights reserved.
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@
 #include "MediaProducer.h"
 #include "MediaStreamTrackPrivate.h"
 #include "MediaTrackConstraints.h"
+#include <wtf/LoggerHelper.h>
 
 namespace WebCore {
 
@@ -46,13 +47,17 @@ class Document;
 
 struct MediaTrackConstraints;
 
-class MediaStreamTrack :
-    public RefCounted<MediaStreamTrack>,
-    public ActiveDOMObject,
-    public EventTargetWithInlineData,
-    public CanMakeWeakPtr<MediaStreamTrack>,
-    private MediaProducer,
-    private MediaStreamTrackPrivate::Observer {
+class MediaStreamTrack
+    : public RefCounted<MediaStreamTrack>
+    , public ActiveDOMObject
+    , public EventTargetWithInlineData
+    , public CanMakeWeakPtr<MediaStreamTrack>
+    , private MediaProducer
+    , private MediaStreamTrackPrivate::Observer
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     class Observer {
     public:
@@ -69,7 +74,6 @@ public:
     WEBCORE_EXPORT const String& id() const;
     const String& label() const;
 
-
     const AtomicString& contentHint() const;
     void setContentHint(const String&);
         
@@ -145,6 +149,11 @@ public:
 
     void setIdForTesting(String&& id) { m_private->setIdForTesting(WTFMove(id)); }
 
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final { return m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+#endif
+
 protected:
     MediaStreamTrack(ScriptExecutionContext&, Ref<MediaStreamTrackPrivate>&&);
 
@@ -176,8 +185,15 @@ private:
     void trackSettingsChanged(MediaStreamTrackPrivate&) final;
     void trackEnabledChanged(MediaStreamTrackPrivate&) final;
 
-    Vector<Observer*> m_observers;
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "MediaStreamTrack"; }
+    WTFLogChannel& logChannel() const final;
+    
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
 
+    Vector<Observer*> m_observers;
 
     MediaTrackConstraints m_constraints;
     Optional<DOMPromiseDeferred<void>> m_promise;
index 51ad321..90ca1be 100644 (file)
@@ -219,18 +219,12 @@ bool LibWebRTCMediaEndpoint::addTrack(LibWebRTCRtpSenderBackend& sender, MediaSt
     switch (track.privateTrack().type()) {
     case RealtimeMediaSource::Type::Audio: {
         auto audioSource = RealtimeOutgoingAudioSource::create(track.privateTrack());
-#if !RELEASE_LOG_DISABLED
-        audioSource->setLogger(m_logger.copyRef());
-#endif
         rtcTrack = m_peerConnectionFactory.CreateAudioTrack(track.id().utf8().data(), audioSource.ptr());
         source = WTFMove(audioSource);
         break;
     }
     case RealtimeMediaSource::Type::Video: {
         auto videoSource = RealtimeOutgoingVideoSource::create(track.privateTrack());
-#if !RELEASE_LOG_DISABLED
-        videoSource->setLogger(m_logger.copyRef());
-#endif
         rtcTrack = m_peerConnectionFactory.CreateVideoTrack(track.id().utf8().data(), videoSource.ptr());
         source = WTFMove(videoSource);
         break;
@@ -462,19 +456,11 @@ RefPtr<RealtimeMediaSource> LibWebRTCMediaEndpoint::sourceFromNewReceiver(webrtc
         return nullptr;
     case cricket::MEDIA_TYPE_AUDIO: {
         rtc::scoped_refptr<webrtc::AudioTrackInterface> audioTrack = static_cast<webrtc::AudioTrackInterface*>(rtcTrack.get());
-        auto audioSource = RealtimeIncomingAudioSource::create(WTFMove(audioTrack), fromStdString(rtcTrack->id()));
-#if !RELEASE_LOG_DISABLED
-        audioSource->setLogger(m_logger.copyRef());
-#endif
-        return audioSource;
+        return RealtimeIncomingAudioSource::create(WTFMove(audioTrack), fromStdString(rtcTrack->id()));
     }
     case cricket::MEDIA_TYPE_VIDEO: {
         rtc::scoped_refptr<webrtc::VideoTrackInterface> videoTrack = static_cast<webrtc::VideoTrackInterface*>(rtcTrack.get());
-        auto videoSource =  RealtimeIncomingVideoSource::create(WTFMove(videoTrack), fromStdString(rtcTrack->id()));
-#if !RELEASE_LOG_DISABLED
-        videoSource->setLogger(m_logger.copyRef());
-#endif
-        return videoSource;
+        return RealtimeIncomingVideoSource::create(WTFMove(videoTrack), fromStdString(rtcTrack->id()));
     }
     }
 
index d874ec2..4047006 100644 (file)
@@ -106,14 +106,6 @@ namespace WebCore {
 
 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(document()->page() && document()->page()->isAlwaysOnLoggingAllowed(), Media, "%p - AudioContext::" fmt, this, ##__VA_ARGS__)
     
-#if !RELEASE_LOG_DISABLED
-static const void* nextLogIdentifier()
-{
-    static uint64_t logIdentifier = cryptographicallyRandomNumber();
-    return reinterpret_cast<const void*>(++logIdentifier);
-}
-#endif
-
 bool AudioContext::isSampleRateRangeGood(float sampleRate)
 {
     // FIXME: It would be nice if the minimum sample-rate could be less than 44.1KHz,
@@ -141,7 +133,7 @@ AudioContext::AudioContext(Document& document)
     : ActiveDOMObject(document)
 #if !RELEASE_LOG_DISABLED
     , m_logger(document.logger())
-    , m_logIdentifier(nextLogIdentifier())
+    , m_logIdentifier(uniqueLogIdentifier())
 #endif
     , m_mediaSession(PlatformMediaSession::create(*this))
     , m_eventQueue(std::make_unique<GenericEventQueue>(*this))
@@ -159,7 +151,7 @@ AudioContext::AudioContext(Document& document, unsigned numberOfChannels, size_t
     : ActiveDOMObject(document)
 #if !RELEASE_LOG_DISABLED
     , m_logger(document.logger())
-    , m_logIdentifier(nextLogIdentifier())
+    , m_logIdentifier(uniqueLogIdentifier())
 #endif
     , m_isOfflineContext(true)
     , m_mediaSession(PlatformMediaSession::create(*this))
index 641f7c7..35e8450 100644 (file)
@@ -416,14 +416,6 @@ static bool mediaSessionMayBeConfusedWithMainContent(const MediaElementSessionIn
     return true;
 }
 
-#if !RELEASE_LOG_DISABLED
-static uint64_t nextLogIdentifier()
-{
-    static uint64_t logIdentifier = cryptographicallyRandomNumber();
-    return ++logIdentifier;
-}
-#endif
-
 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : HTMLElement(tagName, document)
     , ActiveDOMObject(document)
@@ -474,7 +466,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
 #endif
 #if !RELEASE_LOG_DISABLED
     , m_logger(&document.logger())
-    , m_logIdentifier(nextLogIdentifier())
+    , m_logIdentifier(uniqueLogIdentifier())
 #endif
 {
     allMediaElements().add(this);
index a678d94..85cd06d 100644 (file)
@@ -561,7 +561,7 @@ public:
 
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return *m_logger.get(); }
-    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
     WTFLogChannel& logChannel() const final;
 #endif
 
@@ -1176,7 +1176,7 @@ private:
 
 #if !RELEASE_LOG_DISABLED
     RefPtr<Logger> m_logger;
-    uint64_t m_logIdentifier;
+    const void* m_logIdentifier;
 #endif
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
index 3e561fe..ba36379 100644 (file)
 #include "Logging.h"
 #include "MediaPlayer.h"
 #include "PlatformMediaSessionManager.h"
-#include <wtf/CryptographicallyRandomNumber.h>
 
 namespace WebCore {
 
 static const Seconds clientDataBufferingTimerThrottleDelay { 100_ms };
 
 #if !RELEASE_LOG_DISABLED
-static uint64_t nextLogIdentifier()
-{
-    static uint64_t logIdentifier = cryptographicallyRandomNumber();
-    return ++logIdentifier;
-}
-
 String convertEnumerationToString(PlatformMediaSession::State state)
 {
     static const NeverDestroyed<String> values[] = {
@@ -126,7 +119,7 @@ PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionClient& client)
     , m_notifyingClient(false)
 #if !RELEASE_LOG_DISABLED
     , m_logger(client.hostingDocument()->logger())
-    , m_logIdentifier(nextLogIdentifier())
+    , m_logIdentifier(uniqueLogIdentifier())
 #endif
 {
     ASSERT(m_client.mediaType() >= None && m_client.mediaType() <= MediaStreamCapturingAudio);
index b5d792f..469824d 100644 (file)
@@ -184,7 +184,7 @@ public:
 
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return m_logger.get(); }
-    const void* logIdentifier() const override { return reinterpret_cast<const void*>(m_logIdentifier); }
+    const void* logIdentifier() const override { return m_logIdentifier; }
     const char* logClassName() const override { return "PlatformMediaSession"; }
     WTFLogChannel& logChannel() const final;
 #endif
@@ -204,7 +204,7 @@ private:
 
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;
-    uint64_t m_logIdentifier;
+    const void* m_logIdentifier;
 #endif
 
     friend class PlatformMediaSessionManager;
index 375a1a1..9d266de 100644 (file)
@@ -27,6 +27,7 @@
 #include "IntSize.h"
 
 #include "FloatSize.h"
+#include <wtf/JSONValues.h>
 #include <wtf/text/TextStream.h>
 
 namespace WebCore {
@@ -50,4 +51,19 @@ TextStream& operator<<(TextStream& ts, const IntSize& size)
     return ts << "width=" << size.width() << " height=" << size.height();
 }
 
+Ref<JSON::Object> IntSize::toJSONObject() const
+{
+    auto object = JSON::Object::create();
+
+    object->setDouble("width"_s, m_width);
+    object->setDouble("height"_s, m_height);
+
+    return object;
+}
+
+String IntSize::toJSONString() const
+{
+    return toJSONObject()->toJSONString();
+}
+
 }
index 3052a37..ee7c6c0 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <algorithm>
+#include <wtf/JSONValues.h>
 #include <wtf/Forward.h>
 
 #if PLATFORM(MAC) && defined __OBJC__
@@ -173,6 +174,9 @@ public:
     operator D2D1_SIZE_F() const;
 #endif
 
+    String toJSONString() const;
+    Ref<JSON::Object> toJSONObject() const;
+
 private:
     int m_width, m_height;
 };
@@ -223,4 +227,14 @@ WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const IntSize&);
 namespace WTF {
 template<> struct DefaultHash<WebCore::IntSize>;
 template<> struct HashTraits<WebCore::IntSize>;
+
+template<typename Type> struct LogArgument;
+template <>
+struct LogArgument<WebCore::IntSize> {
+    static String toString(const WebCore::IntSize& size)
+    {
+        return size.toJSONString();
+    }
+};
 }
+
index bd8eb88..e36177a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2011, 2015 Ericsson AB. All rights reserved.
  * Copyright (C) 2013 Google Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -136,6 +136,8 @@ void MediaStreamPrivate::addTrack(RefPtr<MediaStreamTrackPrivate>&& track, Notif
     if (m_trackSet.contains(track->id()))
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, track->logIdentifier());
+
     track->addObserver(*this);
     m_trackSet.add(track->id(), track);
 
@@ -154,6 +156,7 @@ void MediaStreamPrivate::removeTrack(MediaStreamTrackPrivate& track, NotifyClien
     if (!m_trackSet.remove(track.id()))
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier());
     track.removeObserver(*this);
 
     if (notifyClientOption == NotifyClientOption::Notify) {
@@ -168,12 +171,14 @@ void MediaStreamPrivate::removeTrack(MediaStreamTrackPrivate& track, NotifyClien
 
 void MediaStreamPrivate::startProducingData()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     for (auto& track : m_trackSet.values())
         track->startProducingData();
 }
 
 void MediaStreamPrivate::stopProducingData()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     for (auto& track : m_trackSet.values())
         track->stopProducingData();
 }
@@ -189,6 +194,7 @@ bool MediaStreamPrivate::isProducingData() const
 
 void MediaStreamPrivate::setCaptureTracksMuted(bool muted)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, muted);
     for (auto& track : m_trackSet.values()) {
         if (track->isCaptureTrack())
             track->setMuted(muted);
@@ -271,8 +277,13 @@ void MediaStreamPrivate::characteristicsChanged()
     });
 }
 
-void MediaStreamPrivate::trackMutedChanged(MediaStreamTrackPrivate&)
+void MediaStreamPrivate::trackMutedChanged(MediaStreamTrackPrivate& track)
 {
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(track);
+#endif
+
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier(), " ", track.muted());
     scheduleDeferredTask([this] {
         characteristicsChanged();
     });
@@ -283,8 +294,13 @@ void MediaStreamPrivate::trackSettingsChanged(MediaStreamTrackPrivate&)
     characteristicsChanged();
 }
 
-void MediaStreamPrivate::trackEnabledChanged(MediaStreamTrackPrivate&)
+void MediaStreamPrivate::trackEnabledChanged(MediaStreamTrackPrivate& track)
 {
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(track);
+#endif
+
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier(), " ", track.enabled());
     updateActiveVideoTrack();
 
     scheduleDeferredTask([this] {
@@ -292,15 +308,25 @@ void MediaStreamPrivate::trackEnabledChanged(MediaStreamTrackPrivate&)
     });
 }
 
-void MediaStreamPrivate::trackStarted(MediaStreamTrackPrivate&)
+void MediaStreamPrivate::trackStarted(MediaStreamTrackPrivate& track)
 {
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(track);
+#endif
+
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier());
     scheduleDeferredTask([this] {
         characteristicsChanged();
     });
 }
 
-void MediaStreamPrivate::trackEnded(MediaStreamTrackPrivate&)
+void MediaStreamPrivate::trackEnded(MediaStreamTrackPrivate& track)
 {
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(track);
+#endif
+
+    ALWAYS_LOG(LOGIDENTIFIER, track.logIdentifier());
     scheduleDeferredTask([this] {
         updateActiveState(NotifyClientOption::Notify);
         characteristicsChanged();
@@ -326,6 +352,20 @@ void MediaStreamPrivate::monitorOrientation(OrientationNotifier& notifier)
     }
 }
 
+#if !RELEASE_LOG_DISABLED
+void MediaStreamPrivate::setLogger(const Logger& newLogger, const void* newLogIdentifier)
+{
+    m_logger = &newLogger;
+    m_logIdentifier = newLogIdentifier;
+    ALWAYS_LOG(LOGIDENTIFIER);
+}
+
+WTFLogChannel& MediaStreamPrivate::logChannel() const
+{
+    return LogWebRTC;
+}
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index e146c68..e2da353 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2011, 2015 Ericsson AB. All rights reserved.
  * Copyright (C) 2012 Google Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,6 +41,7 @@
 #include "MediaStreamTrackPrivate.h"
 #include <wtf/Function.h>
 #include <wtf/HashMap.h>
+#include <wtf/LoggerHelper.h>
 #include <wtf/MediaTime.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -53,7 +54,14 @@ namespace WebCore {
 class MediaStream;
 class OrientationNotifier;
 
-class MediaStreamPrivate : public MediaStreamTrackPrivate::Observer, public RefCounted<MediaStreamPrivate>, public CanMakeWeakPtr<MediaStreamPrivate> {
+class MediaStreamPrivate final
+    : public MediaStreamTrackPrivate::Observer
+    , public RefCounted<MediaStreamPrivate>
+    , public CanMakeWeakPtr<MediaStreamPrivate>
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     class Observer {
     public:
@@ -103,6 +111,10 @@ public:
 
     void monitorOrientation(OrientationNotifier&);
 
+#if !RELEASE_LOG_DISABLED
+    void setLogger(const Logger&, const void*);
+#endif
+
 private:
     MediaStreamPrivate(const MediaStreamTrackPrivateVector&, String&&);
 
@@ -119,6 +131,16 @@ private:
     void scheduleDeferredTask(Function<void ()>&&);
     void forEachObserver(const WTF::Function<void(Observer&)>&) const;
 
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final { ASSERT(m_logger); return *m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    const char* logClassName() const final { return "MediaStreamPrivate"; }
+    WTFLogChannel& logChannel() const final;
+
+    RefPtr<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
+
     HashSet<Observer*> m_observers;
     String m_id;
     MediaStreamTrackPrivate* m_activeVideoTrack { nullptr };
index 4938ff9..4943da3 100644 (file)
@@ -1,6 +1,7 @@
 /*
- *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *  Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -269,12 +270,29 @@ void MediaStreamTrackPrivate::updateReadyState()
     if (state == m_readyState)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     m_readyState = state;
     forEachObserver([this](auto& observer) {
         observer.readyStateChanged(*this);
     });
 }
 
+#if !RELEASE_LOG_DISABLED
+void MediaStreamTrackPrivate::setLogger(const Logger& newLogger, const void* newLogIdentifier)
+{
+    m_logger = &newLogger;
+    m_logIdentifier = newLogIdentifier;
+    ALWAYS_LOG(LOGIDENTIFIER);
+    m_source->setLogger(newLogger, newLogIdentifier);
+}
+
+WTFLogChannel& MediaStreamTrackPrivate::logChannel() const
+{
+    return LogWebRTC;
+}
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 9c7f03f..5967d45 100644 (file)
@@ -1,6 +1,7 @@
 /*
- *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *  Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +30,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "RealtimeMediaSource.h"
+#include <wtf/LoggerHelper.h>
 
 namespace WebCore {
 
@@ -38,7 +40,13 @@ class MediaSample;
 class RealtimeMediaSourceCapabilities;
 class WebAudioSourceProvider;
 
-class MediaStreamTrackPrivate : public RefCounted<MediaStreamTrackPrivate>, public RealtimeMediaSource::Observer {
+class MediaStreamTrackPrivate final
+    : public RefCounted<MediaStreamTrackPrivate>
+    , public RealtimeMediaSource::Observer
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     class Observer {
     public:
@@ -108,6 +116,12 @@ public:
 
     void setIdForTesting(String&& id) { m_id = WTFMove(id); }
 
+#if !RELEASE_LOG_DISABLED
+    void setLogger(const Logger&, const void*);
+    const Logger& logger() const final { ASSERT(m_logger); return *m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+#endif
+    
 private:
     MediaStreamTrackPrivate(Ref<RealtimeMediaSource>&&, String&& id);
 
@@ -124,6 +138,14 @@ private:
 
     void forEachObserver(const WTF::Function<void(Observer&)>&) const;
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "MediaStreamTrackPrivate"; }
+    WTFLogChannel& logChannel() const final;
+
+    RefPtr<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
+
     mutable RecursiveLock m_observersLock;
     HashSet<Observer*> m_observers;
     Ref<RealtimeMediaSource> m_source;
index fe0ddd7..a4b127a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "LibWebRTCAudioFormat.h"
 #include "Logging.h"
-#include <wtf/CryptographicallyRandomNumber.h>
 
 namespace WebCore {
 
 RealtimeIncomingAudioSource::RealtimeIncomingAudioSource(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& audioTrack, String&& audioTrackId)
     : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, "remote audio"_s, WTFMove(audioTrackId))
     , m_audioTrack(WTFMove(audioTrack))
-#if !RELEASE_LOG_DISABLED
-    , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
-#endif
 {
     notifyMutedChange(!m_audioTrack);
 }
@@ -89,20 +85,6 @@ const RealtimeMediaSourceSettings& RealtimeIncomingAudioSource::settings()
     return m_currentSettings;
 }
 
-#if !RELEASE_LOG_DISABLED
-WTFLogChannel& RealtimeIncomingAudioSource::logChannel() const
-{
-    return LogWebRTC;
-}
-
-const Logger& RealtimeIncomingAudioSource::logger() const
-{
-    if (!m_logger)
-        m_logger = Logger::create(this);
-    return *m_logger;
-}
-#endif
-
 }
 
 #endif // USE(LIBWEBRTC)
index 16e2128..aec965b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,7 +41,6 @@ ALLOW_UNUSED_PARAMETERS_BEGIN
 
 ALLOW_UNUSED_PARAMETERS_END
 
-#include <wtf/LoggerHelper.h>
 #include <wtf/RetainPtr.h>
 
 namespace WebCore {
@@ -49,29 +48,18 @@ namespace WebCore {
 class RealtimeIncomingAudioSource
     : public RealtimeMediaSource
     , private webrtc::AudioTrackSinkInterface
-#if !RELEASE_LOG_DISABLED
-    , private LoggerHelper
-#endif
 {
 public:
     static Ref<RealtimeIncomingAudioSource> create(rtc::scoped_refptr<webrtc::AudioTrackInterface>&&, String&&);
 
     void setSourceTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>&&);
 
-#if !RELEASE_LOG_DISABLED
-    void setLogger(Ref<const Logger>&& logger) { m_logger = WTFMove(logger); }
-#endif
-
 protected:
     RealtimeIncomingAudioSource(rtc::scoped_refptr<webrtc::AudioTrackInterface>&&, String&&);
     ~RealtimeIncomingAudioSource();
 
 #if !RELEASE_LOG_DISABLED
-    // LoggerHelper API
-    const Logger& logger() const final;
-    const void* logIdentifier() const final { return m_logIdentifier; }
     const char* logClassName() const final { return "RealtimeIncomingAudioSource"; }
-    WTFLogChannel& logChannel() const final;
 #endif
 
 private:
index 1446b3f..45403dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if USE(LIBWEBRTC)
 
-#include "Logging.h"
-#include <wtf/CryptographicallyRandomNumber.h>
-
 namespace WebCore {
 
 RealtimeIncomingVideoSource::RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
     : RealtimeMediaSource(Type::Video, "remote video"_s, WTFMove(videoTrackId))
     , m_videoTrack(WTFMove(videoTrack))
-#if !RELEASE_LOG_DISABLED
-    , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
-#endif
 {
     notifyMutedChange(!m_videoTrack);
 
@@ -108,20 +102,6 @@ void RealtimeIncomingVideoSource::settingsDidChange(OptionSet<RealtimeMediaSourc
         m_currentSettings = WTF::nullopt;
 }
 
-#if !RELEASE_LOG_DISABLED
-WTFLogChannel& RealtimeIncomingVideoSource::logChannel() const
-{
-    return LogWebRTC;
-}
-
-const Logger& RealtimeIncomingVideoSource::logger() const
-{
-    if (!m_logger)
-        m_logger = Logger::create(this);
-    return *m_logger;
-}
-#endif
-
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)
index d0c4960..35a7d66 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,7 +41,6 @@ ALLOW_UNUSED_PARAMETERS_BEGIN
 
 ALLOW_UNUSED_PARAMETERS_END
 
-#include <wtf/LoggerHelper.h>
 #include <wtf/RetainPtr.h>
 
 namespace WebCore {
@@ -51,9 +50,6 @@ class CaptureDevice;
 class RealtimeIncomingVideoSource
     : public RealtimeMediaSource
     , private rtc::VideoSinkInterface<webrtc::VideoFrame>
-#if !RELEASE_LOG_DISABLED
-    , private LoggerHelper
-#endif
 {
 public:
     static Ref<RealtimeIncomingVideoSource> create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&);
@@ -64,19 +60,11 @@ public:
 
     void setSourceTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&);
 
-#if !RELEASE_LOG_DISABLED
-    void setLogger(Ref<const Logger>&& logger) { m_logger = WTFMove(logger); }
-#endif
-
 protected:
     RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&);
 
 #if !RELEASE_LOG_DISABLED
-    // LoggerHelper API
-    const Logger& logger() const final;
-    const void* logIdentifier() const final { return m_logIdentifier; }
     const char* logClassName() const final { return "RealtimeIncomingVideoSource"; }
-    WTFLogChannel& logChannel() const final;
 #endif
     
 private:
index c83ca74..a9d2946 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  * Copyright (C) 2015 Ericsson AB. All rights reserved.
  *
@@ -56,8 +56,8 @@ RealtimeMediaSource::RealtimeMediaSource(Type type, String&& name, String&& devi
 {
     if (m_persistentID.isEmpty())
         m_persistentID = createCanonicalUUIDString();
-    else
-        m_hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, m_idHashSalt);
+
+    m_hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, m_idHashSalt);
 }
 
 void RealtimeMediaSource::addObserver(RealtimeMediaSource::Observer& observer)
@@ -80,6 +80,8 @@ void RealtimeMediaSource::setInterrupted(bool interrupted, bool pageMuted)
     if (interrupted == m_interrupted)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, interrupted, ", page muted : ", pageMuted);
+
     m_interrupted = interrupted;
     if (!interrupted && pageMuted)
         return;
@@ -89,6 +91,8 @@ void RealtimeMediaSource::setInterrupted(bool interrupted, bool pageMuted)
 
 void RealtimeMediaSource::setMuted(bool muted)
 {
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
+
     if (muted)
         stop();
     else {
@@ -106,6 +110,7 @@ void RealtimeMediaSource::notifyMutedChange(bool muted)
     if (m_muted == muted)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
     m_muted = muted;
 
     notifyMutedObservers();
@@ -149,6 +154,8 @@ void RealtimeMediaSource::notifySettingsDidChangeObservers(OptionSet<RealtimeMed
         return;
     m_pendingSettingsDidChangeNotification = true;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, flags);
+
     scheduleDeferredTask([this] {
         m_pendingSettingsDidChangeNotification = false;
         forEachObserver([](auto& observer) {
@@ -159,6 +166,20 @@ void RealtimeMediaSource::notifySettingsDidChangeObservers(OptionSet<RealtimeMed
 
 void RealtimeMediaSource::videoSampleAvailable(MediaSample& mediaSample)
 {
+#if !RELEASE_LOG_DISABLED
+    ++m_frameCount;
+
+    auto timestamp = MonotonicTime::now();
+    auto delta = timestamp - m_lastFrameLogTime;
+    if (!m_lastFrameLogTime || delta >= 1_s) {
+        if (m_lastFrameLogTime) {
+            INFO_LOG_IF(loggerPtr(), LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");
+            m_frameCount = 0;
+        }
+        m_lastFrameLogTime = timestamp;
+    }
+#endif
+
     forEachObserver([&](auto& observer) {
         observer.videoSampleAvailable(mediaSample);
     });
@@ -176,6 +197,8 @@ void RealtimeMediaSource::start()
     if (m_isProducingData || m_isEnded)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
+
     m_isProducingData = true;
     startProducingData();
 
@@ -192,6 +215,8 @@ void RealtimeMediaSource::stop()
     if (!m_isProducingData)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
+
     m_isProducingData = false;
     stopProducingData();
 }
@@ -223,7 +248,7 @@ void RealtimeMediaSource::requestToEnd(Observer& callingObserver)
 
 void RealtimeMediaSource::captureFailed()
 {
-    RELEASE_LOG_ERROR(MediaStream, "RealtimeMediaSource::captureFailed");
+    ERROR_LOG_IF(m_logger, LOGIDENTIFIER);
 
     m_isProducingData = false;
     m_captureDidFailed = true;
@@ -467,6 +492,8 @@ void RealtimeMediaSource::setSizeAndFrameRate(Optional<int> width, Optional<int>
 
 void RealtimeMediaSource::applyConstraint(const MediaConstraint& constraint)
 {
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, constraint.name());
+
     auto& capabilities = this->capabilities();
     switch (constraint.constraintType()) {
     case MediaConstraintType::Width:
@@ -769,6 +796,8 @@ bool RealtimeMediaSource::supportsConstraints(const MediaConstraints& constraint
 {
     ASSERT(constraints.isValid);
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
+
     FlattenedConstraint candidates;
     if (!selectSettings(constraints, candidates, invalidConstraint))
         return false;
@@ -799,6 +828,8 @@ bool RealtimeMediaSource::supportsConstraints(const MediaConstraints& constraint
         }
     }
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, "fitness distance : ", m_fitnessScore);
+
     return true;
 }
 
@@ -855,6 +886,8 @@ Optional<RealtimeMediaSource::ApplyConstraintsError> RealtimeMediaSource::applyC
 {
     ASSERT(constraints.isValid);
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER);
+
     FlattenedConstraint candidates;
     String failedConstraint;
     if (!selectSettings(constraints, candidates, failedConstraint))
@@ -874,6 +907,8 @@ void RealtimeMediaSource::setSize(const IntSize& size)
     if (size == m_size)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, size);
+    
     m_size = size;
     notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
 }
@@ -899,6 +934,8 @@ void RealtimeMediaSource::setIntrinsicSize(const IntSize& size)
     if (m_intrinsicSize == size)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, size);
+    
     auto currentSize = this->size();
     m_intrinsicSize = size;
 
@@ -916,6 +953,8 @@ void RealtimeMediaSource::setFrameRate(double rate)
     if (m_frameRate == rate)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, rate);
+    
     m_frameRate = rate;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::FrameRate);
 }
@@ -925,6 +964,8 @@ void RealtimeMediaSource::setAspectRatio(double ratio)
     if (m_aspectRatio == ratio)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, ratio);
+    
     m_aspectRatio = ratio;
     m_size.setHeight(m_size.width() / ratio);
     notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::AspectRatio, RealtimeMediaSourceSettings::Flag::Height });
@@ -935,6 +976,8 @@ void RealtimeMediaSource::setFacingMode(RealtimeMediaSourceSettings::VideoFacing
     if (m_facingMode == mode)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, mode);
+
     m_facingMode = mode;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::FacingMode);
 }
@@ -944,6 +987,8 @@ void RealtimeMediaSource::setVolume(double volume)
     if (m_volume == volume)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, volume);
+
     m_volume = volume;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::Volume);
 }
@@ -953,6 +998,8 @@ void RealtimeMediaSource::setSampleRate(int rate)
     if (m_sampleRate == rate)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, rate);
+
     m_sampleRate = rate;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::SampleRate);
 }
@@ -967,6 +1014,8 @@ void RealtimeMediaSource::setSampleSize(int size)
     if (m_sampleSize == size)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, size);
+
     m_sampleSize = size;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::SampleSize);
 }
@@ -981,6 +1030,7 @@ void RealtimeMediaSource::setEchoCancellation(bool echoCancellation)
     if (m_echoCancellation == echoCancellation)
         return;
 
+    ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, echoCancellation);
     m_echoCancellation = echoCancellation;
     notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::EchoCancellation);
 }
@@ -1011,6 +1061,34 @@ RealtimeMediaSource::Observer::~Observer()
 {
 }
 
+#if !RELEASE_LOG_DISABLED
+void RealtimeMediaSource::setLogger(const Logger& newLogger, const void* newLogIdentifier)
+{
+    m_logger = &newLogger;
+    m_logIdentifier = newLogIdentifier;
+    ALWAYS_LOG(LOGIDENTIFIER, m_type, ", ", m_name, ", ", m_hashedID);
+}
+
+WTFLogChannel& RealtimeMediaSource::logChannel() const
+{
+    return LogWebRTC;
+}
+#endif
+
+String convertEnumerationToString(RealtimeMediaSource::Type enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("None"),
+        MAKE_STATIC_STRING_IMPL("Audio"),
+        MAKE_STATIC_STRING_IMPL("Video"),
+    };
+    static_assert(static_cast<size_t>(RealtimeMediaSource::Type::None) == 0, "RealtimeMediaSource::Type::None is not 0 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSource::Type::Audio) == 1, "RealtimeMediaSource::Type::Audio is not 1 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSource::Type::Video) == 2, "RealtimeMediaSource::Type::Video is not 2 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index afe1977..ab3c997 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
  * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,7 @@
 #include "PlatformLayer.h"
 #include "RealtimeMediaSourceCapabilities.h"
 #include "RealtimeMediaSourceFactory.h"
+#include <wtf/LoggerHelper.h>
 #include <wtf/RecursiveLockAdapter.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Vector.h>
@@ -65,7 +66,13 @@ class RemoteVideoSample;
 
 struct CaptureSourceOrError;
 
-class WEBCORE_EXPORT RealtimeMediaSource : public ThreadSafeRefCounted<RealtimeMediaSource>, public CanMakeWeakPtr<RealtimeMediaSource> {
+class WEBCORE_EXPORT RealtimeMediaSource
+    : public ThreadSafeRefCounted<RealtimeMediaSource>
+    , public CanMakeWeakPtr<RealtimeMediaSource>
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     class Observer {
     public:
@@ -176,6 +183,15 @@ public:
     void setIsRemote(bool isRemote) { m_isRemote = isRemote; }
     bool isRemote() const { return m_isRemote; }
 
+#if !RELEASE_LOG_DISABLED
+    void setLogger(const Logger&, const void*);
+    const Logger* loggerPtr() const { return m_logger.get(); }
+    const Logger& logger() const final { ASSERT(m_logger); return *m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    const char* logClassName() const override { return "RealtimeMediaSource"; }
+    WTFLogChannel& logChannel() const final;
+#endif
+
     // Testing only
     virtual void delaySamples(Seconds) { };
     void setInterruptedForTesting(bool);
@@ -217,7 +233,12 @@ private:
 
     void forEachObserver(const WTF::Function<void(Observer&)>&) const;
 
-    bool m_muted { false };
+#if !RELEASE_LOG_DISABLED
+    RefPtr<const Logger> m_logger;
+    const void* m_logIdentifier;
+    MonotonicTime m_lastFrameLogTime;
+    unsigned m_frameCount { 0 };
+#endif
 
     String m_idHashSalt;
     String m_hashedID;
@@ -236,6 +257,7 @@ private:
     double m_fitnessScore { 0 };
     RealtimeMediaSourceSettings::VideoFacingMode m_facingMode { RealtimeMediaSourceSettings::User};
 
+    bool m_muted { false };
     bool m_pendingSettingsDidChangeNotification { false };
     bool m_echoCancellation { false };
     bool m_isProducingData { false };
@@ -257,6 +279,23 @@ struct CaptureSourceOrError {
     String errorMessage;
 };
 
+String convertEnumerationToString(RealtimeMediaSource::Type);
+
 } // namespace WebCore
 
+namespace WTF {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RealtimeMediaSource::Type> {
+    static String toString(const WebCore::RealtimeMediaSource::Type type)
+    {
+        return convertEnumerationToString(type);
+    }
+};
+
+}; // namespace WTF
+
 #endif // ENABLE(MEDIA_STREAM)
index 3aadd24..02d0283 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -69,6 +69,65 @@ RealtimeMediaSourceSettings::VideoFacingMode RealtimeMediaSourceSettings::videoF
     return RealtimeMediaSourceSettings::Unknown;
 }
 
+String RealtimeMediaSourceSettings::convertFlagsToString(const OptionSet<RealtimeMediaSourceSettings::Flag> flags)
+{
+    StringBuilder builder;
+
+    builder.append("[ ");
+    for (auto flag : flags) {
+        if (!builder.isEmpty())
+            builder.append(", ");
+
+        switch (flag) {
+        case RealtimeMediaSourceSettings::Width:
+            builder.append("Width");
+            break;
+        case RealtimeMediaSourceSettings::Height:
+            builder.append("Height");
+            break;
+        case RealtimeMediaSourceSettings::AspectRatio:
+            builder.append("AspectRatio");
+            break;
+        case RealtimeMediaSourceSettings::FrameRate:
+            builder.append("FrameRate");
+            break;
+        case RealtimeMediaSourceSettings::FacingMode:
+            builder.append("FacingMode");
+            break;
+        case RealtimeMediaSourceSettings::Volume:
+            builder.append("Volume");
+            break;
+        case RealtimeMediaSourceSettings::SampleRate:
+            builder.append("SampleRate");
+            break;
+        case RealtimeMediaSourceSettings::SampleSize:
+            builder.append("SampleSize");
+            break;
+        case RealtimeMediaSourceSettings::EchoCancellation:
+            builder.append("EchoCancellation");
+            break;
+        case RealtimeMediaSourceSettings::DeviceId:
+            builder.append("DeviceId");
+            break;
+        case RealtimeMediaSourceSettings::GroupId:
+            builder.append("GroupId");
+            break;
+        case RealtimeMediaSourceSettings::Label:
+            builder.append("Label");
+            break;
+        case RealtimeMediaSourceSettings::DisplaySurface:
+            builder.append("DisplaySurface");
+            break;
+        case RealtimeMediaSourceSettings::LogicalSurface:
+            builder.append("LogicalSurface");
+            break;
+        }
+    }
+    builder.append(" ]");
+
+    return builder.toString();
+}
+
 OptionSet<RealtimeMediaSourceSettings::Flag> RealtimeMediaSourceSettings::difference(const RealtimeMediaSourceSettings& that) const
 {
     OptionSet<RealtimeMediaSourceSettings::Flag> difference;
@@ -105,6 +164,23 @@ OptionSet<RealtimeMediaSourceSettings::Flag> RealtimeMediaSourceSettings::differ
     return difference;
 }
 
+String convertEnumerationToString(RealtimeMediaSourceSettings::VideoFacingMode enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("Unknown"),
+        MAKE_STATIC_STRING_IMPL("User"),
+        MAKE_STATIC_STRING_IMPL("Environment"),
+        MAKE_STATIC_STRING_IMPL("Left"),
+        MAKE_STATIC_STRING_IMPL("Right"),
+    };
+    static_assert(static_cast<size_t>(RealtimeMediaSourceSettings::VideoFacingMode::Unknown) == 0, "RealtimeMediaSourceSettings::VideoFacingMode::Unknown is not 0 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSourceSettings::VideoFacingMode::User) == 1, "RealtimeMediaSourceSettings::VideoFacingMode::User is not 1 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSourceSettings::VideoFacingMode::Environment) == 2, "RealtimeMediaSourceSettings::VideoFacingMode::Environment is not 2 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSourceSettings::VideoFacingMode::Left) == 3, "RealtimeMediaSourceSettings::VideoFacingMode::Left is not 3 as expected");
+    static_assert(static_cast<size_t>(RealtimeMediaSourceSettings::VideoFacingMode::Right) == 4, "RealtimeMediaSourceSettings::VideoFacingMode::Right is not 4 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
 
 } // namespace WebCore
 
index c4a96bb..395a64c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -134,6 +134,8 @@ public:
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static bool decode(Decoder&, RealtimeMediaSourceSettings&);
 
+    static String convertFlagsToString(const OptionSet<RealtimeMediaSourceSettings::Flag>);
+
 private:
     uint32_t m_width { 0 };
     uint32_t m_height { 0 };
@@ -191,6 +193,8 @@ bool RealtimeMediaSourceSettings::decode(Decoder& decoder, RealtimeMediaSourceSe
         && decoder.decodeEnum(settings.m_facingMode);
 }
 
+String convertEnumerationToString(RealtimeMediaSourceSettings::VideoFacingMode);
+
 } // namespace WebCore
 
 namespace WTF {
@@ -206,6 +210,25 @@ template <> struct EnumTraits<WebCore::RealtimeMediaSourceSettings::VideoFacingM
     >;
 };
 
-}
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RealtimeMediaSourceSettings::VideoFacingMode> {
+    static String toString(const WebCore::RealtimeMediaSourceSettings::VideoFacingMode mode)
+    {
+        return convertEnumerationToString(mode);
+    }
+};
+
+template <>
+struct LogArgument<OptionSet<WebCore::RealtimeMediaSourceSettings::Flag>> {
+    static String toString(const OptionSet<WebCore::RealtimeMediaSourceSettings::Flag> flags)
+    {
+        return WebCore::RealtimeMediaSourceSettings::convertFlagsToString(flags);
+    }
+};
+
+}; // namespace WTF
 
 #endif
index 03b9496..7747086 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc.
+ * Copyright (C) 2017-2019 Apple Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted, provided that the following conditions
@@ -41,7 +41,8 @@ namespace WebCore {
 RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource(Ref<MediaStreamTrackPrivate>&& source)
     : m_audioSource(WTFMove(source))
 #if !RELEASE_LOG_DISABLED
-    , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
+    , m_logger(m_audioSource->logger())
+    , m_logIdentifier(m_audioSource->logIdentifier())
 #endif
 {
 }
@@ -134,14 +135,6 @@ WTFLogChannel& RealtimeOutgoingAudioSource::logChannel() const
 {
     return LogWebRTC;
 }
-
-const Logger& RealtimeOutgoingAudioSource::logger() const
-{
-    if (!m_logger)
-        m_logger = Logger::create(this);
-    return *m_logger;
-}
-
 #endif
     
 } // namespace WebCore
index 97d0d4f..c315730 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc.
+ * Copyright (C) 2017-2019 Apple Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted, provided that the following conditions
@@ -69,10 +69,6 @@ public:
     bool setSource(Ref<MediaStreamTrackPrivate>&&);
     MediaStreamTrackPrivate& source() const { return m_audioSource.get(); }
 
-#if !RELEASE_LOG_DISABLED
-    void setLogger(Ref<const Logger>&& logger) { m_logger = WTFMove(logger); }
-#endif
-
 protected:
     explicit RealtimeOutgoingAudioSource(Ref<MediaStreamTrackPrivate>&&);
 
@@ -86,7 +82,7 @@ protected:
 
 #if !RELEASE_LOG_DISABLED
     // LoggerHelper API
-    const Logger& logger() const final;
+    const Logger& logger() const final { return m_logger.get(); }
     const void* logIdentifier() const final { return m_logIdentifier; }
     const char* logClassName() const final { return "RealtimeOutgoingAudioSource"; }
     WTFLogChannel& logChannel() const final;
@@ -137,7 +133,7 @@ private:
     HashSet<webrtc::AudioTrackSinkInterface*> m_sinks;
 
 #if !RELEASE_LOG_DISABLED
-    mutable RefPtr<const Logger> m_logger;
+    mutable Ref<const Logger> m_logger;
     const void* m_logIdentifier;
     size_t m_chunksSent { 0 };
 #endif
index 64b4e9e..ef93e67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc.
+ * Copyright (C) 2017-2019 Apple Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted, provided that the following conditions
@@ -40,7 +40,6 @@ ALLOW_UNUSED_PARAMETERS_BEGIN
 
 ALLOW_UNUSED_PARAMETERS_END
 
-#include <wtf/CryptographicallyRandomNumber.h>
 #include <wtf/MainThread.h>
 
 namespace WebCore {
@@ -49,7 +48,8 @@ RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPri
     : m_videoSource(WTFMove(videoSource))
     , m_blackFrameTimer(*this, &RealtimeOutgoingVideoSource::sendOneBlackFrame)
 #if !RELEASE_LOG_DISABLED
-    , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
+    , m_logger(m_videoSource->logger())
+    , m_logIdentifier(m_videoSource->logIdentifier())
 #endif
 {
 }
@@ -200,7 +200,7 @@ void RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded()
 
 void RealtimeOutgoingVideoSource::sendOneBlackFrame()
 {
-    ALWAYS_LOG(LOGIDENTIFIER, "test");
+    ALWAYS_LOG(LOGIDENTIFIER);
     sendFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>(m_blackFrame));
 }
 
@@ -209,6 +209,19 @@ void RealtimeOutgoingVideoSource::sendFrame(rtc::scoped_refptr<webrtc::VideoFram
     MonotonicTime timestamp = MonotonicTime::now();
     webrtc::VideoFrame frame(buffer, m_shouldApplyRotation ? webrtc::kVideoRotation_0 : m_currentRotation, static_cast<int64_t>(timestamp.secondsSinceEpoch().microseconds()));
 
+#if !RELEASE_LOG_DISABLED
+    ++m_frameCount;
+
+    auto delta = timestamp - m_lastFrameLogTime;
+    if (!m_lastFrameLogTime || delta >= 1_s) {
+        if (m_lastFrameLogTime) {
+            INFO_LOG(LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");
+            m_frameCount = 0;
+        }
+        m_lastFrameLogTime = timestamp;
+    }
+#endif
+
     auto locker = holdLock(m_sinksLock);
     for (auto* sink : m_sinks)
         sink->OnFrame(frame);
@@ -219,13 +232,6 @@ WTFLogChannel& RealtimeOutgoingVideoSource::logChannel() const
 {
     return LogWebRTC;
 }
-
-const Logger& RealtimeOutgoingVideoSource::logger() const
-{
-    if (!m_logger)
-        m_logger = Logger::create(this);
-    return *m_logger;
-}
 #endif
 
 } // namespace WebCore
index 031f607..c46a027 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc.
+ * Copyright (C) 2017-2019 Apple Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted, provided that the following conditions
@@ -72,10 +72,6 @@ public:
 
     void setApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = shouldApplyRotation; }
 
-#if !RELEASE_LOG_DISABLED
-    void setLogger(Ref<const Logger>&& logger) { m_logger = WTFMove(logger); }
-#endif
-
 protected:
     explicit RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);
 
@@ -89,7 +85,7 @@ protected:
 
 #if !RELEASE_LOG_DISABLED
     // LoggerHelper API
-    const Logger& logger() const final;
+    const Logger& logger() const final { return m_logger.get(); }
     const void* logIdentifier() const final { return m_logIdentifier; }
     const char* logClassName() const final { return "RealtimeOutgoingVideoSource"; }
     WTFLogChannel& logChannel() const final;
@@ -145,8 +141,10 @@ private:
     uint32_t m_height { 0 };
 
 #if !RELEASE_LOG_DISABLED
-    mutable RefPtr<const Logger> m_logger;
+    Ref<const Logger> m_logger;
     const void* m_logIdentifier;
+    MonotonicTime m_lastFrameLogTime;
+    unsigned m_frameCount { 0 };
 #endif
 };
 
index 4529e28..ada1ec3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
 #include "RealtimeMediaSourceCenter.h"
 #include "RealtimeMediaSourceSettings.h"
 #include "RemoteVideoSample.h"
+#include <wtf/JSONValues.h>
 
 #if PLATFORM(COCOA)
 #include "ImageTransferSessionVT.h"
@@ -352,7 +353,7 @@ Optional<RealtimeVideoSource::CaptureSizeAndFrameRate> RealtimeVideoSource::best
 
 void RealtimeVideoSource::setSizeAndFrameRate(Optional<int> width, Optional<int> height, Optional<double> frameRate)
 {
-    Optional<RealtimeVideoSource::CaptureSizeAndFrameRate> match;
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, SizeAndFrameRate { width, height, frameRate });
 
     auto size = this->size();
     if (!width && !height && !size.isEmpty()) {
@@ -360,7 +361,7 @@ void RealtimeVideoSource::setSizeAndFrameRate(Optional<int> width, Optional<int>
         height = size.height();
     }
 
-    match = bestSupportedSizeAndFrameRate(width, height, frameRate);
+    Optional<RealtimeVideoSource::CaptureSizeAndFrameRate> match = bestSupportedSizeAndFrameRate(width, height, frameRate);
     ASSERT(match);
     if (!match)
         return;
@@ -411,6 +412,24 @@ void RealtimeVideoSource::dispatchMediaSampleToObservers(MediaSample& sample)
     videoSampleAvailable(mediaSample.releaseNonNull());
 }
 
+#if !RELEASE_LOG_DISABLED
+Ref<JSON::Object> SizeAndFrameRate::toJSONObject() const
+{
+    auto object = JSON::Object::create();
+
+    object->setDouble("width"_s, width ? width.value() : 0);
+    object->setDouble("height"_s, height ? height.value() : 0);
+    object->setDouble("frameRate"_s, frameRate ? frameRate.value() : 0);
+
+    return object;
+}
+
+String SizeAndFrameRate::toJSONString() const
+{
+    return toJSONObject()->toJSONString();
+}
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 07ded4f..ac34400 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -81,6 +81,10 @@ private:
     Optional<CaptureSizeAndFrameRate> bestSupportedSizeAndFrameRate(Optional<int> width, Optional<int> height, Optional<double>);
     bool presetSupportsFrameRate(RefPtr<VideoPreset>, double);
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "RealtimeVideoSource"; }
+#endif
+
     Vector<Ref<VideoPreset>> m_presets;
     Deque<double> m_observedFrameTimeStamps;
     double m_observedFrameRate { 0 };
@@ -90,7 +94,27 @@ private:
 #endif
 };
 
+struct SizeAndFrameRate {
+    Optional<int> width;
+    Optional<int> height;
+    Optional<double> frameRate;
+
+    String toJSONString() const;
+    Ref<JSON::Object> toJSONObject() const;
+};
+
 } // namespace WebCore
 
+namespace WTF {
+template<typename Type> struct LogArgument;
+template <>
+struct LogArgument<WebCore::SizeAndFrameRate> {
+    static String toString(const WebCore::SizeAndFrameRate& size)
+    {
+        return size.toJSONString();
+    }
+};
+}; // namespace WTF
+
 #endif // ENABLE(MEDIA_STREAM)
 
index ed9fb8b..b3c9854 100644 (file)
@@ -122,10 +122,15 @@ private:
 
 static void doReleaseLogging(rtc::LoggingSeverity severity, const char* message)
 {
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(severity);
+    UNUSED_PARAM(message);
+#else
     if (severity == rtc::LS_ERROR)
         RELEASE_LOG_ERROR(WebRTC, "LibWebRTC error: %{public}s", message);
     else
         RELEASE_LOG(WebRTC, "LibWebRTC message: %{public}s", message);
+#endif
 }
 
 static void setLogging(rtc::LoggingSeverity level)
index 26f92ff..417a73b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -73,7 +73,6 @@ private:
     AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt);
     virtual ~AVVideoCaptureSource();
 
-    void initializeSession();
     void clearSession();
 
     bool setupSession();
@@ -111,6 +110,10 @@ private:
 
     AVCaptureDevice* device() const { return m_device.get(); }
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "AVVideoCaptureSource"; }
+#endif
+
     RefPtr<MediaSample> m_buffer;
     RetainPtr<AVCaptureVideoDataOutput> m_videoOutput;
     std::unique_ptr<ImageTransferSessionVT> m_imageTransferSession;
index 9a661c7..96ed7f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -202,15 +202,9 @@ AVVideoCaptureSource::~AVVideoCaptureSource()
     clearSession();
 }
 
-void AVVideoCaptureSource::initializeSession()
-{
-    ASSERT(!m_session);
-    m_session = adoptNS([allocAVCaptureSessionInstance() init]);
-    [m_session addObserver:m_objcObserver.get() forKeyPath:@"running" options:NSKeyValueObservingOptionNew context:(void *)nil];
-}
-
 void AVVideoCaptureSource::clearSession()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     ASSERT(m_session);
     [m_session removeObserver:m_objcObserver.get() forKeyPath:@"running"];
     m_session = nullptr;
@@ -226,6 +220,7 @@ void AVVideoCaptureSource::startProducingData()
     if ([m_session isRunning])
         return;
 
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     [m_objcObserver addNotificationObservers];
     [m_session startRunning];
 }
@@ -235,6 +230,7 @@ void AVVideoCaptureSource::stopProducingData()
     if (!m_session)
         return;
 
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     [m_objcObserver removeNotificationObservers];
 
     if ([m_session isRunning])
@@ -335,6 +331,8 @@ bool AVVideoCaptureSource::prefersPreset(VideoPreset& preset)
 
 void AVVideoCaptureSource::setSizeAndFrameRateWithPreset(IntSize requestedSize, double requestedFrameRate, RefPtr<VideoPreset> preset)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, SizeAndFrameRate { requestedSize.width(), requestedSize.height(), requestedFrameRate });
+
     auto* avPreset = preset ? downcast<AVVideoPreset>(preset.get()) : nullptr;
 
     if (!m_session) {
@@ -363,6 +361,12 @@ void AVVideoCaptureSource::setSizeAndFrameRateWithPreset(IntSize requestedSize,
         if ([device() lockForConfiguration:&error]) {
             if (!m_currentPreset || ![m_currentPreset->format.get() isEqual:avPreset->format.get()]) {
                 [device() setActiveFormat:avPreset->format.get()];
+
+                frameRateRange = frameDurationForFrameRate(requestedFrameRate);
+                ASSERT(frameRateRange);
+                if (!frameRateRange)
+                    return;
+
 #if PLATFORM(MAC)
                 auto settingsDictionary = @{
                     (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(avVideoCapturePixelBufferFormat()),
@@ -373,19 +377,21 @@ void AVVideoCaptureSource::setSizeAndFrameRateWithPreset(IntSize requestedSize,
                 [m_videoOutput setVideoSettings:settingsDictionary];
 #endif
             }
+
+            ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "setting frame rate ", CMTimeGetSeconds([frameRateRange minFrameDuration]), " .. ", CMTimeGetSeconds([frameRateRange maxFrameDuration]));
             [device() setActiveVideoMinFrameDuration:[frameRateRange minFrameDuration]];
             [device() setActiveVideoMaxFrameDuration:[frameRateRange maxFrameDuration]];
             [device() unlockForConfiguration];
         }
     } @catch(NSException *exception) {
-        RELEASE_LOG(Media, "AVVideoCaptureSource::setFrameRate - exception thrown configuring device: <%s> %s", [[exception name] UTF8String], [[exception reason] UTF8String]);
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "error configuring device ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
+        return;
     }
     [m_session commitConfiguration];
 
     m_currentPreset = avPreset;
 
-    if (error)
-        RELEASE_LOG(Media, "AVVideoCaptureSource::setFrameRate - failed to lock video device for configuration: %s", [[error localizedDescription] UTF8String]);
+    ERROR_LOG_IF(error && loggerPtr(), LOGIDENTIFIER, [[error localizedDescription] UTF8String]);
 }
 
 static inline int sensorOrientation(AVCaptureVideoOrientation videoOrientation)
@@ -426,7 +432,10 @@ bool AVVideoCaptureSource::setupSession()
     if (m_session)
         return true;
 
-    initializeSession();
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
+    m_session = adoptNS([allocAVCaptureSessionInstance() init]);
+    [m_session addObserver:m_objcObserver.get() forKeyPath:@"running" options:NSKeyValueObservingOptionNew context:(void *)nil];
 
     [m_session beginConfiguration];
     bool success = setupCaptureSession();
@@ -449,13 +458,15 @@ AVFrameRateRangeType* AVVideoCaptureSource::frameDurationForFrameRate(double rat
     }
 
     if (!bestFrameRateRange)
-        RELEASE_LOG(Media, "AVVideoCaptureSource::frameDurationForFrameRate, no frame rate range for rate %g", rate);
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "no frame rate range for rate ", rate);
 
     return bestFrameRateRange;
 }
 
 bool AVVideoCaptureSource::setupCaptureSession()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
 #if PLATFORM(IOS_FAMILY)
     RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(*this);
 #endif
@@ -463,12 +474,12 @@ bool AVVideoCaptureSource::setupCaptureSession()
     NSError *error = nil;
     RetainPtr<AVCaptureDeviceInputType> videoIn = adoptNS([allocAVCaptureDeviceInputInstance() initWithDevice:device() error:&error]);
     if (error) {
-        RELEASE_LOG(Media, "AVVideoCaptureSource::setupCaptureSession(%p), failed to allocate AVCaptureDeviceInput: %s", this, [[error localizedDescription] UTF8String]);
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "failed to allocate AVCaptureDeviceInput ", [[error localizedDescription] UTF8String]);
         return false;
     }
 
     if (![session() canAddInput:videoIn.get()]) {
-        RELEASE_LOG(Media, "AVVideoCaptureSource::setupCaptureSession(%p), unable to add video input device", this);
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "unable to add video input device");
         return false;
     }
     [session() addInput:videoIn.get()];
@@ -481,7 +492,7 @@ bool AVVideoCaptureSource::setupCaptureSession()
     [m_videoOutput setSampleBufferDelegate:m_objcObserver.get() queue:globaVideoCaptureSerialQueue()];
 
     if (![session() canAddOutput:m_videoOutput.get()]) {
-        RELEASE_LOG(Media, "AVVideoCaptureSource::setupCaptureSession(%p), unable to add video sample buffer output delegate", this);
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "unable to add video output device");
         return false;
     }
     [session() addOutput:m_videoOutput.get()];
@@ -571,6 +582,7 @@ void AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection(AVCa
 void AVVideoCaptureSource::captureSessionIsRunningDidChange(bool state)
 {
     scheduleDeferredTask([this, state] {
+        ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, state);
         if ((state == m_isRunning) && (state == !muted()))
             return;
 
@@ -587,6 +599,7 @@ void AVVideoCaptureSource::captureDeviceSuspendedDidChange()
 #if !PLATFORM(IOS_FAMILY)
     scheduleDeferredTask([this] {
         auto isSuspended = [m_device isSuspended];
+        ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, !!isSuspended);
         if (isSuspended == muted())
             return;
 
@@ -629,6 +642,8 @@ void AVVideoCaptureSource::generatePresets()
 #if PLATFORM(IOS_FAMILY)
 void AVVideoCaptureSource::captureSessionRuntimeError(RetainPtr<NSError> error)
 {
+    ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, [[error localizedDescription] UTF8String]);
+
     if (!m_isRunning || error.get().code != AVErrorMediaServicesWereReset)
         return;
 
@@ -639,11 +654,14 @@ void AVVideoCaptureSource::captureSessionRuntimeError(RetainPtr<NSError> error)
 
 void AVVideoCaptureSource::captureSessionBeginInterruption(RetainPtr<NSNotification> notification)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, [notification.get().userInfo[AVCaptureSessionInterruptionReasonKey] integerValue]);
     m_interruption = static_cast<AVVideoCaptureSource::InterruptionReason>([notification.get().userInfo[AVCaptureSessionInterruptionReasonKey] integerValue]);
 }
 
 void AVVideoCaptureSource::captureSessionEndInterruption(RetainPtr<NSNotification>)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
     InterruptionReason reason = m_interruption;
 
     m_interruption = InterruptionReason::None;
@@ -657,6 +675,7 @@ void AVVideoCaptureSource::captureSessionEndInterruption(RetainPtr<NSNotificatio
 
 void AVVideoCaptureSource::deviceDisconnected(RetainPtr<NSNotification> notification)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     if (this->device() == [notification object])
         captureFailed();
 }
@@ -724,13 +743,13 @@ void AVVideoCaptureSource::deviceDisconnected(RetainPtr<NSNotification> notifica
     id newValue = [change valueForKey:NSKeyValueChangeNewKey];
 
     bool willChange = [[change valueForKey:NSKeyValueChangeNotificationIsPriorKey] boolValue];
-#if !LOG_DISABLED
 
-    if (willChange)
-        LOG(Media, "WebCoreAVVideoCaptureSourceObserver::observeValueForKeyPath(%p) - will change, keyPath = %s", self, [keyPath UTF8String]);
-    else {
+#if !RELEASE_LOG_DISABLED
+    if (m_callback->loggerPtr() && m_callback->logger().willLog(m_callback->logChannel(), WTFLogLevelDebug)) {
+        auto identifier = Logger::LogSiteIdentifier("AVVideoCaptureSource", "observeValueForKeyPath", m_callback->logIdentifier());
+
         RetainPtr<NSString> valueString = adoptNS([[NSString alloc] initWithFormat:@"%@", newValue]);
-        LOG(Media, "WebCoreAVVideoCaptureSourceObserver::observeValueForKeyPath(%p) - did change, keyPath = %s, value = %s", self, [keyPath UTF8String], [valueString.get() UTF8String]);
+        m_callback->logger().debug(m_callback->logChannel(), identifier, "did change '", [keyPath UTF8String], "' to ", [valueString.get() UTF8String]);
     }
 #endif
 
@@ -742,8 +761,6 @@ void AVVideoCaptureSource::deviceDisconnected(RetainPtr<NSNotification> notifica
 
 - (void)deviceConnectedDidChange:(NSNotification*)notification
 {
-    LOG(Media, "WebCoreAVVideoCaptureSourceObserver::deviceConnectedDidChange(%p)", self);
-
     if (m_callback)
         m_callback->deviceDisconnected(notification);
 }
@@ -752,24 +769,18 @@ void AVVideoCaptureSource::deviceDisconnected(RetainPtr<NSNotification> notifica
 - (void)sessionRuntimeError:(NSNotification*)notification
 {
     NSError *error = notification.userInfo[AVCaptureSessionErrorKey];
-    LOG(Media, "WebCoreAVVideoCaptureSourceObserver::sessionRuntimeError(%p) - error = %s", self, [[error localizedDescription] UTF8String]);
-
     if (m_callback)
         m_callback->captureSessionRuntimeError(error);
 }
 
 - (void)beginSessionInterrupted:(NSNotification*)notification
 {
-    LOG(Media, "WebCoreAVVideoCaptureSourceObserver::beginSessionInterrupted(%p) - reason = %d", self, [notification.userInfo[AVCaptureSessionInterruptionReasonKey] integerValue]);
-
     if (m_callback)
         m_callback->captureSessionBeginInterruption(notification);
 }
 
 - (void)endSessionInterrupted:(NSNotification*)notification
 {
-    LOG(Media, "WebCoreAVVideoCaptureSourceObserver::endSessionInterrupted(%p)", self);
-
     if (m_callback)
         m_callback->captureSessionEndInterruption(notification);
 }
index c71d357..c41bf7a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -235,7 +235,7 @@ void CoreAudioSharedUnit::devicesChanged(const Vector<CaptureDevice>& devices)
 void CoreAudioSharedUnit::addEchoCancellationSource(AudioSampleDataSource& source)
 {
     if (!source.setOutputFormat(m_speakerProcFormat)) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::addEchoCancellationSource: source %p configureOutput failed", &source);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::addEchoCancellationSource: source %p configureOutput failed", &source);
         return;
     }
 
@@ -269,7 +269,7 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
     AudioComponent ioComponent = AudioComponentFindNext(nullptr, &ioUnitDescription);
     ASSERT(ioComponent);
     if (!ioComponent) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to find vpio unit component", this);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to find vpio unit component", this);
         return -1;
     }
 
@@ -279,13 +279,13 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
     if (name) {
         m_ioUnitName = name;
         CFRelease(name);
-        RELEASE_LOG(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) created \"%s\" component", this, m_ioUnitName.utf8().data());
+        RELEASE_LOG(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) created \"%s\" component", this, m_ioUnitName.utf8().data());
     }
 #endif
 
     auto err = AudioComponentInstanceNew(ioComponent, &m_ioUnit);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to open vpio unit, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to open vpio unit, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -293,13 +293,13 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
         uint32_t param = 0;
         err = AudioUnitSetProperty(m_ioUnit, kAUVoiceIOProperty_VoiceProcessingEnableAGC, kAudioUnitScope_Global, inputBus, &param, sizeof(param));
         if (err) {
-            RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to set vpio automatic gain control, error %d (%.4s)", this, (int)err, (char*)&err);
+            RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to set vpio automatic gain control, error %d (%.4s)", this, (int)err, (char*)&err);
             return err;
         }
         param = 1;
         err = AudioUnitSetProperty(m_ioUnit, kAUVoiceIOProperty_BypassVoiceProcessing, kAudioUnitScope_Global, inputBus, &param, sizeof(param));
         if (err) {
-            RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to set vpio unit echo cancellation, error %d (%.4s)", this, (int)err, (char*)&err);
+            RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to set vpio unit echo cancellation, error %d (%.4s)", this, (int)err, (char*)&err);
             return err;
         }
     }
@@ -308,7 +308,7 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
     uint32_t param = 1;
     err = AudioUnitSetProperty(m_ioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, inputBus, &param, sizeof(param));
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to enable vpio unit input, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to enable vpio unit input, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 #else
@@ -320,7 +320,7 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
 
     err = AudioUnitSetProperty(m_ioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, inputBus, &m_captureDeviceID, sizeof(m_captureDeviceID));
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) unable to set vpio unit capture device ID, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to set vpio unit capture device ID, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 #endif
@@ -335,7 +335,7 @@ OSStatus CoreAudioSharedUnit::setupAudioUnit()
 
     err = AudioUnitInitialize(m_ioUnit);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioCaptureSource::setupAudioUnit(%p) AudioUnitInitialize() failed, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) AudioUnitInitialize() failed, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
     m_ioUnitInitialized = true;
@@ -358,7 +358,7 @@ OSStatus CoreAudioSharedUnit::configureMicrophoneProc()
     AURenderCallbackStruct callback = { microphoneCallback, this };
     auto err = AudioUnitSetProperty(m_ioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, inputBus, &callback, sizeof(callback));
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to set vpio unit mic proc, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to set vpio unit mic proc, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -367,14 +367,14 @@ OSStatus CoreAudioSharedUnit::configureMicrophoneProc()
     UInt32 size = sizeof(microphoneProcFormat);
     err = AudioUnitGetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, inputBus, &microphoneProcFormat, &size);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to get output stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to get output stream format, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
     microphoneProcFormat.mSampleRate = m_sampleRate;
     err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, inputBus, &microphoneProcFormat, size);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to set output stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureMicrophoneProc(%p) unable to set output stream format, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -389,7 +389,7 @@ OSStatus CoreAudioSharedUnit::configureSpeakerProc()
     AURenderCallbackStruct callback = { speakerCallback, this };
     auto err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, outputBus, &callback, sizeof(callback));
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to set vpio unit speaker proc, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to set vpio unit speaker proc, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -398,14 +398,14 @@ OSStatus CoreAudioSharedUnit::configureSpeakerProc()
     UInt32 size = sizeof(speakerProcFormat);
     err = AudioUnitGetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, outputBus, &speakerProcFormat, &size);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to get input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to get input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
     speakerProcFormat.mSampleRate = m_sampleRate;
     err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, outputBus, &speakerProcFormat, size);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to get input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::configureSpeakerProc(%p) unable to get input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -419,7 +419,7 @@ OSStatus CoreAudioSharedUnit::configureSpeakerProc()
 void CoreAudioSharedUnit::checkTimestamps(const AudioTimeStamp& timeStamp, uint64_t sampleTime, double hostTime)
 {
     if (!timeStamp.mSampleTime || sampleTime == m_latestMicTimeStamp || !hostTime)
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::checkTimestamps: unusual timestamps, sample time = %lld, previous sample time = %lld, hostTime %f", sampleTime, m_latestMicTimeStamp, hostTime);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::checkTimestamps: unusual timestamps, sample time = %lld, previous sample time = %lld, hostTime %f", sampleTime, m_latestMicTimeStamp, hostTime);
 }
 #endif
 
@@ -431,7 +431,7 @@ OSStatus CoreAudioSharedUnit::provideSpeakerData(AudioUnitRenderActionFlags& /*i
 #endif
 
     if (m_speakerSampleBuffer->sampleCapacity() < inNumberFrames) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::provideSpeakerData: speaker sample buffer size (%d) too small for amount of sample data requested (%d)!", m_speakerSampleBuffer->sampleCapacity(), (int)inNumberFrames);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::provideSpeakerData: speaker sample buffer size (%d) too small for amount of sample data requested (%d)!", m_speakerSampleBuffer->sampleCapacity(), (int)inNumberFrames);
         return kAudio_ParamError;
     }
 
@@ -494,7 +494,7 @@ OSStatus CoreAudioSharedUnit::processMicrophoneSamples(AudioUnitRenderActionFlag
     AudioBufferList& bufferList = m_microphoneSampleBuffer->bufferList();
     auto err = AudioUnitRender(m_ioUnit, &ioActionFlags, &timeStamp, inBusNumber, inNumberFrames, &bufferList);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::processMicrophoneSamples(%p) AudioUnitRender failed with error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::processMicrophoneSamples(%p) AudioUnitRender failed with error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -530,7 +530,7 @@ void CoreAudioSharedUnit::cleanupAudioUnit()
         ASSERT(m_ioUnit);
         auto err = AudioUnitUninitialize(m_ioUnit);
         if (err)
-            RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::cleanupAudioUnit(%p) AudioUnitUninitialize failed with error %d (%.4s)", this, (int)err, (char*)&err);
+            RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::cleanupAudioUnit(%p) AudioUnitUninitialize failed with error %d (%.4s)", this, (int)err, (char*)&err);
         m_ioUnitInitialized = false;
     }
 
@@ -555,7 +555,7 @@ OSStatus CoreAudioSharedUnit::reconfigureAudioUnit()
     if (m_ioUnitStarted) {
         err = AudioOutputUnitStop(m_ioUnit);
         if (err) {
-            RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::reconfigureAudioUnit(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err);
+            RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::reconfigureAudioUnit(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err);
             return err;
         }
     }
@@ -568,7 +568,7 @@ OSStatus CoreAudioSharedUnit::reconfigureAudioUnit()
     if (m_ioUnitStarted) {
         err = AudioOutputUnitStart(m_ioUnit);
         if (err) {
-            RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::reconfigureAudioUnit(%p) AudioOutputUnitStart failed with error %d (%.4s)", this, (int)err, (char*)&err);
+            RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::reconfigureAudioUnit(%p) AudioOutputUnitStart failed with error %d (%.4s)", this, (int)err, (char*)&err);
             return err;
         }
     }
@@ -627,7 +627,7 @@ OSStatus CoreAudioSharedUnit::startInternal()
 
     err = AudioOutputUnitStart(m_ioUnit);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::start(%p) AudioOutputUnitStart failed with error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::start(%p) AudioOutputUnitStart failed with error %d (%.4s)", this, (int)err, (char*)&err);
         return err;
     }
 
@@ -649,14 +649,13 @@ void CoreAudioSharedUnit::verifyIsCapturing()
         return;
     }
 
+    RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::verifyIsCapturing - no audio received in %d seconds, failing", static_cast<int>(m_verifyCapturingTimer.repeatInterval().value()));
     captureFailed();
 }
 
 void CoreAudioSharedUnit::captureFailed()
 {
-#if !RELEASE_LOG_DISABLED
-    RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::captureFailed - capture failed");
-#endif
+    RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::captureFailed - capture failed");
     for (CoreAudioCaptureSource& client : m_clients)
         client.captureFailed();
 
@@ -697,7 +696,7 @@ void CoreAudioSharedUnit::stopInternal()
 
     auto err = AudioOutputUnitStop(m_ioUnit);
     if (err) {
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::stop(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::stop(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err);
         return;
     }
 
@@ -711,7 +710,7 @@ OSStatus CoreAudioSharedUnit::defaultInputDevice(uint32_t* deviceID)
     UInt32 propertySize = sizeof(*deviceID);
     auto err = AudioUnitGetProperty(m_ioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, inputBus, deviceID, &propertySize);
     if (err)
-        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::defaultInputDevice(%p) unable to get default input device ID, error %d (%.4s)", this, (int)err, (char*)&err);
+        RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::defaultInputDevice(%p) unable to get default input device ID, error %d (%.4s)", this, (int)err, (char*)&err);
 
     return err;
 }
@@ -836,6 +835,7 @@ void CoreAudioCaptureSource::initializeToStartProducingData()
     if (m_isReadyToStart)
         return;
 
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     m_isReadyToStart = true;
 
     auto& unit = CoreAudioSharedUnit::singleton();
@@ -866,11 +866,13 @@ CoreAudioCaptureSource::~CoreAudioCaptureSource()
 
 void CoreAudioCaptureSource::addEchoCancellationSource(AudioSampleDataSource& source)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     CoreAudioSharedUnit::singleton().addEchoCancellationSource(source);
 }
 
 void CoreAudioCaptureSource::removeEchoCancellationSource(AudioSampleDataSource& source)
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     CoreAudioSharedUnit::singleton().removeEchoCancellationSource(source);
 }
 
@@ -881,7 +883,11 @@ void CoreAudioCaptureSource::startProducingData()
 #endif
 
     auto& unit = CoreAudioSharedUnit::singleton();
-    if (unit.isSuspended()) {
+
+    auto isSuspended = unit.isSuspended();
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, isSuspended);
+
+    if (isSuspended) {
         m_suspendType = SuspensionType::WhilePlaying;
         return;
     }
@@ -894,7 +900,10 @@ void CoreAudioCaptureSource::stopProducingData()
 {
     auto& unit = CoreAudioSharedUnit::singleton();
 
-    if (unit.isSuspended()) {
+    auto isSuspended = unit.isSuspended();
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, isSuspended);
+
+    if (isSuspended) {
         m_suspendType = SuspensionType::WhilePaused;
         return;
     }
@@ -953,6 +962,8 @@ void CoreAudioCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSett
 
 void CoreAudioCaptureSource::scheduleReconfiguration()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
     ASSERT(isMainThread());
     auto& unit = CoreAudioSharedUnit::singleton();
     if (!unit.hasAudioUnit() || m_reconfigurationState != ReconfigurationState::None)
@@ -972,6 +983,8 @@ void CoreAudioCaptureSource::scheduleReconfiguration()
 
 void CoreAudioCaptureSource::beginInterruption()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
     ASSERT(isMainThread());
     auto& unit = CoreAudioSharedUnit::singleton();
     if (!unit.hasAudioUnit() || unit.isSuspended() || m_suspendPending)
@@ -988,6 +1001,8 @@ void CoreAudioCaptureSource::beginInterruption()
 
 void CoreAudioCaptureSource::endInterruption()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
     ASSERT(isMainThread());
     auto& unit = CoreAudioSharedUnit::singleton();
     if (!unit.hasAudioUnit() || !unit.isSuspended() || m_resumePending)
index 5644272..b3ea782 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -95,6 +95,10 @@ private:
 
     void initializeToStartProducingData();
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "CoreAudioCaptureSource"; }
+#endif
+
     uint32_t m_captureDeviceID { 0 };
 
     Optional<RealtimeMediaSourceCapabilities> m_capabilities;
index 04b8d8c..b82feaf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,7 +66,11 @@ private:
 
     bool createDisplayStream();
     void startDisplayStream();
-    
+
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "ScreenDisplayCaptureSourceMac"; }
+#endif
+
     class DisplaySurface {
     public:
         DisplaySurface() = default;
index 1e8ac6c..f6d631e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -115,15 +115,18 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
 {
     static const int screenQueueMaximumLength = 6;
 
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
+
     auto actualDisplayID = updateDisplayID(m_displayID);
     if (!actualDisplayID) {
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "invalid display ID: ", m_displayID);
         captureFailed();
         return false;
     }
 
     if (m_displayID != actualDisplayID.value()) {
         m_displayID = actualDisplayID.value();
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: display ID changed to %d", static_cast<int>(m_displayID));
+        ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "display ID changed to ", static_cast<int>(m_displayID));
         m_displayStream = nullptr;
     }
 
@@ -132,7 +135,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
         auto screenWidth = CGDisplayModeGetPixelsWide(displayMode.get());
         auto screenHeight = CGDisplayModeGetPixelsHigh(displayMode.get());
         if (!screenWidth || !screenHeight) {
-            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: unable to get screen width/height");
+            ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "unable to get screen width/height");
             captureFailed();
             return false;
         }
@@ -158,7 +161,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
 
         m_displayStream = adoptCF(CGDisplayStreamCreateWithDispatchQueue(m_displayID, screenWidth, screenHeight, preferedPixelBufferFormat(), (__bridge CFDictionaryRef)streamOptions, m_captureQueue.get(), frameAvailableBlock));
         if (!m_displayStream) {
-            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: CGDisplayStreamCreate failed");
+            ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "CGDisplayStreamCreate failed");
             captureFailed();
             return false;
         }
@@ -174,6 +177,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
 
 void ScreenDisplayCaptureSourceMac::startProducingData()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     DisplayCaptureSourceCocoa::startProducingData();
 
     if (m_isRunning)
@@ -184,6 +188,7 @@ void ScreenDisplayCaptureSourceMac::startProducingData()
 
 void ScreenDisplayCaptureSourceMac::stopProducingData()
 {
+    ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
     DisplayCaptureSourceCocoa::stopProducingData();
 
     if (!m_isRunning)
@@ -214,7 +219,7 @@ void ScreenDisplayCaptureSourceMac::startDisplayStream()
 
     if (m_displayID != actualDisplayID.value()) {
         m_displayID = actualDisplayID.value();
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream: display ID changed to %d", static_cast<int>(m_displayID));
+        ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "display ID changed to ", static_cast<int>(m_displayID));
     }
 
     if (!m_displayStream && !createDisplayStream())
@@ -222,7 +227,7 @@ void ScreenDisplayCaptureSourceMac::startDisplayStream()
 
     auto err = CGDisplayStreamStart(m_displayStream.get());
     if (err) {
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream: CGDisplayStreamStart failed with error %d", static_cast<int>(err));
+        ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "CGDisplayStreamStart failed with error ", static_cast<int>(err));
         captureFailed();
         return;
     }