blob: 5477f7bb8818daff002f095210e172045604c32e (
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
|
// Copyright 2013 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 CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
#define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/api/media_galleries.h"
#include "chrome/common/media_galleries/metadata_types.h"
namespace base {
class Thread;
}
namespace media {
class DataSource;
}
namespace metadata {
// This class takes a MIME type and data source and parses its metadata. It
// handles audio, video, and images. It delegates its operations to FFMPEG,
// libexif, etc. This class lives and operates on the utility thread of the
// utility process, as we wish to sandbox potentially dangerous operations
// on user-provided data.
class MediaMetadataParser {
public:
typedef extensions::api::media_galleries::MediaMetadata MediaMetadata;
typedef base::Callback<
void(const MediaMetadata& metadata,
const std::vector<AttachedImage>& attached_images)>
MetadataCallback;
// Does not take ownership of |source|. Caller is responsible for ensuring
// that |source| outlives this object.
MediaMetadataParser(media::DataSource* source, const std::string& mime_type,
bool get_attached_images);
~MediaMetadataParser();
// |callback| is called on same message loop.
void Start(const MetadataCallback& callback);
private:
// Only accessed on |media_thread_| from this class.
media::DataSource* const source_;
const std::string mime_type_;
bool get_attached_images_;
// Thread that blocking media parsing operations run on while the main thread
// handles messages from the browser process.
// TODO(tommycli): Replace with a reference to a WorkerPool if we ever use
// this class in batch mode.
scoped_ptr<base::Thread> media_thread_;
DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser);
};
} // namespace metadata
#endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
|