OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ | 5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ |
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ | 6 #define MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/basictypes.h" | |
14 #include "base/callback.h" | 13 #include "base/callback.h" |
15 #include "media/midi/usb_midi_device.h" | 14 #include "media/midi/usb_midi_device.h" |
16 #include "media/midi/usb_midi_export.h" | 15 #include "media/midi/usb_midi_export.h" |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 namespace midi { | 18 namespace midi { |
20 | 19 |
21 class USB_MIDI_EXPORT UsbMidiDeviceAndroid : public UsbMidiDevice { | 20 class USB_MIDI_EXPORT UsbMidiDeviceAndroid : public UsbMidiDevice { |
22 public: | 21 public: |
23 static scoped_ptr<Factory> CreateFactory(); | 22 static scoped_ptr<Factory> CreateFactory(); |
24 | 23 |
25 UsbMidiDeviceAndroid(const base::android::JavaRef<jobject>& raw_device, | 24 UsbMidiDeviceAndroid(const base::android::JavaRef<jobject>& raw_device, |
26 UsbMidiDeviceDelegate* delegate); | 25 UsbMidiDeviceDelegate* delegate); |
27 ~UsbMidiDeviceAndroid() override; | 26 ~UsbMidiDeviceAndroid() override; |
28 | 27 |
29 // UsbMidiDevice implementation. | 28 // UsbMidiDevice implementation. |
30 std::vector<uint8> GetDescriptors() override; | 29 std::vector<uint8_t> GetDescriptors() override; |
31 std::string GetManufacturer() override; | 30 std::string GetManufacturer() override; |
32 std::string GetProductName() override; | 31 std::string GetProductName() override; |
33 std::string GetDeviceVersion() override; | 32 std::string GetDeviceVersion() override; |
34 void Send(int endpoint_number, const std::vector<uint8>& data) override; | 33 void Send(int endpoint_number, const std::vector<uint8_t>& data) override; |
35 | 34 |
36 // Called by the Java world. | 35 // Called by the Java world. |
37 void OnData(JNIEnv* env, | 36 void OnData(JNIEnv* env, |
38 const base::android::JavaParamRef<jobject>& caller, | 37 const base::android::JavaParamRef<jobject>& caller, |
39 jint endpoint_number, | 38 jint endpoint_number, |
40 const base::android::JavaParamRef<jbyteArray>& data); | 39 const base::android::JavaParamRef<jbyteArray>& data); |
41 | 40 |
42 static bool RegisterUsbMidiDevice(JNIEnv* env); | 41 static bool RegisterUsbMidiDevice(JNIEnv* env); |
43 | 42 |
44 private: | 43 private: |
45 void GetDescriptorsInternal(); | 44 void GetDescriptorsInternal(); |
46 void InitDeviceInfo(); | 45 void InitDeviceInfo(); |
47 std::vector<uint8> GetStringDescriptor(int index); | 46 std::vector<uint8_t> GetStringDescriptor(int index); |
48 std::string GetString(int index, const std::string& backup); | 47 std::string GetString(int index, const std::string& backup); |
49 | 48 |
50 // The actual device object. | 49 // The actual device object. |
51 base::android::ScopedJavaGlobalRef<jobject> raw_device_; | 50 base::android::ScopedJavaGlobalRef<jobject> raw_device_; |
52 UsbMidiDeviceDelegate* delegate_; | 51 UsbMidiDeviceDelegate* delegate_; |
53 | 52 |
54 std::vector<uint8> descriptors_; | 53 std::vector<uint8_t> descriptors_; |
55 std::string manufacturer_; | 54 std::string manufacturer_; |
56 std::string product_; | 55 std::string product_; |
57 std::string device_version_; | 56 std::string device_version_; |
58 | 57 |
59 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid); | 58 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid); |
60 }; | 59 }; |
61 | 60 |
62 } // namespace midi | 61 } // namespace midi |
63 } // namespace media | 62 } // namespace media |
64 | 63 |
65 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ | 64 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_ |
OLD | NEW |