Skip to content

Commit 57a6d6f

Browse files
committed
Add debug logging of TransceiverStates https://bugs.webkit.org/show_bug.cgi?id=275146
Reviewed by Philippe Normand. Add debug logging of TransceiverStates, to aid debugging while moving the GStreamer backend out of m_pendingTrackEvents in PeerConnectionBackend. * Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp: (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded): (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded): (WebCore::toJSONObject): (WebCore::toJSONArray): (WebCore::toJSONString): (WTF::LogArgument<WebCore::PeerConnectionBackend::TransceiverState>::toString): (WTF::LogArgument<WebCore::PeerConnectionBackend::TransceiverStates>::toString): * Source/WebCore/Modules/mediastream/PeerConnectionBackend.h: (WebCore::PeerConnectionBackend::DescriptionStates::isolatedCopy): * Source/WebCore/platform/mediastream/RTCRtpTransceiverDirection.h: Canonical link: https://commits.webkit.org/279742@main
1 parent 90ba85b commit 57a6d6f

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ void PeerConnectionBackend::setLocalDescriptionSucceeded(std::optional<Descripti
238238
{
239239
ASSERT(isMainThread());
240240
ALWAYS_LOG(LOGIDENTIFIER);
241-
241+
if (transceiverStates)
242+
DEBUG_LOG(LOGIDENTIFIER, "Transceiver states: ", *transceiverStates);
242243
ASSERT(m_setDescriptionCallback);
243244
m_peerConnection.queueTaskKeepingObjectAlive(m_peerConnection, TaskSource::Networking, [this, callback = WTFMove(m_setDescriptionCallback), descriptionStates = WTFMove(descriptionStates), transceiverStates = WTFMove(transceiverStates), sctpBackend = WTFMove(sctpBackend), maxMessageSize]() mutable {
244245
if (m_peerConnection.isClosed())
@@ -323,6 +324,8 @@ void PeerConnectionBackend::setRemoteDescriptionSucceeded(std::optional<Descript
323324
{
324325
ASSERT(isMainThread());
325326
ALWAYS_LOG(LOGIDENTIFIER, "Set remote description succeeded");
327+
if (transceiverStates)
328+
DEBUG_LOG(LOGIDENTIFIER, "Transceiver states: ", *transceiverStates);
326329
ASSERT(m_setDescriptionCallback);
327330

328331
m_peerConnection.queueTaskKeepingObjectAlive(m_peerConnection, TaskSource::Networking, [this, callback = WTFMove(m_setDescriptionCallback), descriptionStates = WTFMove(descriptionStates), transceiverStates = WTFMove(transceiverStates), sctpBackend = WTFMove(sctpBackend), maxMessageSize, events = WTFMove(m_pendingTrackEvents)]() mutable {
@@ -650,6 +653,55 @@ WTFLogChannel& PeerConnectionBackend::logChannel() const
650653
}
651654
#endif
652655

656+
static Ref<JSON::Object> toJSONObject(const PeerConnectionBackend::TransceiverState& transceiverState)
657+
{
658+
auto object = JSON::Object::create();
659+
object->setString("mid"_s, transceiverState.mid);
660+
661+
auto receiverStreams = JSON::Array::create();
662+
for (auto receiverStream : transceiverState.receiverStreams)
663+
receiverStreams->pushString(receiverStream->id());
664+
object->setArray("receiverStreams"_s, WTFMove(receiverStreams));
665+
666+
if (auto firedDirection = transceiverState.firedDirection)
667+
object->setString("firedDirection"_s, convertEnumerationToString(*firedDirection));
668+
669+
return object;
670+
}
671+
672+
static Ref<JSON::Array> toJSONArray(const PeerConnectionBackend::TransceiverStates& transceiverStates)
673+
{
674+
auto array = JSON::Array::create();
675+
for (auto transceiverState : transceiverStates)
676+
array->pushObject(toJSONObject(transceiverState));
677+
678+
return array;
679+
}
680+
681+
static String toJSONString(const PeerConnectionBackend::TransceiverState& transceiverState)
682+
{
683+
return toJSONObject(transceiverState)->toJSONString();
684+
}
685+
686+
static String toJSONString(const PeerConnectionBackend::TransceiverStates& transceiverStates)
687+
{
688+
return toJSONArray(transceiverStates)->toJSONString();
689+
}
690+
653691
} // namespace WebCore
654692

693+
namespace WTF {
694+
695+
String LogArgument<WebCore::PeerConnectionBackend::TransceiverState>::toString(const WebCore::PeerConnectionBackend::TransceiverState& transceiverState)
696+
{
697+
return toJSONString(transceiverState);
698+
}
699+
700+
String LogArgument<WebCore::PeerConnectionBackend::TransceiverStates>::toString(const WebCore::PeerConnectionBackend::TransceiverStates& transceiverStates)
701+
{
702+
return toJSONString(transceiverStates);
703+
}
704+
705+
}
706+
655707
#endif // ENABLE(WEB_RTC)

Source/WebCore/Modules/mediastream/PeerConnectionBackend.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,23 @@ inline PeerConnectionBackend::DescriptionStates PeerConnectionBackend::Descripti
279279
WTFMove(pendingRemoteDescriptionSdp).isolatedCopy()
280280
};
281281
}
282-
283282
} // namespace WebCore
284283

284+
namespace WTF {
285+
286+
template<typename>
287+
struct LogArgument;
288+
289+
template <>
290+
struct LogArgument<WebCore::PeerConnectionBackend::TransceiverState> {
291+
static String toString(const WebCore::PeerConnectionBackend::TransceiverState&);
292+
};
293+
294+
template <>
295+
struct LogArgument<WebCore::PeerConnectionBackend::TransceiverStates> {
296+
static String toString(const WebCore::PeerConnectionBackend::TransceiverStates&);
297+
};
298+
299+
}
300+
285301
#endif // ENABLE(WEB_RTC)

Source/WebCore/platform/mediastream/RTCRtpTransceiverDirection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#if ENABLE(WEB_RTC)
2929

30+
#include <wtf/text/WTFString.h>
31+
3032
namespace WebCore {
3133

3234
enum class RTCRtpTransceiverDirection {
@@ -36,6 +38,8 @@ enum class RTCRtpTransceiverDirection {
3638
Inactive
3739
};
3840

41+
String convertEnumerationToString(RTCRtpTransceiverDirection); // in JSRTCRtpTransceiverDirection.h
42+
3943
} // namespace WebCore
4044

4145
#endif

0 commit comments

Comments
 (0)