Clang cleanup
This commit is contained in:
+4
-2
@@ -56,7 +56,8 @@ pthread_mutex_t activity_monitor_mutex;
|
||||
pthread_cond_t activity_monitor_cv;
|
||||
|
||||
void going_active(int block) {
|
||||
// debug(1, "activity_monitor: state transitioning to \"active\" with%s blocking", block ? "" : "out");
|
||||
// debug(1, "activity_monitor: state transitioning to \"active\" with%s blocking", block ? "" :
|
||||
// "out");
|
||||
if (config.cmd_active_start)
|
||||
command_execute(config.cmd_active_start, "", block);
|
||||
#ifdef CONFIG_METADATA
|
||||
@@ -75,7 +76,8 @@ void going_active(int block) {
|
||||
}
|
||||
|
||||
void going_inactive(int block) {
|
||||
// debug(1, "activity_monitor: state transitioning to \"inactive\" with%s blocking", block ? "" : "out");
|
||||
// debug(1, "activity_monitor: state transitioning to \"inactive\" with%s blocking", block ? "" :
|
||||
// "out");
|
||||
if (config.cmd_active_stop)
|
||||
command_execute(config.cmd_active_stop, "", block);
|
||||
#ifdef CONFIG_METADATA
|
||||
|
||||
+5
-6
@@ -222,10 +222,9 @@ static void do_start() {
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
}
|
||||
|
||||
|
||||
static void start(__attribute__((unused)) int sample_rate,
|
||||
__attribute__((unused)) int sample_format) {
|
||||
do_start();
|
||||
do_start();
|
||||
}
|
||||
|
||||
static int stream_is_open() {
|
||||
@@ -247,7 +246,7 @@ static int play(void *buf, int samples, __attribute__((unused)) int sample_type,
|
||||
if (stream_is_open() == 0) {
|
||||
// debug(1,"pa open stream before play.");
|
||||
do_start();
|
||||
}
|
||||
}
|
||||
if (stream_is_open() != 0) {
|
||||
// copy the samples into the queue
|
||||
size_t bytes_to_transfer = samples * 2 * 2;
|
||||
@@ -287,7 +286,7 @@ int pa_delay(long *the_delay) {
|
||||
// debug(1,"pa open stream before delay.");
|
||||
do_start();
|
||||
}
|
||||
if (stream_is_open() != 0) {
|
||||
if (stream_is_open() != 0) {
|
||||
pa_usec_t latency;
|
||||
int negative;
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
@@ -304,7 +303,7 @@ int pa_delay(long *the_delay) {
|
||||
reply = 0;
|
||||
}
|
||||
} else {
|
||||
// debug(2, "could not open pa stream for delay");
|
||||
// debug(2, "could not open pa stream for delay");
|
||||
}
|
||||
*the_delay = result;
|
||||
return reply;
|
||||
@@ -327,7 +326,7 @@ void flush(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void stop(void) {
|
||||
static void stop(void) {
|
||||
// debug(1,"Stop.");
|
||||
if (stream_is_open() != 0) {
|
||||
// Cork the stream so it will stop playing
|
||||
|
||||
+3
-1
@@ -141,7 +141,9 @@ static void deinit(void) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void help(void) { printf(" Provide the pipe's pathname. The default is \"%s\".\n", default_pipe_name); }
|
||||
static void help(void) {
|
||||
printf(" Provide the pipe's pathname. The default is \"%s\".\n", default_pipe_name);
|
||||
}
|
||||
|
||||
audio_output audio_pipe = {.name = "pipe",
|
||||
.help = &help,
|
||||
|
||||
@@ -803,8 +803,9 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
|
||||
case 'canp': // nowplaying 4 ids: dbid, plid, playlistItem, itemid (from mellowware
|
||||
// see reference above)
|
||||
debug(2, "DACP Composite ID seen");
|
||||
if ((metadata_store.item_composite_id_is_valid == 0) || (memcmp(metadata_store.item_composite_id, sp - item_size,
|
||||
sizeof(metadata_store.item_composite_id)) != 0)) {
|
||||
if ((metadata_store.item_composite_id_is_valid == 0) ||
|
||||
(memcmp(metadata_store.item_composite_id, sp - item_size,
|
||||
sizeof(metadata_store.item_composite_id)) != 0)) {
|
||||
memcpy(metadata_store.item_composite_id, sp - item_size,
|
||||
sizeof(metadata_store.item_composite_id));
|
||||
char st[33];
|
||||
|
||||
+9
-8
@@ -68,7 +68,8 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
argc->airplay_volume);
|
||||
|
||||
shairport_sync_remote_control_set_client(shairportSyncRemoteControlSkeleton, argc->client_ip);
|
||||
shairport_sync_remote_control_set_client_name(shairportSyncRemoteControlSkeleton, argc->client_name);
|
||||
shairport_sync_remote_control_set_client_name(shairportSyncRemoteControlSkeleton,
|
||||
argc->client_name);
|
||||
|
||||
// although it's a DACP server, the server is in fact, part of the the AirPlay "client" (their
|
||||
// term).
|
||||
@@ -102,11 +103,9 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
if ((th == NULL) || (strcasecmp(th, argc->stream_type) != 0)) {
|
||||
// debug(1, "Stream type string should be changed");
|
||||
shairport_sync_remote_control_set_stream_type(shairportSyncRemoteControlSkeleton,
|
||||
argc->stream_type);
|
||||
argc->stream_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (argc->player_state) {
|
||||
case PS_NOT_AVAILABLE:
|
||||
@@ -224,8 +223,9 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
}
|
||||
|
||||
// Add in the Song Data Kind based on the 'asdk' metadata if it is valid
|
||||
// It seems that this is 0 for a timed play, e.g. a track or an album, but is 1 for an untimed play, such as a stream.
|
||||
|
||||
// It seems that this is 0 for a timed play, e.g. a track or an album, but is 1 for an untimed
|
||||
// play, such as a stream.
|
||||
|
||||
if (argc->song_data_kind_is_valid != 0) {
|
||||
GVariant *songdatakind = g_variant_new_uint32(argc->song_data_kind);
|
||||
g_variant_builder_add(dict_builder, "{sv}", "sps:songdatakind", songdatakind);
|
||||
@@ -1042,7 +1042,8 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
|
||||
|
||||
shairport_sync_set_service_name(SHAIRPORT_SYNC(shairportSyncSkeleton), config.service_name);
|
||||
shairport_sync_set_output_rate(SHAIRPORT_SYNC(shairportSyncSkeleton), config.output_rate);
|
||||
shairport_sync_set_output_format(SHAIRPORT_SYNC(shairportSyncSkeleton), sps_format_description_string(config.output_format));
|
||||
shairport_sync_set_output_format(SHAIRPORT_SYNC(shairportSyncSkeleton),
|
||||
sps_format_description_string(config.output_format));
|
||||
|
||||
#ifdef CONFIG_AIRPLAY_2
|
||||
shairport_sync_set_protocol(SHAIRPORT_SYNC(shairportSyncSkeleton), "AirPlay 2");
|
||||
@@ -1157,7 +1158,7 @@ void stop_dbus_service() {
|
||||
if (ownerID) {
|
||||
g_bus_unown_name(ownerID);
|
||||
} else if (service_is_running != 0) {
|
||||
debug(1, "Zero OwnerID for running \"org.gnome.ShairportSync\" dbus service.");
|
||||
debug(1, "Zero OwnerID for running \"org.gnome.ShairportSync\" dbus service.");
|
||||
}
|
||||
service_is_running = 0;
|
||||
}
|
||||
|
||||
+15
-14
@@ -337,7 +337,7 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
|
||||
// Some metadata items are contained in one metadata packet.
|
||||
// The start of the metadata packet is signalled by an 'ssnc' 'mdst' item and
|
||||
// the end of it by an 'ssnc 'mden' item.
|
||||
// the end of it by an 'ssnc 'mden' item.
|
||||
// We don't set "changed" for them individually; instead we set it when the 'mden' token
|
||||
// comes in if the metadata_packet_item_changed item is set by parsed items
|
||||
// within the packet.
|
||||
@@ -351,10 +351,11 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
switch (code) {
|
||||
case 'asdk': {
|
||||
// get the one-byte number as an unsigned number
|
||||
int song_data_kind = data[0]; // one byte
|
||||
int song_data_kind = data[0]; // one byte
|
||||
song_data_kind = song_data_kind & 0xFF; // unsigned
|
||||
debug(2, "MH Song Data Kind seen: \"%d\" of length %u.", song_data_kind, length);
|
||||
if ((song_data_kind != metadata_store.song_data_kind) || (metadata_store.song_data_kind_is_valid == 0)) {
|
||||
if ((song_data_kind != metadata_store.song_data_kind) ||
|
||||
(metadata_store.song_data_kind_is_valid == 0)) {
|
||||
metadata_store.song_data_kind = song_data_kind;
|
||||
metadata_store.song_data_kind_changed = 1;
|
||||
metadata_store.song_data_kind_is_valid = 1;
|
||||
@@ -380,7 +381,8 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
case 'astm': {
|
||||
uint32_t ui = ntohl(*(uint32_t *)data);
|
||||
debug(2, "MH Song Time seen: \"%u\" of length %u.", ui, length);
|
||||
if ((ui != metadata_store.songtime_in_milliseconds) || (metadata_store.songtime_in_milliseconds_is_valid == 0)) {
|
||||
if ((ui != metadata_store.songtime_in_milliseconds) ||
|
||||
(metadata_store.songtime_in_milliseconds_is_valid == 0)) {
|
||||
metadata_store.songtime_in_milliseconds = ui;
|
||||
metadata_store.songtime_in_milliseconds_changed = 1;
|
||||
metadata_store.songtime_in_milliseconds_is_valid = 1;
|
||||
@@ -584,8 +586,7 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
break;
|
||||
case 'styp':
|
||||
cs = strndup(data, length);
|
||||
if (string_update(&metadata_store.stream_type, &metadata_store.stream_type_changed,
|
||||
cs)) {
|
||||
if (string_update(&metadata_store.stream_type, &metadata_store.stream_type_changed, cs)) {
|
||||
changed = 1;
|
||||
debug(2, "MH Stream Type set to: \"%s\"", metadata_store.stream_type);
|
||||
}
|
||||
@@ -624,14 +625,14 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
changed = (metadata_store.player_state != PS_PAUSED);
|
||||
metadata_store.player_state = PS_PAUSED;
|
||||
break;
|
||||
/*
|
||||
// not using this anymore.
|
||||
case 'pffr': // this is sent when the first frame has been received
|
||||
case 'prsm':
|
||||
changed = (metadata_store.player_state != PS_PLAYING);
|
||||
metadata_store.player_state = PS_PLAYING;
|
||||
break;
|
||||
*/
|
||||
/*
|
||||
// not using this anymore.
|
||||
case 'pffr': // this is sent when the first frame has been received
|
||||
case 'prsm':
|
||||
changed = (metadata_store.player_state != PS_PLAYING);
|
||||
metadata_store.player_state = PS_PLAYING;
|
||||
break;
|
||||
*/
|
||||
case 'pvol': {
|
||||
// Note: it's assumed that the config.airplay volume has already been correctly set.
|
||||
// int32_t actual_volume;
|
||||
|
||||
@@ -179,9 +179,10 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le
|
||||
mqtt_publish("songalbum", data, length);
|
||||
break;
|
||||
case 'asdk':
|
||||
mqtt_publish("songdatakind", data, length); // 0 seem to be a timed item, 1 an untimed stream
|
||||
mqtt_publish("songdatakind", data,
|
||||
length); // 0 seem to be a timed item, 1 an untimed stream
|
||||
break;
|
||||
case 'clip':
|
||||
case 'clip':
|
||||
mqtt_publish("client_ip", data, length);
|
||||
break;
|
||||
case 'cdid':
|
||||
|
||||
@@ -374,7 +374,9 @@ static void init_buffer(rtsp_conn_info *conn) {
|
||||
// conn->max_frames_per_packet);
|
||||
void *allocation = malloc(8 * conn->max_frames_per_packet);
|
||||
if (allocation == NULL) {
|
||||
die("could not allocate memory for audio buffers. %" PRId64 " buffers allocated, %" PRId64 " buffers released.", buffers_allocated, buffers_released);
|
||||
die("could not allocate memory for audio buffers. %" PRId64 " buffers allocated, %" PRId64
|
||||
" buffers released.",
|
||||
buffers_allocated, buffers_released);
|
||||
} else {
|
||||
conn->audio_buffer[i].data = allocation;
|
||||
buffers_allocated++;
|
||||
@@ -388,7 +390,8 @@ static void free_audio_buffers(rtsp_conn_info *conn) {
|
||||
free(conn->audio_buffer[i].data);
|
||||
buffers_released++;
|
||||
}
|
||||
debug(1, "%" PRId64 " buffers allocated, %" PRId64 " buffers released.", buffers_allocated, buffers_released);
|
||||
debug(1, "%" PRId64 " buffers allocated, %" PRId64 " buffers released.", buffers_allocated,
|
||||
buffers_released);
|
||||
}
|
||||
|
||||
int first_possibly_missing_frame = -1;
|
||||
@@ -2741,34 +2744,38 @@ void *player_thread_func(void *arg) {
|
||||
#ifdef CONFIG_AIRPLAY_2
|
||||
if (conn->airplay_stream_type == realtime_stream) {
|
||||
if (conn->airplay_type == ap_1) {
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
send_ssnc_metadata('styp', "Classic", strlen("Classic"), 1);
|
||||
#endif
|
||||
if (config.statistics_requested)
|
||||
inform("Connection %d: Playback started at frame %" PRId64 " -- AirPlay 1 Compatible.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
inform("Connection %d: Playback started at frame %" PRId64
|
||||
" -- AirPlay 1 Compatible.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
} else {
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
send_ssnc_metadata('styp', "Realtime", strlen("Realtime"), 1);
|
||||
#endif
|
||||
if (config.statistics_requested)
|
||||
inform("Connection %d: Playback started at frame %" PRId64 " -- AirPlay 2 Realtime.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
inform("Connection %d: Playback started at frame %" PRId64
|
||||
" -- AirPlay 2 Realtime.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
send_ssnc_metadata('styp', "Buffered", strlen("Buffered"), 1);
|
||||
#endif
|
||||
if (config.statistics_requested)
|
||||
inform("Connection %d: Playback started at frame %" PRId64 " -- AirPlay 2 Buffered.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
inform("Connection %d: Playback started at frame %" PRId64
|
||||
" -- AirPlay 2 Buffered.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
}
|
||||
#else
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
send_ssnc_metadata('styp', "Classic", strlen("Classic"), 1);
|
||||
#endif
|
||||
if (config.statistics_requested)
|
||||
inform("Connection %d: Playback started at frame %" PRId64 " -- AirPlay 1.", conn->connection_number, inframe->given_timestamp);
|
||||
inform("Connection %d: Playback started at frame %" PRId64 " -- AirPlay 1.",
|
||||
conn->connection_number, inframe->given_timestamp);
|
||||
#endif
|
||||
}
|
||||
// not too sure if abs() is implemented for int64_t, so we'll do it manually
|
||||
|
||||
@@ -2842,12 +2842,12 @@ void *rtp_buffered_audio_processor(void *arg) {
|
||||
|
||||
// https://libsodium.gitbook.io/doc/secret-key_cryptography/aead/chacha20-poly1305/ietf_chacha20-poly1305_construction
|
||||
// Note: the eight-byte nonce must be front-padded out to 12 bytes.
|
||||
|
||||
|
||||
response = crypto_aead_chacha20poly1305_ietf_decrypt(
|
||||
m + 7, // m
|
||||
&new_payload_length, // mlen_p
|
||||
NULL, // nsec,
|
||||
packet + 12, // the ciphertext starts 12 bytes in and is followed by the MAC tag,
|
||||
packet + 12, // the ciphertext starts 12 bytes in and is followed by the MAC tag,
|
||||
nread - (8 + 12), // clen -- the last 8 bytes are the nonce
|
||||
packet + 4, // authenticated additional data
|
||||
8, // authenticated additional data length
|
||||
|
||||
@@ -1219,12 +1219,13 @@ ssize_t timed_read_from_rtsp_connection(rtsp_conn_info *conn, uint64_t wait_time
|
||||
ssize_t result = 0; // closed
|
||||
if (conn->fd > 0) {
|
||||
int64_t remaining_time = 0;
|
||||
uint64_t time_to_wait_to = get_absolute_time_in_ns();;
|
||||
uint64_t time_to_wait_to = get_absolute_time_in_ns();
|
||||
;
|
||||
time_to_wait_to = time_to_wait_to + wait_time;
|
||||
|
||||
// remaining_time will be zero if wait_time is zero
|
||||
if (wait_time != 0) {
|
||||
remaining_time = time_to_wait_to - get_absolute_time_in_ns();
|
||||
remaining_time = time_to_wait_to - get_absolute_time_in_ns();
|
||||
}
|
||||
do {
|
||||
struct timeval tv;
|
||||
@@ -1240,7 +1241,8 @@ ssize_t timed_read_from_rtsp_connection(rtsp_conn_info *conn, uint64_t wait_time
|
||||
#ifdef CONFIG_AIRPLAY_2
|
||||
if (conn->ap2_pairing_context.control_cipher_bundle.cipher_ctx) {
|
||||
conn->ap2_pairing_context.control_cipher_bundle.is_encrypted = 1;
|
||||
result = read_encrypted(conn->fd, &conn->ap2_pairing_context.control_cipher_bundle, buf, count);
|
||||
result =
|
||||
read_encrypted(conn->fd, &conn->ap2_pairing_context.control_cipher_bundle, buf, count);
|
||||
} else {
|
||||
result = read(conn->fd, buf, count);
|
||||
}
|
||||
@@ -1250,11 +1252,13 @@ ssize_t timed_read_from_rtsp_connection(rtsp_conn_info *conn, uint64_t wait_time
|
||||
if (wait_time != 0)
|
||||
remaining_time = time_to_wait_to - get_absolute_time_in_ns();
|
||||
if (((result == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) && (remaining_time > 0))
|
||||
debug(1,"remaining time on a timed read is %" PRId64 " ns.", remaining_time);
|
||||
} while (((result == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) && (remaining_time > 0));
|
||||
debug(1, "remaining time on a timed read is %" PRId64 " ns.", remaining_time);
|
||||
} while (((result == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) &&
|
||||
(remaining_time > 0));
|
||||
|
||||
} else {
|
||||
debug(1,"Connection %d: attempt to read from a closed RTSP connection.",conn->connection_number);
|
||||
debug(1, "Connection %d: attempt to read from a closed RTSP connection.",
|
||||
conn->connection_number);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1268,9 +1272,7 @@ void set_client_as_ptp_clock(rtsp_conn_info *conn) {
|
||||
ptp_send_control_message_string(timing_list_message);
|
||||
}
|
||||
|
||||
void clear_ptp_clock() {
|
||||
ptp_send_control_message_string("T");
|
||||
}
|
||||
void clear_ptp_clock() { ptp_send_control_message_string("T"); }
|
||||
#endif
|
||||
|
||||
ssize_t read_from_rtsp_connection(rtsp_conn_info *conn, void *buf, size_t count) {
|
||||
@@ -1341,9 +1343,8 @@ enum rtsp_read_request_response rtsp_read_request(rtsp_conn_info *conn, rtsp_mes
|
||||
nread = read_from_rtsp_connection(conn, buf + inbuf, buflen - inbuf);
|
||||
|
||||
if (nread == 0) {
|
||||
// a blocking read that returns zero means eof -- implies connection closed by client
|
||||
debug(1, "Connection %d: Connection closed by client.",
|
||||
conn->connection_number);
|
||||
// a blocking read that returns zero means eof -- implies connection closed by client
|
||||
debug(1, "Connection %d: Connection closed by client.", conn->connection_number);
|
||||
reply = rtsp_read_request_response_channel_closed;
|
||||
// Note: the socket will be closed when the thread exits
|
||||
goto shutdown;
|
||||
@@ -1669,7 +1670,6 @@ void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
|
||||
#ifdef CONFIG_AIRPLAY_2
|
||||
|
||||
|
||||
void handle_get_info(__attribute((unused)) rtsp_conn_info *conn, rtsp_message *req,
|
||||
rtsp_message *resp) {
|
||||
debug_log_rtsp_message(2, "GET /info:", req);
|
||||
@@ -1891,8 +1891,8 @@ void handle_flushbuffered(rtsp_conn_info *conn, rtsp_message *req, rtsp_message
|
||||
if ((conn->ap2_flush_requested != 0) && (conn->ap2_flush_from_valid != 0) &&
|
||||
(flushFromValid != 0)) {
|
||||
// if there is a request already, and it's a deferred request, and the current request is also
|
||||
// deferred... do nothing! -- leave the starting point in place. Yeah, yeah, we know de Morgan's
|
||||
// Law, but this seems clearer
|
||||
// deferred... do nothing! -- leave the starting point in place. Yeah, yeah, we know de
|
||||
// Morgan's Law, but this seems clearer
|
||||
} else {
|
||||
conn->ap2_flush_from_sequence_number = flushFromSeq;
|
||||
conn->ap2_flush_from_rtp_timestamp = flushFromTS;
|
||||
@@ -1912,7 +1912,7 @@ void handle_flushbuffered(rtsp_conn_info *conn, rtsp_message *req, rtsp_message
|
||||
debug(2, "Deferred Flush Requested");
|
||||
else
|
||||
debug(2, "Immediate Flush Requested");
|
||||
|
||||
|
||||
plist_free(messagePlist);
|
||||
// display_all_flush_requests(conn);
|
||||
}
|
||||
@@ -2011,7 +2011,7 @@ void handle_setrateanchori(rtsp_conn_info *conn, rtsp_message *req, rtsp_message
|
||||
#ifdef CONFIG_METADATA
|
||||
send_ssnc_metadata('paus', NULL, 0, 1); // pause -- contains cancellation points
|
||||
#endif
|
||||
if (config.output->stop) {
|
||||
if (config.output->stop) {
|
||||
debug(2, "Connection %d: Stop the output backend.", conn->connection_number);
|
||||
config.output->stop();
|
||||
}
|
||||
@@ -2567,38 +2567,38 @@ void handle_setpeers(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp
|
||||
debug(2, "Connection %d: SETPEERS %s Content-Length %d", conn->connection_number, req->path,
|
||||
req->contentlength);
|
||||
debug_log_rtsp_message(2, "SETPEERS request", req);
|
||||
/*
|
||||
char timing_list_message[4096];
|
||||
timing_list_message[0] = 'T';
|
||||
timing_list_message[1] = 0;
|
||||
/*
|
||||
char timing_list_message[4096];
|
||||
timing_list_message[0] = 'T';
|
||||
timing_list_message[1] = 0;
|
||||
|
||||
// ensure the client itself is first -- it's okay if it's duplicated later
|
||||
strncat(timing_list_message, " ", sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
strncat(timing_list_message, (const char *)&conn->client_ip_string,
|
||||
sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
// ensure the client itself is first -- it's okay if it's duplicated later
|
||||
strncat(timing_list_message, " ", sizeof(timing_list_message) - 1 -
|
||||
strlen(timing_list_message)); strncat(timing_list_message, (const char
|
||||
*)&conn->client_ip_string, sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
|
||||
plist_t addresses_array = NULL;
|
||||
plist_from_memory(req->content, req->contentlength, &addresses_array);
|
||||
uint32_t items = plist_array_get_size(addresses_array);
|
||||
if (items) {
|
||||
uint32_t item;
|
||||
for (item = 0; item < items; item++) {
|
||||
plist_t n = plist_array_get_item(addresses_array, item);
|
||||
char *ip_address = NULL;
|
||||
plist_get_string_val(n, &ip_address);
|
||||
// debug(1,ip_address);
|
||||
strncat(timing_list_message, " ",
|
||||
sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
strncat(timing_list_message, ip_address,
|
||||
sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
if (ip_address != NULL)
|
||||
free(ip_address);
|
||||
plist_t addresses_array = NULL;
|
||||
plist_from_memory(req->content, req->contentlength, &addresses_array);
|
||||
uint32_t items = plist_array_get_size(addresses_array);
|
||||
if (items) {
|
||||
uint32_t item;
|
||||
for (item = 0; item < items; item++) {
|
||||
plist_t n = plist_array_get_item(addresses_array, item);
|
||||
char *ip_address = NULL;
|
||||
plist_get_string_val(n, &ip_address);
|
||||
// debug(1,ip_address);
|
||||
strncat(timing_list_message, " ",
|
||||
sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
strncat(timing_list_message, ip_address,
|
||||
sizeof(timing_list_message) - 1 - strlen(timing_list_message));
|
||||
if (ip_address != NULL)
|
||||
free(ip_address);
|
||||
}
|
||||
ptp_send_control_message_string(timing_list_message);
|
||||
}
|
||||
ptp_send_control_message_string(timing_list_message);
|
||||
}
|
||||
plist_free(addresses_array);
|
||||
*/
|
||||
//set_client_as_ptp_clock(conn);
|
||||
plist_free(addresses_array);
|
||||
*/
|
||||
// set_client_as_ptp_clock(conn);
|
||||
resp->respcode = 200;
|
||||
}
|
||||
#endif
|
||||
@@ -2845,7 +2845,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
plist_t messagePlist = plist_from_rtsp_content(req);
|
||||
plist_t setupResponsePlist = plist_new_dict();
|
||||
resp->respcode = 400;
|
||||
|
||||
|
||||
// see if we can get a name for the client
|
||||
char *clientNameString = NULL;
|
||||
plist_t nameItem = plist_dict_get_item(messagePlist, "name");
|
||||
@@ -2864,7 +2864,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
"and open a TCP port.",
|
||||
conn->connection_number);
|
||||
conn->airplay_stream_category = unspecified_stream_category;
|
||||
|
||||
|
||||
// figure out what category of stream it is, by looking at the plist
|
||||
plist_t timingProtocol = plist_dict_get_item(messagePlist, "timingProtocol");
|
||||
if (timingProtocol != NULL) {
|
||||
@@ -2873,8 +2873,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
if (timingProtocolString) {
|
||||
if (strcmp(timingProtocolString, "PTP") == 0) {
|
||||
debug(1, "Connection %d: AP2 PTP connection from %s:%u (\"%s\") to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
clientNameString, conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->airplay_stream_category = ptp_stream;
|
||||
conn->timing_type = ts_ptp;
|
||||
#ifdef CONFIG_METADATA
|
||||
@@ -2888,23 +2888,27 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
#endif
|
||||
} else if (strcmp(timingProtocolString, "NTP") == 0) {
|
||||
debug(1, "Connection %d: SETUP: NTP setup from %s:%u (\"%s\") to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
clientNameString, conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->airplay_stream_category = ntp_stream;
|
||||
conn->timing_type = ts_ntp;
|
||||
} else if (strcmp(timingProtocolString, "None") == 0) {
|
||||
debug(3, "Connection %d: SETUP: a \"None\" setup detected from %s:%u (\"%s\") to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
debug(3,
|
||||
"Connection %d: SETUP: a \"None\" setup detected from %s:%u (\"%s\") to self at "
|
||||
"%s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
clientNameString, conn->self_ip_string, conn->self_rtsp_port);
|
||||
// now check to see if it's got the "isRemoteControlOnly" item and check it's true
|
||||
plist_t isRemoteControlOnly = plist_dict_get_item(messagePlist, "isRemoteControlOnly");
|
||||
if (isRemoteControlOnly != NULL) {
|
||||
uint8_t isRemoteControlOnlyBoolean = 0;
|
||||
plist_get_bool_val(isRemoteControlOnly, &isRemoteControlOnlyBoolean);
|
||||
if (isRemoteControlOnlyBoolean != 0) {
|
||||
debug(1, "Connection %d: Remote Control connection from %s:%u (\"%s\") to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
debug(
|
||||
1,
|
||||
"Connection %d: Remote Control connection from %s:%u (\"%s\") to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
clientNameString, conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->airplay_stream_category = remote_control_stream;
|
||||
} else {
|
||||
debug(1,
|
||||
@@ -3037,7 +3041,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
freeifaddrs(addrs);
|
||||
|
||||
// debug(1,"initial timing peer command: \"%s\".", timing_list_message);
|
||||
//ptp_send_control_message_string(timing_list_message);
|
||||
// ptp_send_control_message_string(timing_list_message);
|
||||
set_client_as_ptp_clock(conn);
|
||||
plist_dict_set_item(timingPeerInfoPlist, "Addresses", addresses);
|
||||
plist_dict_set_item(timingPeerInfoPlist, "ID", plist_new_string(conn->self_ip_string));
|
||||
@@ -3158,7 +3162,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
// get the session key -- it must have one
|
||||
|
||||
plist_t item = plist_dict_get_item(stream0, "shk"); // session key
|
||||
uint64_t item_value = 0; // the length
|
||||
uint64_t item_value = 0; // the length
|
||||
plist_get_data_val(item, (char **)&conn->session_key, &item_value);
|
||||
|
||||
// more stuff
|
||||
@@ -3336,7 +3340,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
plist_array_append_item(streams_array, stream0dict);
|
||||
plist_dict_set_item(setupResponsePlist, "streams", streams_array);
|
||||
resp->respcode = 200;
|
||||
|
||||
|
||||
} else if (conn->airplay_stream_category == remote_control_stream) {
|
||||
debug(2, "Connection %d (RC): SETUP: Remote Control Stream received from %s.",
|
||||
conn->connection_number, conn->client_ip_string);
|
||||
@@ -4452,8 +4456,8 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
|
||||
conn->airplay_type = ap_1;
|
||||
conn->timing_type = ts_ntp;
|
||||
debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.",
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
#endif
|
||||
|
||||
conn->stream.type = ast_unknown;
|
||||
@@ -4547,7 +4551,7 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
|
||||
if ((paesiv == NULL) && (prsaaeskey == NULL)) {
|
||||
// debug(1,"Unencrypted session requested?");
|
||||
conn->stream.encrypted = 0;
|
||||
} else if ((paesiv != NULL) && (prsaaeskey != NULL)){
|
||||
} else if ((paesiv != NULL) && (prsaaeskey != NULL)) {
|
||||
conn->stream.encrypted = 1;
|
||||
// debug(1,"Encrypted session requested");
|
||||
} else {
|
||||
@@ -4987,25 +4991,27 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
|
||||
debug(3, "Connection %d: terminating -- closing timing, control and audio sockets...",
|
||||
conn->connection_number);
|
||||
if (conn->control_socket) {
|
||||
debug(3, "Connection %d: terminating -- closing control_socket %d.",
|
||||
conn->connection_number, conn->control_socket);
|
||||
debug(3, "Connection %d: terminating -- closing control_socket %d.", conn->connection_number,
|
||||
conn->control_socket);
|
||||
close(conn->control_socket);
|
||||
conn->control_socket = 0;
|
||||
}
|
||||
if (conn->timing_socket) {
|
||||
debug(3, "Connection %d: terminating -- closing timing_socket %d.",
|
||||
conn->connection_number, conn->timing_socket);
|
||||
debug(3, "Connection %d: terminating -- closing timing_socket %d.", conn->connection_number,
|
||||
conn->timing_socket);
|
||||
close(conn->timing_socket);
|
||||
conn->timing_socket = 0;
|
||||
}
|
||||
if (conn->audio_socket) {
|
||||
debug(3, "Connection %d: terminating -- closing audio_socket %d.",
|
||||
conn->connection_number, conn->audio_socket);
|
||||
debug(3, "Connection %d: terminating -- closing audio_socket %d.", conn->connection_number,
|
||||
conn->audio_socket);
|
||||
close(conn->audio_socket);
|
||||
conn->audio_socket = 0;
|
||||
}
|
||||
if (conn->fd > 0) {
|
||||
debug(2, "Connection %d: terminating -- closing RTSP connection socket %d: from %s:%u to self at %s:%u.",
|
||||
debug(2,
|
||||
"Connection %d: terminating -- closing RTSP connection socket %d: from %s:%u to self at "
|
||||
"%s:%u.",
|
||||
conn->connection_number, conn->fd, conn->client_ip_string, conn->client_rtsp_port,
|
||||
conn->self_ip_string, conn->self_rtsp_port);
|
||||
close(conn->fd);
|
||||
|
||||
+1
-2
@@ -2457,7 +2457,7 @@ int main(int argc, char **argv) {
|
||||
// calculate the 12-hex-digit prefix by hashing the service name.
|
||||
uint8_t ap_md5[16];
|
||||
|
||||
debug(1,"size of hw_addr is %u.", sizeof(config.hw_addr));
|
||||
debug(1, "size of hw_addr is %u.", sizeof(config.hw_addr));
|
||||
#ifdef CONFIG_OPENSSL
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
@@ -2492,7 +2492,6 @@ debug(1,"size of hw_addr is %u.", sizeof(config.hw_addr));
|
||||
|
||||
memcpy(config.ap1_prefix, ap_md5, sizeof(config.ap1_prefix));
|
||||
|
||||
|
||||
#ifdef CONFIG_METADATA
|
||||
metadata_init(); // create the metadata pipe if necessary
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user