Changeset 222271 in webkit


Ignore:
Timestamp:
Sep 20, 2017 10:55:27 AM (7 years ago)
Author:
eric.carlson@apple.com
Message:

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):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r222270 r222271  
     12017-09-20  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Switch PeerConnection to release logging
     4        https://bugs.webkit.org/show_bug.cgi?id=177193
     5        <rdar://problem/34529014>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        * Modules/mediastream/PeerConnectionBackend.cpp:
     10        (WebCore::PeerConnectionBackend::PeerConnectionBackend):
     11        (WebCore::PeerConnectionBackend::createOfferSucceeded):
     12        (WebCore::PeerConnectionBackend::createOfferFailed):
     13        (WebCore::PeerConnectionBackend::createAnswerSucceeded):
     14        (WebCore::PeerConnectionBackend::createAnswerFailed):
     15        (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
     16        (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
     17        (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
     18        (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
     19        (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
     20        (WebCore::PeerConnectionBackend::addIceCandidateFailed):
     21        (WebCore::PeerConnectionBackend::newICECandidate):
     22        (WebCore::PeerConnectionBackend::doneGatheringCandidates):
     23        (WebCore::PeerConnectionBackend::logChannel const):
     24        * Modules/mediastream/PeerConnectionBackend.h:
     25        (WebCore::PeerConnectionBackend::PeerConnectionBackend): Deleted.
     26
     27        * Modules/mediastream/RTCPeerConnection.cpp:
     28        (WebCore::RTCPeerConnection::RTCPeerConnection):
     29        (WebCore::RTCPeerConnection::~RTCPeerConnection):
     30        (WebCore::RTCPeerConnection::addTrack):
     31        (WebCore::RTCPeerConnection::removeTrack):
     32        (WebCore::RTCPeerConnection::addTransceiver):
     33        (WebCore::RTCPeerConnection::queuedCreateOffer):
     34        (WebCore::RTCPeerConnection::queuedCreateAnswer):
     35        (WebCore::RTCPeerConnection::queuedSetLocalDescription):
     36        (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
     37        (WebCore::RTCPeerConnection::queuedAddIceCandidate):
     38        (WebCore::RTCPeerConnection::initializeConfiguration):
     39        (WebCore::RTCPeerConnection::setConfiguration):
     40        (WebCore::RTCPeerConnection::createDataChannel):
     41        (WebCore::RTCPeerConnection::setSignalingState):
     42        (WebCore::RTCPeerConnection::updateIceGatheringState):
     43        (WebCore::RTCPeerConnection::updateIceConnectionState):
     44        (WebCore::RTCPeerConnection::updateConnectionState):
     45        (WebCore::RTCPeerConnection::replaceTrack):
     46        (WebCore::RTCPeerConnection::dispatchEvent):
     47        (WebCore::RTCPeerConnection::logChannel const):
     48        (WebCore::rtcIceGatheringStateToString): Deleted.
     49        (WebCore::rtcIceConnectionStateToString): Deleted.
     50        * Modules/mediastream/RTCPeerConnection.h:
     51
     52        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
     53        (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
     54        (WebCore::LibWebRTCMediaEndpoint::OnStatsDelivered):
     55        (WebCore::LibWebRTCMediaEndpoint::startLoggingStats):
     56        (WebCore::LibWebRTCMediaEndpoint::logChannel const):
     57        (WebCore::LibWebRTCMediaEndpoint::statsLogInterval const):
     58        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
     59        (PAL::LogArgument<webrtc::RTCStats>::toString):
     60
     61        * platform/mediastream/RTCIceConnectionState.h:
     62        (PAL::LogArgument<WebCore::RTCIceConnectionState>::toString):
     63
     64        * platform/mediastream/RTCIceGatheringState.h:
     65        (PAL::LogArgument<WebCore::RTCIceGatheringState>::toString):
     66
     67        * platform/mediastream/RTCPeerConnectionState.h:
     68        (PAL::LogArgument<WebCore::RTCPeerConnectionState>::toString):
     69
     70        * platform/mediastream/RTCSignalingState.h:
     71        (PAL::LogArgument<WebCore::RTCSignalingState>::toString):
     72
    1732017-09-20  Chris Dumez  <cdumez@apple.com>
    274
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp

    r219856 r222271  
    4545namespace WebCore {
    4646
     47using namespace PAL;
     48
     49PeerConnectionBackend::PeerConnectionBackend(RTCPeerConnection& peerConnection)
     50    : m_peerConnection(peerConnection)
     51#if !RELEASE_LOG_DISABLED
     52    , m_logger(peerConnection.logger())
     53    , m_logIdentifier(peerConnection.logIdentifier())
     54#endif
     55{
     56}
     57
    4758void PeerConnectionBackend::createOffer(RTCOfferOptions&& options, PeerConnection::SessionDescriptionPromise&& promise)
    4859{
     
    5768{
    5869    ASSERT(isMainThread());
    59     RELEASE_LOG(WebRTC, "Creating offer succeeded:\n%{public}s\n", sdp.utf8().data());
     70    ALWAYS_LOG(LOGIDENTIFIER, "Create offer succeeded:\n", sdp);
    6071
    6172    if (m_peerConnection.isClosed())
     
    7081{
    7182    ASSERT(isMainThread());
    72     RELEASE_LOG(WebRTC, "Creating offer failed:\n%{public}s\n", exception.message().utf8().data());
     83    ALWAYS_LOG(LOGIDENTIFIER, "Create offer failed:", exception.message());
    7384
    7485    if (m_peerConnection.isClosed())
     
    92103{
    93104    ASSERT(isMainThread());
    94     RELEASE_LOG(WebRTC, "Creating answer succeeded:\n%{public}s\n", sdp.utf8().data());
     105    ALWAYS_LOG(LOGIDENTIFIER, "Create answer succeeded:\n", sdp);
    95106
    96107    if (m_peerConnection.isClosed())
     
    105116{
    106117    ASSERT(isMainThread());
    107     RELEASE_LOG(WebRTC, "Creating answer failed:\n%{public}s\n", exception.message().utf8().data());
     118    ALWAYS_LOG(LOGIDENTIFIER, "Create answer failed:", exception.message());
    108119
    109120    if (m_peerConnection.isClosed())
     
    150161{
    151162    ASSERT(isMainThread());
    152     RELEASE_LOG(WebRTC, "Setting local description succeeded\n");
     163    ALWAYS_LOG(LOGIDENTIFIER);
    153164
    154165    if (m_peerConnection.isClosed())
     
    164175{
    165176    ASSERT(isMainThread());
    166     RELEASE_LOG(WebRTC, "Setting local description failed:\n%{public}s\n", exception.message().utf8().data());
     177    ALWAYS_LOG(LOGIDENTIFIER, "Set local description failed:", exception.message());
    167178
    168179    if (m_peerConnection.isClosed())
     
    210221{
    211222    ASSERT(isMainThread());
    212     RELEASE_LOG(WebRTC, "Setting remote description succeeded\n");
     223    ALWAYS_LOG(LOGIDENTIFIER, "Set remote description succeeded");
    213224
    214225    if (m_peerConnection.isClosed())
     
    224235{
    225236    ASSERT(isMainThread());
    226     RELEASE_LOG(WebRTC, "Setting remote description failed:\n%{public}s\n", exception.message().utf8().data());
     237    ALWAYS_LOG(LOGIDENTIFIER, "Set remote description failed:", exception.message());
    227238
    228239    if (m_peerConnection.isClosed())
     
    256267{
    257268    ASSERT(isMainThread());
    258     RELEASE_LOG(WebRTC, "Adding ice candidate succeeded\n");
     269    ALWAYS_LOG(LOGIDENTIFIER, "Adding ice candidate succeeded");
    259270
    260271    if (m_peerConnection.isClosed())
     
    271282{
    272283    ASSERT(isMainThread());
    273     RELEASE_LOG(WebRTC, "Adding ice candidate failed:\n%{public}s\n", exception.message().utf8().data());
     284    ALWAYS_LOG(LOGIDENTIFIER, "Adding ice candidate failed:", exception.message());
    274285
    275286    if (m_peerConnection.isClosed())
     
    350361void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex)
    351362{
    352     RELEASE_LOG(WebRTC, "Gathered ice candidate:\n%{public}s\n", sdp.utf8().data());
     363    ALWAYS_LOG(LOGIDENTIFIER, "Gathered ice candidate:", sdp);
    353364
    354365    if (!m_shouldFilterICECandidates) {
     
    366377{
    367378    ASSERT(isMainThread());
    368     RELEASE_LOG(WebRTC, "Finished ice candidate gathering\n");
     379    ALWAYS_LOG(LOGIDENTIFIER, "Finished ice candidate gathering");
    369380
    370381    m_peerConnection.fireEvent(RTCPeerConnectionIceEvent::create(false, false, nullptr));
     
    402413}
    403414
     415#if !RELEASE_LOG_DISABLED
     416WTFLogChannel& PeerConnectionBackend::logChannel() const
     417{
     418    return LogWebRTC;
     419}
     420#endif
     421
    404422} // namespace WebCore
    405423
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h

    r219393 r222271  
    3838#include "RTCSessionDescription.h"
    3939#include "RTCSignalingState.h"
     40#include <pal/Logger.h>
     41#include <pal/LoggerHelper.h>
    4042
    4143namespace WebCore {
     
    6466using CreatePeerConnectionBackend = std::unique_ptr<PeerConnectionBackend> (*)(RTCPeerConnection&);
    6567
    66 class PeerConnectionBackend {
     68class PeerConnectionBackend
     69#if !RELEASE_LOG_DISABLED
     70    : public PAL::LoggerHelper
     71#endif
     72{
    6773public:
    6874    WEBCORE_EXPORT static CreatePeerConnectionBackend create;
    6975
    70     PeerConnectionBackend(RTCPeerConnection& peerConnection) : m_peerConnection(peerConnection) { }
     76    explicit PeerConnectionBackend(RTCPeerConnection&);
    7177    virtual ~PeerConnectionBackend() { }
    7278
     
    113119
    114120    virtual void applyRotationForOutgoingVideoSources() { }
     121
     122#if !RELEASE_LOG_DISABLED
     123    const PAL::Logger& logger() const final { return m_logger.get(); }
     124    const void* logIdentifier() const final { return m_logIdentifier; }
     125    const char* logClassName() const override { return "PeerConnectionBackend"; }
     126    WTFLogChannel& logChannel() const final;
     127#endif
    115128
    116129protected:
     
    163176    Vector<PendingICECandidate> m_pendingICECandidates;
    164177
     178#if !RELEASE_LOG_DISABLED
     179    Ref<const PAL::Logger> m_logger;
     180    const void* m_logIdentifier;
     181#endif
    165182    bool m_negotiationNeeded { false };
    166183};
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r219856 r222271  
    5353#include "RTCSessionDescription.h"
    5454#include "RTCTrackEvent.h"
     55#include <wtf/CryptographicallyRandomNumber.h>
    5556#include <wtf/MainThread.h>
    5657#include <wtf/UUID.h>
     
    8283RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
    8384    : ActiveDOMObject(&context)
     85#if !RELEASE_LOG_DISABLED
     86    , m_logger(downcast<Document>(context).logger())
     87    , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
     88#endif
    8489    , m_backend(PeerConnectionBackend::create(*this))
    8590{
     91    ALWAYS_LOG(LOGIDENTIFIER);
    8692    if (!m_backend)
    8793        m_connectionState = RTCPeerConnectionState::Closed;
     
    9096RTCPeerConnection::~RTCPeerConnection()
    9197{
     98    ALWAYS_LOG(LOGIDENTIFIER);
    9299    unregisterFromController();
    93100    stop();
     
    107114ExceptionOr<Ref<RTCRtpSender>> RTCPeerConnection::addTrack(Ref<MediaStreamTrack>&& track, const Vector<std::reference_wrapper<MediaStream>>& streams)
    108115{
     116    INFO_LOG(LOGIDENTIFIER);
     117
    109118    if (isClosed())
    110119        return Exception { InvalidStateError };
     
    161170ExceptionOr<void> RTCPeerConnection::removeTrack(RTCRtpSender& sender)
    162171{
     172    INFO_LOG(LOGIDENTIFIER);
     173
    163174    if (isClosed())
    164175        return Exception { InvalidStateError };
     
    185196ExceptionOr<Ref<RTCRtpTransceiver>> RTCPeerConnection::addTransceiver(AddTransceiverTrackOrKind&& withTrack, const RTCRtpTransceiverInit& init)
    186197{
     198    INFO_LOG(LOGIDENTIFIER);
     199
    187200    if (WTF::holds_alternative<String>(withTrack)) {
    188201        const String& kind = WTF::get<String>(withTrack);
     
    219232void RTCPeerConnection::queuedCreateOffer(RTCOfferOptions&& options, SessionDescriptionPromise&& promise)
    220233{
    221     RELEASE_LOG(WebRTC, "Creating offer\n");
     234    ALWAYS_LOG(LOGIDENTIFIER);
    222235    if (isClosed()) {
    223236        promise.reject(InvalidStateError);
     
    230243void RTCPeerConnection::queuedCreateAnswer(RTCAnswerOptions&& options, SessionDescriptionPromise&& promise)
    231244{
    232     RELEASE_LOG(WebRTC, "Creating answer\n");
     245    ALWAYS_LOG(LOGIDENTIFIER);
    233246    if (isClosed()) {
    234247        promise.reject(InvalidStateError);
     
    241254void RTCPeerConnection::queuedSetLocalDescription(RTCSessionDescription& description, DOMPromiseDeferred<void>&& promise)
    242255{
    243     RELEASE_LOG(WebRTC, "Setting local description:\n%{public}s\n", description.sdp().utf8().data());
     256    ALWAYS_LOG(LOGIDENTIFIER, "Setting local description to:\n", description.sdp());
    244257    if (isClosed()) {
    245258        promise.reject(InvalidStateError);
     
    267280void RTCPeerConnection::queuedSetRemoteDescription(RTCSessionDescription& description, DOMPromiseDeferred<void>&& promise)
    268281{
    269     RELEASE_LOG(WebRTC, "Setting remote description:\n%{public}s\n", description.sdp().utf8().data());
     282    ALWAYS_LOG(LOGIDENTIFIER, "Setting remote description to:\n", description.sdp());
    270283
    271284    if (isClosed()) {
     
    293306void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOMPromiseDeferred<void>&& promise)
    294307{
    295     RELEASE_LOG(WebRTC, "Received ice candidate:\n%{public}s\n", rtcCandidate ? rtcCandidate->candidate().utf8().data() : "null");
     308    ALWAYS_LOG(LOGIDENTIFIER, "Received ice candidate:\n", rtcCandidate ? rtcCandidate->candidate() : "null");
    296309
    297310    if (isClosed()) {
     
    330343ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&& configuration)
    331344{
     345    INFO_LOG(LOGIDENTIFIER);
     346
    332347    auto servers = iceServersFromConfiguration(configuration);
    333348    if (!servers)
     
    346361    if (isClosed())
    347362        return Exception { InvalidStateError };
     363
     364    INFO_LOG(LOGIDENTIFIER);
    348365
    349366    auto servers = iceServersFromConfiguration(configuration);
     
    365382ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(ScriptExecutionContext& context, String&& label, RTCDataChannelInit&& options)
    366383{
     384    ALWAYS_LOG(LOGIDENTIFIER);
     385
    367386    if (isClosed())
    368387        return Exception { InvalidStateError };
     
    466485void RTCPeerConnection::addTransceiver(Ref<RTCRtpTransceiver>&& transceiver)
    467486{
     487    INFO_LOG(LOGIDENTIFIER);
    468488    m_transceiverSet->append(WTFMove(transceiver));
    469489}
     
    471491void RTCPeerConnection::setSignalingState(RTCSignalingState newState)
    472492{
     493    ALWAYS_LOG(LOGIDENTIFIER, newState);
    473494    m_signalingState = newState;
    474495}
    475496
    476 #if !RELEASE_LOG_DISABLED
    477 static inline const char* rtcIceGatheringStateToString(RTCIceGatheringState newState)
    478 {
    479     switch (newState) {
    480     case RTCIceGatheringState::New:
    481         return "new";
    482     case RTCIceGatheringState::Gathering:
    483         return "gathering";
    484     case RTCIceGatheringState::Complete:
    485         return "complete";
    486     }
    487 }
    488 #endif
    489 
    490497void RTCPeerConnection::updateIceGatheringState(RTCIceGatheringState newState)
    491498{
    492     RELEASE_LOG(WebRTC, "New ICE gathering state: %{public}s\n", rtcIceGatheringStateToString(newState));
     499    ALWAYS_LOG(LOGIDENTIFIER, newState);
    493500
    494501    scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
     
    502509}
    503510
    504 #if !RELEASE_LOG_DISABLED
    505 static inline const char* rtcIceConnectionStateToString(RTCIceConnectionState newState)
    506 {
    507     switch (newState) {
    508     case RTCIceConnectionState::New:
    509         return "new";
    510     case RTCIceConnectionState::Checking:
    511         return "checking";
    512     case RTCIceConnectionState::Connected:
    513         return "connected";
    514     case RTCIceConnectionState::Completed:
    515         return "completed";
    516     case RTCIceConnectionState::Failed:
    517         return "failed";
    518     case RTCIceConnectionState::Disconnected:
    519         return "disconnected";
    520     case RTCIceConnectionState::Closed:
    521         return "closed";
    522     }
    523 }
    524 #endif
    525 
    526511void RTCPeerConnection::updateIceConnectionState(RTCIceConnectionState newState)
    527512{
    528     RELEASE_LOG(WebRTC, "New ICE connection state: %{public}s\n", rtcIceConnectionStateToString(newState));
     513    ALWAYS_LOG(LOGIDENTIFIER, newState);
    529514
    530515    scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
     
    561546        return;
    562547
     548    INFO_LOG(LOGIDENTIFIER, "state changed from: " , m_connectionState, " to ", state);
     549
    563550    m_connectionState = state;
    564551    dispatchEvent(Event::create(eventNames().connectionstatechangeEvent, false, false));
     
    595582void RTCPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromiseDeferred<void>&& promise)
    596583{
     584    INFO_LOG(LOGIDENTIFIER);
     585
    597586    if (!withTrack) {
    598587        scriptExecutionContext()->postTask([protectedSender = makeRef(sender), promise = WTFMove(promise)](ScriptExecutionContext&) mutable {
     
    616605}
    617606
     607bool RTCPeerConnection::dispatchEvent(Event& event)
     608{
     609    DEBUG_LOG(LOGIDENTIFIER, "dispatching '", event.type(), "'");
     610    return EventTarget::dispatchEvent(event);
     611}
     612
     613#if !RELEASE_LOG_DISABLED
     614WTFLogChannel& RTCPeerConnection::logChannel() const
     615{
     616    return LogWebRTC;
     617}
     618#endif
     619
    618620} // namespace WebCore
    619621
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r218994 r222271  
    4646#include "RTCRtpTransceiver.h"
    4747#include "RTCSignalingState.h"
     48#include <pal/LoggerHelper.h>
    4849
    4950namespace WebCore {
     
    6465};
    6566
    66 class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public RTCRtpSender::Backend, public EventTargetWithInlineData, public ActiveDOMObject {
     67class RTCPeerConnection final
     68    : public RefCounted<RTCPeerConnection>
     69    , public RTCRtpSender::Backend
     70    , public EventTargetWithInlineData
     71    , public ActiveDOMObject
     72#if !RELEASE_LOG_DISABLED
     73    , public PAL::LoggerHelper
     74#endif
     75{
    6776public:
    6877    static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
     
    151160    bool hasPendingActivity() const final;
    152161
     162#if !RELEASE_LOG_DISABLED
     163    const PAL::Logger& logger() const final { return m_logger.get(); }
     164    const void* logIdentifier() const final { return m_logIdentifier; }
     165    const char* logClassName() const final { return "RTCPeerConnection"; }
     166    WTFLogChannel& logChannel() const final;
     167#endif
     168
    153169private:
    154170    RTCPeerConnection(ScriptExecutionContext&);
     
    166182    void refEventTarget() final { ref(); }
    167183    void derefEventTarget() final { deref(); }
     184    bool dispatchEvent(Event&) final;
    168185
    169186    // ActiveDOMObject
     
    187204    RTCPeerConnectionState m_connectionState { RTCPeerConnectionState::New };
    188205
     206#if !RELEASE_LOG_DISABLED
     207    Ref<const PAL::Logger> m_logger;
     208    const void* m_logIdentifier;
     209#endif
     210
    189211    std::unique_ptr<RtpTransceiverSet> m_transceiverSet { std::unique_ptr<RtpTransceiverSet>(new RtpTransceiverSet()) };
    190212
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

    r219856 r222271  
    6464    , m_setRemoteSessionDescriptionObserver(*this)
    6565    , m_statsLogTimer(*this, &LibWebRTCMediaEndpoint::gatherStatsForLogging)
     66#if !RELEASE_LOG_DISABLED
     67    , m_logger(peerConnection.logger())
     68    , m_logIdentifier(peerConnection.logIdentifier())
     69#endif
    6670{
    6771    ASSERT(client.factory());
     
    10661070void LibWebRTCMediaEndpoint::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report)
    10671071{
    1068     if (!m_statsTimestamp)
    1069         m_statsTimestamp = report->timestamp_us();
    1070     else if (m_statsLogTimer.repeatInterval() == 2_s && (report->timestamp_us() - m_statsTimestamp) > 15000000) {
    1071         callOnMainThread([protectedThis = makeRef(*this)] {
    1072             protectedThis->m_statsLogTimer.augmentRepeatInterval(9_s);
     1072#if !RELEASE_LOG_DISABLED
     1073    int64_t timestamp = report->timestamp_us();
     1074    if (!m_statsFirstDeliveredTimestamp)
     1075        m_statsFirstDeliveredTimestamp = timestamp;
     1076
     1077    if (m_statsLogTimer.repeatInterval() != statsLogInterval(timestamp)) {
     1078        callOnMainThread([protectedThis = makeRef(*this), this, timestamp] {
     1079            m_statsLogTimer.stop();
     1080            m_statsLogTimer.startRepeating(statsLogInterval(timestamp));
    10731081        });
    10741082    }
    10751083
    1076 #if !RELEASE_LOG_DISABLED
    1077     // Log stats once every second for the 30 seconds, then drop to once every 5 seconds.
    10781084    for (auto iterator = report->begin(); iterator != report->end(); ++iterator) {
    10791085        if (iterator->type() == webrtc::RTCCodecStats::kType)
    10801086            continue;
    1081         RELEASE_LOG(WebRTC, "WebRTC stats for %p: %{public}s", this, iterator->ToString().c_str());
     1087
     1088        ALWAYS_LOG(LOGIDENTIFIER, "WebRTC stats for :", *iterator);
    10821089    }
    10831090#else
     
    10911098    if (m_statsLogTimer.isActive())
    10921099        m_statsLogTimer.stop();
    1093     m_statsLogTimer.startRepeating(2_s);
     1100    m_statsLogTimer.startRepeating(statsLogInterval(0));
    10941101#endif
    10951102}
     
    11001107}
    11011108
     1109#if !RELEASE_LOG_DISABLED
     1110WTFLogChannel& LibWebRTCMediaEndpoint::logChannel() const
     1111{
     1112    return LogWebRTC;
     1113}
     1114
     1115Seconds LibWebRTCMediaEndpoint::statsLogInterval(int64_t reportTimestamp) const
     1116{
     1117    if (logger().willLog(logChannel(), WTFLogLevelInfo))
     1118        return 2_s;
     1119
     1120    if (reportTimestamp - m_statsFirstDeliveredTimestamp > 15000000)
     1121        return 10_s;
     1122
     1123    return 4_s;
     1124}
     1125#endif
     1126
    11021127} // namespace WebCore
    11031128
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h

    r218994 r222271  
    3333#include "RealtimeOutgoingVideoSource.h"
    3434#include <Timer.h>
    35 
     35#include <pal/Logger.h>
     36#include <pal/LoggerHelper.h>
    3637#include <webrtc/api/jsep.h>
    3738#include <webrtc/api/peerconnectioninterface.h>
    3839#include <webrtc/pc/peerconnectionfactory.h>
    3940#include <webrtc/pc/rtcstatscollector.h>
    40 
    4141#include <wtf/ThreadSafeRefCounted.h>
    4242
     
    5858class RTCSessionDescription;
    5959
    60 class LibWebRTCMediaEndpoint : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>, private webrtc::PeerConnectionObserver, private webrtc::RTCStatsCollectorCallback {
     60class LibWebRTCMediaEndpoint
     61    : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>
     62    , private webrtc::PeerConnectionObserver
     63    , private webrtc::RTCStatsCollectorCallback
     64#if !RELEASE_LOG_DISABLED
     65    , public PAL::LoggerHelper
     66#endif
     67{
    6168public:
    6269    static Ref<LibWebRTCMediaEndpoint> create(LibWebRTCPeerConnectionBackend& peerConnection, LibWebRTCProvider& client) { return adoptRef(*new LibWebRTCMediaEndpoint(peerConnection, client)); }
     
    127134    bool shouldOfferAllowToReceiveVideo() const;
    128135
     136#if !RELEASE_LOG_DISABLED
     137    const PAL::Logger& logger() const final { return m_logger.get(); }
     138    const void* logIdentifier() const final { return m_logIdentifier; }
     139    const char* logClassName() const final { return "LibWebRTCMediaEndpoint"; }
     140    WTFLogChannel& logChannel() const final;
     141
     142    Seconds statsLogInterval(int64_t) const;
     143#endif
     144
    129145    class CreateSessionDescriptionObserver final : public webrtc::CreateSessionDescriptionObserver {
    130146    public:
     
    195211    bool m_isInitiator { false };
    196212    Timer m_statsLogTimer;
    197     int64_t m_statsTimestamp { 0 };
     213
     214#if !RELEASE_LOG_DISABLED
     215    int64_t m_statsFirstDeliveredTimestamp { 0 };
     216    Ref<const PAL::Logger> m_logger;
     217    const void* m_logIdentifier;
     218#endif
    198219};
    199220
    200221} // namespace WebCore
    201222
     223namespace PAL {
     224
     225template<typename Type>
     226struct LogArgument;
     227
     228template <>
     229struct LogArgument<webrtc::RTCStats> {
     230    static String toString(const webrtc::RTCStats& iterator)
     231    {
     232        return WTF::String(iterator.ToString().c_str());
     233    }
     234};
     235
     236}; // namespace PAL
     237
    202238#endif // USE(LIBWEBRTC)
  • trunk/Source/WebCore/platform/mediastream/RTCIceConnectionState.h

    r214212 r222271  
    3939};
    4040
     41String convertEnumerationToString(RTCIceConnectionState); // in JSCRTCIceConnectionState.cpp
     42
    4143}; // namespace WebCore
    4244
     45namespace PAL {
     46
     47template<typename Type>
     48struct LogArgument;
     49
     50template <>
     51struct LogArgument<WebCore::RTCIceConnectionState> {
     52    static String toString(const WebCore::RTCIceConnectionState state)
     53    {
     54        return convertEnumerationToString(state);
     55    }
     56};
     57
     58}; // namespace PAL
     59
    4360#endif
  • trunk/Source/WebCore/platform/mediastream/RTCIceGatheringState.h

    r214212 r222271  
    2727#if ENABLE(WEB_RTC)
    2828
     29#include <wtf/text/WTFString.h>
     30
    2931namespace WebCore {
    3032
     
    3537};
    3638
     39String convertEnumerationToString(RTCIceGatheringState); // in JSCRTCIceGatheringState.cpp
     40
    3741}; // namespace WebCore
    3842
     43namespace PAL {
     44
     45template<typename Type>
     46struct LogArgument;
     47
     48template <>
     49struct LogArgument<WebCore::RTCIceGatheringState> {
     50    static String toString(const WebCore::RTCIceGatheringState state)
     51    {
     52        return convertEnumerationToString(state);
     53    }
     54};
     55
     56}; // namespace PAL
     57
    3958#endif
  • trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionState.h

    r214293 r222271  
    3838};
    3939
     40String convertEnumerationToString(RTCPeerConnectionState); // in JSCRTCPeerConnectionState.h
     41
    4042}; // namespace WebCore
    4143
     44namespace PAL {
     45
     46template<typename Type>
     47struct LogArgument;
     48
     49template <>
     50struct LogArgument<WebCore::RTCPeerConnectionState> {
     51    static String toString(const WebCore::RTCPeerConnectionState state)
     52    {
     53        return convertEnumerationToString(state);
     54    }
     55};
     56
     57}; // namespace PAL
     58
    4259#endif
  • trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h

    r215327 r222271  
    3737};
    3838
     39String convertEnumerationToString(RTCSignalingState); // in JSCRTCSignalingState.cpp
     40
    3941}; // namespace WebCore
    4042
     43namespace PAL {
     44
     45template<typename Type>
     46struct LogArgument;
     47
     48template <>
     49struct LogArgument<WebCore::RTCSignalingState> {
     50    static String toString(const WebCore::RTCSignalingState state)
     51    {
     52        return convertEnumerationToString(state);
     53    }
     54};
     55
     56}; // namespace PAL
     57
    4158#endif
Note: See TracChangeset for help on using the changeset viewer.