Skip to content

Commit

Permalink
[GStreamer] Make additional use of wrapSpanData in VideoDecoder
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260200

Reviewed by Xabier Rodriguez-Calvar.

Refactor the decode method to use wrapSpanData.

* Source/WebCore/platform/graphics/gstreamer/VideoDecoderGStreamer.cpp:
(WebCore::GStreamerInternalVideoDecoder::decode):

Canonical link: https://commits.webkit.org/266940@main
  • Loading branch information
philn committed Aug 16, 2023
1 parent 1d5fbef commit 2f1549d
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ GStreamerInternalVideoDecoder::GStreamerInternalVideoDecoder(const String& codec
void GStreamerInternalVideoDecoder::decode(std::span<const uint8_t> frameData, bool isKeyFrame, int64_t timestamp, std::optional<uint64_t> duration, VideoDecoder::DecodeCallback&& callback)
{
GST_DEBUG_OBJECT(m_harness->element(), "Decoding%s frame", isKeyFrame ? " key" : "");

Vector<uint8_t> data { frameData };
if (data.isEmpty()) {
auto buffer = wrapSpanData(frameData);
if (!buffer) {
m_postTaskCallback([protectedThis = Ref { *this }, callback = WTFMove(callback)]() mutable {
if (protectedThis->m_isClosed)
return;
Expand All @@ -228,12 +227,6 @@ void GStreamerInternalVideoDecoder::decode(std::span<const uint8_t> frameData, b
return;
}

auto bufferSize = data.size();
auto bufferData = data.data();
auto buffer = adoptGRef(gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, bufferData, bufferSize, 0, bufferSize, new Vector<uint8_t>(WTFMove(data)), [](gpointer data) {
delete static_cast<Vector<uint8_t>*>(data);
}));

GST_BUFFER_DTS(buffer.get()) = GST_BUFFER_PTS(buffer.get()) = timestamp;
if (duration)
GST_BUFFER_DURATION(buffer.get()) = *duration;
Expand Down

0 comments on commit 2f1549d

Please sign in to comment.