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

ctl: save wfd_presentation_URL from M4

M6 M7 messages should use URL from wfd_presentation_URL of M4. Parse it
during set_parameter and use it in further requests instead of a
hard-coded URL.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
Andrey Gusakov 2014-06-27 06:11:06 +04:00 committed by David Herrmann
parent 40484a022a
commit 60e2254e9e

View file

@ -41,6 +41,7 @@ struct ctl_sink {
char *target; char *target;
char *session; char *session;
char *url;
struct sockaddr_storage addr; struct sockaddr_storage addr;
size_t addr_size; size_t addr_size;
int fd; int fd;
@ -159,7 +160,7 @@ static int sink_setup_fn(struct rtsp *bus, struct rtsp_message *m, void *data)
r = rtsp_message_new_request(s->rtsp, r = rtsp_message_new_request(s->rtsp,
&rep, &rep,
"PLAY", "PLAY",
"rtsp://localhost/wfd1.0/streamid=0"); s->url);
if (r < 0) if (r < 0)
return cli_ERR(r); return cli_ERR(r);
@ -182,6 +183,8 @@ static void sink_handle_set_parameter(struct ctl_sink *s,
{ {
_rtsp_message_unref_ struct rtsp_message *rep = NULL; _rtsp_message_unref_ struct rtsp_message *rep = NULL;
const char *trigger; const char *trigger;
const char *url;
char *nu;
int r; int r;
r = rtsp_message_new_reply_for(m, &rep, 200, NULL); r = rtsp_message_new_reply_for(m, &rep, 200, NULL);
@ -198,15 +201,35 @@ static void sink_handle_set_parameter(struct ctl_sink *s,
rtsp_message_unref(rep); rtsp_message_unref(rep);
rep = NULL; rep = NULL;
/* M4 (or any other) can pass presentation URLs */
r = rtsp_message_read(m, "{<s>}", "wfd_presentation_URL", &url);
if (r >= 0) {
if (!s->url || strcmp(s->url, url)) {
nu = strdup(url);
if (!nu)
return cli_vENOMEM();
free(s->url);
s->url = nu;
cli_debug("Got URL: %s\n", s->url);
}
}
/* M5 */
r = rtsp_message_read(m, "{<s>}", "wfd_trigger_method", &trigger); r = rtsp_message_read(m, "{<s>}", "wfd_trigger_method", &trigger);
if (r < 0) if (r < 0)
return; return;
if (!strcmp(trigger, "SETUP")) { if (!strcmp(trigger, "SETUP")) {
if (!s->url) {
cli_error("No valid wfd_presentation_URL\n");
return;
}
r = rtsp_message_new_request(s->rtsp, r = rtsp_message_new_request(s->rtsp,
&rep, &rep,
"SETUP", "SETUP",
"rtsp://localhost/wfd1.0/streamid=0"); s->url);
if (r < 0) if (r < 0)
return cli_vERR(r); return cli_vERR(r);
@ -433,6 +456,7 @@ void ctl_sink_free(struct ctl_sink *s)
ctl_sink_close(s); ctl_sink_close(s);
free(s->target); free(s->target);
free(s->session); free(s->session);
free(s->url);
sd_event_unref(s->event); sd_event_unref(s->event);
free(s); free(s);
} }