xref: /aosp_15_r20/external/openscreen/cast/streaming/ssrc.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CAST_STREAMING_SSRC_H_
6 #define CAST_STREAMING_SSRC_H_
7 
8 #include <stdint.h>
9 
10 namespace openscreen {
11 namespace cast {
12 
13 // A Synchronization Source is a 32-bit opaque identifier used in RTP packets
14 // for identifying the source (or recipient) of a logical sequence of encoded
15 // audio/video frames. In other words, an audio stream will have one sender SSRC
16 // and a video stream will have a different sender SSRC.
17 using Ssrc = uint32_t;
18 
19 // The "not set" or "null" value for the Ssrc type.
20 constexpr Ssrc kNullSsrc{0};
21 
22 // Computes a new SSRC that will be used to uniquely identify an RTP stream. The
23 // |higher_priority| argument, if true, will generate an SSRC that causes the
24 // system to use a higher priority when scheduling data transmission. Generally,
25 // this is set to true for audio streams and false for video streams.
26 Ssrc GenerateSsrc(bool higher_priority);
27 
28 // Returns a value indicating how to prioritize data transmission for a stream
29 // with |ssrc_a| versus a stream with |ssrc_b|:
30 //
31 //   ret < 0: Stream |ssrc_a| has higher priority.
32 //   ret == 0: Equal priority.
33 //   ret > 0: Stream |ssrc_b| has higher priority.
34 int ComparePriority(Ssrc ssrc_a, Ssrc ssrc_b);
35 
36 }  // namespace cast
37 }  // namespace openscreen
38 
39 #endif  // CAST_STREAMING_SSRC_H_
40