Corrected the TemplateURLTest.ExtractSearchTermsFromUTF8URL test.
[chromium-blink-merge.git] / media / base / audio_video_metadata_extractor.h
blob953ece0b97239611f9b6ab17adbad7e8952e2517
1 // Copyright 2014 The Chromium Authors. All rights reserved.
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_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
6 #define MEDIA_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "media/base/media_export.h"
15 struct AVDictionary;
17 namespace media {
19 class DataSource;
21 // This class extracts a string dictionary of metadata tags for audio and video
22 // files. It also provides the format name.
23 class MEDIA_EXPORT AudioVideoMetadataExtractor {
24 public:
25 typedef std::map<std::string, std::string> TagDictionary;
27 struct StreamInfo {
28 StreamInfo();
29 ~StreamInfo();
30 std::string type;
31 TagDictionary tags;
34 typedef std::vector<StreamInfo> StreamInfoVector;
36 AudioVideoMetadataExtractor();
37 ~AudioVideoMetadataExtractor();
39 // Returns whether or not the fields were successfully extracted. Should only
40 // be called once.
41 bool Extract(DataSource* source, bool extract_attached_pics);
43 // Returns -1 if we cannot extract the duration. In seconds.
44 double duration() const;
46 // Returns -1 for containers without video.
47 int width() const;
48 int height() const;
50 // Returns -1 if undefined.
51 int rotation() const;
53 // Returns -1 or an empty string if the value is undefined.
54 const std::string& album() const;
55 const std::string& artist() const;
56 const std::string& comment() const;
57 const std::string& copyright() const;
58 const std::string& date() const;
59 int disc() const;
60 const std::string& encoder() const;
61 const std::string& encoded_by() const;
62 const std::string& genre() const;
63 const std::string& language() const;
64 const std::string& title() const;
65 int track() const;
67 // First element is the container. Subsequent elements are the child streams.
68 const StreamInfoVector& stream_infos() const;
70 // Empty if Extract call did not request attached images, or if no attached
71 // images were found.
72 const std::vector<std::string>& attached_images_bytes() const;
74 private:
75 void ExtractDictionary(AVDictionary* metadata, TagDictionary* raw_tags);
77 bool extracted_;
79 int duration_;
80 int width_;
81 int height_;
83 std::string album_;
84 std::string artist_;
85 std::string comment_;
86 std::string copyright_;
87 std::string date_;
88 int disc_;
89 std::string encoder_;
90 std::string encoded_by_;
91 std::string genre_;
92 std::string language_;
93 int rotation_;
94 std::string title_;
95 int track_;
97 StreamInfoVector stream_infos_;
99 std::vector<std::string> attached_images_bytes_;
101 DISALLOW_COPY_AND_ASSIGN(AudioVideoMetadataExtractor);
104 } // namespace media
106 #endif // MEDIA_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_