-
Notifications
You must be signed in to change notification settings - Fork 27
/
com_apical_dvr_ffRecorder.cpp
executable file
·253 lines (231 loc) · 7.1 KB
/
com_apical_dvr_ffRecorder.cpp
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#define LOG_TAG "ffrecorder_jni"
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <android_runtime/android_view_Surface.h>
#include <utils/Log.h>
#include "com_apical_dvr_ffRecorder.h"
#include "ffrecorder.h"
/* Header for class com_apical_dvr_ffRecorder */
JavaVM* g_jvm = NULL;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
JNIEnv* env = NULL;
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
ALOGE("ERROR: GetEnv failed\n");
return -1;
}
assert(env != NULL);
// for g_jvm
g_jvm = vm;
return JNI_VERSION_1_4;
}
JNIEXPORT JNIEnv* get_jni_env(void)
{
JNIEnv *env;
int status;
if (NULL == g_jvm)
{
ALOGE("g_jvm == NULL !\n");
return NULL;
}
status = g_jvm->GetEnv((void **)&env, JNI_VERSION_1_4);
if (status < 0) {
// ALOGD("failed to get JNI environment assuming native thread !\n");
status = g_jvm->AttachCurrentThread(&env, NULL);
if (status < 0) {
ALOGE("failed to attach current thread !\n");
return NULL;
}
}
return env;
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeInitCallback
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeInitCallback
(JNIEnv *env, jobject obj, jlong ctxt)
{
ffrecorder_init_jni_callback((void*)ctxt, env, obj);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeInit
* Signature: (IIII)J
*/
JNIEXPORT jlong JNICALL Java_com_apical_dvr_ffRecorder_nativeInit
(JNIEnv *env, jclass clazz, jint cam_main_w, jint cam_main_h, jint cam_usb_w, jint cam_usb_h)
{
FFRECORDER_PARAMS params;
memset(¶ms, 0, sizeof(params));
params.cam_frame_width_0 = cam_main_w;
params.cam_frame_height_0 = cam_main_h;
params.cam_frame_width_1 = cam_usb_w;
params.cam_frame_height_1 = cam_usb_h;
params.enable_h264hwenc = 1; // use h264hwenc
return (jlong)ffrecorder_init(¶ms, env);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeFree
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeFree
(JNIEnv *env, jclass clazz, jlong ctxt)
{
ffrecorder_free((void*)ctxt);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeGetMicMute
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL Java_com_apical_dvr_ffRecorder_nativeGetMicMute
(JNIEnv *env, jclass clazz, jlong ctxt, jint micidx)
{
return ffrecorder_get_mic_mute((void*)ctxt, micidx);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetMicMute
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetMicMute
(JNIEnv *env, jclass clazz, jlong ctxt, jint micidx, jint mute)
{
ffrecorder_set_mic_mute((void*)ctxt, micidx, mute);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeResetCamera
* Signature: (JIIII)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeResetCamera
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx, jint w, jint h, jint frate)
{
ffrecorder_reset_camdev((void*)ctxt, camidx, w, h, frate);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetWatermark
* Signature: (JIIILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetWatermark
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx, jint x, jint y, jstring watermark)
{
const char *str = env->GetStringUTFChars(watermark, NULL);
ffrecorder_set_watermark((void*)ctxt, camidx, x, y, (char*)str);
env->ReleaseStringUTFChars(watermark, str);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetPreviewWindow
* Signature: (JILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetPreviewWindow
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx, jobject jsurface)
{
sp<IGraphicBufferProducer> gbp;
sp<Surface> surface;
if (jsurface) {
surface = android_view_Surface_getSurface(env, jsurface);
if (surface != NULL) {
gbp = surface->getIGraphicBufferProducer();
}
}
ffrecorder_preview_target((void*)ctxt, camidx, gbp);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetPreviewTarget
* Signature: (JILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetPreviewTarget
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx, jobject jtexture)
{
sp<IGraphicBufferProducer> gbp = NULL;
if (jtexture != NULL) {
gbp = SurfaceTexture_getProducer(env, jtexture);
if (gbp == NULL) {
ALOGW("SurfaceTexture already released in setPreviewTexture !");
return;
}
}
ffrecorder_preview_target((void*)ctxt, camidx, gbp);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeStartPreview
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeStartPreview
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx)
{
ffrecorder_preview_start((void*)ctxt, camidx);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeStopPreview
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeStopPreview
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx)
{
ffrecorder_preview_stop((void*)ctxt, camidx);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeStartRecording
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeStartRecording
(JNIEnv *env, jclass clazz, jlong ctxt, jint encidx, jstring filename)
{
const char *str = env->GetStringUTFChars(filename, NULL);
ffrecorder_record_start((void*)ctxt, encidx, (char*)str);
env->ReleaseStringUTFChars(filename, str);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeStopRecording
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeStopRecording
(JNIEnv *env, jclass clazz, jlong ctxt, jint encidx)
{
ffrecorder_record_stop((void*)ctxt, encidx);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetAudioSource
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetAudioSource
(JNIEnv *env, jclass clazz, jlong ctxt, jint encidx, jint source)
{
ffrecorder_record_audio_source((void*)ctxt, encidx, source);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeSetVideoSource
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeSetVideoSource
(JNIEnv *env, jclass clazz, jlong ctxt, jint encidx, jint source)
{
ffrecorder_record_video_source((void*)ctxt, encidx, source);
}
/*
* Class: com_apical_dvr_ffRecorder
* Method: nativeTakePhoto
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_apical_dvr_ffRecorder_nativeTakePhoto
(JNIEnv *env, jclass clazz, jlong ctxt, jint camidx, jstring filename)
{
const char *str = env->GetStringUTFChars(filename, NULL);
ffrecorder_take_photo((void*)ctxt, camidx, (char*)str);
env->ReleaseStringUTFChars(filename, str);
}