1275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent/*
2275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Copyright (C) 2014 The Android Open Source Project
3275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent *
4275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
5275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * you may not use this file except in compliance with the License.
6275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * You may obtain a copy of the License at
7275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent *
8275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
9275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent *
10275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Unless required by applicable law or agreed to in writing, software
11275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
12275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * See the License for the specific language governing permissions and
14275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * limitations under the License.
15275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent */
16275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
17275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
18275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#ifndef ANDROID_AUDIO_POLICY_H
19275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define ANDROID_AUDIO_POLICY_H
20275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
21275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <system/audio.h>
22275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <system/audio_policy.h>
23275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <binder/Parcel.h>
24275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <utils/String8.h>
25275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <utils/Vector.h>
26275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
27275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentnamespace android {
28275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
29275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent// Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java
30275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUSION_MASK 0x8000
31275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_MATCH_ATTRIBUTE_USAGE 0x1
32275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1)
33275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE)
34275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \
35275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET)
36275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
37275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_INVALID -1
38275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_PLAYERS 0
39275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_RECORDERS 1
40275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
41275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define ROUTE_FLAG_RENDER 0x1
42275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define ROUTE_FLAG_LOOP_BACK (0x1 << 1)
43275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
44275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MAX_MIXES_PER_POLICY 10
45275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MAX_CRITERIA_PER_MIX 20
46275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
47275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentclass AttributeMatchCriterion {
48275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentpublic:
49275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    AttributeMatchCriterion() {}
50275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule);
51275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
52275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    status_t readFromParcel(Parcel *parcel);
53275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    status_t writeToParcel(Parcel *parcel) const;
54275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
55275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    union {
56275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent        audio_usage_t   mUsage;
57275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent        audio_source_t  mSource;
58275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    } mAttr;
59275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    uint32_t        mRule;
60275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent};
61275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
62275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentclass AudioMix {
63275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentpublic:
64275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    AudioMix() {}
65275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format,
66275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent             uint32_t routeFlags, String8 registrationId) :
67275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent        mCriteria(criteria), mMixType(mixType), mFormat(format),
68275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent        mRouteFlags(routeFlags), mRegistrationId(registrationId) {}
69275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
70275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    status_t readFromParcel(Parcel *parcel);
71275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    status_t writeToParcel(Parcel *parcel) const;
72275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
73275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    Vector<AttributeMatchCriterion> mCriteria;
74275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    uint32_t        mMixType;
75275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    audio_config_t  mFormat;
76275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    uint32_t        mRouteFlags;
77275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent    String8         mRegistrationId;
78275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent};
79275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
80275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent}; // namespace android
81275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent
82275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#endif  // ANDROID_AUDIO_POLICY_H
83