| OLD | NEW |
| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 struct Dimensions { | 296 struct Dimensions { |
| 297 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that | 297 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that |
| 298 // hardware encoders can be initialized). This gives us low memory usage | 298 // hardware encoders can be initialized). This gives us low memory usage |
| 299 // but also makes it so configuration errors are discovered at the time we | 299 // but also makes it so configuration errors are discovered at the time we |
| 300 // apply the settings rather than when we get the first frame (waiting for | 300 // apply the settings rather than when we get the first frame (waiting for |
| 301 // the first frame to know that you gave a bad codec parameter could make | 301 // the first frame to know that you gave a bad codec parameter could make |
| 302 // debugging hard). | 302 // debugging hard). |
| 303 // TODO(pbos): Consider setting up encoders lazily. | 303 // TODO(pbos): Consider setting up encoders lazily. |
| 304 Dimensions() : width(176), height(144), is_screencast(false) {} | 304 Dimensions() : width(176), height(144) {} |
| 305 int width; | 305 int width; |
| 306 int height; | 306 int height; |
| 307 bool is_screencast; | |
| 308 }; | 307 }; |
| 309 | 308 |
| 310 union VideoEncoderSettings { | 309 union VideoEncoderSettings { |
| 311 webrtc::VideoCodecH264 h264; | 310 webrtc::VideoCodecH264 h264; |
| 312 webrtc::VideoCodecVP8 vp8; | 311 webrtc::VideoCodecVP8 vp8; |
| 313 webrtc::VideoCodecVP9 vp9; | 312 webrtc::VideoCodecVP9 vp9; |
| 314 }; | 313 }; |
| 315 | 314 |
| 316 static std::vector<webrtc::VideoStream> CreateVideoStreams( | 315 static std::vector<webrtc::VideoStream> CreateVideoStreams( |
| 317 const VideoCodec& codec, | 316 const VideoCodec& codec, |
| 318 const VideoOptions& options, | 317 const VideoOptions& options, |
| 319 int max_bitrate_bps, | 318 int max_bitrate_bps, |
| 320 size_t num_streams); | 319 size_t num_streams); |
| 321 static std::vector<webrtc::VideoStream> CreateSimulcastVideoStreams( | 320 static std::vector<webrtc::VideoStream> CreateSimulcastVideoStreams( |
| 322 const VideoCodec& codec, | 321 const VideoCodec& codec, |
| 323 const VideoOptions& options, | 322 const VideoOptions& options, |
| 324 int max_bitrate_bps, | 323 int max_bitrate_bps, |
| 325 size_t num_streams); | 324 size_t num_streams); |
| 326 | 325 |
| 327 void* ConfigureVideoEncoderSettings(const VideoCodec& codec, | 326 void* ConfigureVideoEncoderSettings(const VideoCodec& codec) |
| 328 const VideoOptions& options, | |
| 329 bool is_screencast) | |
| 330 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 327 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 331 | 328 |
| 332 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) | 329 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) |
| 333 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 330 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 334 void DestroyVideoEncoder(AllocatedEncoder* encoder) | 331 void DestroyVideoEncoder(AllocatedEncoder* encoder) |
| 335 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 332 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 336 void SetCodec(const VideoCodecSettings& codec) | 333 void SetCodec(const VideoCodecSettings& codec) |
| 337 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 334 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 338 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 335 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 339 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | 336 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( |
| 340 const Dimensions& dimensions, | 337 const Dimensions& dimensions, |
| 341 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); | 338 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 342 void SetDimensions(int width, int height, bool is_screencast) | 339 void SetDimensions(int width, int height) |
| 343 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 340 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 344 | 341 |
| 345 rtc::ThreadChecker thread_checker_; | 342 rtc::ThreadChecker thread_checker_; |
| 346 rtc::AsyncInvoker invoker_; | 343 rtc::AsyncInvoker invoker_; |
| 347 rtc::Thread* worker_thread_; | 344 rtc::Thread* worker_thread_; |
| 348 const std::vector<uint32_t> ssrcs_; | 345 const std::vector<uint32_t> ssrcs_; |
| 349 const std::vector<SsrcGroup> ssrc_groups_; | 346 const std::vector<SsrcGroup> ssrc_groups_; |
| 350 webrtc::Call* const call_; | 347 webrtc::Call* const call_; |
| 351 rtc::VideoSinkWants sink_wants_; | 348 rtc::VideoSinkWants sink_wants_; |
| 352 // Counter used for deciding if the video resolution is currently | 349 // Counter used for deciding if the video resolution is currently |
| 353 // restricted by CPU usage. It is reset if |capturer_| is changed. | 350 // restricted by CPU usage. It is reset if |capturer_| is changed. |
| 354 int cpu_restricted_counter_; | 351 int cpu_restricted_counter_; |
| 355 // Total number of times resolution as been requested to be changed due to | 352 // Total number of times resolution as been requested to be changed due to |
| 356 // CPU adaptation. | 353 // CPU adaptation. |
| 357 int number_of_cpu_adapt_changes_; | 354 int number_of_cpu_adapt_changes_; |
| 358 VideoCapturer* capturer_; | 355 VideoCapturer* capturer_; |
| 359 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 356 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 360 GUARDED_BY(lock_); | 357 GUARDED_BY(lock_); |
| 361 | 358 |
| 362 rtc::CriticalSection lock_; | 359 rtc::CriticalSection lock_; |
| 363 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 360 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
| 364 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 361 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 365 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 362 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
| 366 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 363 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
| 367 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 364 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
| 368 Dimensions last_dimensions_ GUARDED_BY(lock_); | 365 Dimensions last_dimensions_ GUARDED_BY(lock_); |
| 369 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 366 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
| 370 webrtc::kVideoRotation_0; | 367 webrtc::kVideoRotation_0; |
| 371 | 368 |
| 372 bool capturer_is_screencast_ GUARDED_BY(lock_); | |
| 373 bool sending_ GUARDED_BY(lock_); | 369 bool sending_ GUARDED_BY(lock_); |
| 374 bool muted_ GUARDED_BY(lock_); | 370 bool muted_ GUARDED_BY(lock_); |
| 375 | 371 |
| 376 // The timestamp of the first frame received | 372 // The timestamp of the first frame received |
| 377 // Used to generate the timestamps of subsequent frames | 373 // Used to generate the timestamps of subsequent frames |
| 378 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | 374 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); |
| 379 | 375 |
| 380 // The timestamp of the last frame received | 376 // The timestamp of the last frame received |
| 381 // Used to generate timestamp for the black frame when capturer is removed | 377 // Used to generate timestamp for the black frame when capturer is removed |
| 382 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 378 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 webrtc::Call::Config::BitrateConfig bitrate_config_; | 515 webrtc::Call::Config::BitrateConfig bitrate_config_; |
| 520 // TODO(deadbeef): Don't duplicate information between | 516 // TODO(deadbeef): Don't duplicate information between |
| 521 // send_params/recv_params, rtp_extensions, options, etc. | 517 // send_params/recv_params, rtp_extensions, options, etc. |
| 522 VideoSendParameters send_params_; | 518 VideoSendParameters send_params_; |
| 523 VideoRecvParameters recv_params_; | 519 VideoRecvParameters recv_params_; |
| 524 }; | 520 }; |
| 525 | 521 |
| 526 } // namespace cricket | 522 } // namespace cricket |
| 527 | 523 |
| 528 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 524 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |