diff options
author | 2018-02-23 16:37:41 +0900 | |
---|---|---|
committer | 2018-02-23 16:42:07 +0900 | |
commit | 3990a0620ca2269a190236ad905c0ac542c1e827 (patch) | |
tree | 2ecbf3c7ba3109be641157cb2d7842ab91d29ba1 /src | |
parent | 66a6137efa7530b93096ea7c0b9780d98c7726d7 (diff) |
Add high level API functions
Add the following functions
* stream_open
* stream_close
* set_stream_state
The functions are not impremented yet.
Change-Id: I881ae61978c04bb8cecffbe30a9b821d1e49c43a
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/soundmanager.c | 102 |
2 files changed, 93 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c29aa89..7f4f573 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,13 @@ set(binding_sm_sources sm-helper.c dbus/audio_manager_interface.c) +option(ENABLE_AGL_AHL "Implement AGL High Level API" ON) + +if(ENABLE_AGL_AHL) + message(STATUS "Adopt high level API of AGL") + add_definitions(-DENABLE_AGL_AHL) +endif() + include_directories(dbus) link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined) diff --git a/src/soundmanager.c b/src/soundmanager.c index f138dae..849f176 100644 --- a/src/soundmanager.c +++ b/src/soundmanager.c @@ -136,7 +136,7 @@ static struct afb_event ev_async_set_source_state; * * This will be modified after integrating * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -211,7 +211,7 @@ static void connect (struct afb_req request) * - sourceID : Source ID getting in return value in registerSource or appname. * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -265,7 +265,7 @@ static void disconnect (struct afb_req request) * - volume : volume value. The range of value should be [0-100] * - sinkID : sinkID you would like to change volume at * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -321,7 +321,7 @@ static void setVolume (struct afb_req request) * - volumeStep : Step size of volume * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -377,7 +377,7 @@ static void volumeStep (struct afb_req request) * - muteState : muteState, 1 means mute, 2 means unmute. Or you can designate as "mute" or "unmute" * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -432,7 +432,7 @@ static void setSinkMuteState(struct afb_req request) * None * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list, * Sound Manager return success. * @@ -505,7 +505,7 @@ static void getListMainConnections(struct afb_req request) * None * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list, * Sound Manager return success. * @@ -583,7 +583,7 @@ static void getListMainSources(struct afb_req request) * None * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list, * Sound Manager return success. * @@ -673,7 +673,7 @@ static void getListMainSinks(struct afb_req request) * resources the application got in connect. * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list, * Sound Manager return success. So you should check the contents size of return json object * @@ -735,7 +735,7 @@ static void ackConnect(struct afb_req request) * If an application has some error, send error number in function then AM * * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. Even if there is no connection list, * Sound Manager return success. So you should check the contents size of return json object * @@ -795,7 +795,7 @@ static void ackDisconnect(struct afb_req request) * - error : Error Number you would like to send. If error is 0, it means OK. * If an application has some errors, send error number in function * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -974,7 +974,7 @@ static void registerSource(struct afb_req request) * #### Parameters * - sourceID : sourceID returned in resisterSource * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -1016,7 +1016,7 @@ static void deregisterSource(struct afb_req request) * #### Parameters * - event : Event name. Event list is written in libsoundmanager.hpp * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -1065,7 +1065,7 @@ static void subscribe(struct afb_req request) * #### Parameters * - event : Event name. Event list is written in libsoundmanager.hpp * - * #### Rreturn + * #### Return * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. * * #### Note @@ -1108,6 +1108,66 @@ static void unsubscribe(struct afb_req request) afb_req_success(request, res, info); } +/** + * Application High Level API for AGL + * This function opens "stream". + * "strem" means the routing from source to sink. + * This function calls registerSource and register the endpoint. + * If the endpoint is not registered in AudioManager, Sound Manager uses default value. + * audio_role will be translated to "sourceID", and "endpoint_id" will be translated to "sinkID". + * + * #### Parameters + * - audio_role : audio role such like entertainment, emergency. + * This name is depends on the system architect. + * The name will be application name or will be the group(role) of application. + * - endpoint_id : Same as sinkID in Sound Manager. + * + * #### Return + * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. + * - stream_id : Same as sourceID but key is different. This is for AHL. + * #### Note + * TODO : write note + */ +static void streamOpen(struct afb_req req){ +// TODO : wtite function +} + +/** + * Application High Level API for AGL + * This function closes "stream". + * This function calls disconnect with registered connectionID translated with requested connection_id. + * If the connection is not created in Sound Manager, Sound Manager just returns with error message. + * + * #### Parameters + * - stream_id : Stream id which is returned in stream_open. + * + * #### Return + * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. + * #### Note + * TODO : write note + */ +static void streamClose(struct afb_req req){ +// TODO : wtite function +} + +/** + * Application High Level API for AGL + * This function set stream state. + * This function set the availability and calls connect function of Audio Manager + * and returns the result of policy check. + * + * #### Parameters + * - stream_id : Stream id which is returned in stream_open. + * - mute : Stream state as int + * #### Return + * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message. + * #### Note + * TODO : write note + */ +static void setStreamState(struct afb_req req){ +// TODO : wtite function +} + /* ********** Callback Function invoked by Audio Manager ********** */ @@ -1348,6 +1408,16 @@ static gboolean on_async_set_source_state( * array of the verbs exported to afb-daemon */ static const struct afb_verb_v2 binding_verbs[]= { +#ifdef ENABLE_AGL_AHL +// High Level API of AGL +{ .verb = "stream_open", .callback = streamOpen, .auth = NULL, + .info = "Open stream." , .session = AFB_SESSION_NONE}, +{ .verb = "stream_close", .callback = streamClose, .auth = NULL, + .info = "Close stream" , .session = AFB_SESSION_NONE}, +{ .verb = "set_stream_state", .callback = setStreamState, .auth = NULL, + .info = "Set stream state" , .session = AFB_SESSION_NONE}, +#endif +// Adaption API of Audio Manager { .verb = "connect", .callback = connect, .auth = NULL, .info = "Connect source id and sink id" , .session = AFB_SESSION_NONE}, { .verb = "disconnect", .callback = disconnect, .auth = NULL, @@ -1365,9 +1435,9 @@ static const struct afb_verb_v2 binding_verbs[]= { { .verb = "getListMainSources", .callback = getListMainSources, .auth = NULL, .info = "Get MainSource List" , .session = AFB_SESSION_NONE}, { .verb = "registerSource", .callback = registerSource, .auth = NULL, - .info = "Register Application" , .session = AFB_SESSION_NONE}, + .info = "Register autio role" , .session = AFB_SESSION_NONE}, { .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL, - .info = "Deregister Application" , .session = AFB_SESSION_NONE}, + .info = "Deregister audio role" , .session = AFB_SESSION_NONE}, { .verb = "ackConnect", .callback = ackConnect, .auth = NULL, .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE}, { .verb = "ackDisconnect", .callback = ackDisconnect, .auth = NULL, |