1/*
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
30#include <sys/types.h>
31
32#include "NdkMediaError.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38struct AMediaFormat;
39typedef struct AMediaFormat AMediaFormat;
40
41AMediaFormat *AMediaFormat_new();
42media_status_t AMediaFormat_delete(AMediaFormat*);
43
44/**
45 * Human readable representation of the format. The returned string is owned by the format,
46 * and remains valid until the next call to toString, or until the format is deleted.
47 */
48const char* AMediaFormat_toString(AMediaFormat*);
49
50bool AMediaFormat_getInt32(AMediaFormat*, const char *name, int32_t *out);
51bool AMediaFormat_getInt64(AMediaFormat*, const char *name, int64_t *out);
52bool AMediaFormat_getFloat(AMediaFormat*, const char *name, float *out);
53/**
54 * The returned data is owned by the format and remains valid as long as the named entry
55 * is part of the format.
56 */
57bool AMediaFormat_getBuffer(AMediaFormat*, const char *name, void** data, size_t *size);
58/**
59 * The returned string is owned by the format, and remains valid until the next call to getString,
60 * or until the format is deleted.
61 */
62bool AMediaFormat_getString(AMediaFormat*, const char *name, const char **out);
63
64
65void AMediaFormat_setInt32(AMediaFormat*, const char* name, int32_t value);
66void AMediaFormat_setInt64(AMediaFormat*, const char* name, int64_t value);
67void AMediaFormat_setFloat(AMediaFormat*, const char* name, float value);
68/**
69 * The provided string is copied into the format.
70 */
71void AMediaFormat_setString(AMediaFormat*, const char* name, const char* value);
72/**
73 * The provided data is copied into the format.
74 */
75void AMediaFormat_setBuffer(AMediaFormat*, const char* name, void* data, size_t size);
76
77
78
79/**
80 * XXX should these be ints/enums that we look up in a table as needed?
81 */
82extern const char* AMEDIAFORMAT_KEY_AAC_PROFILE;
83extern const char* AMEDIAFORMAT_KEY_BIT_RATE;
84extern const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT;
85extern const char* AMEDIAFORMAT_KEY_CHANNEL_MASK;
86extern const char* AMEDIAFORMAT_KEY_COLOR_FORMAT;
87extern const char* AMEDIAFORMAT_KEY_DURATION;
88extern const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL;
89extern const char* AMEDIAFORMAT_KEY_FRAME_RATE;
90extern const char* AMEDIAFORMAT_KEY_HEIGHT;
91extern const char* AMEDIAFORMAT_KEY_IS_ADTS;
92extern const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT;
93extern const char* AMEDIAFORMAT_KEY_IS_DEFAULT;
94extern const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE;
95extern const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL;
96extern const char* AMEDIAFORMAT_KEY_LANGUAGE;
97extern const char* AMEDIAFORMAT_KEY_MAX_HEIGHT;
98extern const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE;
99extern const char* AMEDIAFORMAT_KEY_MAX_WIDTH;
100extern const char* AMEDIAFORMAT_KEY_MIME;
101extern const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP;
102extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER;
103extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE;
104extern const char* AMEDIAFORMAT_KEY_WIDTH;
105extern const char* AMEDIAFORMAT_KEY_STRIDE;
106
107#ifdef __cplusplus
108} // extern "C"
109#endif
110
111#endif // _NDK_MEDIA_FORMAT_H
112