Diff
Modified: trunk/Source/WebCore/ChangeLog (222270 => 222271)
--- trunk/Source/WebCore/ChangeLog 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/ChangeLog 2017-09-20 17:55:27 UTC (rev 222271)
@@ -1,3 +1,75 @@
+2017-09-20 Eric Carlson <[email protected]>
+
+ Switch PeerConnection to release logging
+ https://bugs.webkit.org/show_bug.cgi?id=177193
+ <rdar://problem/34529014>
+
+ Reviewed by Youenn Fablet.
+
+ * Modules/mediastream/PeerConnectionBackend.cpp:
+ (WebCore::PeerConnectionBackend::PeerConnectionBackend):
+ (WebCore::PeerConnectionBackend::createOfferSucceeded):
+ (WebCore::PeerConnectionBackend::createOfferFailed):
+ (WebCore::PeerConnectionBackend::createAnswerSucceeded):
+ (WebCore::PeerConnectionBackend::createAnswerFailed):
+ (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
+ (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
+ (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
+ (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
+ (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
+ (WebCore::PeerConnectionBackend::addIceCandidateFailed):
+ (WebCore::PeerConnectionBackend::newICECandidate):
+ (WebCore::PeerConnectionBackend::doneGatheringCandidates):
+ (WebCore::PeerConnectionBackend::logChannel const):
+ * Modules/mediastream/PeerConnectionBackend.h:
+ (WebCore::PeerConnectionBackend::PeerConnectionBackend): Deleted.
+
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::RTCPeerConnection):
+ (WebCore::RTCPeerConnection::~RTCPeerConnection):
+ (WebCore::RTCPeerConnection::addTrack):
+ (WebCore::RTCPeerConnection::removeTrack):
+ (WebCore::RTCPeerConnection::addTransceiver):
+ (WebCore::RTCPeerConnection::queuedCreateOffer):
+ (WebCore::RTCPeerConnection::queuedCreateAnswer):
+ (WebCore::RTCPeerConnection::queuedSetLocalDescription):
+ (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
+ (WebCore::RTCPeerConnection::queuedAddIceCandidate):
+ (WebCore::RTCPeerConnection::initializeConfiguration):
+ (WebCore::RTCPeerConnection::setConfiguration):
+ (WebCore::RTCPeerConnection::createDataChannel):
+ (WebCore::RTCPeerConnection::setSignalingState):
+ (WebCore::RTCPeerConnection::updateIceGatheringState):
+ (WebCore::RTCPeerConnection::updateIceConnectionState):
+ (WebCore::RTCPeerConnection::updateConnectionState):
+ (WebCore::RTCPeerConnection::replaceTrack):
+ (WebCore::RTCPeerConnection::dispatchEvent):
+ (WebCore::RTCPeerConnection::logChannel const):
+ (WebCore::rtcIceGatheringStateToString): Deleted.
+ (WebCore::rtcIceConnectionStateToString): Deleted.
+ * Modules/mediastream/RTCPeerConnection.h:
+
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
+ (WebCore::LibWebRTCMediaEndpoint::OnStatsDelivered):
+ (WebCore::LibWebRTCMediaEndpoint::startLoggingStats):
+ (WebCore::LibWebRTCMediaEndpoint::logChannel const):
+ (WebCore::LibWebRTCMediaEndpoint::statsLogInterval const):
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+ (PAL::LogArgument<webrtc::RTCStats>::toString):
+
+ * platform/mediastream/RTCIceConnectionState.h:
+ (PAL::LogArgument<WebCore::RTCIceConnectionState>::toString):
+
+ * platform/mediastream/RTCIceGatheringState.h:
+ (PAL::LogArgument<WebCore::RTCIceGatheringState>::toString):
+
+ * platform/mediastream/RTCPeerConnectionState.h:
+ (PAL::LogArgument<WebCore::RTCPeerConnectionState>::toString):
+
+ * platform/mediastream/RTCSignalingState.h:
+ (PAL::LogArgument<WebCore::RTCSignalingState>::toString):
+
2017-09-20 Chris Dumez <[email protected]>
Video errors should be instances of Error
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2017-09-20 17:55:27 UTC (rev 222271)
@@ -44,6 +44,17 @@
namespace WebCore {
+using namespace PAL;
+
+PeerConnectionBackend::PeerConnectionBackend(RTCPeerConnection& peerConnection)
+ : m_peerConnection(peerConnection)
+#if !RELEASE_LOG_DISABLED
+ , m_logger(peerConnection.logger())
+ , m_logIdentifier(peerConnection.logIdentifier())
+#endif
+{
+}
+
void PeerConnectionBackend::createOffer(RTCOfferOptions&& options, PeerConnection::SessionDescriptionPromise&& promise)
{
ASSERT(!m_offerAnswerPromise);
@@ -56,7 +67,7 @@
void PeerConnectionBackend::createOfferSucceeded(String&& sdp)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Creating offer succeeded:\n%{public}s\n", sdp.utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Create offer succeeded:\n", sdp);
if (m_peerConnection.isClosed())
return;
@@ -69,7 +80,7 @@
void PeerConnectionBackend::createOfferFailed(Exception&& exception)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Creating offer failed:\n%{public}s\n", exception.message().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Create offer failed:", exception.message());
if (m_peerConnection.isClosed())
return;
@@ -91,7 +102,7 @@
void PeerConnectionBackend::createAnswerSucceeded(String&& sdp)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Creating answer succeeded:\n%{public}s\n", sdp.utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Create answer succeeded:\n", sdp);
if (m_peerConnection.isClosed())
return;
@@ -104,7 +115,7 @@
void PeerConnectionBackend::createAnswerFailed(Exception&& exception)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Creating answer failed:\n%{public}s\n", exception.message().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Create answer failed:", exception.message());
if (m_peerConnection.isClosed())
return;
@@ -149,7 +160,7 @@
void PeerConnectionBackend::setLocalDescriptionSucceeded()
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Setting local description succeeded\n");
+ ALWAYS_LOG(LOGIDENTIFIER);
if (m_peerConnection.isClosed())
return;
@@ -163,7 +174,7 @@
void PeerConnectionBackend::setLocalDescriptionFailed(Exception&& exception)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Setting local description failed:\n%{public}s\n", exception.message().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Set local description failed:", exception.message());
if (m_peerConnection.isClosed())
return;
@@ -209,7 +220,7 @@
void PeerConnectionBackend::setRemoteDescriptionSucceeded()
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Setting remote description succeeded\n");
+ ALWAYS_LOG(LOGIDENTIFIER, "Set remote description succeeded");
if (m_peerConnection.isClosed())
return;
@@ -223,7 +234,7 @@
void PeerConnectionBackend::setRemoteDescriptionFailed(Exception&& exception)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Setting remote description failed:\n%{public}s\n", exception.message().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Set remote description failed:", exception.message());
if (m_peerConnection.isClosed())
return;
@@ -255,7 +266,7 @@
void PeerConnectionBackend::addIceCandidateSucceeded()
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Adding ice candidate succeeded\n");
+ ALWAYS_LOG(LOGIDENTIFIER, "Adding ice candidate succeeded");
if (m_peerConnection.isClosed())
return;
@@ -270,7 +281,7 @@
void PeerConnectionBackend::addIceCandidateFailed(Exception&& exception)
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Adding ice candidate failed:\n%{public}s\n", exception.message().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Adding ice candidate failed:", exception.message());
if (m_peerConnection.isClosed())
return;
@@ -349,7 +360,7 @@
void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex)
{
- RELEASE_LOG(WebRTC, "Gathered ice candidate:\n%{public}s\n", sdp.utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Gathered ice candidate:", sdp);
if (!m_shouldFilterICECandidates) {
fireICECandidateEvent(RTCIceCandidate::create(WTFMove(sdp), WTFMove(mid), sdpMLineIndex));
@@ -365,7 +376,7 @@
void PeerConnectionBackend::doneGatheringCandidates()
{
ASSERT(isMainThread());
- RELEASE_LOG(WebRTC, "Finished ice candidate gathering\n");
+ ALWAYS_LOG(LOGIDENTIFIER, "Finished ice candidate gathering");
m_peerConnection.fireEvent(RTCPeerConnectionIceEvent::create(false, false, nullptr));
m_peerConnection.updateIceGatheringState(RTCIceGatheringState::Complete);
@@ -401,6 +412,13 @@
m_peerConnection.scheduleNegotiationNeededEvent();
}
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& PeerConnectionBackend::logChannel() const
+{
+ return LogWebRTC;
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -37,6 +37,8 @@
#include "RTCRtpParameters.h"
#include "RTCSessionDescription.h"
#include "RTCSignalingState.h"
+#include <pal/Logger.h>
+#include <pal/LoggerHelper.h>
namespace WebCore {
@@ -63,11 +65,15 @@
using CreatePeerConnectionBackend = std::unique_ptr<PeerConnectionBackend> (*)(RTCPeerConnection&);
-class PeerConnectionBackend {
+class PeerConnectionBackend
+#if !RELEASE_LOG_DISABLED
+ : public PAL::LoggerHelper
+#endif
+{
public:
WEBCORE_EXPORT static CreatePeerConnectionBackend create;
- PeerConnectionBackend(RTCPeerConnection& peerConnection) : m_peerConnection(peerConnection) { }
+ explicit PeerConnectionBackend(RTCPeerConnection&);
virtual ~PeerConnectionBackend() { }
void createOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&);
@@ -113,6 +119,13 @@
virtual void applyRotationForOutgoingVideoSources() { }
+#if !RELEASE_LOG_DISABLED
+ const PAL::Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const final { return m_logIdentifier; }
+ const char* logClassName() const override { return "PeerConnectionBackend"; }
+ WTFLogChannel& logChannel() const final;
+#endif
+
protected:
void fireICECandidateEvent(RefPtr<RTCIceCandidate>&&);
void doneGatheringCandidates();
@@ -162,6 +175,10 @@
};
Vector<PendingICECandidate> m_pendingICECandidates;
+#if !RELEASE_LOG_DISABLED
+ Ref<const PAL::Logger> m_logger;
+ const void* m_logIdentifier;
+#endif
bool m_negotiationNeeded { false };
};
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2017-09-20 17:55:27 UTC (rev 222271)
@@ -52,6 +52,7 @@
#include "RTCPeerConnectionIceEvent.h"
#include "RTCSessionDescription.h"
#include "RTCTrackEvent.h"
+#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/MainThread.h>
#include <wtf/UUID.h>
#include <wtf/text/Base64.h>
@@ -81,8 +82,13 @@
RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
: ActiveDOMObject(&context)
+#if !RELEASE_LOG_DISABLED
+ , m_logger(downcast<Document>(context).logger())
+ , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
+#endif
, m_backend(PeerConnectionBackend::create(*this))
{
+ ALWAYS_LOG(LOGIDENTIFIER);
if (!m_backend)
m_connectionState = RTCPeerConnectionState::Closed;
}
@@ -89,6 +95,7 @@
RTCPeerConnection::~RTCPeerConnection()
{
+ ALWAYS_LOG(LOGIDENTIFIER);
unregisterFromController();
stop();
}
@@ -106,6 +113,8 @@
ExceptionOr<Ref<RTCRtpSender>> RTCPeerConnection::addTrack(Ref<MediaStreamTrack>&& track, const Vector<std::reference_wrapper<MediaStream>>& streams)
{
+ INFO_LOG(LOGIDENTIFIER);
+
if (isClosed())
return Exception { InvalidStateError };
@@ -160,6 +169,8 @@
ExceptionOr<void> RTCPeerConnection::removeTrack(RTCRtpSender& sender)
{
+ INFO_LOG(LOGIDENTIFIER);
+
if (isClosed())
return Exception { InvalidStateError };
@@ -184,6 +195,8 @@
ExceptionOr<Ref<RTCRtpTransceiver>> RTCPeerConnection::addTransceiver(AddTransceiverTrackOrKind&& withTrack, const RTCRtpTransceiverInit& init)
{
+ INFO_LOG(LOGIDENTIFIER);
+
if (WTF::holds_alternative<String>(withTrack)) {
const String& kind = WTF::get<String>(withTrack);
if (kind != "audio" && kind != "video")
@@ -218,7 +231,7 @@
void RTCPeerConnection::queuedCreateOffer(RTCOfferOptions&& options, SessionDescriptionPromise&& promise)
{
- RELEASE_LOG(WebRTC, "Creating offer\n");
+ ALWAYS_LOG(LOGIDENTIFIER);
if (isClosed()) {
promise.reject(InvalidStateError);
return;
@@ -229,7 +242,7 @@
void RTCPeerConnection::queuedCreateAnswer(RTCAnswerOptions&& options, SessionDescriptionPromise&& promise)
{
- RELEASE_LOG(WebRTC, "Creating answer\n");
+ ALWAYS_LOG(LOGIDENTIFIER);
if (isClosed()) {
promise.reject(InvalidStateError);
return;
@@ -240,7 +253,7 @@
void RTCPeerConnection::queuedSetLocalDescription(RTCSessionDescription& description, DOMPromiseDeferred<void>&& promise)
{
- RELEASE_LOG(WebRTC, "Setting local description:\n%{public}s\n", description.sdp().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Setting local description to:\n", description.sdp());
if (isClosed()) {
promise.reject(InvalidStateError);
return;
@@ -266,7 +279,7 @@
void RTCPeerConnection::queuedSetRemoteDescription(RTCSessionDescription& description, DOMPromiseDeferred<void>&& promise)
{
- RELEASE_LOG(WebRTC, "Setting remote description:\n%{public}s\n", description.sdp().utf8().data());
+ ALWAYS_LOG(LOGIDENTIFIER, "Setting remote description to:\n", description.sdp());
if (isClosed()) {
promise.reject(InvalidStateError);
@@ -292,7 +305,7 @@
void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOMPromiseDeferred<void>&& promise)
{
- RELEASE_LOG(WebRTC, "Received ice candidate:\n%{public}s\n", rtcCandidate ? rtcCandidate->candidate().utf8().data() : "null");
+ ALWAYS_LOG(LOGIDENTIFIER, "Received ice candidate:\n", rtcCandidate ? rtcCandidate->candidate() : "null");
if (isClosed()) {
promise.reject(InvalidStateError);
@@ -329,6 +342,8 @@
ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&& configuration)
{
+ INFO_LOG(LOGIDENTIFIER);
+
auto servers = iceServersFromConfiguration(configuration);
if (!servers)
return Exception { InvalidAccessError };
@@ -346,6 +361,8 @@
if (isClosed())
return Exception { InvalidStateError };
+ INFO_LOG(LOGIDENTIFIER);
+
auto servers = iceServersFromConfiguration(configuration);
if (!servers)
return Exception { InvalidAccessError };
@@ -364,6 +381,8 @@
ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(ScriptExecutionContext& context, String&& label, RTCDataChannelInit&& options)
{
+ ALWAYS_LOG(LOGIDENTIFIER);
+
if (isClosed())
return Exception { InvalidStateError };
@@ -465,31 +484,19 @@
void RTCPeerConnection::addTransceiver(Ref<RTCRtpTransceiver>&& transceiver)
{
+ INFO_LOG(LOGIDENTIFIER);
m_transceiverSet->append(WTFMove(transceiver));
}
void RTCPeerConnection::setSignalingState(RTCSignalingState newState)
{
+ ALWAYS_LOG(LOGIDENTIFIER, newState);
m_signalingState = newState;
}
-#if !RELEASE_LOG_DISABLED
-static inline const char* rtcIceGatheringStateToString(RTCIceGatheringState newState)
-{
- switch (newState) {
- case RTCIceGatheringState::New:
- return "new";
- case RTCIceGatheringState::Gathering:
- return "gathering";
- case RTCIceGatheringState::Complete:
- return "complete";
- }
-}
-#endif
-
void RTCPeerConnection::updateIceGatheringState(RTCIceGatheringState newState)
{
- RELEASE_LOG(WebRTC, "New ICE gathering state: %{public}s\n", rtcIceGatheringStateToString(newState));
+ ALWAYS_LOG(LOGIDENTIFIER, newState);
scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
if (protectedThis->isClosed() || protectedThis->m_iceGatheringState == newState)
@@ -501,31 +508,9 @@
});
}
-#if !RELEASE_LOG_DISABLED
-static inline const char* rtcIceConnectionStateToString(RTCIceConnectionState newState)
-{
- switch (newState) {
- case RTCIceConnectionState::New:
- return "new";
- case RTCIceConnectionState::Checking:
- return "checking";
- case RTCIceConnectionState::Connected:
- return "connected";
- case RTCIceConnectionState::Completed:
- return "completed";
- case RTCIceConnectionState::Failed:
- return "failed";
- case RTCIceConnectionState::Disconnected:
- return "disconnected";
- case RTCIceConnectionState::Closed:
- return "closed";
- }
-}
-#endif
-
void RTCPeerConnection::updateIceConnectionState(RTCIceConnectionState newState)
{
- RELEASE_LOG(WebRTC, "New ICE connection state: %{public}s\n", rtcIceConnectionStateToString(newState));
+ ALWAYS_LOG(LOGIDENTIFIER, newState);
scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
if (protectedThis->isClosed() || protectedThis->m_iceConnectionState == newState)
@@ -560,6 +545,8 @@
if (state == m_connectionState)
return;
+ INFO_LOG(LOGIDENTIFIER, "state changed from: " , m_connectionState, " to ", state);
+
m_connectionState = state;
dispatchEvent(Event::create(eventNames().connectionstatechangeEvent, false, false));
}
@@ -594,6 +581,8 @@
void RTCPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromiseDeferred<void>&& promise)
{
+ INFO_LOG(LOGIDENTIFIER);
+
if (!withTrack) {
scriptExecutionContext()->postTask([protectedSender = makeRef(sender), promise = WTFMove(promise)](ScriptExecutionContext&) mutable {
protectedSender->setTrackToNull();
@@ -615,6 +604,19 @@
return m_backend->getParameters(sender);
}
+bool RTCPeerConnection::dispatchEvent(Event& event)
+{
+ DEBUG_LOG(LOGIDENTIFIER, "dispatching '", event.type(), "'");
+ return EventTarget::dispatchEvent(event);
+}
+
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& RTCPeerConnection::logChannel() const
+{
+ return LogWebRTC;
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -45,6 +45,7 @@
#include "RTCPeerConnectionState.h"
#include "RTCRtpTransceiver.h"
#include "RTCSignalingState.h"
+#include <pal/LoggerHelper.h>
namespace WebCore {
@@ -63,7 +64,15 @@
RTCRtpTransceiverDirection direction;
};
-class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public RTCRtpSender::Backend, public EventTargetWithInlineData, public ActiveDOMObject {
+class RTCPeerConnection final
+ : public RefCounted<RTCPeerConnection>
+ , public RTCRtpSender::Backend
+ , public EventTargetWithInlineData
+ , public ActiveDOMObject
+#if !RELEASE_LOG_DISABLED
+ , public PAL::LoggerHelper
+#endif
+{
public:
static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
virtual ~RTCPeerConnection();
@@ -150,6 +159,13 @@
// ActiveDOMObject.
bool hasPendingActivity() const final;
+#if !RELEASE_LOG_DISABLED
+ const PAL::Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const final { return m_logIdentifier; }
+ const char* logClassName() const final { return "RTCPeerConnection"; }
+ WTFLogChannel& logChannel() const final;
+#endif
+
private:
RTCPeerConnection(ScriptExecutionContext&);
@@ -165,6 +181,7 @@
// EventTarget implementation.
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
+ bool dispatchEvent(Event&) final;
// ActiveDOMObject
WEBCORE_EXPORT void stop() final;
@@ -186,6 +203,11 @@
RTCIceConnectionState m_iceConnectionState { RTCIceConnectionState::New };
RTCPeerConnectionState m_connectionState { RTCPeerConnectionState::New };
+#if !RELEASE_LOG_DISABLED
+ Ref<const PAL::Logger> m_logger;
+ const void* m_logIdentifier;
+#endif
+
std::unique_ptr<RtpTransceiverSet> m_transceiverSet { std::unique_ptr<RtpTransceiverSet>(new RtpTransceiverSet()) };
std::unique_ptr<PeerConnectionBackend> m_backend;
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2017-09-20 17:55:27 UTC (rev 222271)
@@ -63,6 +63,10 @@
, m_setLocalSessionDescriptionObserver(*this)
, m_setRemoteSessionDescriptionObserver(*this)
, m_statsLogTimer(*this, &LibWebRTCMediaEndpoint::gatherStatsForLogging)
+#if !RELEASE_LOG_DISABLED
+ , m_logger(peerConnection.logger())
+ , m_logIdentifier(peerConnection.logIdentifier())
+#endif
{
ASSERT(client.factory());
}
@@ -1065,20 +1069,23 @@
void LibWebRTCMediaEndpoint::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report)
{
- if (!m_statsTimestamp)
- m_statsTimestamp = report->timestamp_us();
- else if (m_statsLogTimer.repeatInterval() == 2_s && (report->timestamp_us() - m_statsTimestamp) > 15000000) {
- callOnMainThread([protectedThis = makeRef(*this)] {
- protectedThis->m_statsLogTimer.augmentRepeatInterval(9_s);
+#if !RELEASE_LOG_DISABLED
+ int64_t timestamp = report->timestamp_us();
+ if (!m_statsFirstDeliveredTimestamp)
+ m_statsFirstDeliveredTimestamp = timestamp;
+
+ if (m_statsLogTimer.repeatInterval() != statsLogInterval(timestamp)) {
+ callOnMainThread([protectedThis = makeRef(*this), this, timestamp] {
+ m_statsLogTimer.stop();
+ m_statsLogTimer.startRepeating(statsLogInterval(timestamp));
});
}
-#if !RELEASE_LOG_DISABLED
- // Log stats once every second for the 30 seconds, then drop to once every 5 seconds.
for (auto iterator = report->begin(); iterator != report->end(); ++iterator) {
if (iterator->type() == webrtc::RTCCodecStats::kType)
continue;
- RELEASE_LOG(WebRTC, "WebRTC stats for %p: %{public}s", this, iterator->ToString().c_str());
+
+ ALWAYS_LOG(LOGIDENTIFIER, "WebRTC stats for :", *iterator);
}
#else
UNUSED_PARAM(report);
@@ -1090,7 +1097,7 @@
#if !RELEASE_LOG_DISABLED
if (m_statsLogTimer.isActive())
m_statsLogTimer.stop();
- m_statsLogTimer.startRepeating(2_s);
+ m_statsLogTimer.startRepeating(statsLogInterval(0));
#endif
}
@@ -1099,6 +1106,24 @@
m_statsLogTimer.stop();
}
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& LibWebRTCMediaEndpoint::logChannel() const
+{
+ return LogWebRTC;
+}
+
+Seconds LibWebRTCMediaEndpoint::statsLogInterval(int64_t reportTimestamp) const
+{
+ if (logger().willLog(logChannel(), WTFLogLevelInfo))
+ return 2_s;
+
+ if (reportTimestamp - m_statsFirstDeliveredTimestamp > 15000000)
+ return 10_s;
+
+ return 4_s;
+}
+#endif
+
} // namespace WebCore
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (222270 => 222271)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -32,12 +32,12 @@
#include "RealtimeOutgoingAudioSource.h"
#include "RealtimeOutgoingVideoSource.h"
#include <Timer.h>
-
+#include <pal/Logger.h>
+#include <pal/LoggerHelper.h>
#include <webrtc/api/jsep.h>
#include <webrtc/api/peerconnectioninterface.h>
#include <webrtc/pc/peerconnectionfactory.h>
#include <webrtc/pc/rtcstatscollector.h>
-
#include <wtf/ThreadSafeRefCounted.h>
namespace webrtc {
@@ -57,7 +57,14 @@
class MediaStreamTrack;
class RTCSessionDescription;
-class LibWebRTCMediaEndpoint : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>, private webrtc::PeerConnectionObserver, private webrtc::RTCStatsCollectorCallback {
+class LibWebRTCMediaEndpoint
+ : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>
+ , private webrtc::PeerConnectionObserver
+ , private webrtc::RTCStatsCollectorCallback
+#if !RELEASE_LOG_DISABLED
+ , public PAL::LoggerHelper
+#endif
+{
public:
static Ref<LibWebRTCMediaEndpoint> create(LibWebRTCPeerConnectionBackend& peerConnection, LibWebRTCProvider& client) { return adoptRef(*new LibWebRTCMediaEndpoint(peerConnection, client)); }
virtual ~LibWebRTCMediaEndpoint() { }
@@ -126,6 +133,15 @@
bool shouldOfferAllowToReceiveAudio() const;
bool shouldOfferAllowToReceiveVideo() const;
+#if !RELEASE_LOG_DISABLED
+ const PAL::Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const final { return m_logIdentifier; }
+ const char* logClassName() const final { return "LibWebRTCMediaEndpoint"; }
+ WTFLogChannel& logChannel() const final;
+
+ Seconds statsLogInterval(int64_t) const;
+#endif
+
class CreateSessionDescriptionObserver final : public webrtc::CreateSessionDescriptionObserver {
public:
explicit CreateSessionDescriptionObserver(LibWebRTCMediaEndpoint &endpoint) : m_endpoint(endpoint) { }
@@ -194,9 +210,29 @@
bool m_isInitiator { false };
Timer m_statsLogTimer;
- int64_t m_statsTimestamp { 0 };
+
+#if !RELEASE_LOG_DISABLED
+ int64_t m_statsFirstDeliveredTimestamp { 0 };
+ Ref<const PAL::Logger> m_logger;
+ const void* m_logIdentifier;
+#endif
};
} // namespace WebCore
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<webrtc::RTCStats> {
+ static String toString(const webrtc::RTCStats& iterator)
+ {
+ return WTF::String(iterator.ToString().c_str());
+ }
+};
+
+}; // namespace PAL
+
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/platform/mediastream/RTCIceConnectionState.h (222270 => 222271)
--- trunk/Source/WebCore/platform/mediastream/RTCIceConnectionState.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/platform/mediastream/RTCIceConnectionState.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -38,6 +38,23 @@
Closed
};
+String convertEnumerationToString(RTCIceConnectionState); // in JSCRTCIceConnectionState.cpp
+
}; // namespace WebCore
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RTCIceConnectionState> {
+ static String toString(const WebCore::RTCIceConnectionState state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+}; // namespace PAL
+
#endif
Modified: trunk/Source/WebCore/platform/mediastream/RTCIceGatheringState.h (222270 => 222271)
--- trunk/Source/WebCore/platform/mediastream/RTCIceGatheringState.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/platform/mediastream/RTCIceGatheringState.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -26,6 +26,8 @@
#if ENABLE(WEB_RTC)
+#include <wtf/text/WTFString.h>
+
namespace WebCore {
enum class RTCIceGatheringState {
@@ -34,6 +36,23 @@
Complete
};
+String convertEnumerationToString(RTCIceGatheringState); // in JSCRTCIceGatheringState.cpp
+
}; // namespace WebCore
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RTCIceGatheringState> {
+ static String toString(const WebCore::RTCIceGatheringState state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+}; // namespace PAL
+
#endif
Modified: trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionState.h (222270 => 222271)
--- trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionState.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionState.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -37,6 +37,23 @@
Closed
};
+String convertEnumerationToString(RTCPeerConnectionState); // in JSCRTCPeerConnectionState.h
+
}; // namespace WebCore
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RTCPeerConnectionState> {
+ static String toString(const WebCore::RTCPeerConnectionState state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+}; // namespace PAL
+
#endif
Modified: trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h (222270 => 222271)
--- trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h 2017-09-20 17:38:28 UTC (rev 222270)
+++ trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h 2017-09-20 17:55:27 UTC (rev 222271)
@@ -36,6 +36,23 @@
HaveRemotePranswer,
};
+String convertEnumerationToString(RTCSignalingState); // in JSCRTCSignalingState.cpp
+
}; // namespace WebCore
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::RTCSignalingState> {
+ static String toString(const WebCore::RTCSignalingState state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+}; // namespace PAL
+
#endif