diff options
author | Ryan Keane <rwkeane@google.com> | 2021-06-23 19:24:35 -0700 |
---|---|---|
committer | Openscreen LUCI CQ <openscreen-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-06-24 05:06:36 +0000 |
commit | 1fcefe1f610c87c8a8a5b86838590574ab4514ee (patch) | |
tree | c4867986e6a49c2bd0e054b1f91455b0bf84eacb /cast/streaming/resolution.cc | |
parent | 5df61d7305d4122d4724cab3edd03946c12326d7 (diff) | |
download | openscreen-1fcefe1f610c87c8a8a5b86838590574ab4514ee.tar.gz |
Add SupportsAllAllowedBy() function to ReceiverSession inner classes
This CL does the following:
- Add copy ctors for ReceiverSession inner classes. This is required
so that a Preferences object may be copied to a unique_ptr for
initialization of the `cast_streaming` component in Chromium, while
also maintaining a local instance for use with the below function.
- Add SupportsAllAllowedBy() functions for comparing the support
provided by two different Preferences instances. This is required
because the Cast Web Runtime allows for updating of supported AV
settings during runtime, so it must be validated that the
configuration used for negotiation is no more strict than that
supported at any time by the runtime.
Bug: 182427395
Change-Id: Ie7a8625ffbf8156e49e36c13dbcb91e8da214e7b
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2983166
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Commit-Queue: Ryan Keane <rwkeane@google.com>
Diffstat (limited to 'cast/streaming/resolution.cc')
-rw-r--r-- | cast/streaming/resolution.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cast/streaming/resolution.cc b/cast/streaming/resolution.cc index 0bcf5067..9c763cfe 100644 --- a/cast/streaming/resolution.cc +++ b/cast/streaming/resolution.cc @@ -70,6 +70,10 @@ bool Resolution::operator!=(const Resolution& other) const { return !(*this == other); } +bool Resolution::IsSupersetOf(const Resolution& other) const { + return width >= other.width && height >= other.height; +} + bool Dimensions::TryParse(const Json::Value& root, Dimensions* out) { if (!json::TryParseInt(root[kWidth], &(out->width)) || !json::TryParseInt(root[kHeight], &(out->height)) || @@ -104,5 +108,15 @@ bool Dimensions::operator!=(const Dimensions& other) const { return !(*this == other); } +bool Dimensions::IsSupersetOf(const Dimensions& other) const { + if (static_cast<double>(frame_rate) != + static_cast<double>(other.frame_rate)) { + return static_cast<double>(frame_rate) >= + static_cast<double>(other.frame_rate); + } + + return ToResolution().IsSupersetOf(other.ToResolution()); +} + } // namespace cast } // namespace openscreen |