Skip to content

Commit 9c69f13

Browse files
committed
[GStreamer] Make webkitGstGhostPadFromStaticTemplate use ASCIILiteral
https://bugs.webkit.org/show_bug.cgi?id=289788 Reviewed by Philippe Normand. Other than the description, as a fly-by, made GstPadTemplate use a smart ptr. * Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp: (_WebKitWebAudioSrcPrivate::_WebKitWebAudioSrcPrivate): * Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp: (WebCore::webkitGstGhostPadFromStaticTemplate): * Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h: * Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp: (webKitAudioSinkConfigure): * Source/WebCore/platform/gstreamer/VideoEncoderPrivateGStreamer.cpp: (videoEncoderConstructed): * Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp: (webkitMediaStreamSrcAddTrack): Canonical link: https://commits.webkit.org/292260@main Signed-off-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
1 parent 6b140c3 commit 9c69f13

6 files changed

Lines changed: 10 additions & 12 deletions

File tree

Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct _WebKitWebAudioSrcPrivate {
9090

9191
_WebKitWebAudioSrcPrivate()
9292
{
93-
sourcePad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", nullptr);
93+
sourcePad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src"_s, nullptr);
9494

9595
g_rec_mutex_init(&mutex);
9696
}

Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,15 @@ namespace WebCore {
111111

112112
static GstClockTime s_webkitGstInitTime;
113113

114-
GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate* staticPadTemplate, const gchar* name, GstPad* target)
114+
WARN_UNUSED_RETURN GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate* staticPadTemplate, ASCIILiteral name, GstPad* target)
115115
{
116116
GstPad* pad;
117-
GstPadTemplate* padTemplate = gst_static_pad_template_get(staticPadTemplate);
117+
GRefPtr padTemplate = gst_static_pad_template_get(staticPadTemplate);
118118

119119
if (target)
120-
pad = gst_ghost_pad_new_from_template(name, target, padTemplate);
120+
pad = gst_ghost_pad_new_from_template(name.characters(), target, padTemplate.get());
121121
else
122-
pad = gst_ghost_pad_new_no_target_from_template(name, padTemplate);
123-
124-
gst_object_unref(padTemplate);
122+
pad = gst_ghost_pad_new_no_target_from_template(name.characters(), padTemplate.get());
125123

126124
return pad;
127125
}

Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ inline bool webkitGstCheckVersion(guint major, guint minor, guint micro)
6666
#define GST_AUDIO_CAPS_TYPE_PREFIX "audio/"
6767
#define GST_TEXT_CAPS_TYPE_PREFIX "text/"
6868

69-
GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
69+
WARN_UNUSED_RETURN GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, ASCIILiteral name, GstPad* target);
7070
#if ENABLE(VIDEO)
7171
bool getVideoSizeAndFormatFromCaps(const GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
7272
std::optional<FloatSize> getVideoResolutionFromCaps(const GstCaps*);

Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static bool webKitAudioSinkConfigure(WebKitAudioSink* sink)
6565

6666
gst_bin_add(GST_BIN_CAST(sink), sink->priv->interAudioSink.get());
6767
auto targetPad = adoptGRef(gst_element_get_static_pad(sink->priv->interAudioSink.get(), "sink"));
68-
gst_element_add_pad(GST_ELEMENT_CAST(sink), webkitGstGhostPadFromStaticTemplate(&sinkTemplate, "sink", targetPad.get()));
68+
gst_element_add_pad(GST_ELEMENT_CAST(sink), webkitGstGhostPadFromStaticTemplate(&sinkTemplate, "sink"_s, targetPad.get()));
6969
return true;
7070
}
7171
return false;

Source/WebCore/platform/gstreamer/VideoEncoderPrivateGStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static void videoEncoderConstructed(GObject* encoder)
581581
self->priv->bitrateMode = CONSTANT_BITRATE_MODE;
582582
self->priv->latencyMode = REALTIME_LATENCY_MODE;
583583

584-
auto* sinkPad = webkitGstGhostPadFromStaticTemplate(&sinkTemplate, "sink", nullptr);
584+
auto* sinkPad = webkitGstGhostPadFromStaticTemplate(&sinkTemplate, "sink"_s, nullptr);
585585
GST_OBJECT_FLAG_SET(sinkPad, GST_PAD_FLAG_NEED_PARENT);
586586
gst_pad_set_event_function(sinkPad, reinterpret_cast<GstPadEventFunction>(+[](GstPad* pad, GstObject* parent, GstEvent* event) -> gboolean {
587587
if (GST_EVENT_TYPE(event) == GST_EVENT_CUSTOM_DOWNSTREAM_OOB) {
@@ -597,7 +597,7 @@ static void videoEncoderConstructed(GObject* encoder)
597597
}));
598598
gst_element_add_pad(GST_ELEMENT_CAST(self), sinkPad);
599599

600-
gst_element_add_pad(GST_ELEMENT_CAST(self), webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", nullptr));
600+
gst_element_add_pad(GST_ELEMENT_CAST(self), webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src"_s, nullptr));
601601
}
602602

603603
static void setupVaEncoder(WebKitVideoEncoder* self)

Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ void webkitMediaStreamSrcAddTrack(WebKitMediaStreamSrc* self, MediaStreamTrackPr
11571157
GST_DEBUG_OBJECT(self, "%s Ghosting %" GST_PTR_FORMAT, objectPath.get(), pad.get());
11581158
#endif
11591159

1160-
auto ghostPad = webkitGstGhostPadFromStaticTemplate(padTemplate, padName.ascii().data(), pad.get());
1160+
auto* ghostPad = webkitGstGhostPadFromStaticTemplate(padTemplate, ASCIILiteral::fromLiteralUnsafe(padName.ascii().data()), pad.get());
11611161
gst_pad_store_sticky_event(ghostPad, stickyStreamStartEvent.get());
11621162
gst_pad_set_active(ghostPad, TRUE);
11631163
gst_element_add_pad(GST_ELEMENT_CAST(self), ghostPad);

0 commit comments

Comments
 (0)