OLD | NEW |
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 Loading... |
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 | |
78 scoped_ptr<AudioPacket> AudioDecoderOpus::Decode( | 77 scoped_ptr<AudioPacket> AudioDecoderOpus::Decode( |
79 scoped_ptr<AudioPacket> packet) { | 78 scoped_ptr<AudioPacket> packet) { |
80 if (packet->encoding() != AudioPacket::ENCODING_OPUS) { | 79 if (packet->encoding() != AudioPacket::ENCODING_OPUS) { |
81 LOG(WARNING) << "Received an audio packet with encoding " | 80 LOG(WARNING) << "Received an audio packet with encoding " |
82 << packet->encoding() << " when an OPUS packet was expected."; | 81 << packet->encoding() << " when an OPUS packet was expected."; |
83 return nullptr; | 82 return nullptr; |
84 } | 83 } |
85 if (packet->data_size() > kMaxFramesPerPacket) { | 84 if (packet->data_size() > kMaxFramesPerPacket) { |
86 LOG(WARNING) << "Received an packet with too many frames."; | 85 LOG(WARNING) << "Received an packet with too many frames."; |
87 return nullptr; | 86 return nullptr; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 buffer_pos += result * packet->channels() * | 125 buffer_pos += result * packet->channels() * |
127 decoded_packet->bytes_per_sample(); | 126 decoded_packet->bytes_per_sample(); |
128 } | 127 } |
129 | 128 |
130 if (!buffer_pos) { | 129 if (!buffer_pos) { |
131 return nullptr; | 130 return nullptr; |
132 } | 131 } |
133 | 132 |
134 decoded_data->resize(buffer_pos); | 133 decoded_data->resize(buffer_pos); |
135 | 134 |
136 return decoded_packet.Pass(); | 135 return decoded_packet; |
137 } | 136 } |
138 | 137 |
139 } // namespace remoting | 138 } // namespace remoting |
OLD | NEW |