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

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

Issue 2383493005: Revert of Let ViEEncoder handle resolution changes. (Closed)
Patch Set: Created 4 years, 2 months 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 struct AllocatedEncoder { 313 struct AllocatedEncoder {
314 AllocatedEncoder(webrtc::VideoEncoder* encoder, 314 AllocatedEncoder(webrtc::VideoEncoder* encoder,
315 webrtc::VideoCodecType type, 315 webrtc::VideoCodecType type,
316 bool external); 316 bool external);
317 webrtc::VideoEncoder* encoder; 317 webrtc::VideoEncoder* encoder;
318 webrtc::VideoEncoder* external_encoder; 318 webrtc::VideoEncoder* external_encoder;
319 webrtc::VideoCodecType type; 319 webrtc::VideoCodecType type;
320 bool external; 320 bool external;
321 }; 321 };
322 322
323 // TODO(perkj): VideoFrameInfo is currently used for CPU adaptation since
324 // we currently do not express CPU overuse using SinkWants in lower
325 // layers. This will be fixed in an upcoming cl.
326 struct VideoFrameInfo { 323 struct VideoFrameInfo {
324 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that
325 // hardware encoders can be initialized). This gives us low memory usage
326 // but also makes it so configuration errors are discovered at the time we
327 // apply the settings rather than when we get the first frame (waiting for
328 // the first frame to know that you gave a bad codec parameter could make
329 // debugging hard).
330 // TODO(pbos): Consider setting up encoders lazily.
327 VideoFrameInfo() 331 VideoFrameInfo()
328 : width(0), 332 : width(176),
329 height(0), 333 height(144),
330 rotation(webrtc::kVideoRotation_0), 334 rotation(webrtc::kVideoRotation_0),
331 is_texture(false) {} 335 is_texture(false) {}
332 int width; 336 int width;
333 int height; 337 int height;
334 webrtc::VideoRotation rotation; 338 webrtc::VideoRotation rotation;
335 bool is_texture; 339 bool is_texture;
336 }; 340 };
337 341
342 static std::vector<webrtc::VideoStream> CreateVideoStreams(
343 const VideoCodec& codec,
344 const VideoOptions& options,
345 int max_bitrate_bps,
346 size_t num_streams);
347 static std::vector<webrtc::VideoStream> CreateSimulcastVideoStreams(
348 const VideoCodec& codec,
349 const VideoOptions& options,
350 int max_bitrate_bps,
351 size_t num_streams);
352
338 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> 353 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
339 ConfigureVideoEncoderSettings(const VideoCodec& codec); 354 ConfigureVideoEncoderSettings(const VideoCodec& codec)
340 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec); 355 EXCLUSIVE_LOCKS_REQUIRED(lock_);
341 void DestroyVideoEncoder(AllocatedEncoder* encoder); 356
342 void SetCodec(const VideoCodecSettings& codec); 357 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec)
343 void RecreateWebRtcStream(); 358 EXCLUSIVE_LOCKS_REQUIRED(lock_);
359 void DestroyVideoEncoder(AllocatedEncoder* encoder)
360 EXCLUSIVE_LOCKS_REQUIRED(lock_);
361 void SetCodec(const VideoCodecSettings& codec)
362 EXCLUSIVE_LOCKS_REQUIRED(lock_);
363 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_);
344 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 364 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
345 const VideoCodec& codec) const; 365 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_);
346 void ReconfigureEncoder(); 366 void ReconfigureEncoder() EXCLUSIVE_LOCKS_REQUIRED(lock_);
347 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); 367 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters);
348 368
349 // Calls Start or Stop according to whether or not |sending_| is true, 369 // Calls Start or Stop according to whether or not |sending_| is true,
350 // and whether or not the encoding in |rtp_parameters_| is active. 370 // and whether or not the encoding in |rtp_parameters_| is active.
351 void UpdateSendState(); 371 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_);
352 372
353 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_); 373 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_);
354 374
355 rtc::ThreadChecker thread_checker_; 375 rtc::ThreadChecker thread_checker_;
356 rtc::AsyncInvoker invoker_; 376 rtc::AsyncInvoker invoker_;
357 rtc::Thread* worker_thread_; 377 rtc::Thread* worker_thread_;
358 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); 378 const std::vector<uint32_t> ssrcs_;
359 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); 379 const std::vector<SsrcGroup> ssrc_groups_;
360 webrtc::Call* const call_; 380 webrtc::Call* const call_;
361 rtc::VideoSinkWants sink_wants_ ACCESS_ON(&thread_checker_); 381 rtc::VideoSinkWants sink_wants_;
362 // Counter used for deciding if the video resolution is currently 382 // Counter used for deciding if the video resolution is currently
363 // restricted by CPU usage. It is reset if |source_| is changed. 383 // restricted by CPU usage. It is reset if |source_| is changed.
364 int cpu_restricted_counter_; 384 int cpu_restricted_counter_;
365 // Total number of times resolution as been requested to be changed due to 385 // Total number of times resolution as been requested to be changed due to
366 // CPU adaptation. 386 // CPU adaptation.
367 int number_of_cpu_adapt_changes_ ACCESS_ON(&thread_checker_); 387 int number_of_cpu_adapt_changes_;
368 // Total number of frames sent to |stream_|. 388 // Total number of frames sent to |stream_|.
369 int frame_count_ GUARDED_BY(lock_); 389 int frame_count_ GUARDED_BY(lock_);
370 // Total number of cpu restricted frames sent to |stream_|. 390 // Total number of cpu restricted frames sent to |stream_|.
371 int cpu_restricted_frame_count_ GUARDED_BY(lock_); 391 int cpu_restricted_frame_count_ GUARDED_BY(lock_);
372 rtc::VideoSourceInterface<cricket::VideoFrame>* source_ 392 rtc::VideoSourceInterface<cricket::VideoFrame>* source_;
373 ACCESS_ON(&thread_checker_);
374 WebRtcVideoEncoderFactory* const external_encoder_factory_ 393 WebRtcVideoEncoderFactory* const external_encoder_factory_
375 ACCESS_ON(&thread_checker_); 394 GUARDED_BY(lock_);
376 395
377 rtc::CriticalSection lock_; 396 rtc::CriticalSection lock_;
378 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); 397 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_);
379 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 398 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
380 GUARDED_BY(lock_); 399 GUARDED_BY(lock_);
381 // Contains settings that are the same for all streams in the MediaChannel, 400 // Contains settings that are the same for all streams in the MediaChannel,
382 // such as codecs, header extensions, and the global bitrate limit for the 401 // such as codecs, header extensions, and the global bitrate limit for the
383 // entire channel. 402 // entire channel.
384 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_); 403 VideoSendStreamParameters parameters_ GUARDED_BY(lock_);
385 // Contains settings that are unique for each stream, such as max_bitrate. 404 // Contains settings that are unique for each stream, such as max_bitrate.
386 // Does *not* contain codecs, however. 405 // Does *not* contain codecs, however.
387 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. 406 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_.
388 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only 407 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only
389 // one stream per MediaChannel. 408 // one stream per MediaChannel.
390 webrtc::RtpParameters rtp_parameters_ ACCESS_ON(&thread_checker_); 409 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_);
391 AllocatedEncoder allocated_encoder_ ACCESS_ON(&thread_checker_); 410 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_);
411 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_);
392 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_); 412 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_);
393 413
394 bool sending_ ACCESS_ON(&thread_checker_); 414 bool sending_ GUARDED_BY(lock_);
395 415
396 // The timestamp of the last frame received 416 // The timestamp of the last frame received
397 // Used to generate timestamp for the black frame when source is removed 417 // Used to generate timestamp for the black frame when source is removed
398 int64_t last_frame_timestamp_us_ GUARDED_BY(lock_); 418 int64_t last_frame_timestamp_us_ GUARDED_BY(lock_);
399 }; 419 };
400 420
401 // Wrapper for the receiver part, contains configs etc. that are needed to 421 // Wrapper for the receiver part, contains configs etc. that are needed to
402 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper 422 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper
403 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and 423 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and
404 // rtc::VideoSinkInterface<cricket::VideoFrame>. 424 // rtc::VideoSinkInterface<cricket::VideoFrame>.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 VideoSendParameters send_params_; 559 VideoSendParameters send_params_;
540 VideoOptions default_send_options_; 560 VideoOptions default_send_options_;
541 VideoRecvParameters recv_params_; 561 VideoRecvParameters recv_params_;
542 bool red_disabled_by_remote_side_; 562 bool red_disabled_by_remote_side_;
543 int64_t last_stats_log_ms_; 563 int64_t last_stats_log_ms_;
544 }; 564 };
545 565
546 } // namespace cricket 566 } // namespace cricket
547 567
548 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 568 #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