• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 SurroundIO
3  *   Author: Martin Kelly <martin@surround.io>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 package org.freedesktop.gstreamer.androidmedia;
22 
23 import android.hardware.Sensor;
24 import android.hardware.SensorEvent;
25 import android.hardware.SensorEventListener;
26 
27 public class GstAhsCallback implements SensorEventListener {
28     public long mUserData;
29     public long mSensorCallback;
30     public long mAccuracyCallback;
31 
gst_ah_sensor_on_sensor_changed(SensorEvent event, long callback, long user_data)32     public static native void gst_ah_sensor_on_sensor_changed(SensorEvent event,
33                                                               long callback, long user_data);
gst_ah_sensor_on_accuracy_changed(Sensor sensor, int accuracy, long callback, long user_data)34     public static native void gst_ah_sensor_on_accuracy_changed(Sensor sensor, int accuracy,
35                                                                 long callback, long user_data);
36 
GstAhsCallback(long sensor_callback, long accuracy_callback, long user_data)37     public GstAhsCallback(long sensor_callback,
38         long accuracy_callback, long user_data) {
39         mSensorCallback = sensor_callback;
40         mAccuracyCallback = accuracy_callback;
41         mUserData = user_data;
42     }
43 
44     @Override
onSensorChanged(SensorEvent event)45     public void onSensorChanged(SensorEvent event) {
46       gst_ah_sensor_on_sensor_changed(event, mSensorCallback, mUserData);
47     }
48 
49     @Override
onAccuracyChanged(Sensor sensor, int accuracy)50     public void onAccuracyChanged(Sensor sensor, int accuracy) {
51       gst_ah_sensor_on_accuracy_changed(sensor, accuracy,
52           mAccuracyCallback, mUserData);
53     }
54 }
55