Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / utility / media_galleries / image_metadata_extractor.h
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.
4
5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13
14 namespace media {
15 class DataSource;
16 }
17
18 namespace net {
19 class DrainableIOBuffer;
20 }
21
22 namespace metadata {
23
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;
30
31   // One of these two is required before use of this class.
32   static bool InitializeLibrary();
33   static bool InitializeLibraryForTesting();
34
35   ImageMetadataExtractor();
36   ~ImageMetadataExtractor();
37
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);
41
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;
46
47   // In degrees.
48   int rotation() const;
49
50   // In pixels per inch.
51   double x_resolution() const;
52   double y_resolution() const;
53
54   // In the same string form as the original file.
55   const std::string& date() const;
56
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;
64
65  private:
66   // Second half of the Extract method.
67   void FinishExtraction(const DoneCallback& callback,
68                         const scoped_refptr<net::DrainableIOBuffer>& buffer);
69
70   bool extracted_;
71
72   int width_;
73   int height_;
74
75   int rotation_;
76
77   double x_resolution_;
78   double y_resolution_;
79
80   std::string date_;
81
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_;
89
90   DISALLOW_COPY_AND_ASSIGN(ImageMetadataExtractor);
91 };
92
93 }  // namespace metadata
94
95 #endif  // CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_