| 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 <stdint.h> |
| 8 |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "media/base/audio_bus.h" | 13 #include "media/base/audio_bus.h" |
| 13 #include "media/base/limits.h" | 14 #include "media/base/limits.h" |
| 14 #include "media/filters/audio_file_reader.h" | 15 #include "media/filters/audio_file_reader.h" |
| 15 #include "media/filters/in_memory_url_protocol.h" | 16 #include "media/filters/in_memory_url_protocol.h" |
| 16 #include "third_party/WebKit/public/platform/WebAudioBus.h" | 17 #include "third_party/WebKit/public/platform/WebAudioBus.h" |
| 17 | 18 |
| 18 using media::AudioBus; | 19 using media::AudioBus; |
| 19 using media::AudioFileReader; | 20 using media::AudioFileReader; |
| 20 using media::InMemoryUrlProtocol; | 21 using media::InMemoryUrlProtocol; |
| 21 using std::vector; | 22 using std::vector; |
| 22 using blink::WebAudioBus; | 23 using blink::WebAudioBus; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 // Decode in-memory audio file data. | 27 // Decode in-memory audio file data. |
| 27 bool DecodeAudioFileData( | 28 bool DecodeAudioFileData( |
| 28 blink::WebAudioBus* destination_bus, | 29 blink::WebAudioBus* destination_bus, |
| 29 const char* data, size_t data_size) { | 30 const char* data, size_t data_size) { |
| 30 DCHECK(destination_bus); | 31 DCHECK(destination_bus); |
| 31 if (!destination_bus) | 32 if (!destination_bus) |
| 32 return false; | 33 return false; |
| 33 | 34 |
| 34 #if !defined(MEDIA_DISABLE_FFMPEG) | 35 #if !defined(MEDIA_DISABLE_FFMPEG) |
| 35 // Uses the FFmpeg library for audio file reading. | 36 // Uses the FFmpeg library for audio file reading. |
| 36 InMemoryUrlProtocol url_protocol(reinterpret_cast<const uint8*>(data), | 37 InMemoryUrlProtocol url_protocol(reinterpret_cast<const uint8_t*>(data), |
| 37 data_size, false); | 38 data_size, false); |
| 38 AudioFileReader reader(&url_protocol); | 39 AudioFileReader reader(&url_protocol); |
| 39 | 40 |
| 40 if (!reader.Open()) | 41 if (!reader.Open()) |
| 41 return false; | 42 return false; |
| 42 | 43 |
| 43 size_t number_of_channels = reader.channels(); | 44 size_t number_of_channels = reader.channels(); |
| 44 double file_sample_rate = reader.sample_rate(); | 45 double file_sample_rate = reader.sample_rate(); |
| 45 size_t number_of_frames = static_cast<size_t>(reader.GetNumberOfFrames()); | 46 size_t number_of_frames = static_cast<size_t>(reader.GetNumberOfFrames()); |
| 46 | 47 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 << " sample rate: " << file_sample_rate | 90 << " sample rate: " << file_sample_rate |
| 90 << " number of channels: " << number_of_channels; | 91 << " number of channels: " << number_of_channels; |
| 91 | 92 |
| 92 return actual_frames > 0; | 93 return actual_frames > 0; |
| 93 #else | 94 #else |
| 94 return false; | 95 return false; |
| 95 #endif // !defined(MEDIA_DISABLE_FFMPEG) | 96 #endif // !defined(MEDIA_DISABLE_FFMPEG) |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace content | 99 } // namespace content |
| OLD | NEW |