diff --git a/camera/helper/Android.mk b/camera/helper/Android.mk new file mode 100644 index 0000000..9242886 --- /dev/null +++ b/camera/helper/Android.mk @@ -0,0 +1,15 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + helper.cpp + +LOCAL_SHARED_LIBRARIES := \ + liblog libcutils + +LOCAL_MODULE_PATH := /system/bin +LOCAL_MODULE := camera_helper +LOCAL_MODULE_TAGS := optional +LOCAL_PROPRIETARY_MODULE := true + +include $(BUILD_SHARED_LIBRARY) diff --git a/camera/helper/helper.c b/camera/helper/helper.c new file mode 100644 index 0000000..2a0da61 --- /dev/null +++ b/camera/helper/helper.c @@ -0,0 +1,81 @@ +// Copyright 2018 Leonardomeitz@gmail.com +// This is part of the NeoHomies Project + +#include +#include + +#include "helper.h" + +static int raw_file_exists(){ + int ret; + DIR *d; + struct dirent *dir; + + ret = false; + d = opendir(data_path); + if (d) { + while ((dir = readdir(d)) != NULL) { + if (strstr(dir->d_name, "yuv") != NULL){ + return true; + } + printf("%s\n", dir->d_name); + } + closedir(d); + } + + return ret; +} + +static char *get_raw_file_name(){ + char *name; + DIR *d; + struct dirent *dir; + + name = NULL; + d = opendir(data_path); + if (d) { + while ((dir = readdir(d)) != NULL) { + if (strstr(dir->d_name, "yuv") != NULL){ + return dir->d_name; + } + printf("%s\n", dir->d_name); + } + closedir(d); + } + + return name; +} + +static int copy_raw_file(char *name){ + // TODO +} + +static int delete_raw_file(char *name){ + // TODO +} + +int main(){ + if (raw_file_exists()) { + char *name = get_raw_file_name(); + if (name != NULL) { + // TODO + if ((copy_raw_file(name) && delete_raw_file(name)) != NULL) { + return true; + } + else { + // Error while copying/deleting + return false; + } + } + else { + // This should happen, abort! + exit(EXIT_FAILURE); + } + } + else { + // Called but no file found + // Retry in 400 msec + // TODO + + } +} diff --git a/camera/helper/helper.h b/camera/helper/helper.h new file mode 100644 index 0000000..5f917dc --- /dev/null +++ b/camera/helper/helper.h @@ -0,0 +1,7 @@ +#ifndef __helper__ +#define __helper__ + +#define EXIT_FAILURE -1 +#define data_path "/data/" + +#endif