Merge pull request #1766 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:FS-11958 to master
* commit '863189fed69b953dcf732b351124a63814a8f322': FS-11958: [core] add switch_core_media functions that deal with bw and bitrate
This commit is contained in:
commit
241911817f
|
@ -365,6 +365,9 @@ SWITCH_DECLARE(switch_file_handle_t *) switch_core_media_get_video_file(switch_c
|
|||
SWITCH_DECLARE(switch_bool_t) switch_core_session_in_video_thread(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_set_outgoing_bitrate(switch_core_session_t *session, switch_media_type_t type, uint32_t bitrate);
|
||||
SWITCH_DECLARE(uint32_t) switch_core_media_get_orig_bitrate(switch_core_session_t *session, switch_media_type_t type);
|
||||
SWITCH_DECLARE(void) switch_core_media_set_media_bw_mult(switch_core_session_t *session, float mult);
|
||||
SWITCH_DECLARE(float) switch_core_media_get_media_bw_mult(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_reset_jb(switch_core_session_t *session, switch_media_type_t type);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_wait_for_video_input_params(switch_core_session_t *session, uint32_t timeout_ms);
|
||||
|
||||
|
|
|
@ -196,6 +196,8 @@ typedef struct switch_rtp_engine_s {
|
|||
uint8_t new_ice;
|
||||
uint8_t new_dtls;
|
||||
uint32_t sdp_bw;
|
||||
uint32_t orig_bitrate;
|
||||
float bw_mult;
|
||||
uint8_t reject_avp;
|
||||
int t140_pt;
|
||||
int red_pt;
|
||||
|
@ -12434,12 +12436,34 @@ SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t
|
|||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_core_media_get_orig_bitrate(switch_core_session_t *session, switch_media_type_t type)
|
||||
{
|
||||
switch_media_handle_t *smh;
|
||||
switch_rtp_engine_t *engine;
|
||||
|
||||
if (!(smh = session->media_handle)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (switch_channel_down(session->channel)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
engine = &smh->engines[type];
|
||||
|
||||
if (engine) {
|
||||
return engine->orig_bitrate;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_set_outgoing_bitrate(switch_core_session_t *session, switch_media_type_t type, uint32_t bitrate)
|
||||
{
|
||||
switch_media_handle_t *smh;
|
||||
switch_rtp_engine_t *engine;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
uint32_t new_bitrate;
|
||||
|
||||
if (!(smh = session->media_handle)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -12451,14 +12475,57 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_outgoing_bitrate(switch_co
|
|||
|
||||
engine = &smh->engines[type];
|
||||
|
||||
new_bitrate = bitrate - bitrate * engine->bw_mult;
|
||||
if (switch_core_codec_ready(&engine->write_codec)) {
|
||||
status = switch_core_codec_control(&engine->write_codec, SCC_VIDEO_BANDWIDTH,
|
||||
SCCT_INT, &bitrate, SCCT_NONE, NULL, NULL, NULL);
|
||||
SCCT_INT, &new_bitrate, SCCT_NONE, NULL, NULL, NULL);
|
||||
}
|
||||
engine->orig_bitrate = bitrate;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(float) switch_core_media_get_media_bw_mult(switch_core_session_t *session)
|
||||
{
|
||||
switch_media_handle_t *smh;
|
||||
switch_rtp_engine_t *engine;
|
||||
|
||||
if (!(smh = session->media_handle)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (switch_channel_down(session->channel)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
|
||||
|
||||
if (engine) {
|
||||
return engine->bw_mult;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_media_set_media_bw_mult(switch_core_session_t *session, float mult)
|
||||
{
|
||||
switch_media_handle_t *smh;
|
||||
switch_rtp_engine_t *engine;
|
||||
|
||||
if (!(smh = session->media_handle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (switch_channel_down(session->channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
|
||||
|
||||
if (engine) {
|
||||
engine->bw_mult = mult;
|
||||
}
|
||||
}
|
||||
|
||||
//?
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_reset_jb(switch_core_session_t *session, switch_media_type_t type)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue