Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ task clean(type: Delete) {
}

ext {
supportLibVersion = '27.1.1' // variable that can be referenced to keep support libs consistent
supportLibVersion = '27.0.1' // variable that can be referenced to keep support libs consistent
commonLibVersion= '2.12.4'
versionBuildTool = '27.0.3'
versionCompiler = 27
versionTarget = 27
versionCompiler = 26
versionTarget = 26
versionNameString = '1.0.0'
javaSourceCompatibility = JavaVersion.VERSION_1_8
javaTargetCompatibility = JavaVersion.VERSION_1_8
Expand Down
12 changes: 8 additions & 4 deletions libuvccamera/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion versionTarget
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
debuggable = true
}
debug {
jniDebuggable = true
}
}
sourceSets {
Expand Down Expand Up @@ -88,7 +92,7 @@ dependencies {

implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.android.support:support-annotations:${supportLibVersion}"

implementation "com.android.support:appcompat-v7:27.0.0"
implementation("com.serenegiant:common:${commonLibVersion}") {
exclude module: 'support-v4'
}
Expand Down
23 changes: 23 additions & 0 deletions libuvccamera/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepclassmembers class com.serenegiant.usb.* { *; }
-keep class com.serenegiant.usb.* { *; }
-keep public interface com.serenegiant.usb.*
2 changes: 1 addition & 1 deletion libuvccamera/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package="com.serenegiant.uvccamera"
android:versionCode="2"
android:versionName="1.1" >

<uses-feature android:name="android.hardware.usb.host" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void onCancel(final DialogInterface dialog) {
public void updateDevices() {
// mUSBMonitor.dumpDevices();
final List<DeviceFilter> filter = DeviceFilter.getDeviceFilters(getActivity(), R.xml.device_filter);
mDeviceListAdapter = new DeviceListAdapter(getActivity(), mUSBMonitor.getDeviceList(filter.get(0)));
mDeviceListAdapter = new DeviceListAdapter(getActivity(), mUSBMonitor.getDeviceList(filter));
mSpinner.setAdapter(mDeviceListAdapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

public final class USBMonitor {

private static final boolean DEBUG = false; // TODO set false on production
private static final boolean DEBUG = true; // TODO set false on production
private static final String TAG = "USBMonitor";

private static final String ACTION_USB_PERMISSION_BASE = "com.serenegiant.USB_PERMISSION.";
Expand Down Expand Up @@ -982,6 +982,8 @@ private UsbControlBlock(final USBMonitor monitor, final UsbDevice device) {
}
mBusNum = busnum;
mDevNum = devnum;

try {
// if (DEBUG) {
if (mConnection != null) {
final int desc = mConnection.getFileDescriptor();
Expand All @@ -991,6 +993,9 @@ private UsbControlBlock(final USBMonitor monitor, final UsbDevice device) {
Log.e(TAG, "could not connect to device " + name);
}
// }
} catch (Throwable e){
Log.e(TAG, "UsbControlBlock Throwable:" + e.toString());
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion libuvccamera/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#NDK_TOOLCHAIN_VERSION := 4.9

APP_PLATFORM := android-14
APP_ABI := armeabi armeabi-v7a x86 mips
APP_ABI := arm64-v8a armeabi-v7a
#APP_OPTIM := debug
APP_OPTIM := release

12 changes: 8 additions & 4 deletions libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ int UVCPreview::startPreview() {
mIsRunning = true;
pthread_mutex_lock(&preview_mutex);
{
if (LIKELY(mPreviewWindow)) {
// if (LIKELY(mPreviewWindow)) {
result = pthread_create(&preview_thread, NULL, preview_thread_func, (void *)this);
}
// }
}
pthread_mutex_unlock(&preview_mutex);
if (UNLIKELY(result != EXIT_SUCCESS)) {
Expand Down Expand Up @@ -533,7 +533,9 @@ void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) {
result = uvc_mjpeg2yuyv(frame_mjpeg, frame); // MJPEG => yuyv
recycle_frame(frame_mjpeg);
if (LIKELY(!result)) {
frame = draw_preview_one(frame, &mPreviewWindow, uvc_any2rgbx, 4);
if (mPreviewWindow) {
frame = draw_preview_one(frame, &mPreviewWindow, uvc_any2rgbx, 4);
}
addCaptureFrame(frame);
} else {
recycle_frame(frame);
Expand All @@ -545,7 +547,9 @@ void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) {
for ( ; LIKELY(isRunning()) ; ) {
frame = waitPreviewFrame();
if (LIKELY(frame)) {
frame = draw_preview_one(frame, &mPreviewWindow, uvc_any2rgbx, 4);
if (mPreviewWindow) {
frame = draw_preview_one(frame, &mPreviewWindow, uvc_any2rgbx, 4);
}
addCaptureFrame(frame);
}
}
Expand Down
14 changes: 13 additions & 1 deletion libuvccamera/src/main/jni/libusb/libusb/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define LOCAL_DEBUG 0

#if 0 // デバッグ情報を出さない時1
#ifndef LOG_NDEBUG
#define LOG_NDEBUG // LOGV/LOGD/MARKを出力しない時
#endif
#undef USE_LOGALL // 指定したLOGxだけを出力
#else
#define USE_LOGALL
#undef LOG_NDEBUG
#undef NDEBUG
#define GET_RAW_DESCRIPTOR
#endif

#include <errno.h>
#include <stdint.h>
Expand Down Expand Up @@ -293,7 +306,6 @@ static int parse_interface(libusb_context *ctx,
size -= ifp->bLength;

begin = buffer;

/* Skip over any interface, class or vendor descriptors */
while (size >= LIBUSB_DT_HEADER_SIZE/*DESC_HEADER_LENGTH*/) {
usbi_parse_descriptor(buffer, "bb", &header, 0);
Expand Down
3 changes: 3 additions & 0 deletions libuvccamera/src/main/jni/libusb/libusb/os/android_usbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,9 @@ static int handle_iso_completion(struct libusb_device_handle *handle, // XXX add

usbi_mutex_lock(&itransfer->lock);
for (i = 0; i < num_urbs; i++) {
if (tpriv->iso_urbs == NULL) {
break;
}
if (urb == tpriv->iso_urbs[i]) {
urb_idx = i + 1;
break;
Expand Down
2 changes: 1 addition & 1 deletion libuvccamera/src/main/jni/utilbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
#endif

#define ENTER() LOGD("begin")
#define RETURN(code,type) {type RESULT = code; LOGD("end (%d)", (int)RESULT); return RESULT;}
#define RETURN(code,type) {type RESULT = code; LOGD("end (%d)", (long)RESULT); return RESULT;}
#define RET(code) {LOGD("end"); return code;}
#define EXIT() {LOGD("end"); return;}
#define PRE_EXIT() LOGD("end")
Expand Down
1 change: 1 addition & 0 deletions libuvccamera/src/main/res/xml/device_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@

<usb>
<usb-device class="239" subclass="2" /> <!-- all device of UVC -->
<usb-device class="14" subclass="2" />
</usb>
10 changes: 7 additions & 3 deletions usbCameraCommon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,25 @@ android {
}

defaultConfig {
minSdkVersion 18
minSdkVersion 14
targetSdkVersion versionTarget

}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable = true
}
debug {
jniDebuggable = true
}
}
}

dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.android.support:support-annotations:${supportLibVersion}"

Expand Down
7 changes: 5 additions & 2 deletions usbCameraTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@ android {
targetSdkVersion versionTarget
versionCode 8
versionName "3.00"
}
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debuggable = true
signingConfig signingConfigs.debug
}
}
}

dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.android.support:support-annotations:${supportLibVersion}"

Expand Down
11 changes: 6 additions & 5 deletions usbCameraTest/proguard-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepclassmembers public class com.serenegiant.usb.UVCCamera {
public *;
protected *;
private *;
}
-keepclassmembers class com.serenegiant.usb.UVCCamera { *; }
-keep class com.serenegiant.usb.UVCCamera { *; }
-keep public interface com.serenegiant.usb.IStatusCallback
-keep public interface com.serenegiant.usb.IFrameCallback
-keep public interface com.serenegiant.usb.IButtonCallback

4 changes: 2 additions & 2 deletions usbCameraTest/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.serenegiant.usbcameratest" >

<uses-feature android:name="android.hardware.usb.host" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
Expand All @@ -36,7 +36,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity>
</application>

</manifest>
3 changes: 1 addition & 2 deletions usbCameraTest/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
android:id="@+id/UVCCameraTextureView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#ff000000" />
android:layout_gravity="center" />

<ImageButton
android:id="@+id/camera_button"
Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest/src/main/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest/src/main/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<style name="AppBaseTheme" parent="Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
Expand Down
1 change: 1 addition & 0 deletions usbCameraTest/src/main/res/xml/device_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@

<usb>
<usb-device class="239" subclass="2" /> <!-- all device of UVC -->
<usb-device class="14" subclass="2" />
<usb-device vendor-id="0x1b80" />
</usb>
2 changes: 1 addition & 1 deletion usbCameraTest0/src/main/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest0/src/main/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

Expand Down
1 change: 1 addition & 0 deletions usbCameraTest2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:support-v4:${supportLibVersion}"
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:support-annotations:${supportLibVersion}"

implementation("com.serenegiant:common:${commonLibVersion}") {
Expand Down
3 changes: 1 addition & 2 deletions usbCameraTest2/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="#ff000000" />
android:layout_gravity="center" />

<ImageView
android:id="@+id/imageView1"
Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest2/src/main/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion usbCameraTest2/src/main/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

Expand Down
Loading