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

Side by Side Diff: remoting/codec/audio_encoder_opus.cc

Issue 914133003: Fix AudioPump to pause the stream when the network is congested. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_pump
Patch Set: Created 5 years, 10 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
« no previous file with comments | « remoting/codec/audio_encoder_opus.h ('k') | remoting/codec/audio_encoder_verbatim.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/codec/audio_encoder_opus.h" 5 #include "remoting/codec/audio_encoder_opus.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 int samples_left = (resampling_data_size_ - resampling_data_pos_) / 127 int samples_left = (resampling_data_size_ - resampling_data_pos_) /
128 kBytesPerSample / channels_; 128 kBytesPerSample / channels_;
129 DCHECK_LE(audio_bus->frames(), samples_left); 129 DCHECK_LE(audio_bus->frames(), samples_left);
130 audio_bus->FromInterleaved( 130 audio_bus->FromInterleaved(
131 resampling_data_ + resampling_data_pos_, 131 resampling_data_ + resampling_data_pos_,
132 audio_bus->frames(), kBytesPerSample); 132 audio_bus->frames(), kBytesPerSample);
133 resampling_data_pos_ += audio_bus->frames() * kBytesPerSample * channels_; 133 resampling_data_pos_ += audio_bus->frames() * kBytesPerSample * channels_;
134 DCHECK_LE(resampling_data_pos_, static_cast<int>(resampling_data_size_)); 134 DCHECK_LE(resampling_data_pos_, static_cast<int>(resampling_data_size_));
135 } 135 }
136 136
137 int AudioEncoderOpus::GetBitrate() {
138 return kOutputBitrateBps;
139 }
140
137 scoped_ptr<AudioPacket> AudioEncoderOpus::Encode( 141 scoped_ptr<AudioPacket> AudioEncoderOpus::Encode(
138 scoped_ptr<AudioPacket> packet) { 142 scoped_ptr<AudioPacket> packet) {
139 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); 143 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
140 DCHECK_EQ(1, packet->data_size()); 144 DCHECK_EQ(1, packet->data_size());
141 DCHECK_EQ(kBytesPerSample, packet->bytes_per_sample()); 145 DCHECK_EQ(kBytesPerSample, packet->bytes_per_sample());
142 146
143 if (!ResetForPacket(packet.get())) { 147 if (!ResetForPacket(packet.get())) {
144 LOG(ERROR) << "Encoder initialization failed"; 148 LOG(ERROR) << "Encoder initialization failed";
145 return nullptr; 149 return nullptr;
146 } 150 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 233 }
230 234
231 // Return NULL if there's nothing in the packet. 235 // Return NULL if there's nothing in the packet.
232 if (encoded_packet->data_size() == 0) 236 if (encoded_packet->data_size() == 0)
233 return nullptr; 237 return nullptr;
234 238
235 return encoded_packet.Pass(); 239 return encoded_packet.Pass();
236 } 240 }
237 241
238 } // namespace remoting 242 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/codec/audio_encoder_opus.h ('k') | remoting/codec/audio_encoder_verbatim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698