|
@@ -19,7 +19,9 @@ typedef int (* framecb)(struct frames_st *);
|
|
|
|
|
|
|
|
static int (*real_local_sdk_video_set_encode_frame_callback)(int ch, void *callback);
|
|
static int (*real_local_sdk_video_set_encode_frame_callback)(int ch, void *callback);
|
|
|
static void *video_encode_cb = NULL;
|
|
static void *video_encode_cb = NULL;
|
|
|
|
|
+static void *video_encode_cb1 = NULL;
|
|
|
static int VideoCaptureEnable = 0;
|
|
static int VideoCaptureEnable = 0;
|
|
|
|
|
+static int VideoCaptureEnable1 = 0;
|
|
|
|
|
|
|
|
char *VideoCapture(int fd, char *tokenPtr) {
|
|
char *VideoCapture(int fd, char *tokenPtr) {
|
|
|
|
|
|
|
@@ -27,12 +29,22 @@ char *VideoCapture(int fd, char *tokenPtr) {
|
|
|
if(!p) return VideoCaptureEnable ? "on" : "off";
|
|
if(!p) return VideoCaptureEnable ? "on" : "off";
|
|
|
if(!strcmp(p, "on")) {
|
|
if(!strcmp(p, "on")) {
|
|
|
VideoCaptureEnable = 1;
|
|
VideoCaptureEnable = 1;
|
|
|
- fprintf(stderr, "[command] video capute on\n", p);
|
|
|
|
|
|
|
+ fprintf(stderr, "[command] video capture ch0 on\n", p);
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!strcmp(p, "on1")) {
|
|
|
|
|
+ VideoCaptureEnable1 = 1;
|
|
|
|
|
+ fprintf(stderr, "[command] video capture ch1 on\n", p);
|
|
|
return "ok";
|
|
return "ok";
|
|
|
}
|
|
}
|
|
|
if(!strcmp(p, "off")) {
|
|
if(!strcmp(p, "off")) {
|
|
|
VideoCaptureEnable = 0;
|
|
VideoCaptureEnable = 0;
|
|
|
- fprintf(stderr, "[command] video capute off\n", p);
|
|
|
|
|
|
|
+ fprintf(stderr, "[command] video capture ch0 off\n", p);
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!strcmp(p, "off1")) {
|
|
|
|
|
+ VideoCaptureEnable1 = 0;
|
|
|
|
|
+ fprintf(stderr, "[command] video capture ch1 off\n", p);
|
|
|
return "ok";
|
|
return "ok";
|
|
|
}
|
|
}
|
|
|
return "error";
|
|
return "error";
|
|
@@ -43,6 +55,7 @@ static uint32_t video_encode_capture(struct frames_st *frames) {
|
|
|
static int firstEntry = 0;
|
|
static int firstEntry = 0;
|
|
|
static int v4l2Fd = -1;
|
|
static int v4l2Fd = -1;
|
|
|
|
|
|
|
|
|
|
+//primary stream 0
|
|
|
if(!firstEntry) {
|
|
if(!firstEntry) {
|
|
|
firstEntry++;
|
|
firstEntry++;
|
|
|
int err;
|
|
int err;
|
|
@@ -86,19 +99,78 @@ static uint32_t video_encode_capture(struct frames_st *frames) {
|
|
|
return ((framecb)video_encode_cb)(frames);
|
|
return ((framecb)video_encode_cb)(frames);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//secondary stream 1
|
|
|
|
|
+static uint32_t video_encode_capture1(struct frames_st *frames) {
|
|
|
|
|
+
|
|
|
|
|
+ static int firstEntry = 0;
|
|
|
|
|
+ static int v4l2Fd = -1;
|
|
|
|
|
+
|
|
|
|
|
+ if(!firstEntry) {
|
|
|
|
|
+ firstEntry++;
|
|
|
|
|
+ int err;
|
|
|
|
|
+ const char *v4l2_device_path = "/dev/video2";
|
|
|
|
|
+ const char *productf="/configs/.product_db3";
|
|
|
|
|
+ fprintf(stderr,"Opening V4L2 device: %s \n", v4l2_device_path);
|
|
|
|
|
+ v4l2Fd = open(v4l2_device_path, O_WRONLY, 0777);
|
|
|
|
|
+ if(v4l2Fd < 0) fprintf(stderr,"Failed to open V4L2 device: %s\n", v4l2_device_path);
|
|
|
|
|
+ struct v4l2_format vid_format;
|
|
|
|
|
+ memset(&vid_format, 0, sizeof(vid_format));
|
|
|
|
|
+ vid_format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
|
|
|
|
+
|
|
|
|
|
+ if( access( productf, F_OK ) == 0 ) {
|
|
|
|
|
+ /* doorbell resolution */
|
|
|
|
|
+ printf("[command] video product 640x480");
|
|
|
|
|
+ vid_format.fmt.pix.width = 640;
|
|
|
|
|
+ vid_format.fmt.pix.height = 480;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ /* v3 and panv2 res */
|
|
|
|
|
+ printf("[command] video product 640x320");
|
|
|
|
|
+ vid_format.fmt.pix.width = 640;
|
|
|
|
|
+ vid_format.fmt.pix.height = 320;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ vid_format.fmt.pix.pixelformat = V4L2_PIX_FMT_H264;
|
|
|
|
|
+ vid_format.fmt.pix.sizeimage = 0;
|
|
|
|
|
+ vid_format.fmt.pix.field = V4L2_FIELD_NONE;
|
|
|
|
|
+ vid_format.fmt.pix.bytesperline = 0;
|
|
|
|
|
+ vid_format.fmt.pix.colorspace = V4L2_PIX_FMT_YUV420;
|
|
|
|
|
+ err = ioctl(v4l2Fd, VIDIOC_S_FMT, &vid_format);
|
|
|
|
|
+ if(err < 0) fprintf(stderr,"Unable to set V4L2 device video format: %d\n", err);
|
|
|
|
|
+ err = ioctl(v4l2Fd, VIDIOC_STREAMON, &vid_format);
|
|
|
|
|
+ if(err < 0) fprintf(stderr,"Unable to perform VIDIOC_STREAMON: %d\n", err);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if( (v4l2Fd >= 0) && VideoCaptureEnable) {
|
|
|
|
|
+ uint32_t *buf = frames->buf;
|
|
|
|
|
+ int size = write(v4l2Fd, frames->buf, frames->length);
|
|
|
|
|
+ if(size != frames->length) fprintf(stderr,"Stream write error: %s\n", size);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ((framecb)video_encode_cb1)(frames);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
int local_sdk_video_set_encode_frame_callback(int ch, void *callback) {
|
|
int local_sdk_video_set_encode_frame_callback(int ch, void *callback) {
|
|
|
|
|
|
|
|
fprintf(stderr, "local_sdk_video_set_encode_frame_callback streamChId=%d, callback=0x%x\n", ch, callback);
|
|
fprintf(stderr, "local_sdk_video_set_encode_frame_callback streamChId=%d, callback=0x%x\n", ch, callback);
|
|
|
static int ch_count = 0;
|
|
static int ch_count = 0;
|
|
|
|
|
|
|
|
-/* two callbacks typically detected, unknown what the difference is between them, but if they are both hooked, the app breaks. grab just one of them. */
|
|
|
|
|
-
|
|
|
|
|
|
|
+/* two callbacks for video stream 0 are typically detected, unknown what the difference is between them, but if they are both hooked, the app breaks. grab just one of them. */
|
|
|
|
|
+ //stream 0
|
|
|
if( (ch == 0) && ch_count == 2) {
|
|
if( (ch == 0) && ch_count == 2) {
|
|
|
video_encode_cb = callback;
|
|
video_encode_cb = callback;
|
|
|
fprintf(stderr,"enc func injection save video_encode_cb=0x%x\n", video_encode_cb);
|
|
fprintf(stderr,"enc func injection save video_encode_cb=0x%x\n", video_encode_cb);
|
|
|
callback = video_encode_capture;
|
|
callback = video_encode_capture;
|
|
|
}
|
|
}
|
|
|
fprintf(stderr,"ch count is %x\n", ch_count);
|
|
fprintf(stderr,"ch count is %x\n", ch_count);
|
|
|
|
|
+
|
|
|
|
|
+ //stream 1
|
|
|
|
|
+ if( (ch == 1) && ch_count == 1) {
|
|
|
|
|
+ video_encode_cb1 = callback;
|
|
|
|
|
+ fprintf(stderr,"enc func injection save video_encode_cb=0x%x\n", video_encode_cb1);
|
|
|
|
|
+ callback = video_encode_capture1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ch_count=ch_count+1;
|
|
ch_count=ch_count+1;
|
|
|
|
|
|
|
|
return real_local_sdk_video_set_encode_frame_callback(ch, callback);
|
|
return real_local_sdk_video_set_encode_frame_callback(ch, callback);
|