yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef MEDIA_MIDI_MIDI_DEVICE_ANDROID_H_ |
| 6 | #define MEDIA_MIDI_MIDI_DEVICE_ANDROID_H_ |
| 7 | |
| 8 | #include <jni.h> |
xiaofeng.zhang | 06152d8 | 2017-05-21 04:39:34 -0700 | [diff] [blame] | 9 | #include <memory> |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 10 | #include <string> |
xiaofeng.zhang | 06152d8 | 2017-05-21 04:39:34 -0700 | [diff] [blame] | 11 | #include <vector> |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 12 | |
| 13 | #include "base/android/scoped_java_ref.h" |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 14 | #include "media/midi/midi_input_port_android.h" |
| 15 | |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 16 | namespace midi { |
| 17 | |
| 18 | class MidiOutputPortAndroid; |
| 19 | |
| 20 | class MidiDeviceAndroid final { |
| 21 | public: |
| 22 | MidiDeviceAndroid(JNIEnv* env, |
Torne (Richard Coles) | 7527ac6 | 2017-07-31 21:17:01 +0000 | [diff] [blame] | 23 | const base::android::JavaRef<jobject>& raw_device, |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 24 | MidiInputPortAndroid::Delegate* delegate); |
| 25 | ~MidiDeviceAndroid(); |
| 26 | |
| 27 | std::string GetManufacturer(); |
| 28 | std::string GetProductName(); |
| 29 | std::string GetDeviceVersion(); |
| 30 | |
xiaofeng.zhang | 06152d8 | 2017-05-21 04:39:34 -0700 | [diff] [blame] | 31 | const std::vector<std::unique_ptr<MidiInputPortAndroid>>& input_ports() |
| 32 | const { |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 33 | return input_ports_; |
| 34 | } |
xiaofeng.zhang | 06152d8 | 2017-05-21 04:39:34 -0700 | [diff] [blame] | 35 | const std::vector<std::unique_ptr<MidiOutputPortAndroid>>& output_ports() |
| 36 | const { |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 37 | return output_ports_; |
| 38 | } |
| 39 | bool HasRawDevice(JNIEnv* env, jobject raw_device) const { |
| 40 | return env->IsSameObject(raw_device_.obj(), raw_device); |
| 41 | } |
| 42 | |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 43 | private: |
| 44 | base::android::ScopedJavaGlobalRef<jobject> raw_device_; |
xiaofeng.zhang | 06152d8 | 2017-05-21 04:39:34 -0700 | [diff] [blame] | 45 | std::vector<std::unique_ptr<MidiInputPortAndroid>> input_ports_; |
| 46 | std::vector<std::unique_ptr<MidiOutputPortAndroid>> output_ports_; |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace midi |
yhirano | bc742d8 | 2015-09-17 07:41:44 -0700 | [diff] [blame] | 50 | |
| 51 | #endif // MEDIA_MIDI_MIDI_DEVICE_ANDROID_H_ |