blob: 930b6e27e13054ab1980fb204373f9e1c19bed5e [file] [log] [blame]
Marco Nelissen0b164472018-05-30 12:16:56 -07001/*
2 * Copyright (C) 2018 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 MEDIA_EXTRACTOR_PLUGIN_API_H_
18#define MEDIA_EXTRACTOR_PLUGIN_API_H_
19
20#include <utils/Errors.h> // for status_t
21
22namespace android {
23
24struct MediaTrack;
25class MetaDataBase;
Marco Nelissen0b164472018-05-30 12:16:56 -070026
27extern "C" {
28
Marco Nelissencec44d02018-06-17 22:21:09 -070029struct CDataSource {
30 ssize_t (*readAt)(void *handle, off64_t offset, void *data, size_t size);
31 status_t (*getSize)(void *handle, off64_t *size);
32 uint32_t (*flags)(void *handle );
33 bool (*getUri)(void *handle, char *uriString, size_t bufferSize);
34 void *handle;
35};
36
Marco Nelissen0b164472018-05-30 12:16:56 -070037struct CMediaExtractor {
38 void *data;
39
40 void (*free)(void *data);
41 size_t (*countTracks)(void *data);
42 MediaTrack* (*getTrack)(void *data, size_t index);
43 status_t (*getTrackMetaData)(
44 void *data,
45 MetaDataBase& meta,
46 size_t index, uint32_t flags);
47
48 status_t (*getMetaData)(void *data, MetaDataBase& meta);
49 uint32_t (*flags)(void *data);
50 status_t (*setMediaCas)(void *data, const uint8_t* casToken, size_t size);
51 const char * (*name)(void *data);
52};
53
Marco Nelissencec44d02018-06-17 22:21:09 -070054typedef CMediaExtractor* (*CreatorFunc)(CDataSource *source, void *meta);
Marco Nelissen0b164472018-05-30 12:16:56 -070055typedef void (*FreeMetaFunc)(void *meta);
56
57// The sniffer can optionally fill in an opaque object, "meta", that helps
58// the corresponding extractor initialize its state without duplicating
59// effort already exerted by the sniffer. If "freeMeta" is given, it will be
60// called against the opaque object when it is no longer used.
61typedef CreatorFunc (*SnifferFunc)(
Marco Nelissencec44d02018-06-17 22:21:09 -070062 CDataSource *source, float *confidence,
Marco Nelissen0b164472018-05-30 12:16:56 -070063 void **meta, FreeMetaFunc *freeMeta);
64
65typedef struct {
66 const uint8_t b[16];
67} media_uuid_t;
68
69typedef struct {
70 // version number of this structure
71 const uint32_t def_version;
72
73 // A unique identifier for this extractor.
74 // See below for a convenience macro to create this from a string.
75 media_uuid_t extractor_uuid;
76
77 // Version number of this extractor. When two extractors with the same
78 // uuid are encountered, the one with the largest version number will
79 // be used.
80 const uint32_t extractor_version;
81
82 // a human readable name
83 const char *extractor_name;
84
85 // the sniffer function
86 const SnifferFunc sniff;
87} ExtractorDef;
88
89const uint32_t EXTRACTORDEF_VERSION = 1;
90
91// each plugin library exports one function of this type
92typedef ExtractorDef (*GetExtractorDef)();
93
94} // extern "C"
95
96} // namespace android
97
98#endif // MEDIA_EXTRACTOR_PLUGIN_API_H_