Skip to content

Commit

Permalink
get_jpeg.cgi implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
bakueikozo committed Sep 29, 2021
1 parent fa33f99 commit ffbfd56
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 10 deletions.
31 changes: 22 additions & 9 deletions filesnooper.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdint.h>
#include <fcntl.h>
#include <linux/videodev2.h>

#include <pthread.h>
#include <time.h>

static ssize_t (*real_write)(int fd, const void *buf, size_t count) = NULL;
Expand All @@ -29,14 +29,6 @@ struct v4l2_format vid_format2;
int v4l2_fd2;
char v4l2_device_path2[255];


struct tm *gmtime_r_(const time_t *timep, struct tm *result)
{
fprintf(stderr,"!!! called gmtime_r!!!\n");
fflush(stderr);

return ((gmtime_r_t)dlsym(RTLD_NEXT, "gmtime_r"))(timep, result);
}
int cnt2=0;
static uint32_t test_capture(void *param){
int ret=0;
Expand Down Expand Up @@ -137,7 +129,26 @@ static uint32_t test_captureyuv(void *param){

return 0;
}
static void *jpg_stream_thread(void *m)
{
int n=0;
char filename[255];
fprintf(stderr,"jpeg_stream_thread_start");
while(1){
FILE *fp;
fp=fopen("/tmp/get_jpeg", "r");
if( fp ){
sprintf(filename,"/tmp/snapshot.jpg");
local_sdk_video_get_jpeg(0,filename);
remove("/tmp/get_jpeg");
fclose(fp);
sleep(0);
}else{

}
}

}
uint32_t local_sdk_video_set_encode_frame_callback(uint32_t param1,uint32_t param2){
void *handle;
fprintf(stderr,"!!! called local_sdk_video_set_encode_frame_callback !!!\n");
Expand All @@ -158,6 +169,8 @@ uint32_t local_sdk_video_set_encode_frame_callback(uint32_t param1,uint32_t para
fprintf(stderr,"enc func injection save pcb=0x%x\n",pfunccb);
param2=(uint32_t)test_capture;
fprintf(stderr,"override to 0x%x\n",param2);
pthread_t tid; /* Stream capture in another thread */
pthread_create(&tid, NULL, jpg_stream_thread, NULL);
}
int ret=real_local_sdk_video_set_encode_frame_callback(param1,param2);
/*
Expand Down
Binary file modified modules/libcallback.so
Binary file not shown.
17 changes: 17 additions & 0 deletions scripts/get_jpeg.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

echo "Cache-Control: no-cache"
echo "Content-Type: image/jpeg"
echo ""


touch /tmp/get_jpeg
while true
do
if [ ! -f /tmp/get_jpeg ]; then
break
fi
done

cat /tmp/snapshot.jpg

4 changes: 3 additions & 1 deletion scripts/honeylab_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ mkdir /tmp/www
mkdir /tmp/www/cgi-bin
chmod 755 /tmp/www/cgi-bin
cp /tmp/mmc/scripts/honeylab.cgi /tmp/www/cgi-bin
cp /tmp/mmc/scripts/get_jpeg.cgi /tmp/www/cgi-bin
chmod 755 /tmp/www/cgi-bin/honeylab.cgi

chmod 755 /tmp/www/cgi-bin/get_jpeg.cgi
cp /tmp/mmc/scripts/still_image.html /tmp/www

echo "run /tmp/mmc/scripts/pre.sh"
source /tmp/mmc/scripts/pre.sh
Expand Down
13 changes: 13 additions & 0 deletions scripts/still_image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html><head>
<title> ATOM CAM STILL IMAGE TEST </title>
<script>
function reloadimg(e,timer){
setTimeout( function(){
e.src = "/cgi-bin/get_jpeg.cgi?r=" + Math.random();
},timer);
}
</script>
</head>
STILL IMAGE <br>
<img src="/cgi-bin/get_jpeg.cgi" onload="reloadimg(this,100)" onerror="reloadimg(this,2000)" />

0 comments on commit ffbfd56

Please sign in to comment.