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); }
Pull request: https://github.com/WebKit/WebKit/pull/29931
Committed 280130@main (c09dbedb8429): <https://commits.webkit.org/280130@main> Reviewed commits have been landed. Closing PR #29931 and removing active labels.
<rdar://problem/130099156>