NUGU SDK Linux  1.7.6
nugu_pcm.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_PCM_H__
18 #define __NUGU_PCM_H__
19 
20 #include <stddef.h>
21 #include <nugu.h>
22 #include <base/nugu_audio.h>
23 #include <base/nugu_media.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
37 typedef struct _nugu_pcm NuguPcm;
38 
43 typedef struct _nugu_pcm_driver NuguPcmDriver;
44 
65 NUGU_API NuguPcm *nugu_pcm_new(const char *name, NuguPcmDriver *driver,
66  NuguAudioProperty property);
67 
73 NUGU_API void nugu_pcm_free(NuguPcm *pcm);
74 
84 NUGU_API int nugu_pcm_add(NuguPcm *pcm);
85 
95 NUGU_API int nugu_pcm_remove(NuguPcm *pcm);
96 
104 NUGU_API NuguPcm *nugu_pcm_find(const char *name);
105 
115  NuguAudioAttribute attr);
116 
124 
131 NUGU_API const char *nugu_pcm_get_audio_attribute_str(NuguPcm *pcm);
132 
141 NUGU_API int nugu_pcm_start(NuguPcm *pcm);
142 
151 NUGU_API int nugu_pcm_stop(NuguPcm *pcm);
152 
161 NUGU_API int nugu_pcm_pause(NuguPcm *pcm);
162 
171 NUGU_API int nugu_pcm_resume(NuguPcm *pcm);
172 
182 NUGU_API int nugu_pcm_set_volume(NuguPcm *pcm, int volume);
183 
192 NUGU_API int nugu_pcm_get_volume(NuguPcm *pcm);
193 
201 NUGU_API int nugu_pcm_get_duration(NuguPcm *pcm);
202 
210 NUGU_API int nugu_pcm_get_position(NuguPcm *pcm);
211 
218 
227  void *userdata);
228 
234 NUGU_API void nugu_pcm_emit_status(NuguPcm *pcm, enum nugu_media_status status);
235 
244  void *userdata);
245 
251 NUGU_API void nugu_pcm_emit_event(NuguPcm *pcm, enum nugu_media_event event);
252 
262 NUGU_API int nugu_pcm_set_driver_data(NuguPcm *pcm, void *data);
263 
270 NUGU_API void *nugu_pcm_get_driver_data(NuguPcm *pcm);
271 
276 NUGU_API void nugu_pcm_clear_buffer(NuguPcm *pcm);
277 
288 NUGU_API int nugu_pcm_push_data(NuguPcm *pcm, const char *data, size_t size,
289  int is_last);
290 
299 NUGU_API int nugu_pcm_push_data_done(NuguPcm *pcm);
300 
310 NUGU_API int nugu_pcm_get_data(NuguPcm *pcm, char *data, size_t size);
311 
317 NUGU_API size_t nugu_pcm_get_data_size(NuguPcm *pcm);
318 
328 
352  int (*create)(NuguPcmDriver *driver, NuguPcm *pcm,
353  NuguAudioProperty property);
354 
359  void (*destroy)(NuguPcmDriver *driver, NuguPcm *pcm);
360 
365  int (*start)(NuguPcmDriver *driver, NuguPcm *pcm);
366 
371  int (*push_data)(NuguPcmDriver *driver, NuguPcm *pcm, const char *data,
372  size_t size, int is_last);
373 
378  int (*stop)(NuguPcmDriver *driver, NuguPcm *pcm);
379 
384  int (*pause)(NuguPcmDriver *driver, NuguPcm *pcm);
385 
390  int (*resume)(NuguPcmDriver *driver, NuguPcm *pcm);
391 
396  int (*set_volume)(NuguPcmDriver *driver, NuguPcm *pcm, int volume);
397 
402  int (*get_position)(NuguPcmDriver *driver, NuguPcm *pcm);
403 };
404 
412 NUGU_API NuguPcmDriver *nugu_pcm_driver_new(const char *name,
413  struct nugu_pcm_driver_ops *ops);
414 
423 NUGU_API int nugu_pcm_driver_free(NuguPcmDriver *driver);
424 
434 
443 NUGU_API int nugu_pcm_driver_remove(NuguPcmDriver *driver);
444 
454 
461 
467 NUGU_API NuguPcmDriver *nugu_pcm_driver_find(const char *name);
468 
473 #ifdef __cplusplus
474 }
475 #endif
476 
477 #endif
nugu_media_event
media event type
Definition: nugu_media.h:66
void(* NuguMediaEventCallback)(enum nugu_media_event event, void *userdata)
Callback type for media event.
Definition: nugu_media.h:86
void(* NuguMediaStatusCallback)(enum nugu_media_status status, void *userdata)
Callback type for media status.
Definition: nugu_media.h:80
nugu_media_status
media status
Definition: nugu_media.h:56
NUGU_API int nugu_pcm_driver_free(NuguPcmDriver *driver)
Destroy the pcm driver object.
NUGU_API NuguPcmDriver * nugu_pcm_driver_get_default(void)
Get the default pcm driver.
NUGU_API NuguPcmDriver * nugu_pcm_driver_new(const char *name, struct nugu_pcm_driver_ops *ops)
Create new pcm driver object.
NUGU_API int nugu_pcm_driver_remove(NuguPcmDriver *driver)
Remove the driver from driver list.
NUGU_API NuguPcmDriver * nugu_pcm_driver_find(const char *name)
Find a driver by name in the driver list.
struct _nugu_pcm_driver NuguPcmDriver
pcm driver object
Definition: nugu_pcm.h:43
NUGU_API int nugu_pcm_driver_set_default(NuguPcmDriver *driver)
Set the default pcm driver.
NUGU_API int nugu_pcm_driver_register(NuguPcmDriver *driver)
Register the driver to driver list.
NUGU_API NuguPcm * nugu_pcm_new(const char *name, NuguPcmDriver *driver, NuguAudioProperty property)
Create new pcm object.
NUGU_API NuguPcm * nugu_pcm_find(const char *name)
Find a pcm object by name in the managed list.
NUGU_API void nugu_pcm_emit_status(NuguPcm *pcm, enum nugu_media_status status)
Emit status to registered callback.
NUGU_API int nugu_pcm_set_driver_data(NuguPcm *pcm, void *data)
Set custom data for driver.
NUGU_API void nugu_pcm_clear_buffer(NuguPcm *pcm)
Clear pcm buffer.
NUGU_API const char * nugu_pcm_get_audio_attribute_str(NuguPcm *pcm)
Get audio attribute.
NUGU_API int nugu_pcm_resume(NuguPcm *pcm)
Resume pcm playback.
NUGU_API int nugu_pcm_receive_is_last_data(NuguPcm *pcm)
Get flag that all data pushes are complete.
NUGU_API void nugu_pcm_set_event_callback(NuguPcm *pcm, NuguMediaEventCallback cb, void *userdata)
Set pcm event callback.
NUGU_API int nugu_pcm_add(NuguPcm *pcm)
Add pcm object to managed list.
NUGU_API int nugu_pcm_pause(NuguPcm *pcm)
Pause pcm playback.
NUGU_API void nugu_pcm_emit_event(NuguPcm *pcm, enum nugu_media_event event)
Emit event to registered callback.
NUGU_API int nugu_pcm_remove(NuguPcm *pcm)
Remove pcm object from managed list.
NUGU_API int nugu_pcm_start(NuguPcm *pcm)
Start pcm playback.
NUGU_API int nugu_pcm_get_audio_attribute(NuguPcm *pcm)
Get audio attribute.
NUGU_API int nugu_pcm_get_position(NuguPcm *pcm)
Get current playback position of pcm.
NUGU_API int nugu_pcm_push_data_done(NuguPcm *pcm)
Set flag that push for all data is complete.
NUGU_API int nugu_pcm_get_volume(NuguPcm *pcm)
Get volume of pcm.
NUGU_API void nugu_pcm_free(NuguPcm *pcm)
Destroy the pcm object.
NUGU_API int nugu_pcm_set_volume(NuguPcm *pcm, int volume)
Set volume of pcm.
struct _nugu_pcm NuguPcm
pcm object
Definition: nugu_pcm.h:37
NUGU_API void * nugu_pcm_get_driver_data(NuguPcm *pcm)
Get custom data for driver.
NUGU_API int nugu_pcm_get_duration(NuguPcm *pcm)
Get duration information of pcm.
NUGU_API int nugu_pcm_push_data(NuguPcm *pcm, const char *data, size_t size, int is_last)
Push playback pcm data.
NUGU_API size_t nugu_pcm_get_data_size(NuguPcm *pcm)
Get pcm data size.
NUGU_API int nugu_pcm_stop(NuguPcm *pcm)
Stop pcm playback.
NUGU_API int nugu_pcm_set_audio_attribute(NuguPcm *pcm, NuguAudioAttribute attr)
Set audio attribute.
NUGU_API void nugu_pcm_set_status_callback(NuguPcm *pcm, NuguMediaStatusCallback cb, void *userdata)
Set pcm status callback.
NUGU_API int nugu_pcm_get_data(NuguPcm *pcm, char *data, size_t size)
Get all data.
NUGU_API enum nugu_media_status nugu_pcm_get_status(NuguPcm *pcm)
Get status of pcm.
enum nugu_audio_attribute NuguAudioAttribute
NuguAudioAttribute.
Definition: nugu_audio.h:101
audio property
Definition: nugu_audio.h:92
pcm driver operations
Definition: nugu_pcm.h:347
int(* resume)(NuguPcmDriver *driver, NuguPcm *pcm)
called when pcm is resumed
Definition: nugu_pcm.h:390
int(* start)(NuguPcmDriver *driver, NuguPcm *pcm)
Called when pcm is started.
Definition: nugu_pcm.h:365
int(* set_volume)(NuguPcmDriver *driver, NuguPcm *pcm, int volume)
called when pcm is needed to set volume
Definition: nugu_pcm.h:396
int(* get_position)(NuguPcmDriver *driver, NuguPcm *pcm)
Called when a playback position is requested.
Definition: nugu_pcm.h:402
int(* create)(NuguPcmDriver *driver, NuguPcm *pcm, NuguAudioProperty property)
Called when pcm is created.
Definition: nugu_pcm.h:352
int(* push_data)(NuguPcmDriver *driver, NuguPcm *pcm, const char *data, size_t size, int is_last)
Called when a pcm data is pushed to pcm object.
Definition: nugu_pcm.h:371
int(* pause)(NuguPcmDriver *driver, NuguPcm *pcm)
Called when pcm is paused.
Definition: nugu_pcm.h:384
void(* destroy)(NuguPcmDriver *driver, NuguPcm *pcm)
Called when pcm is destroyed.
Definition: nugu_pcm.h:359
int(* stop)(NuguPcmDriver *driver, NuguPcm *pcm)
Called when pcm is stopped.
Definition: nugu_pcm.h:378