Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: media/base/audio_video_metadata_extractor.cc

Issue 250143002: Media Galleries API: Audio/Video attached pictures support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Create Blobs on browser-process, eliminating two IPC copies. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/audio_video_metadata_extractor.cc
diff --git a/media/base/audio_video_metadata_extractor.cc b/media/base/audio_video_metadata_extractor.cc
index a18cc7d3d97c2286f85b1d2cabaf8ac75f995f45..7a8cf766abde16b92d10c4f03647682eaf02a40d 100644
--- a/media/base/audio_video_metadata_extractor.cc
+++ b/media/base/audio_video_metadata_extractor.cc
@@ -47,6 +47,9 @@ bool ExtractInt(AVDictionaryEntry* tag, const char* expected_key,
return true;
}
+// Set attached image size limit to 4MB. Chosen arbitrarily.
+const int kAttachedImageSizeLimit = 4 * 1024 * 1024;
+
} // namespace
AudioVideoMetadataExtractor::StreamInfo::StreamInfo() {}
@@ -66,7 +69,8 @@ AudioVideoMetadataExtractor::AudioVideoMetadataExtractor()
AudioVideoMetadataExtractor::~AudioVideoMetadataExtractor() {
}
-bool AudioVideoMetadataExtractor::Extract(DataSource* source) {
+bool AudioVideoMetadataExtractor::Extract(DataSource* source,
+ bool extract_attached_images) {
DCHECK(!extracted_);
bool read_ok = true;
@@ -111,12 +115,24 @@ bool AudioVideoMetadataExtractor::Extract(DataSource* source) {
info.type = avcodec_get_name(stream->codec->codec_id);
- // Extract dimensions of largest stream that's not an attached picture.
+ // Extract dimensions of largest stream that's not an attached image.
if (stream->codec->width > 0 && stream->codec->width > width_ &&
stream->codec->height > 0 && stream->codec->height > height_) {
width_ = stream->codec->width;
height_ = stream->codec->height;
}
+
+ // Extract attached image if requested.
+ if (extract_attached_images &&
+ stream->disposition == AV_DISPOSITION_ATTACHED_PIC &&
+ stream->attached_pic.size > 0 &&
+ stream->attached_pic.size <= kAttachedImageSizeLimit &&
+ stream->attached_pic.data != NULL) {
+ attached_images_bytes_.push_back(std::string());
+ attached_images_bytes_.back().assign(
+ reinterpret_cast<const char*>(stream->attached_pic.data),
+ stream->attached_pic.size);
+ }
}
extracted_ = true;
@@ -209,6 +225,12 @@ AudioVideoMetadataExtractor::stream_infos() const {
return stream_infos_;
}
+const std::vector<std::string>&
+AudioVideoMetadataExtractor::attached_images_bytes() const {
+ DCHECK(extracted_);
+ return attached_images_bytes_;
+}
+
void AudioVideoMetadataExtractor::ExtractDictionary(
AVDictionary* metadata, TagDictionary* raw_tags) {
if (!metadata)

Powered by Google App Engine
This is Rietveld 408576698