Don't complain if the remote processing time is zero. Check for sanity of send and return times.
This commit is contained in:
@@ -2783,6 +2783,7 @@ int player_stop(rtsp_conn_info *conn) {
|
||||
if (conn->player_thread) {
|
||||
debug(2, "player_thread cancel...");
|
||||
pthread_cancel(*conn->player_thread);
|
||||
debug(2, "player_thread join...");
|
||||
pthread_join(*conn->player_thread, NULL);
|
||||
debug(2, "player_thread joined.");
|
||||
free(conn->player_thread);
|
||||
|
||||
@@ -621,9 +621,14 @@ void *rtp_timing_receiver(void *arg) {
|
||||
|
||||
distant_transmit_time = (uint64_t)nctohl(&packet[24]) << 32;
|
||||
distant_transmit_time += nctohl(&packet[28]);
|
||||
|
||||
uint64_t remote_processing_time = distant_transmit_time - distant_receive_time;
|
||||
|
||||
|
||||
uint64_t remote_processing_time = 0;
|
||||
|
||||
if (distant_transmit_time >= distant_receive_time)
|
||||
remote_processing_time = distant_transmit_time - distant_receive_time;
|
||||
else {
|
||||
debug(1, "Yikes: distant_transmit_time is before distant_receive_time; remote processing time set to zero.");
|
||||
}
|
||||
// debug(1,"Return trip time: %" PRIu64 " uS, remote processing time: %" PRIu64 "
|
||||
// uS.",(return_time*1000000)>>32,(remote_processing_time*1000000)>>32);
|
||||
|
||||
@@ -632,10 +637,10 @@ void *rtp_timing_receiver(void *arg) {
|
||||
// remove the remote processing time from the record of the return time, as long at the
|
||||
// processing time looks sensible.
|
||||
|
||||
if ((remote_processing_time > 0) && (remote_processing_time < return_time))
|
||||
if (remote_processing_time < return_time)
|
||||
return_time -= remote_processing_time;
|
||||
else
|
||||
debug(1, "Non-sensical remote processing time -- ignored.");
|
||||
debug(1, "Remote processing time greater than return time -- ignored.");
|
||||
|
||||
int cc;
|
||||
for (cc = time_ping_history - 1; cc > 0; cc--) {
|
||||
|
||||
@@ -648,7 +648,7 @@ shutdown:
|
||||
return reply;
|
||||
}
|
||||
|
||||
void msg_write_response(int fd, rtsp_message *resp) {
|
||||
int msg_write_response(int fd, rtsp_message *resp) {
|
||||
char pkt[2048];
|
||||
int pktfree = sizeof(pkt);
|
||||
char *p = pkt;
|
||||
@@ -666,8 +666,10 @@ void msg_write_response(int fd, rtsp_message *resp) {
|
||||
n = snprintf(p, pktfree, "%s: %s\r\n", resp->name[i], resp->value[i]);
|
||||
pktfree -= n;
|
||||
p += n;
|
||||
if (pktfree <= 1024)
|
||||
die("Attempted to write overlong RTSP packet 1");
|
||||
if (pktfree <= 1024) {
|
||||
debug(1,"Attempted to write overlong RTSP packet 1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Here, if there's content, write the Content-Length header ...
|
||||
@@ -677,8 +679,10 @@ void msg_write_response(int fd, rtsp_message *resp) {
|
||||
n = snprintf(p, pktfree, "Content-Length: %d\r\n", resp->contentlength);
|
||||
pktfree -= n;
|
||||
p += n;
|
||||
if (pktfree <= 1024)
|
||||
die("Attempted to write overlong RTSP packet 2");
|
||||
if (pktfree <= 1024) {
|
||||
debug(1,"Attempted to write overlong RTSP packet 2");
|
||||
return -2;
|
||||
}
|
||||
debug(1, "Content is \"%s\"", resp->content);
|
||||
memcpy(p, resp->content, resp->contentlength);
|
||||
pktfree -= resp->contentlength;
|
||||
@@ -689,11 +693,15 @@ void msg_write_response(int fd, rtsp_message *resp) {
|
||||
pktfree -= n;
|
||||
p += n;
|
||||
|
||||
if (pktfree <= 1024)
|
||||
die("Attempted to write overlong RTSP packet 3");
|
||||
|
||||
if (write(fd, pkt, p - pkt) != p - pkt)
|
||||
if (pktfree <= 1024) {
|
||||
debug(1,"Attempted to write overlong RTSP packet 3");
|
||||
return -3;
|
||||
}
|
||||
if (write(fd, pkt, p - pkt) != p - pkt) {
|
||||
debug(1, "Error writing an RTSP packet -- requested bytes not fully written.");
|
||||
return -4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
|
||||
@@ -2055,9 +2063,28 @@ static void *rtsp_conversation_thread_func(void *pconn) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (method_selected == 0)
|
||||
if (method_selected == 0) {
|
||||
debug(1, "RTSP thread %d: Unrecognised and unhandled rtsp request \"%s\".",
|
||||
conn->connection_number, req->method);
|
||||
|
||||
|
||||
int y = req->contentlength;
|
||||
if (y > 0) {
|
||||
char obf[4096];
|
||||
if (y > 4096)
|
||||
y = 4096;
|
||||
char *p = req->content;
|
||||
char *obfp = obf;
|
||||
int obfc;
|
||||
for (obfc = 0; obfc < y; obfc++) {
|
||||
snprintf(obfp, 3, "%02X", (unsigned int)*p);
|
||||
p++;
|
||||
obfp += 2;
|
||||
};
|
||||
*obfp = 0;
|
||||
debug(1, "Content: \"%s\".",obf);
|
||||
}
|
||||
}
|
||||
}
|
||||
debug(debug_level, "RTSP thread %d: RTSP Response:", conn->connection_number);
|
||||
debug_print_msg_headers(debug_level, resp);
|
||||
@@ -2069,7 +2096,14 @@ static void *rtsp_conversation_thread_func(void *pconn) {
|
||||
} while (conn->stop == 0 &&
|
||||
pselect(conn->fd + 1, NULL, &writefds, NULL, NULL, &pselect_sigset) <= 0);
|
||||
if (conn->stop == 0) {
|
||||
msg_write_response(conn->fd, resp);
|
||||
int err = msg_write_response(conn->fd, resp);
|
||||
if (err) {
|
||||
int odv = debuglev;
|
||||
debuglev = 3;
|
||||
debug(1,"A communication error was detected. Closing the play session.");
|
||||
player_stop(conn);
|
||||
debuglev = odv;
|
||||
}
|
||||
}
|
||||
pthread_cleanup_pop(1);
|
||||
pthread_cleanup_pop(1);
|
||||
|
||||
Reference in New Issue
Block a user