Browse Source

支持单独推流和边推边录制

main 2.1.4
jiangdongguo 7 years ago
parent
commit
57765b6765
  1. 1
      .gradle/2.14.1/taskArtifacts/cache.properties
  2. BIN
      .gradle/2.14.1/taskArtifacts/cache.properties.lock
  3. BIN
      .gradle/2.14.1/taskArtifacts/fileHashes.bin
  4. BIN
      .gradle/2.14.1/taskArtifacts/fileSnapshots.bin
  5. BIN
      .gradle/2.14.1/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin
  6. BIN
      .gradle/2.14.1/taskArtifacts/taskArtifacts.bin
  7. BIN
      .gradle/3.3/taskArtifacts/fileHashes.bin
  8. BIN
      .gradle/3.3/taskArtifacts/fileSnapshots.bin
  9. BIN
      .gradle/3.3/taskArtifacts/taskArtifacts.bin
  10. BIN
      .gradle/3.3/taskArtifacts/taskArtifacts.lock
  11. BIN
      .gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  12. BIN
      .gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  13. BIN
      .gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  14. BIN
      .gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  15. BIN
      .gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin
  16. BIN
      .gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock
  17. BIN
      .gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin
  18. BIN
      .gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock
  19. 71
      app/app.iml
  20. 9
      app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java
  21. 66
      libusbcamera/libusbcamera.iml
  22. 16
      libusbcamera/src/main/java/com/jiangdg/usbcamera/UVCCameraHelper.java
  23. 45
      libusbcamera/src/main/java/com/serenegiant/usb/common/AbstractUVCCameraHandler.java

1
.gradle/2.14.1/taskArtifacts/cache.properties

@ -1 +0,0 @@
#Fri Sep 29 14:50:34 CST 2017

BIN
.gradle/2.14.1/taskArtifacts/cache.properties.lock

Binary file not shown.

BIN
.gradle/2.14.1/taskArtifacts/fileHashes.bin

Binary file not shown.

BIN
.gradle/2.14.1/taskArtifacts/fileSnapshots.bin

Binary file not shown.

BIN
.gradle/2.14.1/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin

Binary file not shown.

BIN
.gradle/2.14.1/taskArtifacts/taskArtifacts.bin

Binary file not shown.

BIN
.gradle/3.3/taskArtifacts/fileHashes.bin

Binary file not shown.

BIN
.gradle/3.3/taskArtifacts/fileSnapshots.bin

Binary file not shown.

BIN
.gradle/3.3/taskArtifacts/taskArtifacts.bin

Binary file not shown.

BIN
.gradle/3.3/taskArtifacts/taskArtifacts.lock

Binary file not shown.

BIN
.gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin

Binary file not shown.

BIN
.gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock

Binary file not shown.

BIN
.gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin

Binary file not shown.

BIN
.gradle/3.3/tasks/_app_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock

Binary file not shown.

BIN
.gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin

Binary file not shown.

BIN
.gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock

Binary file not shown.

BIN
.gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin

Binary file not shown.

BIN
.gradle/3.3/tasks/_libusbcamera_compileReleaseJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock

Binary file not shown.

71
app/app.iml

@ -27,21 +27,20 @@
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" /> <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@ -49,13 +48,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
@ -88,10 +80,13 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
@ -102,33 +97,33 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:exposed-instrumentation-api-publish-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" scope="TEST" name="junit:junit:4.12@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="junit:junit:4.12@jar" level="project" />
<orderEntry type="library" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-core-ui-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-core-ui-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-compat-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-compat-25.3.1" level="project" />
<orderEntry type="library" name="com.serenegiant:common-1.5.20" level="project" /> <orderEntry type="library" exported="" name="com.serenegiant:common-1.5.20" level="project" />
<orderEntry type="library" name="com.android.support:support-core-utils-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-core-utils-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-v4-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-v4-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-fragment-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-fragment-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-media-compat-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-media-compat-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.google.code.findbugs:jsr305:2.0.1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-core:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="com.jakewharton:butterknife-8.8.1" level="project" /> <orderEntry type="library" exported="" name="com.jakewharton:butterknife-8.8.1" level="project" />
<orderEntry type="library" name="com.jakewharton:butterknife-annotations:8.8.1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test.espresso:espresso-core-2.2.2" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-core-2.2.2" level="project" /> <orderEntry type="library" exported="" name="com.jakewharton:butterknife-annotations:8.8.1@jar" level="project" />
<orderEntry type="library" name="com.android.support:animated-vector-drawable-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:animated-vector-drawable-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:rules-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:rules-0.5" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-library:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-integration:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:runner-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:runner-0.5" level="project" />
<orderEntry type="library" name="com.android.support:appcompat-v7-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:appcompat-v7-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" scope="TEST" name="javax.annotation:javax.annotation-api:1.2@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javax.annotation:javax.annotation-api:1.2@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-vector-drawable-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-vector-drawable-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:recyclerview-v7-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:recyclerview-v7-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-annotations:25.3.1@jar" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-annotations:25.3.1@jar" level="project" />
<orderEntry type="module" module-name="libusbcamera" /> <orderEntry type="module" module-name="libusbcamera" exported="" />
</component> </component>
</module> </module>

9
app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java

@ -241,14 +241,15 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog
showShortMsg("sorry,camera open failed"); showShortMsg("sorry,camera open failed");
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
if (!mCameraHelper.isRecording()) { if (!mCameraHelper.isPushing()) {
String videoPath = UVCCameraHelper.ROOT_PATH + System.currentTimeMillis(); String videoPath = UVCCameraHelper.ROOT_PATH + System.currentTimeMillis();
FileUtils.createfile(FileUtils.ROOT_PATH + "test666.h264"); FileUtils.createfile(FileUtils.ROOT_PATH + "test666.h264");
// if you want to record,please create RecordParams like this
RecordParams params = new RecordParams(); RecordParams params = new RecordParams();
params.setRecordPath(videoPath); params.setRecordPath(videoPath);
params.setRecordDuration(0); // 设置为0,不分割保存 params.setRecordDuration(0); // 设置为0,不分割保存
params.setVoiceClose(mSwitchVoice.isChecked()); // is close voice params.setVoiceClose(mSwitchVoice.isChecked()); // is close voice
mCameraHelper.startRecording(params, new AbstractUVCCameraHandler.OnEncodeResultListener() { mCameraHelper.startPusher(params, new AbstractUVCCameraHandler.OnEncodeResultListener() {
@Override @Override
public void onEncodeResult(byte[] data, int offset, int length, long timestamp, int type) { public void onEncodeResult(byte[] data, int offset, int length, long timestamp, int type) {
// type = 1,h264 video stream // type = 1,h264 video stream
@ -266,11 +267,13 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog
Log.i(TAG,"videoPath = "+videoPath); Log.i(TAG,"videoPath = "+videoPath);
} }
}); });
// if you only want to push stream,please call like this
// mCameraHelper.startPusher(listener);
showShortMsg("start record..."); showShortMsg("start record...");
mSwitchVoice.setEnabled(false); mSwitchVoice.setEnabled(false);
} else { } else {
FileUtils.releaseFile(); FileUtils.releaseFile();
mCameraHelper.stopRecording(); mCameraHelper.stopPusher();
showShortMsg("stop record..."); showShortMsg("stop record...");
mSwitchVoice.setEnabled(true); mSwitchVoice.setEnabled(true);
} }

66
libusbcamera/libusbcamera.iml

@ -28,21 +28,20 @@
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" /> <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@ -57,13 +56,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
@ -85,16 +77,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
@ -104,30 +100,30 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:exposed-instrumentation-api-publish-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" scope="TEST" name="junit:junit:4.12@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="junit:junit:4.12@jar" level="project" />
<orderEntry type="library" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-core-ui-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-core-ui-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-compat-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-compat-25.3.1" level="project" />
<orderEntry type="library" name="com.serenegiant:common-1.5.20" level="project" /> <orderEntry type="library" exported="" name="com.serenegiant:common-1.5.20" level="project" />
<orderEntry type="library" name="com.android.support:support-core-utils-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-core-utils-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-v4-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-v4-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-fragment-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-fragment-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-media-compat-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-media-compat-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.google.code.findbugs:jsr305:2.0.1@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-core:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-core-2.2.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test.espresso:espresso-core-2.2.2" level="project" />
<orderEntry type="library" name="com.android.support:animated-vector-drawable-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:animated-vector-drawable-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:rules-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:rules-0.5" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-library:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-integration:1.3@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:runner-0.5" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test:runner-0.5" level="project" />
<orderEntry type="library" name="com.android.support:appcompat-v7-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:appcompat-v7-25.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" scope="TEST" name="javax.annotation:javax.annotation-api:1.2@jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javax.annotation:javax.annotation-api:1.2@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-vector-drawable-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-vector-drawable-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:recyclerview-v7-25.3.1" level="project" /> <orderEntry type="library" exported="" name="com.android.support:recyclerview-v7-25.3.1" level="project" />
<orderEntry type="library" name="com.android.support:support-annotations:25.3.1@jar" level="project" /> <orderEntry type="library" exported="" name="com.android.support:support-annotations:25.3.1@jar" level="project" />
</component> </component>
</module> </module>

16
libusbcamera/src/main/java/com/jiangdg/usbcamera/UVCCameraHelper.java

@ -247,19 +247,25 @@ public class UVCCameraHelper {
} }
} }
public void startRecording(RecordParams params, AbstractUVCCameraHandler.OnEncodeResultListener listener) { public void startPusher(AbstractUVCCameraHandler.OnEncodeResultListener listener) {
if (mCameraHandler != null && !isRecording()) { if (mCameraHandler != null && !isPushing()) {
mCameraHandler.startRecording(null, listener);
}
}
public void startPusher(RecordParams params, AbstractUVCCameraHandler.OnEncodeResultListener listener) {
if (mCameraHandler != null && !isPushing()) {
mCameraHandler.startRecording(params, listener); mCameraHandler.startRecording(params, listener);
} }
} }
public void stopRecording() { public void stopPusher() {
if (mCameraHandler != null && isRecording()) { if (mCameraHandler != null && isPushing()) {
mCameraHandler.stopRecording(); mCameraHandler.stopRecording();
} }
} }
public boolean isRecording() { public boolean isPushing() {
if (mCameraHandler != null) { if (mCameraHandler != null) {
return mCameraHandler.isRecording(); return mCameraHandler.isRecording();
} }

45
libusbcamera/src/main/java/com/serenegiant/usb/common/AbstractUVCCameraHandler.java

@ -51,8 +51,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* Camera业务处理抽象类 * Camera业务处理抽象类
* */
* */
public abstract class AbstractUVCCameraHandler extends Handler { public abstract class AbstractUVCCameraHandler extends Handler {
private static final boolean DEBUG = true; // TODO set false on release private static final boolean DEBUG = true; // TODO set false on release
@ -62,11 +61,17 @@ public abstract class AbstractUVCCameraHandler extends Handler {
// 对外回调接口 // 对外回调接口
public interface CameraCallback { public interface CameraCallback {
public void onOpen(); public void onOpen();
public void onClose(); public void onClose();
public void onStartPreview(); public void onStartPreview();
public void onStopPreview(); public void onStopPreview();
public void onStartRecording(); public void onStartRecording();
public void onStopRecording(); public void onStopRecording();
public void onError(final Exception e); public void onError(final Exception e);
} }
@ -76,6 +81,7 @@ public abstract class AbstractUVCCameraHandler extends Handler {
public interface OnEncodeResultListener { public interface OnEncodeResultListener {
void onEncodeResult(byte[] data, int offset, int length, long timestamp, int type); void onEncodeResult(byte[] data, int offset, int length, long timestamp, int type);
void onRecordResult(String videoPath); void onRecordResult(String videoPath);
} }
@ -362,10 +368,10 @@ public abstract class AbstractUVCCameraHandler extends Handler {
break; break;
case MSG_CAPTURE_START: case MSG_CAPTURE_START:
// thread.handleStartRecording((String)msg.obj); // thread.handleStartRecording((String)msg.obj);
thread.handleStartRecording((RecordParams)msg.obj); thread.handleStartPusher((RecordParams) msg.obj);
break; break;
case MSG_CAPTURE_STOP: case MSG_CAPTURE_STOP:
thread.handleStopRecording(); thread.handleStopPusher();
break; break;
case MSG_MEDIA_UPDATE: case MSG_MEDIA_UPDATE:
thread.handleUpdateMedia((String) msg.obj); thread.handleUpdateMedia((String) msg.obj);
@ -405,11 +411,13 @@ public abstract class AbstractUVCCameraHandler extends Handler {
// private MediaMuxerWrapper mMuxer; // private MediaMuxerWrapper mMuxer;
private MediaVideoBufferEncoder mVideoEncoder; private MediaVideoBufferEncoder mVideoEncoder;
private Mp4MediaMuxer mMuxer; private Mp4MediaMuxer mMuxer;
private boolean isPushing;
private String videoPath; private String videoPath;
// private boolean isAudioThreadStart; // private boolean isAudioThreadStart;
/** 构造方法 /**
* * 构造方法
* <p>
* clazz 继承于AbstractUVCCameraHandler * clazz 继承于AbstractUVCCameraHandler
* parent Activity子类 * parent Activity子类
* cameraView 用于捕获静止图像 * cameraView 用于捕获静止图像
@ -480,7 +488,7 @@ public abstract class AbstractUVCCameraHandler extends Handler {
public boolean isRecording() { public boolean isRecording() {
synchronized (mSync) { synchronized (mSync) {
return (mUVCCamera != null) && (mMuxer != null); return (mUVCCamera != null) && (mH264Consumer != null);
} }
} }
@ -507,12 +515,13 @@ public abstract class AbstractUVCCameraHandler extends Handler {
} catch (final Exception e) { } catch (final Exception e) {
callOnError(e); callOnError(e);
} }
if (DEBUG) Log.i(TAG, "supportedSize:" + (mUVCCamera != null ? mUVCCamera.getSupportedSize() : null)); if (DEBUG)
Log.i(TAG, "supportedSize:" + (mUVCCamera != null ? mUVCCamera.getSupportedSize() : null));
} }
public void handleClose() { public void handleClose() {
if (DEBUG) Log.v(TAG_THREAD, "handleClose:"); if (DEBUG) Log.v(TAG_THREAD, "handleClose:");
handleStopRecording(); handleStopPusher();
final UVCCamera camera; final UVCCamera camera;
synchronized (mSync) { synchronized (mSync) {
camera = mUVCCamera; camera = mUVCCamera;
@ -545,7 +554,8 @@ public abstract class AbstractUVCCameraHandler extends Handler {
} }
if (surface instanceof SurfaceHolder) { if (surface instanceof SurfaceHolder) {
mUVCCamera.setPreviewDisplay((SurfaceHolder) surface); mUVCCamera.setPreviewDisplay((SurfaceHolder) surface);
} if (surface instanceof Surface) { }
if (surface instanceof Surface) {
mUVCCamera.setPreviewDisplay((Surface) surface); mUVCCamera.setPreviewDisplay((Surface) surface);
} else { } else {
mUVCCamera.setPreviewTexture((SurfaceTexture) surface); mUVCCamera.setPreviewTexture((SurfaceTexture) surface);
@ -652,18 +662,17 @@ public abstract class AbstractUVCCameraHandler extends Handler {
private AACEncodeConsumer mAacConsumer; private AACEncodeConsumer mAacConsumer;
private H264EncodeConsumer mH264Consumer; private H264EncodeConsumer mH264Consumer;
public void handleStartRecording(RecordParams params){ public void handleStartPusher(RecordParams params) {
if ((mUVCCamera == null) || (mMuxer != null)) if ((mUVCCamera == null) || (mH264Consumer != null))
return; return;
if (params == null)
throw new NullPointerException("RecordParams can not be null!");
// // 获取USB Camera预览数据 // // 获取USB Camera预览数据
// mUVCCamera.setFrameCallback(mIFrameCallback, UVCCamera.PIXEL_FORMAT_NV21); // mUVCCamera.setFrameCallback(mIFrameCallback, UVCCamera.PIXEL_FORMAT_NV21);
// 初始化混合器 // 初始化混合器
if (params != null) {
videoPath = params.getRecordPath(); videoPath = params.getRecordPath();
mMuxer = new Mp4MediaMuxer(params.getRecordPath(), mMuxer = new Mp4MediaMuxer(params.getRecordPath(),
params.getRecordDuration() * 60 * 1000, params.isVoiceClose()); params.getRecordDuration() * 60 * 1000, params.isVoiceClose());
}
// 启动视频编码线程 // 启动视频编码线程
startVideoRecord(); startVideoRecord();
// 启动音频编码线程 // 启动音频编码线程
@ -674,7 +683,7 @@ public abstract class AbstractUVCCameraHandler extends Handler {
} }
public void handleStopRecording(){ public void handleStopPusher() {
// 停止混合器 // 停止混合器
if (mMuxer != null) { if (mMuxer != null) {
mMuxer.release(); mMuxer.release();
@ -709,10 +718,12 @@ public abstract class AbstractUVCCameraHandler extends Handler {
}); });
mH264Consumer.start(); mH264Consumer.start();
// 添加混合器 // 添加混合器
if (mMuxer != null) {
if (mH264Consumer != null) { if (mH264Consumer != null) {
mH264Consumer.setTmpuMuxer(mMuxer); mH264Consumer.setTmpuMuxer(mMuxer);
} }
} }
}
private void stopVideoRecord() { private void stopVideoRecord() {
if (mH264Consumer != null) { if (mH264Consumer != null) {
@ -743,10 +754,12 @@ public abstract class AbstractUVCCameraHandler extends Handler {
}); });
mAacConsumer.start(); mAacConsumer.start();
// 添加混合器 // 添加混合器
if (mMuxer != null) {
if (mAacConsumer != null) { if (mAacConsumer != null) {
mAacConsumer.setTmpuMuxer(mMuxer); mAacConsumer.setTmpuMuxer(mMuxer);
} }
} }
}
private void stopAudioRecord() { private void stopAudioRecord() {
if (mAacConsumer != null) { if (mAacConsumer != null) {

Loading…
Cancel
Save