| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_MIDI_INPUT_PORT_ANDROID_H_ | 5 #ifndef MEDIA_MIDI_MIDI_INPUT_PORT_ANDROID_H_ |
| 6 #define MEDIA_MIDI_MIDI_INPUT_PORT_ANDROID_H_ | 6 #define MEDIA_MIDI_MIDI_INPUT_PORT_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 namespace midi { | 14 namespace midi { |
| 15 | 15 |
| 16 class MidiInputPortAndroid final { | 16 class MidiInputPortAndroid final { |
| 17 public: | 17 public: |
| 18 class Delegate { | 18 class Delegate { |
| 19 public: | 19 public: |
| 20 virtual ~Delegate() {} | 20 virtual ~Delegate() {} |
| 21 virtual void OnReceivedData(MidiInputPortAndroid* port, | 21 virtual void OnReceivedData(MidiInputPortAndroid* port, |
| 22 const uint8* data, | 22 const uint8_t* data, |
| 23 size_t size, | 23 size_t size, |
| 24 base::TimeTicks time) = 0; | 24 base::TimeTicks time) = 0; |
| 25 }; | 25 }; |
| 26 MidiInputPortAndroid(JNIEnv* env, jobject raw, Delegate* delegate); | 26 MidiInputPortAndroid(JNIEnv* env, jobject raw, Delegate* delegate); |
| 27 ~MidiInputPortAndroid(); | 27 ~MidiInputPortAndroid(); |
| 28 | 28 |
| 29 // Returns true when the operation succeeds. | 29 // Returns true when the operation succeeds. |
| 30 bool Open(); | 30 bool Open(); |
| 31 void Close(); | 31 void Close(); |
| 32 | 32 |
| 33 // Called by the Java world. | 33 // Called by the Java world. |
| 34 void OnData(JNIEnv* env, | 34 void OnData(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& caller, | 35 const base::android::JavaParamRef<jobject>& caller, |
| 36 const base::android::JavaParamRef<jbyteArray>& data, | 36 const base::android::JavaParamRef<jbyteArray>& data, |
| 37 jint offset, | 37 jint offset, |
| 38 jint size, | 38 jint size, |
| 39 jlong timestamp); | 39 jlong timestamp); |
| 40 | 40 |
| 41 static bool Register(JNIEnv* env); | 41 static bool Register(JNIEnv* env); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 base::android::ScopedJavaGlobalRef<jobject> raw_port_; | 44 base::android::ScopedJavaGlobalRef<jobject> raw_port_; |
| 45 Delegate* const delegate_; | 45 Delegate* const delegate_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // namespace midi | 48 } // namespace midi |
| 49 } // namespace media | 49 } // namespace media |
| 50 | 50 |
| 51 #endif // MEDIA_MIDI_MIDI_INPUT_PORT_ANDROID_H_ | 51 #endif // MEDIA_MIDI_MIDI_INPUT_PORT_ANDROID_H_ |
| OLD | NEW |