Bug 275609
| Summary: | [GStreamer] Add gstStructureGet helper function | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Carlos Bentzen <cadubentzen> |
| Component: | Platform | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Carlos Bentzen
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Carlos Bentzen
Pull request: https://github.com/WebKit/WebKit/pull/29931
EWS
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
<rdar://problem/130099156>