breadcast/breadcast-caststream-sys/vendor/openscreen/cast/streaming/resolution.h
Breadway 8c745d18e0
Some checks failed
dev release / build (push) Failing after 12s
Implement Cast Streaming mirroring, DLNA casting, daemon+GUI, and breadd integration
Builds out the full v1 scope: a vendored+patched openscreen subset for
low-latency Cast Streaming (Mirroring receiver 0F5096E8) alongside the
existing Cast V2/HLS and new DLNA/AVTransport casting paths, breadcastd's
Idle/Casting state machine with a private IPC socket, the breadcast GTK4
popup as a thin IPC client, and bread.cast.*/bread.command.cast.* breadd
integration (device discovery, start/stop, mirroring lifecycle events).
Also adds bakery/systemd/Forgejo CI packaging.

Validated end-to-end against a real Chromecast/Google TV: negotiated
Cast Streaming session, live pipeline playback, and daemon+GUI click-to-cast/
stop through the actual popup.
2026-08-03 09:07:21 +08:00

67 lines
2 KiB
C++

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Resolutions and dimensions (resolutions with a frame rate) are used
// extensively throughout cast streaming. Since their serialization to and
// from JSON is stable and standard, we have a single place definition for
// these for use both in our public APIs and private messages.
#ifndef CAST_STREAMING_RESOLUTION_H_
#define CAST_STREAMING_RESOLUTION_H_
#include "json/value.h"
#include "util/simple_fraction.h"
namespace openscreen::cast {
// A resolution in pixels.
struct Resolution {
static ErrorOr<Resolution> TryParse(const Json::Value& value);
bool IsValid() const;
Json::Value ToJson() const;
// Returns true if both `width` and `height` of this instance are greater than
// or equal to that of `other`.
bool IsSupersetOf(const Resolution& other) const;
bool operator==(const Resolution& other) const;
bool operator!=(const Resolution& other) const;
// Width and height in pixels.
int width = 0;
int height = 0;
};
// A resolution in pixels and a frame rate.
struct Dimensions {
static ErrorOr<Dimensions> TryParse(const Json::Value& value);
bool IsValid() const;
Json::Value ToJson() const;
// Returns true if all properties of this instance are greater than or equal
// to those of `other`.
bool IsSupersetOf(const Dimensions& other) const;
bool operator==(const Dimensions& other) const;
bool operator!=(const Dimensions& other) const;
// Get just the width and height fields (for comparisons).
constexpr Resolution ToResolution() const { return {width, height}; }
// The effective bit rate is the width * height * frame rate.
constexpr int effective_bit_rate() const {
return width * height * static_cast<double>(frame_rate);
}
// Width and height in pixels.
int width = 0;
int height = 0;
// `frame_rate` is the maximum maintainable frame rate.
SimpleFraction frame_rate{0, 1};
};
} // namespace openscreen::cast
#endif // CAST_STREAMING_RESOLUTION_H_