|
|
@@ -170,6 +170,13 @@ static void rtpDbg(videortp_t *rtp, const char *fmt, ...)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static void rtpLogevent(videortp_t* rtp, int itype, const char* strmessage)
|
|
|
+{
|
|
|
+ if (rtp->config.logevent) {
|
|
|
+ (*rtp->config.logevent)(rtp->config.user_data, itype, strmessage);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
//#define Dbg(__fmt__, ...) __Dbg(vrtp, __fmt__, __VA_ARGS__)
|
|
|
|
|
|
@@ -1145,7 +1152,6 @@ void* recv_proc(void* arg)
|
|
|
videortp_t *vrtp = (videortp_t*)arg;
|
|
|
int rtp_timeout_cnt = 0;
|
|
|
int64_t pre_500_ms = TimeInMilliseconds();
|
|
|
-
|
|
|
rtpDbg(vrtp,"enter recv_proc.");
|
|
|
#ifdef _WIN32
|
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
|
|
|
@@ -2017,8 +2023,10 @@ static rtp_session_t *videortp_internal_create_rtp_session(const videortp_config
|
|
|
int rc;
|
|
|
addr.s_addr = config->local_ip;
|
|
|
rc = rtp_session_create(inet_ntoa(addr), config->local_rtp_port, 2, &rtp_sess);
|
|
|
- if (rc != 0)
|
|
|
+ if (rc != 0){
|
|
|
return 0;
|
|
|
+ }
|
|
|
+
|
|
|
addr.s_addr = config->remote_ip;
|
|
|
rtp_session_reset(rtp_sess, config->dir, inet_ntoa(addr), config->remote_rtp_port, config->remote_rtp_port+1);
|
|
|
{
|
|
|
@@ -2078,28 +2086,34 @@ int videortp_create(const videortp_config_t *config, videortp_t **p_rtp)
|
|
|
}
|
|
|
vrtp->delta_ts = VIDEO_CLOCK * config->fps_den / config->fps_num;
|
|
|
vrtp->rtp_sess = videortp_internal_create_rtp_session(config);
|
|
|
- if (!vrtp->rtp_sess)
|
|
|
+ if (!vrtp->rtp_sess) {
|
|
|
+ char strMessage[MAX_PATH] = { 0 };
|
|
|
+ snprintf(strMessage, MAX_PATH, "video rtp create failed and local port is %d.", config->local_rtp_port);
|
|
|
+ rtpLogevent(vrtp, 0, strMessage);
|
|
|
goto on_error;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ char strInfo[MAX_PATH] = { 0 };
|
|
|
+ snprintf(strInfo, MAX_PATH, "video rtp create success and local port is %d.", config->local_rtp_port);
|
|
|
+ rtpLogevent(vrtp, 0, strInfo);
|
|
|
+ }
|
|
|
|
|
|
{
|
|
|
- VideoStatsLogCallBack log_func;
|
|
|
- log_func.log_fn = &video_stats_on_log;
|
|
|
- log_func.userdata = vrtp;
|
|
|
- video_stats_init(&log_func);
|
|
|
+ VideoStatsLogCallBack log_func;
|
|
|
+ log_func.log_fn = &video_stats_on_log;
|
|
|
+ log_func.userdata = vrtp;
|
|
|
+ video_stats_init(&log_func);
|
|
|
}
|
|
|
jitter_buffer_create(vrtp, config);
|
|
|
vrtp->rtp_header_extension = rtp_header_extension_api_new();
|
|
|
|
|
|
if (config->dir & DIR_RX) {
|
|
|
decoder_create(vrtp, config);
|
|
|
-
|
|
|
video_debug_open_play_file();
|
|
|
}
|
|
|
if (config->dir & DIR_TX) {
|
|
|
ffmpeg_encoder_create(vrtp, config);
|
|
|
-
|
|
|
video_debug_open_record_file();
|
|
|
-
|
|
|
vrtp->framenum = 0;
|
|
|
}
|
|
|
|
|
|
@@ -2125,6 +2139,7 @@ on_error:
|
|
|
void videortp_destroy(videortp_t *vrtp)
|
|
|
{
|
|
|
videortp_config_t *config;
|
|
|
+ unsigned short ilocal_port = 0;
|
|
|
|
|
|
if (!vrtp){
|
|
|
return;
|
|
|
@@ -2148,7 +2163,14 @@ void videortp_destroy(videortp_t *vrtp)
|
|
|
rtp_header_extension_api_destroy(vrtp->rtp_header_extension);
|
|
|
h264_packetizer_destroy(vrtp->h264_packetizer);
|
|
|
|
|
|
+ rtp_session_get_local_rtp_port(vrtp->rtp_sess, &ilocal_port);
|
|
|
+
|
|
|
rtp_session_destroy(vrtp->rtp_sess);
|
|
|
+ {
|
|
|
+ char strInfo[MAX_PATH] = { 0 };
|
|
|
+ snprintf(strInfo, MAX_PATH, "video rtp destroy and local port is %u.", ilocal_port);
|
|
|
+ rtpLogevent(vrtp, 1, strInfo);
|
|
|
+ }
|
|
|
vrtp->rtp_sess = NULL;
|
|
|
|
|
|
if (config->dir & DIR_RX) {
|