Functions | |
| switch_status_t | switch_core_codec_init (switch_codec_t *codec, const char *codec_name, const char *fmtp, uint32_t rate, int ms, int channels, uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool) |
| Initialize a codec handle. | |
| switch_status_t | switch_core_codec_copy (switch_codec_t *codec, switch_codec_t *new_codec, switch_memory_pool_t *pool) |
| switch_status_t | switch_core_codec_encode (switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data, uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag) |
| Encode data using a codec handle. | |
| switch_status_t | switch_core_codec_decode (switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag) |
| Decode data using a codec handle. | |
| switch_status_t | switch_core_codec_destroy (switch_codec_t *codec) |
| Destroy an initalized codec handle. | |
| switch_status_t | switch_core_session_set_read_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the read codec to a given session. | |
| void | switch_core_session_unset_read_codec (_In_ switch_core_session_t *session) |
| switch_codec_t * | switch_core_session_get_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the read codec from a given session. | |
| switch_codec_t * | switch_core_session_get_effective_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the effevtive read codec from a given session. | |
| switch_status_t | switch_core_session_set_write_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the write codec to a given session. | |
| switch_codec_t * | switch_core_session_get_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the write codec from a given session. | |
| switch_codec_t * | switch_core_session_get_effective_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the effevtive write codec from a given session. | |
| switch_status_t | switch_core_session_set_video_read_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the video_read codec to a given session. | |
| switch_codec_t * | switch_core_session_get_video_read_codec (_In_ switch_core_session_t *session) |
| Retrieve the video_read codec from a given session. | |
| switch_status_t | switch_core_session_set_video_write_codec (_In_ switch_core_session_t *session, switch_codec_t *codec) |
| Assign the video_write codec to a given session. | |
| switch_codec_t * | switch_core_session_get_video_write_codec (_In_ switch_core_session_t *session) |
| Retrieve the video_write codec from a given session. | |
|
||||||||||||||||
|
00253 {
00254 switch_status_t status;
00255
00256 switch_assert(codec != NULL);
00257 switch_assert(new_codec != NULL);
00258
00259 if (pool) {
00260 new_codec->memory_pool = pool;
00261 } else {
00262 if ((status = switch_core_new_memory_pool(&new_codec->memory_pool)) != SWITCH_STATUS_SUCCESS) {
00263 return status;
00264 }
00265 switch_set_flag(new_codec, SWITCH_CODEC_FLAG_FREE_POOL);
00266 }
00267
00268 new_codec->codec_interface = codec->codec_interface;
00269 new_codec->implementation = codec->implementation;
00270 new_codec->flags = codec->flags;
00271
00272 if (codec->fmtp_in) {
00273 new_codec->fmtp_in = switch_core_strdup(new_codec->memory_pool, codec->fmtp_in);
00274 }
00275
00276 new_codec->implementation->init(new_codec, new_codec->flags, NULL);
00277
00278 return SWITCH_STATUS_SUCCESS;
00279 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Decode data using a codec handle.
00398 {
00399 switch_assert(codec != NULL);
00400 switch_assert(encoded_data != NULL);
00401 switch_assert(decoded_data != NULL);
00402
00403 if (!codec->implementation) {
00404 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
00405 return SWITCH_STATUS_GENERR;
00406 }
00407
00408 if (!switch_test_flag(codec, SWITCH_CODEC_FLAG_DECODE)) {
00409 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec decoder is not initialized!\n");
00410 return SWITCH_STATUS_GENERR;
00411 }
00412
00413 return codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate, decoded_data, decoded_data_len, decoded_rate,
00414 flag);
00415 }
|
Here is the call graph for this function:

|
|
Destroy an initalized codec handle.
00418 {
00419 switch_assert(codec != NULL);
00420
00421 if (!codec->implementation) {
00422 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec is not initialized!\n");
00423 return SWITCH_STATUS_GENERR;
00424 }
00425
00426 codec->implementation->destroy(codec);
00427
00428 if (switch_test_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL)) {
00429 switch_core_destroy_memory_pool(&codec->memory_pool);
00430 }
00431
00432 memset(codec, 0, sizeof(*codec));
00433
00434 return SWITCH_STATUS_SUCCESS;
00435 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||
|
Encode data using a codec handle.
00373 {
00374 switch_assert(codec != NULL);
00375 switch_assert(encoded_data != NULL);
00376 switch_assert(decoded_data != NULL);
00377
00378 if (!codec->implementation) {
00379 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
00380 return SWITCH_STATUS_GENERR;
00381 }
00382
00383 if (!switch_test_flag(codec, SWITCH_CODEC_FLAG_ENCODE)) {
00384 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec encoder is not initialized!\n");
00385 return SWITCH_STATUS_GENERR;
00386 }
00387
00388 return codec->implementation->encode(codec, other_codec, decoded_data, decoded_data_len, decoded_rate, encoded_data, encoded_data_len, encoded_rate,
00389 flag);
00390 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||
|
Initialize a codec handle.
00284 {
00285 const switch_codec_interface_t *codec_interface;
00286 const switch_codec_implementation_t *iptr, *implementation = NULL;
00287 const char *mode = fmtp;
00288
00289 switch_assert(codec != NULL);
00290 switch_assert(codec_name != NULL);
00291
00292 memset(codec, 0, sizeof(*codec));
00293
00294 if (channels == 2) {
00295 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stereo is currently unsupported. please downsample audio source to mono.\n");
00296 return SWITCH_STATUS_GENERR;
00297 }
00298
00299 if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name)) == 0) {
00300 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid codec %s!\n", codec_name);
00301 return SWITCH_STATUS_GENERR;
00302 }
00303
00304 if (!strcasecmp(codec_name, "ilbc") && mode && strncasecmp(mode, "mode=", 5)) {
00305 int mms;
00306 mode += 5;
00307 if (mode) {
00308 mms = atoi(mode);
00309 if (mms > 0 && mms < 120) {
00310 ms = mms;
00311 }
00312 }
00313 }
00314
00315 /* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
00316 if (!ms) {
00317 for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
00318 if ((!rate || rate == iptr->samples_per_second) &&
00319 (20 == (iptr->microseconds_per_frame / 1000)) && (!channels || channels == iptr->number_of_channels)) {
00320 implementation = iptr;
00321 goto found;
00322 }
00323 }
00324 }
00325
00326 /* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
00327 for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
00328 if ((!rate || rate == iptr->samples_per_second) &&
00329 (!ms || ms == (iptr->microseconds_per_frame / 1000)) && (!channels || channels == iptr->number_of_channels)) {
00330 implementation = iptr;
00331 break;
00332 }
00333 }
00334
00335 found:
00336
00337 if (implementation) {
00338 switch_status_t status;
00339 codec->codec_interface = codec_interface;
00340 codec->implementation = implementation;
00341 codec->flags = flags;
00342
00343 if (pool) {
00344 codec->memory_pool = pool;
00345 } else {
00346 if ((status = switch_core_new_memory_pool(&codec->memory_pool)) != SWITCH_STATUS_SUCCESS) {
00347 return status;
00348 }
00349 switch_set_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL);
00350 }
00351
00352 if (fmtp) {
00353 codec->fmtp_in = switch_core_strdup(codec->memory_pool, fmtp);
00354 }
00355
00356 implementation->init(codec, flags, codec_settings);
00357
00358 return SWITCH_STATUS_SUCCESS;
00359 } else {
00360 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms\n", codec_name, rate,
00361 ms);
00362 }
00363
00364 return SWITCH_STATUS_NOTIMPL;
00365 }
|
Here is the call graph for this function:

|
|
Retrieve the effevtive read codec from a given session.
|
|
|
Retrieve the effevtive write codec from a given session.
|
|
|
Retrieve the read codec from a given session.
|
|
|
Retrieve the video_read codec from a given session.
|
|
|
Retrieve the video_write codec from a given session.
|
|
|
Retrieve the write codec from a given session.
|
|
||||||||||||
|
Assign the read codec to a given session.
|
|
||||||||||||
|
Assign the video_read codec to a given session.
|
|
||||||||||||
|
Assign the video_write codec to a given session.
|
|
||||||||||||
|
Assign the write codec to a given session.
|
|
|
|
1.3.9.1