mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-22 05:27:24 +00:00
add mp4write feature from @mnakada, and patch in on-off capability to libcallback
This commit is contained in:
parent
a14d6ee7cc
commit
24baf11f4a
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
|
||||
CC = /openmiko/build/mips-gcc472-glibc216-64bit/bin/mips-linux-uclibc-gnu-gcc
|
||||
CFLAGS = -fPIC -std=gnu99 -shared -ldl -ltinyalsa -lm -pthread
|
||||
CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c
|
||||
CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c mp4write.c
|
||||
TARGET = libcallback.so
|
||||
|
||||
all: ${TARGET}
|
||||
|
@ -21,6 +21,7 @@ extern char *MotorMove(int fd, char *tokenPtr);
|
||||
extern char *WaitMotion(int fd, char *tokenPtr);
|
||||
extern char *IrLed(int fd, char *tokenPtr);
|
||||
extern char *AudioPlay(int fd, char *tokenPtr);
|
||||
extern char *mp4Write(int fd, char *tokenPtr);
|
||||
|
||||
struct CommandTableSt {
|
||||
const char *cmd;
|
||||
@ -35,6 +36,8 @@ struct CommandTableSt CommandTable[] = {
|
||||
{ "waitMotion", &WaitMotion },
|
||||
{ "irled", &IrLed },
|
||||
{ "aplay", &AudioPlay },
|
||||
{ "mp4write", &mp4Write },
|
||||
|
||||
};
|
||||
|
||||
void CommandResponse(int fd, const char *res) {
|
||||
|
Binary file not shown.
53
libcallback_wz_mod/mp4write.c
Normal file
53
libcallback_wz_mod/mp4write.c
Normal file
@ -0,0 +1,53 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int (*original_mp4write_start_handler)(void *handler, char *file, void *config);
|
||||
|
||||
static int mp4WriteEnable = 0;
|
||||
|
||||
char *mp4Write(int fd, char *tokenPtr) {
|
||||
|
||||
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
|
||||
if(!p) return mp4WriteEnable ? "on" : "off";
|
||||
if(!strcmp(p, "on")) {
|
||||
mp4WriteEnable = 1;
|
||||
fprintf(stderr, "[command] mp4write on\n", p);
|
||||
return "ok";
|
||||
}
|
||||
if(!strcmp(p, "off")) {
|
||||
mp4WriteEnable = 0;
|
||||
fprintf(stderr, "[command] mp4write off\n", p);
|
||||
return "ok";
|
||||
}
|
||||
return "error in mp4write.c";
|
||||
}
|
||||
|
||||
int mp4write_start_handler(void *handler, char *file, void *config) {
|
||||
|
||||
if(mp4WriteEnable) {
|
||||
|
||||
struct stat st = {0};
|
||||
|
||||
if(!strncmp(file, "/tmp/", 5)) {
|
||||
char buf[64];
|
||||
strncpy(buf, file + 5, 30);
|
||||
if (stat("/media/mmc/record/tmp", &st) == -1) {
|
||||
mkdir("/media/mmc/record/tmp", 0700);
|
||||
}
|
||||
strcpy(file, "/media/mmc/record/tmp/");
|
||||
strcat(file, buf);
|
||||
}
|
||||
}
|
||||
return (original_mp4write_start_handler)(handler, file, config);
|
||||
}
|
||||
static void __attribute ((constructor)) mp4write_init(void) {
|
||||
|
||||
original_mp4write_start_handler = dlsym(dlopen("/system/lib/libmp4rw.so", RTLD_LAZY), "mp4write_start_handler");
|
||||
}
|
Loading…
Reference in New Issue
Block a user