diff options
Diffstat (limited to 'ahl-binding/ahl-binding.hpp')
-rw-r--r-- | ahl-binding/ahl-binding.hpp | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/ahl-binding/ahl-binding.hpp b/ahl-binding/ahl-binding.hpp index 62a518e..66fce84 100644 --- a/ahl-binding/ahl-binding.hpp +++ b/ahl-binding/ahl-binding.hpp @@ -21,11 +21,12 @@ #include <functional> #include <sstream> #include <vector> +#include <list> #include <map> #include <cassert> #include "config_entry.hpp" -#include "ahl-4a.hpp" +#include "role.hpp" #define HL_API_NAME "ahl-4a" #define HL_API_INFO "Audio high level API for AGL applications" @@ -37,55 +38,27 @@ extern "C" { #include <afb/afb-binding.h> #include <string.h> #include <ctl-config.h> - - int afbBindingVdyn(afb_dynapi* handle); - int ahl_api_create(void*, struct afb_dynapi*); }; -namespace ext -{ - template<class T> - typename T::iterator find(T& container, const typename T::value_type& value) - { - return std::find(std::begin(container), std::end(container), value); - } - - template<class T, class UnaryPredicate> - typename T::iterator find_if(T& container, UnaryPredicate pred) - { - return std::find_if(std::begin(container), std::end(container), pred); - } - - template<class T, class UnaryPredicate> - typename T::iterator cfind_if(T& container, UnaryPredicate pred) - { - return std::find_if(std::begin(container), std::end(container), pred); - } -} - class ahl_binding_t { using role_action = std::function<void(afb_request*, std::string, std::string, json_object*)>; private: afb_dynapi* handle_; - - ahl_4a_t config_; - std::map<std::string, role_action> actions_; - std::vector<role_t> opened_roles_; + std::vector<role_t> roles_; explicit ahl_binding_t(); void load_static_verbs(); - void load_controller_api(); + + + void load_controller_configs(); int load_controller_config(const std::string& path); - int load_config(CtlSectionT* section, json_object* o); + int update_streams(); + void update_stream(std::string hal, std::string stream, std::string deviceuri); + int create_api_verb(role_t* r); - void volume(afb_request* req, std::string role, std::string stream, json_object* arg); - void open(afb_request* req, std::string role, std::string stream, json_object* arg); - void close(afb_request* req, std::string role, std::string stream, json_object* arg); - void interrupt(afb_request* req, std::string role, std::string stream, json_object* arg); - void policy_open(afb_request* req, const role_t& role); public: @@ -93,8 +66,13 @@ public: int preinit(afb_dynapi* handle); int init(); void event(std::string name, json_object* arg); - void audiorole(afb_request* req); void get_roles(afb_request* req); + + const std::vector<role_t> roles() const; + afb_dynapi* handle() const; + + void audiorole(afb_request* req); + int parse_roles_config(json_object* o); }; |