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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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_decoder_opus.h ('k') | remoting/codec/audio_decoder_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_decoder_opus.h" 5 #include "remoting/codec/audio_decoder_opus.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 if (!decoder_) { 70 if (!decoder_) {
71 InitDecoder(); 71 InitDecoder();
72 } 72 }
73 73
74 return decoder_ != nullptr; 74 return decoder_ != nullptr;
75 } 75 }
76 76
77 scoped_ptr<AudioPacket> AudioDecoderOpus::Decode( 77 std::unique_ptr<AudioPacket> AudioDecoderOpus::Decode(
78 scoped_ptr<AudioPacket> packet) { 78 std::unique_ptr<AudioPacket> packet) {
79 if (packet->encoding() != AudioPacket::ENCODING_OPUS) { 79 if (packet->encoding() != AudioPacket::ENCODING_OPUS) {
80 LOG(WARNING) << "Received an audio packet with encoding " 80 LOG(WARNING) << "Received an audio packet with encoding "
81 << packet->encoding() << " when an OPUS packet was expected."; 81 << packet->encoding() << " when an OPUS packet was expected.";
82 return nullptr; 82 return nullptr;
83 } 83 }
84 if (packet->data_size() > kMaxFramesPerPacket) { 84 if (packet->data_size() > kMaxFramesPerPacket) {
85 LOG(WARNING) << "Received an packet with too many frames."; 85 LOG(WARNING) << "Received an packet with too many frames.";
86 return nullptr; 86 return nullptr;
87 } 87 }
88 88
89 if (!ResetForPacket(packet.get())) { 89 if (!ResetForPacket(packet.get())) {
90 return nullptr; 90 return nullptr;
91 } 91 }
92 92
93 // Create a new packet of decoded data. 93 // Create a new packet of decoded data.
94 scoped_ptr<AudioPacket> decoded_packet(new AudioPacket()); 94 std::unique_ptr<AudioPacket> decoded_packet(new AudioPacket());
95 decoded_packet->set_encoding(AudioPacket::ENCODING_RAW); 95 decoded_packet->set_encoding(AudioPacket::ENCODING_RAW);
96 decoded_packet->set_sampling_rate(kSamplingRate); 96 decoded_packet->set_sampling_rate(kSamplingRate);
97 decoded_packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); 97 decoded_packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2);
98 decoded_packet->set_channels(packet->channels()); 98 decoded_packet->set_channels(packet->channels());
99 99
100 int max_frame_samples = kMaxFrameSizeMs * kSamplingRate / 100 int max_frame_samples = kMaxFrameSizeMs * kSamplingRate /
101 base::Time::kMillisecondsPerSecond; 101 base::Time::kMillisecondsPerSecond;
102 int max_frame_bytes = max_frame_samples * channels_ * 102 int max_frame_bytes = max_frame_samples * channels_ *
103 decoded_packet->bytes_per_sample(); 103 decoded_packet->bytes_per_sample();
104 104
(...skipping 24 matching lines...) Expand all
129 if (!buffer_pos) { 129 if (!buffer_pos) {
130 return nullptr; 130 return nullptr;
131 } 131 }
132 132
133 decoded_data->resize(buffer_pos); 133 decoded_data->resize(buffer_pos);
134 134
135 return decoded_packet; 135 return decoded_packet;
136 } 136 }
137 137
138 } // namespace remoting 138 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/codec/audio_decoder_opus.h ('k') | remoting/codec/audio_decoder_verbatim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698