mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
pw-mon: add filter param to hide props and/or params
This commit is contained in:
parent
69d431acd4
commit
cacdcc1b62
1 changed files with 85 additions and 50 deletions
|
|
@ -55,6 +55,9 @@ struct data {
|
||||||
|
|
||||||
struct spa_list pending_list;
|
struct spa_list pending_list;
|
||||||
struct spa_list global_list;
|
struct spa_list global_list;
|
||||||
|
|
||||||
|
bool hide_params;
|
||||||
|
bool hide_props;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct proxy_data {
|
struct proxy_data {
|
||||||
|
|
@ -152,7 +155,7 @@ static void event_param(void *_data, int seq, uint32_t id,
|
||||||
spa_list_append(&data->param_list, &p->link);
|
spa_list_append(&data->param_list, &p->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_params(struct proxy_data *data, bool use_prefix)
|
static void print_parameters(struct proxy_data *data, bool use_prefix)
|
||||||
{
|
{
|
||||||
struct param *p;
|
struct param *p;
|
||||||
|
|
||||||
|
|
@ -198,9 +201,12 @@ static void print_properties(const struct spa_dict *props, bool use_prefix)
|
||||||
|
|
||||||
#define MARK_CHANGE(f) (!!(print_mark && ((info)->change_mask & (f))))
|
#define MARK_CHANGE(f) (!!(print_mark && ((info)->change_mask & (f))))
|
||||||
|
|
||||||
static void on_core_info(void *data, const struct pw_core_info *info)
|
static void on_core_info(void *_data, const struct pw_core_info *info)
|
||||||
{
|
{
|
||||||
bool print_all = true, print_mark = true;
|
struct proxy_data *data = _data;
|
||||||
|
bool hide_props, print_mark = true;
|
||||||
|
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
printf("\ttype: %s\n", PW_TYPE_INTERFACE_Core);
|
printf("\ttype: %s\n", PW_TYPE_INTERFACE_Core);
|
||||||
printf("\tcookie: %u\n", info->cookie);
|
printf("\tcookie: %u\n", info->cookie);
|
||||||
|
|
@ -208,7 +214,7 @@ static void on_core_info(void *data, const struct pw_core_info *info)
|
||||||
printf("\thost-name: \"%s\"\n", info->host_name);
|
printf("\thost-name: \"%s\"\n", info->host_name);
|
||||||
printf("\tversion: \"%s\"\n", info->version);
|
printf("\tversion: \"%s\"\n", info->version);
|
||||||
printf("\tname: \"%s\"\n", info->name);
|
printf("\tname: \"%s\"\n", info->name);
|
||||||
if (print_all) {
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_CORE_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_CORE_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,9 +222,9 @@ static void on_core_info(void *data, const struct pw_core_info *info)
|
||||||
static void module_event_info(void *_data, const struct pw_module_info *info)
|
static void module_event_info(void *_data, const struct pw_module_info *info)
|
||||||
{
|
{
|
||||||
struct proxy_data *data = _data;
|
struct proxy_data *data = _data;
|
||||||
bool print_all, print_mark;
|
bool hide_props, print_mark;
|
||||||
|
|
||||||
print_all = true;
|
hide_props = data->data->hide_props;
|
||||||
if (data->info == NULL) {
|
if (data->info == NULL) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -237,7 +243,7 @@ static void module_event_info(void *_data, const struct pw_module_info *info)
|
||||||
printf("\tname: \"%s\"\n", info->name);
|
printf("\tname: \"%s\"\n", info->name);
|
||||||
printf("\tfilename: \"%s\"\n", info->filename);
|
printf("\tfilename: \"%s\"\n", info->filename);
|
||||||
printf("\targs: \"%s\"\n", info->args);
|
printf("\targs: \"%s\"\n", info->args);
|
||||||
if (print_all) {
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_MODULE_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_MODULE_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -250,9 +256,11 @@ static const struct pw_module_events module_events = {
|
||||||
static void print_node(struct proxy_data *data)
|
static void print_node(struct proxy_data *data)
|
||||||
{
|
{
|
||||||
struct pw_node_info *info = data->info;
|
struct pw_node_info *info = data->info;
|
||||||
bool print_all, print_mark;
|
bool hide_params, hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_params = data->data->hide_params;
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->first) {
|
if (data->first) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -267,8 +275,8 @@ static void print_node(struct proxy_data *data)
|
||||||
printf("\tpermissions: "PW_PERMISSION_FORMAT"\n",
|
printf("\tpermissions: "PW_PERMISSION_FORMAT"\n",
|
||||||
PW_PERMISSION_ARGS(data->permissions));
|
PW_PERMISSION_ARGS(data->permissions));
|
||||||
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
||||||
if (print_all) {
|
if (!hide_params) {
|
||||||
print_params(data, MARK_CHANGE(PW_NODE_CHANGE_MASK_PARAMS));
|
print_parameters(data, MARK_CHANGE(PW_NODE_CHANGE_MASK_PARAMS));
|
||||||
with_prefix(MARK_CHANGE(PW_NODE_CHANGE_MASK_INPUT_PORTS)) {
|
with_prefix(MARK_CHANGE(PW_NODE_CHANGE_MASK_INPUT_PORTS)) {
|
||||||
printf("\tinput ports: %u/%u\n",
|
printf("\tinput ports: %u/%u\n",
|
||||||
info->n_input_ports, info->max_input_ports);
|
info->n_input_ports, info->max_input_ports);
|
||||||
|
|
@ -285,6 +293,9 @@ static void print_node(struct proxy_data *data)
|
||||||
printf(" \"%s\"\n", info->error);
|
printf(" \"%s\"\n", info->error);
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_NODE_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_NODE_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -323,9 +334,11 @@ static const struct pw_node_events node_events = {
|
||||||
static void print_port(struct proxy_data *data)
|
static void print_port(struct proxy_data *data)
|
||||||
{
|
{
|
||||||
struct pw_port_info *info = data->info;
|
struct pw_port_info *info = data->info;
|
||||||
bool print_all, print_mark;
|
bool hide_params, hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_params = data->data->hide_params;
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->first) {
|
if (data->first) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -342,8 +355,12 @@ static void print_port(struct proxy_data *data)
|
||||||
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
||||||
|
|
||||||
printf("\tdirection: \"%s\"\n", pw_direction_as_string(info->direction));
|
printf("\tdirection: \"%s\"\n", pw_direction_as_string(info->direction));
|
||||||
if (print_all) {
|
|
||||||
print_params(data, MARK_CHANGE(PW_PORT_CHANGE_MASK_PARAMS));
|
if (!hide_params) {
|
||||||
|
print_parameters(data, MARK_CHANGE(PW_PORT_CHANGE_MASK_PARAMS));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_PORT_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_PORT_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -382,9 +399,10 @@ static const struct pw_port_events port_events = {
|
||||||
static void factory_event_info(void *_data, const struct pw_factory_info *info)
|
static void factory_event_info(void *_data, const struct pw_factory_info *info)
|
||||||
{
|
{
|
||||||
struct proxy_data *data = _data;
|
struct proxy_data *data = _data;
|
||||||
bool print_all, print_mark;
|
bool hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->info == NULL) {
|
if (data->info == NULL) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -403,7 +421,7 @@ static void factory_event_info(void *_data, const struct pw_factory_info *info)
|
||||||
|
|
||||||
printf("\tname: \"%s\"\n", info->name);
|
printf("\tname: \"%s\"\n", info->name);
|
||||||
printf("\tobject-type: %s/%d\n", info->type, info->version);
|
printf("\tobject-type: %s/%d\n", info->type, info->version);
|
||||||
if (print_all) {
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_FACTORY_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_FACTORY_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -416,9 +434,10 @@ static const struct pw_factory_events factory_events = {
|
||||||
static void client_event_info(void *_data, const struct pw_client_info *info)
|
static void client_event_info(void *_data, const struct pw_client_info *info)
|
||||||
{
|
{
|
||||||
struct proxy_data *data = _data;
|
struct proxy_data *data = _data;
|
||||||
bool print_all, print_mark;
|
bool hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->info == NULL) {
|
if (data->info == NULL) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -435,7 +454,7 @@ static void client_event_info(void *_data, const struct pw_client_info *info)
|
||||||
PW_PERMISSION_ARGS(data->permissions));
|
PW_PERMISSION_ARGS(data->permissions));
|
||||||
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
||||||
|
|
||||||
if (print_all) {
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_CLIENT_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_CLIENT_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -448,9 +467,10 @@ static const struct pw_client_events client_events = {
|
||||||
static void link_event_info(void *_data, const struct pw_link_info *info)
|
static void link_event_info(void *_data, const struct pw_link_info *info)
|
||||||
{
|
{
|
||||||
struct proxy_data *data = _data;
|
struct proxy_data *data = _data;
|
||||||
bool print_all, print_mark;
|
bool hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->info == NULL) {
|
if (data->info == NULL) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -471,7 +491,7 @@ static void link_event_info(void *_data, const struct pw_link_info *info)
|
||||||
printf("\toutput-port-id: %u\n", info->output_port_id);
|
printf("\toutput-port-id: %u\n", info->output_port_id);
|
||||||
printf("\tinput-node-id: %u\n", info->input_node_id);
|
printf("\tinput-node-id: %u\n", info->input_node_id);
|
||||||
printf("\tinput-port-id: %u\n", info->input_port_id);
|
printf("\tinput-port-id: %u\n", info->input_port_id);
|
||||||
if (print_all) {
|
if (!hide_props) {
|
||||||
with_prefix(MARK_CHANGE(PW_LINK_CHANGE_MASK_STATE)) {
|
with_prefix(MARK_CHANGE(PW_LINK_CHANGE_MASK_STATE)) {
|
||||||
printf("\tstate: \"%s\"",
|
printf("\tstate: \"%s\"",
|
||||||
pw_link_state_as_string(info->state));
|
pw_link_state_as_string(info->state));
|
||||||
|
|
@ -499,9 +519,11 @@ static const struct pw_link_events link_events = {
|
||||||
static void print_device(struct proxy_data *data)
|
static void print_device(struct proxy_data *data)
|
||||||
{
|
{
|
||||||
struct pw_device_info *info = data->info;
|
struct pw_device_info *info = data->info;
|
||||||
bool print_all, print_mark;
|
bool hide_params, hide_props, print_mark;
|
||||||
|
|
||||||
|
hide_params = data->data->hide_params;
|
||||||
|
hide_props = data->data->hide_props;
|
||||||
|
|
||||||
print_all = true;
|
|
||||||
if (data->first) {
|
if (data->first) {
|
||||||
printf("added:\n");
|
printf("added:\n");
|
||||||
print_mark = false;
|
print_mark = false;
|
||||||
|
|
@ -517,8 +539,11 @@ static void print_device(struct proxy_data *data)
|
||||||
PW_PERMISSION_ARGS(data->permissions));
|
PW_PERMISSION_ARGS(data->permissions));
|
||||||
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
printf("\ttype: %s (version %d)\n", data->type, data->version);
|
||||||
|
|
||||||
if (print_all) {
|
if (!hide_params) {
|
||||||
print_params(data, MARK_CHANGE(PW_DEVICE_CHANGE_MASK_PARAMS));
|
print_parameters(data, MARK_CHANGE(PW_DEVICE_CHANGE_MASK_PARAMS));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hide_props) {
|
||||||
print_properties(info->props, MARK_CHANGE(PW_DEVICE_CHANGE_MASK_PROPS));
|
print_properties(info->props, MARK_CHANGE(PW_DEVICE_CHANGE_MASK_PROPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -732,7 +757,9 @@ static void show_help(const char *name, bool error)
|
||||||
" --version Show version\n"
|
" --version Show version\n"
|
||||||
" -r, --remote Remote daemon name\n"
|
" -r, --remote Remote daemon name\n"
|
||||||
" -N, --no-colors disable color output\n"
|
" -N, --no-colors disable color output\n"
|
||||||
" -C, --color[=WHEN] whether to enable color support. WHEN is `never`, `always`, or `auto`\n",
|
" -C, --color[=WHEN] whether to enable color support. WHEN is `never`, `always`, or `auto`\n"
|
||||||
|
" -o, --hide-props hide node properties\n"
|
||||||
|
" -a, --hide-params hide node properties\n",
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -747,6 +774,8 @@ int main(int argc, char *argv[])
|
||||||
{ "remote", required_argument, NULL, 'r' },
|
{ "remote", required_argument, NULL, 'r' },
|
||||||
{ "no-colors", no_argument, NULL, 'N' },
|
{ "no-colors", no_argument, NULL, 'N' },
|
||||||
{ "color", optional_argument, NULL, 'C' },
|
{ "color", optional_argument, NULL, 'C' },
|
||||||
|
{ "hide-props", no_argument, NULL, 'o' },
|
||||||
|
{ "hide-params", no_argument, NULL, 'a' },
|
||||||
{ NULL, 0, NULL, 0}
|
{ NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
|
|
@ -760,7 +789,7 @@ int main(int argc, char *argv[])
|
||||||
if (isatty(STDOUT_FILENO) && getenv("NO_COLOR") == NULL)
|
if (isatty(STDOUT_FILENO) && getenv("NO_COLOR") == NULL)
|
||||||
colors = true;
|
colors = true;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVr:NC", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVr:NCoa", long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
show_help(argv[0], false);
|
show_help(argv[0], false);
|
||||||
|
|
@ -793,6 +822,12 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
data.hide_props = true;
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
data.hide_params = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
show_help(argv[0], true);
|
show_help(argv[0], true);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue