Skip to content

Commit be809c7

Browse files
committed
[Glib][GStreamer] Implement GMallocString class and apply it to GStreamer code
https://bugs.webkit.org/show_bug.cgi?id=303909 Reviewed by Adrian Perez de Castro. When interfacing with Glib APIs there was no way to wrap an owned malloced char* so GMallocString was created. It can adopt C strings in several ways, providing then easy ways to interface with the WebKit strings the same way CStringView does and also preserving the original null terminated C string without performing any copy. I applied this to the GStreamer code. Tests: Tools/TestWebKitAPI/Tests/WTF/CStringView.cpp Tools/TestWebKitAPI/Tests/WTF/glib/GMallocString.cpp Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.cpp Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GstElementHarness.cpp * Source/WTF/wtf/PlatformGTK.cmake: * Source/WTF/wtf/PlatformWPE.cmake: * Source/WTF/wtf/glib/GMallocString.cpp: Added. * Source/WTF/wtf/glib/GMallocString.h: Added. (WTF::operator==): (WTF::safePrintfType): (WTF::toCStringView): * Source/WTF/wtf/glib/GSpanExtras.h: (WTF::dupGMallocSpan): (WTF::adoptGMallocString): Deleted. * Source/WTF/wtf/text/CStringView.h: * Source/WebCore/Modules/mediastream/gstreamer/GStreamerDataChannelHandler.cpp: (WebCore::GStreamerDataChannelHandler::checkState): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerDtlsTransportBackend.cpp: (WebCore::GStreamerDtlsTransportBackendObserver::stateChanged): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerIceAgent.cpp: (webkitGstWebRTCIceAgentLocalCandidateGatheredForStream): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerIceTransportBackend.cpp: (WebCore::GStreamerIceTransportBackend::registerClient): (WebCore::GStreamerIceTransportBackend::stateChanged const): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp: (WebCore::GStreamerMediaEndpoint::initializePipeline): (WebCore::fetchDescription): (WebCore::fetchSignalingState): (WebCore::toGStreamerMediaEndpointTransceiverState): (WebCore::transceiverStatesFromWebRTCBin): (WebCore::GStreamerMediaEndpoint::linkOutgoingSources): (WebCore::GStreamerMediaEndpoint::setDescription): (WebCore::GStreamerMediaEndpoint::processSDPMessage): (WebCore::GStreamerMediaEndpoint::createTransceiverBackends): (WebCore::GStreamerMediaEndpoint::onIceGatheringChange): (WebCore::GStreamerMediaEndpoint::collectTransceivers): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerRtpTransceiverBackend.cpp: (WebCore::GStreamerRtpTransceiverBackend::setDirection): * Source/WebCore/Modules/mediastream/gstreamer/GStreamerWebRTCUtils.cpp: (WebCore::setSsrcAudioLevelVadOn): * Source/WebCore/platform/audio/gstreamer/AudioEncoderGStreamer.cpp: (WebCore::GStreamerInternalAudioEncoder::initialize): * Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp: (WebCore::AudioTrackPrivateGStreamer::updateConfigurationFromCaps): * Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp: (WebCore::getStreamIdFromPad): (WebCore::registerActivePipeline): (WebCore::unregisterPipeline): (WebCore::videoColorSpaceFromInfo): * Source/WebCore/platform/graphics/gstreamer/GStreamerSinksWorkarounds.cpp: (WebCore::BaseSinkPositionFlushWorkaroundProbe::checkIsNeeded): (WebCore::AppSinkFlushCapsWorkaroundProbe::checkIsNeeded): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::elementIdChanged const): (WebCore::MediaPlayerPrivateGStreamer::handleMessage): (WebCore::MediaPlayerPrivateGStreamer::updateBufferingStatus): (WebCore::MediaPlayerPrivateGStreamer::configureParsebin): (WebCore::MediaPlayerPrivateGStreamer::configureElement): (WebCore::MediaPlayerPrivateGStreamer::configureDownloadBuffer): (WebCore::MediaPlayerPrivateGStreamer::downloadBufferFileCreatedCallback): (WebCore::MediaPlayerPrivateGStreamer::setupCodecProbe): (WebCore::MediaPlayerPrivateGStreamer::configureVideoDecoder): (WebCore::MediaPlayerPrivateGStreamer::getVideoOrientation): (WebCore::MediaPlayerPrivateGStreamer::audioOutputDeviceChanged): * Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp: (WebCore::VideoTrackPrivateGStreamer::updateConfigurationFromCaps): * Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: (webKitWebSrcSetProperty): (webKitWebSrcGetProperty): (webKitWebSrcSetExtraHeader): (webKitWebSrcMakeRequest): * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp: (WebCore::AppendPipeline::didReceiveInitializationSegment): * Source/WebCore/platform/graphics/gstreamer/mse/GStreamerMediaDescription.cpp: (WebCore::GStreamerMediaDescription::extractCodecName const): * Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: (webKitMediaSrcLoop): (webKitMediaSrcGetUri): (webKitMediaSrcSetUri): * Source/WebCore/platform/gstreamer/GStreamerElementHarness.cpp: (WebCore::MermaidBuilder::describeCaps): (WebCore::GStreamerElementHarness::dumpGraph): * Source/WebCore/platform/mediastream/gstreamer/DesktopPortal.cpp: (WebCore::DesktopPortal::waitResponseSignal): (WebCore::DesktopPortalScreenCast::createScreencastSession): (WebCore::DesktopPortalScreenCast::ScreencastSession::openPipewireRemote): * Source/WebCore/platform/mediastream/gstreamer/DesktopPortal.h: (WebCore::DesktopPortal::waitResponseSignal): * Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.cpp: (WebCore::sortDevices): (WebCore::GStreamerCaptureDeviceManager::captureDeviceFromGstDevice): (WebCore::GStreamerCaptureDeviceManager::refreshCaptureDevices): * Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp: (WebCore::GStreamerDisplayCaptureDeviceManager::createDisplayCaptureSource): * Source/WebCore/platform/mediastream/gstreamer/GStreamerIncomingTrackProcessor.cpp: (WebCore::GStreamerIncomingTrackProcessor::mediaStreamIdFromPad): * Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp: (webkitMediaStreamSrcAddTrack): * Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingMediaSourceGStreamer.cpp: (WebCore::RealtimeOutgoingMediaSourceGStreamer::checkMid): * Tools/TestWebKitAPI/PlatformGTK.cmake: * Tools/TestWebKitAPI/PlatformWPE.cmake: * Tools/TestWebKitAPI/Tests/WTF/CStringView.cpp: (TestWebKitAPI::TEST(WTF, CStringViewFrom)): * Tools/TestWebKitAPI/Tests/WTF/glib/GMallocString.cpp: Added. (TestWebKitAPI::TEST(WTF_GMallocString, NullAndEmpty)): (TestWebKitAPI::TEST(WTF_GMallocString, Move)): (TestWebKitAPI::TEST(WTF_GMallocString, Length)): (TestWebKitAPI::TEST(WTF_GMallocString, Equality)): (TestWebKitAPI::TEST(WTF_GMallocString, CStringView)): (TestWebKitAPI::TEST(WTF_GMallocString, LeakUTF8)): (TestWebKitAPI::TEST(WTF_GMallocString, ToCStringView)): * Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.cpp: (TestWebKitAPI::TEST_F(GStreamerTest, capsFromCodecString)): * Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GstElementHarness.cpp: (TestWebKitAPI::TEST_F(GStreamerTest, harnessParseMP4)): (TestWebKitAPI::TEST_F(GStreamerTest, harnessDecodeMP4Video)): Canonical link: https://commits.webkit.org/304343@main Signed-off-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
1 parent bbb348f commit be809c7

39 files changed

Lines changed: 1959 additions & 214 deletions

Source/WTF/wtf/PlatformGTK.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ list(APPEND WTF_SOURCES
77
glib/Application.cpp
88
glib/ChassisType.cpp
99
glib/FileSystemGlib.cpp
10+
glib/GMallocString.cpp
1011
glib/GRefPtr.cpp
1112
glib/GSocketMonitor.cpp
1213
glib/GSpanExtras.cpp
@@ -30,6 +31,7 @@ list(APPEND WTF_SOURCES
3031
list(APPEND WTF_PUBLIC_HEADERS
3132
glib/Application.h
3233
glib/ChassisType.h
34+
glib/GMallocString.h
3335
glib/GMutexLocker.h
3436
glib/GRefPtr.h
3537
glib/GSocketMonitor.h

Source/WTF/wtf/PlatformWPE.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ list(APPEND WTF_SOURCES
66
glib/Application.cpp
77
glib/ChassisType.cpp
88
glib/FileSystemGlib.cpp
9+
glib/GMallocString.cpp
910
glib/GRefPtr.cpp
1011
glib/GSocketMonitor.cpp
1112
glib/GSpanExtras.cpp
@@ -33,6 +34,7 @@ list(APPEND WTF_SOURCES
3334
list(APPEND WTF_PUBLIC_HEADERS
3435
glib/Application.h
3536
glib/ChassisType.h
37+
glib/GMallocString.h
3638
glib/GMutexLocker.h
3739
glib/GRefPtr.h
3840
glib/GSocketMonitor.h

Source/WTF/wtf/StdLibExtras.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ using WTF::bitwise_cast;
897897
using WTF::byteCast;
898898
using WTF::callStatelessLambda;
899899
using WTF::checkAndSet;
900+
using WTF::compareSpans;
900901
using WTF::constructFixedSizeArrayWithArguments;
901902
using WTF::equalSpans;
902903
using WTF::findBitInWord;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2018 Yusuke Suzuki <utatane.tea@gmail.com>
3+
* Copyright (C) 2024 Apple Inc. All Rights Reserved.
4+
* Copyright (C) 2025 Comcast Inc.
5+
* Copyright (C) 2025 Igalia S.L.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
20+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#include "config.h"
30+
#include <wtf/glib/GMallocString.h>
31+
32+
#include <wtf/PrintStream.h>
33+
#include <wtf/text/CStringView.h>
34+
#include <wtf/text/MakeString.h>
35+
#include <wtf/text/StringView.h>
36+
#include <wtf/text/WTFString.h>
37+
38+
namespace WTF {
39+
40+
void GMallocString::dump(PrintStream& out) const LIFETIME_BOUND {
41+
out.print(span());
42+
}
43+
44+
} // namespace WTF
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Copyright (C) 2018 Yusuke Suzuki <utatane.tea@gmail.com>
3+
* Copyright (C) 2024 Apple Inc. All Rights Reserved.
4+
* Copyright (C) 2025 Comcast Inc.
5+
* Copyright (C) 2025 Igalia S.L.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
20+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#pragma once
30+
31+
#include <wtf/Compiler.h>
32+
#include <wtf/HashFunctions.h>
33+
#include <wtf/glib/GSpanExtras.h>
34+
#include <wtf/text/ASCIILiteral.h>
35+
#include <wtf/text/CStringView.h>
36+
#include <wtf/text/StringCommon.h>
37+
#include <wtf/text/SuperFastHash.h>
38+
39+
namespace WTF {
40+
41+
class PrintStream;
42+
43+
class GMallocString final {
44+
WTF_FORBID_HEAP_ALLOCATION;
45+
WTF_MAKE_NONCOPYABLE(GMallocString);
46+
public:
47+
48+
static GMallocString unsafeAdoptFromUTF8(char* string)
49+
{
50+
if (!string)
51+
return GMallocString();
52+
return GMallocString { adoptGMallocSpan<char8_t>(unsafeMakeSpan(byteCast<char8_t>(string), string ? std::char_traits<char>::length(string) + 1 : 0)) };
53+
}
54+
55+
static GMallocString unsafeAdoptFromUTF8(GUniquePtr<char>&& pointer)
56+
{
57+
return unsafeAdoptFromUTF8(pointer.release());
58+
}
59+
60+
static GMallocString unsafeAdoptFromUTF8(GUniqueOutPtr<char>&& pointer)
61+
{
62+
return unsafeAdoptFromUTF8(pointer.release());
63+
}
64+
65+
static GMallocString adoptFromUTF8(std::span<char> string)
66+
{
67+
if (string.size() < 1)
68+
return GMallocString();
69+
RELEASE_ASSERT(string[string.size() - 1] == '\0');
70+
return GMallocString { adoptGMallocSpan<char8_t>(byteCast<char8_t>(string)) };
71+
}
72+
73+
explicit GMallocString(const CStringView& view)
74+
{
75+
m_spanWithNullTerminator = dupGMallocSpan(view.spanIncludingNullTerminator());
76+
}
77+
78+
WTF_EXPORT_PRIVATE void dump(PrintStream& out) const;
79+
80+
GMallocString() = default;
81+
constexpr GMallocString(std::nullptr_t)
82+
: GMallocString()
83+
{ }
84+
85+
GMallocString(GMallocString&& other)
86+
: m_spanWithNullTerminator(WTFMove(other.m_spanWithNullTerminator))
87+
{
88+
}
89+
GMallocString& operator=(GMallocString&& other)
90+
{
91+
GMallocSpan<char8_t> otherSpan = WTFMove(other.m_spanWithNullTerminator);
92+
std::swap(m_spanWithNullTerminator, otherSpan);
93+
return *this;
94+
}
95+
96+
bool isNull() const { return m_spanWithNullTerminator.span().empty(); }
97+
const char* utf8() const LIFETIME_BOUND { return byteCast<char>(m_spanWithNullTerminator.span().data()); }
98+
char* leakUTF8() WARN_UNUSED_RETURN { return byteCast<char>(m_spanWithNullTerminator.leakSpan().data()); }
99+
size_t lengthInBytes() const { return !m_spanWithNullTerminator.span().empty() ? m_spanWithNullTerminator.span().size() - 1 : 0; }
100+
std::span<const char8_t> span() const LIFETIME_BOUND { return m_spanWithNullTerminator.span().first(lengthInBytes()); }
101+
std::span<const char8_t> spanIncludingNullTerminator() const LIFETIME_BOUND { return m_spanWithNullTerminator.span(); }
102+
size_t isEmpty() const { return m_spanWithNullTerminator.span().size() <= 1; }
103+
104+
explicit operator bool() const { return !isEmpty(); }
105+
bool operator!() const { return isEmpty(); }
106+
107+
private:
108+
explicit GMallocString(GMallocSpan<char8_t>&& string)
109+
: m_spanWithNullTerminator(WTFMove(string))
110+
{
111+
}
112+
113+
GMallocSpan<char8_t> m_spanWithNullTerminator;
114+
};
115+
116+
inline bool operator==(const GMallocString& a, const GMallocString& b)
117+
{
118+
return equal(a.span(), b.span());
119+
}
120+
121+
inline bool operator==(const GMallocString& a, ASCIILiteral b)
122+
{
123+
return equal(a.span(), byteCast<char8_t>(b.span()));
124+
}
125+
126+
inline bool operator==(const GMallocString& a, CStringView b)
127+
{
128+
return equal(a.span(), b.span());
129+
}
130+
131+
// GMallocString is null terminated
132+
inline const char* safePrintfType(const GMallocString& string) { return string.utf8(); }
133+
134+
inline CStringView toCStringView(const GMallocString& string LIFETIME_BOUND) { return CStringView::fromUTF8(string.spanIncludingNullTerminator()); }
135+
136+
} // namespace WTF
137+
138+
using WTF::GMallocString;
139+
using WTF::toCStringView;

Source/WTF/wtf/glib/GSpanExtras.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ GMallocSpan<T, Malloc> adoptGMallocSpan(std::span<T> span)
6767
return adoptMallocSpan<T, Malloc>(span);
6868
}
6969

70+
template<typename T, typename Malloc = GMalloc>
71+
GMallocSpan<T, Malloc> dupGMallocSpan(std::span<const T> span)
72+
{
73+
auto duplicate = GMallocSpan<T, Malloc>::malloc(span.size_bytes());
74+
memcpySpan(duplicate.mutableSpan(), span);
75+
return duplicate;
76+
}
77+
7078
WTF_EXPORT_PRIVATE Expected<GMallocSpan<char>, GUniquePtr<GError>> gFileGetContents(CStringView);
7179
WTF_EXPORT_PRIVATE Expected<GMallocSpan<char*, GMallocStrv>, GUniquePtr<GError>> gKeyFileGetKeys(GKeyFile*, CStringView groupName);
7280
WTF_EXPORT_PRIVATE GMallocSpan<GParamSpec*> gObjectClassGetProperties(GObjectClass*);

Source/WTF/wtf/text/CStringView.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class CStringView final {
5353
return CStringView(unsafeMakeSpan(byteCast<char8_t>(string), std::char_traits<char>::length(string) + 1));
5454
}
5555

56+
static CStringView fromUTF8(std::span<const char8_t> spanWithNullTerminator LIFETIME_BOUND)
57+
{
58+
if (spanWithNullTerminator.size() < 1)
59+
return CStringView();
60+
RELEASE_ASSERT(spanWithNullTerminator[spanWithNullTerminator.size() - 1] == '\0');
61+
return CStringView(spanWithNullTerminator);
62+
}
63+
5664
WTF_EXPORT_PRIVATE void dump(PrintStream& out) const;
5765

5866
CStringView() = default;

Source/WebCore/Modules/mediastream/gstreamer/GStreamerDataChannelHandler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "RTCPriorityType.h"
3131

3232
#include <wtf/MainThread.h>
33+
#include <wtf/glib/GMallocString.h>
3334

3435
GST_DEBUG_CATEGORY(webkit_webrtc_data_channel_debug);
3536
#define GST_CAT_DEFAULT webkit_webrtc_data_channel_debug
@@ -293,8 +294,8 @@ bool GStreamerDataChannelHandler::checkState()
293294
}
294295

295296
#ifndef GST_DISABLE_GST_DEBUG
296-
GUniquePtr<char> stateString(g_enum_to_string(GST_TYPE_WEBRTC_DATA_CHANNEL_STATE, channelState));
297-
DC_DEBUG("Dispatching state change to %s on channel %p", stateString.get(), m_channel.get());
297+
auto stateString = GMallocString::unsafeAdoptFromUTF8(g_enum_to_string(GST_TYPE_WEBRTC_DATA_CHANNEL_STATE, channelState));
298+
DC_DEBUG("Dispatching state change to %s on channel %p", stateString.utf8(), m_channel.get());
298299
#endif
299300
postTask([client = m_client, state] {
300301
if (!*client) {

Source/WebCore/Modules/mediastream/gstreamer/GStreamerDtlsTransportBackend.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "GStreamerIceTransportBackend.h"
2626
#include "GStreamerWebRTCUtils.h"
2727
#include <JavaScriptCore/ArrayBuffer.h>
28+
#include <wtf/glib/GMallocString.h>
2829
#include <wtf/glib/GUniquePtr.h>
2930

3031
namespace WebCore {
@@ -68,8 +69,8 @@ void GStreamerDtlsTransportBackendObserver::stateChanged()
6869
g_object_get(m_backend.get(), "state", &state, nullptr);
6970

7071
#ifndef GST_DISABLE_GST_DEBUG
71-
GUniquePtr<char> desc(g_enum_to_string(GST_TYPE_WEBRTC_DTLS_TRANSPORT_STATE, state));
72-
GST_DEBUG_OBJECT(m_backend.get(), "DTLS transport state changed to %s", desc.get());
72+
auto desc = GMallocString::unsafeAdoptFromUTF8(g_enum_to_string(GST_TYPE_WEBRTC_DTLS_TRANSPORT_STATE, state));
73+
GST_DEBUG_OBJECT(m_backend.get(), "DTLS transport state changed to %s", desc.utf8());
7374
#endif
7475

7576
Vector<Ref<JSC::ArrayBuffer>> certificates;

0 commit comments

Comments
 (0)