-
Notifications
You must be signed in to change notification settings - Fork 27
/
recordertest.cpp
executable file
·84 lines (67 loc) · 2.43 KB
/
recordertest.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
#include <cutils/properties.h>
#include "ffutils.h"
#include "ffrecorder.h"
int main(int argc, char *argv[])
{
void *recorder = NULL;
char filename[128];
uint64_t curtick = 0;
int i = 0;
// set exit flag to 0
property_set("sys.ffrecorder.test.exit", "0");
// create a client to surfaceflinger
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
ISurfaceComposer::eDisplayIdMain));
DisplayInfo dinfo;
status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
if (status) {
return -1;
}
sp<SurfaceControl> surfaceControl = client->createSurface(String8("yuvtest_surface"),
dinfo.w, dinfo.h, PIXEL_FORMAT_RGBX_8888, 0);
SurfaceComposerClient::openGlobalTransaction();
surfaceControl->setLayer(0x40000000);
// surfaceControl->setPosition(0, 0);
// surfaceControl->setSize(320, 180);
SurfaceComposerClient::closeGlobalTransaction();
sp<Surface> surface = surfaceControl->getSurface();
sp<ANativeWindow> win = surface;
// init camdev
FFRECORDER_PARAMS params;
memset(¶ms, 0, sizeof(params));
params.cam_frame_width_0 = 640;
params.cam_frame_height_0 = 480;
params.cam_frame_rate_0 = 25;
params.out_video_bitrate_0= 2000000;
params.out_video_width_0 = 640;
params.out_video_height_0 = 480;
params.cam_frame_rate_0 = 25;
recorder = ffrecorder_init(¶ms, NULL);
// startpreview
ffrecorder_preview_window(recorder, 0, win);
ffrecorder_preview_start (recorder, 0);
// wait exit
while (1) {
if (get_tick_count() - curtick > 60 * 1000) {
curtick = get_tick_count();
sprintf(filename, "/sdcard/test%03d.mp4", i); i++;
ffrecorder_record_start(recorder, 0, filename);
ffrecorder_record_start(recorder,-1, NULL );
}
char exit[PROP_VALUE_MAX];
property_get("sys.ffrecorder.test.exit", exit, "0");
if (strcmp(exit, "1") == 0) {
break;
}
usleep(100*1000);
}
// stop record
ffrecorder_record_stop(recorder, 0);
ffrecorder_record_stop(recorder,-1);
// stop preview
ffrecorder_preview_stop(recorder, 0);
// close camdev
ffrecorder_free(recorder);
return 0;
}