Revision b8237291 utils.c

View differences:

utils.c
201 201
int janus_get_opus_pt(const char *sdp) {
202 202
	if(!sdp)
203 203
		return -1;
204
	if(!strstr(sdp, "m=audio") || !strstr(sdp, "opus/48000"))	/* FIXME Should be case insensitive */
205
		return -1;
204
	if(!strstr(sdp, "m=audio") || (!strstr(sdp, "opus/48000") && !strstr(sdp, "OPUS/48000")))
205
		return -2;
206 206
	const char *line = strstr(sdp, "m=audio");
207 207
	while(line) {
208 208
		char *next = strchr(line, '\n');
209 209
		if(next) {
210 210
			*next = '\0';
211
			JANUS_LOG(LOG_WARN, "%s\n", line);
211 212
			if(strstr(line, "a=rtpmap") && strstr(line, "opus/48000")) {
212 213
				/* Gotcha! */
214
				JANUS_LOG(LOG_WARN, "opus/48000!\n");
213 215
				int pt = 0;
214 216
				if(sscanf(line, "a=rtpmap:%d opus/48000/2", &pt) == 1) {
215 217
					*next = '\n';
216 218
					return pt;
217 219
				}
220
			} else if(strstr(line, "a=rtpmap") && strstr(line, "OPUS/48000")) {
221
				/* Gotcha! */
222
				JANUS_LOG(LOG_WARN, "OPUS/48000!\n");
223
				int pt = 0;
224
				if(sscanf(line, "a=rtpmap:%d OPUS/48000/2", &pt) == 1) {
225
					*next = '\n';
226
					return pt;
227
				}
218 228
			}
219 229
			*next = '\n';
220 230
		}
221 231
		line = next ? (next+1) : NULL;
222 232
	}
223
	return -1;
233
	return -3;
224 234
}
225 235

  
226 236
int janus_get_vp8_pt(const char *sdp) {
227 237
	if(!sdp)
228 238
		return -1;
229
	if(!strstr(sdp, "m=video") || !strstr(sdp, "VP8/90000"))	/* FIXME Should be case insensitive */
230
		return -1;
239
	if(!strstr(sdp, "m=video") || (!strstr(sdp, "VP8/90000") && !strstr(sdp, "vp8/90000")))
240
		return -2;
231 241
	const char *line = strstr(sdp, "m=video");
232 242
	while(line) {
233 243
		char *next = strchr(line, '\n');
......
240 250
					*next = '\n';
241 251
					return pt;
242 252
				}
253
			} else if(strstr(line, "a=rtpmap") && strstr(line, "vp8/90000")) {
254
				/* Gotcha! */
255
				int pt = 0;
256
				if(sscanf(line, "a=rtpmap:%d vp8/90000", &pt) == 1) {
257
					*next = '\n';
258
					return pt;
259
				}
243 260
			}
244 261
			*next = '\n';
245 262
		}
246 263
		line = next ? (next+1) : NULL;
247 264
	}
248
	return -1;
265
	return -3;
249 266
}
250 267

  
251 268
gboolean janus_is_ip_valid(const char *ip, int *family) {

Also available in: Unified diff