RESOLVED FIXED275609
[GStreamer] Add gstStructureGet helper function
https://bugs.webkit.org/show_bug.cgi?id=275609
Summary [GStreamer] Add gstStructureGet helper function
Carlos Bentzen
Reported 2024-06-18 07:37:51 PDT
In GStreamerStatsCollector.cpp, we need to assign to a bunch of std::optional<T> fields and the pattern below gets repeated many times: struct InboundRtpStreamStats : RtpStreamStats { std::optional<uint64_t> bytesReceived; std::optional<uint32_t> firCount; }; void fillInboundRTPStreamStats(InboundRtpStreamStats& stats, const GstStructure* structure) { uint64_t bytesReceived; if (gst_structure_get_uint64(structure, "bytes-received", &value)) stats.bytesReceived = value; unsigned firCount; if (gst_structure_get_uint(structure, "fir-count", &firCount)) stats.firCount = firCount; } It would be nice to not have to always declare new variables and if conditions: template<typename T> std::optional<T> gstStructureGet(const GstStructure* structure, ASCIILiteral key); void fillInboundRTPStreamStats(InboundRtpStreamStats& stats, const GstStructure* structure) { stats.bytesReceived = gstStructureGet<unint64_t>(structure, "bytes-received"_s); stats.firCount = gstStructureGet<unsigned>(structure, "fir-count"_s); }
Attachments
Carlos Bentzen
Comment 1 2024-06-18 08:04:19 PDT
EWS
Comment 2 2024-06-18 12:35:24 PDT
Committed 280130@main (c09dbedb8429): <https://commits.webkit.org/280130@main> Reviewed commits have been landed. Closing PR #29931 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2024-06-18 12:36:15 PDT
Note You need to log in before you can comment on or make changes to this bug.