[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / chrome / utility / media_galleries / image_metadata_extractor.h
blob9f589598237a78117d54d0ec143ab23455005acf
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 CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
14 namespace media {
15 class DataSource;
18 namespace net {
19 class DrainableIOBuffer;
22 namespace metadata {
24 // Extracts a basic set of image metadata tags. Users must initialize the
25 // library before use. Each class instance is 'one-time-use', and cannot be used
26 // to extract metadata from multiple images.
27 class ImageMetadataExtractor {
28 public:
29 typedef base::Callback<void(bool)> DoneCallback;
31 // One of these two is required before use of this class.
32 static bool InitializeLibrary();
33 static bool InitializeLibraryForTesting();
35 ImageMetadataExtractor();
36 ~ImageMetadataExtractor();
38 // |callback| called with whether or not the extraction succeeded. Should
39 // only be called once.
40 void Extract(media::DataSource* source, const DoneCallback& callback);
42 // All below methods require Extract to have already succeeded.
43 // Returns -1 if file does not define a width or height.
44 int width() const;
45 int height() const;
47 // In degrees.
48 int rotation() const;
50 // In pixels per inch.
51 double x_resolution() const;
52 double y_resolution() const;
54 // In the same string form as the original file.
55 const std::string& date() const;
57 const std::string& camera_make() const;
58 const std::string& camera_model() const;
59 double exposure_time_sec() const;
60 bool flash_fired() const;
61 double f_number() const;
62 double focal_length_mm() const;
63 int iso_equivalent() const;
65 private:
66 // Second half of the Extract method.
67 void FinishExtraction(const DoneCallback& callback,
68 const scoped_refptr<net::DrainableIOBuffer>& buffer);
70 bool extracted_;
72 int width_;
73 int height_;
75 int rotation_;
77 double x_resolution_;
78 double y_resolution_;
80 std::string date_;
82 std::string camera_make_;
83 std::string camera_model_;
84 double exposure_time_sec_;
85 bool flash_fired_;
86 double f_number_;
87 double focal_length_mm_;
88 int iso_equivalent_;
90 DISALLOW_COPY_AND_ASSIGN(ImageMetadataExtractor);
93 } // namespace metadata
95 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_