This repository has been archived by the owner on Jan 10, 2020. It is now read-only.
forked from sailfishos/droidmedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
droidmediacodec.h
113 lines (94 loc) · 3.35 KB
/
droidmediacodec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright (C) 2014-2015 Jolla Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Authored by: Mohammed Hassan <[email protected]>
*/
#ifndef DROID_MEDIA_CODEC_H
#define DROID_MEDIA_CODEC_H
#include "droidmedia.h"
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _DroidMediaCodec DroidMediaCodec;
typedef enum {
DROID_MEDIA_CODEC_SW_ONLY = 0x1,
DROID_MEDIA_CODEC_HW_ONLY = 0x2,
DROID_MEDIA_CODEC_USE_EXTERNAL_LOOP = 0x4,
DROID_MEDIA_CODEC_NO_MEDIA_BUFFER = 0x8,
} DroidMediaCodecFlags;
typedef enum {
DROID_MEDIA_CODEC_LOOP_OK,
DROID_MEDIA_CODEC_LOOP_ERROR,
DROID_MEDIA_CODEC_LOOP_EOS,
} DroidMediaCodecLoopReturn;
typedef struct {
const char *type;
int32_t width;
int32_t height;
int32_t fps;
int32_t channels;
int32_t sample_rate;
int32_t hal_format;
DroidMediaCodecFlags flags;
} DroidMediaCodecMetaData;
typedef struct {
DroidMediaCodecMetaData parent;
DroidMediaData codec_data;
} DroidMediaCodecDecoderMetaData;
typedef struct {
DroidMediaCodecMetaData parent;
int32_t color_format;
int32_t bitrate;
int32_t meta_data;
int32_t stride;
int32_t slice_height;
int32_t max_input_size;
} DroidMediaCodecEncoderMetaData;
typedef struct {
DroidMediaData data;
int64_t ts;
int64_t decoding_ts;
bool sync; /* used for decoder input and encoder output */
bool codec_config; /* user for encoder output */
} DroidMediaCodecData;
typedef struct {
void (* signal_eos)(void *data);
void (* error)(void *data, int err);
int (* size_changed)(void *data, int32_t width, int32_t height);
} DroidMediaCodecCallbacks;
typedef struct {
void (* data_available) (void *data, DroidMediaCodecData *encoded);
} DroidMediaCodecDataCallbacks;
DroidMediaBufferQueue *droid_media_codec_get_buffer_queue (DroidMediaCodec *codec);
DroidMediaCodec *droid_media_codec_create_decoder(DroidMediaCodecDecoderMetaData *meta);
DroidMediaCodec *droid_media_codec_create_encoder(DroidMediaCodecEncoderMetaData *meta);
void droid_media_codec_set_callbacks(DroidMediaCodec *codec, DroidMediaCodecCallbacks *cb, void *data);
void droid_media_codec_set_data_callbacks(DroidMediaCodec *codec,
DroidMediaCodecDataCallbacks *cb, void *data);
bool droid_media_codec_start(DroidMediaCodec *codec);
void droid_media_codec_stop(DroidMediaCodec *codec);
void droid_media_codec_destroy(DroidMediaCodec *codec);
void droid_media_codec_queue(DroidMediaCodec *codec, DroidMediaCodecData *data, DroidMediaBufferCallbacks *cb);
void droid_media_codec_flush(DroidMediaCodec *codec);
void droid_media_codec_drain(DroidMediaCodec *codec);
DroidMediaCodecLoopReturn droid_media_codec_loop(DroidMediaCodec *codec);
void droid_media_codec_get_output_info(DroidMediaCodec *codec, DroidMediaCodecMetaData *info, DroidMediaRect *crop);
#ifdef __cplusplus
};
#endif
#endif /* DROID_MEDIA_CODEC_H */