1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* Copyright (C) 2017 "Audiokinetic Inc"
* Author Francois Thibault <fthibault@audiokinetic.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include "ahl-binding.h"
// This file provides example of custom, business logic driven policy actions that can affect behavior of the high level
// TODO: Currently only isolated in separate source file. Objective is to make this to at least a shared lib plug-in
// Going a step further would be to implement this within afb-controler policy plug-in (would require bi-directional access to HLB context)
extern AHLCtxT g_AHLCtx; // TODO: Cannot stay if moved to external module
// Attribute of high-level binding (parsed), policy enforced
typedef enum InterruptedBehavior {
INTERRUPTEDBEHAVIOR_CONTINUE = 0, // Continue to play when interrupted (e.g. media will be ducked)
INTERRUPTEDBEHAVIOR_CANCEL, // Abort playback when interrupted (e.g. non-important HMI feedback that does not make sense later)
INTERRUPTEDBEHAVIOR_PAUSE, // Pause source when interrupted, to be resumed afterwards (e.g. non-temporal guidance)
INTERRUPTEDBEHAVIOR_MAXVALUE, // Enum count, keep at the end
} InterruptedBehaviorT;
PUBLIC int Policy_OpenStream(char *pAudioRole, EndpointTypeT endpointType, endpointID_t endpointID)
{
return 1; // Policy allowed
}
PUBLIC int Policy_SetVolume(EndpointTypeT endpointType, endpointID_t endpointID, char *volumeStr, int rampTimeMS)
{
return 1; // Policy allowed
}
PUBLIC int Policy_SetProperty(EndpointTypeT endpointType, endpointID_t endpointID, char *propertyName, char *propValueStr, int rampTimeMS)
{
return 1; // Policy allowed
}
PUBLIC int Policy_SetState(EndpointTypeT endpointType, endpointID_t endpointID, char *pStateName, char *pStateValue)
{
//Mute
if(strcmp(pStateName, AUDIOHL_STATE_NAME_MUTE) == 0)
{
if(strcmp(pStateName, AUDIOHL_STATE_NAME_MUTE) == 0)
return AUDIOHL_POLICY_ACCEPT;
}
//Retrieve global context
//Active rule check
//Ducking rule settings
return AUDIOHL_POLICY_ACCEPT;
}
PUBLIC int Policy_PostSoundEvent(char *eventName, char *audioRole, char *mediaName, void *audioContext)
{
return 1; // Policy allowed
}
PUBLIC int Policy_AudioDeviceChange()
{
// Allow or disallow a new audio device
// Raise events to engage device switching
// Policy can also assign audio role(s) for device
return 1; // Policy allowed
}
|