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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 public: | 247 public: |
248 WebRtcVideoSendStream( | 248 WebRtcVideoSendStream( |
249 webrtc::Call* call, | 249 webrtc::Call* call, |
250 const StreamParams& sp, | 250 const StreamParams& sp, |
251 const webrtc::VideoSendStream::Config& config, | 251 const webrtc::VideoSendStream::Config& config, |
252 const VideoOptions& options, | 252 const VideoOptions& options, |
253 WebRtcVideoEncoderFactory* external_encoder_factory, | 253 WebRtcVideoEncoderFactory* external_encoder_factory, |
254 bool enable_cpu_overuse_detection, | 254 bool enable_cpu_overuse_detection, |
255 int max_bitrate_bps, | 255 int max_bitrate_bps, |
256 const rtc::Optional<VideoCodecSettings>& codec_settings, | 256 const rtc::Optional<VideoCodecSettings>& codec_settings, |
257 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 257 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, |
258 const VideoSendParameters& send_params); | 258 const VideoSendParameters& send_params); |
259 virtual ~WebRtcVideoSendStream(); | 259 virtual ~WebRtcVideoSendStream(); |
260 | 260 |
261 void SetSendParameters(const ChangedSendParameters& send_params); | 261 void SetSendParameters(const ChangedSendParameters& send_params); |
262 bool SetRtpParameters(const webrtc::RtpParameters& parameters); | 262 bool SetRtpParameters(const webrtc::RtpParameters& parameters); |
263 webrtc::RtpParameters GetRtpParameters() const; | 263 webrtc::RtpParameters GetRtpParameters() const; |
264 | 264 |
265 void OnFrame(const cricket::VideoFrame& frame) override; | 265 void OnFrame(const cricket::VideoFrame& frame) override; |
266 bool SetVideoSend(bool mute, | 266 bool SetVideoSend(bool mute, |
267 const VideoOptions* options, | 267 const VideoOptions* options, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 struct AllocatedEncoder { | 302 struct AllocatedEncoder { |
303 AllocatedEncoder(webrtc::VideoEncoder* encoder, | 303 AllocatedEncoder(webrtc::VideoEncoder* encoder, |
304 webrtc::VideoCodecType type, | 304 webrtc::VideoCodecType type, |
305 bool external); | 305 bool external); |
306 webrtc::VideoEncoder* encoder; | 306 webrtc::VideoEncoder* encoder; |
307 webrtc::VideoEncoder* external_encoder; | 307 webrtc::VideoEncoder* external_encoder; |
308 webrtc::VideoCodecType type; | 308 webrtc::VideoCodecType type; |
309 bool external; | 309 bool external; |
310 }; | 310 }; |
311 | 311 |
312 struct Dimensions { | 312 struct VideoFrameInfo { |
313 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that | 313 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that |
314 // hardware encoders can be initialized). This gives us low memory usage | 314 // hardware encoders can be initialized). This gives us low memory usage |
315 // but also makes it so configuration errors are discovered at the time we | 315 // but also makes it so configuration errors are discovered at the time we |
316 // apply the settings rather than when we get the first frame (waiting for | 316 // apply the settings rather than when we get the first frame (waiting for |
317 // the first frame to know that you gave a bad codec parameter could make | 317 // the first frame to know that you gave a bad codec parameter could make |
318 // debugging hard). | 318 // debugging hard). |
319 // TODO(pbos): Consider setting up encoders lazily. | 319 // TODO(pbos): Consider setting up encoders lazily. |
320 Dimensions() : width(176), height(144) {} | 320 VideoFrameInfo() |
| 321 : width(176), |
| 322 height(144), |
| 323 rotation(webrtc::kVideoRotation_0), |
| 324 is_texture(false) {} |
321 int width; | 325 int width; |
322 int height; | 326 int height; |
| 327 webrtc::VideoRotation rotation; |
| 328 bool is_texture; |
323 }; | 329 }; |
324 | 330 |
325 union VideoEncoderSettings { | 331 union VideoEncoderSettings { |
326 webrtc::VideoCodecH264 h264; | 332 webrtc::VideoCodecH264 h264; |
327 webrtc::VideoCodecVP8 vp8; | 333 webrtc::VideoCodecVP8 vp8; |
328 webrtc::VideoCodecVP9 vp9; | 334 webrtc::VideoCodecVP9 vp9; |
329 }; | 335 }; |
330 | 336 |
331 static std::vector<webrtc::VideoStream> CreateVideoStreams( | 337 static std::vector<webrtc::VideoStream> CreateVideoStreams( |
332 const VideoCodec& codec, | 338 const VideoCodec& codec, |
(...skipping 10 matching lines...) Expand all Loading... |
343 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 349 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
344 | 350 |
345 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) | 351 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) |
346 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 352 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
347 void DestroyVideoEncoder(AllocatedEncoder* encoder) | 353 void DestroyVideoEncoder(AllocatedEncoder* encoder) |
348 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 354 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
349 void SetCodec(const VideoCodecSettings& codec) | 355 void SetCodec(const VideoCodecSettings& codec) |
350 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 356 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
351 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 357 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
352 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | 358 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( |
353 const Dimensions& dimensions, | |
354 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); | 359 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); |
355 void SetDimensions(int width, int height) | 360 void ReconfigureEncoder() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
356 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
357 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); | 361 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); |
358 | 362 |
359 // Calls Start or Stop according to whether or not |sending_| is true, | 363 // Calls Start or Stop according to whether or not |sending_| is true, |
360 // and whether or not the encoding in |rtp_parameters_| is active. | 364 // and whether or not the encoding in |rtp_parameters_| is active. |
361 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 365 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
362 | 366 |
363 rtc::ThreadChecker thread_checker_; | 367 rtc::ThreadChecker thread_checker_; |
364 rtc::AsyncInvoker invoker_; | 368 rtc::AsyncInvoker invoker_; |
365 rtc::Thread* worker_thread_; | 369 rtc::Thread* worker_thread_; |
366 const std::vector<uint32_t> ssrcs_; | 370 const std::vector<uint32_t> ssrcs_; |
(...skipping 18 matching lines...) Expand all Loading... |
385 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 389 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
386 // Contains settings that are unique for each stream, such as max_bitrate. | 390 // Contains settings that are unique for each stream, such as max_bitrate. |
387 // Does *not* contain codecs, however. | 391 // Does *not* contain codecs, however. |
388 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. | 392 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. |
389 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only | 393 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only |
390 // one stream per MediaChannel. | 394 // one stream per MediaChannel. |
391 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); | 395 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); |
392 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 396 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
393 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 397 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
394 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 398 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
395 Dimensions last_dimensions_ GUARDED_BY(lock_); | 399 VideoFrameInfo last_frame_info_ GUARDED_BY(lock_); |
396 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | |
397 webrtc::kVideoRotation_0; | |
398 | 400 |
399 bool sending_ GUARDED_BY(lock_); | 401 bool sending_ GUARDED_BY(lock_); |
400 | 402 |
401 // The timestamp of the first frame received | 403 // The timestamp of the first frame received |
402 // Used to generate the timestamps of subsequent frames | 404 // Used to generate the timestamps of subsequent frames |
403 rtc::Optional<int64_t> first_frame_timestamp_ms_ GUARDED_BY(lock_); | 405 rtc::Optional<int64_t> first_frame_timestamp_ms_ GUARDED_BY(lock_); |
404 | 406 |
405 // The timestamp of the last frame received | 407 // The timestamp of the last frame received |
406 // Used to generate timestamp for the black frame when source is removed | 408 // Used to generate timestamp for the black frame when source is removed |
407 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 409 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 rtc::CriticalSection stream_crit_; | 533 rtc::CriticalSection stream_crit_; |
532 // Using primary-ssrc (first ssrc) as key. | 534 // Using primary-ssrc (first ssrc) as key. |
533 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_ | 535 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_ |
534 GUARDED_BY(stream_crit_); | 536 GUARDED_BY(stream_crit_); |
535 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ | 537 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ |
536 GUARDED_BY(stream_crit_); | 538 GUARDED_BY(stream_crit_); |
537 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_); | 539 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_); |
538 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); | 540 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); |
539 | 541 |
540 rtc::Optional<VideoCodecSettings> send_codec_; | 542 rtc::Optional<VideoCodecSettings> send_codec_; |
541 std::vector<webrtc::RtpExtension> send_rtp_extensions_; | 543 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; |
542 | 544 |
543 WebRtcVideoEncoderFactory* const external_encoder_factory_; | 545 WebRtcVideoEncoderFactory* const external_encoder_factory_; |
544 WebRtcVideoDecoderFactory* const external_decoder_factory_; | 546 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
545 std::vector<VideoCodecSettings> recv_codecs_; | 547 std::vector<VideoCodecSettings> recv_codecs_; |
546 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 548 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
547 webrtc::Call::Config::BitrateConfig bitrate_config_; | 549 webrtc::Call::Config::BitrateConfig bitrate_config_; |
548 // TODO(deadbeef): Don't duplicate information between | 550 // TODO(deadbeef): Don't duplicate information between |
549 // send_params/recv_params, rtp_extensions, options, etc. | 551 // send_params/recv_params, rtp_extensions, options, etc. |
550 VideoSendParameters send_params_; | 552 VideoSendParameters send_params_; |
551 VideoOptions default_send_options_; | 553 VideoOptions default_send_options_; |
552 VideoRecvParameters recv_params_; | 554 VideoRecvParameters recv_params_; |
553 bool red_disabled_by_remote_side_; | 555 bool red_disabled_by_remote_side_; |
554 }; | 556 }; |
555 | 557 |
556 } // namespace cricket | 558 } // namespace cricket |
557 | 559 |
558 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 560 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
OLD | NEW |