OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_CAST_CONFIG_H_ | 5 #ifndef MEDIA_CAST_CAST_CONFIG_H_ |
6 #define MEDIA_CAST_CAST_CONFIG_H_ | 6 #define MEDIA_CAST_CAST_CONFIG_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 // End-to-end latency in milliseconds. | 39 // End-to-end latency in milliseconds. |
40 // | 40 // |
41 // DO NOT USE THIS (400 ms is proven as ideal for general-purpose use). | 41 // DO NOT USE THIS (400 ms is proven as ideal for general-purpose use). |
42 // | 42 // |
43 // TODO(miu): Change to 400, and confirm nothing has broken in later change. | 43 // TODO(miu): Change to 400, and confirm nothing has broken in later change. |
44 // http://crbug.com/530839 | 44 // http://crbug.com/530839 |
45 kDefaultRtpMaxDelayMs = 100, | 45 kDefaultRtpMaxDelayMs = 100, |
46 | 46 |
47 // Suggested minimum and maximum video bitrates for general-purpose use (up to | 47 // Suggested minimum and maximum video bitrates for general-purpose use (up to |
48 // 1080p, 30 FPS). | 48 // 1080p, 30 FPS). |
49 kDefaultMinVideoKbps = 300, | 49 kDefaultMinVideoBitrate = 300000, |
50 kDefaultMaxVideoKbps = 5000, | 50 kDefaultMaxVideoBitrate = 5000000, |
| 51 |
| 52 // Minimum and Maximum VP8 quantizer in default configuration. |
| 53 kDefaultMaxQp = 63, |
| 54 kDefaultMinQp = 4, |
| 55 |
| 56 kDefaultMaxCpuSaverQp = 25, |
| 57 |
| 58 // Number of video buffers in default configuration (applies only to certain |
| 59 // external codecs). |
| 60 kDefaultNumberOfVideoBuffers = 1, |
51 }; | 61 }; |
52 | 62 |
53 // TODO(miu): Merge AudioSenderConfig and VideoSenderConfig and make their | 63 // These parameters are only for video encoders. |
54 // naming/documentation consistent with FrameReceiverConfig. | 64 struct VideoCodecParams { |
55 // http://crbug.com/530839 | 65 VideoCodecParams(); |
56 struct AudioSenderConfig { | 66 VideoCodecParams(const VideoCodecParams& other); |
57 AudioSenderConfig(); | 67 ~VideoCodecParams(); |
58 AudioSenderConfig(const AudioSenderConfig& other); | |
59 ~AudioSenderConfig(); | |
60 | 68 |
61 // Identifier referring to the sender, used by the receiver. | 69 int max_qp; |
62 uint32_t ssrc; | 70 int min_qp; |
| 71 |
| 72 // The maximum |min_quantizer| set to the encoder when CPU is constrained. |
| 73 // This is a trade-off between higher resolution with lower encoding quality |
| 74 // and lower resolution with higher encoding quality. The set value indicates |
| 75 // the maximum quantizer that the encoder might produce better quality video |
| 76 // at this resolution than lowering resolution with similar CPU usage and |
| 77 // smaller quantizer. The set value has to be between |min_qp| and |max_qp|. |
| 78 // Suggested value range: [4, 30]. It is only used by software VP8 codec. |
| 79 int max_cpu_saver_qp; |
| 80 |
| 81 // This field is used differently by various encoders. |
| 82 // |
| 83 // It defaults to 1. |
| 84 // |
| 85 // For VP8, this field is ignored. |
| 86 // |
| 87 // For H.264 on Mac or iOS, it controls the max number of frames the encoder |
| 88 // may hold before emitting a frame. A larger window may allow higher encoding |
| 89 // efficiency at the cost of latency and memory. Set to 0 to let the encoder |
| 90 // choose a suitable value for the platform and other encoding settings. |
| 91 int max_number_of_video_buffers_used; |
| 92 |
| 93 int number_of_encode_threads; |
| 94 }; |
| 95 |
| 96 struct FrameSenderConfig { |
| 97 FrameSenderConfig(); |
| 98 FrameSenderConfig(const FrameSenderConfig& other); |
| 99 ~FrameSenderConfig(); |
| 100 |
| 101 // The sender's SSRC identifier. |
| 102 uint32_t sender_ssrc; |
63 | 103 |
64 // The receiver's SSRC identifier. | 104 // The receiver's SSRC identifier. |
65 uint32_t receiver_ssrc; | 105 uint32_t receiver_ssrc; |
66 | |
67 // The total amount of time between a frame's capture/recording on the sender | |
68 // and its playback on the receiver (i.e., shown to a user). This should be | |
69 // set to a value large enough to give the system sufficient time to encode, | |
70 // transmit/retransmit, receive, decode, and render; given its run-time | |
71 // environment (sender/receiver hardware performance, network conditions, | |
72 // etc.). | |
73 base::TimeDelta min_playout_delay; | |
74 base::TimeDelta max_playout_delay; | |
75 | |
76 // Starting playout delay when streaming animated content. | |
77 base::TimeDelta animated_playout_delay; | |
78 | |
79 // RTP payload type enum: Specifies the type/encoding of frame data. | |
80 RtpPayloadType rtp_payload_type; | |
81 | |
82 bool use_external_encoder; | |
83 int frequency; | |
84 int channels; | |
85 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best). | |
86 Codec codec; | |
87 | |
88 // The AES crypto key and initialization vector. Each of these strings | |
89 // contains the data in binary form, of size kAesKeySize. If they are empty | |
90 // strings, crypto is not being used. | |
91 std::string aes_key; | |
92 std::string aes_iv_mask; | |
93 }; | |
94 | |
95 struct VideoSenderConfig { | |
96 VideoSenderConfig(); | |
97 VideoSenderConfig(const VideoSenderConfig& other); | |
98 ~VideoSenderConfig(); | |
99 | |
100 // Identifier referring to the sender, used by the receiver. | |
101 uint32_t ssrc; | |
102 | |
103 // The receiver's SSRC identifier. | |
104 uint32_t receiver_ssrc; | |
105 | 106 |
106 // The total amount of time between a frame's capture/recording on the sender | 107 // The total amount of time between a frame's capture/recording on the sender |
107 // and its playback on the receiver (i.e., shown to a user). This should be | 108 // and its playback on the receiver (i.e., shown to a user). This should be |
108 // set to a value large enough to give the system sufficient time to encode, | 109 // set to a value large enough to give the system sufficient time to encode, |
109 // transmit/retransmit, receive, decode, and render; given its run-time | 110 // transmit/retransmit, receive, decode, and render; given its run-time |
110 // environment (sender/receiver hardware performance, network conditions, | 111 // environment (sender/receiver hardware performance, network conditions, |
111 // etc.). | 112 // etc.). |
112 base::TimeDelta min_playout_delay; | 113 base::TimeDelta min_playout_delay; |
113 base::TimeDelta max_playout_delay; | 114 base::TimeDelta max_playout_delay; |
114 | 115 |
115 // Starting playout delay when streaming animated content. | 116 // Starting playout delay when streaming animated content. |
116 base::TimeDelta animated_playout_delay; | 117 base::TimeDelta animated_playout_delay; |
117 | 118 |
118 // RTP payload type enum: Specifies the type/encoding of frame data. | 119 // RTP payload type enum: Specifies the type/encoding of frame data. |
119 RtpPayloadType rtp_payload_type; | 120 RtpPayloadType rtp_payload_type; |
120 | 121 |
| 122 // If true, use an external HW encoder rather than the built-in |
| 123 // software-based one. |
121 bool use_external_encoder; | 124 bool use_external_encoder; |
122 | 125 |
123 float congestion_control_back_off; | 126 // RTP timebase: The number of RTP units advanced per one second. For audio, |
| 127 // this is the sampling rate. For video, by convention, this is 90 kHz. |
| 128 int rtp_timebase; |
| 129 |
| 130 // Number of channels. For audio, this is normally 2. For video, this must |
| 131 // be 1 as Cast does not have support for stereoscopic video. |
| 132 int channels; |
| 133 |
| 134 // For now, only fixed bitrate is used for audio encoding. So for audio, |
| 135 // |max_bitrate| is used, and the other two will be overriden if they are not |
| 136 // equal to |max_bitrate|. |
124 int max_bitrate; | 137 int max_bitrate; |
125 int min_bitrate; | 138 int min_bitrate; |
126 int start_bitrate; | 139 int start_bitrate; |
127 int max_qp; | |
128 int min_qp; | |
129 | 140 |
130 // The maximum |min_quantizer| set to the encoder when CPU is constrained. | 141 double max_frame_rate; |
131 // This is a trade-off between higher resolution with lower encoding quality | |
132 // and lower resolution with higher encoding quality. The set value indicates | |
133 // the maximum quantizer that the encoder might produce better quality video | |
134 // at this resolution than lowering resolution with similar CPU usage and | |
135 // smaller quantizer. The set value has to be between |min_qp| and |max_qp|. | |
136 // Suggested value range: [4, 30]. | |
137 int max_cpu_saver_qp; | |
138 | 142 |
139 int max_frame_rate; // TODO(miu): Should be double, not int. | 143 // Codec used for the compression of signal data. |
140 | |
141 // This field is used differently by various encoders. It defaults to 1. | |
142 // | |
143 // For VP8, this field is ignored. | |
144 // | |
145 // For H.264 on Mac or iOS, it controls the max number of frames the encoder | |
146 // may hold before emitting a frame. A larger window may allow higher encoding | |
147 // efficiency at the cost of latency and memory. Set to 0 to let the encoder | |
148 // choose a suitable value for the platform and other encoding settings. | |
149 int max_number_of_video_buffers_used; | |
150 | |
151 Codec codec; | 144 Codec codec; |
152 int number_of_encode_threads; | |
153 | 145 |
154 // The AES crypto key and initialization vector. Each of these strings | 146 // The AES crypto key and initialization vector. Each of these strings |
155 // contains the data in binary form, of size kAesKeySize. If they are empty | 147 // contains the data in binary form, of size kAesKeySize. If they are empty |
156 // strings, crypto is not being used. | 148 // strings, crypto is not being used. |
157 std::string aes_key; | 149 std::string aes_key; |
158 std::string aes_iv_mask; | 150 std::string aes_iv_mask; |
| 151 |
| 152 // These are codec specific parameters for video streams only. |
| 153 VideoCodecParams video_codec_params; |
159 }; | 154 }; |
160 | 155 |
161 // TODO(miu): Naming and minor type changes are badly needed in a later CL. | 156 // TODO(miu): Naming and minor type changes are badly needed in a later CL. |
162 struct FrameReceiverConfig { | 157 struct FrameReceiverConfig { |
163 FrameReceiverConfig(); | 158 FrameReceiverConfig(); |
164 FrameReceiverConfig(const FrameReceiverConfig& other); | 159 FrameReceiverConfig(const FrameReceiverConfig& other); |
165 ~FrameReceiverConfig(); | 160 ~FrameReceiverConfig(); |
166 | 161 |
167 // The receiver's SSRC identifier. | 162 // The receiver's SSRC identifier. |
168 uint32_t receiver_ssrc; | 163 uint32_t receiver_ssrc; |
(...skipping 16 matching lines...) Expand all Loading... |
185 // this is the sampling rate. For video, by convention, this is 90 kHz. | 180 // this is the sampling rate. For video, by convention, this is 90 kHz. |
186 int rtp_timebase; | 181 int rtp_timebase; |
187 | 182 |
188 // Number of channels. For audio, this is normally 2. For video, this must | 183 // Number of channels. For audio, this is normally 2. For video, this must |
189 // be 1 as Cast does not have support for stereoscopic video. | 184 // be 1 as Cast does not have support for stereoscopic video. |
190 int channels; | 185 int channels; |
191 | 186 |
192 // The target frame rate. For audio, this is normally 100 (i.e., frames have | 187 // The target frame rate. For audio, this is normally 100 (i.e., frames have |
193 // a duration of 10ms each). For video, this is normally 30, but any frame | 188 // a duration of 10ms each). For video, this is normally 30, but any frame |
194 // rate is supported. | 189 // rate is supported. |
195 int target_frame_rate; | 190 double target_frame_rate; |
196 | 191 |
197 // Codec used for the compression of signal data. | 192 // Codec used for the compression of signal data. |
198 // TODO(miu): Merge the AudioCodec and VideoCodec enums into one so this union | 193 // TODO(miu): Merge the AudioCodec and VideoCodec enums into one so this union |
199 // is not necessary. | 194 // is not necessary. |
200 Codec codec; | 195 Codec codec; |
201 | 196 |
202 // The AES crypto key and initialization vector. Each of these strings | 197 // The AES crypto key and initialization vector. Each of these strings |
203 // contains the data in binary form, of size kAesKeySize. If they are empty | 198 // contains the data in binary form, of size kAesKeySize. If they are empty |
204 // strings, crypto is not being used. | 199 // strings, crypto is not being used. |
205 std::string aes_key; | 200 std::string aes_key; |
206 std::string aes_iv_mask; | 201 std::string aes_iv_mask; |
207 }; | 202 }; |
208 | 203 |
209 // TODO(miu): Remove the CreateVEA callbacks. http://crbug.com/454029 | 204 // TODO(miu): Remove the CreateVEA callbacks. http://crbug.com/454029 |
210 typedef base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>, | 205 typedef base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>, |
211 std::unique_ptr<media::VideoEncodeAccelerator>)> | 206 std::unique_ptr<media::VideoEncodeAccelerator>)> |
212 ReceiveVideoEncodeAcceleratorCallback; | 207 ReceiveVideoEncodeAcceleratorCallback; |
213 typedef base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)> | 208 typedef base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)> |
214 CreateVideoEncodeAcceleratorCallback; | 209 CreateVideoEncodeAcceleratorCallback; |
215 typedef base::Callback<void(std::unique_ptr<base::SharedMemory>)> | 210 typedef base::Callback<void(std::unique_ptr<base::SharedMemory>)> |
216 ReceiveVideoEncodeMemoryCallback; | 211 ReceiveVideoEncodeMemoryCallback; |
217 typedef base::Callback<void(size_t size, | 212 typedef base::Callback<void(size_t size, |
218 const ReceiveVideoEncodeMemoryCallback&)> | 213 const ReceiveVideoEncodeMemoryCallback&)> |
219 CreateVideoEncodeMemoryCallback; | 214 CreateVideoEncodeMemoryCallback; |
220 | 215 |
221 } // namespace cast | 216 } // namespace cast |
222 } // namespace media | 217 } // namespace media |
223 | 218 |
224 #endif // MEDIA_CAST_CAST_CONFIG_H_ | 219 #endif // MEDIA_CAST_CAST_CONFIG_H_ |
OLD | NEW |