소스 검색

camera: Rewrote Android support.

This does something a little weird, in that it doesn't care what
`__ANDROID_API__` is set to, but will attempt to dlopen the system
libraries, like we do for many other platform-specific pieces of SDL.

This allows us to a) not bump the minimum required Android version, which is
extremely ancient but otherwise still working, doing the right thing on old
and new hardware in the field, and b) not require the app to link against
more libraries than it previously did before the feature was available.

The downside is that it's a little messy, but it's okay for now, I think.
Ryan C. Gordon 1 년 전
부모
커밋
2613e3da24
5개의 변경된 파일665개의 추가작업 그리고 476개의 파일을 삭제
  1. 3 0
      Android.mk
  2. 7 0
      android-project/app/src/main/AndroidManifest.xml
  3. 1 0
      include/build_config/SDL_build_config_android.h
  4. 4 6
      src/camera/SDL_syscamera.h
  5. 650 470
      src/camera/android/SDL_camera_android.c

+ 3 - 0
Android.mk

@@ -24,6 +24,9 @@ LOCAL_SRC_FILES := \
 	$(wildcard $(LOCAL_PATH)/src/audio/openslES/*.c) \
 	$(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \
 	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
+	$(wildcard $(LOCAL_PATH)/src/camera/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/camera/android/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/camera/dummy/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/core/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \

+ 7 - 0
android-project/app/src/main/AndroidManifest.xml

@@ -37,6 +37,13 @@
         android:name="android.hardware.microphone"
         android:required="false" /> -->
 
+    <!-- Camera support -->
+    <!-- if you want to record video, uncomment this. -->
+    <!--
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-feature android:name="android.hardware.camera" />
+    -->
+
     <!-- Allow downloading to the external storage on Android 5.1 and older -->
     <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
 

+ 1 - 0
include/build_config/SDL_build_config_android.h

@@ -192,5 +192,6 @@
 
 /* Enable the camera driver */
 #define SDL_CAMERA_DRIVER_ANDROID 1
+#define SDL_CAMERA_DRIVER_DUMMY 1
 
 #endif /* SDL_build_config_android_h_ */

+ 4 - 6
src/camera/SDL_syscamera.h

@@ -27,12 +27,6 @@
 
 #define DEBUG_CAMERA 0
 
-
-// !!! FIXME: update this driver!
-#ifdef SDL_CAMERA_DRIVER_ANDROID
-#undef SDL_CAMERA_DRIVER_ANDROID
-#endif
-
 typedef struct SDL_CameraDevice SDL_CameraDevice;
 
 /* Backends should call this as devices are added to the system (such as
@@ -53,6 +47,10 @@ extern void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool
 // Backends can call this to get a standardized name for a thread to power a specific camera device.
 extern char *SDL_GetCameraThreadName(SDL_CameraDevice *device, char *buf, size_t buflen);
 
+// Backends can call these to change a device's refcount.
+extern void RefPhysicalCameraDevice(SDL_CameraDevice *device);
+extern void UnrefPhysicalCameraDevice(SDL_CameraDevice *device);
+
 // These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread.
 extern void SDL_CameraThreadSetup(SDL_CameraDevice *device);
 extern SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 650 - 470
src/camera/android/SDL_camera_android.c


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.