NUGU SDK Linux  1.7.6
nugu_encoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 SK Telecom Co., Ltd. All rights reserved.
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 __NUGU_ENCODER_H__
18 #define __NUGU_ENCODER_H__
19 
20 #include <nugu.h>
21 #include <base/nugu_pcm.h>
22 #include <base/nugu_buffer.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
36 typedef struct _nugu_encoder NuguEncoder;
37 
42 typedef struct _nugu_encoder_driver NuguEncoderDriver;
43 
62  NuguAudioProperty property);
63 
72 NUGU_API int nugu_encoder_free(NuguEncoder *enc);
73 
83 NUGU_API int nugu_encoder_set_driver_data(NuguEncoder *enc, void *data);
84 
92 
102 NUGU_API void *nugu_encoder_encode(NuguEncoder *enc, int is_last,
103  const void *data, size_t data_len,
104  size_t *output_len);
105 
111 NUGU_API const char *nugu_encoder_get_codec(NuguEncoder *enc);
112 
118 NUGU_API const char *nugu_encoder_get_mime_type(NuguEncoder *enc);
119 
142 };
143 
153  int (*create)(NuguEncoderDriver *driver, NuguEncoder *enc,
154  NuguAudioProperty property);
155 
160  int (*encode)(NuguEncoderDriver *driver, NuguEncoder *enc, int is_last,
161  const void *data, size_t data_len, NuguBuffer *out_buf);
166  int (*destroy)(NuguEncoderDriver *driver, NuguEncoder *enc);
167 };
168 
177 NUGU_API NuguEncoderDriver *
178 nugu_encoder_driver_new(const char *name, enum nugu_encoder_type type,
179  struct nugu_encoder_driver_ops *ops);
180 
189 
198 
207 
214 NUGU_API NuguEncoderDriver *nugu_encoder_driver_find(const char *name);
215 
222 NUGU_API NuguEncoderDriver *
224 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif
struct _nugu_buffer NuguBuffer
Buffer object.
Definition: nugu_buffer.h:52
NUGU_API NuguEncoderDriver * nugu_encoder_driver_find_bytype(enum nugu_encoder_type type)
Find a driver by type in the driver list.
struct _nugu_encoder_driver NuguEncoderDriver
encoder driver object
Definition: nugu_encoder.h:42
NUGU_API NuguEncoderDriver * nugu_encoder_driver_find(const char *name)
Find a driver by name in the driver list.
NUGU_API int nugu_encoder_driver_remove(NuguEncoderDriver *driver)
Remove the driver from driver list.
NUGU_API int nugu_encoder_driver_free(NuguEncoderDriver *driver)
Destroy the encoder driver.
NUGU_API int nugu_encoder_driver_register(NuguEncoderDriver *driver)
Register the driver to driver list.
NUGU_API NuguEncoderDriver * nugu_encoder_driver_new(const char *name, enum nugu_encoder_type type, struct nugu_encoder_driver_ops *ops)
Create new encoder driver.
nugu_encoder_type
encoder type
Definition: nugu_encoder.h:138
@ NUGU_ENCODER_TYPE_OPUS
Definition: nugu_encoder.h:140
@ NUGU_ENCODER_TYPE_SPEEX
Definition: nugu_encoder.h:139
@ NUGU_ENCODER_TYPE_CUSTOM
Definition: nugu_encoder.h:141
NUGU_API NuguEncoder * nugu_encoder_new(NuguEncoderDriver *driver, NuguAudioProperty property)
Create new encoder object.
NUGU_API int nugu_encoder_set_driver_data(NuguEncoder *enc, void *data)
Set custom data for driver.
NUGU_API int nugu_encoder_free(NuguEncoder *enc)
Destroy the encoder object.
struct _nugu_encoder NuguEncoder
encoder object
Definition: nugu_encoder.h:36
NUGU_API const char * nugu_encoder_get_codec(NuguEncoder *enc)
Get encoder codec. e.g. "OGG_OPUS" or "SPEEX".
NUGU_API void * nugu_encoder_get_driver_data(NuguEncoder *enc)
Get custom data for driver.
NUGU_API void * nugu_encoder_encode(NuguEncoder *enc, int is_last, const void *data, size_t data_len, size_t *output_len)
Encode the encoded data.
NUGU_API const char * nugu_encoder_get_mime_type(NuguEncoder *enc)
Get encoder mime type.
audio property
Definition: nugu_audio.h:92
encoder driver operations
Definition: nugu_encoder.h:148
int(* create)(NuguEncoderDriver *driver, NuguEncoder *enc, NuguAudioProperty property)
Called when creating a new encoder.
Definition: nugu_encoder.h:153
int(* encode)(NuguEncoderDriver *driver, NuguEncoder *enc, int is_last, const void *data, size_t data_len, NuguBuffer *out_buf)
Called when a encoding request is received from the encoder.
Definition: nugu_encoder.h:160
int(* destroy)(NuguEncoderDriver *driver, NuguEncoder *enc)
Called when the encoder is destroyed.
Definition: nugu_encoder.h:166