blob: 30c2b05407e8d43eb0bd17255dbf70a1a135cb79 [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;
26class DataSourceBase;
27
28extern "C" {
29
30struct CMediaExtractor {
31 void *data;
32
33 void (*free)(void *data);
34 size_t (*countTracks)(void *data);
35 MediaTrack* (*getTrack)(void *data, size_t index);
36 status_t (*getTrackMetaData)(
37 void *data,
38 MetaDataBase& meta,
39 size_t index, uint32_t flags);
40
41 status_t (*getMetaData)(void *data, MetaDataBase& meta);
42 uint32_t (*flags)(void *data);
43 status_t (*setMediaCas)(void *data, const uint8_t* casToken, size_t size);
44 const char * (*name)(void *data);
45};
46
47typedef CMediaExtractor* (*CreatorFunc)(DataSourceBase *source, void *meta);
48typedef void (*FreeMetaFunc)(void *meta);
49
50// The sniffer can optionally fill in an opaque object, "meta", that helps
51// the corresponding extractor initialize its state without duplicating
52// effort already exerted by the sniffer. If "freeMeta" is given, it will be
53// called against the opaque object when it is no longer used.
54typedef CreatorFunc (*SnifferFunc)(
55 DataSourceBase *source, float *confidence,
56 void **meta, FreeMetaFunc *freeMeta);
57
58typedef struct {
59 const uint8_t b[16];
60} media_uuid_t;
61
62typedef struct {
63 // version number of this structure
64 const uint32_t def_version;
65
66 // A unique identifier for this extractor.
67 // See below for a convenience macro to create this from a string.
68 media_uuid_t extractor_uuid;
69
70 // Version number of this extractor. When two extractors with the same
71 // uuid are encountered, the one with the largest version number will
72 // be used.
73 const uint32_t extractor_version;
74
75 // a human readable name
76 const char *extractor_name;
77
78 // the sniffer function
79 const SnifferFunc sniff;
80} ExtractorDef;
81
82const uint32_t EXTRACTORDEF_VERSION = 1;
83
84// each plugin library exports one function of this type
85typedef ExtractorDef (*GetExtractorDef)();
86
87} // extern "C"
88
89} // namespace android
90
91#endif // MEDIA_EXTRACTOR_PLUGIN_API_H_