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.
60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
// Copyright 2019 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_IMPL_PACKET_UTIL_H_
|
|
#define CAST_STREAMING_IMPL_PACKET_UTIL_H_
|
|
|
|
#include <utility>
|
|
|
|
#include "cast/streaming/ssrc.h"
|
|
#include "platform/base/span.h"
|
|
#include "util/big_endian.h"
|
|
#include "util/osp_logging.h"
|
|
|
|
namespace openscreen::cast {
|
|
|
|
// Reads a field from the start of the given span and advances the span to point
|
|
// just after the field.
|
|
template <typename Integer>
|
|
inline Integer ConsumeField(ByteView& in) {
|
|
OSP_CHECK_GE(in.size(), sizeof(Integer));
|
|
const Integer result = ReadBigEndian<Integer>(in.data());
|
|
in = in.subspan(sizeof(Integer));
|
|
return result;
|
|
}
|
|
|
|
// Writes a field at the start of the given span and advances the span to point
|
|
// just after the field.
|
|
template <typename Integer>
|
|
inline void AppendField(Integer value, ByteBuffer& out) {
|
|
WriteBigEndian<Integer>(value, out.data());
|
|
out = out.subspan(sizeof(Integer));
|
|
}
|
|
|
|
// Returns a bitmask for a field having the given number of bits. For example,
|
|
// FieldBitmask<uint8_t>(5) returns 0b00011111.
|
|
template <typename Integer>
|
|
constexpr Integer FieldBitmask(unsigned field_size_in_bits) {
|
|
return (Integer{1} << field_size_in_bits) - 1;
|
|
}
|
|
|
|
// Reserves `num_bytes` from the beginning of the given span, returning the
|
|
// reserved space.
|
|
inline ByteBuffer ReserveSpace(int num_bytes, ByteBuffer& out) {
|
|
const ByteBuffer reserved = out.subspan(0, num_bytes);
|
|
out = out.subspan(num_bytes);
|
|
return reserved;
|
|
}
|
|
|
|
// Performs a quick-scan of the packet data for the purposes of routing it to an
|
|
// appropriate parser. Identifies whether the packet is a RTP packet, RTCP
|
|
// packet, or unknown; and provides the originator's SSRC. This only performs a
|
|
// very quick scan of the packet data, and does not guarantee that a full parse
|
|
// will later succeed.
|
|
enum class ApparentPacketType { UNKNOWN, RTP, RTCP };
|
|
std::pair<ApparentPacketType, Ssrc> InspectPacketForRouting(ByteView packet);
|
|
|
|
} // namespace openscreen::cast
|
|
|
|
#endif // CAST_STREAMING_IMPL_PACKET_UTIL_H_
|