mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
add -nohold option: drop current client when new client connects
This commit is contained in:
15
README.html
15
README.html
@@ -1,6 +1,6 @@
|
||||
<h1
|
||||
id="uxplay-1.57-airplay-mirror-and-airplay-audio-server-for-linux-macos-and-unix-now-also-runs-on-windows.">UxPlay
|
||||
1.57: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix
|
||||
id="uxplay-1.58-airplay-mirror-and-airplay-audio-server-for-linux-macos-and-unix-now-also-runs-on-windows.">UxPlay
|
||||
1.58: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix
|
||||
(now also runs on Windows).</h1>
|
||||
<h3
|
||||
id="now-developed-at-the-github-site-httpsgithub.comfdh2uxplay-where-all-user-issues-should-be-posted.">Now
|
||||
@@ -347,6 +347,12 @@ longer automatically applied. <strong>After a recent update, Raspberry
|
||||
Pi OS (Bullseye) now supplies an already-patched GStreamer-1.18.4 that
|
||||
works with UxPlay, but needs the <code>-bt709</code> option with
|
||||
UxPlay-1.56 or later.</strong></p></li>
|
||||
<li><p><strong>The option <code>-v4l2</code> (also <code>-rpi*</code>
|
||||
options) causes a crash when the client screen is rotated, if used with
|
||||
current Raspberry Pi OS version
|
||||
gstreamer1.0-plugins-good-1.18.4-2+deb11u1+rpt1. Solution: don’t use
|
||||
these options, or apply the GStreamer backport patch from the UxPlay
|
||||
Wiki.</strong></p></li>
|
||||
<li><p>Tip: to start UxPlay on a remote host (such as a Raspberry Pi)
|
||||
using ssh:</p></li>
|
||||
</ul>
|
||||
@@ -706,6 +712,9 @@ client sends the “Stop Mirroring” signal. <em>This option is currently
|
||||
used by default in macOS, as the window created in macOS by GStreamer
|
||||
does not terminate correctly (it causes a segfault) if it is still open
|
||||
when the GStreamer pipeline is closed.</em></p>
|
||||
<p><strong>-nohold</strong> Drops the current connection when a new
|
||||
client attempts to connect. Without this option, the current client
|
||||
maintains exclusive ownership of UxPlay until it disconnects.</p>
|
||||
<p><strong>-FPSdata</strong> Turns on monitoring of regular reports
|
||||
about video streaming performance that are sent by the client. These
|
||||
will be displayed in the terminal window if this option is used. The
|
||||
@@ -962,6 +971,8 @@ as “SupportsLegacyPairing”) of the “features” plist code (reported to
|
||||
the client by the AirPlay server) to be set. The “features” code and
|
||||
other settings are set in <code>UxPlay/lib/dnssdint.h</code>.</p>
|
||||
<h1 id="changelog">Changelog</h1>
|
||||
<p>1.58 2022-10-29 Add option “-nohold” that will drop existing
|
||||
connections when a new client connects.</p>
|
||||
<p>1.57 2022-10-09 Minor fixes: (fix coredump on AUR on “stop
|
||||
mirroring”, occurs when compiled with AUR CFLAGS -DFORTIFY_SOURCE);
|
||||
graceful exit when required plugins are missing; improved support for
|
||||
|
||||
10
README.md
10
README.md
@@ -1,4 +1,4 @@
|
||||
# UxPlay 1.57: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix (now also runs on Windows).
|
||||
# UxPlay 1.58: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix (now also runs on Windows).
|
||||
|
||||
### Now developed at the GitHub site [https://github.com/FDH2/UxPlay](https://github.com/FDH2/UxPlay) (where all user issues should be posted).
|
||||
|
||||
@@ -289,6 +289,9 @@ a fix for this, which is included in the latest patches, so beginning with UxPla
|
||||
**After a recent update, Raspberry Pi OS (Bullseye) now supplies an already-patched GStreamer-1.18.4 that works with UxPlay, but
|
||||
needs the `-bt709` option with UxPlay-1.56 or later.**
|
||||
|
||||
* **The option `-v4l2` (also ``-rpi*`` options) causes a crash when the client screen is rotated,
|
||||
if used with current Raspberry Pi OS version gstreamer1.0-plugins-good-1.18.4-2+deb11u1+rpt1. Solution:
|
||||
don't use these options, or apply the GStreamer backport patch from the UxPlay Wiki.**
|
||||
|
||||
* Tip: to start UxPlay on a remote host (such as a Raspberry Pi) using ssh:
|
||||
|
||||
@@ -600,6 +603,9 @@ which will not work if a firewall is running.
|
||||
as the window created in macOS by GStreamer does not terminate correctly (it causes a segfault)
|
||||
if it is still open when the GStreamer pipeline is closed._
|
||||
|
||||
**-nohold** Drops the current connection when a new client attempts to connect. Without this option,
|
||||
the current client maintains exclusive ownership of UxPlay until it disconnects.
|
||||
|
||||
**-FPSdata** Turns on monitoring of regular reports about video streaming performance
|
||||
that are sent by the client. These will be displayed in the terminal window if this
|
||||
option is used. The data is updated by the client at 1 second intervals.
|
||||
@@ -809,6 +815,8 @@ tvOS 12.2.1); it seems that the use of "legacy" protocol just requires bit 27 (l
|
||||
The "features" code and other settings are set in `UxPlay/lib/dnssdint.h`.
|
||||
|
||||
# Changelog
|
||||
1.58 2022-10-29 Add option "-nohold" that will drop existing connections when a new client connects.
|
||||
|
||||
1.57 2022-10-09 Minor fixes: (fix coredump on AUR on "stop mirroring", occurs when compiled with
|
||||
AUR CFLAGS -DFORTIFY_SOURCE); graceful exit when required plugins are missing;
|
||||
improved support for builds on Windows. Include audioresample in GStreamer
|
||||
|
||||
15
README.txt
15
README.txt
@@ -1,4 +1,4 @@
|
||||
# UxPlay 1.57: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix (now also runs on Windows).
|
||||
# UxPlay 1.58: AirPlay-Mirror and AirPlay-Audio server for Linux, macOS, and Unix (now also runs on Windows).
|
||||
|
||||
### Now developed at the GitHub site <https://github.com/FDH2/UxPlay> (where all user issues should be posted).
|
||||
|
||||
@@ -345,6 +345,12 @@ results.
|
||||
supplies an already-patched GStreamer-1.18.4 that works with UxPlay,
|
||||
but needs the `-bt709` option with UxPlay-1.56 or later.**
|
||||
|
||||
- **The option `-v4l2` (also `-rpi*` options) causes a crash when the
|
||||
client screen is rotated, if used with current Raspberry Pi OS
|
||||
version gstreamer1.0-plugins-good-1.18.4-2+deb11u1+rpt1. Solution:
|
||||
don't use these options, or apply the GStreamer backport patch from
|
||||
the UxPlay Wiki.**
|
||||
|
||||
- Tip: to start UxPlay on a remote host (such as a Raspberry Pi) using
|
||||
ssh:
|
||||
|
||||
@@ -731,6 +737,10 @@ window created in macOS by GStreamer does not terminate correctly (it
|
||||
causes a segfault) if it is still open when the GStreamer pipeline is
|
||||
closed.*
|
||||
|
||||
**-nohold** Drops the current connection when a new client attempts to
|
||||
connect. Without this option, the current client maintains exclusive
|
||||
ownership of UxPlay until it disconnects.
|
||||
|
||||
**-FPSdata** Turns on monitoring of regular reports about video
|
||||
streaming performance that are sent by the client. These will be
|
||||
displayed in the terminal window if this option is used. The data is
|
||||
@@ -1004,6 +1014,9 @@ other settings are set in `UxPlay/lib/dnssdint.h`.
|
||||
|
||||
# Changelog
|
||||
|
||||
1.58 2022-10-29 Add option "-nohold" that will drop existing connections
|
||||
when a new client connects.
|
||||
|
||||
1.57 2022-10-09 Minor fixes: (fix coredump on AUR on "stop mirroring",
|
||||
occurs when compiled with AUR CFLAGS -DFORTIFY_SOURCE); graceful exit
|
||||
when required plugins are missing; improved support for builds on
|
||||
|
||||
41
lib/httpd.c
41
lib/httpd.c
@@ -97,6 +97,20 @@ httpd_destroy(httpd_t *httpd)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
httpd_remove_connection(httpd_t *httpd, http_connection_t *connection)
|
||||
{
|
||||
if (connection->request) {
|
||||
http_request_destroy(connection->request);
|
||||
connection->request = NULL;
|
||||
}
|
||||
httpd->callbacks.conn_destroy(connection->user_data);
|
||||
shutdown(connection->socket_fd, SHUT_WR);
|
||||
closesocket(connection->socket_fd);
|
||||
connection->connected = 0;
|
||||
httpd->open_connections--;
|
||||
}
|
||||
|
||||
static int
|
||||
httpd_add_connection(httpd_t *httpd, int fd, unsigned char *local, int local_len, unsigned char *remote, int remote_len)
|
||||
{
|
||||
@@ -158,6 +172,19 @@ httpd_accept_connection(httpd_t *httpd, int server_fd, int is_ipv6)
|
||||
local = netutils_get_address(&local_saddr, &local_len);
|
||||
remote = netutils_get_address(&remote_saddr, &remote_len);
|
||||
|
||||
/* for uxplay, remove existing connections to make way for new connections:
|
||||
* this will only occur if max_connections > 2 */
|
||||
if (httpd->open_connections >= 2) {
|
||||
logger_log(httpd->logger, LOGGER_INFO, "removing current connections to make way for new connection");
|
||||
for (int i = 0; i<httpd->max_connections; i++) {
|
||||
http_connection_t *connection = &httpd->connections[i];
|
||||
if (!connection->connected) {
|
||||
continue;
|
||||
}
|
||||
httpd_remove_connection(httpd, connection);
|
||||
}
|
||||
}
|
||||
|
||||
ret = httpd_add_connection(httpd, fd, local, local_len, remote, remote_len);
|
||||
if (ret == -1) {
|
||||
shutdown(fd, SHUT_RDWR);
|
||||
@@ -167,20 +194,6 @@ httpd_accept_connection(httpd_t *httpd, int server_fd, int is_ipv6)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
httpd_remove_connection(httpd_t *httpd, http_connection_t *connection)
|
||||
{
|
||||
if (connection->request) {
|
||||
http_request_destroy(connection->request);
|
||||
connection->request = NULL;
|
||||
}
|
||||
httpd->callbacks.conn_destroy(connection->user_data);
|
||||
shutdown(connection->socket_fd, SHUT_WR);
|
||||
closesocket(connection->socket_fd);
|
||||
connection->connected = 0;
|
||||
httpd->open_connections--;
|
||||
}
|
||||
|
||||
static THREAD_RETVAL
|
||||
httpd_thread(void *arg)
|
||||
{
|
||||
|
||||
6
uxplay.1
6
uxplay.1
@@ -1,11 +1,11 @@
|
||||
.TH UXPLAY "1" "October 2022" "1.57" "User Commands"
|
||||
.TH UXPLAY "1" "November 2022" "1.58" "User Commands"
|
||||
.SH NAME
|
||||
uxplay \- start AirPlay server
|
||||
.SH SYNOPSIS
|
||||
.B uxplay
|
||||
[\fI\,-n name\/\fR] [\fI\,-s wxh\/\fR] [\fI\,-p \/\fR[\fI\,n\/\fR]] [more \fI OPTIONS \/\fR ...]
|
||||
.SH DESCRIPTION
|
||||
UxPlay 1.57: An open\-source AirPlay mirroring server based on RPiPlay
|
||||
UxPlay 1.58: An open\-source AirPlay mirroring server based on RPiPlay
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B
|
||||
@@ -79,6 +79,8 @@ UxPlay 1.57: An open\-source AirPlay mirroring server based on RPiPlay
|
||||
.TP
|
||||
\fB\-nc\fR Do not close video window when client stops mirroring
|
||||
.TP
|
||||
\fB\-nohold\fR Drop current connection when new client connects.
|
||||
.TP
|
||||
\fB\-FPSdata\fR Show video-streaming performance reports sent by client.
|
||||
.TP
|
||||
\fB\-fps\fR n Set maximum allowed streaming framerate, default 30
|
||||
|
||||
16
uxplay.cpp
16
uxplay.cpp
@@ -50,7 +50,7 @@
|
||||
#include "renderers/video_renderer.h"
|
||||
#include "renderers/audio_renderer.h"
|
||||
|
||||
#define VERSION "1.57"
|
||||
#define VERSION "1.58"
|
||||
|
||||
#define DEFAULT_NAME "UxPlay"
|
||||
#define DEFAULT_DEBUG_LOG false
|
||||
@@ -111,6 +111,7 @@ static bool use_random_hw_addr = false;
|
||||
static unsigned short display[5] = {0}, tcp[3] = {0}, udp[3] = {0};
|
||||
static bool debug_log = DEFAULT_DEBUG_LOG;
|
||||
static bool bt709_fix = false;
|
||||
static int max_connections = 2;
|
||||
|
||||
/* 95 byte png file with a 1x1 white square (single pixel): placeholder for coverart*/
|
||||
static const unsigned char empty_image[] = {
|
||||
@@ -416,7 +417,8 @@ static void print_info (char *name) {
|
||||
printf("-as 0 (or -a) Turn audio off, streamed video only\n");
|
||||
printf("-ca <fn> In Airplay Audio (ALAC) mode, write cover-art to file <fn>\n");
|
||||
printf("-reset n Reset after 3n seconds client silence (default %d, 0=never)\n", NTP_TIMEOUT_LIMIT);
|
||||
printf("-nc do Not Close video window when client stops mirroring\n");
|
||||
printf("-nc do Not Close video window when client stops mirroring\n");
|
||||
printf("-nohold Drop current connection when new client connects.\n");
|
||||
printf("-FPSdata Show video-streaming performance reports sent by client.\n");
|
||||
printf("-fps n Set maximum allowed streaming framerate, default 30\n");
|
||||
printf("-f {H|V|I}Horizontal|Vertical flip, or both=Inversion=rotate 180 deg\n");
|
||||
@@ -763,8 +765,10 @@ void parse_arguments (int argc, char *argv[]) {
|
||||
LOGE("option -ca must be followed by a filename for cover-art output");
|
||||
exit(1);
|
||||
}
|
||||
} else if (arg == "-bt709" ) {
|
||||
} else if (arg == "-bt709") {
|
||||
bt709_fix = true;
|
||||
} else if (arg == "-nohold") {
|
||||
max_connections = 3;
|
||||
} else {
|
||||
LOGE("unknown option %s, stopping\n",argv[i]);
|
||||
exit(1);
|
||||
@@ -953,7 +957,7 @@ extern "C" void conn_destroy (void *cls) {
|
||||
//video_renderer_update_background(-1);
|
||||
open_connections--;
|
||||
LOGI("Open connections: %i", open_connections);
|
||||
if(!open_connections) {
|
||||
if (!open_connections) {
|
||||
connections_stopped = true;
|
||||
}
|
||||
}
|
||||
@@ -1133,8 +1137,8 @@ int start_raop_server (std::vector<char> hw_addr, std::string name, unsigned sho
|
||||
raop_cbs.audio_set_metadata = audio_set_metadata;
|
||||
raop_cbs.audio_set_coverart = audio_set_coverart;
|
||||
|
||||
/* set max number of connections = 2 */
|
||||
raop = raop_init(2, &raop_cbs);
|
||||
/* set max number of connections = 2 to protect against capture by new client */
|
||||
raop = raop_init(max_connections, &raop_cbs);
|
||||
if (raop == NULL) {
|
||||
LOGE("Error initializing raop!");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user