Some checks failed
dev release / build (push) Failing after 12s
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.
121 lines
3.6 KiB
C++
121 lines
3.6 KiB
C++
// Copyright 2016 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef CAST_STREAMING_PUBLIC_FRAME_ID_H_
|
|
#define CAST_STREAMING_PUBLIC_FRAME_ID_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <limits>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#include "cast/streaming/impl/expanded_value_base.h"
|
|
|
|
namespace openscreen::cast {
|
|
|
|
// Forward declaration (see below).
|
|
class FrameId;
|
|
|
|
// Convenience operator overloads for logging.
|
|
std::ostream& operator<<(std::ostream& out, const FrameId rhs);
|
|
|
|
// Unique identifier for a frame in a RTP media stream. FrameIds are truncated
|
|
// to 8-bit values in RTP and RTCP headers, and then expanded back by the other
|
|
// endpoint when parsing the headers.
|
|
//
|
|
// Usage example:
|
|
//
|
|
// // Distance/offset math.
|
|
// FrameId first = FrameId::first();
|
|
// FrameId second = first + 1;
|
|
// FrameId third = second + 1;
|
|
// int64_t offset = third - first;
|
|
// FrameId fourth = second + offset;
|
|
//
|
|
// // Logging convenience.
|
|
// OSP_DLOG_INFO << "The current frame is " << fourth;
|
|
class FrameId : public ExpandedValueBase<int64_t, FrameId> {
|
|
public:
|
|
// The "null" FrameId constructor. Represents a FrameId field that has not
|
|
// been set and/or a "not applicable" indicator.
|
|
constexpr FrameId() : FrameId(std::numeric_limits<int64_t>::min()) {}
|
|
|
|
constexpr explicit FrameId(int64_t value) : ExpandedValueBase(value) {}
|
|
|
|
// Allow copy construction and assignment.
|
|
constexpr FrameId(const FrameId&) = default;
|
|
constexpr FrameId& operator=(const FrameId&) = default;
|
|
|
|
// Returns true if this is the special value representing null.
|
|
constexpr bool is_null() const { return *this == FrameId(); }
|
|
|
|
// Distance operator.
|
|
int64_t operator-(FrameId rhs) const {
|
|
OSP_CHECK(!is_null());
|
|
OSP_CHECK(!rhs.is_null());
|
|
return value_ - rhs.value_;
|
|
}
|
|
|
|
// Operators to compute advancement by incremental amounts.
|
|
constexpr FrameId operator+(int64_t rhs) const {
|
|
OSP_CHECK(!is_null());
|
|
return FrameId(value_ + rhs);
|
|
}
|
|
constexpr FrameId operator-(int64_t rhs) const {
|
|
OSP_CHECK(!is_null());
|
|
return FrameId(value_ - rhs);
|
|
}
|
|
constexpr FrameId& operator+=(int64_t rhs) {
|
|
OSP_CHECK(!is_null());
|
|
return (*this = (*this + rhs));
|
|
}
|
|
constexpr FrameId& operator-=(int64_t rhs) {
|
|
OSP_CHECK(!is_null());
|
|
return (*this = (*this - rhs));
|
|
}
|
|
constexpr FrameId& operator++() {
|
|
OSP_CHECK(!is_null());
|
|
++value_;
|
|
return *this;
|
|
}
|
|
constexpr FrameId& operator--() {
|
|
OSP_CHECK(!is_null());
|
|
--value_;
|
|
return *this;
|
|
}
|
|
constexpr FrameId operator++(int) {
|
|
OSP_CHECK(!is_null());
|
|
return FrameId(value_++);
|
|
}
|
|
constexpr FrameId operator--(int) {
|
|
OSP_CHECK(!is_null());
|
|
return FrameId(value_--);
|
|
}
|
|
|
|
// The identifier for the first frame in a stream.
|
|
static constexpr FrameId first() { return FrameId(0); }
|
|
|
|
// A virtual identifier, representing the frame before the first. There should
|
|
// never actually be a frame streamed with this identifier. Instead, this is
|
|
// used in various components to represent a "not yet seen/processed the first
|
|
// frame" state.
|
|
//
|
|
// The name "leader" comes from the terminology used in tape reels, which
|
|
// refers to the non-data-carrying segment of tape before the recording
|
|
// begins.
|
|
static constexpr FrameId leader() { return FrameId(-1); }
|
|
|
|
constexpr int64_t value() const { return value_; }
|
|
|
|
std::string ToString() const;
|
|
|
|
private:
|
|
friend class ExpandedValueBase<int64_t, FrameId>;
|
|
friend std::ostream& operator<<(std::ostream& out, const FrameId rhs);
|
|
};
|
|
|
|
} // namespace openscreen::cast
|
|
|
|
#endif // CAST_STREAMING_PUBLIC_FRAME_ID_H_
|