Sound Manager  0.3
soundmanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
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 
21 #ifndef SOUNDMANAGER_H
22 #define SOUNDMANAGER_H
23 
24 #define _GNU_SOURCE
25 #define AFB_BINDING_VERSION 2
26 #include <afb/afb-binding.h>
27 #include "dbus/audio_manager_interface.h"
28 
29 struct event{
30  char* name;
31  struct afb_event* event;
32  };
33 
34 /*
35 ********** Method of Sound Manager (API) **********
36 */
37 
67 void connect (struct afb_req request);
68 
85 void disconnect (struct afb_req request);
86 
102 void setVolume (struct afb_req request);
103 
120 void volumeStep (struct afb_req request);
121 
138 void setSinkMuteState(struct afb_req request);
139 
156 void getListMainConnections(struct afb_req request);
157 
174 void getListMainSources(struct afb_req request);
175 
192 void getListMainSinks(struct afb_req request);
193 
213 void ackConnect(struct afb_req request);
214 
233 void ackDisconnect(struct afb_req request);
234 
252 void ackSetSourceState(struct afb_req request);
253 
273 void registerSource(struct afb_req request);
274 
288 void deregisterSource(struct afb_req request);
289 
302 void subscribe(struct afb_req request);
303 
316 void unsubscribe(struct afb_req request);
317 
340 void streamOpen(struct afb_req req);
341 
356 void streamClose(struct afb_req req);
357 
372 void setStreamState(struct afb_req req);
373 
374 /*
375 ********** Event list from Sound Manager **********
376 */
377 
378 
379 /*
380 ********** Application Framework Imprement **********
381 */
382 
383 /*
384  * array of the verbs exported to afb-daemon
385  */
386 const struct afb_verb_v2 binding_verbs[]= {
387 // High Level API of AGL
388 { .verb = "stream_open", .callback = streamOpen, .auth = NULL,
389  .info = "Open stream." , .session = AFB_SESSION_NONE},
390 { .verb = "stream_close", .callback = streamClose, .auth = NULL,
391  .info = "Close stream" , .session = AFB_SESSION_NONE},
392 { .verb = "set_stream_state", .callback = setStreamState, .auth = NULL,
393  .info = "Set stream state" , .session = AFB_SESSION_NONE},
394 // Adaption API of Audio Manager
395 { .verb = "connect", .callback = connect, .auth = NULL,
396  .info = "Connect source id and sink id" , .session = AFB_SESSION_NONE},
397 { .verb = "disconnect", .callback = disconnect, .auth = NULL,
398  .info = "Disconnect source id and sink id" , .session = AFB_SESSION_NONE},
399 { .verb = "setVolume", .callback = setVolume, .auth = NULL,
400  .info = "Set volume value" , .session = AFB_SESSION_NONE}, /* it is better to show the range*/
401 { .verb = "volumeStep", .callback = volumeStep, .auth = NULL,
402  .info = "Set volume step range" , .session = AFB_SESSION_NONE},
403 { .verb = "setSinkMuteState", .callback = setSinkMuteState, .auth = NULL,
404  .info = "Set Mute state: 1 means mute, 2 means umute. Others are invalid" ,.session = AFB_SESSION_NONE},
405 { .verb = "getListMainConnections", .callback = getListMainConnections, .auth = NULL,
406  .info = "Get MainConnection List" , .session = AFB_SESSION_NONE},
407 { .verb = "getListMainSinks", .callback = getListMainSinks, .auth = NULL,
408  .info = "Get MainSink List" , .session = AFB_SESSION_NONE},
409 { .verb = "getListMainSources", .callback = getListMainSources, .auth = NULL,
410  .info = "Get MainSource List" , .session = AFB_SESSION_NONE},
411 { .verb = "registerSource", .callback = registerSource, .auth = NULL,
412  .info = "Register autio role" , .session = AFB_SESSION_NONE},
413 { .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL,
414  .info = "Deregister audio role" , .session = AFB_SESSION_NONE},
415 { .verb = "ackConnect", .callback = ackConnect, .auth = NULL,
416  .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
417 { .verb = "ackDisconnect", .callback = ackDisconnect, .auth = NULL,
418  .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
419 { .verb = "ackSetSourceState", .callback = ackSetSourceState, .auth = NULL,
420  .info = "Acknowledge of asyncSetSourceState" , .session = AFB_SESSION_NONE},
421 { .verb = "subscribe", .callback = subscribe, .auth = NULL,
422  .info = "Subscribe event" , .session = AFB_SESSION_NONE},
423 { .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL,
424  .info = "Unsubscribe event" , .session = AFB_SESSION_NONE},
425 { .verb = NULL } /* marker for end of the array */};
426 
427 int preinit();
428 int sm_init();
429 void onevent(const char *event, struct json_object *object);
430 
431 const struct afb_binding_v2 afbBindingV2 = {
432  .api = "soundmanager",
433  .specification = NULL,
434  .verbs = binding_verbs,
435  .preinit = preinit,
436  .init = sm_init,
437  .onevent = onevent
438 };
439 
440 #endif //SOUNDMANAGER_H
void ackConnect(struct afb_req request)
void setSinkMuteState(struct afb_req request)
void streamOpen(struct afb_req req)
void subscribe(struct afb_req request)
void unsubscribe(struct afb_req request)
void ackDisconnect(struct afb_req request)
void ackSetSourceState(struct afb_req request)
void getListMainSources(struct afb_req request)
void disconnect(struct afb_req request)
void volumeStep(struct afb_req request)
void setStreamState(struct afb_req req)
void registerSource(struct afb_req request)
void streamClose(struct afb_req req)
void deregisterSource(struct afb_req request)
void getListMainSinks(struct afb_req request)
void connect(struct afb_req request)
void setVolume(struct afb_req request)
void getListMainConnections(struct afb_req request)