Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c09dbedb84290973ddebb7166af1cd97b43f4956
      
https://github.com/WebKit/WebKit/commit/c09dbedb84290973ddebb7166af1cd97b43f4956
  Author: Carlos Bentzen <cadubent...@igalia.com>
  Date:   2024-06-18 (Tue, 18 Jun 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h
    M Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.cpp

  Log Message:
  -----------
  [GStreamer] Add gstStructureGet helper function
https://bugs.webkit.org/show_bug.cgi?id=275609

Reviewed by Philippe Normand.

Add gstStructureGet helper template function, to avoid repeating the
pattern as below when getting fields from GstStructure:

uint64_t value;
if (gst_structure_get_uint64(structure, "bytes-received", &value))
    stats.bytesReceived = value;

By using the helper function, the code above becomes:

stats.bytesReceived = gstStructureGet<uint64_t>(structure, "bytes-received"_s);

This will be useful in refactoring GStreamerStatsCollector.cpp where this
pattern is repeated many times.

The helper function is implemented for integer types and double, and is
static_asserted to handle only those types. It's also tested with a unit
test in TestWebKitAPI.

* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h:
(WebCore::gstStructureGet):
* Tools/TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/280130@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to