Changeset 1403 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
- Timestamp:
- Jul 17, 2007 4:25:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1393 r1403 1106 1106 */ 1107 1107 1108 static char* get_basename(const char *path, unsigned len) 1109 { 1110 char *p = ((char*)path) + len; 1111 1112 if (len==0) 1113 return p; 1114 1115 for (--p; p!=path && *p!='/' && *p!='\\'; --p); 1116 1117 return (p==path) ? p : p+1; 1118 } 1119 1120 1108 1121 /* 1109 1122 * Create a file player, and automatically connect this player to … … 1116 1129 unsigned slot, file_id; 1117 1130 char path[PJ_MAXPATH]; 1131 pj_pool_t *pool; 1118 1132 pjmedia_port *port; 1119 1133 pj_status_t status; … … 1138 1152 pj_memcpy(path, filename->ptr, filename->slen); 1139 1153 path[filename->slen] = '\0'; 1140 status = pjmedia_wav_player_port_create(pjsua_var.pool, path, 1154 1155 pool = pjsua_pool_create(get_basename(path, filename->slen), 1000, 1000); 1156 if (!pool) { 1157 PJSUA_UNLOCK(); 1158 return PJ_ENOMEM; 1159 } 1160 1161 status = pjmedia_wav_player_port_create(pool, path, 1141 1162 pjsua_var.mconf_cfg.samples_per_frame * 1142 1163 1000 / pjsua_var.media_cfg.clock_rate, … … 1145 1166 PJSUA_UNLOCK(); 1146 1167 pjsua_perror(THIS_FILE, "Unable to open file for playback", status); 1168 pj_pool_release(pool); 1147 1169 return status; 1148 1170 } … … 1155 1177 pjsua_perror(THIS_FILE, "Unable to add file to conference bridge", 1156 1178 status); 1179 pj_pool_release(pool); 1157 1180 return status; 1158 1181 } 1159 1182 1160 1183 pjsua_var.player[file_id].type = 0; 1184 pjsua_var.player[file_id].pool = pool; 1161 1185 pjsua_var.player[file_id].port = port; 1162 1186 pjsua_var.player[file_id].slot = slot; … … 1182 1206 { 1183 1207 unsigned slot, file_id, ptime; 1208 pj_pool_t *pool; 1184 1209 pjmedia_port *port; 1185 1210 pj_status_t status; … … 1206 1231 pjsua_var.media_cfg.clock_rate; 1207 1232 1208 status = pjmedia_wav_playlist_create(pjsua_var.pool, label, 1233 pool = pjsua_pool_create("playlist", 1000, 1000); 1234 if (!pool) { 1235 PJSUA_UNLOCK(); 1236 return PJ_ENOMEM; 1237 } 1238 1239 status = pjmedia_wav_playlist_create(pool, label, 1209 1240 file_names, file_count, 1210 1241 ptime, options, 0, &port); … … 1212 1243 PJSUA_UNLOCK(); 1213 1244 pjsua_perror(THIS_FILE, "Unable to create playlist", status); 1214 return status; 1215 } 1216 1217 status = pjmedia_conf_add_port(pjsua_var.mconf, pjsua_var.pool, 1245 pj_pool_release(pool); 1246 return status; 1247 } 1248 1249 status = pjmedia_conf_add_port(pjsua_var.mconf, pool, 1218 1250 port, &port->info.name, &slot); 1219 1251 if (status != PJ_SUCCESS) { … … 1221 1253 PJSUA_UNLOCK(); 1222 1254 pjsua_perror(THIS_FILE, "Unable to add port", status); 1255 pj_pool_release(pool); 1223 1256 return status; 1224 1257 } 1225 1258 1226 1259 pjsua_var.player[file_id].type = 1; 1260 pjsua_var.player[file_id].pool = pool; 1227 1261 pjsua_var.player[file_id].port = port; 1228 1262 pjsua_var.player[file_id].slot = slot; … … 1295 1329 pjsua_var.player[id].port = NULL; 1296 1330 pjsua_var.player[id].slot = 0xFFFF; 1331 pj_pool_release(pjsua_var.player[id].pool); 1332 pjsua_var.player[id].pool = NULL; 1297 1333 pjsua_var.player_cnt--; 1298 1334 } … … 1329 1365 pj_str_t ext; 1330 1366 int file_format; 1367 pj_pool_t *pool; 1331 1368 pjmedia_port *port; 1332 1369 pj_status_t status; … … 1376 1413 path[filename->slen] = '\0'; 1377 1414 1415 pool = pjsua_pool_create(get_basename(path, filename->slen), 1000, 1000); 1416 if (!pool) { 1417 PJSUA_UNLOCK(); 1418 return PJ_ENOMEM; 1419 } 1420 1378 1421 if (file_format == FMT_WAV) { 1379 status = pjmedia_wav_writer_port_create(p jsua_var.pool, path,1422 status = pjmedia_wav_writer_port_create(pool, path, 1380 1423 pjsua_var.media_cfg.clock_rate, 1381 1424 pjsua_var.mconf_cfg.channel_count, … … 1392 1435 PJSUA_UNLOCK(); 1393 1436 pjsua_perror(THIS_FILE, "Unable to open file for recording", status); 1394 return status; 1395 } 1396 1397 status = pjmedia_conf_add_port(pjsua_var.mconf, pjsua_var.pool, 1437 pj_pool_release(pool); 1438 return status; 1439 } 1440 1441 status = pjmedia_conf_add_port(pjsua_var.mconf, pool, 1398 1442 port, filename, &slot); 1399 1443 if (status != PJ_SUCCESS) { 1400 1444 pjmedia_port_destroy(port); 1401 1445 PJSUA_UNLOCK(); 1446 pj_pool_release(pool); 1402 1447 return status; 1403 1448 } … … 1405 1450 pjsua_var.recorder[file_id].port = port; 1406 1451 pjsua_var.recorder[file_id].slot = slot; 1452 pjsua_var.recorder[file_id].pool = pool; 1407 1453 1408 1454 if (p_id) *p_id = file_id; … … 1459 1505 pjsua_var.recorder[id].port = NULL; 1460 1506 pjsua_var.recorder[id].slot = 0xFFFF; 1507 pj_pool_release(pjsua_var.recorder[id].pool); 1508 pjsua_var.recorder[id].pool = NULL; 1461 1509 pjsua_var.rec_cnt--; 1462 1510 }
Note: See TracChangeset
for help on using the changeset viewer.