| 820 | } |
| 821 | |
| 822 | static int check_keyboard_interaction(int64_t cur_time) |
| 823 | { |
| 824 | int i, key; |
| 825 | static int64_t last_time; |
| 826 | /* read_key() returns 0 on EOF */ |
| 827 | if (cur_time - last_time >= 100000) { |
| 828 | key = read_key(); |
| 829 | last_time = cur_time; |
| 830 | }else |
| 831 | key = -1; |
| 832 | if (key == 'q') { |
| 833 | av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n"); |
| 834 | return AVERROR_EXIT; |
| 835 | } |
| 836 | if (key == '+') av_log_set_level(av_log_get_level()+10); |
| 837 | if (key == '-') av_log_set_level(av_log_get_level()-10); |
| 838 | if (key == 'c' || key == 'C'){ |
| 839 | char buf[4096], target[64], command[256], arg[256] = {0}; |
| 840 | double time; |
| 841 | int k, n = 0; |
| 842 | fprintf(stderr, "\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n"); |
| 843 | i = 0; |
| 844 | set_tty_echo(1); |
| 845 | while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1) |
| 846 | if (k > 0) |
| 847 | buf[i++] = k; |
| 848 | buf[i] = 0; |
| 849 | set_tty_echo(0); |
| 850 | fprintf(stderr, "\n"); |
| 851 | if (k > 0 && |
| 852 | (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) { |
| 853 | av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s", |
| 854 | target, time, command, arg); |
| 855 | for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { |
| 856 | if (ost->fg_simple) |
| 857 | fg_send_command(ost->fg_simple, time, target, command, arg, |
| 858 | key == 'C'); |
| 859 | } |
| 860 | for (i = 0; i < nb_filtergraphs; i++) |
| 861 | fg_send_command(filtergraphs[i], time, target, command, arg, |
| 862 | key == 'C'); |
| 863 | } else { |
| 864 | av_log(NULL, AV_LOG_ERROR, |
| 865 | "Parse error, at least 3 arguments were expected, " |
| 866 | "only %d given in string '%s'\n", n, buf); |
| 867 | } |
| 868 | } |
| 869 | if (key == '?'){ |
| 870 | fprintf(stderr, "key function\n" |
| 871 | "? show this help\n" |
| 872 | "+ increase verbosity\n" |
| 873 | "- decrease verbosity\n" |
| 874 | "c Send command to first matching filter supporting it\n" |
| 875 | "C Send/Queue command to all matching filters\n" |
| 876 | "h dump packets/hex press to cycle through the 3 states\n" |
| 877 | "q quit\n" |
| 878 | "s Show QP histogram\n" |
| 879 | ); |
no test coverage detected