Use new ICE API to add STUN servers when SIP is Used.\n Fix rotation issue in h264
This commit is contained in:
parent
50c32ae287
commit
baf317bbb7
|
@ -87,12 +87,17 @@ typedef struct tdav_codec_h264_s
|
|||
}
|
||||
tdav_codec_h264_t;
|
||||
|
||||
#define TDAV_H264_GOP_SIZE_IN_SECONDS 25
|
||||
#if !defined(TDAV_H264_GOP_SIZE_IN_SECONDS)
|
||||
# define TDAV_H264_GOP_SIZE_IN_SECONDS 25
|
||||
#endif
|
||||
|
||||
#define kResetRotationTrue tsk_true
|
||||
#define kResetRotationFalse tsk_false
|
||||
|
||||
static int tdav_codec_h264_init(tdav_codec_h264_t* self, profile_idc_t profile);
|
||||
static int tdav_codec_h264_deinit(tdav_codec_h264_t* self);
|
||||
static int tdav_codec_h264_open_encoder(tdav_codec_h264_t* self);
|
||||
static int tdav_codec_h264_close_encoder(tdav_codec_h264_t* self);
|
||||
static int tdav_codec_h264_close_encoder(tdav_codec_h264_t* self, tsk_bool_t reset_rotation);
|
||||
static int tdav_codec_h264_open_decoder(tdav_codec_h264_t* self);
|
||||
static int tdav_codec_h264_close_decoder(tdav_codec_h264_t* self);
|
||||
|
||||
|
@ -158,13 +163,13 @@ static int tdav_codec_h264_set(tmedia_codec_t* self, const tmedia_param_t* param
|
|||
else if(tsk_striequals(param->key, "rotation")){
|
||||
int32_t rotation = *((int32_t*)param->value);
|
||||
if(h264->encoder.rotation != rotation){
|
||||
if(self->opened){
|
||||
h264->encoder.rotation = rotation;
|
||||
if (self->opened) {
|
||||
int ret;
|
||||
h264->encoder.rotation = rotation;
|
||||
if((ret = tdav_codec_h264_close_encoder(h264))){
|
||||
return ret;
|
||||
}
|
||||
if((ret = tdav_codec_h264_open_encoder(h264))){
|
||||
if ((ret = tdav_codec_h264_close_encoder(h264, kResetRotationFalse))) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = tdav_codec_h264_open_encoder(h264))) {
|
||||
return ret;
|
||||
}
|
||||
#if 0 // Not working
|
||||
|
@ -226,7 +231,7 @@ static int tdav_codec_h264_close(tmedia_codec_t* self)
|
|||
/* the caller (base class) alreasy checked that the codec is opened */
|
||||
|
||||
// Encoder
|
||||
tdav_codec_h264_close_encoder(h264);
|
||||
tdav_codec_h264_close_encoder(h264, kResetRotationTrue);
|
||||
|
||||
// Decoder
|
||||
tdav_codec_h264_close_decoder(h264);
|
||||
|
@ -811,7 +816,7 @@ int tdav_codec_h264_open_encoder(tdav_codec_h264_t* self)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int tdav_codec_h264_close_encoder(tdav_codec_h264_t* self)
|
||||
int tdav_codec_h264_close_encoder(tdav_codec_h264_t* self, tsk_bool_t reset_rotation)
|
||||
{
|
||||
#if HAVE_FFMPEG
|
||||
if(self->encoder.context){
|
||||
|
@ -828,7 +833,9 @@ int tdav_codec_h264_close_encoder(tdav_codec_h264_t* self)
|
|||
TSK_FREE(self->encoder.buffer);
|
||||
}
|
||||
self->encoder.frame_count = 0;
|
||||
self->encoder.rotation = 0; // reset rotation
|
||||
if (reset_rotation) {
|
||||
self->encoder.rotation = 0; // reset rotation
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -78,10 +78,13 @@ tdav_codec_h264_cisco_t;
|
|||
# define CISCO_H264_GOP_SIZE_IN_SECONDS 25
|
||||
#endif
|
||||
|
||||
#define kResetRotationTrue tsk_true
|
||||
#define kResetRotationFalse tsk_false
|
||||
|
||||
static int tdav_codec_h264_cisco_init(tdav_codec_h264_cisco_t* self, profile_idc_t profile);
|
||||
static int tdav_codec_h264_cisco_deinit(tdav_codec_h264_cisco_t* self);
|
||||
static int tdav_codec_h264_cisco_open_encoder(tdav_codec_h264_cisco_t* self);
|
||||
static int tdav_codec_h264_cisco_close_encoder(tdav_codec_h264_cisco_t* self);
|
||||
static int tdav_codec_h264_cisco_close_encoder(tdav_codec_h264_cisco_t* self, tsk_bool_t reset_rotation);
|
||||
static int tdav_codec_h264_cisco_open_decoder(tdav_codec_h264_cisco_t* self);
|
||||
static int tdav_codec_h264_cisco_close_decoder(tdav_codec_h264_cisco_t* self);
|
||||
static ELevelIdc tdav_codec_h264_cisco_convert_level(enum level_idc_e level);
|
||||
|
@ -148,10 +151,10 @@ static int tdav_codec_h264_cisco_set(tmedia_codec_t* self, const tmedia_param_t*
|
|||
else if (tsk_striequals(param->key, "rotation")) {
|
||||
int rotation = *((int32_t*)param->value);
|
||||
if (h264->encoder.rotation != rotation) {
|
||||
h264->encoder.rotation = rotation;
|
||||
if (self->opened) {
|
||||
int ret;
|
||||
h264->encoder.rotation = rotation;
|
||||
if ((ret = tdav_codec_h264_cisco_close_encoder(h264))) {
|
||||
if ((ret = tdav_codec_h264_cisco_close_encoder(h264, kResetRotationFalse))) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = tdav_codec_h264_cisco_open_encoder(h264))) {
|
||||
|
@ -216,10 +219,10 @@ static int tdav_codec_h264_cisco_close(tmedia_codec_t* self)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* the caller (base class) alreasy checked that the codec is opened */
|
||||
/* the caller (base class) already checked that the codec is opened */
|
||||
|
||||
// Encoder
|
||||
tdav_codec_h264_cisco_close_encoder(h264);
|
||||
tdav_codec_h264_cisco_close_encoder(h264, kResetRotationTrue);
|
||||
|
||||
// Decoder
|
||||
tdav_codec_h264_cisco_close_decoder(h264);
|
||||
|
@ -703,7 +706,7 @@ bail:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int tdav_codec_h264_cisco_close_encoder(tdav_codec_h264_cisco_t* self)
|
||||
static int tdav_codec_h264_cisco_close_encoder(tdav_codec_h264_cisco_t* self, tsk_bool_t reset_rotation)
|
||||
{
|
||||
if (self) {
|
||||
if (self->encoder.pInst) {
|
||||
|
@ -717,8 +720,10 @@ static int tdav_codec_h264_cisco_close_encoder(tdav_codec_h264_cisco_t* self)
|
|||
if (self->encoder.mutex) {
|
||||
tsk_mutex_destroy(&self->encoder.mutex);
|
||||
}
|
||||
self->encoder.frame_count = 0;
|
||||
self->encoder.rotation = 0; // reset rotation
|
||||
self->encoder.frame_count = 0;
|
||||
if (reset_rotation) {
|
||||
self->encoder.rotation = 0; // reset rotation
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ static int tsip_dialog_invite_ice_create_ctx(tsip_dialog_invite_t * self, tmedia
|
|||
TSK_DEBUG_ERROR("Failed to create ICE audio context");
|
||||
return -2;
|
||||
}
|
||||
#if 1 // @deprecated
|
||||
#if 0 // @deprecated
|
||||
ret = tnet_ice_ctx_set_stun(self->ice.ctx_audio, TSIP_DIALOG_GET_SS(self)->media.stun.hostname, TSIP_DIALOG_GET_SS(self)->media.stun.port, kStunSoftware, TSIP_DIALOG_GET_SS(self)->media.stun.username, TSIP_DIALOG_GET_SS(self)->media.stun.password);
|
||||
#else
|
||||
ret = tnet_ice_ctx_add_server(
|
||||
|
|
Loading…
Reference in New Issue