webOS Userland
Native system APIs for webOS
NDL_directmedia_types.h
1 #pragma once
2 
3 #define _REPLACE_TYPE(_old, _new) typedef _new _old __attribute__((__deprecated__("use " #_new " instead")))
4 #define _REPLACE_TYPE_ERROR(_old, _new) typedef _new _old __attribute__((__unavailable__("use " #_new " instead")))
5 #define _REPLACE_VALUE(_old, _new) _old __attribute__((__deprecated__("use " #_new " instead"))) = (_new)
6 #define _REPLACE_STRUCT(_old, _new) struct _old __attribute__((__unavailable__("use struct " #_new " instead")))
7 #define _REPLACE_ENUM(_old, _new) enum _old __attribute__((__unavailable__("use enum " #_new " instead")))
8 
9 typedef void (*ResourceReleased)(const char *type);
10 
11 _REPLACE_TYPE(NDLInitCallback, ResourceReleased);
12 
13 typedef enum NDL_DIRECTVIDEO_SRC_TYPE_ {
14  NDL_DIRECTVIDEO_SRC_TYPE_NONE = 0,
15  NDL_DIRECTVIDEO_SRC_TYPE_H264 = 1,
16 } NDL_DIRECTVIDEO_SRC_TYPE;
17 
18 typedef enum NDL_DIRECTAUDIO_SRC_TYPE_ {
19  NDL_DIRECTAUDIO_SRC_TYPE_NONE = 0,
21  NDL_DIRECTAUDIO_SRC_TYPE_PCM = 1,
22  NDL_DIRECTAUDIO_SRC_TYPE_AC3 = 2,
24  NDL_DIRECTAUDIO_SRC_TYPE_AAC = 3,
25  NDL_DIRECTAUDIO_SRC_TYPE_WTF = 4,
26 } NDL_DIRECTAUDIO_SRC_TYPE;
27 
28 _REPLACE_TYPE(NDL_DIRECTAUDIO_SRC_TYPE_T, NDL_DIRECTAUDIO_SRC_TYPE);
29 
30 typedef enum NDL_DIRECTAUDIO_SAMPLING_FREQ_ {
31  NDL_DIRECTAUDIO_SAMPLING_FREQ_NONE = 0,
32  NDL_DIRECTAUDIO_SAMPLING_FREQ_4_KHZ = 1,
33  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_4KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_4_KHZ),
34  NDL_DIRECTAUDIO_SAMPLING_FREQ_8_KHZ = 2,
35  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_8KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_8_KHZ),
36  NDL_DIRECTAUDIO_SAMPLING_FREQ_11_025KHZ = 3,
37  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_11KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_11_025KHZ),
38  NDL_DIRECTAUDIO_SAMPLING_FREQ_12_KHZ = 4,
39  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_12KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_12_KHZ),
40  NDL_DIRECTAUDIO_SAMPLING_FREQ_16_KHZ = 5,
41  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_16KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_16_KHZ),
42  NDL_DIRECTAUDIO_SAMPLING_FREQ_22_05KHZ = 6,
43  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_22KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_22_05KHZ),
44  NDL_DIRECTAUDIO_SAMPLING_FREQ_24_KHZ = 7,
45  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_24KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_24_KHZ),
46  NDL_DIRECTAUDIO_SAMPLING_FREQ_32_KHZ = 8,
47  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_32KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_32_KHZ),
48  NDL_DIRECTAUDIO_SAMPLING_FREQ_44_1KHZ = 9,
49  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_44KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_44_1KHZ),
50  NDL_DIRECTAUDIO_SAMPLING_FREQ_48_KHZ = 10,
51  _REPLACE_VALUE(NDL_DIRECTAUDIO_SAMPLING_FREQ_48KHZ, NDL_DIRECTAUDIO_SAMPLING_FREQ_48_KHZ),
52  NDL_DIRECTAUDIO_SAMPLING_FREQ_64_KHZ = 11,
53 } NDL_DIRECTAUDIO_SAMPLING_FREQ;
54 
55 _REPLACE_TYPE(NDL_DIRECTAUDIO_SAMPLING_FREQ_T, NDL_DIRECTAUDIO_SAMPLING_FREQ);
56 
57 typedef enum NDL_DIRECTAUDIO_CH_ {
58  NDL_DIRECTAUDIO_CH_MAIN = 0,
59  NDL_DIRECTAUDIO_CH_SUB = 1,
60  NDL_DIRECTAUDIO_CH_MAX = 2,
61 } NDL_DIRECTAUDIO_CH;
62 
63 _REPLACE_TYPE(NDL_DIRECTAUDIO_CH_T, NDL_DIRECTAUDIO_CH);
64 
65 typedef enum NDL_DIRECTAUDIO_NODELAY_MODE_ {
66  NDL_DIRECTAUDIO_NODELAY_MODE_DISABLED = -1,
67  NDL_DIRECTAUDIO_NODELAY_MODE_DEFAULT = 0,
68  NDL_DIRECTAUDIO_NODELAY_MODE_CUSTOM = 1,
69 } NDL_DIRECTAUDIO_NODELAY_MODE;
70 
71 typedef enum NDL_DIRECTMEDIA_APP_STATE_ {
72  NDL_DIRECTMEDIA_APP_STATE_FOREGROUND = 0,
73  NDL_DIRECTMEDIA_APP_STATE_BACKGROUND = 1,
74 } NDL_DIRECTMEDIA_APP_STATE;
75 
76 _REPLACE_TYPE(NDL_DIRECTMEDIA_APP_STATE_T, NDL_DIRECTMEDIA_APP_STATE);
77 
78 typedef struct NDL_DIRECTAUDIO_DATA_INFO {
79  unsigned int number_of_channel;
80  unsigned int bit_per_sample;
81  NDL_DIRECTAUDIO_NODELAY_MODE no_delay_mode;
82  int no_delay_upper_time;
83  int no_delay_lower_time;
84  NDL_DIRECTAUDIO_CH channel;
85  NDL_DIRECTAUDIO_SRC_TYPE source;
86  NDL_DIRECTAUDIO_SAMPLING_FREQ frequency;
88 
89 _REPLACE_TYPE_ERROR(NDL_DIRECTAUDIO_DATA_INFO, NDL_DIRECTAUDIO_DATA_INFO_T);
90 
91 typedef struct NDL_DIRECTVIDEO_DATA_INFO {
92  int width;
93  int height;
94  NDL_DIRECTVIDEO_SRC_TYPE source;
96 
97 _REPLACE_TYPE_ERROR(NDL_DIRECTVIDEO_DATA_INFO, NDL_DIRECTVIDEO_DATA_INFO_T);
98 
99 #if defined(NDL_DIRECTMEDIA_API_VERSION) && (NDL_DIRECTMEDIA_API_VERSION >= 2)
100 /* types for API version 2 (webOS 5+) */
101 
102 typedef void (*NDLMediaLoadCallback)(int, long long, const char *);
103 
104 #define NDL_DIRECTMEDIA_AUDIO_PCM_FORMAT_S16LE "S16LE"
105 #define NDL_DIRECTMEDIA_AUDIO_PCM_MODE_MONO "mono"
106 #define NDL_DIRECTMEDIA_AUDIO_PCM_MODE_STEREO "stereo"
107 #define NDL_DIRECTMEDIA_AUDIO_PCM_MODE_6_CHANNEL "6-channel"
108 #define NDL_DIRECTMEDIA_AUDIO_PCM_LAYOUT_INTERLEAVED "interleaved"
109 #define NDL_DIRECTMEDIA_AUDIO_PCM_LAYOUT_NON_INTERLEAVED "non-interleaved"
110 
111 typedef enum NDL_VIDEO_TYPE_ {
112  NDL_VIDEO_TYPE_H264 = 1,
113  NDL_VIDEO_TYPE_H265 = 2,
114  NDL_VIDEO_TYPE_VP9 = 3,
115  NDL_VIDEO_TYPE_AV1 = 4,
116  NDL_VIDEO_TYPE_MAX = 0x7FFFFFFF,
117 } NDL_VIDEO_TYPE;
118 
119 _REPLACE_ENUM(NDL_VIDEO_TYPE, NDL_VIDEO_TYPE_);
120 
121 typedef enum NDL_AUDIO_TYPE_ {
122  NDL_AUDIO_TYPE_PCM = 1,
123  NDL_AUDIO_TYPE_MP3 = 2,
124  NDL_AUDIO_TYPE_OPUS = 3,
125  NDL_AUDIO_TYPE_MAX = 0x7FFFFFFF,
126 } NDL_AUDIO_TYPE;
127 
128 _REPLACE_ENUM(NDL_AUDIO_TYPE, NDL_AUDIO_TYPE_);
129 
130 typedef enum NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_ {
131  /* I'm pretty sure the app will crash on this value */
132  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_NONE = 0,
133  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_48KHZ = 1,
134  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_44KHZ = 2,
135  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_32KHZ = 3,
136  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_24KHZ = 4,
137  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_22KHZ = 5,
138  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_16KHZ = 6,
139  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_12KHZ = 7,
140  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_8KHZ = 8,
141 } NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE;
142 
143 _REPLACE_ENUM(NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE, NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_);
144 
145 static inline __attribute__((__const__)) NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_OF(int hertz) {
146  switch (hertz) {
147  case 48000:
148  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_48KHZ;
149  case 44100:
150  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_44KHZ;
151  case 32000:
152  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_32KHZ;
153  case 24000:
154  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_24KHZ;
155  case 22050:
156  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_22KHZ;
157  case 16000:
158  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_16KHZ;
159  case 12000:
160  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_12KHZ;
161  case 8000:
162  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_8KHZ;
163  default:
164  return NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE_NONE;
165  }
166 }
167 
168 /* name confirmed: struct NDL_DIRECTAUDIO_PCM_INFO_ */
169 typedef struct NDL_DIRECTAUDIO_PCM_INFO_ {
170  NDL_AUDIO_TYPE type;
171  int unknown1;
172  const char *format;
173  const char *layout;
174  const char *channelMode;
175  NDL_DIRECTMEDIA_AUDIO_PCM_SAMPLE_RATE sampleRate;
176 } NDL_DIRECTAUDIO_PCM_INFO_T;
177 
178 _REPLACE_STRUCT(NDL_DIRECTMEDIA_AUDIO_PCM_INFO_T, NDL_DIRECTAUDIO_PCM_INFO_);
179 _REPLACE_TYPE(NDL_DIRECTMEDIA_AUDIO_PCM_INFO, NDL_DIRECTAUDIO_PCM_INFO_T);
180 
181 typedef struct NDL_DIRECTMEDIA_AUDIO_OPUS_INFO {
182  NDL_AUDIO_TYPE type;
183  int unknown1;
184  int channels;
185  int unknown2;
186  double sampleRate;
187  const char *streamHeader;
188 } NDL_DIRECTMEDIA_AUDIO_OPUS_INFO_T;
189 
190 _REPLACE_STRUCT(NDL_DIRECTMEDIA_AUDIO_OPUS_INFO_T, NDL_DIRECTMEDIA_AUDIO_OPUS_INFO);
191 _REPLACE_TYPE(NDL_DIRECTMEDIA_AUDIO_OPUS_INFO, NDL_DIRECTMEDIA_AUDIO_OPUS_INFO_T);
192 
193 /* name confirmed: struct NDL_DIRECTMEDIA_DATA_INFO */
194 typedef struct NDL_DIRECTMEDIA_DATA_INFO {
195  struct NDL_DIRECTMEDIA_VIDEO_INFO {
196  int width;
197  int height;
198  NDL_VIDEO_TYPE type;
199  int unknown1;
200  } video;
201  union {
202  NDL_AUDIO_TYPE type;
203  NDL_DIRECTAUDIO_PCM_INFO_T pcm;
204  NDL_DIRECTMEDIA_AUDIO_OPUS_INFO_T opus;
205  char padding[32];
206  } audio;
207 } NDL_DIRECTMEDIA_DATA_INFO_T;
208 
209 _REPLACE_STRUCT(NDL_DIRECTMEDIA_DATA_INFO_T, NDL_DIRECTMEDIA_DATA_INFO);
210 _REPLACE_TYPE(NDL_DIRECTMEDIA_DATA_INFO, NDL_DIRECTMEDIA_DATA_INFO_T);
211 
212 /* name confirmed: struct NDL_DIRECTVIDEO_HDR_INFO */
213 typedef struct NDL_DIRECTVIDEO_HDR_INFO {
214  int displayPrimariesX0;
215  int displayPrimariesY0;
216  int displayPrimariesX1;
217  int displayPrimariesY1;
218  int displayPrimariesX2;
219  int displayPrimariesY2;
220  int whitePointX;
221  int whitePointY;
222  int maxDisplayMasteringLuminance;
223  int minDisplayMasteringLuminance;
224  int maxContentLightLevel;
225  int maxPicAverageLightLevel;
226  int transferCharacteristics;
227  int colorPrimaries;
228  int matrixCoeffs;
229  unsigned char reserved[32];
230 } NDL_DIRECTVIDEO_HDR_INFO_T;
231 
232 _REPLACE_STRUCT(NDL_DIRECTVIDEO_HDR_INFO_T, NDL_DIRECTVIDEO_HDR_INFO);
233 _REPLACE_TYPE(NDL_DIRECTVIDEO_HDR_INFO, NDL_DIRECTVIDEO_HDR_INFO_T);
234 
235 #endif
236 
237 #undef _REPLACE_TYPE
238 #undef _REPLACE_VALUE
239 #undef _REPLACE_STRUCT
240 #undef _REPLACE_ENUM
Definition: NDL_directmedia_types.h:78
Definition: NDL_directmedia_types.h:91