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 26 matching lines...) Expand all Loading... | |
37 kDefaultMaxFrameRate = 30, | 37 kDefaultMaxFrameRate = 30, |
38 | 38 |
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 // RTP payload types that identify an RTP stream as audio or video. | |
48 kDefaultRtpAudioPayloadType = 127, | |
49 kDefaultRtpVideoPayloadType = 96, | |
50 | |
51 // 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 |
52 // 1080p, 30 FPS). | 48 // 1080p, 30 FPS). |
53 kDefaultMinVideoKbps = 300, | 49 kDefaultMinVideoKbps = 300, |
54 kDefaultMaxVideoKbps = 5000, | 50 kDefaultMaxVideoKbps = 5000, |
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, | |
55 }; | 61 }; |
56 | 62 |
57 // TODO(miu): Merge AudioSenderConfig and VideoSenderConfig and make their | 63 // These parameters are only for video encoders. |
58 // naming/documentation consistent with FrameReceiverConfig. | 64 struct CodecSpecificParams { |
59 // http://crbug.com/530839 | 65 CodecSpecificParams(); |
60 struct AudioSenderConfig { | 66 CodecSpecificParams(const CodecSpecificParams& other); |
61 AudioSenderConfig(); | 67 ~CodecSpecificParams(); |
62 AudioSenderConfig(const AudioSenderConfig& other); | |
63 ~AudioSenderConfig(); | |
64 | 68 |
65 // Identifier referring to the sender, used by the receiver. | 69 int start_bitrate; |
66 uint32_t ssrc; | 70 int max_qp; |
71 int min_qp; | |
72 | |
73 // The maximum |min_quantizer| set to the encoder when CPU is constrained. | |
74 // This is a trade-off between higher resolution with lower encoding quality | |
75 // and lower resolution with higher encoding quality. The set value indicates | |
76 // the maximum quantizer that the encoder might produce better quality video | |
77 // at this resolution than lowering resolution with similar CPU usage and | |
78 // smaller quantizer. The set value has to be between |min_qp| and |max_qp|. | |
79 // Suggested value range: [4, 30]. It is only used by software VP8 codec. | |
80 int max_cpu_saver_qp; | |
81 | |
82 // This field is used differently by various encoders. | |
83 // | |
84 // It defaults to 1. | |
85 // | |
86 // For VP8, this field is ignored. | |
87 // | |
88 // For H.264 on Mac or iOS, it controls the max number of frames the encoder | |
89 // may hold before emitting a frame. A larger window may allow higher encoding | |
90 // efficiency at the cost of latency and memory. Set to 0 to let the encoder | |
91 // choose a suitable value for the platform and other encoding settings. | |
92 int max_number_of_video_buffers_used; | |
93 | |
94 int number_of_encode_threads; | |
95 }; | |
96 | |
97 struct FrameSenderConfig { | |
98 FrameSenderConfig(); | |
99 FrameSenderConfig(const FrameSenderConfig& other); | |
100 ~FrameSenderConfig(); | |
101 | |
102 // The sender's SSRC identifier. | |
103 uint32_t sender_ssrc; | |
67 | 104 |
68 // The receiver's SSRC identifier. | 105 // The receiver's SSRC identifier. |
69 uint32_t receiver_ssrc; | 106 uint32_t receiver_ssrc; |
70 | |
71 // The total amount of time between a frame's capture/recording on the sender | |
72 // and its playback on the receiver (i.e., shown to a user). This should be | |
73 // set to a value large enough to give the system sufficient time to encode, | |
74 // transmit/retransmit, receive, decode, and render; given its run-time | |
75 // environment (sender/receiver hardware performance, network conditions, | |
76 // etc.). | |
77 base::TimeDelta min_playout_delay; | |
78 base::TimeDelta max_playout_delay; | |
79 | |
80 // Starting playout delay when streaming animated content. | |
81 base::TimeDelta animated_playout_delay; | |
82 | |
83 // RTP payload type enum: Specifies the type/encoding of frame data. | |
84 int rtp_payload_type; | |
85 | |
86 bool use_external_encoder; | |
87 int frequency; | |
88 int channels; | |
89 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best). | |
90 Codec codec; | |
91 | |
92 // The AES crypto key and initialization vector. Each of these strings | |
93 // contains the data in binary form, of size kAesKeySize. If they are empty | |
94 // strings, crypto is not being used. | |
95 std::string aes_key; | |
96 std::string aes_iv_mask; | |
97 }; | |
98 | |
99 struct VideoSenderConfig { | |
100 VideoSenderConfig(); | |
101 VideoSenderConfig(const VideoSenderConfig& other); | |
102 ~VideoSenderConfig(); | |
103 | |
104 // Identifier referring to the sender, used by the receiver. | |
105 uint32_t ssrc; | |
106 | |
107 // The receiver's SSRC identifier. | |
108 uint32_t receiver_ssrc; | |
109 | 107 |
110 // The total amount of time between a frame's capture/recording on the sender | 108 // The total amount of time between a frame's capture/recording on the sender |
111 // and its playback on the receiver (i.e., shown to a user). This should be | 109 // and its playback on the receiver (i.e., shown to a user). This should be |
112 // set to a value large enough to give the system sufficient time to encode, | 110 // set to a value large enough to give the system sufficient time to encode, |
113 // transmit/retransmit, receive, decode, and render; given its run-time | 111 // transmit/retransmit, receive, decode, and render; given its run-time |
114 // environment (sender/receiver hardware performance, network conditions, | 112 // environment (sender/receiver hardware performance, network conditions, |
115 // etc.). | 113 // etc.). |
116 base::TimeDelta min_playout_delay; | 114 base::TimeDelta min_playout_delay; |
117 base::TimeDelta max_playout_delay; | 115 base::TimeDelta max_playout_delay; |
118 | 116 |
119 // Starting playout delay when streaming animated content. | 117 // Starting playout delay when streaming animated content. |
120 base::TimeDelta animated_playout_delay; | 118 base::TimeDelta animated_playout_delay; |
121 | 119 |
122 // RTP payload type enum: Specifies the type/encoding of frame data. | 120 // RTP payload type enum: Specifies the type/encoding of frame data. |
123 int rtp_payload_type; | 121 RtpPayloadType rtp_payload_type; |
124 | 122 |
125 bool use_external_encoder; | 123 bool use_external_encoder; |
miu
2016/06/30 21:59:43
Let's add a comment like, "If true, use an externa
xjz
2016/07/01 23:52:09
Done.
| |
126 | 124 |
127 float congestion_control_back_off; | 125 int frequency; |
miu
2016/06/30 21:59:43
Now might be a good time to rename this to rtp_tim
xjz
2016/07/01 23:52:09
Done.
| |
126 | |
127 int channels; | |
128 | |
129 // Audio streams only use |max_bitrate|. | |
miu
2016/06/30 21:59:43
Probably not worth mentioning that audio uses only
xjz
2016/07/01 23:52:09
Moved |start_bitrate| back to here.
Added comments
| |
130 // Audio only: Set to <= 0 for "auto variable bitrate" (libopus knows best). | |
128 int max_bitrate; | 131 int max_bitrate; |
129 int min_bitrate; | 132 int min_bitrate; |
130 int start_bitrate; | 133 double max_frame_rate; |
miu
2016/06/30 21:59:43
Nice! Thanks for resolving the TODO! :)
xjz
2016/07/01 23:52:09
:)
| |
131 int max_qp; | |
132 int min_qp; | |
133 | |
134 // The maximum |min_quantizer| set to the encoder when CPU is constrained. | |
135 // This is a trade-off between higher resolution with lower encoding quality | |
136 // and lower resolution with higher encoding quality. The set value indicates | |
137 // the maximum quantizer that the encoder might produce better quality video | |
138 // at this resolution than lowering resolution with similar CPU usage and | |
139 // smaller quantizer. The set value has to be between |min_qp| and |max_qp|. | |
140 // Suggested value range: [4, 30]. | |
141 int max_cpu_saver_qp; | |
142 | |
143 int max_frame_rate; // TODO(miu): Should be double, not int. | |
144 | |
145 // This field is used differently by various encoders. It defaults to 1. | |
146 // | |
147 // For VP8, this field is ignored. | |
148 // | |
149 // For H.264 on Mac or iOS, it controls the max number of frames the encoder | |
150 // may hold before emitting a frame. A larger window may allow higher encoding | |
151 // efficiency at the cost of latency and memory. Set to 0 to let the encoder | |
152 // choose a suitable value for the platform and other encoding settings. | |
153 int max_number_of_video_buffers_used; | |
154 | 134 |
155 Codec codec; | 135 Codec codec; |
156 int number_of_encode_threads; | |
157 | 136 |
158 // The AES crypto key and initialization vector. Each of these strings | 137 // The AES crypto key and initialization vector. Each of these strings |
159 // contains the data in binary form, of size kAesKeySize. If they are empty | 138 // contains the data in binary form, of size kAesKeySize. If they are empty |
160 // strings, crypto is not being used. | 139 // strings, crypto is not being used. |
161 std::string aes_key; | 140 std::string aes_key; |
162 std::string aes_iv_mask; | 141 std::string aes_iv_mask; |
142 | |
143 // These are codec specific parameters for video streams only. | |
144 CodecSpecificParams codec_specific_params; | |
miu
2016/06/30 21:59:43
Please rename (for precision). Suggestion:
s/Code
xjz
2016/07/01 23:52:09
Done.
| |
163 }; | 145 }; |
164 | 146 |
165 // TODO(miu): Naming and minor type changes are badly needed in a later CL. | 147 // TODO(miu): Naming and minor type changes are badly needed in a later CL. |
166 struct FrameReceiverConfig { | 148 struct FrameReceiverConfig { |
167 FrameReceiverConfig(); | 149 FrameReceiverConfig(); |
168 FrameReceiverConfig(const FrameReceiverConfig& other); | 150 FrameReceiverConfig(const FrameReceiverConfig& other); |
169 ~FrameReceiverConfig(); | 151 ~FrameReceiverConfig(); |
170 | 152 |
171 // The receiver's SSRC identifier. | 153 // The receiver's SSRC identifier. |
172 uint32_t receiver_ssrc; | 154 uint32_t receiver_ssrc; |
173 | 155 |
174 // The sender's SSRC identifier. | 156 // The sender's SSRC identifier. |
175 uint32_t sender_ssrc; | 157 uint32_t sender_ssrc; |
176 | 158 |
177 // The total amount of time between a frame's capture/recording on the sender | 159 // The total amount of time between a frame's capture/recording on the sender |
178 // and its playback on the receiver (i.e., shown to a user). This is fixed as | 160 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
179 // a value large enough to give the system sufficient time to encode, | 161 // a value large enough to give the system sufficient time to encode, |
180 // transmit/retransmit, receive, decode, and render; given its run-time | 162 // transmit/retransmit, receive, decode, and render; given its run-time |
181 // environment (sender/receiver hardware performance, network conditions, | 163 // environment (sender/receiver hardware performance, network conditions, |
182 // etc.). | 164 // etc.). |
183 int rtp_max_delay_ms; // TODO(miu): Change to TimeDelta target_playout_delay. | 165 int rtp_max_delay_ms; // TODO(miu): Change to TimeDelta target_playout_delay. |
184 | 166 |
185 // RTP payload type enum: Specifies the type/encoding of frame data. | 167 // RTP payload type enum: Specifies the type/encoding of frame data. |
186 int rtp_payload_type; | 168 RtpPayloadType rtp_payload_type; |
187 | 169 |
188 // RTP timebase: The number of RTP units advanced per one second. For audio, | 170 // RTP timebase: The number of RTP units advanced per one second. For audio, |
189 // this is the sampling rate. For video, by convention, this is 90 kHz. | 171 // this is the sampling rate. For video, by convention, this is 90 kHz. |
190 int rtp_timebase; | 172 int rtp_timebase; |
191 | 173 |
192 // Number of channels. For audio, this is normally 2. For video, this must | 174 // Number of channels. For audio, this is normally 2. For video, this must |
193 // be 1 as Cast does not have support for stereoscopic video. | 175 // be 1 as Cast does not have support for stereoscopic video. |
194 int channels; | 176 int channels; |
195 | 177 |
196 // The target frame rate. For audio, this is normally 100 (i.e., frames have | 178 // The target frame rate. For audio, this is normally 100 (i.e., frames have |
(...skipping 22 matching lines...) Expand all Loading... | |
219 typedef base::Callback<void(std::unique_ptr<base::SharedMemory>)> | 201 typedef base::Callback<void(std::unique_ptr<base::SharedMemory>)> |
220 ReceiveVideoEncodeMemoryCallback; | 202 ReceiveVideoEncodeMemoryCallback; |
221 typedef base::Callback<void(size_t size, | 203 typedef base::Callback<void(size_t size, |
222 const ReceiveVideoEncodeMemoryCallback&)> | 204 const ReceiveVideoEncodeMemoryCallback&)> |
223 CreateVideoEncodeMemoryCallback; | 205 CreateVideoEncodeMemoryCallback; |
224 | 206 |
225 } // namespace cast | 207 } // namespace cast |
226 } // namespace media | 208 } // namespace media |
227 | 209 |
228 #endif // MEDIA_CAST_CAST_CONFIG_H_ | 210 #endif // MEDIA_CAST_CAST_CONFIG_H_ |
OLD | NEW |