mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
more infrastructure for diifferent audio formats
This commit is contained in:
@@ -53,10 +53,19 @@ struct raop_buffer_s {
|
||||
unsigned short first_seqnum;
|
||||
unsigned short last_seqnum;
|
||||
|
||||
/* audio parameters */
|
||||
audio_format_t audio_format;
|
||||
bool using_screen;
|
||||
|
||||
/* RTP buffer entries */
|
||||
raop_buffer_entry_t entries[RAOP_BUFFER_LENGTH];
|
||||
};
|
||||
|
||||
void raop_buffer_set_audio_parameters(raop_buffer_t *raop_buffer, audio_format_t *audio_format, bool *using_screen) {
|
||||
assert(raop_buffer);
|
||||
raop_buffer->audio_format = *audio_format;
|
||||
raop_buffer->using_screen = *using_screen;
|
||||
}
|
||||
void
|
||||
raop_buffer_init_key_iv(raop_buffer_t *raop_buffer,
|
||||
const unsigned char *aeskey,
|
||||
|
||||
@@ -34,5 +34,6 @@ void raop_buffer_flush(raop_buffer_t *raop_buffer, int next_seq);
|
||||
int raop_buffer_decrypt(raop_buffer_t *raop_buffer, unsigned char *data, unsigned char* output,
|
||||
unsigned int datalen, unsigned int *outputlen);
|
||||
void raop_buffer_destroy(raop_buffer_t *raop_buffer);
|
||||
void raop_buffer_set_audio_parameters(raop_buffer_t *raop_buffer, audio_format_t *audio_format, bool *using_screen);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -431,45 +431,70 @@ raop_handler_setup(raop_conn_t *conn,
|
||||
break;
|
||||
} case 96: {
|
||||
// Audio
|
||||
|
||||
unsigned short cport = conn->raop->control_lport, dport = conn->raop->data_lport;
|
||||
audio_format_t audio_format = AAC_ELD;
|
||||
bool using_screen = true;
|
||||
audio_format_t audioFormat = UNKNOWN;
|
||||
bool usingScreen = false;
|
||||
unsigned short spf = 0, ct = 0, redundantAudio = 0;
|
||||
unsigned int latencyMax, latencyMin;
|
||||
|
||||
plist_type ptype;
|
||||
uint64_t uint_val;
|
||||
uint8_t bool_val;
|
||||
|
||||
/* get audio parameter of connection */
|
||||
uint64_t audioFormat;
|
||||
plist_t audio_format_node = plist_dict_get_item(req_stream_node, "audioFormat");
|
||||
plist_get_uint_val(audio_format_node, &audioFormat);
|
||||
audio_format = get_audio_format( (int) audioFormat);
|
||||
logger_log(conn->raop->logger, LOGGER_DEBUG, "audioFormat = 0X%X %s", audioFormat, audio_format_name(audio_format));
|
||||
plist_get_uint_val(audio_format_node, &uint_val);
|
||||
audioFormat = get_audio_format( (int) uint_val);
|
||||
logger_log(conn->raop->logger, LOGGER_INFO, "audioFormat = 0X%X %s", audioFormat, audio_format_name(audioFormat));
|
||||
|
||||
if (audio_format == UNKNOWN) {
|
||||
logger_log(conn->raop->logger, LOGGER_ERR, "RAOP cannot play UNKNOWN audio format 0X%X\n", (int) audioFormat);
|
||||
if (audioFormat == UNKNOWN) {
|
||||
logger_log(conn->raop->logger, LOGGER_ERR, "RAOP cannot play UNKNOWN audio format 0X%X\n", (int) uint_val);
|
||||
http_response_set_disconnect(response, 1);
|
||||
}
|
||||
|
||||
uint8_t usingScreen;
|
||||
plist_t using_screen_node = plist_dict_get_item(req_stream_node, "usingScreen");
|
||||
plist_get_bool_val(using_screen_node, &usingScreen);
|
||||
using_screen = (usingScreen == 0) ? false : true;
|
||||
|
||||
uint64_t latencyMax, redundantAudio, latencyMin, ct, spf;
|
||||
plist_t latency_max_node = plist_dict_get_item(req_stream_node, "latencyMax");
|
||||
plist_get_uint_val(latency_max_node, &latencyMax);
|
||||
plist_t redundant_audio_node = plist_dict_get_item(req_stream_node, "redundantAudio");
|
||||
plist_get_uint_val(redundant_audio_node, &redundantAudio);
|
||||
plist_t latency_min_node = plist_dict_get_item(req_stream_node, "latencyMin");
|
||||
plist_get_uint_val(latency_min_node, &latencyMin);
|
||||
plist_t ct_node = plist_dict_get_item(req_stream_node, "ct");
|
||||
plist_get_uint_val(ct_node, &ct);
|
||||
plist_t using_screen_node = plist_dict_get_item(req_stream_node, "usingScreen");
|
||||
ptype = plist_get_node_type(using_screen_node);
|
||||
if (ptype == PLIST_BOOLEAN){
|
||||
plist_get_bool_val(using_screen_node, &bool_val);
|
||||
if (bool_val) {
|
||||
usingScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
plist_t spf_node = plist_dict_get_item(req_stream_node, "spf");
|
||||
plist_get_uint_val(spf_node, &spf);
|
||||
ptype = plist_get_node_type(spf_node);
|
||||
if(ptype == PLIST_UINT) {
|
||||
plist_get_uint_val(spf_node, &uint_val);
|
||||
spf = (unsigned short) uint_val;
|
||||
}
|
||||
|
||||
plist_t ct_node = plist_dict_get_item(req_stream_node, "ct");
|
||||
ptype = plist_get_node_type(ct_node);
|
||||
if(ptype == PLIST_UINT) {
|
||||
plist_get_uint_val(ct_node, &uint_val);
|
||||
ct = (unsigned short) uint_val;
|
||||
}
|
||||
|
||||
logger_log(conn->raop->logger, LOGGER_DEBUG, "%d %d %d %d %d %d %d", latencyMax, redundantAudio, latencyMin, ct, spf, using_screen);
|
||||
plist_t redundant_audio_node = plist_dict_get_item(req_stream_node, "redundantAudio");
|
||||
ptype = plist_get_node_type(redundant_audio_node);
|
||||
if(ptype == PLIST_UINT) {
|
||||
plist_get_uint_val(redundant_audio_node, &uint_val);
|
||||
redundantAudio = (unsigned short) uint_val;
|
||||
}
|
||||
|
||||
plist_t latency_max_node = plist_dict_get_item(req_stream_node, "latencyMax");
|
||||
plist_get_uint_val(latency_max_node, &uint_val);
|
||||
latencyMax = (unsigned int) uint_val;
|
||||
|
||||
plist_t latency_min_node = plist_dict_get_item(req_stream_node, "latencyMin");
|
||||
plist_get_uint_val(latency_min_node, &uint_val);
|
||||
latencyMin = (unsigned int) uint_val;
|
||||
|
||||
logger_log(conn->raop->logger, LOGGER_DEBUG, "audio stream properties: %d %d %d %d %d %d", latencyMax, redundantAudio, latencyMin, ct, spf, usingScreen);
|
||||
|
||||
if (conn->raop_rtp) {
|
||||
raop_rtp_start_audio(conn->raop_rtp, use_udp, remote_cport, &cport, &dport, &audio_format, &using_screen);
|
||||
raop_rtp_start_audio(conn->raop_rtp, use_udp, remote_cport, &cport, &dport, &audioFormat, &usingScreen);
|
||||
logger_log(conn->raop->logger, LOGGER_DEBUG, "RAOP initialized success");
|
||||
} else {
|
||||
logger_log(conn->raop->logger, LOGGER_ERR, "RAOP not initialized at SETUP, playing will fail!");
|
||||
|
||||
@@ -98,10 +98,6 @@ struct raop_rtp_s {
|
||||
unsigned short control_lport;
|
||||
unsigned short data_lport;
|
||||
|
||||
/* connection-time audio parameters from client */
|
||||
audio_format_t audio_format;
|
||||
bool using_screen;
|
||||
|
||||
/* Initialized after the first control packet */
|
||||
struct sockaddr_storage control_saddr;
|
||||
socklen_t control_saddr_len;
|
||||
@@ -537,16 +533,14 @@ raop_rtp_start_audio(raop_rtp_t *raop_rtp, int use_udp, unsigned short control_r
|
||||
int use_ipv6 = 0;
|
||||
|
||||
assert(raop_rtp);
|
||||
|
||||
raop_buffer_set_audio_parameters(raop_rtp->buffer, audio_format, using_screen);
|
||||
|
||||
MUTEX_LOCK(raop_rtp->run_mutex);
|
||||
if (raop_rtp->running || !raop_rtp->joined) {
|
||||
MUTEX_UNLOCK(raop_rtp->run_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
raop_rtp->audio_format = *audio_format;
|
||||
raop_rtp->using_screen = *using_screen;
|
||||
|
||||
/* Initialize ports and sockets */
|
||||
raop_rtp->control_lport = *control_lport;
|
||||
raop_rtp->data_lport = *data_lport;
|
||||
|
||||
Reference in New Issue
Block a user