Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add outputstream constractor for more demand. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/checkstyle-idea.xml

This file was deleted.

22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

92 changes: 12 additions & 80 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
buildToolsVersion '25.0.3'

defaultConfig {
applicationId "com.kingbull.recorder"
Expand Down
6 changes: 3 additions & 3 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Apr 26 18:02:18 IST 2017
#ndk.dir=D\:\\Installation\\Android\\Sdk\\ndk-bundle
#Mon Jul 24 16:52:56 CST 2017
ndk.dir=/Users/ymr/Library/Android/sdk/ndk-bundle
bintray.apikey=dummy
#sdk.dir=D\:\\Installation\\Android\\Sdk
sdk.dir=/Users/ymr/Library/Android/sdk
bintray.user=kailash09dabhi
11 changes: 9 additions & 2 deletions om-recorder/src/main/java/omrecorder/AbstractRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public abstract class AbstractRecorder implements Recorder {
protected final PullTransport pullTransport;
protected final File file;
protected File file;
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private OutputStream outputStream;
private final Runnable recordingTask = new Runnable() {
Expand All @@ -50,8 +50,15 @@ protected AbstractRecorder(PullTransport pullTransport, File file) {
this.file = file;
}

protected AbstractRecorder(PullTransport pullTransport, OutputStream outputStream) {
this.pullTransport = pullTransport;
this.outputStream = outputStream;
}

@Override public void startRecording() {
outputStream = outputStream(file);
if (outputStream == null && file != null) {
outputStream = outputStream(file);
}
executorService.submit(recordingTask);
}

Expand Down
11 changes: 11 additions & 0 deletions om-recorder/src/main/java/omrecorder/OmRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package omrecorder;

import android.icu.util.Output;

import java.io.File;
import java.io.OutputStream;

/**
* Essential APIs for working with OmRecorder.
Expand All @@ -31,7 +34,15 @@ public static Recorder pcm(PullTransport pullTransport, File file) {
return new Pcm(pullTransport, file);
}

public static Recorder pcm(PullTransport pullTransport, OutputStream outputStream) {
return new Pcm(pullTransport, outputStream);
}

public static Recorder wav(PullTransport pullTransport, File file) {
return new Wav(pullTransport, file);
}

public static Recorder wav(PullTransport pullTransport, OutputStream outputStream) {
return new Wav(pullTransport, outputStream);
}
}
5 changes: 5 additions & 0 deletions om-recorder/src/main/java/omrecorder/Pcm.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package omrecorder;

import java.io.File;
import java.io.OutputStream;

/**
* {@code Pcm} is recorder for recording audio in wav format.
Expand All @@ -27,4 +28,8 @@ final class Pcm extends AbstractRecorder {
public Pcm(PullTransport pullTransport, File file) {
super(pullTransport, file);
}

public Pcm(PullTransport pullTransport, OutputStream outputStream) {
super(pullTransport, outputStream);
}
}
5 changes: 5 additions & 0 deletions om-recorder/src/main/java/omrecorder/Wav.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;

/**
Expand All @@ -31,6 +32,10 @@ public Wav(PullTransport pullTransport, File file) {
super(pullTransport, file);
}

public Wav(PullTransport pullTransport, OutputStream outputStream) {
super(pullTransport, outputStream);
}

@Override public void stopRecording() {
try {
super.stopRecording();
Expand Down