Marco Nelissen | 0b16447 | 2018-05-30 12:16:56 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 22 | namespace android { |
| 23 | |
| 24 | struct MediaTrack; |
| 25 | class MetaDataBase; |
Marco Nelissen | 0b16447 | 2018-05-30 12:16:56 -0700 | [diff] [blame] | 26 | |
| 27 | extern "C" { |
| 28 | |
Marco Nelissen | cec44d0 | 2018-06-17 22:21:09 -0700 | [diff] [blame^] | 29 | struct 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 Nelissen | 0b16447 | 2018-05-30 12:16:56 -0700 | [diff] [blame] | 37 | struct 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 Nelissen | cec44d0 | 2018-06-17 22:21:09 -0700 | [diff] [blame^] | 54 | typedef CMediaExtractor* (*CreatorFunc)(CDataSource *source, void *meta); |
Marco Nelissen | 0b16447 | 2018-05-30 12:16:56 -0700 | [diff] [blame] | 55 | typedef 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. |
| 61 | typedef CreatorFunc (*SnifferFunc)( |
Marco Nelissen | cec44d0 | 2018-06-17 22:21:09 -0700 | [diff] [blame^] | 62 | CDataSource *source, float *confidence, |
Marco Nelissen | 0b16447 | 2018-05-30 12:16:56 -0700 | [diff] [blame] | 63 | void **meta, FreeMetaFunc *freeMeta); |
| 64 | |
| 65 | typedef struct { |
| 66 | const uint8_t b[16]; |
| 67 | } media_uuid_t; |
| 68 | |
| 69 | typedef 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 | |
| 89 | const uint32_t EXTRACTORDEF_VERSION = 1; |
| 90 | |
| 91 | // each plugin library exports one function of this type |
| 92 | typedef ExtractorDef (*GetExtractorDef)(); |
| 93 | |
| 94 | } // extern "C" |
| 95 | |
| 96 | } // namespace android |
| 97 | |
| 98 | #endif // MEDIA_EXTRACTOR_PLUGIN_API_H_ |