Fix media update issues with sip2sip.info (loosing AVPF profile info which disable RTCP-FB)
This commit is contained in:
parent
e150f2eab6
commit
2834ba3d41
|
@ -1047,6 +1047,8 @@ int tdav_codec_h263_open_decoder(tdav_codec_h263_t* self)
|
|||
return ret;
|
||||
}
|
||||
|
||||
self->decoder.last_seq = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -805,10 +805,13 @@ int tdav_codec_h264_open_encoder(tdav_codec_h264_t* self)
|
|||
return ret;
|
||||
}
|
||||
|
||||
self->encoder.frame_count = 0;
|
||||
|
||||
TSK_DEBUG_INFO("[H.264] bitrate=%d bps", self->encoder.context->bit_rate);
|
||||
|
||||
return ret;
|
||||
#elif HAVE_H264_PASSTHROUGH
|
||||
self->encoder.frame_count = 0;
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
@ -870,6 +873,7 @@ int tdav_codec_h264_open_decoder(tdav_codec_h264_t* self)
|
|||
TSK_DEBUG_ERROR("Failed to open [%s] codec", TMEDIA_CODEC(self)->plugin->desc);
|
||||
return ret;
|
||||
}
|
||||
self->decoder.last_seq = 0;
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -700,6 +700,8 @@ static int tdav_codec_h264_cisco_open_encoder(tdav_codec_h264_cisco_t* self)
|
|||
goto bail;
|
||||
}
|
||||
|
||||
self->encoder.frame_count = 0;
|
||||
|
||||
ret = 0;
|
||||
|
||||
bail:
|
||||
|
@ -755,6 +757,7 @@ int tdav_codec_h264_cisco_open_decoder(tdav_codec_h264_cisco_t* self)
|
|||
TSK_DEBUG_ERROR("Failed to initialize decoder: %ld", err);
|
||||
goto bail;
|
||||
}
|
||||
self->decoder.last_seq = 0;
|
||||
TSK_DEBUG_INFO("[OpenH264 Decoder] neg_width=%d, neg_height=%d, neg_fps=%d",
|
||||
TMEDIA_CODEC_VIDEO(self)->in.width,
|
||||
TMEDIA_CODEC_VIDEO(self)->in.height,
|
||||
|
|
|
@ -569,6 +569,8 @@ int tdav_codec_mp4ves_open_decoder(tdav_codec_mp4ves_t* self)
|
|||
return ret;
|
||||
}
|
||||
|
||||
self->decoder.last_seq = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ static int tdav_codec_opus_open(tmedia_codec_t* self)
|
|||
return -2;
|
||||
}
|
||||
}
|
||||
opus->decoder.last_seq = 0;
|
||||
|
||||
// Initialize the encoder
|
||||
if(!opus->encoder.inst){
|
||||
|
|
|
@ -777,6 +777,8 @@ int tdav_codec_vp8_open_encoder(tdav_codec_vp8_t* self)
|
|||
return -4;
|
||||
}
|
||||
|
||||
self->encoder.frame_count = 0;
|
||||
|
||||
self->encoder.initialized = tsk_true;
|
||||
|
||||
TSK_DEBUG_INFO("[VP8] target_bitrate=%d kbps", self->encoder.cfg.rc_target_bitrate);
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#define TDAV_VIDEO_JB_LATENCY_MIN 2 /* Must be > 0 */
|
||||
#define TDAV_VIDEO_JB_LATENCY_MAX 15 /* Default, will be updated using fps */
|
||||
|
||||
static int _tdav_video_jb_set_defaults(struct tdav_video_jb_s* self);
|
||||
static const tdav_video_frame_t* _tdav_video_jb_get_frame(struct tdav_video_jb_s* self, uint32_t timestamp, uint8_t pt, tsk_bool_t *pt_matched);
|
||||
static void* TSK_STDCALL _tdav_video_jb_decode_thread_func(void *arg);
|
||||
|
||||
|
@ -122,15 +123,6 @@ static tsk_object_t* tdav_video_jb_ctor(tsk_object_t * self, va_list * app)
|
|||
jb->cb_data_fdd.type = tdav_video_jb_cb_data_type_fdd;
|
||||
jb->cb_data_rtp.type = tdav_video_jb_cb_data_type_rtp;
|
||||
|
||||
jb->decode_last_seq_num_with_mark = -1;
|
||||
|
||||
jb->fps = TDAV_VIDEO_JB_FPS_MAX;
|
||||
|
||||
jb->rate = TDAV_VIDEO_JB_RATE;
|
||||
|
||||
jb->latency_min = TDAV_VIDEO_JB_LATENCY_MIN;
|
||||
jb->latency_max = TDAV_VIDEO_JB_LATENCY_MAX;
|
||||
|
||||
tsk_safeobj_init(jb);
|
||||
}
|
||||
return self;
|
||||
|
@ -165,9 +157,9 @@ tdav_video_jb_t* tdav_video_jb_create()
|
|||
tdav_video_jb_t* jb;
|
||||
|
||||
if ((jb = tsk_object_new(&tdav_video_jb_def_s))) {
|
||||
jb->fps = TDAV_VIDEO_JB_FPS;
|
||||
jb->fps_prob = TDAV_VIDEO_JB_FPS_PROB;
|
||||
jb->tail_max = TDAV_VIDEO_JB_TAIL_MAX;
|
||||
if (_tdav_video_jb_set_defaults(jb) != 0) {
|
||||
TSK_OBJECT_SAFE_FREE(jb);
|
||||
}
|
||||
}
|
||||
return jb;
|
||||
}
|
||||
|
@ -367,9 +359,43 @@ int tdav_video_jb_stop(tdav_video_jb_t* self)
|
|||
ret = tsk_thread_join(&self->decode_thread[0]);
|
||||
}
|
||||
|
||||
// clear pending frames
|
||||
tsk_list_lock(self->frames);
|
||||
tsk_list_clear_items(self->frames);
|
||||
self->frames_count = 0;
|
||||
tsk_list_unlock(self->frames);
|
||||
|
||||
// reset default values to make sure next start will be called with right defaults
|
||||
// do not call this function in start to avoid overriding values defined between prepare() and start()
|
||||
_tdav_video_jb_set_defaults(self);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _tdav_video_jb_set_defaults(struct tdav_video_jb_s* self)
|
||||
{
|
||||
if (!self) {
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
self->fps = TDAV_VIDEO_JB_FPS;
|
||||
self->fps_prob = TDAV_VIDEO_JB_FPS_PROB;
|
||||
self->tail_max = TDAV_VIDEO_JB_TAIL_MAX;
|
||||
self->avg_duration = 0;
|
||||
self->rate = TDAV_VIDEO_JB_RATE;
|
||||
self->conseq_frame_drop = 0;
|
||||
self->frames_count = 0;
|
||||
self->decode_last_timestamp = 0;
|
||||
self->decode_last_seq_num_with_mark = -1;
|
||||
self->decode_last_time = 0;
|
||||
|
||||
self->latency_min = TDAV_VIDEO_JB_LATENCY_MIN;
|
||||
self->latency_max = TDAV_VIDEO_JB_LATENCY_MAX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const tdav_video_frame_t* _tdav_video_jb_get_frame(tdav_video_jb_t* self, uint32_t timestamp, uint8_t pt, tsk_bool_t *pt_matched)
|
||||
{
|
||||
const tdav_video_frame_t* ret = tsk_null;
|
||||
|
|
|
@ -134,6 +134,8 @@ static const tmedia_codec_action_t __action_encode_bw_down = tmedia_codec_action
|
|||
(__self)->encoder.pkt_loss_prob_bad = TDAV_SESSION_VIDEO_PKT_LOSS_PROB_BAD; \
|
||||
(__self)->encoder.pkt_loss_prob_good = TDAV_SESSION_VIDEO_PKT_LOSS_PROB_GOOD; \
|
||||
}
|
||||
|
||||
static int _tdav_session_video_set_defaults(tdav_session_video_t* self);
|
||||
static int _tdav_session_video_jb_cb(const tdav_video_jb_cb_data_xt* data);
|
||||
static int _tdav_session_video_open_decoder(tdav_session_video_t* self, uint8_t payload_type);
|
||||
static int _tdav_session_video_decode(tdav_session_video_t* self, const trtp_rtp_packet_t* packet);
|
||||
|
@ -681,6 +683,28 @@ static int tdav_session_video_rtcp_cb(const void* callback_data, const trtp_rtcp
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int _tdav_session_video_set_defaults(tdav_session_video_t* self)
|
||||
{
|
||||
if (!self) {
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
self->jb_enabled = tmedia_defaults_get_videojb_enabled();
|
||||
self->zero_artifacts = tmedia_defaults_get_video_zeroartifacts_enabled();
|
||||
self->avpf.max = tmedia_defaults_get_avpf_tail_min();
|
||||
self->encoder.pkt_loss_level = tdav_session_video_pkt_loss_level_low;
|
||||
self->encoder.pkt_loss_prob_bad = 0; // honor first report
|
||||
self->encoder.pkt_loss_prob_good = TDAV_SESSION_VIDEO_PKT_LOSS_PROB_GOOD;
|
||||
self->encoder.last_frame_time = 0;
|
||||
|
||||
// reset rotation info (MUST for reINVITE when mobile device in portrait[90 degrees])
|
||||
self->encoder.rotation = 0;
|
||||
|
||||
TSK_DEBUG_INFO("Video 'zero-artifacts' option = %s", self->zero_artifacts ? "yes" : "no");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// From jitter buffer to codec
|
||||
static int _tdav_session_video_jb_cb(const tdav_video_jb_cb_data_xt* data)
|
||||
{
|
||||
|
@ -1044,6 +1068,7 @@ static int tdav_session_video_get(tmedia_session_t* self, tmedia_param_t* param)
|
|||
static int tdav_session_video_prepare(tmedia_session_t* self)
|
||||
{
|
||||
tdav_session_av_t* base = (tdav_session_av_t*)(self);
|
||||
tdav_session_video_t* video = (tdav_session_video_t*)self;
|
||||
int ret;
|
||||
|
||||
if((ret = tdav_session_av_prepare(base))){
|
||||
|
@ -1151,8 +1176,9 @@ static int tdav_session_video_stop(tmedia_session_t* self)
|
|||
tsk_mutex_unlock(video->encoder.h_mutex);
|
||||
TSK_OBJECT_SAFE_FREE(video->decoder.codec);
|
||||
|
||||
// reset rotation info (MUST for reINVITE when mobile device in portrait[90 degrees])
|
||||
video->encoder.rotation = 0;
|
||||
// reset default values to make sure next start will be called with right defaults
|
||||
// do not call this function in start to avoid overriding values defined between prepare() and start()
|
||||
_tdav_session_video_set_defaults(video);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1348,10 +1374,8 @@ static int _tdav_session_video_init(tdav_session_video_t *p_self, tmedia_type_t
|
|||
}
|
||||
|
||||
/* init() self */
|
||||
p_self->jb_enabled = tmedia_defaults_get_videojb_enabled();
|
||||
p_self->zero_artifacts = tmedia_defaults_get_video_zeroartifacts_enabled();
|
||||
TSK_DEBUG_INFO("Video 'zero-artifacts' option = %s", p_self->zero_artifacts ? "yes" : "no");
|
||||
if (!(p_self->encoder.h_mutex = tsk_mutex_create())) {
|
||||
_tdav_session_video_set_defaults(p_self);
|
||||
if (!p_self->encoder.h_mutex && !(p_self->encoder.h_mutex = tsk_mutex_create())) {
|
||||
TSK_DEBUG_ERROR("Failed to create encode mutex");
|
||||
return -4;
|
||||
}
|
||||
|
@ -1371,10 +1395,6 @@ static int _tdav_session_video_init(tdav_session_video_t *p_self, tmedia_type_t
|
|||
tmedia_producer_set_enc_callback(p_base->producer, tdav_session_video_producer_enc_cb, p_self);
|
||||
tmedia_producer_set_raw_callback(p_base->producer, tdav_session_video_raw_cb, p_self);
|
||||
}
|
||||
p_self->avpf.max = tmedia_defaults_get_avpf_tail_min();
|
||||
p_self->encoder.pkt_loss_level = tdav_session_video_pkt_loss_level_low;
|
||||
p_self->encoder.pkt_loss_prob_bad = 0; // honor first report
|
||||
p_self->encoder.pkt_loss_prob_good = TDAV_SESSION_VIDEO_PKT_LOSS_PROB_GOOD;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1997,6 +1997,7 @@ int tmedia_session_mgr_set_onerror_cbfn(tmedia_session_mgr_t* self, const void*
|
|||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
// save for sessions created later
|
||||
self->onerror_cb.fun = fun;
|
||||
self->onerror_cb.usrdata = usrdata;
|
||||
|
||||
|
@ -2021,6 +2022,7 @@ int tmedia_session_mgr_set_rfc5168_cbfn(tmedia_session_mgr_t* self, const void*
|
|||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
// save for functions created later
|
||||
self->rfc5168_cb.fun = fun;
|
||||
self->rfc5168_cb.usrdata = usrdata;
|
||||
|
||||
|
@ -2121,9 +2123,6 @@ static int _tmedia_session_mgr_load_sessions(tmedia_session_mgr_t* self)
|
|||
|
||||
/* set other default values */
|
||||
|
||||
// set callback functions
|
||||
tmedia_session_set_onerror_cbfn(session, self->onerror_cb.usrdata, self->onerror_cb.fun);
|
||||
|
||||
/* push session */
|
||||
tsk_list_push_back_data(self->sessions, (void**)(&session));
|
||||
}
|
||||
|
@ -2147,6 +2146,9 @@ static int _tmedia_session_mgr_load_sessions(tmedia_session_mgr_t* self)
|
|||
TMEDIA_SESSION_SET_STR(self->type, "local-ipver", self->ipv6 ? "ipv6" : "ipv4"),
|
||||
TMEDIA_SESSION_SET_INT32(self->type, "bandwidth-level", self->bl),
|
||||
TMEDIA_SESSION_SET_NULL());
|
||||
// set callback functions
|
||||
tmedia_session_mgr_set_onerror_cbfn(self, self->onerror_cb.usrdata, self->onerror_cb.fun);
|
||||
tmedia_session_mgr_set_rfc5168_cbfn(self, self->rfc5168_cb.usrdata, self->rfc5168_cb.fun);
|
||||
}
|
||||
#undef has_media
|
||||
|
||||
|
|
|
@ -1688,8 +1688,12 @@ int trtp_manager_stop(trtp_manager_t* self)
|
|||
TSK_OBJECT_SAFE_FREE(master_copy);
|
||||
TSK_OBJECT_SAFE_FREE(self->transport);
|
||||
}
|
||||
// Free RTCP socket
|
||||
// Free RTCP info to make sure these values will be updated in next start()
|
||||
TSK_OBJECT_SAFE_FREE(self->rtcp.local_socket);
|
||||
TSK_OBJECT_SAFE_FREE(self->rtcp.session);
|
||||
self->rtcp.public_port = self->rtcp.remote_port = 0;
|
||||
TSK_FREE(self->rtcp.public_ip);
|
||||
TSK_FREE(self->rtcp.remote_ip);
|
||||
|
||||
// reset default values
|
||||
self->is_symetric_rtp_checked = self->is_symetric_rtcp_checked = tsk_false;
|
||||
|
|
|
@ -878,7 +878,7 @@ int tsdp_header_M_diff(const tsdp_header_M_t* M_old, const tsdp_header_M_t* M_ne
|
|||
diff |= tsdp_header_M_diff_sdes_crypto;
|
||||
}
|
||||
}
|
||||
else if (index == 0) { // (A1 && !AO) means "more" crypto lines, otherwise "less". In all cases if the first matched we're ok
|
||||
else if (index == 0 && (A0 || A1)) { // (A1 && !AO) means "more" crypto lines, otherwise "less". In all cases if the first matched we're ok
|
||||
diff |= tsdp_header_M_diff_sdes_crypto;
|
||||
}
|
||||
++index;
|
||||
|
|
Loading…
Reference in New Issue