Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.h

Issue 2304363002: Let ViEEncoder express resolution requests as Sinkwants (Closed)
Patch Set: Rebased. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/fakewebrtccall.cc ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) 231 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream)
232 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); 232 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
233 233
234 static std::string CodecSettingsVectorToString( 234 static std::string CodecSettingsVectorToString(
235 const std::vector<VideoCodecSettings>& codecs); 235 const std::vector<VideoCodecSettings>& codecs);
236 236
237 // Wrapper for the sender part, this is where the source is connected and 237 // Wrapper for the sender part, this is where the source is connected and
238 // frames are then converted from cricket frames to webrtc frames. 238 // frames are then converted from cricket frames to webrtc frames.
239 class WebRtcVideoSendStream 239 class WebRtcVideoSendStream
240 : public rtc::VideoSinkInterface<cricket::VideoFrame>, 240 : public rtc::VideoSinkInterface<cricket::VideoFrame>,
241 public rtc::VideoSourceInterface<webrtc::VideoFrame>, 241 public rtc::VideoSourceInterface<webrtc::VideoFrame> {
242 public webrtc::LoadObserver {
243 public: 242 public:
244 WebRtcVideoSendStream( 243 WebRtcVideoSendStream(
245 webrtc::Call* call, 244 webrtc::Call* call,
246 const StreamParams& sp, 245 const StreamParams& sp,
247 webrtc::VideoSendStream::Config config, 246 webrtc::VideoSendStream::Config config,
248 const VideoOptions& options, 247 const VideoOptions& options,
249 WebRtcVideoEncoderFactory* external_encoder_factory, 248 WebRtcVideoEncoderFactory* external_encoder_factory,
250 bool enable_cpu_overuse_detection, 249 bool enable_cpu_overuse_detection,
251 int max_bitrate_bps, 250 int max_bitrate_bps,
252 const rtc::Optional<VideoCodecSettings>& codec_settings, 251 const rtc::Optional<VideoCodecSettings>& codec_settings,
(...skipping 12 matching lines...) Expand all
265 // TODO(perkj, nisse): Refactor WebRtcVideoSendStream to directly connect 264 // TODO(perkj, nisse): Refactor WebRtcVideoSendStream to directly connect
266 // the camera input |source_| 265 // the camera input |source_|
267 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink, 266 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
268 const rtc::VideoSinkWants& wants) override; 267 const rtc::VideoSinkWants& wants) override;
269 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override; 268 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;
270 269
271 void OnFrame(const cricket::VideoFrame& frame) override; 270 void OnFrame(const cricket::VideoFrame& frame) override;
272 bool SetVideoSend(bool mute, 271 bool SetVideoSend(bool mute,
273 const VideoOptions* options, 272 const VideoOptions* options,
274 rtc::VideoSourceInterface<cricket::VideoFrame>* source); 273 rtc::VideoSourceInterface<cricket::VideoFrame>* source);
275 void DisconnectSource();
276 274
277 void SetSend(bool send); 275 void SetSend(bool send);
278 276
279 // Implements webrtc::LoadObserver.
280 void OnLoadUpdate(Load load) override;
281
282 const std::vector<uint32_t>& GetSsrcs() const; 277 const std::vector<uint32_t>& GetSsrcs() const;
283 VideoSenderInfo GetVideoSenderInfo(bool log_stats); 278 VideoSenderInfo GetVideoSenderInfo(bool log_stats);
284 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); 279 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info);
285 280
286 private: 281 private:
287 // Parameters needed to reconstruct the underlying stream. 282 // Parameters needed to reconstruct the underlying stream.
288 // webrtc::VideoSendStream doesn't support setting a lot of options on the 283 // webrtc::VideoSendStream doesn't support setting a lot of options on the
289 // fly, so when those need to be changed we tear down and reconstruct with 284 // fly, so when those need to be changed we tear down and reconstruct with
290 // similar parameters depending on which options changed etc. 285 // similar parameters depending on which options changed etc.
291 struct VideoSendStreamParameters { 286 struct VideoSendStreamParameters {
(...skipping 16 matching lines...) Expand all
308 struct AllocatedEncoder { 303 struct AllocatedEncoder {
309 AllocatedEncoder(webrtc::VideoEncoder* encoder, 304 AllocatedEncoder(webrtc::VideoEncoder* encoder,
310 webrtc::VideoCodecType type, 305 webrtc::VideoCodecType type,
311 bool external); 306 bool external);
312 webrtc::VideoEncoder* encoder; 307 webrtc::VideoEncoder* encoder;
313 webrtc::VideoEncoder* external_encoder; 308 webrtc::VideoEncoder* external_encoder;
314 webrtc::VideoCodecType type; 309 webrtc::VideoCodecType type;
315 bool external; 310 bool external;
316 }; 311 };
317 312
318 // TODO(perkj): VideoFrameInfo is currently used for CPU adaptation since 313 // TODO(perkj): VideoFrameInfo is currently used for sending a black frame
319 // we currently do not express CPU overuse using SinkWants in lower 314 // when the video source is removed. Consider moving that logic to
320 // layers. This will be fixed in an upcoming cl. 315 // VieEncoder or remove it.
321 struct VideoFrameInfo { 316 struct VideoFrameInfo {
322 VideoFrameInfo() 317 VideoFrameInfo()
323 : width(0), 318 : width(0),
324 height(0), 319 height(0),
325 rotation(webrtc::kVideoRotation_0), 320 rotation(webrtc::kVideoRotation_0),
326 is_texture(false) {} 321 is_texture(false) {}
327 int width; 322 int width;
328 int height; 323 int height;
329 webrtc::VideoRotation rotation; 324 webrtc::VideoRotation rotation;
330 bool is_texture; 325 bool is_texture;
331 }; 326 };
332 327
333 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> 328 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
334 ConfigureVideoEncoderSettings(const VideoCodec& codec); 329 ConfigureVideoEncoderSettings(const VideoCodec& codec);
335 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec); 330 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec);
336 void DestroyVideoEncoder(AllocatedEncoder* encoder); 331 void DestroyVideoEncoder(AllocatedEncoder* encoder);
337 void SetCodec(const VideoCodecSettings& codec); 332 void SetCodec(const VideoCodecSettings& codec);
338 void RecreateWebRtcStream(); 333 void RecreateWebRtcStream();
339 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 334 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
340 const VideoCodec& codec) const; 335 const VideoCodec& codec) const;
341 void ReconfigureEncoder(); 336 void ReconfigureEncoder();
342 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); 337 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters);
343 338
344 // Calls Start or Stop according to whether or not |sending_| is true, 339 // Calls Start or Stop according to whether or not |sending_| is true,
345 // and whether or not the encoding in |rtp_parameters_| is active. 340 // and whether or not the encoding in |rtp_parameters_| is active.
346 void UpdateSendState(); 341 void UpdateSendState();
347 342
348 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_);
349
350 rtc::ThreadChecker thread_checker_; 343 rtc::ThreadChecker thread_checker_;
351 rtc::AsyncInvoker invoker_; 344 rtc::AsyncInvoker invoker_;
352 rtc::Thread* worker_thread_; 345 rtc::Thread* worker_thread_;
353 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); 346 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_);
354 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); 347 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_);
355 webrtc::Call* const call_; 348 webrtc::Call* const call_;
356 rtc::VideoSinkWants sink_wants_ ACCESS_ON(&thread_checker_); 349 const bool enable_cpu_overuse_detection_;
357 // Counter used for deciding if the video resolution is currently
358 // restricted by CPU usage. It is reset if |source_| is changed.
359 int cpu_restricted_counter_;
360 // Total number of times resolution as been requested to be changed due to
361 // CPU adaptation.
362 int number_of_cpu_adapt_changes_ ACCESS_ON(&thread_checker_);
363 // Total number of frames sent to |stream_|.
364 int frame_count_ GUARDED_BY(lock_);
365 // Total number of cpu restricted frames sent to |stream_|.
366 int cpu_restricted_frame_count_ GUARDED_BY(lock_);
367 rtc::VideoSourceInterface<cricket::VideoFrame>* source_ 350 rtc::VideoSourceInterface<cricket::VideoFrame>* source_
368 ACCESS_ON(&thread_checker_); 351 ACCESS_ON(&thread_checker_);
369 WebRtcVideoEncoderFactory* const external_encoder_factory_ 352 WebRtcVideoEncoderFactory* const external_encoder_factory_
370 ACCESS_ON(&thread_checker_); 353 ACCESS_ON(&thread_checker_);
371 354
372 rtc::CriticalSection lock_; 355 rtc::CriticalSection lock_;
373 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); 356 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_);
374 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 357 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
375 GUARDED_BY(lock_); 358 GUARDED_BY(lock_);
376 // Contains settings that are the same for all streams in the MediaChannel, 359 // Contains settings that are the same for all streams in the MediaChannel,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 VideoSendParameters send_params_; 517 VideoSendParameters send_params_;
535 VideoOptions default_send_options_; 518 VideoOptions default_send_options_;
536 VideoRecvParameters recv_params_; 519 VideoRecvParameters recv_params_;
537 bool red_disabled_by_remote_side_; 520 bool red_disabled_by_remote_side_;
538 int64_t last_stats_log_ms_; 521 int64_t last_stats_log_ms_;
539 }; 522 };
540 523
541 } // namespace cricket 524 } // namespace cricket
542 525
543 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 526 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
OLDNEW
« no previous file with comments | « webrtc/media/engine/fakewebrtccall.cc ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698