Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: media/cast/sender/audio_sender.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "media/cast/common/rtp_time.h"
12 #include "media/cast/net/cast_transport_config.h" 13 #include "media/cast/net/cast_transport_config.h"
13 #include "media/cast/sender/audio_encoder.h" 14 #include "media/cast/sender/audio_encoder.h"
14 15
15 namespace media { 16 namespace media {
16 namespace cast { 17 namespace cast {
17 18
18 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, 19 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment,
19 const AudioSenderConfig& audio_config, 20 const AudioSenderConfig& audio_config,
20 const StatusChangeCallback& status_change_cb, 21 const StatusChangeCallback& status_change_cb,
21 CastTransportSender* const transport_sender) 22 CastTransportSender* const transport_sender)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus, 80 void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus,
80 const base::TimeTicks& recorded_time) { 81 const base::TimeTicks& recorded_time) {
81 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 82 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
82 83
83 if (!audio_encoder_) { 84 if (!audio_encoder_) {
84 NOTREACHED(); 85 NOTREACHED();
85 return; 86 return;
86 } 87 }
87 88
88 const base::TimeDelta next_frame_duration = 89 const base::TimeDelta next_frame_duration =
89 RtpDeltaToTimeDelta(audio_bus->frames(), rtp_timebase()); 90 RtpTimeDelta::FromTicks(audio_bus->frames()).ToTimeDelta(rtp_timebase());
90 if (ShouldDropNextFrame(next_frame_duration)) 91 if (ShouldDropNextFrame(next_frame_duration))
91 return; 92 return;
92 93
93 samples_in_encoder_ += audio_bus->frames(); 94 samples_in_encoder_ += audio_bus->frames();
94 95
95 audio_encoder_->InsertAudio(std::move(audio_bus), recorded_time); 96 audio_encoder_->InsertAudio(std::move(audio_bus), recorded_time);
96 } 97 }
97 98
98 int AudioSender::GetNumberOfFramesInEncoder() const { 99 int AudioSender::GetNumberOfFramesInEncoder() const {
99 // Note: It's possible for a partial frame to be in the encoder, but returning 100 // Note: It's possible for a partial frame to be in the encoder, but returning
100 // the floor() is good enough for the "design limit" check in FrameSender. 101 // the floor() is good enough for the "design limit" check in FrameSender.
101 return samples_in_encoder_ / audio_encoder_->GetSamplesPerFrame(); 102 return samples_in_encoder_ / audio_encoder_->GetSamplesPerFrame();
102 } 103 }
103 104
104 base::TimeDelta AudioSender::GetInFlightMediaDuration() const { 105 base::TimeDelta AudioSender::GetInFlightMediaDuration() const {
105 const int samples_in_flight = samples_in_encoder_ + 106 const int samples_in_flight = samples_in_encoder_ +
106 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame(); 107 GetUnacknowledgedFrameCount() * audio_encoder_->GetSamplesPerFrame();
107 return RtpDeltaToTimeDelta(samples_in_flight, rtp_timebase()); 108 return RtpTimeDelta::FromTicks(samples_in_flight).ToTimeDelta(rtp_timebase());
108 } 109 }
109 110
110 void AudioSender::OnEncodedAudioFrame( 111 void AudioSender::OnEncodedAudioFrame(
111 int encoder_bitrate, 112 int encoder_bitrate,
112 scoped_ptr<SenderEncodedFrame> encoded_frame, 113 scoped_ptr<SenderEncodedFrame> encoded_frame,
113 int samples_skipped) { 114 int samples_skipped) {
114 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 115 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
115 116
116 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; 117 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped;
117 DCHECK_GE(samples_in_encoder_, 0); 118 DCHECK_GE(samples_in_encoder_, 0);
118 119
119 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); 120 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame));
120 } 121 }
121 122
122 } // namespace cast 123 } // namespace cast
123 } // namespace media 124 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_encoder_unittest.cc ('k') | media/cast/sender/external_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698