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
3 // found in the LICENSE file.
5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/callback.h"
15 #include "media/midi/usb_midi_device.h"
16 #include "media/midi/usb_midi_export.h"
21 class USB_MIDI_EXPORT UsbMidiDeviceAndroid
: public UsbMidiDevice
{
23 typedef base::android::ScopedJavaLocalRef
<jobject
> ObjectRef
;
25 static scoped_ptr
<Factory
> CreateFactory();
27 UsbMidiDeviceAndroid(ObjectRef raw_device
, UsbMidiDeviceDelegate
* delegate
);
28 ~UsbMidiDeviceAndroid() override
;
30 // UsbMidiDevice implementation.
31 std::vector
<uint8
> GetDescriptors() override
;
32 std::string
GetManufacturer() override
;
33 std::string
GetProductName() override
;
34 std::string
GetDeviceVersion() override
;
35 void Send(int endpoint_number
, const std::vector
<uint8
>& data
) override
;
37 // Called by the Java world.
38 void OnData(JNIEnv
* env
,
43 static bool RegisterUsbMidiDevice(JNIEnv
* env
);
46 void GetDescriptorsInternal();
47 void InitDeviceInfo();
48 std::vector
<uint8
> GetStringDescriptor(int index
);
49 std::string
GetString(int index
, const std::string
& backup
);
51 // The actual device object.
52 base::android::ScopedJavaGlobalRef
<jobject
> raw_device_
;
53 UsbMidiDeviceDelegate
* delegate_
;
55 std::vector
<uint8
> descriptors_
;
56 std::string manufacturer_
;
58 std::string device_version_
;
60 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid
);
66 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_