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/base/media_export.h"
16 #include "media/midi/usb_midi_device.h"
20 class MEDIA_EXPORT UsbMidiDeviceAndroid
: public UsbMidiDevice
{
22 typedef base::android::ScopedJavaLocalRef
<jobject
> ObjectRef
;
24 static scoped_ptr
<Factory
> CreateFactory();
26 UsbMidiDeviceAndroid(ObjectRef raw_device
, UsbMidiDeviceDelegate
* delegate
);
27 ~UsbMidiDeviceAndroid() override
;
29 // UsbMidiDevice implementation.
30 std::vector
<uint8
> GetDescriptors() override
;
31 std::string
GetManufacturer() override
;
32 std::string
GetProductName() override
;
33 std::string
GetDeviceVersion() override
;
34 void Send(int endpoint_number
, const std::vector
<uint8
>& data
) override
;
36 // Called by the Java world.
37 void OnData(JNIEnv
* env
,
42 static bool RegisterUsbMidiDevice(JNIEnv
* env
);
45 void GetDescriptorsInternal();
46 void InitDeviceInfo();
47 std::vector
<uint8
> GetStringDescriptor(int index
);
48 std::string
GetString(int index
, const std::string
& backup
);
50 // The actual device object.
51 base::android::ScopedJavaGlobalRef
<jobject
> raw_device_
;
52 UsbMidiDeviceDelegate
* delegate_
;
54 std::vector
<uint8
> descriptors_
;
55 std::string manufacturer_
;
57 std::string device_version_
;
59 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid
);
64 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_