add conn to many procedure calls
This commit is contained in:
@@ -782,7 +782,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
|
||||
int64_t reference_timestamp;
|
||||
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
|
||||
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
|
||||
&remote_reference_timestamp_time);
|
||||
&remote_reference_timestamp_time, conn);
|
||||
reference_timestamp *= conn->output_sample_ratio;
|
||||
if (conn->first_packet_timestamp == 0) { // if this is the very first packet
|
||||
// debug(1,"First frame seen, time %u, with %d
|
||||
@@ -943,7 +943,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
|
||||
// not the time of the playing of the first frame
|
||||
uint64_t reference_timestamp_time; // don't need this...
|
||||
get_reference_timestamp_stuff(&play_segment_reference_frame, &reference_timestamp_time,
|
||||
&play_segment_reference_frame_remote_time);
|
||||
&play_segment_reference_frame_remote_time, conn);
|
||||
play_segment_reference_frame *= conn->output_sample_ratio;
|
||||
#ifdef CONFIG_METADATA
|
||||
send_ssnc_metadata('prsm', NULL, 0,
|
||||
@@ -973,7 +973,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
|
||||
int64_t reference_timestamp;
|
||||
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
|
||||
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
|
||||
&remote_reference_timestamp_time); // all types okay
|
||||
&remote_reference_timestamp_time, conn); // all types okay
|
||||
reference_timestamp *= conn->output_sample_ratio;
|
||||
if (reference_timestamp) { // if we have a reference time
|
||||
int64_t packet_timestamp = curframe->timestamp; // types okay
|
||||
@@ -1059,7 +1059,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info* conn) {
|
||||
seq_t next = seq_sum(conn->ab_read, i);
|
||||
abuf = conn->audio_buffer + BUFIDX(next);
|
||||
if (!abuf->ready) {
|
||||
rtp_request_resend(next, 1);
|
||||
rtp_request_resend(next, 1, conn);
|
||||
// debug(1,"Resend %u.",next);
|
||||
conn->resend_requests++;
|
||||
}
|
||||
@@ -1338,9 +1338,9 @@ static void *player_thread_func(void *arg) {
|
||||
|
||||
// create and start the timing, control and audio receiver threads
|
||||
pthread_t rtp_audio_thread, rtp_control_thread, rtp_timing_thread;
|
||||
pthread_create(&rtp_audio_thread, NULL, &rtp_audio_receiver, (void *)conn);
|
||||
pthread_create(&rtp_control_thread, NULL, &rtp_control_receiver, (void *)conn);
|
||||
pthread_create(&rtp_timing_thread, NULL, &rtp_timing_receiver, (void *)conn);
|
||||
pthread_create(&rtp_audio_thread, NULL, &rtp_audio_receiver, (void*) conn);
|
||||
pthread_create(&rtp_control_thread, NULL, &rtp_control_receiver, (void*) conn);
|
||||
pthread_create(&rtp_timing_thread, NULL, &rtp_timing_receiver, (void*) conn);
|
||||
|
||||
session_corrections = 0;
|
||||
play_segment_reference_frame = 0; // zero signals that we are not in a play segment
|
||||
@@ -1604,7 +1604,7 @@ static void *player_thread_func(void *arg) {
|
||||
int64_t reference_timestamp;
|
||||
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
|
||||
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
|
||||
&remote_reference_timestamp_time); // types okay
|
||||
&remote_reference_timestamp_time, conn); // types okay
|
||||
reference_timestamp *= conn->output_sample_ratio;
|
||||
int64_t rt, nt;
|
||||
rt = reference_timestamp; // uint32_t to int64_t
|
||||
|
||||
@@ -94,11 +94,11 @@ static pthread_mutex_t reference_time_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
uint64_t static local_to_remote_time_difference; // used to switch between local and remote clocks
|
||||
|
||||
void *rtp_audio_receiver(void *arg) {
|
||||
void *rtp_audio_receiver(void* arg) {
|
||||
debug(2, "Audio receiver -- Server RTP thread starting.");
|
||||
|
||||
// we inherit the signal mask (SIGUSR1)
|
||||
rtsp_conn_info *conn = arg;
|
||||
rtsp_conn_info *conn = (rtsp_conn_info*)arg;
|
||||
|
||||
int32_t last_seqno = -1;
|
||||
uint8_t packet[2048], *pktp;
|
||||
@@ -193,11 +193,12 @@ void *rtp_audio_receiver(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *rtp_control_receiver(void *arg) {
|
||||
void *rtp_control_receiver(void* arg) {
|
||||
// we inherit the signal mask (SIGUSR1)
|
||||
|
||||
debug(2, "Control receiver -- Server RTP thread starting.");
|
||||
rtsp_conn_info *conn = arg;
|
||||
|
||||
rtsp_conn_info *conn = (rtsp_conn_info*)arg;
|
||||
|
||||
reference_timestamp = 0; // nothing valid received yet
|
||||
uint8_t packet[2048], *pktp;
|
||||
@@ -355,8 +356,7 @@ void *rtp_timing_sender(void *arg) {
|
||||
void *rtp_timing_receiver(void *arg) {
|
||||
debug(2, "Timing receiver -- Server RTP thread starting.");
|
||||
// we inherit the signal mask (SIGUSR1)
|
||||
|
||||
rtsp_conn_info *conn = arg;
|
||||
rtsp_conn_info *conn = (rtsp_conn_info*)arg;
|
||||
|
||||
uint8_t packet[2048], *pktp;
|
||||
ssize_t nread;
|
||||
@@ -500,7 +500,7 @@ void *rtp_timing_receiver(void *arg) {
|
||||
int64_t reference_timestamp;
|
||||
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
|
||||
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
|
||||
&remote_reference_timestamp_time);
|
||||
&remote_reference_timestamp_time, conn);
|
||||
uint64_t frame_difference = 0;
|
||||
if (reference_timestamp >= play_segment_reference_frame)
|
||||
frame_difference = (uint64_t)reference_timestamp - (uint64_t)play_segment_reference_frame;
|
||||
@@ -622,7 +622,7 @@ static int bind_port(int ip_family, const char *self_ip_address, uint32_t scope_
|
||||
}
|
||||
|
||||
void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t active_remote,
|
||||
int *lsport, int *lcport, int *ltport) {
|
||||
int *lsport, int *lcport, int *ltport, rtsp_conn_info *conn) {
|
||||
|
||||
// this gets the local and remote ip numbers (and ports used for the TCD stuff)
|
||||
// we use the local stuff to specify the address we are coming from and
|
||||
@@ -731,7 +731,7 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
|
||||
}
|
||||
|
||||
void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
|
||||
uint64_t *remote_timestamp_time) {
|
||||
uint64_t *remote_timestamp_time, rtsp_conn_info *conn) {
|
||||
// types okay
|
||||
pthread_mutex_lock(&reference_time_mutex);
|
||||
*timestamp = reference_timestamp;
|
||||
@@ -740,19 +740,19 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
|
||||
pthread_mutex_unlock(&reference_time_mutex);
|
||||
}
|
||||
|
||||
void clear_reference_timestamp(void) {
|
||||
void clear_reference_timestamp(rtsp_conn_info *conn) {
|
||||
pthread_mutex_lock(&reference_time_mutex);
|
||||
reference_timestamp = 0;
|
||||
reference_timestamp_time = 0;
|
||||
pthread_mutex_unlock(&reference_time_mutex);
|
||||
}
|
||||
|
||||
void rtp_shutdown(void) {
|
||||
void rtp_shutdown(rtsp_conn_info *conn) {
|
||||
if (!running)
|
||||
debug(1, "rtp_shutdown called without active stream!");
|
||||
|
||||
debug(2, "shutting down RTP thread");
|
||||
clear_reference_timestamp();
|
||||
clear_reference_timestamp(conn);
|
||||
// debug(1,"Shut down audio, control and timing threads");
|
||||
// usleep(3000000); // hack
|
||||
// pthread_kill(rtp_audio_thread, SIGUSR1);
|
||||
@@ -764,7 +764,7 @@ void rtp_shutdown(void) {
|
||||
running = 0;
|
||||
}
|
||||
|
||||
void rtp_request_resend(seq_t first, uint32_t count) {
|
||||
void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
|
||||
if (running) {
|
||||
// if (!request_sent) {
|
||||
debug(3, "requesting resend of %d packets starting at %u.", count, first);
|
||||
@@ -795,7 +795,7 @@ void rtp_request_resend(seq_t first, uint32_t count) {
|
||||
}
|
||||
}
|
||||
|
||||
void rtp_request_client_pause() {
|
||||
void rtp_request_client_pause(rtsp_conn_info *conn) {
|
||||
if (running) {
|
||||
if (client_active_remote == 0) {
|
||||
debug(1, "Can't request a client pause: no valid active remote.");
|
||||
|
||||
@@ -11,14 +11,14 @@ void *rtp_timing_receiver(void *arg);
|
||||
|
||||
void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int controlport, int timingport,
|
||||
uint32_t active_remote, int *local_server_port, int *local_control_port,
|
||||
int *local_timing_port);
|
||||
void rtp_shutdown(void);
|
||||
void rtp_request_resend(seq_t first, uint32_t count);
|
||||
void rtp_request_client_pause(void); // ask the client to pause
|
||||
int *local_timing_port, rtsp_conn_info* conn);
|
||||
void rtp_shutdown(rtsp_conn_info* conn);
|
||||
void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info* conn);
|
||||
void rtp_request_client_pause(rtsp_conn_info* conn); // ask the client to pause
|
||||
|
||||
void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
|
||||
uint64_t *remote_timestamp_time);
|
||||
void clear_reference_timestamp(void);
|
||||
uint64_t *remote_timestamp_time, rtsp_conn_info* conn);
|
||||
void clear_reference_timestamp(rtsp_conn_info* conn);
|
||||
|
||||
uint64_t static local_to_remote_time_jitters;
|
||||
uint64_t static local_to_remote_time_jitters_count;
|
||||
|
||||
@@ -797,7 +797,7 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *
|
||||
tport = atoi(p);
|
||||
|
||||
// rtsp_take_player();
|
||||
rtp_setup(&conn->local, &conn->remote, cport, tport, active_remote, &lsport, &lcport, <port);
|
||||
rtp_setup(&conn->local, &conn->remote, cport, tport, active_remote, &lsport, &lcport, <port, conn);
|
||||
if (!lsport)
|
||||
goto error;
|
||||
char *q;
|
||||
@@ -1772,7 +1772,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {
|
||||
debug(1, "Closing down RTSP conversation thread...");
|
||||
if (rtsp_playing()) {
|
||||
player_stop(&conn->player_thread,conn); // might be less noisy doing this first
|
||||
rtp_shutdown();
|
||||
rtp_shutdown(conn);
|
||||
// usleep(400000); // let an angel pass...
|
||||
pthread_mutex_unlock(&play_lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user