|
|
@@ -147,25 +147,27 @@ typedef struct _MSPicture {
|
|
|
int strides[4]; // with ffmpeg's swscale.h
|
|
|
}MSPicture;
|
|
|
|
|
|
-//static void __Dbg(videortp_t *rtp, const char *fmt, ...)
|
|
|
-//{
|
|
|
-// int n;
|
|
|
-// va_list arg;
|
|
|
-// va_start(arg, fmt);
|
|
|
-// if (rtp->config.dbg) {
|
|
|
-// (*rtp->config.dbg)(rtp->config.user_data, fmt, arg);
|
|
|
-// } else {
|
|
|
-// n = _vscprintf(fmt, arg);
|
|
|
-// if (n > 0) {
|
|
|
-// char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
-// vsprintf(buf, fmt, arg);
|
|
|
-// strcat(buf, "\r\n");
|
|
|
-// OutputDebugStringA((LPCSTR)buf);
|
|
|
-// printf(buf);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// va_end(arg);
|
|
|
-//}
|
|
|
+static void rtpDbg(videortp_t *rtp, const char *fmt, ...)
|
|
|
+{
|
|
|
+ int n;
|
|
|
+ va_list arg;
|
|
|
+ va_start(arg, fmt);
|
|
|
+ if (rtp->config.dbg) {
|
|
|
+ (*rtp->config.dbg)(rtp->config.user_data, fmt, arg);
|
|
|
+ } else {
|
|
|
+ n = _vscprintf(fmt, arg);
|
|
|
+ if (n > 0) {
|
|
|
+ char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
+ vsprintf(buf, fmt, arg);
|
|
|
+ strcat(buf, "\r\n");
|
|
|
+#ifdef _WIN32
|
|
|
+ OutputDebugStringA((LPCSTR)buf);
|
|
|
+#endif
|
|
|
+ printf(buf);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ va_end(arg);
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -298,7 +300,7 @@ static __inline void receiver_notify_peer_fast_update(videortp_t *vrtp)
|
|
|
DWORD dwNow = GetTickCount();
|
|
|
if (dwNow - vrtp->last_peer_update_tick >= PEER_UPDATE_INTERVAL) {
|
|
|
|
|
|
- Dbg("%I64d receiver_notify_peer_fast_update!", TimeInMilliseconds());
|
|
|
+ rtpDbg(vrtp,"%I64d receiver_notify_peer_fast_update!", TimeInMilliseconds());
|
|
|
rtp_session_send_rtcp_h261_fir(vrtp->rtp_sess);
|
|
|
vrtp->last_peer_update_tick = dwNow;
|
|
|
}
|
|
|
@@ -308,15 +310,23 @@ static __inline void receiver_notify_peer_fast_update_now(videortp_t *vrtp)
|
|
|
{
|
|
|
DWORD dwNow = GetTickCount();
|
|
|
|
|
|
- Dbg("%I64d receiver_notify_peer_fast_update_now!", TimeInMilliseconds());
|
|
|
+ rtpDbg(vrtp,"%I64d receiver_notify_peer_fast_update_now!", TimeInMilliseconds());
|
|
|
rtp_session_send_rtcp_h261_fir(vrtp->rtp_sess);
|
|
|
vrtp->last_peer_update_tick = dwNow;
|
|
|
}
|
|
|
|
|
|
static __inline void receiver_force_key_frame(videortp_t *vrtp)
|
|
|
{
|
|
|
- Dbg("%I64d receiver_force_key_frame!", TimeInMilliseconds());
|
|
|
+ rtpDbg(vrtp,"%I64d receiver_force_key_frame!", TimeInMilliseconds());
|
|
|
+#ifdef _WIN32
|
|
|
InterlockedCompareExchange(&vrtp->force_key_frames, 1, 0);
|
|
|
+#else
|
|
|
+ LONG* plTemp = &vrtp->force_key_frames;
|
|
|
+ if (0 == *plTemp){
|
|
|
+ *plTemp = 1;
|
|
|
+ rtpDbg(vrtp,"%s:%d force_key_frames = %lu", __FUNCTION__, __LINE__, vrtp->force_key_frames);
|
|
|
+ }
|
|
|
+#endif // _WIN32
|
|
|
}
|
|
|
|
|
|
static void receiver_clear_window(videortp_t *vrtp)
|
|
|
@@ -347,7 +357,7 @@ int video_coding_on_log(void *userdata, int level, const char* file, int line, c
|
|
|
if ((DEBUG_ENCODER || DEBUG_DECODER) && n > 0 && vrtp && level >= VIDEO_CODING_DEBUG_INFO) {
|
|
|
char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
vsprintf(buf, fmt, vl);
|
|
|
- Dbg("%s.", buf);
|
|
|
+ rtpDbg(vrtp,"%s.", buf);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
@@ -366,18 +376,18 @@ static int decoder_process(videortp_t *vrtp, uint8_t *input_buf, int input_len){
|
|
|
video_debug_write_play_file(AUDIO_DEC_IN, input_buf, input_len);
|
|
|
|
|
|
if(DEBUG_DECODER){
|
|
|
- Dbg("%s:%d: receiver_do_decode before decode data_len:%d.", __FILE__, __LINE__, input_len);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_do_decode before decode data_len:%d.", __FILE__, __LINE__, input_len);
|
|
|
}
|
|
|
before_decode_ms = TimeInMilliseconds();
|
|
|
|
|
|
decodered_frame = video_decoder_process(vrtp->decoder, input_buf, input_len, &input_len, &key_frame);
|
|
|
|
|
|
if(DEBUG_DECODER){
|
|
|
- Dbg("%s:%d: receiver_do_decode after decode data_len:%d.", __FILE__, __LINE__, input_len);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_do_decode after decode data_len:%d.", __FILE__, __LINE__, input_len);
|
|
|
}
|
|
|
after_decode_ms = TimeInMilliseconds();
|
|
|
if (decodered_frame == NULL){
|
|
|
- Dbg("receiver_do_decode decode failed.");
|
|
|
+ rtpDbg(vrtp,"receiver_do_decode decode failed.");
|
|
|
video_stats_receiver_on_decoded_frame(after_decode_ms, after_decode_ms - before_decode_ms, 0);
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -388,14 +398,21 @@ static int decoder_process(videortp_t *vrtp, uint8_t *input_buf, int input_len){
|
|
|
if (vrtp->config.rx_height)
|
|
|
{
|
|
|
if (VIDEO_FORMAT_RGB24 != decodered_frame->format)
|
|
|
- {
|
|
|
- unsigned char *video_debug_buf;
|
|
|
- int length = vrtp->config.rx_height*vrtp->config.rx_width*3/2;
|
|
|
- video_debug_buf = (unsigned char *)malloc(length);
|
|
|
+ {
|
|
|
+ unsigned char* video_debug_buf;
|
|
|
+ int length = vrtp->config.rx_height * vrtp->config.rx_width * 3 / 2;
|
|
|
+ video_debug_buf = (unsigned char*)malloc(length);
|
|
|
yuv_buffers_combine_to_one(decodered_frame, video_debug_buf);
|
|
|
video_debug_write_play_file(VIDEO_RENDER_IN, video_debug_buf, length);
|
|
|
free(video_debug_buf);
|
|
|
}
|
|
|
+
|
|
|
+ rtpDbg(vrtp, "%s:%d: decodered_frame->format = %d", __FILE__, __LINE__, decodered_frame->format);
|
|
|
+ static int icount = 0;
|
|
|
+ if (icount == 0) {
|
|
|
+ video_frame_save_bmpfile("formattest.bmp", decodered_frame);
|
|
|
+ icount++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//notify render
|
|
|
@@ -424,7 +441,7 @@ void decoder_create(videortp_t *vrtp, const videortp_config_t *config){
|
|
|
log_func.userdata = vrtp;
|
|
|
vrtp->decoder = video_decoder_open(&decoder_config, &log_func);
|
|
|
|
|
|
- Dbg("decoder_create color_space: %d decode_id: %d width: %d height: %d.",
|
|
|
+ rtpDbg(vrtp,"decoder_create color_space: %d decode_id: %d width: %d height: %d.",
|
|
|
decoder_config.color_space, decoder_config.decode_id, decoder_config.width, decoder_config.height);
|
|
|
}
|
|
|
|
|
|
@@ -432,7 +449,7 @@ void decoder_destroy(videortp_t *vrtp){
|
|
|
if (vrtp->decoder != NULL) {
|
|
|
video_decoder_close(vrtp->decoder);
|
|
|
}
|
|
|
- Dbg("decoder_destroy.");
|
|
|
+ rtpDbg(vrtp,"decoder_destroy.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -674,12 +691,12 @@ static int receiver_h264_on_receive_encoded_image(EncodedImage *encoded_image,
|
|
|
int decoded;
|
|
|
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_h264_on_receive_encoded_image timestamp:%u first_seq:%u last_seq:%u key: %d len: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_h264_on_receive_encoded_image timestamp:%u first_seq:%u last_seq:%u key: %d len: %d.", __FILE__, __LINE__,
|
|
|
timestamp, first_seq, last_seq, encoded_image->key_frame, encoded_image->size_);
|
|
|
- Dbg("%s:%d: receiver_h264_on_receive_encoded_image fragmentationSize: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_h264_on_receive_encoded_image fragmentationSize: %d.", __FILE__, __LINE__,
|
|
|
encoded_image->fragmentation_header_.fragmentationVectorSize);
|
|
|
for (i = 0;i < encoded_image->fragmentation_header_.fragmentationVectorSize;++i){
|
|
|
- Dbg("%s:%d: receiver_h264_on_receive_encoded_image index: %d fragmentationLength: %d fragmentationOffset: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_h264_on_receive_encoded_image index: %d fragmentationLength: %d fragmentationOffset: %d.", __FILE__, __LINE__,
|
|
|
i, encoded_image->fragmentation_header_.fragmentationLength[i], encoded_image->fragmentation_header_.fragmentationOffset[i]);
|
|
|
|
|
|
}
|
|
|
@@ -718,7 +735,7 @@ static int receiver_h264_on_receive_encoded_image(EncodedImage *encoded_image,
|
|
|
}
|
|
|
}
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_h264_on_receive_encoded_image encoded_size:%d frame_len:%d now:%I64d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_h264_on_receive_encoded_image encoded_size:%d frame_len:%d now:%I64d.", __FILE__, __LINE__,
|
|
|
encoded_image->size_, input_len, TimeInMilliseconds());
|
|
|
}
|
|
|
|
|
|
@@ -728,7 +745,7 @@ static int receiver_h264_on_receive_encoded_image(EncodedImage *encoded_image,
|
|
|
vrtp->prev_dec_seq = last_seq;
|
|
|
vrtp->prev_dec_ts = timestamp;
|
|
|
} else {
|
|
|
- Dbg("receiver_h264_on_receive_encoded_image decode_frame failed!");
|
|
|
+ rtpDbg(vrtp,"receiver_h264_on_receive_encoded_image decode_frame failed!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -754,7 +771,7 @@ static int receiver_standard_h264_decode(videortp_t *vrtp, rtpframe_t *frame)
|
|
|
input_len = receiver_standard_h264_add_startcode(vrtp, frame, input_buf, &need_reinit);
|
|
|
}
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_standard_h264_decode frame_used:%d frame_len:%d now:%I64d.", __FILE__, __LINE__, frame->used, input_len, TimeInMilliseconds());
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_standard_h264_decode frame_used:%d frame_len:%d now:%I64d.", __FILE__, __LINE__, frame->used, input_len, TimeInMilliseconds());
|
|
|
}
|
|
|
|
|
|
//decode
|
|
|
@@ -789,7 +806,7 @@ rtpframe_t *receiver_standard_h264_assemble(videortp_t *vrtp,
|
|
|
part_data->mark = mark;
|
|
|
part_data->seq = seq;
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_standard_h264_assemble actual_len:%d seq:%d key:%d.", __FILE__, __LINE__, len, seq, key);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_standard_h264_assemble actual_len:%d seq:%d key:%d.", __FILE__, __LINE__, len, seq, key);
|
|
|
}
|
|
|
|
|
|
iret = receiver_standard_h264_find_frame(vrtp, part_data, mark, ts, key);
|
|
|
@@ -829,7 +846,7 @@ static int receiver_process_standard_h264_packet(
|
|
|
packet_info.pt = pt;
|
|
|
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_process_standard_h264_packet len:%d seq:%d mark:%d ts:%d nalu_type:%u offset:%d actual_len:%d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_process_standard_h264_packet len:%d seq:%d mark:%d ts:%d nalu_type:%u offset:%d actual_len:%d.", __FILE__, __LINE__,
|
|
|
len, seq, mark, ts, nalu_type, offset, actual_len);
|
|
|
}
|
|
|
|
|
|
@@ -851,12 +868,12 @@ static int receiver_process_standard_h264_packet(
|
|
|
//Dbg("decode_frame ok!");
|
|
|
if (vrtp->frame_duration==0 && vrtp->prev_dec_seq+1 == rtpframe_get_first_seq(frame)) {
|
|
|
vrtp->frame_duration = frame->ts - vrtp->prev_dec_ts;
|
|
|
- Dbg("decode frame duration: %d", vrtp->frame_duration);
|
|
|
+ rtpDbg(vrtp,"decode frame duration: %d", vrtp->frame_duration);
|
|
|
}
|
|
|
vrtp->prev_dec_seq = rtpframe_get_last_seq(frame);
|
|
|
vrtp->prev_dec_ts = frame->ts;
|
|
|
} else {
|
|
|
- Dbg("decode_frame failed!");
|
|
|
+ rtpDbg(vrtp,"decode_frame failed!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -974,7 +991,7 @@ static int receiver_custom_h264_decode(videortp_t *vrtp, rtpframe_t *frame)
|
|
|
}
|
|
|
memset(input_buf+input_len, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_custom_h264_decode frame_used:%d frame_len:%d now:%I64d.", __FILE__, __LINE__, frame->used, input_len, TimeInMilliseconds());
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_custom_h264_decode frame_used:%d frame_len:%d now:%I64d.", __FILE__, __LINE__, frame->used, input_len, TimeInMilliseconds());
|
|
|
}
|
|
|
//decode
|
|
|
return decoder_process(vrtp, input_buf, input_len);
|
|
|
@@ -996,7 +1013,7 @@ rtpframe_t *receiver_custom_h264_assemble(videortp_t *vrtp,
|
|
|
int sno = hdr->id;
|
|
|
int end = hdr->end;
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_custom_h264_assemble actual_len:%d seq:%d key:%d sno:%d end: %d.", __FILE__, __LINE__, actual_len, seq, !!key, sno, end);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_custom_h264_assemble actual_len:%d seq:%d key:%d sno:%d end: %d.", __FILE__, __LINE__, actual_len, seq, !!key, sno, end);
|
|
|
}
|
|
|
part_data->actual_len = actual_len;
|
|
|
part_data->offset = sizeof(h26x_hdr)-2;
|
|
|
@@ -1046,7 +1063,7 @@ static int receiver_process_custom_h264_packet(videortp_t *vrtp,
|
|
|
packet_info.pt = pt;
|
|
|
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_process_custom_h264_packet len:%d seq:%d mark:%d ts:%d pt:%u key:%d sno:%d end:%d offset:%d actual_len:%d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_process_custom_h264_packet len:%d seq:%d mark:%d ts:%d pt:%u key:%d sno:%d end:%d offset:%d actual_len:%d.", __FILE__, __LINE__,
|
|
|
len, seq, mark, ts, pt, key, sno, end, offset, actual_len);
|
|
|
}
|
|
|
|
|
|
@@ -1057,7 +1074,7 @@ static int receiver_process_custom_h264_packet(videortp_t *vrtp,
|
|
|
rtpframe_t *frame = NULL;
|
|
|
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: receiver_process_custom_h264_packet len:%d seq:%d mark:%d ts:%d.", __FILE__, __LINE__, len, seq, mark, ts);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_process_custom_h264_packet len:%d seq:%d mark:%d ts:%d.", __FILE__, __LINE__, len, seq, mark, ts);
|
|
|
}
|
|
|
|
|
|
frame = receiver_custom_h264_assemble(vrtp, part_data, len, seq, mark, ts);
|
|
|
@@ -1070,12 +1087,12 @@ static int receiver_process_custom_h264_packet(videortp_t *vrtp,
|
|
|
if (decoded) {
|
|
|
if (vrtp->frame_duration==0 && vrtp->prev_dec_seq+1 == rtpframe_get_first_seq(frame)) {
|
|
|
vrtp->frame_duration = frame->ts - vrtp->prev_dec_ts;
|
|
|
- Dbg("%s:%d: receiver_process_custom_h264_packet decode frame duration: %d.", __FILE__, __LINE__, vrtp->frame_duration);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_process_custom_h264_packet decode frame duration: %d.", __FILE__, __LINE__, vrtp->frame_duration);
|
|
|
}
|
|
|
vrtp->prev_dec_seq = rtpframe_get_last_seq(frame);
|
|
|
vrtp->prev_dec_ts = frame->ts;
|
|
|
} else {
|
|
|
- Dbg("%s:%d: receiver_process_custom_h264_packet decode_frame failed!", __FILE__, __LINE__);
|
|
|
+ rtpDbg(vrtp,"%s:%d: receiver_process_custom_h264_packet decode_frame failed!", __FILE__, __LINE__);
|
|
|
}
|
|
|
rtpframe_clear(vrtp, frame);
|
|
|
vrtp->frame_win_ptr = (frame->id+1) % FRAME_WIN_SIZE;
|
|
|
@@ -1118,28 +1135,39 @@ static void receiver_process_rtcp_packet(videortp_t *vrtp, unsigned rtcp_flags){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static unsigned int __stdcall recv_proc(void *arg)
|
|
|
+#ifdef _WIN32
|
|
|
+static unsigned int __stdcall recv_proc(void* arg)
|
|
|
+#else
|
|
|
+void* recv_proc(void* arg)
|
|
|
+#endif
|
|
|
{
|
|
|
videortp_t *vrtp = (videortp_t*)arg;
|
|
|
int rtp_timeout_cnt = 0;
|
|
|
int64_t pre_500_ms = TimeInMilliseconds();
|
|
|
|
|
|
- Dbg("recv_proc.");
|
|
|
-
|
|
|
+ rtpDbg(vrtp,"recv_proc.");
|
|
|
+#ifdef _WIN32
|
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
|
|
|
+#else
|
|
|
+ struct sched_param param;
|
|
|
+ int policy;
|
|
|
+ pthread_getschedparam(pthread_self(), &policy, ¶m);
|
|
|
+ rtpDbg(vrtp,"%s:%d current thread policy is %d, priority is %d.", __FUNCTION__, __LINE__, policy, param.sched_priority);
|
|
|
+#endif
|
|
|
receiver_notify_peer_fast_update_now(vrtp);
|
|
|
|
|
|
-
|
|
|
for (;;) {
|
|
|
#ifdef _WIN32
|
|
|
DWORD dwRet = WaitForSingleObject(vrtp->evt, 10);
|
|
|
if (dwRet == WAIT_TIMEOUT)
|
|
|
#else
|
|
|
struct timespec ts;
|
|
|
+ int ivalue = -1;
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
ts.tv_nsec += 1000 * 1000 * 10;
|
|
|
- //sem_getvalue(&m_semt, &ivalue);
|
|
|
- if (-1 == sem_timedwait(&vrtp->sem_evt, &ts) && (ETIMEDOUT == errno))
|
|
|
+ sem_getvalue(&vrtp->sem_evt, &ivalue);
|
|
|
+ rtpDbg(vrtp,"%s:%d sem value is %d", __FUNCTION__, __LINE__, ivalue);
|
|
|
+ if (0 != sem_timedwait(&vrtp->sem_evt, &ts) /*&& (ETIMEDOUT == errno)*/)
|
|
|
#endif
|
|
|
{
|
|
|
int n;
|
|
|
@@ -1147,7 +1175,7 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
unsigned rtcp_flags = 0;
|
|
|
int result = rtp_session_recv_rtcp(vrtp->rtp_sess, &rtcp_flags);
|
|
|
if (result >= 0) {
|
|
|
- receiver_process_rtcp_packet(vrtp, rtcp_flags);
|
|
|
+ //receiver_process_rtcp_packet(vrtp, rtcp_flags);
|
|
|
}
|
|
|
}
|
|
|
do {
|
|
|
@@ -1175,7 +1203,7 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
#if 0 // for testing
|
|
|
#define PACKET_LOSS_RATIO 30
|
|
|
if (n > 0 && rand()%1000 >= PACKET_LOSS_RATIO) {
|
|
|
- Dbg("rtp_session_recv_hook pt = %u, mark = %u, ts = %u, seq = %u, size = %d", pt, mark, ts, seq, n);
|
|
|
+ rtpDbg(vrtp,"%s:%d rtp_session_recv_hook2 pt = %u, mark = %u, ts = %u, seq = %u, size = %d", __FUNCTION__, __LINE__, pt, mark, ts, seq, n);
|
|
|
#else
|
|
|
if (n > 0) {
|
|
|
#endif
|
|
|
@@ -1188,7 +1216,7 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
part_data->actual_len = n - extension_length;
|
|
|
part_data->offset = extension_length;
|
|
|
if(DEBUG_RX){
|
|
|
- Dbg("%s:%d: recv_proc rtp_header_extension send_time:%u length:%d actual_len:%d offset:%d.",
|
|
|
+ rtpDbg(vrtp,"%s:%d: recv_proc rtp_header_extension send_time:%u length:%d actual_len:%d offset:%d.",
|
|
|
__FILE__, __LINE__, send_time, extension_length,
|
|
|
part_data->actual_len, part_data->offset);
|
|
|
}
|
|
|
@@ -1198,14 +1226,16 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
}
|
|
|
|
|
|
//huchen add for video cc
|
|
|
- {
|
|
|
- sim_segment_t seg = {0};
|
|
|
- seg.transport_seq = seq;
|
|
|
- //注意,cc中的ts是以真实时间毫秒为单位,rtp的时间戳是90000为1秒,这里需要转换
|
|
|
- seg.timestamp = (send_time==0 ? (ts/(VIDEO_CLOCK/1000)) : send_time);
|
|
|
- seg.data_size = n;
|
|
|
- sim_recv_video(&seg);
|
|
|
- }
|
|
|
+ //{
|
|
|
+ // sim_segment_t seg = {0};
|
|
|
+ // seg.transport_seq = seq;
|
|
|
+ // //注意,cc中的ts是以真实时间毫秒为单位,rtp的时间戳是90000为1秒,这里需要转换
|
|
|
+ // seg.timestamp = (send_time==0 ? (ts/(VIDEO_CLOCK/1000)) : send_time);
|
|
|
+ // seg.data_size = n;
|
|
|
+ // rtpDbg(vrtp,"%s:%d ", __FUNCTION__, __LINE__);
|
|
|
+ // sim_recv_video(&seg);
|
|
|
+ // rtpDbg(vrtp,"%s:%d ", __FUNCTION__, __LINE__);
|
|
|
+ //}
|
|
|
}
|
|
|
video_stats_bandwidth_update_recv_rtp_bytes(n);
|
|
|
video_stats_receiver_on_incoming_packet(TimeInMilliseconds());
|
|
|
@@ -1226,7 +1256,7 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
//1s没有解码到视频数据,请求I帧
|
|
|
int64_t now_ms = TimeInMilliseconds();
|
|
|
if (now_ms - vrtp->prev_dec_ms >= 1000){
|
|
|
- Dbg("recv_proc now:%I64d > prev_dec_ms:%I64d 1s.", TimeInMilliseconds(), vrtp->prev_dec_ms);
|
|
|
+ rtpDbg(vrtp,"recv_proc now:%I64d > prev_dec_ms:%I64d 1s.", TimeInMilliseconds(), vrtp->prev_dec_ms);
|
|
|
receiver_notify_peer_fast_update_now(vrtp);
|
|
|
vrtp->prev_dec_ms = now_ms;
|
|
|
}
|
|
|
@@ -1248,9 +1278,6 @@ static unsigned int __stdcall recv_proc(void *arg)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-#if 0
|
|
|
-#endif
|
|
|
-
|
|
|
/******************************custom_h264发送处理 start***************************/
|
|
|
|
|
|
|
|
|
@@ -1264,7 +1291,7 @@ static void sender_custom_h264_packetize_and_send(videortp_t *vrtp, int key, uns
|
|
|
mtu = mtu-20-8-12-sizeof(h26x_hdr)+2; // ip hdr: 20, udp hdr: 8, rtp hdr: 12
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_custom_h264_packetize_and_send key: %d len: %d delta_ts: %d now: %I64d.",
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_custom_h264_packetize_and_send key: %d len: %d delta_ts: %d now: %I64d.",
|
|
|
__FILE__, __LINE__, key, n, delta_ts, TimeInMilliseconds());
|
|
|
}
|
|
|
video_debug_write_record_file(VIDEO_ENC_OUT, buf, n);
|
|
|
@@ -1281,7 +1308,7 @@ static void sender_custom_h264_packetize_and_send(videortp_t *vrtp, int key, uns
|
|
|
hdr->id = id++;
|
|
|
memcpy((void *)(&tx_buf[0]+sizeof(h26x_hdr)-2), (const void *)ptr, (size_t)tn);
|
|
|
if (DEBUG_TX) {
|
|
|
- Dbg("end = %d, id = %d, tn = %d", hdr->end, hdr->id, tn);
|
|
|
+ rtpDbg(vrtp,"end = %d, id = %d, tn = %d", hdr->end, hdr->id, tn);
|
|
|
}
|
|
|
rc = rtp_session_send_hook(vrtp->rtp_sess, &rtcp_flag, pt, mark, delta_ts, tx_buf, tn+sizeof(h26x_hdr)-2, vrtp->config.on_tx_udp, vrtp->config.user_data);
|
|
|
if (rc == 0) {
|
|
|
@@ -1315,7 +1342,7 @@ static void sender_custom_h264_send_fragment(videortp_t *vrtp, int index, int ke
|
|
|
unsigned int delta_ts = vrtp->delta_ts;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_custom_h264_send_fragment mark: %d length: %d delta_ts: %d now: %I64d.",
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_custom_h264_send_fragment mark: %d length: %d delta_ts: %d now: %I64d.",
|
|
|
__FILE__, __LINE__, mark, length, delta_ts, TimeInMilliseconds());
|
|
|
}
|
|
|
|
|
|
@@ -1327,7 +1354,7 @@ static void sender_custom_h264_send_fragment(videortp_t *vrtp, int index, int ke
|
|
|
memcpy((void *)(&tx_buf[0]), (const void *)rtp_header_extension_buf, (size_t)rtp_header_extension_length);
|
|
|
rtp_extension = 1;
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_custom_h264_send_fragment rtp_header_extension interval_ms:%u length:%d.", __FILE__, __LINE__, interval_ms, rtp_header_extension_length);
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_custom_h264_send_fragment rtp_header_extension interval_ms:%u length:%d.", __FILE__, __LINE__, interval_ms, rtp_header_extension_length);
|
|
|
}
|
|
|
}
|
|
|
//custom header
|
|
|
@@ -1372,7 +1399,7 @@ static int sender_standard_h264_send_packet(videortp_t *vrtp, unsigned mark, uns
|
|
|
unsigned int delta_ts = vrtp->delta_ts;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_standard_h264_send_packet mark: %d length: %d delta_ts: %d now: %I64d.",
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_standard_h264_send_packet mark: %d length: %d delta_ts: %d now: %I64d.",
|
|
|
__FILE__, __LINE__, mark, length, delta_ts, TimeInMilliseconds());
|
|
|
}
|
|
|
|
|
|
@@ -1384,7 +1411,7 @@ static int sender_standard_h264_send_packet(videortp_t *vrtp, unsigned mark, uns
|
|
|
memcpy(&tx_buf[0], rtp_header_extension_buf, rtp_header_extension_length);
|
|
|
rtp_extension = 1;
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_standard_h264_send_packet rtp_header_extension interval_ms:%u length:%d.", __FILE__, __LINE__, interval_ms, rtp_header_extension_length);
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_standard_h264_send_packet rtp_header_extension interval_ms:%u length:%d.", __FILE__, __LINE__, interval_ms, rtp_header_extension_length);
|
|
|
}
|
|
|
}
|
|
|
//playload
|
|
|
@@ -1435,7 +1462,7 @@ static int sender_standard_h264_send_nal(videortp_t *vrtp, unsigned mark, unsign
|
|
|
}
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_standard_h264_send_nal mark: %d processed: %u payload_len: %d.",
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_standard_h264_send_nal mark: %d processed: %u payload_len: %d.",
|
|
|
__FILE__, __LINE__, mark, processed, payload_len);
|
|
|
}
|
|
|
//input mark =1, means last nal, rtp mark = 1, we need last nal 's last packet.
|
|
|
@@ -1482,7 +1509,7 @@ static void sender_standard_h264_packetize_x264_nals(videortp_t *vrtp, unsigned
|
|
|
int i;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_standard_h264_packetize_x264_nals num_nals: %d.", __FILE__, __LINE__, num_nals);
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_standard_h264_packetize_x264_nals num_nals: %d.", __FILE__, __LINE__, num_nals);
|
|
|
}
|
|
|
|
|
|
for (i = 0;i < num_nals;++i){
|
|
|
@@ -1490,22 +1517,22 @@ static void sender_standard_h264_packetize_x264_nals(videortp_t *vrtp, unsigned
|
|
|
x264_nal_t* nal = &xnals[i];
|
|
|
if (xnals[i].i_type == NAL_SPS) {
|
|
|
if (DEBUG_TX) {
|
|
|
- Dbg("A SPS is being sent.");
|
|
|
+ rtpDbg(vrtp,"A SPS is being sent.");
|
|
|
}
|
|
|
}else if (xnals[i].i_type == NAL_PPS) {
|
|
|
if (DEBUG_TX) {
|
|
|
- Dbg("A PPS is being sent.");
|
|
|
+ rtpDbg(vrtp,"A PPS is being sent.");
|
|
|
}
|
|
|
}else if (xnals[i].i_type == NAL_SLICE_IDR) {
|
|
|
if (DEBUG_TX) {
|
|
|
- Dbg("A IDR is being sent.");
|
|
|
+ rtpDbg(vrtp,"A IDR is being sent.");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (i == num_nals -1){
|
|
|
mark = 1;
|
|
|
if (DEBUG_TX) {
|
|
|
- Dbg("A frame end.");
|
|
|
+ rtpDbg(vrtp,"A frame end.");
|
|
|
}
|
|
|
}
|
|
|
sender_standard_h264_send_nal(vrtp, mark , pt, nal->p_payload, nal->i_payload);
|
|
|
@@ -1518,14 +1545,14 @@ void sender_h264_packetize_nal(videortp_t *vrtp, int index, int total, int key_f
|
|
|
unsigned mark = 0;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: sender_h264_packetize_nal index: %d total: %d key_frame: %d data_size: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: sender_h264_packetize_nal index: %d total: %d key_frame: %d data_size: %d.", __FILE__, __LINE__,
|
|
|
index, total, key_frame, data_size);
|
|
|
}
|
|
|
|
|
|
if (index == total -1){
|
|
|
mark = 1;
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("A frame end.");
|
|
|
+ rtpDbg(vrtp,"A frame end.");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1567,7 +1594,7 @@ int congestion_control_on_log(void *userdata, int level, const char* file, int l
|
|
|
if (DEBUG_CC && n > 0 && level >= 1 && vrtp) {
|
|
|
char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
vsprintf(buf, fmt, vl);
|
|
|
- Dbg("%s.", buf);
|
|
|
+ rtpDbg(vrtp,"%s.", buf);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1578,7 +1605,7 @@ void congestion_control_sender_on_send_fragment(sim_segment_t* seg, void *userda
|
|
|
videortp_t *vrtp = (videortp_t *)userdata;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: congestion_control_sender_on_send_fragment.", __FILE__, __LINE__);
|
|
|
+ rtpDbg(vrtp,"%s:%d: congestion_control_sender_on_send_fragment.", __FILE__, __LINE__);
|
|
|
}
|
|
|
|
|
|
sender_h264_packetize_nal(vrtp, seg->index, seg->total, seg->key_frame, seg->payload_type, seg->data, seg->data_size);
|
|
|
@@ -1592,7 +1619,7 @@ void congestion_control_sender_on_change_bitrate(uint32_t bw, int lost, void *us
|
|
|
videortp_t *vrtp = (videortp_t *)userdata;
|
|
|
|
|
|
if(DEBUG_CC){
|
|
|
- Dbg("%s:%d: congestion_control_sender_on_change_bitrate bw: %d lost: %d.", __FILE__, __LINE__, bw, lost);
|
|
|
+ rtpDbg(vrtp,"%s:%d: congestion_control_sender_on_change_bitrate bw: %d lost: %d.", __FILE__, __LINE__, bw, lost);
|
|
|
}
|
|
|
|
|
|
//回调时编码器可能未创建
|
|
|
@@ -1606,7 +1633,7 @@ void congestion_control_receiver_on_send_bitrate_feedback(uint32_t estimate_bitr
|
|
|
videortp_t *vrtp = (videortp_t *)userdata;
|
|
|
|
|
|
if(DEBUG_CC){
|
|
|
- Dbg("%s:%d: congestion_control_receiver_on_send_bitrate_feedback estimate_bitrate: %d.", __FILE__, __LINE__, estimate_bitrate);
|
|
|
+ rtpDbg(vrtp,"%s:%d: congestion_control_receiver_on_send_bitrate_feedback estimate_bitrate: %d.", __FILE__, __LINE__, estimate_bitrate);
|
|
|
}
|
|
|
video_stats_receiver_on_report_cc_bitrate(estimate_bitrate);
|
|
|
|
|
|
@@ -1615,6 +1642,7 @@ void congestion_control_receiver_on_send_bitrate_feedback(uint32_t estimate_bitr
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
void congestion_control_create(videortp_t *vrtp, const videortp_config_t *config){
|
|
|
int max_bitrate, target_bitrate, min_bitrate;
|
|
|
|
|
|
@@ -1629,14 +1657,14 @@ void congestion_control_create(videortp_t *vrtp, const videortp_config_t *config
|
|
|
sim_init(gcc_transport, 0, min_bitrate, target_bitrate, max_bitrate, &callback);
|
|
|
}
|
|
|
|
|
|
- Dbg("congestion_control_create min_bitrate: %d target_bitrate: %d max_bitrate: %d.", min_bitrate, target_bitrate, max_bitrate);
|
|
|
+ rtpDbg(vrtp,"congestion_control_create min_bitrate: %d target_bitrate: %d max_bitrate: %d.", min_bitrate, target_bitrate, max_bitrate);
|
|
|
}
|
|
|
|
|
|
|
|
|
void congestion_control_destroy(videortp_t *vrtp){
|
|
|
sim_destroy();
|
|
|
|
|
|
- Dbg("congestion_control_destroy.");
|
|
|
+ rtpDbg(vrtp,"congestion_control_destroy.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1794,9 +1822,9 @@ void x264_encoder_create(videortp_t *vrtp, const videortp_config_t *config){
|
|
|
x264_encoder_set_param_t(¶ms);
|
|
|
vrtp->enc_params = x264_encoder_open(¶ms);
|
|
|
x264_encoder_parameters(vrtp->enc_params, ¶ms_print);
|
|
|
- Dbg("x264_encoder_create bit_rate: %d kb/s, i_rc_method: %d ", params_print.rc.i_bitrate, params_print.rc.i_rc_method);
|
|
|
- Dbg("x264_encoder_create i_vbv_max_bitrate: %d kb/s, i_vbv_buffer_size: %d ", params_print.rc.i_vbv_max_bitrate, params_print.rc.i_vbv_buffer_size);
|
|
|
- Dbg("x264_encoder_create keyint_max: %d, i_keyint_min: %d ", params_print.i_keyint_max, params_print.i_keyint_min);
|
|
|
+ rtpDbg(vrtp,"x264_encoder_create bit_rate: %d kb/s, i_rc_method: %d ", params_print.rc.i_bitrate, params_print.rc.i_rc_method);
|
|
|
+ rtpDbg(vrtp,"x264_encoder_create i_vbv_max_bitrate: %d kb/s, i_vbv_buffer_size: %d ", params_print.rc.i_vbv_max_bitrate, params_print.rc.i_vbv_buffer_size);
|
|
|
+ rtpDbg(vrtp,"x264_encoder_create keyint_max: %d, i_keyint_min: %d ", params_print.i_keyint_max, params_print.i_keyint_min);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1804,7 +1832,7 @@ void x264_encoder_destroy(videortp_t *vrtp){
|
|
|
if (vrtp->enc_params){
|
|
|
x264_encoder_close(vrtp->enc_params);
|
|
|
}
|
|
|
- Dbg("x264_encoder_destroy.");
|
|
|
+ rtpDbg(vrtp,"x264_encoder_destroy.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1822,15 +1850,15 @@ void ffmpeg_encoder_on_encoder_encoded_image(const EncodedImage *encoded_image,
|
|
|
if (encoded_image != NULL && vrtp != NULL) {
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: ffmpeg_encoder_on_encoder_encoded_image key: %d len: %d qp: %d, PT:%u.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: ffmpeg_encoder_on_encoder_encoded_image key: %d len: %d qp: %d, PT:%u.", __FILE__, __LINE__,
|
|
|
encoded_image->key_frame, encoded_image->size_, encoded_image->qp_, encoded_image->pt_);
|
|
|
- Dbg("%s:%d: ffmpeg_encoder_on_encoder_encoded_image encode_start_ms: %I64d encode_finish_ms: %I64d fragmentationSize: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: ffmpeg_encoder_on_encoder_encoded_image encode_start_ms: %I64d encode_finish_ms: %I64d fragmentationSize: %d.", __FILE__, __LINE__,
|
|
|
encoded_image->encode_start_ms, encoded_image->encode_finish_ms, encoded_image->fragmentation_header_.fragmentationVectorSize);
|
|
|
|
|
|
}
|
|
|
if(DEBUG_TX){
|
|
|
for (i = 0;i < encoded_image->fragmentation_header_.fragmentationVectorSize;++i){
|
|
|
- Dbg("%s:%d: ffmpeg_encoder_on_encoder_encoded_image index: %d fragmentationLength: %d.", __FILE__, __LINE__,
|
|
|
+ rtpDbg(vrtp,"%s:%d: ffmpeg_encoder_on_encoder_encoded_image index: %d fragmentationLength: %d.", __FILE__, __LINE__,
|
|
|
i, encoded_image->fragmentation_header_.fragmentationLength[i]);
|
|
|
|
|
|
}
|
|
|
@@ -1908,11 +1936,11 @@ void ffmpeg_encoder_create(videortp_t *vrtp, const videortp_config_t *config){
|
|
|
encoder_config.min_qp = 10;
|
|
|
video_encoder_api_configure_encoder(vrtp->encoder, &encoder_config, get_mtu(config->mtu) - 5/*padding*/ - ((sizeof(h26x_hdr)-2 + 32/*rtp_header_extension_length*/)));
|
|
|
|
|
|
- Dbg("ffmpeg_encoder_create color_space: %d encode_id: %d width: %d height: %d.",
|
|
|
+ rtpDbg(vrtp,"ffmpeg_encoder_create color_space: %d encode_id: %d width: %d height: %d.",
|
|
|
encoder_config.color_space, encoder_config.encode_id, encoder_config.width, encoder_config.height);
|
|
|
- Dbg("ffmpeg_encoder_create max_bitrate: %d min_bitrate: %d target_bitrate: %d.",
|
|
|
+ rtpDbg(vrtp,"ffmpeg_encoder_create max_bitrate: %d min_bitrate: %d target_bitrate: %d.",
|
|
|
max_bitrate, min_bitrate, target_bitrate);
|
|
|
- Dbg("ffmpeg_encoder_create min_framerate: %d key_frame_interval: %d target_qp: %d.",
|
|
|
+ rtpDbg(vrtp,"ffmpeg_encoder_create min_framerate: %d key_frame_interval: %d target_qp: %d.",
|
|
|
encoder_config.min_framerate, encoder_config.key_frame_interval, encoder_config.target_qp);
|
|
|
|
|
|
}
|
|
|
@@ -1923,7 +1951,7 @@ void ffmpeg_encoder_destory(videortp_t *vrtp){
|
|
|
video_encoder_api_stop(vrtp->encoder);
|
|
|
video_encoder_api_destroy(vrtp->encoder);
|
|
|
}
|
|
|
- Dbg("ffmpeg_encoder_destory.");
|
|
|
+ rtpDbg(vrtp,"ffmpeg_encoder_destory.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1944,7 +1972,7 @@ int jitter_buffer_on_log(void *userdata, int level, const char* file, int line,
|
|
|
if (DEBUG_RX && n > 0 && vrtp && level >= VIDEO_JBUFFER_DEBUG_TRACE) {
|
|
|
char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
vsprintf(buf, fmt, vl);
|
|
|
- Dbg("%s.", buf);
|
|
|
+ rtpDbg(vrtp,"%s.", buf);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1960,7 +1988,7 @@ void jitter_buffer_create(videortp_t *vrtp, const videortp_config_t *config){
|
|
|
log_func.userdata = vrtp;
|
|
|
vrtp->jbuffer = video_jbuffer_api_new(&video_jbuffer_observer, &log_func);
|
|
|
|
|
|
- Dbg("jitter_buffer_create.");
|
|
|
+ rtpDbg(vrtp,"jitter_buffer_create.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1968,7 +1996,7 @@ void jitter_buffer_destory(videortp_t *vrtp){
|
|
|
if (vrtp->jbuffer != NULL) {
|
|
|
video_jbuffer_api_destroy(vrtp->jbuffer);
|
|
|
}
|
|
|
- Dbg("jitter_buffer_destory.");
|
|
|
+ rtpDbg(vrtp,"jitter_buffer_destory.");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2010,7 +2038,7 @@ int video_stats_on_log(void *userdata, int level, const char* file, int line, co
|
|
|
if (n > 0 && vrtp) {
|
|
|
char *buf = (char*)_alloca((size_t)(n+3));
|
|
|
vsprintf(buf, fmt, vl);
|
|
|
- Dbg("%s.", buf);
|
|
|
+ rtpDbg(vrtp,"%s.", buf);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2029,12 +2057,12 @@ int videortp_create(const videortp_config_t *config, videortp_t **p_rtp)
|
|
|
vrtp->remote_support_cc = 0;
|
|
|
memcpy((void *)(&vrtp->config), (const void *)config, sizeof(videortp_config_t));
|
|
|
|
|
|
- Dbg("videortp_create local_pt: %d local_ip: %d local_rtp_port: %d.", config->local_pt, config->local_ip, config->local_rtp_port);
|
|
|
- Dbg("videortp_create remote_pt: %d remote_ip: %d remote_rtp_port: %d.", config->remote_pt, config->remote_ip, config->remote_rtp_port);
|
|
|
- Dbg("videortp_create tx_width: %d tx_height: %d.", config->tx_width, config->tx_height);
|
|
|
- Dbg("videortp_create rx_width: %d rx_height: %d.", config->rx_width, config->rx_height);
|
|
|
- Dbg("videortp_create capture_width: %d capture_height: %d.", config->capture_width, config->capture_height);
|
|
|
- Dbg("videortp_create fps_num: %d bit_rate: %d dir: %d.", config->fps_num, config->bit_rate, config->dir);
|
|
|
+ rtpDbg(vrtp,"videortp_create local_pt: %d local_ip: %d local_rtp_port: %d.", config->local_pt, config->local_ip, config->local_rtp_port);
|
|
|
+ rtpDbg(vrtp,"videortp_create remote_pt: %d remote_ip: %d remote_rtp_port: %d.", config->remote_pt, config->remote_ip, config->remote_rtp_port);
|
|
|
+ rtpDbg(vrtp,"videortp_create tx_width: %d tx_height: %d.", config->tx_width, config->tx_height);
|
|
|
+ rtpDbg(vrtp,"videortp_create rx_width: %d rx_height: %d.", config->rx_width, config->rx_height);
|
|
|
+ rtpDbg(vrtp,"videortp_create capture_width: %d capture_height: %d.", config->capture_width, config->capture_height);
|
|
|
+ rtpDbg(vrtp,"videortp_create fps_num: %d bit_rate: %d dir: %d.", config->fps_num, config->bit_rate, config->dir);
|
|
|
|
|
|
INIT_LIST_HEAD(&vrtp->free_part_list);
|
|
|
for (i = 0; i < FRAME_WIN_SIZE; ++i) {
|
|
|
@@ -2095,7 +2123,7 @@ void videortp_destroy(videortp_t *vrtp)
|
|
|
}
|
|
|
config = &vrtp->config;
|
|
|
|
|
|
- Dbg("videortp_destroy.");
|
|
|
+ rtpDbg(vrtp,"videortp_destroy.");
|
|
|
|
|
|
receiver_clear_window(vrtp);
|
|
|
while (!list_empty(&vrtp->free_part_list)) {
|
|
|
@@ -2142,16 +2170,23 @@ int videortp_start(videortp_t *vrtp)
|
|
|
vrtp->recv_thread = (HANDLE)_beginthreadex(NULL, 0, &recv_proc, vrtp, 0, NULL);
|
|
|
#else
|
|
|
sem_init(&vrtp->sem_evt, 0, 0);
|
|
|
- int err = pthread_create(&vrtp->recv_threadid, NULL, recv_proc, vrtp);
|
|
|
+ pthread_attr_t attr;
|
|
|
+ pthread_attr_init(&attr);
|
|
|
+ struct sched_param param;
|
|
|
+ param.sched_priority = sched_get_priority_max(SCHED_RR);
|
|
|
+ pthread_attr_setschedpolicy(&attr, SCHED_RR);
|
|
|
+ pthread_attr_setschedparam(&attr, ¶m);
|
|
|
+ pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
|
|
+ int err = pthread_create(&vrtp->recv_threadid, &attr, recv_proc, vrtp);
|
|
|
if (0 == err) {
|
|
|
- Dbg("create vrtp recv thread success, %lu.", vrtp->recv_threadid);
|
|
|
+ rtpDbg(vrtp,"create vrtp recv thread success, %lu.", vrtp->recv_threadid);
|
|
|
}
|
|
|
else {
|
|
|
- Dbg("create vrtp recv thread failed.");
|
|
|
+ rtpDbg(vrtp,"create vrtp recv thread failed.");
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
- Dbg("videortp_start.");
|
|
|
+ rtpDbg(vrtp,"videortp_start.");
|
|
|
|
|
|
receiver_config_stats.remote_pt = vrtp->config.remote_pt;
|
|
|
receiver_config_stats.local_ip = vrtp->config.local_ip;
|
|
|
@@ -2180,7 +2215,7 @@ int videortp_start(videortp_t *vrtp)
|
|
|
void videortp_stop(videortp_t* vrtp)
|
|
|
{
|
|
|
int64_t now = TimeInMilliseconds();
|
|
|
- Dbg("start call videortp_stop.");
|
|
|
+ rtpDbg(vrtp,"start call videortp_stop.");
|
|
|
#ifdef _WIN32
|
|
|
if (vrtp->evt) {
|
|
|
SetEvent(vrtp->evt);
|
|
|
@@ -2203,13 +2238,13 @@ void videortp_stop(videortp_t* vrtp)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
- Dbg("stop rtp recv thread.");
|
|
|
+ rtpDbg(vrtp,"stop rtp recv thread.");
|
|
|
|
|
|
video_stats_receiver_on_stopped(now);
|
|
|
video_stats_sender_on_stopped(now);
|
|
|
|
|
|
video_jbuffer_api_stop(vrtp->jbuffer);
|
|
|
- Dbg("videortp_stop func end.");
|
|
|
+ rtpDbg(vrtp,"videortp_stop func end.");
|
|
|
}
|
|
|
|
|
|
int videortp_send_frame(videortp_t *vrtp, const video_frame *frame)
|
|
|
@@ -2218,7 +2253,7 @@ int videortp_send_frame(videortp_t *vrtp, const video_frame *frame)
|
|
|
int64_t now;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: videortp_send_frame width: %d height: %d format: %d.", __FILE__, __LINE__, frame->width, frame->height, frame->format);
|
|
|
+ rtpDbg(vrtp,"%s:%d: videortp_send_frame width: %d height: %d format: %d.", __FILE__, __LINE__, frame->width, frame->height, frame->format);
|
|
|
}
|
|
|
|
|
|
if (VIDEO_FORMAT_RGB24 != frame->format)
|
|
|
@@ -2236,7 +2271,7 @@ int videortp_send_frame(videortp_t *vrtp, const video_frame *frame)
|
|
|
vrtp->force_key_frames = 0;
|
|
|
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: videortp_send_frame force_key_frames.", __FILE__, __LINE__);
|
|
|
+ rtpDbg(vrtp,"%s:%d: videortp_send_frame force_key_frames.", __FILE__, __LINE__);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -2250,7 +2285,7 @@ int videortp_send_frame(videortp_t *vrtp, const video_frame *frame)
|
|
|
if (vrtp->framenum % start_key_interval == 0) {
|
|
|
video_encoder_api_send_key_frame(vrtp->encoder);
|
|
|
if(DEBUG_TX){
|
|
|
- Dbg("%s:%d: videortp_send_frame framenum: %d force_key_frames.", __FILE__, __LINE__, vrtp->framenum);
|
|
|
+ rtpDbg(vrtp,"%s:%d: videortp_send_frame framenum: %d force_key_frames.", __FILE__, __LINE__, vrtp->framenum);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2263,7 +2298,7 @@ int videortp_send_frame(videortp_t *vrtp, const video_frame *frame)
|
|
|
//从未收到cc_feedback估计带宽,远端不支持流量控制,将码率设为配置值
|
|
|
now = TimeInMilliseconds();
|
|
|
if ((vrtp->recv_cc_feedback == FALSE) && (now-vrtp->recv_cc_feedback_ms >= 10*1000)){
|
|
|
- Dbg("videortp_send_frame, never receive cc feedback, remote don't support .");
|
|
|
+ rtpDbg(vrtp,"videortp_send_frame, never receive cc feedback, remote don't support .");
|
|
|
|
|
|
sim_recv_bitrate_feedback(vrtp->config.bit_rate/*bps*/);
|
|
|
vrtp->recv_cc_feedback = TRUE;
|
|
|
@@ -2280,11 +2315,17 @@ int videortp_send_yuvframe(videortp_t *vrtp, const video_frame *vframe)
|
|
|
{
|
|
|
videortp_send_frame(vrtp, vframe);
|
|
|
|
|
|
+ static int itest = 0;
|
|
|
+ if (itest == 0) {
|
|
|
+ video_frame_save_bmpfile("videortp_send_yuvframe.bmp", vframe);
|
|
|
+ itest++;
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int videortp_reconfig_local_pt(videortp_t *vrtp, unsigned int local_pt){
|
|
|
- Dbg("videortp_reconfig_local_pt:%u .", local_pt);
|
|
|
+ rtpDbg(vrtp,"videortp_reconfig_local_pt:%u .", local_pt);
|
|
|
|
|
|
vrtp->config.local_pt = local_pt;
|
|
|
}
|