comparison recpt1/recpt1.c @ 121:e915d31c5bd9

add --es option
author Naoya OYAMA <naoya.oyama@gmail.com>
date Thu, 29 Apr 2010 02:02:42 +0900
parents d89f0da0a7e4
children 4009737ea899
comparison
equal deleted inserted replaced
120:8e438d2a1529 121:e915d31c5bd9
334 buf = sbuf; /* default */ 334 buf = sbuf; /* default */
335 335
336 if(use_b25) { 336 if(use_b25) {
337 code = b25_decode(dec, &sbuf, &dbuf); 337 code = b25_decode(dec, &sbuf, &dbuf);
338 if(code < 0) { 338 if(code < 0) {
339 fprintf(stderr, "b25_decode failed (code=%d). fall back to encrypted recording.\n", code); 339 fprintf(stderr, "b25_decode failed. fall back to encrypted recording.\n");
340 use_b25 = FALSE; 340 use_b25 = FALSE; /* local flag */
341 } 341 }
342 else 342 else
343 buf = dbuf; 343 buf = dbuf;
344 } 344 }
345 345
359 } 359 }
360 else if(split_select_finish != TSS_SUCCESS) { 360 else if(split_select_finish != TSS_SUCCESS) {
361 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B 361 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B
362 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B 362 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B
363 */ 363 */
364 time_t cur_time;
365 time(&cur_time);
366 if(cur_time - data->start_time > 4) {
367 use_splitter = FALSE;
368 goto fin;
369 }
370 break; 364 break;
371 } 365 }
372 } 366 }
373 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ 367 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */
374 code = split_ts(splitter, &buf, &splitbuf); 368 code = split_ts(splitter, &buf, &splitbuf);
484 478
485 void 479 void
486 show_usage(char *cmd) 480 show_usage(char *cmd)
487 { 481 {
488 #ifdef HAVE_LIBARIB25 482 #ifdef HAVE_LIBARIB25
489 fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] channel rectime destfile\n", cmd); 483 fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] channel [--es filename_suffix] rectime destfile\n", cmd);
490 #else 484 #else
491 fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] channel rectime destfile\n", cmd); 485 fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] [--es filename_suffix] channel rectime destfile\n", cmd);
492 #endif 486 #endif
493 fprintf(stderr, "\n"); 487 fprintf(stderr, "\n");
494 fprintf(stderr, "Remarks:\n"); 488 fprintf(stderr, "Remarks:\n");
495 fprintf(stderr, "if rectime is '-', records indefinitely.\n"); 489 fprintf(stderr, "if rectime is '-', records indefinitely.\n");
496 fprintf(stderr, "if destfile is '-', stdout is used for output.\n"); 490 fprintf(stderr, "if destfile is '-', stdout is used for output.\n");
510 fprintf(stderr, " --addr hostname: Hostname or address to connect\n"); 504 fprintf(stderr, " --addr hostname: Hostname or address to connect\n");
511 fprintf(stderr, " --port portnumber: Port number to connect\n"); 505 fprintf(stderr, " --port portnumber: Port number to connect\n");
512 fprintf(stderr, "--device devicefile: Specify devicefile to use\n"); 506 fprintf(stderr, "--device devicefile: Specify devicefile to use\n");
513 fprintf(stderr, "--lnb voltage: Specify LNB voltage (0, 11, 15)\n"); 507 fprintf(stderr, "--lnb voltage: Specify LNB voltage (0, 11, 15)\n");
514 fprintf(stderr, "--sid SID1,SID2,...: Specify SID number in CSV format (101,102,...)\n"); 508 fprintf(stderr, "--sid SID1,SID2,...: Specify SID number in CSV format (101,102,...)\n");
509 fprintf(stderr, " --es filename: Specify ES out filename prefix\n");
515 fprintf(stderr, "--help: Show this help\n"); 510 fprintf(stderr, "--help: Show this help\n");
516 fprintf(stderr, "--version: Show version\n"); 511 fprintf(stderr, "--version: Show version\n");
517 fprintf(stderr, "--list: Show channel list\n"); 512 fprintf(stderr, "--list: Show channel list\n");
518 } 513 }
519 514
896 { "device", 1, NULL, 'd'}, 891 { "device", 1, NULL, 'd'},
897 { "help", 0, NULL, 'h'}, 892 { "help", 0, NULL, 'h'},
898 { "version", 0, NULL, 'v'}, 893 { "version", 0, NULL, 'v'},
899 { "list", 0, NULL, 'l'}, 894 { "list", 0, NULL, 'l'},
900 { "sid", 1, NULL, 'i'}, 895 { "sid", 1, NULL, 'i'},
896 { "SID", 1, NULL, 'i'},
897 { "es", 1, NULL, 'e'},
898 { "ES", 1, NULL, 'e'},
901 {0, 0, NULL, 0} /* terminate */ 899 {0, 0, NULL, 0} /* terminate */
902 }; 900 };
903 901
904 boolean use_b25 = FALSE; 902 boolean use_b25 = FALSE;
905 boolean use_udp = FALSE; 903 boolean use_udp = FALSE;
911 sock_data *sockdata = NULL; 909 sock_data *sockdata = NULL;
912 char *device = NULL; 910 char *device = NULL;
913 int val; 911 int val;
914 char *voltage[] = {"0V", "11V", "15V"}; 912 char *voltage[] = {"0V", "11V", "15V"};
915 char *sid_list = NULL; 913 char *sid_list = NULL;
914 char *es_name_prefix = NULL;
916 915
917 while((result = getopt_long(argc, argv, "br:smn:ua:p:d:hvli:", 916 while((result = getopt_long(argc, argv, "br:smn:ua:p:d:hvli:",
918 long_options, &option_index)) != -1) { 917 long_options, &option_index)) != -1) {
919 switch(result) { 918 switch(result) {
920 case 'b': 919 case 'b':
988 break; 987 break;
989 case 'i': 988 case 'i':
990 use_splitter = TRUE; 989 use_splitter = TRUE;
991 sid_list = optarg; 990 sid_list = optarg;
992 break; 991 break;
992 case 'e':
993 es_name_prefix = optarg;
994 break;
993 } 995 }
994 } 996 }
995 997
996 if(argc - optind < 3) { 998 if(argc - optind < 3) {
997 if(argc - optind == 2 && use_udp) { 999 if(argc - optind == 2 && use_udp) {
1045 if(use_b25) { 1047 if(use_b25) {
1046 dec = b25_startup(&dopt); 1048 dec = b25_startup(&dopt);
1047 if(!dec) { 1049 if(!dec) {
1048 fprintf(stderr, "Cannot start b25 decoder\n"); 1050 fprintf(stderr, "Cannot start b25 decoder\n");
1049 fprintf(stderr, "Fall back to encrypted recording\n"); 1051 fprintf(stderr, "Fall back to encrypted recording\n");
1050 use_b25 = FALSE; 1052 use_b25 = 0;
1051 } 1053 }
1052 } 1054 }
1053 /* initialize splitter */ 1055 /* initialize splitter */
1054 if(use_splitter) { 1056 if(use_splitter)
1055 splitter = split_startup(sid_list); 1057 {
1056 if(splitter->sid_list == NULL) { 1058 splitter = split_startup(sid_list, es_name_prefix);
1059 if ( splitter->sid_list == NULL )
1060 {
1057 fprintf(stderr, "Cannot start TS splitter\n"); 1061 fprintf(stderr, "Cannot start TS splitter\n");
1058 return 1; 1062 return 1;
1059 } 1063 }
1060 } 1064 }
1061 1065