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_
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
19 class DrainableIOBuffer
;
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
{
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.
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;
66 // Second half of the Extract method.
67 void FinishExtraction(const DoneCallback
& callback
,
68 const scoped_refptr
<net::DrainableIOBuffer
>& buffer
);
82 std::string camera_make_
;
83 std::string camera_model_
;
84 double exposure_time_sec_
;
87 double focal_length_mm_
;
90 DISALLOW_COPY_AND_ASSIGN(ImageMetadataExtractor
);
93 } // namespace metadata
95 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_