// Copyright 2015 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_CONSTANTS_H_ #define CAST_STREAMING_PUBLIC_CONSTANTS_H_ //////////////////////////////////////////////////////////////////////////////// // NOTE: This file should only contain constants that are reasonably globally // used (i.e., by many modules, and in all or nearly all subdirs). Do NOT add // non-POD constants, functions, interfaces, or any logic to this module, // except for std::ostream operators on an as-needed basis. //////////////////////////////////////////////////////////////////////////////// #include <chrono> #include <ostream> #include <ratio> namespace openscreen::cast { // Default target playout delay. The playout delay is the window of time between // capture from the source until presentation at the receiver. constexpr std::chrono::milliseconds kDefaultTargetPlayoutDelay(400); // Default UDP port, bound at the Receiver, for Cast Streaming. An // implementation is required to use the port specified by the Receiver in its // ANSWER control message, which may or may not match this port number here. constexpr int kDefaultCastStreamingPort = …; // Default TCP port, bound at the TLS server socket level, for Cast Streaming. // An implementation must use the port specified in the DNS-SD published record // for connecting over TLS, which may or may not match this port number here. constexpr int kDefaultCastPort = …; // Target number of milliseconds between the sending of RTCP reports. Both // senders and receivers regularly send RTCP reports to their peer. constexpr std::chrono::milliseconds kRtcpReportInterval(500); // This is an important system-wide constant. This limits how much history // the implementation must retain in order to process the acknowledgements of // past frames. // // This value is carefully choosen such that it fits in the 8-bits range for // frame IDs. It is also less than half of the full 8-bits range such that // logic can handle wrap around and compare two frame IDs meaningfully. constexpr int kMaxUnackedFrames = …; // The network must support a packet size of at least this many bytes. constexpr int kRequiredNetworkPacketSize = …; // The spec declares RTP timestamps must always have a timebase of 90000 ticks // per second for video. constexpr int kRtpVideoTimebase = …; // Minimum resolution is 320x240. constexpr int kMinVideoHeight = …; constexpr int kMinVideoWidth = …; // The default frame rate for capture options is 30FPS. constexpr int kDefaultFrameRate = …; // The mirroring spec suggests 300kbps as the absolute minimum bitrate. constexpr int kDefaultVideoMinBitRate = …; // Default video max bitrate is based on 1080P @ 30FPS, which can be played back // at good quality around 10mbps. constexpr int kDefaultVideoMaxBitRate = …; // The mirroring control protocol specifies 32kbps as the absolute minimum // for audio. Depending on the type of audio content (narrowband, fullband, // etc.) Opus specifically can perform very well at this bitrate. // See: https://research.google/pubs/pub41650/ constexpr int kDefaultAudioMinBitRate = …; // Opus generally sees little improvement above 192kbps, but some older codecs // that we may consider supporting improve at up to 256kbps. constexpr int kDefaultAudioMaxBitRate = …; // While generally audio should be captured at the maximum sample rate, 16kHz is // the recommended absolute minimum. constexpr int kDefaultAudioMinSampleRate = …; // The default audio sample rate is 48kHz, slightly higher than standard // consumer audio. constexpr int kDefaultAudioSampleRate = …; // The default audio number of channels is set to stereo. constexpr int kDefaultAudioChannels = …; // Default maximum delay for both audio and video. Used if the sender fails // to provide any constraints. constexpr std::chrono::milliseconds kDefaultMaxDelayMs(1500); // TODO(issuetracker.google.com/184189100): As part of updating remoting // OFFER/ANSWER and capabilities exchange, remoting version should be updated // to 3. constexpr int kSupportedRemotingVersion = …; // Codecs known and understood by cast senders and receivers. Note: receivers // are required to implement the following codecs to be Cast V2 compliant: H264, // VP8, AAC, Opus. Senders have to implement at least one codec from this // list for audio or video to start a session. // |kNotSpecified| is used in remoting to indicate that the stream is being // remoted and is not specified as part of the OFFER message (indicated as // "REMOTE_AUDIO" or "REMOTE_VIDEO"). enum class AudioCodec { … }; enum class VideoCodec { … }; std::ostream& operator<<(std::ostream& os, VideoCodec codec); // The type (audio, video, or unknown) of the stream. enum class StreamType { … }; enum class CastMode : uint8_t { … }; std::ostream& operator<<(std::ostream& os, CastMode mode); } // namespace openscreen::cast #endif // CAST_STREAMING_PUBLIC_CONSTANTS_H_