@@ -48,6 +48,7 @@ struct encoding_parameters {
4848 int8_t input_source ;
4949 char * exec_program ;
5050 int respawn : 1 ;
51+ int pipe_sz ;
5152 int src_x , src_y , src_width , src_height , dst_width , dst_height ;
5253};
5354
@@ -633,7 +634,7 @@ static int pipe2(int pipefd[2], int flags)
633634}
634635#endif
635636
636- static int bmd_start_exec_program (struct blackmagic_device * bmd , char * exec_program )
637+ static int bmd_start_exec_program (struct blackmagic_device * bmd , int pipe_sz , char * exec_program )
637638{
638639 uint8_t ports [8 ];
639640 char fmt [array_size (ports )* 4 ];
@@ -653,6 +654,12 @@ static int bmd_start_exec_program(struct blackmagic_device *bmd, char *exec_prog
653654 if (pipe2 (pipefd , O_CLOEXEC ) < 0 )
654655 return 0 ;
655656
657+ if (pipe_sz ) {
658+ if (fcntl (pipefd [0 ], F_SETPIPE_SZ , pipe_sz * 1024 ) < 0 )
659+ dlog (LOG_ERR , "%s: unable to set pipe size" ,
660+ bmd -> name , ep .exec_program );
661+ }
662+
656663 i = p = 0 ;
657664 if (bmd -> desc .idProduct != USB_PID_BMD_H264_PRO_RECORDER ) {
658665 envp [i ++ ] = & tmp [p ];
@@ -714,7 +721,7 @@ static void *bmd_pump_mpegts(void *ctx)
714721 if (ep .exec_program ) {
715722 if (ep .respawn ) {
716723 bmd_kill_exec_program (bmd );
717- bmd_start_exec_program (bmd , ep .exec_program );
724+ bmd_start_exec_program (bmd , ep .pipe_sz , ep . exec_program );
718725 } else {
719726 bmd -> running = 0 ;
720727 }
@@ -1031,7 +1038,7 @@ static void bmd_encoder_start(struct blackmagic_device *bmd)
10311038 goto error ;
10321039 }
10331040
1034- if (!bmd_start_exec_program (bmd , ep .exec_program )) {
1041+ if (!bmd_start_exec_program (bmd , ep .pipe_sz , ep . exec_program )) {
10351042 err = "start exec program" ;
10361043 goto error ;
10371044 }
@@ -1321,6 +1328,7 @@ static int usage(void)
13211328 " -S,--input-source Set input source (component, sdi, hdmi,\n"
13221329 " composite, s-video, or 0-4)\n"
13231330 " -f,--firmware-dir Directory for firmware images\n"
1331+ " -z,--pipe-size Set stream output pipe size in kB\n"
13241332 " -x,--exec Program to execute for each connected stream\n"
13251333 " -R,--respawn Restart execute program if it exits\n"
13261334 " -s,--syslog Log to syslog\n"
@@ -1352,6 +1360,7 @@ int main(int argc, char **argv)
13521360 { "fps-divider" , required_argument , NULL , 'F' },
13531361 { "firmware-dir" , required_argument , NULL , 'f' },
13541362 { "input-source" , required_argument , NULL , 'S' },
1363+ { "pipe-size" , required_argument , NULL , 'z' },
13551364 { "exec" , required_argument , NULL , 'x' },
13561365 { "respawn" , no_argument , NULL , 'R' },
13571366 { "syslog" , no_argument , NULL , 's' },
@@ -1363,7 +1372,7 @@ int main(int argc, char **argv)
13631372 { "dst-height" , required_argument , NULL , '5' },
13641373 { NULL }
13651374 };
1366- static const char short_options [] = "vk:K:a:P:L:bcBCF:f:S:x:Rs" ;
1375+ static const char short_options [] = "vk:K:a:P:L:bcBCF:f:S:z: x:Rs" ;
13671376
13681377 libusb_context * ctx ;
13691378 libusb_hotplug_callback_handle cbhandle ;
@@ -1409,6 +1418,7 @@ int main(int argc, char **argv)
14091418 if (i >= array_size (input_source_names )) i = -1 ;
14101419 ep .input_source = i ;
14111420 break ;
1421+ case 'z' : ep .pipe_sz = atoi (optarg ); break ;
14121422 case '0' : ep .src_x = atoi (optarg ); break ;
14131423 case '1' : ep .src_y = atoi (optarg ); break ;
14141424 case '2' : ep .src_width = atoi (optarg ); break ;
0 commit comments