-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMediaRecorder.java
executable file
·135 lines (97 loc) · 4.59 KB
/
MediaRecorder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.apical.dvr;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.view.SurfaceView;
import android.util.Log;
public class ffRecorder {
private static final String TAG = "ffRecorder";
private static ffRecorder mSingleInstance = null;
public static ffRecorder getInstance(Context context) {
if (mSingleInstance == null) {
mSingleInstance = new ffRecorder();
mSingleInstance.mContext = context;
}
return mSingleInstance;
}
private Context mContext = null;
private long mRecorderContext = 0;
public void init(int cam_main_w, int cam_main_h, int cam_usb_w, int cam_usb_h) {
mRecorderContext = nativeInit(cam_main_w, cam_main_h, cam_usb_w, cam_usb_h);
nativeInitCallback(mRecorderContext);
}
public void release() {
nativeFree(mRecorderContext);
mSingleInstance = null;
}
public boolean getMicMute(int micidx) {
int mute = nativeGetMicMute(mRecorderContext, micidx);
return (nativeGetMicMute(mRecorderContext, micidx) == 1);
}
public void setMicMute(int micidx, boolean mute) {
nativeSetMicMute(mRecorderContext, micidx, mute ? 1 : 0);
}
public void resetCamera(int camidx, int w, int h, int frate) {
nativeResetCamera(mRecorderContext, camidx, w, h, frate);
}
public void setWatermark(int camidx, int x, int y, String watermark) {
nativeSetWatermark(mRecorderContext, camidx, x, y, watermark);
}
public void setPreviewDisplay(int camidx, SurfaceView win) {
nativeSetPreviewWindow(mRecorderContext, camidx, win);
}
public void setPreviewTexture(int camidx, SurfaceTexture win) {
nativeSetPreviewTarget(mRecorderContext, camidx, win);
}
public void startPreview(int camidx) {
nativeStartPreview(mRecorderContext, camidx);
}
public void stopPreview(int camidx) {
nativeStopPreview(mRecorderContext, camidx);
}
public void startRecording(int encidx, String filename) {
nativeStartRecording(mRecorderContext, encidx, filename);
}
public void stopRecording(int encidx) {
nativeStopRecording(mRecorderContext, encidx);
}
public void setAudioSource(int encidx, int source) {
nativeSetAudioSource(mRecorderContext, encidx, source);
}
public void setVideoSource(int encidx, int source) {
nativeSetVideoSource(mRecorderContext, encidx, source);
}
public void takePhoto(int camidx, String filename, takePhotoCallback callback) {
mTakePhotoCB = callback; // setup callback
nativeTakePhoto(mRecorderContext, camidx, filename);
}
public interface takePhotoCallback {
public void onPhotoTaken(String filename, int w, int h);
}
//++ for take photo callback
private takePhotoCallback mTakePhotoCB = null;
private void internalTakePhotoCallback(String filename, int w, int h) {
if (mTakePhotoCB != null) {
mTakePhotoCB.onPhotoTaken(filename, w, h);
}
}
private native void nativeInitCallback(long ctxt);
//-- for take photo callback
private static native long nativeInit(int cam_main_w, int cam_main_h, int cam_usb_w, int cam_usb_h);
private static native void nativeFree(long ctxt);
private static native int nativeGetMicMute (long ctxt, int micidx);
private static native void nativeSetMicMute (long ctxt, int micidx, int mute);
private static native void nativeResetCamera (long ctxt, int camidx, int w, int h, int frate);
private static native void nativeSetWatermark(long ctxt, int camidx, int x, int y, String watermark);
private static native void nativeSetPreviewWindow(long ctxt, int camidx, Object win);
private static native void nativeSetPreviewTarget(long ctxt, int camidx, Object win);
private static native void nativeStartPreview(long ctxt, int camidx);
private static native void nativeStopPreview (long ctxt, int camidx);
private static native void nativeStartRecording(long ctxt, int encidx, String filename);
private static native void nativeStopRecording (long ctxt, int encidx);
private static native void nativeSetAudioSource(long ctxt, int encidx, int source);
private static native void nativeSetVideoSource(long ctxt, int encidx, int source);
private static native void nativeTakePhoto(long ctxt, int camidx, String filename);
static {
System.loadLibrary("ffrecorder_jni");
}
}