1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

Check source UIBC capability

If source has no UIBC capability don't try to connect UIBC controller,
and listen UIBC setting to disable UIBC

relates to #115
This commit is contained in:
albfan 2016-10-23 00:30:19 +02:00
parent 5e93ad0638
commit 472fbf4a24
3 changed files with 39 additions and 31 deletions

View file

@ -122,7 +122,7 @@ static void sink_handle_get_parameter(struct ctl_sink *s,
} }
/* wfd_uibc_capability */ /* wfd_uibc_capability */
if (rtsp_message_read(m, "{<>}", "wfd_uibc_capability") >= 0 && uibc) { if (rtsp_message_read(m, "{<>}", "wfd_uibc_capability") >= 0 && uibc_option) {
char wfd_uibc_capability[512]; char wfd_uibc_capability[512];
sprintf(wfd_uibc_capability, sprintf(wfd_uibc_capability,
"wfd_uibc_capability: input_category_list=GENERIC;" "wfd_uibc_capability: input_category_list=GENERIC;"
@ -258,16 +258,22 @@ static void sink_handle_set_parameter(struct ctl_sink *s,
free(s->uibc_config); free(s->uibc_config);
s->uibc_config = nu; s->uibc_config = nu;
char* token = strtok(uibc_config, ";"); if (!strcasecmp(uibc_config, "none")) {
uibc_enabled = false;
} else {
char* token = strtok(uibc_config, ";");
while (token) { while (token) {
if (sscanf(token, "port=%d", &uibc_port)) { if (sscanf(token, "port=%d", &uibc_port)) {
break; log_debug("UIBC port: %d\n", uibc_port);
} if (uibc_option) {
token = strtok(0, ";"); uibc_enabled = true;
} }
break;
cli_debug("Got URL: %s\n", s->url); }
token = strtok(0, ";");
}
}
} }
} }

View file

@ -40,7 +40,8 @@
#include "wfd.h" #include "wfd.h"
extern int rstp_port; extern int rstp_port;
extern bool uibc; extern bool uibc_option;
extern bool uibc_enabled;
extern int uibc_port; extern int uibc_port;
struct ctl_sink { struct ctl_sink {

View file

@ -59,7 +59,8 @@ void launch_player(struct ctl_sink *s);
char *gst_scale_res; char *gst_scale_res;
int gst_audio_en = 1; int gst_audio_en = 1;
static const int DEFAULT_RSTP_PORT = 1991; static const int DEFAULT_RSTP_PORT = 1991;
bool uibc; bool uibc_option;
bool uibc_enabled;
int rstp_port; int rstp_port;
int uibc_port; int uibc_port;
@ -388,14 +389,14 @@ void launch_player(struct ctl_sink *s) {
char uibc_portStr[64]; char uibc_portStr[64];
int i = 0; int i = 0;
char* player; char* player;
if (uibc) { if (uibc_enabled) {
player = "uibc-viewer"; player = "uibc-viewer";
} else { } else {
player = "miracle-gst"; player = "miracle-gst";
} }
argv[i++] = player; argv[i++] = player;
if (uibc) { if (uibc_enabled) {
argv[i++] = s->target; argv[i++] = s->target;
sprintf(uibc_portStr, "%d", uibc_port); sprintf(uibc_portStr, "%d", uibc_port);
argv[i++] = uibc_portStr; argv[i++] = uibc_portStr;
@ -420,29 +421,28 @@ void launch_player(struct ctl_sink *s) {
argv[i] = NULL; argv[i] = NULL;
i = 0; i = 0;
int size = 0; int size = 0;
while (argv[i]) { while (argv[i]) {
size += strlen(argv[i++] + 1); size += strlen(argv[i++] + 1);
} }
char* player_command = malloc(size); char* player_command = malloc(size);
i = 0; i = 0;
strcpy(player_command, argv[i++]); strcpy(player_command, argv[i++]);
while (argv[i]) { while (argv[i]) {
strcat(player_command, " "); strcat(player_command, " ");
strcat(player_command, argv[i++]); strcat(player_command, argv[i++]);
} }
log_debug("player command: %s", player_command); log_debug("player command: %s", player_command);
//free(player_command); if (execvpe(argv[0], argv, environ) < 0) {
if (execvpe(argv[0], argv, environ) < 0) { cli_debug("stream player failed (%d): %m", errno);
cli_debug("stream player failed (%d): %m", errno); int i = 0;
int i = 0; cli_debug("printing environment: ");
cli_debug("printing environment: "); while (environ[i]) {
while (environ[i]) { cli_debug("%s", environ[i++]);
cli_debug("%s", environ[i++]); }
} }
}
} }
void launch_uibc_daemon(int port) { void launch_uibc_daemon(int port) {
@ -771,7 +771,8 @@ static int parse_argv(int argc, char *argv[])
}; };
int c; int c;
uibc = false; uibc_option = false;
uibc_enabled = false;
rstp_port = DEFAULT_RSTP_PORT; rstp_port = DEFAULT_RSTP_PORT;
while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) {
@ -803,7 +804,7 @@ static int parse_argv(int argc, char *argv[])
rstp_port = atoi(optarg); rstp_port = atoi(optarg);
break; break;
case ARG_UIBC: case ARG_UIBC:
uibc = true; uibc_option = true;
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;