blob: 953ece0b97239611f9b6ab17adbad7e8952e2517 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
#define MEDIA_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "media/base/media_export.h"
struct AVDictionary;
namespace media {
class DataSource;
// This class extracts a string dictionary of metadata tags for audio and video
// files. It also provides the format name.
class MEDIA_EXPORT AudioVideoMetadataExtractor {
public:
typedef std::map<std::string, std::string> TagDictionary;
struct StreamInfo {
StreamInfo();
~StreamInfo();
std::string type;
TagDictionary tags;
};
typedef std::vector<StreamInfo> StreamInfoVector;
AudioVideoMetadataExtractor();
~AudioVideoMetadataExtractor();
// Returns whether or not the fields were successfully extracted. Should only
// be called once.
bool Extract(DataSource* source, bool extract_attached_pics);
// Returns -1 if we cannot extract the duration. In seconds.
double duration() const;
// Returns -1 for containers without video.
int width() const;
int height() const;
// Returns -1 if undefined.
int rotation() const;
// Returns -1 or an empty string if the value is undefined.
const std::string& album() const;
const std::string& artist() const;
const std::string& comment() const;
const std::string& copyright() const;
const std::string& date() const;
int disc() const;
const std::string& encoder() const;
const std::string& encoded_by() const;
const std::string& genre() const;
const std::string& language() const;
const std::string& title() const;
int track() const;
// First element is the container. Subsequent elements are the child streams.
const StreamInfoVector& stream_infos() const;
// Empty if Extract call did not request attached images, or if no attached
// images were found.
const std::vector<std::string>& attached_images_bytes() const;
private:
void ExtractDictionary(AVDictionary* metadata, TagDictionary* raw_tags);
bool extracted_;
int duration_;
int width_;
int height_;
std::string album_;
std::string artist_;
std::string comment_;
std::string copyright_;
std::string date_;
int disc_;
std::string encoder_;
std::string encoded_by_;
std::string genre_;
std::string language_;
int rotation_;
std::string title_;
int track_;
StreamInfoVector stream_infos_;
std::vector<std::string> attached_images_bytes_;
DISALLOW_COPY_AND_ASSIGN(AudioVideoMetadataExtractor);
};
} // namespace media
#endif // MEDIA_BASE_AUDIO_VIDEO_METADATA_EXTRACTOR_H_
|