| 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_receiver/video_receiver.h" | 5 #include "media/cast/video_receiver/video_receiver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "media/cast/logging/logging_defines.h" | 14 #include "media/cast/logging/logging_defines.h" |
| 15 #include "media/cast/transport/cast_transport_defines.h" | 15 #include "media/cast/transport/cast_transport_defines.h" |
| 16 #include "media/cast/video_receiver/video_decoder.h" | 16 #include "media/cast/video_receiver/video_decoder.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 const int kMinSchedulingDelayMs = 1; | 19 const int kMinSchedulingDelayMs = 1; |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 namespace media { | 22 namespace media { |
| 23 namespace cast { | 23 namespace cast { |
| 24 | 24 |
| 25 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 25 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
| 26 const VideoReceiverConfig& video_config, | 26 const FrameReceiverConfig& video_config, |
| 27 transport::PacedPacketSender* const packet_sender) | 27 transport::PacedPacketSender* const packet_sender) |
| 28 : RtpReceiver(cast_environment->Clock(), NULL, &video_config), | 28 : RtpReceiver(cast_environment->Clock(), NULL, &video_config), |
| 29 cast_environment_(cast_environment), | 29 cast_environment_(cast_environment), |
| 30 event_subscriber_(kReceiverRtcpEventHistorySize, VIDEO_EVENT), | 30 event_subscriber_(kReceiverRtcpEventHistorySize, VIDEO_EVENT), |
| 31 codec_(video_config.codec), | 31 codec_(video_config.codec.video), |
| 32 target_playout_delay_( | 32 target_playout_delay_( |
| 33 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), | 33 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), |
| 34 expected_frame_duration_( | 34 expected_frame_duration_( |
| 35 base::TimeDelta::FromSeconds(1) / video_config.max_frame_rate), | 35 base::TimeDelta::FromSeconds(1) / video_config.max_frame_rate), |
| 36 reports_are_scheduled_(false), | 36 reports_are_scheduled_(false), |
| 37 framer_(cast_environment->Clock(), | 37 framer_(cast_environment->Clock(), |
| 38 this, | 38 this, |
| 39 video_config.incoming_ssrc, | 39 video_config.incoming_ssrc, |
| 40 video_config.decoder_faster_than_max_frame_rate, | 40 true, |
| 41 video_config.rtp_max_delay_ms * video_config.max_frame_rate / | 41 video_config.rtp_max_delay_ms * video_config.max_frame_rate / |
| 42 1000), | 42 1000), |
| 43 rtcp_(cast_environment_, | 43 rtcp_(cast_environment_, |
| 44 NULL, | 44 NULL, |
| 45 NULL, | 45 NULL, |
| 46 packet_sender, | 46 packet_sender, |
| 47 GetStatistics(), | 47 GetStatistics(), |
| 48 video_config.rtcp_mode, | 48 video_config.rtcp_mode, |
| 49 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 49 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
| 50 video_config.feedback_ssrc, | 50 video_config.feedback_ssrc, |
| 51 video_config.incoming_ssrc, | 51 video_config.incoming_ssrc, |
| 52 video_config.rtcp_c_name, | 52 video_config.rtcp_c_name, |
| 53 false), | 53 false), |
| 54 is_waiting_for_consecutive_frame_(false), | 54 is_waiting_for_consecutive_frame_(false), |
| 55 lip_sync_drift_(ClockDriftSmoother::GetDefaultTimeConstant()), | 55 lip_sync_drift_(ClockDriftSmoother::GetDefaultTimeConstant()), |
| 56 weak_factory_(this) { | 56 weak_factory_(this) { |
| 57 DCHECK_GT(video_config.rtp_max_delay_ms, 0); | 57 DCHECK_GT(video_config.rtp_max_delay_ms, 0); |
| 58 DCHECK_GT(video_config.max_frame_rate, 0); | 58 DCHECK_GT(video_config.max_frame_rate, 0); |
| 59 if (!video_config.use_external_decoder) { | 59 video_decoder_.reset(new VideoDecoder(cast_environment, video_config)); |
| 60 video_decoder_.reset(new VideoDecoder(cast_environment, video_config)); | |
| 61 } | |
| 62 decryptor_.Initialize(video_config.aes_key, video_config.aes_iv_mask); | 60 decryptor_.Initialize(video_config.aes_key, video_config.aes_iv_mask); |
| 63 rtcp_.SetTargetDelay(target_playout_delay_); | 61 rtcp_.SetTargetDelay(target_playout_delay_); |
| 64 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); | 62 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); |
| 65 memset(frame_id_to_rtp_timestamp_, 0, sizeof(frame_id_to_rtp_timestamp_)); | 63 memset(frame_id_to_rtp_timestamp_, 0, sizeof(frame_id_to_rtp_timestamp_)); |
| 66 } | 64 } |
| 67 | 65 |
| 68 VideoReceiver::~VideoReceiver() { | 66 VideoReceiver::~VideoReceiver() { |
| 69 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 67 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 70 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); | 68 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); |
| 71 } | 69 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 371 } |
| 374 | 372 |
| 375 void VideoReceiver::SendNextRtcpReport() { | 373 void VideoReceiver::SendNextRtcpReport() { |
| 376 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 374 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 377 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL); | 375 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL); |
| 378 ScheduleNextRtcpReport(); | 376 ScheduleNextRtcpReport(); |
| 379 } | 377 } |
| 380 | 378 |
| 381 } // namespace cast | 379 } // namespace cast |
| 382 } // namespace media | 380 } // namespace media |
| OLD | NEW |