NUGU SDK Linux  1.7.6
nugu_recorder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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_RECORDER_H__
18 #define __NUGU_RECORDER_H__
19 
20 #include <nugu.h>
21 #include <base/nugu_audio.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
34 #define NUGU_RECORDER_FRAME_SIZE 512
35 
39 #define NUGU_RECORDER_MAX_FRAMES 100
40 
44 #define NUGU_RECORDER_BUFFER_SIZE \
45  (NUGU_RECORDER_FRAME_SIZE * NUGU_RECORDER_MAX_FRAMES)
46 
51 typedef struct _nugu_recorder NuguRecorder;
52 
57 typedef struct _nugu_recorder_driver NuguRecorderDriver;
58 
76 NUGU_API NuguRecorder *nugu_recorder_new(const char *name,
77  NuguRecorderDriver *driver);
78 
84 NUGU_API void nugu_recorder_free(NuguRecorder *rec);
85 
95 NUGU_API int nugu_recorder_add(NuguRecorder *rec);
96 
105 
113 NUGU_API NuguRecorder *nugu_recorder_find(const char *name);
114 
124  NuguAudioProperty property);
125 
135 
144 NUGU_API int nugu_recorder_stop(NuguRecorder *rec);
145 
154 
164 
174 NUGU_API int nugu_recorder_set_driver_data(NuguRecorder *rec, void *data);
175 
183 
194 NUGU_API int nugu_recorder_get_frame_size(NuguRecorder *rec, int *size,
195  int *max);
196 
207 NUGU_API int nugu_recorder_set_frame_size(NuguRecorder *rec, int size, int max);
208 
218 NUGU_API int nugu_recorder_push_frame(NuguRecorder *rec, const char *data,
219  int size);
220 
230 NUGU_API int nugu_recorder_get_frame(NuguRecorder *rec, char *data, int *size);
231 
242 NUGU_API int nugu_recorder_get_frame_timeout(NuguRecorder *rec, char *data,
243  int *size, int timeout);
244 
253 
273  int (*start)(NuguRecorderDriver *driver, NuguRecorder *rec,
274  NuguAudioProperty property);
275 
280  int (*stop)(NuguRecorderDriver *driver, NuguRecorder *rec);
281 };
282 
290 NUGU_API NuguRecorderDriver *
291 nugu_recorder_driver_new(const char *name,
292  struct nugu_recorder_driver_ops *ops);
293 
303 
313 
323 
333 
340 
346 NUGU_API NuguRecorderDriver *nugu_recorder_driver_find(const char *name);
347 
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif
NUGU_API int nugu_recorder_driver_set_default(NuguRecorderDriver *driver)
Set the default recorder driver.
NUGU_API NuguRecorderDriver * nugu_recorder_driver_find(const char *name)
Find a driver by name in the driver list.
NUGU_API int nugu_recorder_driver_remove(NuguRecorderDriver *driver)
Remove the driver from driver list.
NUGU_API int nugu_recorder_driver_free(NuguRecorderDriver *driver)
Destroy the recorder driver object.
NUGU_API NuguRecorderDriver * nugu_recorder_driver_new(const char *name, struct nugu_recorder_driver_ops *ops)
Create new recorder driver object.
NUGU_API NuguRecorderDriver * nugu_recorder_driver_get_default(void)
Get the default recorder driver.
NUGU_API int nugu_recorder_driver_register(NuguRecorderDriver *driver)
Register the driver to driver list.
struct _nugu_recorder_driver NuguRecorderDriver
recorder driver object
Definition: nugu_recorder.h:57
NUGU_API NuguRecorder * nugu_recorder_find(const char *name)
Find a recorder object by name in the managed list.
NUGU_API int nugu_recorder_start(NuguRecorder *rec)
Start recording.
NUGU_API int nugu_recorder_get_frame_timeout(NuguRecorder *rec, char *data, int *size, int timeout)
Get recorded data with timeout.
NUGU_API int nugu_recorder_get_frame_count(NuguRecorder *rec)
Get frame count.
NUGU_API int nugu_recorder_set_frame_size(NuguRecorder *rec, int size, int max)
Set frame size.
NUGU_API int nugu_recorder_clear(NuguRecorder *rec)
Clear recording data.
NUGU_API int nugu_recorder_push_frame(NuguRecorder *rec, const char *data, int size)
Push recorded data.
NUGU_API int nugu_recorder_get_frame(NuguRecorder *rec, char *data, int *size)
Get recorded data.
NUGU_API NuguRecorder * nugu_recorder_new(const char *name, NuguRecorderDriver *driver)
Create new recorder object.
NUGU_API int nugu_recorder_is_recording(NuguRecorder *rec)
Get the status of recording.
NUGU_API void nugu_recorder_free(NuguRecorder *rec)
Destroy the recorder object.
NUGU_API int nugu_recorder_add(NuguRecorder *rec)
Add recorder object to managed list.
struct _nugu_recorder NuguRecorder
recorder object
Definition: nugu_recorder.h:51
NUGU_API int nugu_recorder_stop(NuguRecorder *rec)
Stop recording.
NUGU_API int nugu_recorder_get_frame_size(NuguRecorder *rec, int *size, int *max)
Get frame size.
NUGU_API int nugu_recorder_set_driver_data(NuguRecorder *rec, void *data)
Set custom data for driver.
NUGU_API int nugu_recorder_remove(NuguRecorder *rec)
Remove recorder object from managed list.
NUGU_API void * nugu_recorder_get_driver_data(NuguRecorder *rec)
Get custom data for driver.
NUGU_API int nugu_recorder_set_property(NuguRecorder *rec, NuguAudioProperty property)
Set property to recorder object.
audio property
Definition: nugu_audio.h:92
Definition: nugu_recorder.h:268
int(* start)(NuguRecorderDriver *driver, NuguRecorder *rec, NuguAudioProperty property)
Called when recording is started.
Definition: nugu_recorder.h:273
int(* stop)(NuguRecorderDriver *driver, NuguRecorder *rec)
Called when recording is stopped.
Definition: nugu_recorder.h:280