mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
miracle_wfdctl: control flow and passing arguments with wfd_arg instead
of keep adding new structure fields
This commit is contained in:
parent
fadcceabd8
commit
6e48e1092a
3 changed files with 155 additions and 120 deletions
|
@ -30,12 +30,6 @@ struct wfd_out_session
|
||||||
struct wfd_session parent;
|
struct wfd_session parent;
|
||||||
struct wfd_sink *sink;
|
struct wfd_sink *sink;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
bool sink_has_video: 1;
|
|
||||||
bool sink_has_audio: 1;
|
|
||||||
bool sink_has_pref_disp_mode: 1;
|
|
||||||
bool sink_has_3d: 1;
|
|
||||||
bool sink_has_uibc: 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[];
|
static const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[];
|
||||||
|
@ -190,13 +184,13 @@ static void wfd_out_session_distruct(struct wfd_session *s)
|
||||||
|
|
||||||
static int wfd_out_session_initiate_request(struct wfd_session *s)
|
static int wfd_out_session_initiate_request(struct wfd_session *s)
|
||||||
{
|
{
|
||||||
return wfd_session_request(s, RTSP_M1_REQUEST_SINK_OPTIONS);
|
return wfd_session_request(s,
|
||||||
|
RTSP_M1_REQUEST_SINK_OPTIONS,
|
||||||
|
&(struct wfd_arg_list) wfd_arg_list(wfd_arg_cstr("SETUP")));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_handle_get_parameter_reply(struct wfd_session *s,
|
static int wfd_out_session_handle_get_parameter_reply(struct wfd_session *s,
|
||||||
struct rtsp_message *m,
|
struct rtsp_message *m)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
struct wfd_video_formats *vformats;
|
struct wfd_video_formats *vformats;
|
||||||
struct wfd_audio_codecs *acodecs;
|
struct wfd_audio_codecs *acodecs;
|
||||||
|
@ -254,12 +248,11 @@ static int wfd_out_session_handle_get_parameter_reply(struct wfd_session *s,
|
||||||
s->rtp_ports[1] = rtp_ports[1];
|
s->rtp_ports[1] = rtp_ports[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
*next_request = RTSP_M4_SET_PARAMETER;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_request_get_parameter(struct wfd_session *s,
|
static int wfd_out_session_request_get_parameter(struct wfd_session *s,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
struct rtsp_message **out)
|
struct rtsp_message **out)
|
||||||
{
|
{
|
||||||
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
||||||
|
@ -306,9 +299,7 @@ static bool find_strv(const char *str, char **strv)
|
||||||
|
|
||||||
static int wfd_out_session_handle_options_request(struct wfd_session *s,
|
static int wfd_out_session_handle_options_request(struct wfd_session *s,
|
||||||
struct rtsp_message *req,
|
struct rtsp_message *req,
|
||||||
struct rtsp_message **out_rep,
|
struct rtsp_message **out_rep)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
const char *require;
|
const char *require;
|
||||||
_rtsp_message_unref_ struct rtsp_message *rep = NULL;
|
_rtsp_message_unref_ struct rtsp_message *rep = NULL;
|
||||||
|
@ -344,15 +335,11 @@ static int wfd_out_session_handle_options_request(struct wfd_session *s,
|
||||||
*out_rep = rep;
|
*out_rep = rep;
|
||||||
rep = NULL;
|
rep = NULL;
|
||||||
|
|
||||||
*next_request = RTSP_M3_GET_PARAMETER;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_handle_options_reply(struct wfd_session *s,
|
static int wfd_out_session_handle_options_reply(struct wfd_session *s,
|
||||||
struct rtsp_message *m,
|
struct rtsp_message *m)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
const char *public;
|
const char *public;
|
||||||
|
@ -383,6 +370,7 @@ static int wfd_out_session_handle_options_reply(struct wfd_session *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_request_options(struct wfd_session *s,
|
static int wfd_out_session_request_options(struct wfd_session *s,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
struct rtsp_message **out)
|
struct rtsp_message **out)
|
||||||
{
|
{
|
||||||
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
||||||
|
@ -464,7 +452,7 @@ static int wfd_out_session_launch_gst(struct wfd_session *s, pid_t *out)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_sessoin_handle_gst_term(sd_event_source *source,
|
static int wfd_out_session_handle_gst_term(sd_event_source *source,
|
||||||
const siginfo_t *si,
|
const siginfo_t *si,
|
||||||
void *userdata)
|
void *userdata)
|
||||||
{
|
{
|
||||||
|
@ -482,9 +470,7 @@ static int wfd_out_sessoin_handle_gst_term(sd_event_source *source,
|
||||||
|
|
||||||
static int wfd_out_session_handle_play_request(struct wfd_session *s,
|
static int wfd_out_session_handle_play_request(struct wfd_session *s,
|
||||||
struct rtsp_message *req,
|
struct rtsp_message *req,
|
||||||
struct rtsp_message **out_rep,
|
struct rtsp_message **out_rep)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
_shl_free_ char *v;
|
_shl_free_ char *v;
|
||||||
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
||||||
|
@ -522,7 +508,7 @@ static int wfd_out_session_handle_play_request(struct wfd_session *s,
|
||||||
r = sd_event_add_child(ctl_wfd_get_loop(),
|
r = sd_event_add_child(ctl_wfd_get_loop(),
|
||||||
NULL,
|
NULL,
|
||||||
gst, WEXITED,
|
gst, WEXITED,
|
||||||
wfd_out_sessoin_handle_gst_term,
|
wfd_out_session_handle_gst_term,
|
||||||
s);
|
s);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
kill(gst, SIGKILL);
|
kill(gst, SIGKILL);
|
||||||
|
@ -535,16 +521,14 @@ static int wfd_out_session_handle_play_request(struct wfd_session *s,
|
||||||
*out_rep = m;
|
*out_rep = m;
|
||||||
m = NULL;
|
m = NULL;
|
||||||
|
|
||||||
*new_state = WFD_SESSION_STATE_PLAYING;
|
/**new_state = WFD_SESSION_STATE_PLAYING;*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_handle_setup_request(struct wfd_session *s,
|
static int wfd_out_session_handle_setup_request(struct wfd_session *s,
|
||||||
struct rtsp_message *req,
|
struct rtsp_message *req,
|
||||||
struct rtsp_message **out_rep,
|
struct rtsp_message **out_rep)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
const char *l;
|
const char *l;
|
||||||
|
@ -610,52 +594,42 @@ static int wfd_out_session_handle_setup_request(struct wfd_session *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_request_trigger(struct wfd_session *s,
|
static int wfd_out_session_request_trigger(struct wfd_session *s,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
struct rtsp_message **out)
|
struct rtsp_message **out)
|
||||||
{
|
{
|
||||||
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
const char *method;
|
||||||
|
|
||||||
switch(wfd_session_get_state(s)) {
|
assert(args);
|
||||||
case WFD_SESSION_STATE_ESTABLISHED:
|
|
||||||
r = rtsp_message_new_request(s->rtsp,
|
|
||||||
&m,
|
|
||||||
"SET_PARAMETER",
|
|
||||||
wfd_session_get_stream_url(s));
|
|
||||||
if(0 > r) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = rtsp_message_append(m, "{<s>}",
|
wfd_arg_list_get(args, 0, &method);
|
||||||
"wfd_trigger_method",
|
|
||||||
"SETUP");
|
assert(method);
|
||||||
if(0 > r) {
|
|
||||||
return r;
|
r = rtsp_message_new_request(s->rtsp,
|
||||||
}
|
&m,
|
||||||
break;
|
"SET_PARAMETER",
|
||||||
default:
|
wfd_session_get_stream_url(s));
|
||||||
break;
|
if(0 > r) {
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m) {
|
r = rtsp_message_append(m, "{<s>}",
|
||||||
*out = m;
|
"wfd_trigger_method",
|
||||||
m = NULL;
|
method);
|
||||||
|
if(0 > r) {
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
*out = m;
|
||||||
}
|
m = NULL;
|
||||||
|
|
||||||
static int wfd_out_session_handle_set_parameter_reply(struct wfd_session *s,
|
|
||||||
struct rtsp_message *m,
|
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
|
||||||
*new_state = WFD_SESSION_STATE_ESTABLISHED;
|
|
||||||
*next_request = RTSP_M5_TRIGGER;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_out_session_request_set_parameter(struct wfd_session *s,
|
static int wfd_out_session_request_set_parameter(struct wfd_session *s,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
struct rtsp_message **out)
|
struct rtsp_message **out)
|
||||||
{
|
{
|
||||||
_rtsp_message_unref_ struct rtsp_message *m;
|
_rtsp_message_unref_ struct rtsp_message *m;
|
||||||
|
@ -715,20 +689,45 @@ const struct wfd_session_vtable session_vtables[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[] = {
|
static const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[] = {
|
||||||
[RTSP_M1_REQUEST_SINK_OPTIONS] = {
|
[RTSP_M1_REQUEST_SINK_OPTIONS] = {
|
||||||
.request = wfd_out_session_request_options,
|
.request = wfd_out_session_request_options,
|
||||||
.handle_reply = wfd_out_session_handle_options_reply
|
.handle_reply = wfd_out_session_handle_options_reply
|
||||||
},
|
},
|
||||||
[RTSP_M2_REQUEST_SRC_OPTIONS] = {
|
[RTSP_M2_REQUEST_SRC_OPTIONS] = {
|
||||||
.handle_request = wfd_out_session_handle_options_request
|
.handle_request = wfd_out_session_handle_options_request,
|
||||||
|
.rule = wfd_arg_list(
|
||||||
|
wfd_arg_dict(
|
||||||
|
wfd_arg_u(WFD_SESSION_ARG_NEXT_REQUEST),
|
||||||
|
wfd_arg_u(RTSP_M3_GET_PARAMETER)
|
||||||
|
),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
[RTSP_M3_GET_PARAMETER] = {
|
[RTSP_M3_GET_PARAMETER] = {
|
||||||
.request = wfd_out_session_request_get_parameter,
|
.request = wfd_out_session_request_get_parameter,
|
||||||
.handle_reply = wfd_out_session_handle_get_parameter_reply
|
.handle_reply = wfd_out_session_handle_get_parameter_reply,
|
||||||
|
.rule = wfd_arg_list(
|
||||||
|
wfd_arg_dict(
|
||||||
|
wfd_arg_u(WFD_SESSION_ARG_NEXT_REQUEST),
|
||||||
|
wfd_arg_u(RTSP_M4_SET_PARAMETER)
|
||||||
|
),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
[RTSP_M4_SET_PARAMETER] = {
|
[RTSP_M4_SET_PARAMETER] = {
|
||||||
.request = wfd_out_session_request_set_parameter,
|
.request = wfd_out_session_request_set_parameter,
|
||||||
.handle_reply = wfd_out_session_handle_set_parameter_reply
|
.rule = wfd_arg_list(
|
||||||
|
wfd_arg_dict(
|
||||||
|
wfd_arg_u(WFD_SESSION_ARG_NEXT_REQUEST),
|
||||||
|
wfd_arg_u(RTSP_M5_TRIGGER)
|
||||||
|
),
|
||||||
|
wfd_arg_dict(
|
||||||
|
wfd_arg_u(WFD_SESSION_ARG_NEW_STATE),
|
||||||
|
wfd_arg_u(WFD_SESSION_STATE_ESTABLISHED)
|
||||||
|
),
|
||||||
|
wfd_arg_dict(
|
||||||
|
wfd_arg_u(WFD_SESSION_ARG_REQUEST_ARGS),
|
||||||
|
wfd_arg_arg_list(wfd_arg_cstr("SETUP"))
|
||||||
|
),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
[RTSP_M5_TRIGGER] = {
|
[RTSP_M5_TRIGGER] = {
|
||||||
.request = wfd_out_session_request_trigger,
|
.request = wfd_out_session_request_trigger,
|
||||||
|
@ -758,3 +757,10 @@ static const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[] = {
|
||||||
[RTSP_M16_KEEPALIVE] = {
|
[RTSP_M16_KEEPALIVE] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern const struct rtsp_dispatch_entry out_session_rtsp_disp_tbl[];
|
||||||
|
|
||||||
static inline int wfd_session_do_request(struct wfd_session *s,
|
static inline int wfd_session_do_request(struct wfd_session *s,
|
||||||
enum rtsp_message_id id,
|
enum rtsp_message_id id,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
struct rtsp_message **out)
|
struct rtsp_message **out)
|
||||||
{
|
{
|
||||||
if(!rtsp_message_id_is_valid(id)) {
|
if(!rtsp_message_id_is_valid(id)) {
|
||||||
|
@ -46,15 +47,13 @@ static inline int wfd_session_do_request(struct wfd_session *s,
|
||||||
}
|
}
|
||||||
assert(s->rtsp_disp_tbl[id].request);
|
assert(s->rtsp_disp_tbl[id].request);
|
||||||
|
|
||||||
return (*s->rtsp_disp_tbl[id].request)(s, out);
|
return (*s->rtsp_disp_tbl[id].request)(s, args, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wfd_session_do_handle_request(struct wfd_session *s,
|
static inline int wfd_session_do_handle_request(struct wfd_session *s,
|
||||||
enum rtsp_message_id id,
|
enum rtsp_message_id id,
|
||||||
struct rtsp_message *req,
|
struct rtsp_message *req,
|
||||||
struct rtsp_message **out_rep,
|
struct rtsp_message **out_rep)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
if(!rtsp_message_id_is_valid(id)) {
|
if(!rtsp_message_id_is_valid(id)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -63,16 +62,12 @@ static inline int wfd_session_do_handle_request(struct wfd_session *s,
|
||||||
|
|
||||||
return (*s->rtsp_disp_tbl[id].handle_request)(s,
|
return (*s->rtsp_disp_tbl[id].handle_request)(s,
|
||||||
req,
|
req,
|
||||||
out_rep,
|
out_rep);
|
||||||
new_state,
|
|
||||||
next_request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wfd_session_do_handle_reply(struct wfd_session *s,
|
static inline int wfd_session_do_handle_reply(struct wfd_session *s,
|
||||||
enum rtsp_message_id id,
|
enum rtsp_message_id id,
|
||||||
struct rtsp_message *m,
|
struct rtsp_message *m)
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request)
|
|
||||||
{
|
{
|
||||||
if(!rtsp_message_id_is_valid(id)) {
|
if(!rtsp_message_id_is_valid(id)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -82,7 +77,7 @@ static inline int wfd_session_do_handle_reply(struct wfd_session *s,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*s->rtsp_disp_tbl[id].handle_reply)(s, m, new_state, next_request);
|
return (*s->rtsp_disp_tbl[id].handle_reply)(s, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t wfd_session_get_id(struct wfd_session *s)
|
uint64_t wfd_session_get_id(struct wfd_session *s)
|
||||||
|
@ -292,14 +287,51 @@ static enum rtsp_message_id wfd_session_message_to_id(struct wfd_session *s,
|
||||||
return RTSP_M_UNKNOWN;
|
return RTSP_M_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wfd_session_post_handle_request_n_reply(struct wfd_session *s,
|
||||||
|
enum rtsp_message_id ror)
|
||||||
|
{
|
||||||
|
const struct wfd_arg_list *args = &s->rtsp_disp_tbl[ror].rule;
|
||||||
|
enum rtsp_message_id next_request = RTSP_M_UNKNOWN;
|
||||||
|
enum wfd_session_arg_id arg_id;
|
||||||
|
enum wfd_session_state new_state;
|
||||||
|
const struct wfd_arg_list *req_args;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(!args->len) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < args->len; i ++) {
|
||||||
|
wfd_arg_list_get_dictk(args, i, &arg_id);
|
||||||
|
switch(arg_id) {
|
||||||
|
case WFD_SESSION_ARG_NEXT_REQUEST:
|
||||||
|
wfd_arg_list_get_dictv(args, i, &next_request);
|
||||||
|
break;
|
||||||
|
case WFD_SESSION_ARG_NEW_STATE:
|
||||||
|
wfd_arg_list_get_dictv(args, i, &new_state);
|
||||||
|
wfd_session_set_state(s, new_state);
|
||||||
|
break;
|
||||||
|
case WFD_SESSION_ARG_REQUEST_ARGS:
|
||||||
|
wfd_arg_list_get_dictv(args, i, &req_args);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RTSP_M_UNKNOWN != next_request) {
|
||||||
|
return wfd_session_request(s, next_request, req_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int wfd_session_handle_request(struct rtsp *bus,
|
static int wfd_session_handle_request(struct rtsp *bus,
|
||||||
struct rtsp_message *m,
|
struct rtsp_message *m,
|
||||||
void *userdata)
|
void *userdata)
|
||||||
{
|
{
|
||||||
_rtsp_message_unref_ struct rtsp_message *rep = NULL;
|
_rtsp_message_unref_ struct rtsp_message *rep = NULL;
|
||||||
struct wfd_session *s = userdata;
|
struct wfd_session *s = userdata;
|
||||||
enum rtsp_message_id id, next_request = RTSP_M_UNKNOWN;
|
enum rtsp_message_id id;
|
||||||
enum wfd_session_state new_state = WFD_SESSION_STATE_NULL;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
id = wfd_session_message_to_id(s, m);
|
id = wfd_session_message_to_id(s, m);
|
||||||
|
@ -315,9 +347,7 @@ static int wfd_session_handle_request(struct rtsp *bus,
|
||||||
r = wfd_session_do_handle_request(s,
|
r = wfd_session_do_handle_request(s,
|
||||||
id,
|
id,
|
||||||
m,
|
m,
|
||||||
&rep,
|
&rep);
|
||||||
&new_state,
|
|
||||||
&next_request);
|
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -336,15 +366,9 @@ static int wfd_session_handle_request(struct rtsp *bus,
|
||||||
id,
|
id,
|
||||||
(char *) rtsp_message_get_raw(rep));
|
(char *) rtsp_message_get_raw(rep));
|
||||||
|
|
||||||
if(WFD_SESSION_STATE_NULL != new_state) {
|
r = wfd_session_post_handle_request_n_reply(s, id);
|
||||||
wfd_session_set_state(s, new_state);
|
if(0 > r) {
|
||||||
}
|
goto error;
|
||||||
|
|
||||||
if(rtsp_message_id_is_valid(next_request)) {
|
|
||||||
r = wfd_session_request(s, next_request);
|
|
||||||
if(0 > r) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -363,8 +387,6 @@ static int wfd_session_handle_reply(struct rtsp *bus,
|
||||||
int r;
|
int r;
|
||||||
enum rtsp_message_id id;
|
enum rtsp_message_id id;
|
||||||
struct wfd_session *s = userdata;
|
struct wfd_session *s = userdata;
|
||||||
enum wfd_session_state new_state = WFD_SESSION_STATE_NULL;
|
|
||||||
enum rtsp_message_id next_request = RTSP_M_UNKNOWN;
|
|
||||||
|
|
||||||
if(!m) {
|
if(!m) {
|
||||||
r = 0;
|
r = 0;
|
||||||
|
@ -383,20 +405,14 @@ static int wfd_session_handle_reply(struct rtsp *bus,
|
||||||
id,
|
id,
|
||||||
(char *) rtsp_message_get_raw(m));
|
(char *) rtsp_message_get_raw(m));
|
||||||
|
|
||||||
r = wfd_session_do_handle_reply(s, id, m, &new_state, &next_request);
|
r = wfd_session_do_handle_reply(s, id, m);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(WFD_SESSION_STATE_NULL != new_state) {
|
r = wfd_session_post_handle_request_n_reply(s, id);
|
||||||
wfd_session_set_state(s, new_state);
|
if(0 > r) {
|
||||||
}
|
goto error;
|
||||||
|
|
||||||
if(rtsp_message_id_is_valid(next_request)) {
|
|
||||||
r = wfd_session_request(s, next_request);
|
|
||||||
if(0 > r) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -406,14 +422,16 @@ error:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wfd_session_request(struct wfd_session *s, enum rtsp_message_id id)
|
int wfd_session_request(struct wfd_session *s,
|
||||||
|
enum rtsp_message_id id,
|
||||||
|
const struct wfd_arg_list *args)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
_rtsp_message_unref_ struct rtsp_message *m = NULL;
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
r = wfd_session_do_request(s, id, &m);
|
r = wfd_session_do_request(s, id, args, &m);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with MiracleCast; If not, see <http://www.gnu.org/licenses/>.
|
* along with MiracleCast; If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef MIRACLE_OUT_SESSION_H
|
|
||||||
#define MIRACLE_OUT_SESSION_H
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ctl.h"
|
#include "ctl.h"
|
||||||
|
#include "wfd-arg.h"
|
||||||
|
|
||||||
|
#ifndef CTL_WFD_SESSION_H
|
||||||
|
#define CTL_WFD_SESSION_H
|
||||||
|
|
||||||
#define wfd_out_session(s) (assert(wfd_is_out_session(s)), (struct wfd_out_session *) (s))
|
#define wfd_out_session(s) (assert(wfd_is_out_session(s)), (struct wfd_out_session *) (s))
|
||||||
#define wfd_in_session(s) (assert(wfd_is_in_session(s)), (struct wfd_in_session *) (s))
|
#define wfd_in_session(s) (assert(wfd_is_in_session(s)), (struct wfd_in_session *) (s))
|
||||||
|
@ -58,20 +59,26 @@ enum wfd_stream_id
|
||||||
WFD_STREAM_ID_SECONDARY,
|
WFD_STREAM_ID_SECONDARY,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum wfd_session_arg_id
|
||||||
|
{
|
||||||
|
WFD_SESSION_ARG_NEXT_REQUEST,
|
||||||
|
WFD_SESSION_ARG_NEW_STATE,
|
||||||
|
WFD_SESSION_ARG_REQUEST_ARGS,
|
||||||
|
};
|
||||||
|
|
||||||
struct rtsp_dispatch_entry
|
struct rtsp_dispatch_entry
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
int (*request)(struct wfd_session *s, struct rtsp_message **out);
|
int (*request)(struct wfd_session *s,
|
||||||
|
const struct wfd_arg_list *args,
|
||||||
|
struct rtsp_message **out);
|
||||||
int (*handle_request)(struct wfd_session *s,
|
int (*handle_request)(struct wfd_session *s,
|
||||||
struct rtsp_message *req,
|
struct rtsp_message *req,
|
||||||
struct rtsp_message **out_rep,
|
struct rtsp_message **out_rep);
|
||||||
enum wfd_session_state *new_state,
|
|
||||||
enum rtsp_message_id *next_request);
|
|
||||||
};
|
};
|
||||||
int (*handle_reply)(struct wfd_session *s,
|
int (*handle_reply)(struct wfd_session *s,
|
||||||
struct rtsp_message *m,
|
struct rtsp_message *m);
|
||||||
enum wfd_session_state *new_state,
|
struct wfd_arg_list rule;
|
||||||
enum rtsp_message_id *next_request);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wfd_session_vtable
|
struct wfd_session_vtable
|
||||||
|
@ -107,11 +114,15 @@ struct wfd_session
|
||||||
};
|
};
|
||||||
|
|
||||||
int wfd_session_init(struct wfd_session *s);
|
int wfd_session_init(struct wfd_session *s);
|
||||||
const char * rtsp_message_id_to_string(enum rtsp_message_id id);
|
|
||||||
struct wfd_sink * wfd_out_session_get_sink(struct wfd_session *s);
|
|
||||||
int wfd_session_request(struct wfd_session *s, enum rtsp_message_id id);
|
|
||||||
int wfd_session_gen_stream_url(struct wfd_session *s,
|
int wfd_session_gen_stream_url(struct wfd_session *s,
|
||||||
const char *local_addr,
|
const char *local_addr,
|
||||||
enum wfd_stream_id id);
|
enum wfd_stream_id id);
|
||||||
|
int wfd_session_request(struct wfd_session *s,
|
||||||
|
enum rtsp_message_id id,
|
||||||
|
const struct wfd_arg_list *args);
|
||||||
|
|
||||||
#endif /* MIRACLE_OUT_SESSION_H */
|
struct wfd_sink * wfd_out_session_get_sink(struct wfd_session *s);
|
||||||
|
|
||||||
|
const char * rtsp_message_id_to_string(enum rtsp_message_id id);
|
||||||
|
|
||||||
|
#endif /* CTL_WFD_SESSION_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue