1 // Copyright 2016 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 
16 // Internal class to represent BAudioDeviceInfo.
17 
18 #ifndef BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_DEVICE_INFO_INTERNAL_H_
19 #define BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_DEVICE_INFO_INTERNAL_H_
20 
21 #include <vector>
22 
23 #include <gtest/gtest_prod.h>
24 #include <hardware/audio_policy.h>
25 
26 #include "include/brillo_audio_device_info.h"
27 
28 namespace brillo {
29 
30 class BAudioDeviceInfoInternal {
31  public:
32   // Constructor for BAudioDeviceInfoInternal.
33   //
34   // |device_id| is an integer representing an audio device type as defined in
35   // brillo_audio_device_info.h.
36   explicit BAudioDeviceInfoInternal(int device_id);
37 
38   // Get audio policy config.
39   //
40   // Returns an audio_policy_forced_cfg_t.
41   audio_policy_forced_cfg_t GetConfig();
42 
43   // Create a BAudioDeviceInfoInternal object from a audio_devices_t device
44   // type.
45   //
46   // |devices_t| is an audio device of type audio_devices_t which is represented
47   // using an int.
48   //
49   // Returns a pointer to a BAudioDeviceInfoInternal that has been created.
50   static BAudioDeviceInfoInternal* CreateFromAudioDevicesT(unsigned int device);
51 
52   // Get the device id.
53   //
54   // Returns an int which is the device_id.
55   int GetDeviceId();
56 
57   // Get audio_devices_t that corresponds to device_id;
58   //
59   // Returns an audio_devices_t.
60   audio_devices_t GetAudioDevicesT();
61 
62  private:
63   FRIEND_TEST(BrilloAudioDeviceInfoInternalTest, InWiredHeadset);
64   FRIEND_TEST(BrilloAudioDeviceInfoInternalTest, OutWiredHeadset);
65   FRIEND_TEST(BrilloAudioDeviceInfoInternalTest, OutWiredHeadphone);
66 
67   // An int representing the underlying audio device. The int is one of the
68   // constants defined in brillo_audio_device_info.h.
69   int device_id_;
70 };
71 
72 }  // namespace brillo
73 
74 #endif  // BRILLO_AUDIO_AUDIOSERVICE_BRILLO_AUDIO_DEVICE_INFO_INTERNAL_H_
75