| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <pjsua-lib/pjsua.h> |
| 19 |
#include <pjsua-lib/pjsua_internal.h> |
| 20 |
|
| 21 |
#if defined(PJSUA_MEDIA_HAS_PJMEDIA) && PJSUA_MEDIA_HAS_PJMEDIA != 0 |
| 22 |
# error The PJSUA_MEDIA_HAS_PJMEDIA should be declared as zero |
| 23 |
#endif |
| 24 |
|
| 25 |
|
| 26 |
#define THIS_FILE "alt_pjsua_txt.c" |
| 27 |
#define UNIMPLEMENTED(func) PJ_LOG(2,(THIS_FILE, "*** Call to unimplemented function %s ***", #func)); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
static void txt_rtp_cb(void *user_data, void *pkt, pj_ssize_t size) |
| 35 |
{ |
| 36 |
pjsua_call_media *call_med = (pjsua_call_media*) user_data; |
| 37 |
|
| 38 |
|
| 39 |
PJ_LOG(4,(THIS_FILE, "RX %d bytes text RTP packet", (int)size)); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
static void txt_rtcp_cb(void *user_data, void *pkt, pj_ssize_t size) |
| 44 |
{ |
| 45 |
pjsua_call_media *call_med = (pjsua_call_media*) user_data; |
| 46 |
|
| 47 |
|
| 48 |
PJ_LOG(4,(THIS_FILE, "RX %d bytes text RTCP packet", (int)size)); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
static void timer_to_send_txt_rtp(void *user_data) |
| 55 |
{ |
| 56 |
pjsua_call_media *call_med = (pjsua_call_media*) user_data; |
| 57 |
const char *pkt = "Not RTP packet"; |
| 58 |
|
| 59 |
if (!call_med->call || !call_med->call->inv || !call_med->tp) { |
| 60 |
|
| 61 |
|
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
pjmedia_transport_send_rtp(call_med->tp, pkt, strlen(pkt)); |
| 66 |
|
| 67 |
pjsua_schedule_timer2(&timer_to_send_txt_rtp, call_med, 2000); |
| 68 |
} |
| 69 |
|
| 70 |
static void timer_to_send_txt_rtcp(void *user_data) |
| 71 |
{ |
| 72 |
pjsua_call_media *call_med = (pjsua_call_media*) user_data; |
| 73 |
const char *pkt = "Not RTCP packet"; |
| 74 |
|
| 75 |
if (!call_med->call || !call_med->call->inv || !call_med->tp) { |
| 76 |
|
| 77 |
|
| 78 |
return; |
| 79 |
} |
| 80 |
|
| 81 |
pjmedia_transport_send_rtcp(call_med->tp, pkt, strlen(pkt)); |
| 82 |
|
| 83 |
pjsua_schedule_timer2(&timer_to_send_txt_rtcp, call_med, 5000); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
void pjsua_txt_stop_stream(pjsua_call_media *call_med) |
| 88 |
{ |
| 89 |
|
| 90 |
if (call_med->tp) { |
| 91 |
pjmedia_transport_detach(call_med->tp, call_med); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
pj_status_t pjsua_txt_channel_update(pjsua_call_media *call_med, |
| 103 |
pj_pool_t *tmp_pool, |
| 104 |
pjmedia_txt_stream_info *si, |
| 105 |
const pjmedia_sdp_session *local_sdp, |
| 106 |
const pjmedia_sdp_session *remote_sdp) |
| 107 |
{ |
| 108 |
pj_status_t status = PJ_SUCCESS; |
| 109 |
|
| 110 |
PJ_LOG(4,(THIS_FILE,"Alt text channel update..")); |
| 111 |
pj_log_push_indent(); |
| 112 |
|
| 113 |
|
| 114 |
if (si->dir != PJMEDIA_DIR_NONE) { |
| 115 |
|
| 116 |
status = pjmedia_transport_attach(call_med->tp, call_med, |
| 117 |
&si->rem_addr, &si->rem_rtcp, |
| 118 |
pj_sockaddr_get_len(&si->rem_addr), |
| 119 |
&txt_rtp_cb, &txt_rtcp_cb); |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
pjsua_schedule_timer2(&timer_to_send_txt_rtp, call_med, 0); |
| 125 |
pjsua_schedule_timer2(&timer_to_send_txt_rtcp, call_med, 2500); |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
on_return: |
| 134 |
pj_log_pop_indent(); |
| 135 |
return status; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
PJ_DEF(pj_status_t) |
| 145 |
pjsua_call_send_text(pjsua_call_id call_id, |
| 146 |
const pjsua_call_send_text_param *param) |
| 147 |
{ |
| 148 |
UNIMPLEMENTED(pjsua_call_send_text) |
| 149 |
return PJ_ENOTSUP; |
| 150 |
} |