| 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/location.h" | 10 #include "base/location.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // This runs on |media_thread_|, as the underlying FFmpeg operation is | 50 // This runs on |media_thread_|, as the underlying FFmpeg operation is |
| 51 // blocking, and the utility thread must not be blocked, so the media file | 51 // blocking, and the utility thread must not be blocked, so the media file |
| 52 // bytes can be sent from the browser process to the utility process. | 52 // bytes can be sent from the browser process to the utility process. |
| 53 void ParseAudioVideoMetadata( | 53 void ParseAudioVideoMetadata( |
| 54 media::DataSource* source, bool get_attached_images, | 54 media::DataSource* source, bool get_attached_images, |
| 55 MediaMetadataParser::MediaMetadata* metadata, | 55 MediaMetadataParser::MediaMetadata* metadata, |
| 56 std::vector<AttachedImage>* attached_images) { | 56 std::vector<AttachedImage>* attached_images) { |
| 57 DCHECK(source); | 57 DCHECK(source); |
| 58 DCHECK(metadata); | 58 DCHECK(metadata); |
| 59 #if !defined(OS_ANDROID) |
| 59 media::AudioVideoMetadataExtractor extractor; | 60 media::AudioVideoMetadataExtractor extractor; |
| 60 | 61 |
| 61 if (!extractor.Extract(source, get_attached_images)) | 62 if (!extractor.Extract(source, get_attached_images)) |
| 62 return; | 63 return; |
| 63 | 64 |
| 64 if (extractor.duration() >= 0) | 65 if (extractor.duration() >= 0) |
| 65 metadata->duration.reset(new double(extractor.duration())); | 66 metadata->duration.reset(new double(extractor.duration())); |
| 66 | 67 |
| 67 if (extractor.height() >= 0 && extractor.width() >= 0) { | 68 if (extractor.height() >= 0 && extractor.width() >= 0) { |
| 68 metadata->height.reset(new int(extractor.height())); | 69 metadata->height.reset(new int(extractor.height())); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (get_attached_images) { | 102 if (get_attached_images) { |
| 102 for (std::vector<std::string>::const_iterator it = | 103 for (std::vector<std::string>::const_iterator it = |
| 103 extractor.attached_images_bytes().begin(); | 104 extractor.attached_images_bytes().begin(); |
| 104 it != extractor.attached_images_bytes().end(); ++it) { | 105 it != extractor.attached_images_bytes().end(); ++it) { |
| 105 attached_images->push_back(AttachedImage()); | 106 attached_images->push_back(AttachedImage()); |
| 106 attached_images->back().data = *it; | 107 attached_images->back().data = *it; |
| 107 net::SniffMimeTypeFromLocalData(it->c_str(), it->length(), | 108 net::SniffMimeTypeFromLocalData(it->c_str(), it->length(), |
| 108 &attached_images->back().type); | 109 &attached_images->back().type); |
| 109 } | 110 } |
| 110 } | 111 } |
| 112 #else |
| 113 NOTIMPLEMENTED(); |
| 114 #endif // OS_ANDROID |
| 111 } | 115 } |
| 112 | 116 |
| 113 void FinishParseAudioVideoMetadata( | 117 void FinishParseAudioVideoMetadata( |
| 114 MediaMetadataParser::MetadataCallback callback, | 118 MediaMetadataParser::MetadataCallback callback, |
| 115 MediaMetadataParser::MediaMetadata* metadata, | 119 MediaMetadataParser::MediaMetadata* metadata, |
| 116 std::vector<AttachedImage>* attached_images) { | 120 std::vector<AttachedImage>* attached_images) { |
| 117 DCHECK(!callback.is_null()); | 121 DCHECK(!callback.is_null()); |
| 118 DCHECK(metadata); | 122 DCHECK(metadata); |
| 119 DCHECK(attached_images); | 123 DCHECK(attached_images); |
| 120 | 124 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 source_, | 193 source_, |
| 190 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), | 194 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), |
| 191 mime_type_, callback)); | 195 mime_type_, callback)); |
| 192 return; | 196 return; |
| 193 } | 197 } |
| 194 | 198 |
| 195 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); | 199 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); |
| 196 } | 200 } |
| 197 | 201 |
| 198 } // namespace metadata | 202 } // namespace metadata |
| OLD | NEW |