[M120 Migration][hbbtv] Audio tracks count notification
[platform/framework/web/chromium-efl.git] / media / filters / audio_video_metadata_extractor.h
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.
4
5 #ifndef MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
6 #define MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "media/base/media_export.h"
13
14 struct AVDictionary;
15
16 namespace media {
17
18 class DataSource;
19
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 {
23  public:
24   typedef std::map<std::string, std::string> TagDictionary;
25
26   struct StreamInfo {
27     StreamInfo();
28     StreamInfo(const StreamInfo& other);
29     ~StreamInfo();
30     std::string type;
31     TagDictionary tags;
32   };
33
34   typedef std::vector<StreamInfo> StreamInfoVector;
35
36   AudioVideoMetadataExtractor();
37
38   AudioVideoMetadataExtractor(const AudioVideoMetadataExtractor&) = delete;
39   AudioVideoMetadataExtractor& operator=(const AudioVideoMetadataExtractor&) =
40       delete;
41
42   ~AudioVideoMetadataExtractor();
43
44   // Returns whether or not the fields were successfully extracted. Should only
45   // be called once.
46   bool Extract(DataSource* source, bool extract_attached_pics);
47
48   // Returns whether or not duration information was extracted. Do not call
49   // duration() if this returns false.
50   bool has_duration() const;
51
52   // Returns the duration in seconds. Value is undefined if has_duration()
53   // returns false.
54   double duration() const;
55
56   // Returns -1 for containers without video.
57   int width() const;
58   int height() const;
59
60   // Returns -1 if undefined.
61   int rotation() const;
62
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;
69   int disc() 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;
75   int track() const;
76
77   // First element is the container. Subsequent elements are the child streams.
78   const StreamInfoVector& stream_infos() const;
79
80   // Empty if Extract call did not request attached images, or if no attached
81   // images were found.
82   const std::vector<std::string>& attached_images_bytes() const;
83
84  private:
85   void ExtractDictionary(AVDictionary* metadata, TagDictionary* raw_tags);
86
87   bool extracted_;
88
89   bool has_duration_;
90   double duration_;  // Valid only if |has_duration_| is true.
91   int width_;
92   int height_;
93
94   std::string album_;
95   std::string artist_;
96   std::string comment_;
97   std::string copyright_;
98   std::string date_;
99   int disc_;
100   std::string encoder_;
101   std::string encoded_by_;
102   std::string genre_;
103   std::string language_;
104   int rotation_;
105   std::string title_;
106   int track_;
107
108   StreamInfoVector stream_infos_;
109
110   std::vector<std::string> attached_images_bytes_;
111 };
112
113 }  // namespace media
114
115 #endif  // MEDIA_FILTERS_AUDIO_VIDEO_METADATA_EXTRACTOR_H_