1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-12 15:31:56 +00:00

simplify pass request options

This commit is contained in:
Alberto Fanjul 2022-05-26 20:55:51 +02:00
parent 3ab7d5913f
commit c42624885b
2 changed files with 31 additions and 39 deletions

View file

@ -87,50 +87,26 @@ static void sink_handle_get_parameter(struct ctl_sink *s,
return cli_vERR(r);
/* wfd_content_protection */
if (rtsp_message_read(m, "{<>}", "wfd_content_protection") >= 0) {
r = rtsp_message_append(rep, "{&}",
"wfd_content_protection: none");
if (r < 0)
return cli_vERR(r);
}
check_and_response_option("wfd_content_protection", "none");
/* wfd_video_formats */
if (rtsp_message_read(m, "{<>}", "wfd_video_formats") >= 0) {
char wfd_video_formats[128];
sprintf(wfd_video_formats,
"wfd_video_formats: 00 00 03 10 %08x %08x %08x 00 0000 0000 10 none none",
sprintf(wfd_video_formats, "00 00 03 10 %08x %08x %08x 00 0000 0000 10 none none",
s->resolutions_cea, s->resolutions_vesa, s->resolutions_hh);
r = rtsp_message_append(rep, "{&}", wfd_video_formats);
if (r < 0)
return cli_vERR(r);
}
check_and_response_option("wfd_video_formats", wfd_video_formats);
/* wfd_audio_codecs */
if (rtsp_message_read(m, "{<>}", "wfd_audio_codecs") >= 0) {
r = rtsp_message_append(rep, "{&}",
"wfd_audio_codecs: AAC 00000007 00");
if (r < 0)
return cli_vERR(r);
}
check_and_response_option("wfd_audio_codecs", "AAC 00000007 00");
/* wfd_client_rtp_ports */
if (rtsp_message_read(m, "{<>}", "wfd_client_rtp_ports") >= 0) {
char wfd_client_rtp_ports[128];
sprintf(wfd_client_rtp_ports,
"wfd_client_rtp_ports: RTP/AVP/UDP;unicast %d 0 mode=play", rstp_port);
r = rtsp_message_append(rep, "{&}",
wfd_client_rtp_ports);
if (r < 0)
return cli_vERR(r);
}
sprintf(wfd_client_rtp_ports, "RTP/AVP/UDP;unicast %d 0 mode=play", rstp_port);
check_and_response_option("wfd_client_rtp_ports", wfd_client_rtp_ports);
/* wfd_uibc_capability */
if (rtsp_message_read(m, "{<>}", "wfd_uibc_capability") >= 0 && uibc_option) {
char wfd_uibc_capability[512];
sprintf(wfd_uibc_capability,
"wfd_uibc_capability: input_category_list=GENERIC;"
if (uibc_option) {
check_and_response_option("wfd_uibc_capability",
"input_category_list=GENERIC;"
"generic_cap_list=Mouse,SingleTouch;"
"hidc_cap_list=none;port=none");
r = rtsp_message_append(rep, "{&}", wfd_uibc_capability);
if (r < 0)
return cli_vERR(r);
"hidc_cap_list=none;"
"port=none");
}
rtsp_message_seal(rep);
cli_debug("OUTGOING: %s\n", rtsp_message_get_raw(rep));
@ -140,6 +116,10 @@ static void sink_handle_get_parameter(struct ctl_sink *s,
return cli_vERR(r);
}
bool check_rtsp_option(struct rtsp_message *m, char *option) {
return rtsp_message_read(m, "{<>}", option) >= 0;
}
static int sink_setup_fn(struct rtsp *bus, struct rtsp_message *m, void *data)
{
_rtsp_message_unref_ struct rtsp_message *rep = NULL;

View file

@ -70,4 +70,16 @@ struct ctl_sink {
int vres;
};
bool check_rtsp_option(struct rtsp_message *m, char *option);
#define check_and_response_option(option, response) \
if (check_rtsp_option(m, option)) { \
char option_response[512]; \
sprintf(option_response, "%s: %s", option, response); \
r = rtsp_message_append(rep, "{&}", option_response); \
if (r < 0) {\
return cli_vERR(r); \
} \
}
#endif /* CTL_SINK_H */