• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef STAGEFRIGHT_METADATA_RETRIEVER_H_
18 
19 #define STAGEFRIGHT_METADATA_RETRIEVER_H_
20 
21 #include <media/IMediaExtractor.h>
22 #include <media/MediaMetadataRetrieverInterface.h>
23 
24 #include <utils/KeyedVector.h>
25 
26 namespace android {
27 
28 class DataSource;
29 class MediaExtractor;
30 struct ImageDecoder;
31 struct FrameRect;
32 
33 struct StagefrightMetadataRetriever : public MediaMetadataRetrieverBase {
34     StagefrightMetadataRetriever();
35     virtual ~StagefrightMetadataRetriever();
36 
37     virtual status_t setDataSource(
38             const sp<IMediaHTTPService> &httpService,
39             const char *url,
40             const KeyedVector<String8, String8> *headers);
41 
42     virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
43     virtual status_t setDataSource(const sp<DataSource>& source, const char *mime);
44 
45     virtual sp<IMemory> getFrameAtTime(
46             int64_t timeUs, int option, int colorFormat, bool metaOnly);
47     virtual sp<IMemory> getImageAtIndex(
48             int index, int colorFormat, bool metaOnly, bool thumbnail);
49     virtual sp<IMemory> getImageRectAtIndex(
50             int index, int colorFormat, int left, int top, int right, int bottom);
51     virtual status_t getFrameAtIndex(
52             std::vector<sp<IMemory> >* frames,
53             int frameIndex, int numFrames, int colorFormat, bool metaOnly);
54 
55     virtual MediaAlbumArt *extractAlbumArt();
56     virtual const char *extractMetadata(int keyCode);
57 
58 private:
59     sp<DataSource> mSource;
60     sp<IMediaExtractor> mExtractor;
61 
62     bool mParsedMetaData;
63     KeyedVector<int, String8> mMetaData;
64     MediaAlbumArt *mAlbumArt;
65 
66     sp<ImageDecoder> mImageDecoder;
67     int mLastImageIndex;
68     void parseMetaData();
69     // Delete album art and clear metadata.
70     void clearMetadata();
71 
72     status_t getFrameInternal(
73             int64_t timeUs, int numFrames, int option, int colorFormat, bool metaOnly,
74             sp<IMemory>* outFrame, std::vector<sp<IMemory> >* outFrames);
75     virtual sp<IMemory> getImageInternal(
76             int index, int colorFormat, bool metaOnly, bool thumbnail, FrameRect* rect);
77 
78     StagefrightMetadataRetriever(const StagefrightMetadataRetriever &);
79 
80     StagefrightMetadataRetriever &operator=(
81             const StagefrightMetadataRetriever &);
82 };
83 
84 }  // namespace android
85 
86 #endif  // STAGEFRIGHT_METADATA_RETRIEVER_H_
87