1 /*
2  * Copyright (C) 2019 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 #pragma once
18 
19 #include <string>
20 #include <vector>
21 
22 #include <binder/Parcelable.h>
23 #include <binder/Parcel.h>
24 #include <media/AudioContainers.h>
25 #include <system/audio.h>
26 #include <utils/Errors.h>
27 
28 namespace android {
29 
30 struct AudioDeviceTypeAddr : public Parcelable {
31     AudioDeviceTypeAddr() = default;
32 
AudioDeviceTypeAddrAudioDeviceTypeAddr33     AudioDeviceTypeAddr(audio_devices_t type, const std::string& address) :
34             mType(type), mAddress(address) {}
35 
36     const char* getAddress() const;
37 
38     bool equals(const AudioDeviceTypeAddr& other) const;
39 
40     AudioDeviceTypeAddr& operator= (const AudioDeviceTypeAddr&) = default;
41 
42     bool operator<(const AudioDeviceTypeAddr& other) const;
43 
44     void reset();
45 
46     status_t readFromParcel(const Parcel *parcel) override;
47 
48     status_t writeToParcel(Parcel *parcel) const override;
49 
50     audio_devices_t mType = AUDIO_DEVICE_NONE;
51     std::string mAddress;
52 };
53 
54 using AudioDeviceTypeAddrVector = std::vector<AudioDeviceTypeAddr>;
55 
56 /**
57  * Return a collection of audio device types from a collection of AudioDeviceTypeAddr
58  */
59 DeviceTypeSet getAudioDeviceTypes(const AudioDeviceTypeAddrVector& deviceTypeAddrs);
60 
61 }
62