mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	m-rtp-sap: add sap.announcer option to disable the send socket
In circumstances where the network interface is not ready yet, creating a send socket will fail. This may be ok if we only intend to use rtp-sap as a listener, therefore add an option for it.
This commit is contained in:
		
							parent
							
								
									1ef6db7d54
								
							
						
					
					
						commit
						242d75c6fc
					
				
					 1 changed files with 17 additions and 7 deletions
				
			
		| 
						 | 
					@ -45,6 +45,10 @@
 | 
				
			||||||
 * sess.sap.announce = true and it will create a receiver for all announced
 | 
					 * sess.sap.announce = true and it will create a receiver for all announced
 | 
				
			||||||
 * streams.
 | 
					 * streams.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
					 * If `sap.announcer` is set to `false`, the announce-stream action will not
 | 
				
			||||||
 | 
					 * work. Use this to avoid opening a send socket if you are not going to use
 | 
				
			||||||
 | 
					 * this functionality.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 * ## Module Name
 | 
					 * ## Module Name
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * `libpipewire-module-rtp-sap`
 | 
					 * `libpipewire-module-rtp-sap`
 | 
				
			||||||
| 
						 | 
					@ -64,6 +68,7 @@
 | 
				
			||||||
 * - `sap.max-sessions = <int>`: maximum number of concurrent send/receive sessions to track
 | 
					 * - `sap.max-sessions = <int>`: maximum number of concurrent send/receive sessions to track
 | 
				
			||||||
 * - `sap.preamble-extra = [strings]`: extra attributes to add to the atomic SDP preamble
 | 
					 * - `sap.preamble-extra = [strings]`: extra attributes to add to the atomic SDP preamble
 | 
				
			||||||
 * - `sap.end-extra = [strings]`: extra attributes to add to the end of the SDP message
 | 
					 * - `sap.end-extra = [strings]`: extra attributes to add to the end of the SDP message
 | 
				
			||||||
 | 
					 * - `sap.announcer = <bool>`: enable announcing local streams, default true
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * ## General options
 | 
					 * ## General options
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -265,6 +270,7 @@ struct impl {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sockaddr_storage src_addr;
 | 
						struct sockaddr_storage src_addr;
 | 
				
			||||||
	socklen_t src_len;
 | 
						socklen_t src_len;
 | 
				
			||||||
 | 
						bool announcer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint16_t sap_port;
 | 
						uint16_t sap_port;
 | 
				
			||||||
	struct sockaddr_storage sap_addr;
 | 
						struct sockaddr_storage sap_addr;
 | 
				
			||||||
| 
						 | 
					@ -1085,7 +1091,7 @@ static int rule_matched(void *data, const char *location, const char *action,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		session_load_source(i->session, i->props);
 | 
							session_load_source(i->session, i->props);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if (i->node && spa_streq(action, "announce-stream")) {
 | 
						else if (i->node && i->impl->announcer && spa_streq(action, "announce-stream")) {
 | 
				
			||||||
		struct pw_properties *props;
 | 
							struct pw_properties *props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ((props = pw_properties_new_dict(i->node->info->props)) == NULL)
 | 
							if ((props = pw_properties_new_dict(i->node->info->props)) == NULL)
 | 
				
			||||||
| 
						 | 
					@ -1486,12 +1492,14 @@ static int start_sap(struct impl *impl)
 | 
				
			||||||
	struct timespec value, interval;
 | 
						struct timespec value, interval;
 | 
				
			||||||
	char addr[128] = "invalid";
 | 
						char addr[128] = "invalid";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (impl->announcer) {
 | 
				
			||||||
		if ((fd = make_send_socket(&impl->src_addr, impl->src_len,
 | 
							if ((fd = make_send_socket(&impl->src_addr, impl->src_len,
 | 
				
			||||||
						&impl->sap_addr, impl->sap_len,
 | 
											&impl->sap_addr, impl->sap_len,
 | 
				
			||||||
						impl->mcast_loop, impl->ttl)) < 0)
 | 
											impl->mcast_loop, impl->ttl)) < 0)
 | 
				
			||||||
			return fd;
 | 
								return fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		impl->sap_fd = fd;
 | 
							impl->sap_fd = fd;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_info("starting SAP timer");
 | 
						pw_log_info("starting SAP timer");
 | 
				
			||||||
	impl->timer = pw_loop_add_timer(impl->loop, on_timer_event, impl);
 | 
						impl->timer = pw_loop_add_timer(impl->loop, on_timer_event, impl);
 | 
				
			||||||
| 
						 | 
					@ -1733,6 +1741,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
	impl->module = module;
 | 
						impl->module = module;
 | 
				
			||||||
	impl->loop = pw_context_get_main_loop(context);
 | 
						impl->loop = pw_context_get_main_loop(context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						impl->announcer = pw_properties_get_bool(props, "sap.announcer", true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	str = pw_properties_get(props, "local.ifname");
 | 
						str = pw_properties_get(props, "local.ifname");
 | 
				
			||||||
	impl->ifname = str ? strdup(str) : NULL;
 | 
						impl->ifname = str ? strdup(str) : NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1754,7 +1764,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
			"sap.cleanup.sec", DEFAULT_CLEANUP_SEC);
 | 
								"sap.cleanup.sec", DEFAULT_CLEANUP_SEC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((str = pw_properties_get(props, "source.ip")) == NULL) {
 | 
						if ((str = pw_properties_get(props, "source.ip")) == NULL) {
 | 
				
			||||||
		if (impl->ifname) {
 | 
							if (impl->ifname && impl->announcer) {
 | 
				
			||||||
			int fd = socket(impl->sap_addr.ss_family, SOCK_DGRAM, 0);
 | 
								int fd = socket(impl->sap_addr.ss_family, SOCK_DGRAM, 0);
 | 
				
			||||||
			if (fd >= 0) {
 | 
								if (fd >= 0) {
 | 
				
			||||||
				struct ifreq req;
 | 
									struct ifreq req;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue