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
// 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,
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
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++;
}
// 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
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
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;
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;
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;
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;
}
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
}
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;
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);
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);
}
}
-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.");
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;
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;
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);
}