blob: 23e1cb4741685885a80c68c5ba30761930ddcb4c [file] [log] [blame]
Marco Nelissen92672802019-10-22 13:44:43 -07001/*
2 * Copyright (C) 2016 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#ifndef ANDROID_MEDIA_MIDI_DEVICE_INFO_H
18#define ANDROID_MEDIA_MIDI_DEVICE_INFO_H
19
20#include <binder/Parcelable.h>
21#include <binder/PersistableBundle.h>
22#include <utils/String16.h>
23#include <utils/Vector.h>
24
25namespace android {
26namespace media {
27namespace midi {
28
29class MidiDeviceInfo : public Parcelable {
30public:
31 MidiDeviceInfo() = default;
32 virtual ~MidiDeviceInfo() = default;
33 MidiDeviceInfo(const MidiDeviceInfo& midiDeviceInfo) = default;
34
35 status_t writeToParcel(Parcel* parcel) const override;
36 status_t readFromParcel(const Parcel* parcel) override;
37
38 int getType() const { return mType; }
39 int getUid() const { return mId; }
40 bool isPrivate() const { return mIsPrivate; }
Robert Wua936a252021-12-22 19:47:20 +000041 int getDefaultProtocol() const { return mDefaultProtocol; }
Marco Nelissen92672802019-10-22 13:44:43 -070042 const Vector<String16>& getInputPortNames() const { return mInputPortNames; }
43 const Vector<String16>& getOutputPortNames() const { return mOutputPortNames; }
44 String16 getProperty(const char* propertyName);
45
46 // The constants need to be kept in sync with MidiDeviceInfo.java
47 enum {
48 TYPE_USB = 1,
49 TYPE_VIRTUAL = 2,
50 TYPE_BLUETOOTH = 3,
51 };
Robert Wua936a252021-12-22 19:47:20 +000052
53 enum {
54 PROTOCOL_UMP_USE_MIDI_CI = 0,
55 PROTOCOL_UMP_MIDI_1_0_UP_TO_64_BITS = 1,
56 PROTOCOL_UMP_MIDI_1_0_UP_TO_64_BITS_AND_JRTS = 2,
57 PROTOCOL_UMP_MIDI_1_0_UP_TO_128_BITS = 3,
58 PROTOCOL_UMP_MIDI_1_0_UP_TO_128_BITS_AND_JRTS = 4,
59 PROTOCOL_UMP_MIDI_2_0 = 17,
60 PROTOCOL_UMP_MIDI_2_0_AND_JRTS = 18,
61 PROTOCOL_UNKNOWN = -1,
62 };
63
Marco Nelissen92672802019-10-22 13:44:43 -070064 static const char* const PROPERTY_NAME;
65 static const char* const PROPERTY_MANUFACTURER;
66 static const char* const PROPERTY_PRODUCT;
67 static const char* const PROPERTY_VERSION;
68 static const char* const PROPERTY_SERIAL_NUMBER;
69 static const char* const PROPERTY_ALSA_CARD;
70 static const char* const PROPERTY_ALSA_DEVICE;
71
72 friend bool operator==(const MidiDeviceInfo& lhs, const MidiDeviceInfo& rhs);
73 friend bool operator!=(const MidiDeviceInfo& lhs, const MidiDeviceInfo& rhs) {
74 return !(lhs == rhs);
75 }
76
77private:
78 status_t readStringVector(
79 const Parcel* parcel, Vector<String16> *vectorPtr, size_t defaultLength);
80 status_t writeStringVector(Parcel* parcel, const Vector<String16>& vector) const;
81
82 int32_t mType;
83 int32_t mId;
84 Vector<String16> mInputPortNames;
85 Vector<String16> mOutputPortNames;
86 os::PersistableBundle mProperties;
87 bool mIsPrivate;
Robert Wua936a252021-12-22 19:47:20 +000088 int32_t mDefaultProtocol;
Marco Nelissen92672802019-10-22 13:44:43 -070089};
90
91} // namespace midi
92} // namespace media
93} // namespace android
94
95#endif // ANDROID_MEDIA_MIDI_DEVICE_INFO_H