busybox 1.19.4 update patch
[openwrt.git] / package / pjsip / patches / 0003-adds-PJ_DEF-pj_status_t-pjsua_add_snd_port-int-id.patch
1 From 1e0d5dbf8b7714dfd490add0e2b507fd513414f3 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 3 Feb 2012 21:45:08 +0100
4 Subject: [PATCH 3/3] adds PJ_DEF(pj_status_t) pjsua_add_snd_port(int id)
5
6 ---
7 pjproject-1.12/pjsip/include/pjsua-lib/pjsua.h | 2 +
8 .../pjsip/include/pjsua-lib/pjsua_internal.h | 4 +-
9 pjproject-1.12/pjsip/src/pjsua-lib/pjsua_media.c | 69 ++++++++++++++------
10 3 files changed, 54 insertions(+), 21 deletions(-)
11
12 diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
13 index 85dbbbb..ad3e020 100644
14 --- a/pjsip/include/pjsua-lib/pjsua.h
15 +++ b/pjsip/include/pjsua-lib/pjsua.h
16 @@ -1543,6 +1543,8 @@ PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
17 PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
18
19
20 +PJ_DECL(pj_status_t) pjsua_add_snd_port(int id, pjsua_conf_port_id *p_id);
21 +
22
23 /*****************************************************************************
24 * Utilities.
25 diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
26 index 6c27826..4ba91ed 100644
27 --- a/pjsip/include/pjsua-lib/pjsua_internal.h
28 +++ b/pjsip/include/pjsua-lib/pjsua_internal.h
29 @@ -261,6 +261,8 @@ typedef struct pjsua_stun_resolve
30 } pjsua_stun_resolve;
31
32
33 +#define MAX_PORT 2
34 +
35 /**
36 * Global pjsua application data.
37 */
38 @@ -336,7 +338,7 @@ struct pjsua_data
39 pj_bool_t aud_open_cnt;/**< How many # device is opened */
40 pj_bool_t no_snd; /**< No sound (app will manage it) */
41 pj_pool_t *snd_pool; /**< Sound's private pool. */
42 - pjmedia_snd_port *snd_port; /**< Sound port. */
43 + pjmedia_snd_port *snd_port[MAX_PORT]; /**< Sound port. */
44 pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */
45 pjmedia_master_port *null_snd; /**< Master port for null sound. */
46 pjmedia_port *null_port; /**< Null port. */
47 diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
48 index 7d53cad..8a882f3 100644
49 --- a/pjsip/src/pjsua-lib/pjsua_media.c
50 +++ b/pjsip/src/pjsua-lib/pjsua_media.c
51 @@ -588,7 +588,7 @@ static void check_snd_dev_idle()
52 * It is idle when there is no port connection in the bridge and
53 * there is no active call.
54 */
55 - if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL) &&
56 + if ((pjsua_var.snd_port[0]!=NULL || pjsua_var.null_snd!=NULL) &&
57 pjsua_var.snd_idle_timer.id == PJ_FALSE &&
58 pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 &&
59 call_cnt == 0 &&
60 @@ -2009,7 +2009,7 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
61 pj_assert(status == PJ_SUCCESS);
62
63 /* Check if sound device is instantiated. */
64 - need_reopen = (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&
65 + need_reopen = (pjsua_var.snd_port[0]==NULL && pjsua_var.null_snd==NULL &&
66 !pjsua_var.no_snd);
67
68 /* Check if sound device need to reopen because it needs to modify
69 @@ -2067,7 +2067,7 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
70 /* The bridge version */
71
72 /* Create sound port if none is instantiated */
73 - if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&
74 + if (pjsua_var.snd_port[0]==NULL && pjsua_var.null_snd==NULL &&
75 !pjsua_var.no_snd)
76 {
77 pj_status_t status;
78 @@ -2679,9 +2679,9 @@ static pj_status_t update_initial_aud_param()
79 pjmedia_aud_param param;
80 pj_status_t status;
81
82 - PJ_ASSERT_RETURN(pjsua_var.snd_port != NULL, PJ_EBUG);
83 + PJ_ASSERT_RETURN(pjsua_var.snd_port[0] != NULL, PJ_EBUG);
84
85 - strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
86 + strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
87
88 status = pjmedia_aud_stream_get_param(strm, &param);
89 if (status != PJ_SUCCESS) {
90 @@ -2747,7 +2747,7 @@ static pj_status_t open_snd_dev(pjmedia_snd_port_param *param)
91 1000 / param->base.clock_rate));
92
93 status = pjmedia_snd_port_create2( pjsua_var.snd_pool,
94 - param, &pjsua_var.snd_port);
95 + param, &pjsua_var.snd_port[0]);
96 if (status != PJ_SUCCESS)
97 return status;
98
99 @@ -2805,13 +2805,13 @@ static pj_status_t open_snd_dev(pjmedia_snd_port_param *param)
100 }
101
102 /* Connect sound port to the bridge */
103 - status = pjmedia_snd_port_connect(pjsua_var.snd_port,
104 + status = pjmedia_snd_port_connect(pjsua_var.snd_port[0],
105 conf_port );
106 if (status != PJ_SUCCESS) {
107 pjsua_perror(THIS_FILE, "Unable to connect conference port to "
108 "sound device", status);
109 - pjmedia_snd_port_destroy(pjsua_var.snd_port);
110 - pjsua_var.snd_port = NULL;
111 + pjmedia_snd_port_destroy(pjsua_var.snd_port[0]);
112 + pjsua_var.snd_port[0] = NULL;
113 return status;
114 }
115
116 @@ -2826,7 +2826,7 @@ static pj_status_t open_snd_dev(pjmedia_snd_port_param *param)
117 pjmedia_aud_param si;
118 pj_str_t tmp;
119
120 - strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
121 + strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
122 status = pjmedia_aud_stream_get_param(strm, &si);
123 if (status == PJ_SUCCESS)
124 status = pjmedia_aud_dev_get_info(si.rec_id, &rec_info);
125 @@ -2869,12 +2869,12 @@ static pj_status_t open_snd_dev(pjmedia_snd_port_param *param)
126 static void close_snd_dev(void)
127 {
128 /* Close sound device */
129 - if (pjsua_var.snd_port) {
130 + if (pjsua_var.snd_port[0]) {
131 pjmedia_aud_dev_info cap_info, play_info;
132 pjmedia_aud_stream *strm;
133 pjmedia_aud_param param;
134
135 - strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
136 + strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
137 pjmedia_aud_stream_get_param(strm, &param);
138
139 if (pjmedia_aud_dev_get_info(param.rec_id, &cap_info) != PJ_SUCCESS)
140 @@ -2886,9 +2886,9 @@ static void close_snd_dev(void)
141 "%s sound capture device",
142 play_info.name, cap_info.name));
143
144 - pjmedia_snd_port_disconnect(pjsua_var.snd_port);
145 - pjmedia_snd_port_destroy(pjsua_var.snd_port);
146 - pjsua_var.snd_port = NULL;
147 + pjmedia_snd_port_disconnect(pjsua_var.snd_port[0]);
148 + pjmedia_snd_port_destroy(pjsua_var.snd_port[0]);
149 + pjsua_var.snd_port[0] = NULL;
150 }
151
152 /* Close null sound device */
153 @@ -2968,6 +2968,35 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
154 return PJ_SUCCESS;
155 }
156
157 +PJ_DEF(pj_status_t) pjsua_add_snd_port(int id, pjsua_conf_port_id *p_id)
158 +{
159 + unsigned alt_cr_cnt = 1;
160 + unsigned alt_cr = 0;
161 + pj_status_t status = -1;
162 + pjmedia_snd_port_param param;
163 + unsigned samples_per_frame;
164 + pjmedia_port *port;
165 + const pj_str_t name = pj_str("tapi2");
166 + alt_cr = pjsua_var.media_cfg.clock_rate;
167 + samples_per_frame = alt_cr *
168 + pjsua_var.media_cfg.audio_frame_ptime *
169 + pjsua_var.media_cfg.channel_count / 1000;
170 + status = create_aud_param(&param.base,
171 + pjsua_var.play_dev,
172 + pjsua_var.cap_dev,
173 + alt_cr,
174 + pjsua_var.media_cfg.channel_count,
175 + samples_per_frame, 16);
176 + if (status != PJ_SUCCESS)
177 + return status;
178 + param.base.rec_id = id;
179 + param.base.play_id = id;
180 + param.options = 0;
181 + status = pjmedia_snd_port_create2(pjsua_var.snd_pool,
182 + &param, &pjsua_var.snd_port[id]);
183 + return PJ_SUCCESS;
184 +}
185 +
186
187 /*
188 * Get currently active sound devices. If sound devices has not been created
189 @@ -3054,8 +3083,8 @@ PJ_DEF(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options)
190 {
191 pjsua_var.media_cfg.ec_tail_len = tail_ms;
192
193 - if (pjsua_var.snd_port)
194 - return pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var.pool,
195 + if (pjsua_var.snd_port[0])
196 + return pjmedia_snd_port_set_ec( pjsua_var.snd_port[0], pjsua_var.pool,
197 tail_ms, options);
198
199 return PJ_SUCCESS;
200 @@ -3077,7 +3106,7 @@ PJ_DEF(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms)
201 */
202 PJ_DEF(pj_bool_t) pjsua_snd_is_active(void)
203 {
204 - return pjsua_var.snd_port != NULL;
205 + return pjsua_var.snd_port[0] != NULL;
206 }
207
208
209 @@ -3099,7 +3128,7 @@ PJ_DEF(pj_status_t) pjsua_snd_set_setting( pjmedia_aud_dev_cap cap,
210 if (pjsua_snd_is_active()) {
211 pjmedia_aud_stream *strm;
212
213 - strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
214 + strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
215 status = pjmedia_aud_stream_set_cap(strm, cap, pval);
216 } else {
217 status = PJ_SUCCESS;
218 @@ -3137,7 +3166,7 @@ PJ_DEF(pj_status_t) pjsua_snd_get_setting( pjmedia_aud_dev_cap cap,
219 /* Sound is active, retrieve from device directly */
220 pjmedia_aud_stream *strm;
221
222 - strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
223 + strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
224 return pjmedia_aud_stream_get_cap(strm, cap, pval);
225 } else {
226 /* Otherwise retrieve from internal param */
227 --
228 1.7.7.1
229
This page took 0.053311 seconds and 5 git commands to generate.