1 // Copyright 2013 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_MEDIA_METADATA_PARSER_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/common/extensions/api/media_galleries.h"
18 // This class takes a MIME type and data source and parses its metadata. It
19 // handles audio, video, and images. It delegates its operations to FFMPEG,
20 // libexif, etc. This class lives and operates on the utility thread of the
21 // utility process, as we wish to sandbox potentially dangerous operations
22 // on user-provided data.
23 class MediaMetadataParser
{
25 typedef extensions::api::media_galleries::MediaMetadata MediaMetadata
;
26 typedef base::Callback
<void(scoped_ptr
<MediaMetadata
>)> MetadataCallback
;
28 // Does not take ownership of |source|. Caller is responsible for ensuring
29 // that |source| outlives this object.
30 MediaMetadataParser(media::DataSource
* source
, const std::string
& mime_type
);
32 ~MediaMetadataParser();
34 // |callback| is called on same message loop.
35 void Start(const MetadataCallback
& callback
);
38 void PopulateAudioVideoMetadata();
40 media::DataSource
* source_
;
42 MetadataCallback callback_
;
44 scoped_ptr
<MediaMetadata
> metadata_
;
46 DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser
);
49 } // namespace metadata
51 #endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_