From 39e4539925687d46c7bbe04681dcc09757dc9ae2 Mon Sep 17 00:00:00 2001 From: wanglu Date: Thu, 28 Mar 2019 09:31:38 +0800 Subject: Fix review problems: 1.Add autobuild 2.Replace literal with notation in tsutils/tsrecorder/tsrecorder.c 3.Update LICENSE and COPYRIGHT This is a logging app with following functions included: 1.video recording 2.Audio recording 3.Can data recording & playing 4.Screen touch event recording & playing Change-Id: Id7942e16f87e69d25240f4985d3c47bc262d25c2 Signed-off-by: wanglu --- tsutils/tsrecorder/tsrecorder.c | 150 ++++++++++++++++++++++++++++++++++++++ tsutils/tsrecorder/tsrecorder.pro | 7 ++ 2 files changed, 157 insertions(+) create mode 100644 tsutils/tsrecorder/tsrecorder.c create mode 100644 tsutils/tsrecorder/tsrecorder.pro (limited to 'tsutils/tsrecorder') diff --git a/tsutils/tsrecorder/tsrecorder.c b/tsutils/tsrecorder/tsrecorder.c new file mode 100644 index 0000000..9c2e466 --- /dev/null +++ b/tsutils/tsrecorder/tsrecorder.c @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2019 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +static int eventFd = -1; +static FILE* pfile; +struct input_event ev0[64]; +static int screenWidth = 0; +static int screenHeight = 0; + +extern char* getTouchScreenInfo(); + +static int handle_event() +{ + int i, rd; + char str[256]; + float x = 0, y = 0; + + rd = read(eventFd, ev0, sizeof(struct input_event)* 64); + + if(rd < sizeof(struct input_event)) + return 0; + + for(i=0;i\n \ + -f : file name for recording event\n", myName); +} + +int main(int argc,char *argv[]) +{ + int done = 1; + int index = 0; + char* fName = NULL; + char eventNode[50]; + const char* tsInfo; + + if (argc < 3) + { + printUsage(argv[0]); + return -1; + } + + for (index = 1; index < argc; index++) + { + if (strcmp(argv[index], "-f") == 0) + { + fName = argv[++index]; + } + else + { + printUsage(argv[0]); + return -1; + } + } + + tsInfo = getTouchScreenInfo(); + if (NULL == tsInfo) { + printf("Failed to get touch screen info.\n"); + return -1; + } + + memset(eventNode, 0, sizeof(eventNode)); + sscanf(tsInfo, "%s %d %d", eventNode, &screenWidth, &screenHeight); + + eventFd = open(eventNode, O_RDWR); + if(eventFd <0) { + printf("open input device error\n"); + return -1; + } + + pfile = fopen(fName, "wb+"); + if(pfile == NULL) + { + printf("Failed to create file!\n"); + return -1; + } + + while (done) + { + printf("begin %s...\n", eventNode); + done = handle_event(); + printf("end %s...\n", eventNode); + } + + fclose(pfile); + + if(eventFd > 0) + { + close(eventFd); + eventFd = -1; + } + + return 0; +} diff --git a/tsutils/tsrecorder/tsrecorder.pro b/tsutils/tsrecorder/tsrecorder.pro new file mode 100644 index 0000000..3c3988b --- /dev/null +++ b/tsutils/tsrecorder/tsrecorder.pro @@ -0,0 +1,7 @@ +TARGET = tsrecorder + +DESTDIR = $${OUT_PWD}/../../package/root/bin + +SOURCES += \ + tsrecorder.c \ + ../tsutils.c -- cgit 1.2.3-korg