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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
10 #include "media/cast/net/cast_transport_config.h" | 12 #include "media/cast/net/cast_transport_config.h" |
11 #include "media/cast/sender/audio_encoder.h" | 13 #include "media/cast/sender/audio_encoder.h" |
12 | 14 |
13 namespace media { | 15 namespace media { |
14 namespace cast { | 16 namespace cast { |
15 | 17 |
16 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, | 18 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return; | 85 return; |
84 } | 86 } |
85 | 87 |
86 const base::TimeDelta next_frame_duration = | 88 const base::TimeDelta next_frame_duration = |
87 RtpDeltaToTimeDelta(audio_bus->frames(), rtp_timebase()); | 89 RtpDeltaToTimeDelta(audio_bus->frames(), rtp_timebase()); |
88 if (ShouldDropNextFrame(next_frame_duration)) | 90 if (ShouldDropNextFrame(next_frame_duration)) |
89 return; | 91 return; |
90 | 92 |
91 samples_in_encoder_ += audio_bus->frames(); | 93 samples_in_encoder_ += audio_bus->frames(); |
92 | 94 |
93 audio_encoder_->InsertAudio(audio_bus.Pass(), recorded_time); | 95 audio_encoder_->InsertAudio(std::move(audio_bus), recorded_time); |
94 } | 96 } |
95 | 97 |
96 int AudioSender::GetNumberOfFramesInEncoder() const { | 98 int AudioSender::GetNumberOfFramesInEncoder() const { |
97 // Note: It's possible for a partial frame to be in the encoder, but returning | 99 // Note: It's possible for a partial frame to be in the encoder, but returning |
98 // the floor() is good enough for the "design limit" check in FrameSender. | 100 // the floor() is good enough for the "design limit" check in FrameSender. |
99 return samples_in_encoder_ / audio_encoder_->GetSamplesPerFrame(); | 101 return samples_in_encoder_ / audio_encoder_->GetSamplesPerFrame(); |
100 } | 102 } |
101 | 103 |
102 base::TimeDelta AudioSender::GetInFlightMediaDuration() const { | 104 base::TimeDelta AudioSender::GetInFlightMediaDuration() const { |
103 const int samples_in_flight = samples_in_encoder_ + | 105 const int samples_in_flight = samples_in_encoder_ + |
104 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame(); | 106 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame(); |
105 return RtpDeltaToTimeDelta(samples_in_flight, rtp_timebase()); | 107 return RtpDeltaToTimeDelta(samples_in_flight, rtp_timebase()); |
106 } | 108 } |
107 | 109 |
108 void AudioSender::OnEncodedAudioFrame( | 110 void AudioSender::OnEncodedAudioFrame( |
109 int encoder_bitrate, | 111 int encoder_bitrate, |
110 scoped_ptr<SenderEncodedFrame> encoded_frame, | 112 scoped_ptr<SenderEncodedFrame> encoded_frame, |
111 int samples_skipped) { | 113 int samples_skipped) { |
112 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 114 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
113 | 115 |
114 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; | 116 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; |
115 DCHECK_GE(samples_in_encoder_, 0); | 117 DCHECK_GE(samples_in_encoder_, 0); |
116 | 118 |
117 SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); | 119 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
118 } | 120 } |
119 | 121 |
120 } // namespace cast | 122 } // namespace cast |
121 } // namespace media | 123 } // namespace media |
OLD | NEW |