Implement JSON/YAML command for graph tree traversal

Implement a single command that allows viewing all information
about a remotes properties/parameters and info variables.

This patch creates a framework for accessing properties using
a simple dotted variable access method or JSON/YAML path expressions.

The root of the tree is a sequence of all globals objects, and
accessing a the first one is simply 0 (or /0 is JSON/YAML path form).

	pipewire-0>>graph 0
	id: 0
	type: PipeWire:Interface:Core
	permissions: rwx
	version: 3
	info:
	    id: 0
	    cookie: 1602594817
	    user_name: panto
	    host_name: nuc2
	    version: 0.2.96
	    name: pipewire-0
	    change_mask: props
	    props:
		pipewire.core.name: pipewire-0
		context.profile.modules: none
		pipewire.core.daemon: 1
		link.max-buffers: 16
		default.clock.rate: 48000
		default.clock.quantum: 1024
		default.clock.min-quantum: 32
		default.clock.max-quantum: 8192
		default.video.width: 640
		default.video.height: 480
		default.video.rate.num: 25
		default.video.rate.denom: 1
		mem.allow-mlock: true
		cpu.max-align: 32
		object.id: 0
	properties:
	    pipewire.core.name: pipewire-0

Displaying a nodes information is simply:

	pipewire-0>>graph /32
	id: 32
	type: PipeWire:Interface:Node
	permissions: rwx
	version: 3
	info:
	    id: 32
	    max_input_ports: 128
	    max_output_ports: 0
	    n_input_ports: 2
	    n_output_ports: 2
	    state: suspended
	    error:
	    change_mask: "n_input_ports,n_output_ports,state,props,params"
	    props:
		object.path: alsa:pcm:HDMI:3:playback
		api.alsa.path: "hw:0,3"
		api.alsa.pcm.card: 0
		api.alsa.pcm.device: 3
		api.alsa.pcm.subdevice: 0
		api.alsa.pcm.stream: playback
		api.alsa.pcm.id: "HDMI 0"
		api.alsa.pcm.name: "HDMI 0"
		api.alsa.pcm.subname: "subdevice #0"
		api.alsa.pcm.class: generic
		api.alsa.pcm.subclass: generic-mix
		api.alsa.pcm.sync-id: 00000000:00000000:00000000:00000000
		device.id: 26
		factory.name: api.alsa.pcm.sink
		priority.master: 696
		priority.session: 696
		media.class: Audio/Sink
		node.name: alsa_card.pci-0000:00:03.0.playback.3.0
		node.description: "Built-in Audio (HDMI 0)"
		factory.id: 17
		client.id: 24
		device.api: alsa
		node.driver: true
		factory.mode: merge
		audio.adapt.slave:
		library.name: audioconvert/libspa-audioconvert
		object.id: 32
	    params:
		EnumFormat:
		    mediaType: audio
		    mediaSubtype: raw
		    format:
			default: S32LE
			alt0: S32LE
			alt1: S16LE
		    rate:
			default: 48000
			min: 32000
			max: 48000
		    channels: 2
		    position:
		      - FL
		      - FR
		PropInfo:
		  - id: volume
		    name: Volume
		    type:
			default: 1.000000
			min: 0.000000
			max: 10.000000
		  - id: mute
		    name: Mute
		    type:
			default: false
			alt0: false
			alt1: true
		  - id: channelVolumes
		    name: "Channel Volumes"
		    type:
			default: 1.000000
			min: 0.000000
			max: 10.000000
		Props:
		    volume: 1.000000
		    mute: false
		    channelVolumes: []
		Format: {}
		EnumPortConfig:
		  - direction: Input
		    mode: dsp
		  - direction: Output
		    mode: dsp
		  - direction: Input
		    mode: convert
		  - direction: Output
		    mode: convert
		PortConfig: {}
	properties:
	    object.path: alsa:pcm:HDMI:3:playback
	    factory.id: 17
	    client.id: 24
	    device.id: 26
	    priority.session: 696
	    priority.master: 696
	    node.description: "Built-in Audio (HDMI 0)"
	    node.name: alsa_card.pci-0000:00:03.0.playback.3.0
	    media.class: Audio/Sink

To simply display the parameters of the same object:

	pipewire-0>>graph 32/info/params
	EnumFormat:
	    mediaType: audio
	    mediaSubtype: raw
	    format:
		default: S32LE
		alt0: S32LE
		alt1: S16LE
	    rate:
		default: 48000
		min: 32000
		max: 48000
	    channels: 2
	    position:
	      - FL
	      - FR
	PropInfo:
	  - id: volume
	    name: Volume
	    type:
		default: 1.000000
		min: 0.000000
		max: 10.000000
	  - id: mute
	    name: Mute
	    type:
		default: false
		alt0: false
		alt1: true
	  - id: channelVolumes
	    name: "Channel Volumes"
	    type:
		default: 1.000000
		min: 0.000000
		max: 10.000000
	Props:
	    volume: 1.000000
	    mute: false
	    channelVolumes: []
	Format: {}
	EnumPortConfig:
	  - direction: Input
	    mode: dsp
	  - direction: Output
	    mode: dsp
	  - direction: Input
	    mode: convert
	  - direction: Output
	    mode: convert
	PortConfig: {}

The graph command also supports the following options:

	-y Select YAML format (this is the default)
	-j Select JSON format
	-n Display numeric instead of textual IDs
	-f Display full type info, i.e. instead of EnumFormat will
	   display Spa:Enum:ParamId:EnumFormat

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
This commit is contained in:
Pantelis Antoniou 2020-02-14 21:05:40 +02:00 committed by Wim Taymans
parent 3b53a6e049
commit 7ead270265

File diff suppressed because it is too large Load diff