OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/audio_decoder.h" | 5 #include "content/renderer/media/audio_decoder.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // Uses the FFmpeg library for audio file reading. | 34 // Uses the FFmpeg library for audio file reading. |
35 InMemoryUrlProtocol url_protocol(reinterpret_cast<const uint8*>(data), | 35 InMemoryUrlProtocol url_protocol(reinterpret_cast<const uint8*>(data), |
36 data_size, false); | 36 data_size, false); |
37 AudioFileReader reader(&url_protocol); | 37 AudioFileReader reader(&url_protocol); |
38 | 38 |
39 if (!reader.Open()) | 39 if (!reader.Open()) |
40 return false; | 40 return false; |
41 | 41 |
42 size_t number_of_channels = reader.channels(); | 42 size_t number_of_channels = reader.channels(); |
43 double file_sample_rate = reader.sample_rate(); | 43 double file_sample_rate = reader.sample_rate(); |
44 size_t number_of_frames = static_cast<size_t>(reader.number_of_frames()); | 44 size_t number_of_frames = static_cast<size_t>(reader.GetNumberOfFrames()); |
45 | 45 |
46 // Apply sanity checks to make sure crazy values aren't coming out of | 46 // Apply sanity checks to make sure crazy values aren't coming out of |
47 // FFmpeg. | 47 // FFmpeg. |
48 if (!number_of_channels || | 48 if (!number_of_channels || |
49 number_of_channels > static_cast<size_t>(media::limits::kMaxChannels) || | 49 number_of_channels > static_cast<size_t>(media::limits::kMaxChannels) || |
50 file_sample_rate < media::limits::kMinSampleRate || | 50 file_sample_rate < media::limits::kMinSampleRate || |
51 file_sample_rate > media::limits::kMaxSampleRate) | 51 file_sample_rate > media::limits::kMaxSampleRate) |
52 return false; | 52 return false; |
53 | 53 |
54 // Allocate and configure the output audio channel data. | 54 // Allocate and configure the output audio channel data. |
(...skipping 30 matching lines...) Expand all Loading... |
85 << " data size: " << data_size | 85 << " data size: " << data_size |
86 << " duration: " << duration | 86 << " duration: " << duration |
87 << " number of frames: " << actual_frames | 87 << " number of frames: " << actual_frames |
88 << " sample rate: " << file_sample_rate | 88 << " sample rate: " << file_sample_rate |
89 << " number of channels: " << number_of_channels; | 89 << " number of channels: " << number_of_channels; |
90 | 90 |
91 return actual_frames > 0; | 91 return actual_frames > 0; |
92 } | 92 } |
93 | 93 |
94 } // namespace content | 94 } // namespace content |
OLD | NEW |