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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: Fix build on Win 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
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.
323 struct VideoFrameInfo { 326 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.
331 VideoFrameInfo() 327 VideoFrameInfo()
332 : width(176), 328 : width(0),
333 height(144), 329 height(0),
334 rotation(webrtc::kVideoRotation_0), 330 rotation(webrtc::kVideoRotation_0),
335 is_texture(false) {} 331 is_texture(false) {}
336 int width; 332 int width;
337 int height; 333 int height;
338 webrtc::VideoRotation rotation; 334 webrtc::VideoRotation rotation;
339 bool is_texture; 335 bool is_texture;
340 }; 336 };
341 337
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
353 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> 338 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
354 ConfigureVideoEncoderSettings(const VideoCodec& codec) 339 ConfigureVideoEncoderSettings(const VideoCodec& codec);
355 EXCLUSIVE_LOCKS_REQUIRED(lock_); 340 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec);
356 341 void DestroyVideoEncoder(AllocatedEncoder* encoder);
357 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) 342 void SetCodec(const VideoCodecSettings& codec);
358 EXCLUSIVE_LOCKS_REQUIRED(lock_); 343 void RecreateWebRtcStream();
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_);
364 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( 344 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
365 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); 345 const VideoCodec& codec) const;
366 void ReconfigureEncoder() EXCLUSIVE_LOCKS_REQUIRED(lock_); 346 void ReconfigureEncoder();
367 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); 347 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters);
368 348
369 // Calls Start or Stop according to whether or not |sending_| is true, 349 // Calls Start or Stop according to whether or not |sending_| is true,
370 // and whether or not the encoding in |rtp_parameters_| is active. 350 // and whether or not the encoding in |rtp_parameters_| is active.
371 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); 351 void UpdateSendState();
372 352
373 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_); 353 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_);
374 354
375 rtc::ThreadChecker thread_checker_; 355 rtc::ThreadChecker thread_checker_;
376 rtc::AsyncInvoker invoker_; 356 rtc::AsyncInvoker invoker_;
377 rtc::Thread* worker_thread_; 357 rtc::Thread* worker_thread_;
378 const std::vector<uint32_t> ssrcs_; 358 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_);
379 const std::vector<SsrcGroup> ssrc_groups_; 359 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_);
380 webrtc::Call* const call_; 360 webrtc::Call* const call_;
381 rtc::VideoSinkWants sink_wants_; 361 rtc::VideoSinkWants sink_wants_ ACCESS_ON(&thread_checker_);
382 // Counter used for deciding if the video resolution is currently 362 // Counter used for deciding if the video resolution is currently
383 // restricted by CPU usage. It is reset if |source_| is changed. 363 // restricted by CPU usage. It is reset if |source_| is changed.
384 int cpu_restricted_counter_; 364 int cpu_restricted_counter_;
385 // Total number of times resolution as been requested to be changed due to 365 // Total number of times resolution as been requested to be changed due to
386 // CPU adaptation. 366 // CPU adaptation.
387 int number_of_cpu_adapt_changes_; 367 int number_of_cpu_adapt_changes_ ACCESS_ON(&thread_checker_);
388 // Total number of frames sent to |stream_|. 368 // Total number of frames sent to |stream_|.
389 int frame_count_ GUARDED_BY(lock_); 369 int frame_count_ GUARDED_BY(lock_);
390 // Total number of cpu restricted frames sent to |stream_|. 370 // Total number of cpu restricted frames sent to |stream_|.
391 int cpu_restricted_frame_count_ GUARDED_BY(lock_); 371 int cpu_restricted_frame_count_ GUARDED_BY(lock_);
392 rtc::VideoSourceInterface<cricket::VideoFrame>* source_; 372 rtc::VideoSourceInterface<cricket::VideoFrame>* source_
373 ACCESS_ON(&thread_checker_);
393 WebRtcVideoEncoderFactory* const external_encoder_factory_ 374 WebRtcVideoEncoderFactory* const external_encoder_factory_
394 GUARDED_BY(lock_); 375 ACCESS_ON(&thread_checker_);
395 376
396 rtc::CriticalSection lock_; 377 rtc::CriticalSection lock_;
397 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); 378 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_);
398 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 379 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
399 GUARDED_BY(lock_); 380 GUARDED_BY(lock_);
400 // Contains settings that are the same for all streams in the MediaChannel, 381 // Contains settings that are the same for all streams in the MediaChannel,
401 // such as codecs, header extensions, and the global bitrate limit for the 382 // such as codecs, header extensions, and the global bitrate limit for the
402 // entire channel. 383 // entire channel.
403 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); 384 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_);
404 // Contains settings that are unique for each stream, such as max_bitrate. 385 // Contains settings that are unique for each stream, such as max_bitrate.
405 // Does *not* contain codecs, however. 386 // Does *not* contain codecs, however.
406 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. 387 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_.
407 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only 388 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only
408 // one stream per MediaChannel. 389 // one stream per MediaChannel.
409 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); 390 webrtc::RtpParameters rtp_parameters_ ACCESS_ON(&thread_checker_);
410 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); 391 AllocatedEncoder allocated_encoder_ ACCESS_ON(&thread_checker_);
411 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_);
412 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_); 392 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_);
413 393
414 bool sending_ GUARDED_BY(lock_); 394 bool sending_ ACCESS_ON(&thread_checker_);
415 395
416 // The timestamp of the last frame received 396 // The timestamp of the last frame received
417 // Used to generate timestamp for the black frame when source is removed 397 // Used to generate timestamp for the black frame when source is removed
418 int64_t last_frame_timestamp_us_ GUARDED_BY(lock_); 398 int64_t last_frame_timestamp_us_ GUARDED_BY(lock_);
419 }; 399 };
420 400
421 // Wrapper for the receiver part, contains configs etc. that are needed to 401 // Wrapper for the receiver part, contains configs etc. that are needed to
422 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper 402 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper
423 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and 403 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and
424 // rtc::VideoSinkInterface<cricket::VideoFrame>. 404 // rtc::VideoSinkInterface<cricket::VideoFrame>.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 VideoSendParameters send_params_; 539 VideoSendParameters send_params_;
560 VideoOptions default_send_options_; 540 VideoOptions default_send_options_;
561 VideoRecvParameters recv_params_; 541 VideoRecvParameters recv_params_;
562 bool red_disabled_by_remote_side_; 542 bool red_disabled_by_remote_side_;
563 int64_t last_stats_log_ms_; 543 int64_t last_stats_log_ms_;
564 }; 544 };
565 545
566 } // namespace cricket 546 } // namespace cricket
567 547
568 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ 548 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698