mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module-netjack2: improve OPUS fallback
This commit is contained in:
		
							parent
							
								
									deba261a1b
								
							
						
					
					
						commit
						da86c2030c
					
				
					 2 changed files with 24 additions and 8 deletions
				
			
		| 
						 | 
					@ -810,6 +810,20 @@ static void update_timer(struct impl *impl, uint64_t timeout)
 | 
				
			||||||
	pw_loop_update_timer(impl->main_loop, impl->timer, &value, &interval, false);
 | 
						pw_loop_update_timer(impl->main_loop, impl->timer, &value, &interval, false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool encoding_supported(uint32_t encoder)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (encoder) {
 | 
				
			||||||
 | 
						case NJ2_ENCODER_FLOAT:
 | 
				
			||||||
 | 
						case NJ2_ENCODER_INT:
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
					#ifdef HAVE_OPUS
 | 
				
			||||||
 | 
						case NJ2_ENCODER_OPUS:
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int handle_follower_setup(struct impl *impl, struct nj2_session_params *params,
 | 
					static int handle_follower_setup(struct impl *impl, struct nj2_session_params *params,
 | 
				
			||||||
	struct sockaddr_storage *addr, socklen_t addr_len)
 | 
						struct sockaddr_storage *addr, socklen_t addr_len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -829,9 +843,7 @@ static int handle_follower_setup(struct impl *impl, struct nj2_session_params *p
 | 
				
			||||||
	    peer->params.recv_midi_channels < 0 ||
 | 
						    peer->params.recv_midi_channels < 0 ||
 | 
				
			||||||
	    peer->params.sample_rate == 0 ||
 | 
						    peer->params.sample_rate == 0 ||
 | 
				
			||||||
	    peer->params.period_size == 0 ||
 | 
						    peer->params.period_size == 0 ||
 | 
				
			||||||
	    (peer->params.sample_encoder != NJ2_ENCODER_FLOAT &&
 | 
						    !encoding_supported(peer->params.sample_encoder)) {
 | 
				
			||||||
	     peer->params.sample_encoder != NJ2_ENCODER_OPUS &&
 | 
					 | 
				
			||||||
	     peer->params.sample_encoder != NJ2_ENCODER_INT)) {
 | 
					 | 
				
			||||||
		pw_log_warn("invalid follower setup");
 | 
							pw_log_warn("invalid follower setup");
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@
 | 
				
			||||||
 *                   placed per stream.
 | 
					 *                   placed per stream.
 | 
				
			||||||
 * - `netjack2.sample-rate`: the sample rate to use, default 48000
 | 
					 * - `netjack2.sample-rate`: the sample rate to use, default 48000
 | 
				
			||||||
 * - `netjack2.period-size`: the buffer size to use, default 1024
 | 
					 * - `netjack2.period-size`: the buffer size to use, default 1024
 | 
				
			||||||
 * - `netjack2.encoding`: the encoding, float|opus, default float
 | 
					 * - `netjack2.encoding`: the encoding, float|opus|int, default float
 | 
				
			||||||
 * - `netjack2.kbps`: the number of kilobits per second when encoding, default 64
 | 
					 * - `netjack2.kbps`: the number of kilobits per second when encoding, default 64
 | 
				
			||||||
 * - `audio.channels`: the number of audio ports. Can also be added to the stream props.
 | 
					 * - `audio.channels`: the number of audio ports. Can also be added to the stream props.
 | 
				
			||||||
 * - `midi.ports`: the number of midi ports. Can also be added to the stream props.
 | 
					 * - `midi.ports`: the number of midi ports. Can also be added to the stream props.
 | 
				
			||||||
| 
						 | 
					@ -1327,15 +1327,19 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
			DEFAULT_PERIOD_SIZE);
 | 
								DEFAULT_PERIOD_SIZE);
 | 
				
			||||||
	if ((str = pw_properties_get(impl->props, "netjack2.encoding")) == NULL)
 | 
						if ((str = pw_properties_get(impl->props, "netjack2.encoding")) == NULL)
 | 
				
			||||||
		str = DEFAULT_ENCODING;
 | 
							str = DEFAULT_ENCODING;
 | 
				
			||||||
	if (spa_streq(str, "float"))
 | 
						if (spa_streq(str, "float")) {
 | 
				
			||||||
		impl->encoding = NJ2_ENCODER_FLOAT;
 | 
							impl->encoding = NJ2_ENCODER_FLOAT;
 | 
				
			||||||
 | 
						} else if (spa_streq(str, "opus")) {
 | 
				
			||||||
#ifdef HAVE_OPUS
 | 
					#ifdef HAVE_OPUS
 | 
				
			||||||
	else if (spa_streq(str, "opus"))
 | 
					 | 
				
			||||||
		impl->encoding = NJ2_ENCODER_OPUS;
 | 
							impl->encoding = NJ2_ENCODER_OPUS;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
							pw_log_error("OPUS support is disabled");
 | 
				
			||||||
 | 
							res = -EINVAL;
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	else if (spa_streq(str, "int"))
 | 
						} else if (spa_streq(str, "int")) {
 | 
				
			||||||
		impl->encoding = NJ2_ENCODER_INT;
 | 
							impl->encoding = NJ2_ENCODER_INT;
 | 
				
			||||||
	else {
 | 
						} else {
 | 
				
			||||||
			pw_log_error("invalid netjack2.encoding '%s'", str);
 | 
								pw_log_error("invalid netjack2.encoding '%s'", str);
 | 
				
			||||||
			res = -EINVAL;
 | 
								res = -EINVAL;
 | 
				
			||||||
			goto error;
 | 
								goto error;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue