• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
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 
17 
18 #pragma once
19 
20 #include <android/media/AudioProductStrategy.h>
21 #include <media/AidlConversionUtil.h>
22 #include <media/AudioCommonTypes.h>
23 #include <media/AudioAttributes.h>
24 #include <system/audio.h>
25 #include <system/audio_policy.h>
26 #include <binder/Parcelable.h>
27 
28 namespace android {
29 
30 class AudioProductStrategy : public Parcelable
31 {
32 public:
AudioProductStrategy()33     AudioProductStrategy() {}
AudioProductStrategy(const std::string & name,const std::vector<AudioAttributes> & attributes,product_strategy_t id)34     AudioProductStrategy(const std::string &name, const std::vector<AudioAttributes> &attributes,
35                          product_strategy_t id) :
36         mName(name), mAudioAttributes(attributes), mId(id) {}
37 
getName()38     const std::string &getName() const { return mName; }
getAudioAttributes()39     std::vector<AudioAttributes> getAudioAttributes() const { return mAudioAttributes; }
getId()40     product_strategy_t getId() const { return mId; }
41 
42     status_t readFromParcel(const Parcel *parcel) override;
43     status_t writeToParcel(Parcel *parcel) const override;
44 
45     /**
46      * @brief attributesMatches: checks if client attributes matches with a reference attributes
47      * "matching" means the usage shall match if reference attributes has a defined usage, AND
48      * content type shall match if reference attributes has a defined content type AND
49      * flags shall match if reference attributes has defined flags AND
50      * tags shall match if reference attributes has defined tags.
51      * Reference attributes "default" shall not be considered as a "true" case. This convention
52      * is used to identify the default strategy.
53      * @param refAttributes to be considered
54      * @param clientAttritubes to be considered
55      * @return true if matching, false otherwise
56      */
57     static bool attributesMatches(const audio_attributes_t refAttributes,
58                                   const audio_attributes_t clientAttritubes);
59 private:
60     std::string mName;
61     std::vector<AudioAttributes> mAudioAttributes;
62     product_strategy_t mId;
63 };
64 
65 using AudioProductStrategyVector = std::vector<AudioProductStrategy>;
66 
67 // AIDL conversion routines.
68 ConversionResult<media::AudioProductStrategy>
69 legacy2aidl_AudioProductStrategy(const AudioProductStrategy& legacy);
70 ConversionResult<AudioProductStrategy>
71 aidl2legacy_AudioProductStrategy(const media::AudioProductStrategy& aidl);
72 
73 } // namespace android
74 
75