| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/video_sender/video_sender.h" | 5 #include "media/cast/video_sender/video_sender.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 VideoSender* video_sender_; | 41 VideoSender* video_sender_; |
| 42 | 42 |
| 43 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtcpVideoSenderFeedback); | 43 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtcpVideoSenderFeedback); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 VideoSender::VideoSender( | 46 VideoSender::VideoSender( |
| 47 scoped_refptr<CastEnvironment> cast_environment, | 47 scoped_refptr<CastEnvironment> cast_environment, |
| 48 const VideoSenderConfig& video_config, | 48 const VideoSenderConfig& video_config, |
| 49 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, | 49 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 50 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, |
| 50 const CastInitializationCallback& cast_initialization_cb, | 51 const CastInitializationCallback& cast_initialization_cb, |
| 51 transport::CastTransportSender* const transport_sender) | 52 transport::CastTransportSender* const transport_sender) |
| 52 : rtp_max_delay_(base::TimeDelta::FromMilliseconds( | 53 : rtp_max_delay_(base::TimeDelta::FromMilliseconds( |
| 53 video_config.rtp_config.max_delay_ms)), | 54 video_config.rtp_config.max_delay_ms)), |
| 54 max_frame_rate_(video_config.max_frame_rate), | 55 max_frame_rate_(video_config.max_frame_rate), |
| 55 cast_environment_(cast_environment), | 56 cast_environment_(cast_environment), |
| 56 transport_sender_(transport_sender), | 57 transport_sender_(transport_sender), |
| 57 event_subscriber_(kMaxEventSubscriberEntries), | 58 event_subscriber_(kMaxEventSubscriberEntries), |
| 58 rtp_stats_(kVideoFrequency), | 59 rtp_stats_(kVideoFrequency), |
| 59 rtcp_feedback_(new LocalRtcpVideoSenderFeedback(this)), | 60 rtcp_feedback_(new LocalRtcpVideoSenderFeedback(this)), |
| 60 last_acked_frame_id_(-1), | 61 last_acked_frame_id_(-1), |
| 61 last_sent_frame_id_(-1), | 62 last_sent_frame_id_(-1), |
| 62 duplicate_ack_(0), | 63 duplicate_ack_(0), |
| 63 last_skip_count_(0), | 64 last_skip_count_(0), |
| 64 congestion_control_(cast_environment->Clock(), | 65 congestion_control_(cast_environment->Clock(), |
| 65 video_config.congestion_control_back_off, | 66 video_config.congestion_control_back_off, |
| 66 video_config.max_bitrate, | 67 video_config.max_bitrate, |
| 67 video_config.min_bitrate, | 68 video_config.min_bitrate, |
| 68 video_config.start_bitrate), | 69 video_config.start_bitrate), |
| 69 initialized_(false), | 70 initialized_(false), |
| 70 active_session_(false), | 71 active_session_(false), |
| 71 weak_factory_(this) { | 72 weak_factory_(this) { |
| 72 max_unacked_frames_ = | 73 max_unacked_frames_ = |
| 73 1 + static_cast<uint8>(video_config.rtp_config.max_delay_ms * | 74 1 + static_cast<uint8>(video_config.rtp_config.max_delay_ms * |
| 74 max_frame_rate_ / 1000); | 75 max_frame_rate_ / 1000); |
| 75 VLOG(1) << "max_unacked_frames " << static_cast<int>(max_unacked_frames_); | 76 VLOG(1) << "max_unacked_frames " << static_cast<int>(max_unacked_frames_); |
| 76 DCHECK_GT(max_unacked_frames_, 0) << "Invalid argument"; | 77 DCHECK_GT(max_unacked_frames_, 0) << "Invalid argument"; |
| 77 | 78 |
| 78 if (video_config.use_external_encoder) { | 79 if (video_config.use_external_encoder) { |
| 79 CHECK(gpu_factories); | 80 video_encoder_.reset(new ExternalVideoEncoder(cast_environment, |
| 80 video_encoder_.reset(new ExternalVideoEncoder( | 81 video_config, |
| 81 cast_environment, video_config, gpu_factories)); | 82 create_vea_cb, |
| 83 create_video_encode_mem_cb)); |
| 82 } else { | 84 } else { |
| 83 video_encoder_.reset(new VideoEncoderImpl( | 85 video_encoder_.reset(new VideoEncoderImpl( |
| 84 cast_environment, video_config, max_unacked_frames_)); | 86 cast_environment, video_config, max_unacked_frames_)); |
| 85 } | 87 } |
| 86 | 88 |
| 87 rtcp_.reset( | 89 rtcp_.reset( |
| 88 new Rtcp(cast_environment_, | 90 new Rtcp(cast_environment_, |
| 89 rtcp_feedback_.get(), | 91 rtcp_feedback_.get(), |
| 90 transport_sender_, | 92 transport_sender_, |
| 91 NULL, // paced sender. | 93 NULL, // paced sender. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 467 |
| 466 void VideoSender::ResendPacketsOnTransportThread( | 468 void VideoSender::ResendPacketsOnTransportThread( |
| 467 const transport::MissingFramesAndPacketsMap& missing_packets) { | 469 const transport::MissingFramesAndPacketsMap& missing_packets) { |
| 468 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); | 470 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); |
| 469 last_send_time_ = cast_environment_->Clock()->NowTicks(); | 471 last_send_time_ = cast_environment_->Clock()->NowTicks(); |
| 470 transport_sender_->ResendPackets(false, missing_packets); | 472 transport_sender_->ResendPackets(false, missing_packets); |
| 471 } | 473 } |
| 472 | 474 |
| 473 } // namespace cast | 475 } // namespace cast |
| 474 } // namespace media | 476 } // namespace media |
| OLD | NEW |