breadcast/breadcast-caststream-sys/vendor/openscreen/util/hashing.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

55 lines
1.6 KiB
C++

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UTIL_HASHING_H_
#define UTIL_HASHING_H_
#include <cstdint>
#include <utility>
#include <vector>
namespace openscreen {
// This value is taken from absl::Hash implementation.
inline constexpr uint64_t kDefaultSeed = UINT64_C(0xc3a5c85c97cb3127);
// Computes the aggregate hash of the provided hashable objects.
// Seed must initially use a large prime between 2^63 and 2^64 as a starting
// value, or the result of a previous call to this function.
template <typename... T>
uint64_t ComputeAggregateHash(uint64_t original_seed, const T&... objs) {
auto hash_combiner = [](uint64_t current_seed,
uint64_t hash_value) -> uint64_t {
static const uint64_t kMultiplier = UINT64_C(0x9ddfea08eb382d69);
uint64_t a = (hash_value ^ current_seed) * kMultiplier;
a ^= (a >> 47);
uint64_t b = (current_seed ^ a) * kMultiplier;
b ^= (b >> 47);
b *= kMultiplier;
return b;
};
uint64_t result = original_seed;
std::vector<uint64_t> hashes = {std::hash<T>()(objs)...};
for (uint64_t hash : hashes) {
result = hash_combiner(result, hash);
}
return result;
}
template <typename... T>
uint64_t ComputeAggregateHash(const T&... objs) {
return ComputeAggregateHash(kDefaultSeed, objs...);
}
struct PairHash {
template <typename TFirst, typename TSecond>
size_t operator()(const std::pair<TFirst, TSecond>& pair) const {
return ComputeAggregateHash(pair.first, pair.second);
}
};
} // namespace openscreen
#endif // UTIL_HASHING_H_