diff options
author | Jordan Bayles <jophba@chromium.org> | 2021-04-08 15:09:10 -0700 |
---|---|---|
committer | Jordan Bayles <jophba@chromium.org> | 2021-04-08 22:36:35 +0000 |
commit | e70f06460eb3a9bd46bc1e13ad0c39b88e033c2d (patch) | |
tree | 13a68cea154ee4ebefb3e4e10659520bc510d7ef /cast | |
parent | 46b7d128bc08fceae9d109c0f675bc98c73ddda9 (diff) | |
download | openscreen-e70f06460eb3a9bd46bc1e13ad0c39b88e033c2d.tar.gz |
[HOTFIX] Fix Chrome issues
Chrome build is complaining about a missing constructor as well as a
bunch of static initialized stuff due to const declarations. This patch
should put Chrome in a good state by making things constexpr and adding
constructors where expected.
TBR=rwkeane@chromium.org
Change-Id: I6b98e04a8a103092bdeb02cd78a4799b7115c498
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2815613
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast')
-rw-r--r-- | cast/streaming/answer_messages_unittest.cc | 20 | ||||
-rw-r--r-- | cast/streaming/capture_recommendations.h | 4 | ||||
-rw-r--r-- | cast/streaming/receiver_session.cc | 24 | ||||
-rw-r--r-- | cast/streaming/receiver_session.h | 14 | ||||
-rw-r--r-- | cast/streaming/resolution.cc | 8 | ||||
-rw-r--r-- | cast/streaming/resolution.h | 6 |
6 files changed, 53 insertions, 23 deletions
diff --git a/cast/streaming/answer_messages_unittest.cc b/cast/streaming/answer_messages_unittest.cc index 3ce93aef..9ddceac0 100644 --- a/cast/streaming/answer_messages_unittest.cc +++ b/cast/streaming/answer_messages_unittest.cc @@ -102,7 +102,7 @@ const Answer kValidAnswer{ }; constexpr int kValidMaxPixelsPerSecond = 1920 * 1080 * 30; -const Dimensions kValidDimensions{1920, 1080, SimpleFraction{60, 1}}; +constexpr Dimensions kValidDimensions{1920, 1080, SimpleFraction{60, 1}}; static const VideoConstraints kValidVideoConstraints{ kValidMaxPixelsPerSecond, absl::optional<Dimensions>(kValidDimensions), kValidDimensions, 300 * 1000, @@ -442,15 +442,15 @@ TEST(AnswerMessagesTest, AudioConstraintsIsValid) { TEST(AnswerMessagesTest, DimensionsIsValid) { // NOTE: in some cases (such as min dimensions) a frame rate of zero is valid. - const Dimensions kValidZeroFrameRate{1920, 1080, SimpleFraction{0, 60}}; - const Dimensions kInvalidWidth{0, 1080, SimpleFraction{60, 1}}; - const Dimensions kInvalidHeight{1920, 0, SimpleFraction{60, 1}}; - const Dimensions kInvalidFrameRateZeroDenominator{1920, 1080, - SimpleFraction{60, 0}}; - const Dimensions kInvalidFrameRateNegativeNumerator{1920, 1080, - SimpleFraction{-1, 30}}; - const Dimensions kInvalidFrameRateNegativeDenominator{1920, 1080, - SimpleFraction{30, -1}}; + constexpr Dimensions kValidZeroFrameRate{1920, 1080, SimpleFraction{0, 60}}; + constexpr Dimensions kInvalidWidth{0, 1080, SimpleFraction{60, 1}}; + constexpr Dimensions kInvalidHeight{1920, 0, SimpleFraction{60, 1}}; + constexpr Dimensions kInvalidFrameRateZeroDenominator{1920, 1080, + SimpleFraction{60, 0}}; + constexpr Dimensions kInvalidFrameRateNegativeNumerator{ + 1920, 1080, SimpleFraction{-1, 30}}; + constexpr Dimensions kInvalidFrameRateNegativeDenominator{ + 1920, 1080, SimpleFraction{30, -1}}; EXPECT_TRUE(kValidDimensions.IsValid()); EXPECT_TRUE(kValidZeroFrameRate.IsValid()); diff --git a/cast/streaming/capture_recommendations.h b/cast/streaming/capture_recommendations.h index 643eac88..603b6098 100644 --- a/cast/streaming/capture_recommendations.h +++ b/cast/streaming/capture_recommendations.h @@ -85,7 +85,7 @@ struct Audio { constexpr Resolution kDefaultMinResolution{kMinVideoWidth, kMinVideoHeight}; // Currently mirroring only supports 1080P. -const Dimensions kDefaultMaxResolution{1920, 1080, kDefaultFrameRate}; +constexpr Dimensions kDefaultMaxResolution{1920, 1080, kDefaultFrameRate}; // The mirroring spec suggests 300kbps as the absolute minimum bitrate. constexpr int kDefaultVideoMinBitRate = 300 * 1000; @@ -93,7 +93,7 @@ constexpr int kDefaultVideoMinBitRate = 300 * 1000; // The theoretical maximum pixels per second is the maximum bit rate // divided by 8 (the max byte rate). In practice it should generally be // less. -const int kDefaultVideoMaxPixelsPerSecond = +constexpr int kDefaultVideoMaxPixelsPerSecond = kDefaultMaxResolution.effective_bit_rate() / 8; // Our default limits are merely the product of the minimum and maximum diff --git a/cast/streaming/receiver_session.cc b/cast/streaming/receiver_session.cc index 5529d840..78956c5d 100644 --- a/cast/streaming/receiver_session.cc +++ b/cast/streaming/receiver_session.cc @@ -46,10 +46,32 @@ std::unique_ptr<Stream> SelectStream( ReceiverSession::Client::~Client() = default; +using Preferences = ReceiverSession::Preferences; + +Preferences::Preferences() = default; +Preferences::Preferences(std::vector<VideoCodec> video_codecs, + std::vector<AudioCodec> audio_codecs) + : video_codecs(std::move(video_codecs)), + audio_codecs(std::move(audio_codecs)) {} + +Preferences::Preferences(std::vector<VideoCodec> video_codecs, + std::vector<AudioCodec> audio_codecs, + std::vector<AudioLimits> audio_limits, + std::vector<VideoLimits> video_limits, + std::unique_ptr<Display> description) + : video_codecs(std::move(video_codecs)), + audio_codecs(std::move(audio_codecs)), + audio_limits(std::move(audio_limits)), + video_limits(std::move(video_limits)), + display_description(std::move(description)) {} + +Preferences::Preferences(Preferences&&) noexcept = default; +Preferences& Preferences::operator=(Preferences&&) noexcept = default; + ReceiverSession::ReceiverSession(Client* const client, Environment* environment, MessagePort* message_port, - ReceiverSession::Preferences preferences) + Preferences preferences) : client_(client), environment_(environment), preferences_(std::move(preferences)), diff --git a/cast/streaming/receiver_session.h b/cast/streaming/receiver_session.h index 489ce9b6..04b1d256 100644 --- a/cast/streaming/receiver_session.h +++ b/cast/streaming/receiver_session.h @@ -146,6 +146,20 @@ class ReceiverSession final : public Environment::SocketSubscriber { // Note: embedders are required to implement the following // codecs to be Cast V2 compliant: H264, VP8, AAC, Opus. struct Preferences { + Preferences(); + Preferences(std::vector<VideoCodec> video_codecs, + std::vector<AudioCodec> audio_codecs); + Preferences(std::vector<VideoCodec> video_codecs, + std::vector<AudioCodec> audio_codecs, + std::vector<AudioLimits> audio_limits, + std::vector<VideoLimits> video_limits, + std::unique_ptr<Display> description); + + Preferences(Preferences&&) noexcept; + Preferences(const Preferences&) = delete; + Preferences& operator=(Preferences&&) noexcept; + Preferences& operator=(const Preferences&) = delete; + std::vector<VideoCodec> video_codecs{VideoCodec::kVp8, VideoCodec::kH264}; std::vector<AudioCodec> audio_codecs{AudioCodec::kOpus, AudioCodec::kAac}; diff --git a/cast/streaming/resolution.cc b/cast/streaming/resolution.cc index 682de444..de6b9358 100644 --- a/cast/streaming/resolution.cc +++ b/cast/streaming/resolution.cc @@ -95,14 +95,6 @@ Json::Value Dimensions::ToJson() const { return root; } -Resolution Dimensions::ToResolution() const { - return {width, height}; -} - -int Dimensions::effective_bit_rate() const { - return width * height * static_cast<double>(frame_rate); -} - bool Dimensions::operator==(const Dimensions& other) const { return (std::tie(width, height) == std::tie(other.width, other.height) && FrameRateEquals(static_cast<double>(frame_rate), diff --git a/cast/streaming/resolution.h b/cast/streaming/resolution.h index 60903001..d27c7d28 100644 --- a/cast/streaming/resolution.h +++ b/cast/streaming/resolution.h @@ -41,10 +41,12 @@ struct Dimensions { bool operator!=(const Dimensions& other) const; // Get just the width and height fields (for comparisons). - Resolution ToResolution() const; + constexpr Resolution ToResolution() const { return {width, height}; } // The effective bit rate is the width * height * frame rate. - int effective_bit_rate() const; + constexpr int effective_bit_rate() const { + return width * height * static_cast<double>(frame_rate); + } // Width and height in pixels. int width = 0; |