mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 07:45:26 +00:00
refactor fmtp parser as a core func
This commit is contained in:
parent
76a065ec8b
commit
56f8c11f0b
@ -1351,6 +1351,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec
|
||||
uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_reset(switch_codec_t *codec);
|
||||
|
||||
/*!
|
||||
|
@ -4152,6 +4152,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
const char *rm_encoding;
|
||||
uint32_t map_bit_rate = 0;
|
||||
int codec_ms = 0;
|
||||
switch_codec_fmtp_t codec_fmtp = { 0 };
|
||||
|
||||
if (x++ < skip) {
|
||||
continue;
|
||||
@ -4197,9 +4198,18 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
|
||||
map_bit_rate = switch_known_bitrate(map->rm_pt);
|
||||
|
||||
if (!codec_ms) {
|
||||
codec_ms = ptime;
|
||||
if (!zstr(map->rm_fmtp)) {
|
||||
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
|
||||
if (codec_fmtp.bits_per_second) {
|
||||
map_bit_rate = codec_fmtp.bits_per_second;
|
||||
}
|
||||
if (codec_fmtp.microseconds_per_packet) {
|
||||
ptime = (codec_fmtp.microseconds_per_packet / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
codec_ms = ptime;
|
||||
|
||||
for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
|
||||
|
@ -450,6 +450,28 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_write_codec(switc
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp)
|
||||
{
|
||||
switch_codec_interface_t *codec_interface;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (zstr(codec_name) || zstr(fmtp) || !codec_fmtp) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
memset(codec_fmtp, 0, sizeof(*codec_fmtp));
|
||||
|
||||
if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name))) {
|
||||
if (codec_interface->parse_fmtp) {
|
||||
codec_fmtp->actual_samples_per_second = rate;
|
||||
status = codec_interface->parse_fmtp(fmtp, codec_fmtp);
|
||||
}
|
||||
|
||||
UNPROTECT_INTERFACE(codec_interface);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_reset(switch_codec_t *codec)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user