NUGU SDK Linux  1.7.6
nugu_player.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_PLAYER_H__
18 #define __NUGU_PLAYER_H__
19 
20 #include <nugu.h>
21 #include <base/nugu_audio.h>
22 #include <base/nugu_media.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
36 typedef struct _nugu_player NuguPlayer;
37 
42 typedef struct _nugu_player_driver NuguPlayerDriver;
43 
61 NUGU_API NuguPlayer *nugu_player_new(const char *name,
62  NuguPlayerDriver *driver);
63 
69 NUGU_API void nugu_player_free(NuguPlayer *player);
70 
80 NUGU_API int nugu_player_add(NuguPlayer *player);
81 
91 NUGU_API int nugu_player_remove(NuguPlayer *player);
92 
100 NUGU_API NuguPlayer *nugu_player_find(const char *name);
101 
111  NuguAudioAttribute attr);
112 
120 
127 NUGU_API const char *nugu_player_get_audio_attribute_str(NuguPlayer *player);
128 
137 NUGU_API int nugu_player_set_source(NuguPlayer *player, const char *url);
138 
148 NUGU_API int nugu_player_start(NuguPlayer *player);
149 
158 NUGU_API int nugu_player_stop(NuguPlayer *player);
159 
168 NUGU_API int nugu_player_pause(NuguPlayer *player);
169 
179 NUGU_API int nugu_player_resume(NuguPlayer *player);
180 
189 NUGU_API int nugu_player_seek(NuguPlayer *player, int sec);
190 
200 NUGU_API int nugu_player_set_volume(NuguPlayer *player, int vol);
201 
210 NUGU_API int nugu_player_get_volume(NuguPlayer *player);
211 
219 NUGU_API int nugu_player_get_duration(NuguPlayer *player);
220 
229 NUGU_API int nugu_player_set_position(NuguPlayer *player, int position);
230 
238 NUGU_API int nugu_player_get_position(NuguPlayer *player);
239 
246 
255  void *userdata);
256 
262 NUGU_API void nugu_player_emit_status(NuguPlayer *player,
263  enum nugu_media_status status);
264 
273  void *userdata);
274 
280 NUGU_API void nugu_player_emit_event(NuguPlayer *player,
281  enum nugu_media_event event);
282 
292 NUGU_API int nugu_player_set_driver_data(NuguPlayer *player, void *data);
293 
300 NUGU_API void *nugu_player_get_driver_data(NuguPlayer *player);
301 
326  int (*create)(NuguPlayerDriver *driver, NuguPlayer *player);
327 
332  void (*destroy)(NuguPlayerDriver *driver, NuguPlayer *player);
333 
338  int (*set_source)(NuguPlayerDriver *driver, NuguPlayer *player,
339  const char *url);
340 
345  int (*start)(NuguPlayerDriver *driver, NuguPlayer *player);
346 
351  int (*stop)(NuguPlayerDriver *driver, NuguPlayer *player);
352 
357  int (*pause)(NuguPlayerDriver *driver, NuguPlayer *player);
358 
363  int (*resume)(NuguPlayerDriver *driver, NuguPlayer *player);
364 
369  int (*seek)(NuguPlayerDriver *driver, NuguPlayer *player, int sec);
370 
375  int (*set_volume)(NuguPlayerDriver *driver, NuguPlayer *player,
376  int vol);
377 
382  int (*get_duration)(NuguPlayerDriver *driver, NuguPlayer *player);
383 
388  int (*get_position)(NuguPlayerDriver *driver, NuguPlayer *player);
389 };
390 
397 NUGU_API NuguPlayerDriver *
398 nugu_player_driver_new(const char *name, struct nugu_player_driver_ops *ops);
399 
408 
417 
426 
435 
441 
447 NUGU_API NuguPlayerDriver *nugu_player_driver_find(const char *name);
448 
453 #ifdef __cplusplus
454 }
455 #endif
456 
457 #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
struct _nugu_player_driver NuguPlayerDriver
player driver object
Definition: nugu_player.h:42
NUGU_API int nugu_player_driver_remove(NuguPlayerDriver *driver)
Remove the driver from driver list.
NUGU_API int nugu_player_driver_free(NuguPlayerDriver *driver)
Destroy the player driver object.
NUGU_API NuguPlayerDriver * nugu_player_driver_get_default(void)
Get the default player driver.
NUGU_API NuguPlayerDriver * nugu_player_driver_find(const char *name)
Find a driver by name in the driver list.
NUGU_API int nugu_player_driver_register(NuguPlayerDriver *driver)
Register the driver to driver list.
NUGU_API int nugu_player_driver_set_default(NuguPlayerDriver *driver)
Set the default player driver.
NUGU_API NuguPlayerDriver * nugu_player_driver_new(const char *name, struct nugu_player_driver_ops *ops)
Create new player driver object.
NUGU_API NuguPlayer * nugu_player_find(const char *name)
Find a player object by name in the managed list.
NUGU_API int nugu_player_start(NuguPlayer *player)
Start the player.
NUGU_API int nugu_player_seek(NuguPlayer *player, int sec)
Seek the player.
NUGU_API void nugu_player_emit_status(NuguPlayer *player, enum nugu_media_status status)
Emit status to registered callback.
NUGU_API int nugu_player_get_position(NuguPlayer *player)
Get current playback position of player.
NUGU_API const char * nugu_player_get_audio_attribute_str(NuguPlayer *player)
Get audio attribute.
NUGU_API void nugu_player_set_event_callback(NuguPlayer *player, NuguMediaEventCallback cb, void *userdata)
Set player event callback.
NUGU_API int nugu_player_set_driver_data(NuguPlayer *player, void *data)
Set custom data for driver.
NUGU_API int nugu_player_remove(NuguPlayer *player)
Remove player object from managed list.
NUGU_API int nugu_player_set_position(NuguPlayer *player, int position)
Set current playback position of player.
NUGU_API NuguPlayer * nugu_player_new(const char *name, NuguPlayerDriver *driver)
Create new player object.
NUGU_API int nugu_player_resume(NuguPlayer *player)
Resume the player.
NUGU_API int nugu_player_stop(NuguPlayer *player)
Stop the player.
NUGU_API int nugu_player_set_source(NuguPlayer *player, const char *url)
Set source url.
struct _nugu_player NuguPlayer
player object
Definition: nugu_player.h:36
NUGU_API void nugu_player_emit_event(NuguPlayer *player, enum nugu_media_event event)
Emit event to registered callback.
NUGU_API int nugu_player_set_volume(NuguPlayer *player, int vol)
Set volume of player.
NUGU_API void * nugu_player_get_driver_data(NuguPlayer *player)
Get custom data for driver.
NUGU_API int nugu_player_pause(NuguPlayer *player)
Pause the player.
NUGU_API int nugu_player_add(NuguPlayer *player)
Add player object to managed list.
NUGU_API int nugu_player_get_volume(NuguPlayer *player)
Get volume of player.
NUGU_API int nugu_player_get_audio_attribute(NuguPlayer *player)
Get audio attribute.
NUGU_API void nugu_player_free(NuguPlayer *player)
Destroy the player object.
NUGU_API enum nugu_media_status nugu_player_get_status(NuguPlayer *player)
Get status of player.
NUGU_API int nugu_player_get_duration(NuguPlayer *player)
Get duration information of player.
NUGU_API void nugu_player_set_status_callback(NuguPlayer *player, NuguMediaStatusCallback cb, void *userdata)
Set player status callback.
NUGU_API int nugu_player_set_audio_attribute(NuguPlayer *player, NuguAudioAttribute attr)
Set audio attribute.
enum nugu_audio_attribute NuguAudioAttribute
NuguAudioAttribute.
Definition: nugu_audio.h:101
player driver operations
Definition: nugu_player.h:321
int(* get_position)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when a playback position is requested.
Definition: nugu_player.h:388
int(* set_volume)(NuguPlayerDriver *driver, NuguPlayer *player, int vol)
Called when volume is changed.
Definition: nugu_player.h:375
void(* destroy)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is destroyed.
Definition: nugu_player.h:332
int(* set_source)(NuguPlayerDriver *driver, NuguPlayer *player, const char *url)
Called when set the player source.
Definition: nugu_player.h:338
int(* stop)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is stopped.
Definition: nugu_player.h:351
int(* seek)(NuguPlayerDriver *driver, NuguPlayer *player, int sec)
Called when playback position is changed by seek.
Definition: nugu_player.h:369
int(* resume)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is resumed.
Definition: nugu_player.h:363
int(* pause)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is paused.
Definition: nugu_player.h:357
int(* create)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is created.
Definition: nugu_player.h:326
int(* start)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when player is started.
Definition: nugu_player.h:345
int(* get_duration)(NuguPlayerDriver *driver, NuguPlayer *player)
Called when a playback duration is requested.
Definition: nugu_player.h:382