mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
miraclw-wfdctl: now you can cast only specified xid or xname to sink
This commit is contained in:
parent
88cf463cae
commit
720f2a1d91
1 changed files with 57 additions and 29 deletions
|
@ -48,6 +48,8 @@ struct wfd_out_session
|
||||||
enum wfd_display_type display_type;
|
enum wfd_display_type display_type;
|
||||||
char *authority;
|
char *authority;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
|
const char *display_param_name;
|
||||||
|
const char *display_param_value;
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
uint16_t width;
|
uint16_t width;
|
||||||
|
@ -73,7 +75,9 @@ int wfd_out_session_new(struct wfd_session **out,
|
||||||
{
|
{
|
||||||
_shl_free_ char *display_schema = NULL;
|
_shl_free_ char *display_schema = NULL;
|
||||||
_shl_free_ char *display_name = NULL;
|
_shl_free_ char *display_name = NULL;
|
||||||
|
char *display_param;
|
||||||
_wfd_session_free_ struct wfd_session *s;
|
_wfd_session_free_ struct wfd_session *s;
|
||||||
|
struct wfd_out_session *os;
|
||||||
enum wfd_display_type display_type;
|
enum wfd_display_type display_type;
|
||||||
enum wfd_resolution_standard std;
|
enum wfd_resolution_standard std;
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
|
@ -93,6 +97,11 @@ int wfd_out_session_new(struct wfd_session **out,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display_param = strchr(display_name, '?');
|
||||||
|
if(display_param) {
|
||||||
|
*display_param ++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if(!width || !height) {
|
if(!width || !height) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -107,34 +116,44 @@ int wfd_out_session_new(struct wfd_session **out,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfd_out_session(s)->authority = strdup(authority);
|
os = wfd_out_session(s);
|
||||||
if(!wfd_out_session(s)->authority) {
|
os->authority = strdup(authority);
|
||||||
|
if(!os->authority) {
|
||||||
free(s);
|
free(s);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfd_out_session(s)->audio_dev = strdup(audio_dev);
|
os->audio_dev = strdup(audio_dev);
|
||||||
if(!wfd_out_session(s)->audio_dev) {
|
if(!os->audio_dev) {
|
||||||
free(s);
|
free(s);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfd_session(s)->dir = WFD_SESSION_DIR_OUT;
|
s->dir = WFD_SESSION_DIR_OUT;
|
||||||
wfd_session(s)->rtsp_disp_tbl = out_session_rtsp_disp_tbl;
|
s->rtsp_disp_tbl = out_session_rtsp_disp_tbl;
|
||||||
wfd_out_session(s)->fd = -1;
|
os->fd = -1;
|
||||||
wfd_out_session(s)->sink = sink;
|
os->sink = sink;
|
||||||
wfd_out_session(s)->display_type = display_type;
|
os->display_type = display_type;
|
||||||
wfd_out_session(s)->display_name = display_name;
|
os->display_name = display_name;
|
||||||
wfd_out_session(s)->x = x;
|
os->x = x;
|
||||||
wfd_out_session(s)->y = y;
|
os->y = y;
|
||||||
wfd_out_session(s)->width = width;
|
os->width = width;
|
||||||
wfd_out_session(s)->height = height;
|
os->height = height;
|
||||||
wfd_out_session(s)->mask = mask;
|
os->mask = mask;
|
||||||
wfd_out_session(s)->std = std;
|
os->std = std;
|
||||||
|
|
||||||
|
if(display_param) {
|
||||||
|
os->display_param_name = display_param;
|
||||||
|
display_param = strchr(display_param, '=');
|
||||||
|
if(!display_param) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
*display_param ++ = '\0';
|
||||||
|
os->display_param_value = display_param;
|
||||||
|
}
|
||||||
|
|
||||||
*out = wfd_session(s);
|
*out = wfd_session(s);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
display_name = NULL;
|
display_name = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -534,9 +553,8 @@ inline static char * quote_str(const char *s, char *d, size_t len)
|
||||||
|
|
||||||
static int wfd_out_session_create_pipeline(struct wfd_session *s)
|
static int wfd_out_session_create_pipeline(struct wfd_session *s)
|
||||||
{
|
{
|
||||||
char x[16], y[16], width[16], height[16];
|
|
||||||
char rrtp_port[16], rrtcp_port[16], lrtcp_port[16];
|
char rrtp_port[16], rrtcp_port[16], lrtcp_port[16];
|
||||||
char audio_dev[256];
|
char audio_dev[256], vsrc_params[256] = "";
|
||||||
struct wfd_out_session *os = wfd_out_session(s);
|
struct wfd_out_session *os = wfd_out_session(s);
|
||||||
GstElement *pipeline;
|
GstElement *pipeline;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
@ -544,12 +562,10 @@ static int wfd_out_session_create_pipeline(struct wfd_session *s)
|
||||||
int r;
|
int r;
|
||||||
const char *pipeline_desc[96] = {
|
const char *pipeline_desc[96] = {
|
||||||
"ximagesrc",
|
"ximagesrc",
|
||||||
|
"name=vsrc",
|
||||||
"use-damage=false",
|
"use-damage=false",
|
||||||
"show-pointer=false",
|
"show-pointer=false",
|
||||||
"startx=", uint16_to_str(os->x, x, sizeof(x)),
|
vsrc_params,
|
||||||
"starty=", uint16_to_str(os->x, y, sizeof(y)),
|
|
||||||
"endx=", uint16_to_str(os->width - 1, width, sizeof(width)),
|
|
||||||
"endy=", uint16_to_str(os->height - 1, height, sizeof(height)),
|
|
||||||
"!", "video/x-raw,",
|
"!", "video/x-raw,",
|
||||||
"framerate=50/1",
|
"framerate=50/1",
|
||||||
"!", "vaapipostproc",
|
"!", "vaapipostproc",
|
||||||
|
@ -605,16 +621,11 @@ static int wfd_out_session_create_pipeline(struct wfd_session *s)
|
||||||
*tmp ++ = "host=";
|
*tmp ++ = "host=";
|
||||||
*tmp ++ = wfd_out_session_get_sink(s)->peer->remote_address;
|
*tmp ++ = wfd_out_session_get_sink(s)->peer->remote_address;
|
||||||
*tmp ++ = "port=";
|
*tmp ++ = "port=";
|
||||||
*tmp ++ = uint16_to_str(s->stream.rtp_port, rrtp_port,sizeof(rrtp_port));
|
*tmp ++ = uint16_to_str(s->stream.rtcp_port, rrtcp_port,sizeof(rrtcp_port));
|
||||||
*tmp ++ = "sync=false";
|
*tmp ++ = "sync=false";
|
||||||
*tmp ++ = "async=false";
|
*tmp ++ = "async=false";
|
||||||
}
|
}
|
||||||
|
|
||||||
r = snprintf(rrtcp_port, sizeof(rrtcp_port), "%hu", s->stream.rtcp_port);
|
|
||||||
if(0 > r) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* bad pratice, but since we are in the same process,
|
/* bad pratice, but since we are in the same process,
|
||||||
I think this is the only way to do it */
|
I think this is the only way to do it */
|
||||||
if(WFD_DISPLAY_TYPE_X == os->display_type) {
|
if(WFD_DISPLAY_TYPE_X == os->display_type) {
|
||||||
|
@ -627,6 +638,23 @@ static int wfd_out_session_create_pipeline(struct wfd_session *s)
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!os->display_param_name) {
|
||||||
|
snprintf(vsrc_params, sizeof(vsrc_params),
|
||||||
|
"strtx=%hu starty=%hu endx=%hu endy=%hu",
|
||||||
|
os->x,
|
||||||
|
os->y,
|
||||||
|
os->width,
|
||||||
|
os->height);
|
||||||
|
}
|
||||||
|
else if(!strcmp("xid", os->display_param_name) ||
|
||||||
|
!strcmp("xname", os->display_param_name)) {
|
||||||
|
snprintf(vsrc_params, sizeof(vsrc_params),
|
||||||
|
"%s=\"%s\"",
|
||||||
|
os->display_param_name,
|
||||||
|
os->display_param_value,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline = gst_parse_launchv(pipeline_desc, &error);
|
pipeline = gst_parse_launchv(pipeline_desc, &error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue