mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
ctl: divide M6 (SETUP) and M7 (PLAY) stages
In M7 message session ID should be included. Session ID is returned in M6 response. So we should wait for M6 response. Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
67de17a511
commit
40484a022a
1 changed files with 45 additions and 18 deletions
|
@ -40,6 +40,7 @@ struct ctl_sink {
|
||||||
sd_event *event;
|
sd_event *event;
|
||||||
|
|
||||||
char *target;
|
char *target;
|
||||||
|
char *session;
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
size_t addr_size;
|
size_t addr_size;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -134,6 +135,48 @@ static void sink_handle_get_parameter(struct ctl_sink *s,
|
||||||
return cli_vERR(r);
|
return cli_vERR(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sink_setup_fn(struct rtsp *bus, struct rtsp_message *m, void *data)
|
||||||
|
{
|
||||||
|
_rtsp_message_unref_ struct rtsp_message *rep = NULL;
|
||||||
|
struct ctl_sink *s = data;
|
||||||
|
const char *session;
|
||||||
|
char *ns;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
cli_debug("INCOMING: %s\n", rtsp_message_get_raw(m));
|
||||||
|
|
||||||
|
r = rtsp_message_read(m, "<s>", "Session", &session);
|
||||||
|
if (r < 0)
|
||||||
|
return cli_ERR(r);
|
||||||
|
|
||||||
|
ns = strdup(session);
|
||||||
|
if (!ns)
|
||||||
|
return cli_ENOMEM();
|
||||||
|
|
||||||
|
free(s->session);
|
||||||
|
s->session = ns;
|
||||||
|
|
||||||
|
r = rtsp_message_new_request(s->rtsp,
|
||||||
|
&rep,
|
||||||
|
"PLAY",
|
||||||
|
"rtsp://localhost/wfd1.0/streamid=0");
|
||||||
|
if (r < 0)
|
||||||
|
return cli_ERR(r);
|
||||||
|
|
||||||
|
r = rtsp_message_append(rep, "<s>", "Session", s->session);
|
||||||
|
if (r < 0)
|
||||||
|
return cli_ERR(r);
|
||||||
|
|
||||||
|
rtsp_message_seal(rep);
|
||||||
|
cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep));
|
||||||
|
|
||||||
|
r = rtsp_call_async(s->rtsp, rep, sink_req_fn, NULL, 0, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return cli_ERR(r);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void sink_handle_set_parameter(struct ctl_sink *s,
|
static void sink_handle_set_parameter(struct ctl_sink *s,
|
||||||
struct rtsp_message *m)
|
struct rtsp_message *m)
|
||||||
{
|
{
|
||||||
|
@ -176,24 +219,7 @@ static void sink_handle_set_parameter(struct ctl_sink *s,
|
||||||
rtsp_message_seal(rep);
|
rtsp_message_seal(rep);
|
||||||
cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep));
|
cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep));
|
||||||
|
|
||||||
r = rtsp_call_async(s->rtsp, rep, sink_req_fn, NULL, 0, NULL);
|
r = rtsp_call_async(s->rtsp, rep, sink_setup_fn, s, 0, NULL);
|
||||||
if (r < 0)
|
|
||||||
return cli_vERR(r);
|
|
||||||
|
|
||||||
rtsp_message_unref(rep);
|
|
||||||
rep = NULL;
|
|
||||||
|
|
||||||
r = rtsp_message_new_request(s->rtsp,
|
|
||||||
&rep,
|
|
||||||
"PLAY",
|
|
||||||
"rtsp://localhost/wfd1.0/streamid=0");
|
|
||||||
if (r < 0)
|
|
||||||
return cli_vERR(r);
|
|
||||||
|
|
||||||
rtsp_message_seal(rep);
|
|
||||||
cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep));
|
|
||||||
|
|
||||||
r = rtsp_call_async(s->rtsp, rep, sink_req_fn, NULL, 0, NULL);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return cli_vERR(r);
|
return cli_vERR(r);
|
||||||
}
|
}
|
||||||
|
@ -406,6 +432,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);
|
||||||
sd_event_unref(s->event);
|
sd_event_unref(s->event);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue