| 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 "chrome/utility/media_galleries/media_metadata_parser.h" | 5 #include "chrome/utility/media_galleries/media_metadata_parser.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // This runs on |media_thread_|, as the underlying FFmpeg operation is | 49 // This runs on |media_thread_|, as the underlying FFmpeg operation is |
| 50 // blocking, and the utility thread must not be blocked, so the media file | 50 // blocking, and the utility thread must not be blocked, so the media file |
| 51 // bytes can be sent from the browser process to the utility process. | 51 // bytes can be sent from the browser process to the utility process. |
| 52 scoped_ptr<MediaMetadataParser::MediaMetadata> ParseAudioVideoMetadata( | 52 scoped_ptr<MediaMetadataParser::MediaMetadata> ParseAudioVideoMetadata( |
| 53 media::DataSource* source, | 53 media::DataSource* source, |
| 54 scoped_ptr<MediaMetadataParser::MediaMetadata> metadata) { | 54 scoped_ptr<MediaMetadataParser::MediaMetadata> metadata) { |
| 55 DCHECK(source); | 55 DCHECK(source); |
| 56 DCHECK(metadata.get()); | 56 DCHECK(metadata.get()); |
| 57 media::AudioVideoMetadataExtractor extractor; | 57 media::AudioVideoMetadataExtractor extractor; |
| 58 | 58 |
| 59 if (!extractor.Extract(source)) | 59 // TODO(tommycli): Add attached picture extraction. |
| 60 if (!extractor.Extract(source, false /* extract_attached_pics */)) |
| 60 return metadata.Pass(); | 61 return metadata.Pass(); |
| 61 | 62 |
| 62 if (extractor.duration() >= 0) | 63 if (extractor.duration() >= 0) |
| 63 metadata->duration.reset(new double(extractor.duration())); | 64 metadata->duration.reset(new double(extractor.duration())); |
| 64 | 65 |
| 65 if (extractor.height() >= 0 && extractor.width() >= 0) { | 66 if (extractor.height() >= 0 && extractor.width() >= 0) { |
| 66 metadata->height.reset(new int(extractor.height())); | 67 metadata->height.reset(new int(extractor.height())); |
| 67 metadata->width.reset(new int(extractor.width())); | 68 metadata->width.reset(new int(extractor.width())); |
| 68 } | 69 } |
| 69 | 70 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), | 166 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), |
| 166 base::Passed(&metadata), callback)); | 167 base::Passed(&metadata), callback)); |
| 167 return; | 168 return; |
| 168 } | 169 } |
| 169 | 170 |
| 170 // TODO(tommycli): Implement for image mime types. | 171 // TODO(tommycli): Implement for image mime types. |
| 171 callback.Run(metadata.Pass()); | 172 callback.Run(metadata.Pass()); |
| 172 } | 173 } |
| 173 | 174 |
| 174 } // namespace metadata | 175 } // namespace metadata |
| OLD | NEW |