1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
6 #define MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
12 #include "media/base/media_export.h"
20 // This class extracts a string dictionary of metadata tags for audio and video
21 // files. It also provides the format name.
22 class MEDIA_EXPORT AudioVideoMetadataExtractor {
24 typedef std::map<std::string, std::string> TagDictionary;
28 StreamInfo(const StreamInfo& other);
34 typedef std::vector<StreamInfo> StreamInfoVector;
36 AudioVideoMetadataExtractor();
38 AudioVideoMetadataExtractor(const AudioVideoMetadataExtractor&) = delete;
39 AudioVideoMetadataExtractor& operator=(const AudioVideoMetadataExtractor&) =
42 ~AudioVideoMetadataExtractor();
44 // Returns whether or not the fields were successfully extracted. Should only
46 bool Extract(DataSource* source, bool extract_attached_pics);
48 // Returns whether or not duration information was extracted. Do not call
49 // duration() if this returns false.
50 bool has_duration() const;
52 // Returns the duration in seconds. Value is undefined if has_duration()
54 double duration() const;
56 // Returns -1 for containers without video.
60 // Returns -1 if undefined.
63 // Returns -1 or an empty string if the value is undefined.
64 const std::string& album() const;
65 const std::string& artist() const;
66 const std::string& comment() const;
67 const std::string& copyright() const;
68 const std::string& date() const;
70 const std::string& encoder() const;
71 const std::string& encoded_by() const;
72 const std::string& genre() const;
73 const std::string& language() const;
74 const std::string& title() const;
77 // First element is the container. Subsequent elements are the child streams.
78 const StreamInfoVector& stream_infos() const;
80 // Empty if Extract call did not request attached images, or if no attached
82 const std::vector<std::string>& attached_images_bytes() const;
85 void ExtractDictionary(AVDictionary* metadata, TagDictionary* raw_tags);
90 double duration_; // Valid only if |has_duration_| is true.
97 std::string copyright_;
100 std::string encoder_;
101 std::string encoded_by_;
103 std::string language_;
108 StreamInfoVector stream_infos_;
110 std::vector<std::string> attached_images_bytes_;
115 #endif // MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_