xref: /aosp_15_r20/external/openscreen/cast/streaming/capture_configs.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1 // Copyright 2020 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_CAPTURE_CONFIGS_H_
6 #define CAST_STREAMING_CAPTURE_CONFIGS_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "cast/streaming/constants.h"
12 #include "cast/streaming/resolution.h"
13 #include "util/simple_fraction.h"
14 
15 namespace openscreen {
16 namespace cast {
17 
18 // A configuration set that can be used by the sender to capture audio, and the
19 // receiver to playback audio. Used by Cast Streaming to provide an offer to the
20 // receiver.
21 struct AudioCaptureConfig {
22   // Audio codec represented by this configuration.
23   AudioCodec codec = AudioCodec::kOpus;
24 
25   // Number of channels used by this configuration.
26   int channels = kDefaultAudioChannels;
27 
28   // Average bit rate in bits per second used by this configuration. A value
29   // of "zero" suggests that the bitrate should be automatically selected by
30   // the sender.
31   int bit_rate = 0;
32 
33   // Sample rate for audio RTP timebase.
34   int sample_rate = kDefaultAudioSampleRate;
35 
36   // Target playout delay in milliseconds.
37   std::chrono::milliseconds target_playout_delay = kDefaultTargetPlayoutDelay;
38 
39   // The codec parameter for this configuration. Honors the format laid out
40   // in RFC 6381: https://datatracker.ietf.org/doc/html/rfc6381
41   // NOTE: the "profiles" parameter is not supported in our implementation.
42   std::string codec_parameter;
43 };
44 
45 // A configuration set that can be used by the sender to capture video, as
46 // well as the receiver to playback video. Used by Cast Streaming to provide an
47 // offer to the receiver.
48 struct VideoCaptureConfig {
49   // Video codec represented by this configuration.
50   VideoCodec codec = VideoCodec::kVp8;
51 
52   // Maximum frame rate in frames per second.
53   // For simple cases, the frame rate may be provided by simply setting the
54   // number to the desired value, e.g. 30 or 60FPS. Some common frame rates like
55   // 23.98 FPS (for NTSC compatibility) are represented as fractions, in this
56   // case 24000/1001.
57   SimpleFraction max_frame_rate{kDefaultFrameRate, 1};
58 
59   // Number specifying the maximum bit rate for this stream. A value of
60   // zero means that the maximum bit rate should be automatically selected by
61   // the sender.
62   int max_bit_rate = 0;
63 
64   // Resolutions to be offered to the receiver. At least one resolution
65   // must be provided.
66   std::vector<Resolution> resolutions;
67 
68   // Target playout delay in milliseconds.
69   std::chrono::milliseconds target_playout_delay = kDefaultTargetPlayoutDelay;
70 
71   // The codec parameter for this configuration. Honors the format laid out
72   // in RFC 6381: https://datatracker.ietf.org/doc/html/rfc6381.
73   // VP8 and VP9 codec parameter versions are defined here:
74   // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter#webm
75   // https://www.webmproject.org/vp9/mp4/#codecs-parameter-string
76   // NOTE: the "profiles" parameter is not supported in our implementation.
77   std::string codec_parameter;
78 };
79 
80 }  // namespace cast
81 }  // namespace openscreen
82 
83 #endif  // CAST_STREAMING_CAPTURE_CONFIGS_H_
84