| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sender/audio_sender.h" | 5 #include "media/cast/sender/audio_sender.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 transport_sender->InitializeAudio( | 70 transport_sender->InitializeAudio( |
| 71 transport_config, base::Bind(&AudioSender::OnReceivedCastFeedback, | 71 transport_config, base::Bind(&AudioSender::OnReceivedCastFeedback, |
| 72 weak_factory_.GetWeakPtr()), | 72 weak_factory_.GetWeakPtr()), |
| 73 base::Bind(&AudioSender::OnMeasuredRoundTripTime, | 73 base::Bind(&AudioSender::OnMeasuredRoundTripTime, |
| 74 weak_factory_.GetWeakPtr()), | 74 weak_factory_.GetWeakPtr()), |
| 75 base::Bind(&AudioSender::OnReceivedPli, weak_factory_.GetWeakPtr())); | 75 base::Bind(&AudioSender::OnReceivedPli, weak_factory_.GetWeakPtr())); |
| 76 } | 76 } |
| 77 | 77 |
| 78 AudioSender::~AudioSender() {} | 78 AudioSender::~AudioSender() {} |
| 79 | 79 |
| 80 void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus, | 80 void AudioSender::InsertAudio(std::unique_ptr<AudioBus> audio_bus, |
| 81 const base::TimeTicks& recorded_time) { | 81 const base::TimeTicks& recorded_time) { |
| 82 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 82 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 83 | 83 |
| 84 if (!audio_encoder_) { | 84 if (!audio_encoder_) { |
| 85 NOTREACHED(); | 85 NOTREACHED(); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 | 88 |
| 89 const base::TimeDelta next_frame_duration = | 89 const base::TimeDelta next_frame_duration = |
| 90 RtpTimeDelta::FromTicks(audio_bus->frames()).ToTimeDelta(rtp_timebase()); | 90 RtpTimeDelta::FromTicks(audio_bus->frames()).ToTimeDelta(rtp_timebase()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 base::TimeDelta AudioSender::GetInFlightMediaDuration() const { | 105 base::TimeDelta AudioSender::GetInFlightMediaDuration() const { |
| 106 const int samples_in_flight = samples_in_encoder_ + | 106 const int samples_in_flight = samples_in_encoder_ + |
| 107 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame(); | 107 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame(); |
| 108 return RtpTimeDelta::FromTicks(samples_in_flight).ToTimeDelta(rtp_timebase()); | 108 return RtpTimeDelta::FromTicks(samples_in_flight).ToTimeDelta(rtp_timebase()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void AudioSender::OnEncodedAudioFrame( | 111 void AudioSender::OnEncodedAudioFrame( |
| 112 int encoder_bitrate, | 112 int encoder_bitrate, |
| 113 scoped_ptr<SenderEncodedFrame> encoded_frame, | 113 std::unique_ptr<SenderEncodedFrame> encoded_frame, |
| 114 int samples_skipped) { | 114 int samples_skipped) { |
| 115 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 115 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 116 | 116 |
| 117 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; | 117 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; |
| 118 DCHECK_GE(samples_in_encoder_, 0); | 118 DCHECK_GE(samples_in_encoder_, 0); |
| 119 | 119 |
| 120 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); | 120 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace cast | 123 } // namespace cast |
| 124 } // namespace media | 124 } // namespace media |
| OLD | NEW |