blob: a2a21d2cdb63692dffced54ec22f290eb3b8827c [file] [log] [blame]
Marco Nelissen0c3be872014-05-01 10:14:44 -07001/*
2 * Copyright (C) 2014 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/*
18 * This file defines an NDK API.
19 * Do not remove methods.
20 * Do not change method signatures.
21 * Do not change the value of constants.
22 * Do not change the size of any of the classes defined in here.
23 * Do not reference types that are not part of the NDK.
24 * Do not #include files that aren't part of the NDK.
25 */
26
27#ifndef _NDK_MEDIA_FORMAT_H
28#define _NDK_MEDIA_FORMAT_H
29
Dan Albert2975a242016-09-23 16:17:45 -070030#include <sys/cdefs.h>
Marco Nelissen0c3be872014-05-01 10:14:44 -070031#include <sys/types.h>
32
Marco Nelissene419d7c2014-05-15 14:17:25 -070033#include "NdkMediaError.h"
34
Marco Nelissen0c3be872014-05-01 10:14:44 -070035#ifdef __cplusplus
36extern "C" {
37#endif
38
Dan Albert2975a242016-09-23 16:17:45 -070039#if __ANDROID_API__ >= 21
40
Marco Nelissen0c3be872014-05-01 10:14:44 -070041struct AMediaFormat;
42typedef struct AMediaFormat AMediaFormat;
43
44AMediaFormat *AMediaFormat_new();
Marco Nelissene419d7c2014-05-15 14:17:25 -070045media_status_t AMediaFormat_delete(AMediaFormat*);
Marco Nelissen0c3be872014-05-01 10:14:44 -070046
47/**
Marco Nelissen7c9b1412014-05-06 10:33:07 -070048 * Human readable representation of the format. The returned string is owned by the format,
49 * and remains valid until the next call to toString, or until the format is deleted.
Marco Nelissen0c3be872014-05-01 10:14:44 -070050 */
51const char* AMediaFormat_toString(AMediaFormat*);
52
53bool AMediaFormat_getInt32(AMediaFormat*, const char *name, int32_t *out);
54bool AMediaFormat_getInt64(AMediaFormat*, const char *name, int64_t *out);
55bool AMediaFormat_getFloat(AMediaFormat*, const char *name, float *out);
Marco Nelissen34d49722014-05-07 12:55:18 -070056/**
57 * The returned data is owned by the format and remains valid as long as the named entry
58 * is part of the format.
59 */
60bool AMediaFormat_getBuffer(AMediaFormat*, const char *name, void** data, size_t *size);
Marco Nelissen0c3be872014-05-01 10:14:44 -070061/**
Marco Nelissen7c9b1412014-05-06 10:33:07 -070062 * The returned string is owned by the format, and remains valid until the next call to getString,
63 * or until the format is deleted.
Marco Nelissen0c3be872014-05-01 10:14:44 -070064 */
65bool AMediaFormat_getString(AMediaFormat*, const char *name, const char **out);
66
Marco Nelissen34d49722014-05-07 12:55:18 -070067
68void AMediaFormat_setInt32(AMediaFormat*, const char* name, int32_t value);
69void AMediaFormat_setInt64(AMediaFormat*, const char* name, int64_t value);
70void AMediaFormat_setFloat(AMediaFormat*, const char* name, float value);
71/**
72 * The provided string is copied into the format.
73 */
74void AMediaFormat_setString(AMediaFormat*, const char* name, const char* value);
75/**
76 * The provided data is copied into the format.
77 */
78void AMediaFormat_setBuffer(AMediaFormat*, const char* name, void* data, size_t size);
79
80
81
Marco Nelissen0c3be872014-05-01 10:14:44 -070082/**
83 * XXX should these be ints/enums that we look up in a table as needed?
84 */
85extern const char* AMEDIAFORMAT_KEY_AAC_PROFILE;
86extern const char* AMEDIAFORMAT_KEY_BIT_RATE;
87extern const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT;
88extern const char* AMEDIAFORMAT_KEY_CHANNEL_MASK;
89extern const char* AMEDIAFORMAT_KEY_COLOR_FORMAT;
90extern const char* AMEDIAFORMAT_KEY_DURATION;
91extern const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL;
92extern const char* AMEDIAFORMAT_KEY_FRAME_RATE;
93extern const char* AMEDIAFORMAT_KEY_HEIGHT;
94extern const char* AMEDIAFORMAT_KEY_IS_ADTS;
95extern const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT;
96extern const char* AMEDIAFORMAT_KEY_IS_DEFAULT;
97extern const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE;
98extern const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL;
99extern const char* AMEDIAFORMAT_KEY_LANGUAGE;
100extern const char* AMEDIAFORMAT_KEY_MAX_HEIGHT;
101extern const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE;
102extern const char* AMEDIAFORMAT_KEY_MAX_WIDTH;
103extern const char* AMEDIAFORMAT_KEY_MIME;
104extern const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP;
105extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER;
106extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE;
107extern const char* AMEDIAFORMAT_KEY_WIDTH;
108extern const char* AMEDIAFORMAT_KEY_STRIDE;
109
Dan Albert2975a242016-09-23 16:17:45 -0700110#endif /* __ANDROID_API__ >= 21 */
111
Marco Nelissen0c3be872014-05-01 10:14:44 -0700112#ifdef __cplusplus
113} // extern "C"
114#endif
115
116#endif // _NDK_MEDIA_FORMAT_H