• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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_CONSTANTS_H_
6 #define CAST_STREAMING_CONSTANTS_H_
7 
8 ////////////////////////////////////////////////////////////////////////////////
9 // NOTE: This file should only contain constants that are reasonably globally
10 // used (i.e., by many modules, and in all or nearly all subdirs).  Do NOT add
11 // non-POD constants, functions, interfaces, or any logic to this module.
12 ////////////////////////////////////////////////////////////////////////////////
13 
14 #include <chrono>
15 #include <ratio>
16 
17 namespace openscreen {
18 namespace cast {
19 
20 // Default target playout delay. The playout delay is the window of time between
21 // capture from the source until presentation at the receiver.
22 constexpr std::chrono::milliseconds kDefaultTargetPlayoutDelay(400);
23 
24 // Default UDP port, bound at the Receiver, for Cast Streaming. An
25 // implementation is required to use the port specified by the Receiver in its
26 // ANSWER control message, which may or may not match this port number here.
27 constexpr int kDefaultCastStreamingPort = 2344;
28 
29 // Default TCP port, bound at the TLS server socket level, for Cast Streaming.
30 // An implementation must use the port specified in the DNS-SD published record
31 // for connecting over TLS, which may or may not match this port number here.
32 constexpr int kDefaultCastPort = 8010;
33 
34 // Target number of milliseconds between the sending of RTCP reports.  Both
35 // senders and receivers regularly send RTCP reports to their peer.
36 constexpr std::chrono::milliseconds kRtcpReportInterval(500);
37 
38 // This is an important system-wide constant.  This limits how much history
39 // the implementation must retain in order to process the acknowledgements of
40 // past frames.
41 //
42 // This value is carefully choosen such that it fits in the 8-bits range for
43 // frame IDs. It is also less than half of the full 8-bits range such that
44 // logic can handle wrap around and compare two frame IDs meaningfully.
45 constexpr int kMaxUnackedFrames = 120;
46 
47 // The network must support a packet size of at least this many bytes.
48 constexpr int kRequiredNetworkPacketSize = 256;
49 
50 // The spec declares RTP timestamps must always have a timebase of 90000 ticks
51 // per second for video.
52 constexpr int kRtpVideoTimebase = 90000;
53 
54 // Minimum resolution is 320x240.
55 constexpr int kMinVideoHeight = 240;
56 constexpr int kMinVideoWidth = 320;
57 
58 // The default frame rate for capture options is 30FPS.
59 constexpr int kDefaultFrameRate = 30;
60 
61 // The default audio sample rate is 48kHz, slightly higher than standard
62 // consumer audio.
63 constexpr int kDefaultAudioSampleRate = 48000;
64 
65 // The default audio number of channels is set to stereo.
66 constexpr int kDefaultAudioChannels = 2;
67 
68 // Codecs known and understood by cast senders and receivers. Note: receivers
69 // are required to implement the following codecs to be Cast V2 compliant: H264,
70 // VP8, AAC, Opus. Senders have to implement at least one codec for audio and
71 // video to start a session.
72 enum class AudioCodec { kAac, kOpus };
73 enum class VideoCodec { kH264, kVp8, kHevc, kVp9 };
74 
75 }  // namespace cast
76 }  // namespace openscreen
77 
78 #endif  // CAST_STREAMING_CONSTANTS_H_
79