Typedefs | |
| typedef void(* | switch_rtp_invalid_handler_t )(switch_rtp_t *rtp_session, switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr) |
Functions | |
| void | switch_rtp_get_random (void *buf, uint32_t len) |
| void | switch_rtp_init (switch_memory_pool_t *pool) |
| Initilize the RTP System. | |
| void | switch_rtp_shutdown (void) |
| switch_port_t | switch_rtp_set_start_port (switch_port_t port) |
| Set/Get RTP start port. | |
| switch_port_t | switch_rtp_set_end_port (switch_port_t port) |
| Set/Get RTP end port. | |
| switch_port_t | switch_rtp_request_port (const char *ip) |
| Request a new port to be used for media. | |
| void | switch_rtp_release_port (const char *ip, switch_port_t port) |
| switch_status_t | switch_rtp_create (switch_rtp_t **new_rtp_session, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool) |
| create a new RTP session handle | |
| switch_rtp_t * | switch_rtp_new (const char *rx_host, switch_port_t rx_port, const char *tx_host, switch_port_t tx_port, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool) |
| prepare a new RTP session handle and fully initilize it | |
| switch_status_t | switch_rtp_set_remote_address (switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_bool_t change_adv_addr, const char **err) |
| Assign a remote address to the RTP session. | |
| char * | switch_rtp_get_remote_host (switch_rtp_t *rtp_session) |
| switch_port_t | switch_rtp_get_remote_port (switch_rtp_t *rtp_session) |
| void | switch_rtp_set_max_missed_packets (switch_rtp_t *rtp_session, uint32_t max) |
| switch_status_t | switch_rtp_set_local_address (switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err) |
| Assign a local address to the RTP session. | |
| void | switch_rtp_kill_socket (switch_rtp_t *rtp_session) |
| Kill the socket on an existing RTP session. | |
| void | switch_rtp_break (switch_rtp_t *rtp_session) |
| uint8_t | switch_rtp_ready (switch_rtp_t *rtp_session) |
| Test if an RTP session is ready. | |
| void | switch_rtp_destroy (switch_rtp_t **rtp_session) |
| Destroy an RTP session. | |
| switch_status_t | switch_rtp_activate_ice (switch_rtp_t *rtp_session, char *login, char *rlogin) |
| Acvite ICE on an RTP session. | |
| switch_status_t | switch_rtp_activate_jitter_buffer (switch_rtp_t *rtp_session, uint32_t queue_frames) |
| Acvite a jitter buffer on an RTP session. | |
| void | switch_rtp_set_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Set an RTP Flag. | |
| uint32_t | switch_rtp_test_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Test an RTP Flag. | |
| void | switch_rtp_clear_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Clear an RTP Flag. | |
| switch_socket_t * | switch_rtp_get_rtp_socket (switch_rtp_t *rtp_session) |
| Retrieve the socket from an existing RTP session. | |
| void | switch_rtp_set_default_samples_per_interval (switch_rtp_t *rtp_session, uint16_t samples_per_interval) |
| Set the default samples per interval for a given RTP session. | |
| uint32_t | switch_rtp_get_default_samples_per_interval (switch_rtp_t *rtp_session) |
| Get the default samples per interval for a given RTP session. | |
| void | switch_rtp_set_default_payload (switch_rtp_t *rtp_session, switch_payload_t payload) |
| Set the default payload number for a given RTP session. | |
| uint32_t | switch_rtp_get_default_payload (switch_rtp_t *rtp_session) |
| Get the default payload number for a given RTP session. | |
| void | switch_rtp_set_invald_handler (switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid) |
| Set a callback function to execute when an invalid RTP packet is encountered. | |
| switch_status_t | switch_rtp_read (switch_rtp_t *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) |
| Read data from a given RTP session. | |
| switch_status_t | switch_rtp_queue_rfc2833 (switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf) |
| Queue RFC2833 DTMF data into an RTP Session. | |
| switch_status_t | switch_rtp_queue_rfc2833_in (switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf) |
| Queue RFC2833 DTMF data into an RTP Session. | |
| switch_size_t | switch_rtp_has_dtmf (switch_rtp_t *rtp_session) |
| Test for presence of DTMF on a given RTP session. | |
| switch_size_t | switch_rtp_dequeue_dtmf (switch_rtp_t *rtp_session, switch_dtmf_t *dtmf) |
| Retrieve DTMF digits from a given RTP session. | |
| switch_status_t | switch_rtp_zerocopy_read (switch_rtp_t *rtp_session, void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) |
| Read data from a given RTP session without copying. | |
| switch_status_t | switch_rtp_zerocopy_read_frame (switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags) |
| Read data from a given RTP session without copying. | |
| switch_status_t | switch_rtp_enable_vad (switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags) |
| Enable VAD on an RTP Session. | |
| switch_status_t | switch_rtp_disable_vad (switch_rtp_t *rtp_session) |
| Disable VAD on an RTP Session. | |
| int | switch_rtp_write_frame (switch_rtp_t *rtp_session, switch_frame_t *frame) |
| Write data to a given RTP session. | |
| int | switch_rtp_write_manual (switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags) |
| Write data with a specified payload and sequence number to a given RTP session. | |
| uint32_t | switch_rtp_get_ssrc (switch_rtp_t *rtp_session) |
| Retrieve the SSRC from a given RTP session. | |
| void | switch_rtp_set_private (switch_rtp_t *rtp_session, void *private_data) |
| Associate an arbitrary data pointer with and RTP session. | |
| void | switch_rtp_set_telephony_event (switch_rtp_t *rtp_session, switch_payload_t te) |
| Set the payload type to consider RFC2833 DTMF. | |
| void | switch_rtp_set_cng_pt (switch_rtp_t *rtp_session, switch_payload_t pt) |
| Set the payload type for comfort noise. | |
| void * | switch_rtp_get_private (switch_rtp_t *rtp_session) |
| Retrieve the private data from a given RTP session. | |
| switch_status_t | switch_rtp_activate_stun_ping (switch_rtp_t *rtp_session, const char *stun_ip, switch_port_t stun_port, uint32_t packet_count, switch_bool_t funny) |
|
|
|
|
||||||||||||||||
|
Acvite ICE on an RTP session.
00957 {
00958 char ice_user[80];
00959 char user_ice[80];
00960
00961 switch_snprintf(ice_user, sizeof(ice_user), "%s%s", login, rlogin);
00962 switch_snprintf(user_ice, sizeof(user_ice), "%s%s", rlogin, login);
00963 rtp_session->ice_user = switch_core_strdup(rtp_session->pool, ice_user);
00964 rtp_session->user_ice = switch_core_strdup(rtp_session->pool, user_ice);
00965 rtp_session->default_stuncount = 25;
00966
00967 if (rtp_session->ice_user) {
00968 if (ice_out(rtp_session) != SWITCH_STATUS_SUCCESS) {
00969 return -1;
00970 }
00971 }
00972
00973 return SWITCH_STATUS_SUCCESS;
00974 }
|
Here is the call graph for this function:

|
||||||||||||
|
Acvite a jitter buffer on an RTP session.
00951 {
00952 rtp_session->jb = stfu_n_init(queue_frames);
00953 return SWITCH_STATUS_SUCCESS;
00954 }
|
|
||||||||||||||||||||||||
|
00929 {
00930
00931 if (switch_sockaddr_info_get(&rtp_session->remote_stun_addr, stun_ip, SWITCH_UNSPEC,
00932 stun_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->remote_stun_addr) {
00933
00934 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error resolving stun ping addr\n");
00935 return SWITCH_STATUS_FALSE;
00936 }
00937
00938 if (funny) {
00939 rtp_session->funny_stun++;
00940 }
00941
00942 rtp_session->stun_port = stun_port;
00943
00944 rtp_session->default_stuncount = packet_count;
00945
00946 rtp_session->stun_ip = switch_core_strdup(rtp_session->pool, stun_ip);
00947 return SWITCH_STATUS_SUCCESS;
00948 }
|
Here is the call graph for this function:

|
|
00977 {
00978 int o = 42;
00979 switch_size_t len = sizeof(o);
00980
00981 switch_assert(rtp_session != NULL);
00982 switch_mutex_lock(rtp_session->flag_mutex);
00983 if (rtp_session->sock_input) {
00984 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
00985 switch_socket_sendto(rtp_session->sock_input, rtp_session->local_addr, 0, (void *) &o, &len);
00986 }
00987 switch_mutex_unlock(rtp_session->flag_mutex);
00988 }
|
Here is the call graph for this function:

|
||||||||||||
|
Clear an RTP Flag.
01137 {
01138 switch_clear_flag_locked(rtp_session, flags);
01139 }
|
|
||||||||||||||||||||||||||||||||||||
|
create a new RTP session handle
00762 {
00763 switch_rtp_t *rtp_session = NULL;
00764
00765 *new_rtp_session = NULL;
00766
00767 if (samples_per_interval > SWITCH_RTP_MAX_BUF_LEN) {
00768 *err = "Packet Size Too Large!";
00769 return SWITCH_STATUS_FALSE;
00770 }
00771
00772 if (!(rtp_session = switch_core_alloc(pool, sizeof(*rtp_session)))) {
00773 *err = "Memory Error!";
00774 return SWITCH_STATUS_MEMERR;
00775 }
00776
00777 rtp_session->pool = pool;
00778 rtp_session->te = 101;
00779
00780
00781 switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, pool);
00782 switch_mutex_init(&rtp_session->read_mutex, SWITCH_MUTEX_NESTED, pool);
00783 switch_mutex_init(&rtp_session->write_mutex, SWITCH_MUTEX_NESTED, pool);
00784 switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
00785 switch_queue_create(&rtp_session->dtmf_data.dtmf_queue, 100, rtp_session->pool);
00786 switch_queue_create(&rtp_session->dtmf_data.dtmf_inqueue, 100, rtp_session->pool);
00787
00788 switch_rtp_set_flag(rtp_session, flags);
00789
00790 /* for from address on recvfrom calls */
00791 switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, pool);
00792
00793
00794 rtp_session->seq = (uint16_t) rand();
00795 rtp_session->ssrc = (uint32_t) ((intptr_t) &rtp_session + (uint32_t) switch_timestamp(NULL));
00796 rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc);
00797 rtp_session->send_msg.header.ts = 0;
00798 rtp_session->send_msg.header.m = 0;
00799 rtp_session->send_msg.header.pt = (switch_payload_t) htonl(payload);
00800 rtp_session->send_msg.header.version = 2;
00801 rtp_session->send_msg.header.p = 0;
00802 rtp_session->send_msg.header.x = 0;
00803 rtp_session->send_msg.header.cc = 0;
00804
00805 rtp_session->recv_msg.header.ssrc = 0;
00806 rtp_session->recv_msg.header.ts = 0;
00807 rtp_session->recv_msg.header.seq = 0;
00808 rtp_session->recv_msg.header.m = 0;
00809 rtp_session->recv_msg.header.pt = (switch_payload_t) htonl(payload);
00810 rtp_session->recv_msg.header.version = 2;
00811 rtp_session->recv_msg.header.p = 0;
00812 rtp_session->recv_msg.header.x = 0;
00813 rtp_session->recv_msg.header.cc = 0;
00814
00815 rtp_session->payload = payload;
00816 rtp_session->ms_per_packet = ms_per_packet;
00817 rtp_session->samples_per_interval = rtp_session->conf_samples_per_interval = samples_per_interval;
00818
00819 if (timer_name && !strcasecmp(timer_name, "none")) {
00820 timer_name = NULL;
00821 }
00822
00823 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && switch_strlen_zero(timer_name)) {
00824 timer_name = "soft";
00825 }
00826
00827 if (!switch_strlen_zero(timer_name)) {
00828 rtp_session->timer_name = switch_core_strdup(pool, timer_name);
00829 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
00830 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
00831
00832 if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == SWITCH_STATUS_SUCCESS) {
00833 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
00834 "Starting timer [%s] %d bytes per %dms\n", timer_name, samples_per_interval, ms_per_packet);
00835 } else {
00836 memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
00837 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error starting timer [%s], async RTP disabled\n", timer_name);
00838 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
00839 }
00840 } else {
00841 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
00842 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
00843 }
00844
00845 rtp_session->ready = 1;
00846 *new_rtp_session = rtp_session;
00847
00848 return SWITCH_STATUS_SUCCESS;
00849 }
|
Here is the call graph for this function:

|
||||||||||||
|
Retrieve DTMF digits from a given RTP session.
01590 {
01591 switch_size_t bytes = 0;
01592 switch_dtmf_t *_dtmf = NULL;
01593 void *pop;
01594
01595 if (!switch_rtp_ready(rtp_session)) {
01596 return bytes;
01597 }
01598
01599 switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
01600 if (switch_queue_trypop(rtp_session->dtmf_data.dtmf_inqueue, &pop) == SWITCH_STATUS_SUCCESS) {
01601 _dtmf = (switch_dtmf_t *) pop;
01602 *dtmf = *_dtmf;
01603 bytes++;
01604 }
01605 switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);
01606
01607 return bytes;
01608 }
|
Here is the call graph for this function:

|
|
Destroy an RTP session.
01022 {
01023 void *pop;
01024 switch_socket_t *sock;
01025
01026 if (!rtp_session || !*rtp_session || !(*rtp_session)->ready) {
01027 return;
01028 }
01029
01030 switch_set_flag_locked((*rtp_session), SWITCH_RTP_FLAG_SHUTDOWN);
01031
01032 READ_INC((*rtp_session));
01033 WRITE_INC((*rtp_session));
01034
01035 (*rtp_session)->ready = 0;
01036
01037 READ_DEC((*rtp_session));
01038 WRITE_DEC((*rtp_session));
01039
01040 switch_mutex_lock((*rtp_session)->flag_mutex);
01041
01042 switch_rtp_kill_socket(*rtp_session);
01043
01044 while (switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_inqueue, &pop) == SWITCH_STATUS_SUCCESS) {
01045 switch_safe_free(pop);
01046 }
01047
01048 while (switch_queue_trypop((*rtp_session)->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
01049 switch_safe_free(pop);
01050 }
01051
01052 if ((*rtp_session)->jb) {
01053 stfu_n_destroy(&(*rtp_session)->jb);
01054 }
01055
01056 sock = (*rtp_session)->sock_input;
01057 (*rtp_session)->sock_input = NULL;
01058 switch_socket_close(sock);
01059
01060 if ( (*rtp_session)->sock_output != sock ) {
01061 sock = (*rtp_session)->sock_output;
01062 (*rtp_session)->sock_output = NULL;
01063 switch_socket_close(sock);
01064 }
01065
01066 if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_VAD)) {
01067 switch_rtp_disable_vad(*rtp_session);
01068 }
01069
01070 if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_SEND)) {
01071 srtp_dealloc((*rtp_session)->send_ctx);
01072 (*rtp_session)->send_ctx = NULL;
01073 switch_clear_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_SEND);
01074 }
01075
01076 if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_RECV)) {
01077 srtp_dealloc((*rtp_session)->recv_ctx);
01078 (*rtp_session)->recv_ctx = NULL;
01079 switch_clear_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_RECV);
01080 }
01081
01082 if ((*rtp_session)->timer.timer_interface) {
01083 switch_core_timer_destroy(&(*rtp_session)->timer);
01084 }
01085
01086 switch_rtp_release_port((*rtp_session)->rx_host, (*rtp_session)->rx_port);
01087 switch_mutex_unlock((*rtp_session)->flag_mutex);
01088
01089 return;
01090 }
|
Here is the call graph for this function:

|
|
Disable VAD on an RTP Session.
01984 {
01985
01986 if (!switch_rtp_ready(rtp_session)) {
01987 return SWITCH_STATUS_FALSE;
01988 }
01989
01990 if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD)) {
01991 return SWITCH_STATUS_GENERR;
01992 }
01993 switch_core_codec_destroy(&rtp_session->vad_data.vad_codec);
01994 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD);
01995 return SWITCH_STATUS_SUCCESS;
01996 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Enable VAD on an RTP Session.
02000 {
02001 if (!switch_rtp_ready(rtp_session)) {
02002 return SWITCH_STATUS_FALSE;
02003 }
02004
02005 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD)) {
02006 return SWITCH_STATUS_GENERR;
02007 }
02008 memset(&rtp_session->vad_data, 0, sizeof(rtp_session->vad_data));
02009
02010 if (switch_core_codec_init(&rtp_session->vad_data.vad_codec,
02011 codec->implementation->iananame,
02012 NULL,
02013 codec->implementation->samples_per_second,
02014 codec->implementation->microseconds_per_frame / 1000,
02015 codec->implementation->number_of_channels,
02016 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
02017 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
02018 return SWITCH_STATUS_FALSE;
02019 }
02020 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Activate VAD codec %s %dms\n", codec->implementation->iananame,
02021 codec->implementation->microseconds_per_frame / 1000);
02022 rtp_session->vad_data.diff_level = 400;
02023 rtp_session->vad_data.hangunder = 15;
02024 rtp_session->vad_data.hangover = 40;
02025 rtp_session->vad_data.bg_len = 5;
02026 rtp_session->vad_data.bg_count = 5;
02027 rtp_session->vad_data.bg_level = 300;
02028 rtp_session->vad_data.read_codec = codec;
02029 rtp_session->vad_data.session = session;
02030 rtp_session->vad_data.flags = flags;
02031 rtp_session->vad_data.cng_freq = 50;
02032 rtp_session->vad_data.ts = 1;
02033 rtp_session->vad_data.start = 0;
02034 rtp_session->vad_data.next_scan = switch_timestamp(NULL);
02035 rtp_session->vad_data.scan_freq = 0;
02036 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD);
02037 switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG);
02038 return SWITCH_STATUS_SUCCESS;
02039 }
|
Here is the call graph for this function:

|
|
Get the default payload number for a given RTP session.
01113 {
01114 return rtp_session->payload;
01115 }
|
|
|
Get the default samples per interval for a given RTP session.
01103 {
01104 return rtp_session->samples_per_interval;
01105 }
|
|
|
Retrieve the private data from a given RTP session.
02171 {
02172 return rtp_session->private_data;
02173 }
|
|
||||||||||||
|
00402 {
00403 crypto_get_random(buf, len);
00404 }
|
|
|
00604 {
00605 return switch_strlen_zero(rtp_session->remote_host_str) ? "0.0.0.0" : rtp_session->remote_host_str;
00606 }
|
|
|
00609 {
00610 return rtp_session->remote_port;
00611 }
|
|
|
Retrieve the socket from an existing RTP session.
01093 {
01094 return rtp_session->sock_input;
01095 }
|
|
|
Retrieve the SSRC from a given RTP session.
|
|
|
Test for presence of DTMF on a given RTP session.
01577 {
01578 switch_size_t has = 0;
01579
01580 if (switch_rtp_ready(rtp_session)) {
01581 switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
01582 has = switch_queue_size(rtp_session->dtmf_data.dtmf_inqueue);
01583 switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);
01584 }
01585
01586 return has;
01587 }
|
Here is the call graph for this function:

|
|
Initilize the RTP System.
00391 {
00392 if (global_init) {
00393 return;
00394 }
00395 switch_core_hash_init(&alloc_hash, pool);
00396 srtp_init();
00397 switch_mutex_init(&port_lock, SWITCH_MUTEX_NESTED, pool);
00398 global_init = 1;
00399 }
|
Here is the call graph for this function:

|
|
Kill the socket on an existing RTP session.
00991 {
00992 switch_assert(rtp_session != NULL);
00993 switch_mutex_lock(rtp_session->flag_mutex);
00994 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
00995 switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO);
00996 if (rtp_session->sock_input) {
00997 switch_socket_shutdown(rtp_session->sock_input, SWITCH_SHUTDOWN_READWRITE);
00998 }
00999 if (rtp_session->sock_output && rtp_session->sock_output != rtp_session->sock_input) {
01000 switch_socket_shutdown(rtp_session->sock_output, SWITCH_SHUTDOWN_READWRITE);
01001 }
01002 }
01003 switch_mutex_unlock(rtp_session->flag_mutex);
01004 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||||||||||
|
prepare a new RTP session handle and fully initilize it
00859 {
00860 switch_rtp_t *rtp_session = NULL;
00861
00862 if (switch_strlen_zero(rx_host)) {
00863 *err = "Missing local host";
00864 goto end;
00865 }
00866
00867 if (!rx_port) {
00868 *err = "Missing local port";
00869 goto end;
00870 }
00871
00872 if (switch_strlen_zero(tx_host)) {
00873 *err = "Missing remote host";
00874 goto end;
00875 }
00876
00877 if (!tx_port) {
00878 *err = "Missing remote port";
00879 goto end;
00880 }
00881
00882 if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
00883 goto end;
00884 }
00885
00886 switch_mutex_lock(rtp_session->flag_mutex);
00887
00888 if (switch_rtp_set_local_address(rtp_session, rx_host, rx_port, err) != SWITCH_STATUS_SUCCESS) {
00889 switch_mutex_unlock(rtp_session->flag_mutex);
00890 rtp_session = NULL;
00891 goto end;
00892 }
00893
00894 if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
00895 switch_mutex_unlock(rtp_session->flag_mutex);
00896 rtp_session = NULL;
00897 goto end;
00898 }
00899
00900 end:
00901
00902 if (rtp_session) {
00903 switch_mutex_unlock(rtp_session->flag_mutex);
00904 rtp_session->ready = 2;
00905 rtp_session->rx_host = switch_core_strdup(rtp_session->pool, rx_host);
00906 rtp_session->rx_port = rx_port;
00907 } else {
00908 switch_rtp_release_port(rx_host, rx_port);
00909 }
00910
00911 return rtp_session;
00912 }
|
Here is the call graph for this function:

|
||||||||||||
|
Queue RFC2833 DTMF data into an RTP Session.
01611 {
01612
01613 switch_dtmf_t *rdigit;
01614
01615 if (!switch_rtp_ready(rtp_session)) {
01616 return SWITCH_STATUS_FALSE;
01617 }
01618
01619 if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
01620 *rdigit = *dtmf;
01621 if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
01622 rdigit->duration = switch_core_default_dtmf_duration(0);
01623 }
01624
01625 if ((switch_queue_trypush(rtp_session->dtmf_data.dtmf_queue, rdigit)) != SWITCH_STATUS_SUCCESS) {
01626 free(rdigit);
01627 return SWITCH_STATUS_FALSE;
01628 }
01629 } else {
01630 abort();
01631 }
01632
01633 return SWITCH_STATUS_SUCCESS;
01634 }
|
Here is the call graph for this function:

|
||||||||||||
|
Queue RFC2833 DTMF data into an RTP Session.
01637 {
01638 switch_dtmf_t *rdigit;
01639
01640 if (!switch_rtp_ready(rtp_session)) {
01641 return SWITCH_STATUS_FALSE;
01642 }
01643
01644 if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
01645 *rdigit = *dtmf;
01646 if (rdigit->duration < switch_core_default_dtmf_duration(0)) {
01647 rdigit->duration = switch_core_default_dtmf_duration(0);
01648 }
01649
01650 if ((switch_queue_trypush(rtp_session->dtmf_data.dtmf_inqueue, rdigit)) != SWITCH_STATUS_SUCCESS) {
01651 free(rdigit);
01652 return SWITCH_STATUS_FALSE;
01653 }
01654 } else {
01655 abort();
01656 }
01657
01658 return SWITCH_STATUS_SUCCESS;
01659 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Read data from a given RTP session.
01663 {
01664 int bytes = 0;
01665
01666 if (!switch_rtp_ready(rtp_session)) {
01667 return SWITCH_STATUS_FALSE;
01668 }
01669
01670 bytes = rtp_common_read(rtp_session, payload_type, flags, io_flags);
01671
01672 if (bytes < 0) {
01673 *datalen = 0;
01674 return bytes == -2 ? SWITCH_STATUS_TIMEOUT : SWITCH_STATUS_GENERR;
01675 } else if (bytes == 0) {
01676 *datalen = 0;
01677 return SWITCH_STATUS_BREAK;
01678 } else {
01679 bytes -= rtp_header_len;
01680 }
01681
01682 *datalen = bytes;
01683
01684 memcpy(data, rtp_session->recv_msg.body, bytes);
01685
01686 return SWITCH_STATUS_SUCCESS;
01687 }
|
Here is the call graph for this function:

|
|
Test if an RTP session is ready.
01007 {
01008 uint8_t ret;
01009
01010 if (!rtp_session || !rtp_session->flag_mutex || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SHUTDOWN)) {
01011 return 0;
01012 }
01013
01014 switch_mutex_lock(rtp_session->flag_mutex);
01015 ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input && rtp_session->sock_output && rtp_session->remote_addr && rtp_session->ready == 2) ? 1 : 0;
01016 switch_mutex_unlock(rtp_session->flag_mutex);
01017
01018 return ret;
01019 }
|
Here is the call graph for this function:

|
||||||||||||
|
00450 {
00451 switch_core_port_allocator_t *alloc = NULL;
00452
00453 if (!ip) {
00454 return;
00455 }
00456
00457 switch_mutex_lock(port_lock);
00458 if ((alloc = switch_core_hash_find(alloc_hash, ip))) {
00459 switch_core_port_allocator_free_port(alloc, port);
00460 }
00461 switch_mutex_unlock(port_lock);
00462
00463 }
|
Here is the call graph for this function:

|
|
Request a new port to be used for media.
00466 {
00467 switch_port_t port = 0;
00468 switch_core_port_allocator_t *alloc = NULL;
00469
00470 switch_mutex_lock(port_lo |