Changeset 4793 for pjproject/trunk/pjsip/src/pjsua2/media.cpp
- Timestamp:
- Mar 14, 2014 4:09:50 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r4776 r4793 263 263 &playerId) ); 264 264 265 /* Register EOF callback */ 266 pjmedia_port *port; 267 pj_status_t status; 268 269 status = pjsua_player_get_port(playerId, &port); 270 if (status != PJ_SUCCESS) { 271 pjsua_player_destroy(playerId); 272 PJSUA2_RAISE_ERROR2(status, "AudioMediaPlayer::createPlayer()"); 273 } 274 status = pjmedia_wav_player_set_eof_cb(port, this, &eof_cb); 275 if (status != PJ_SUCCESS) { 276 pjsua_player_destroy(playerId); 277 PJSUA2_RAISE_ERROR2(status, "AudioMediaPlayer::createPlayer()"); 278 } 279 265 280 /* Get media port id. */ 266 281 id = pjsua_player_get_conf_port(playerId); … … 281 296 unsigned i, count = 0; 282 297 pj_str_t pj_lbl = str2Pj(label); 298 pj_status_t status; 283 299 284 300 count = PJ_ARRAY_SIZE(pj_files); … … 297 313 &playerId) ); 298 314 315 /* Register EOF callback */ 316 pjmedia_port *port; 317 status = pjsua_player_get_port(playerId, &port); 318 if (status != PJ_SUCCESS) { 319 pjsua_player_destroy(playerId); 320 PJSUA2_RAISE_ERROR2(status, "AudioMediaPlayer::createPlaylist()"); 321 } 322 status = pjmedia_wav_playlist_set_eof_cb(port, this, &eof_cb); 323 if (status != PJ_SUCCESS) { 324 pjsua_player_destroy(playerId); 325 PJSUA2_RAISE_ERROR2(status, "AudioMediaPlayer::createPlaylist()"); 326 } 327 299 328 /* Get media port id. */ 300 329 id = pjsua_player_get_conf_port(playerId); … … 303 332 } 304 333 334 AudioMediaPlayerInfo AudioMediaPlayer::getInfo() const throw(Error) 335 { 336 AudioMediaPlayerInfo info; 337 pjmedia_wav_player_info pj_info; 338 339 PJSUA2_CHECK_EXPR( pjsua_player_get_info(playerId, &pj_info) ); 340 341 pj_bzero(&info, sizeof(info)); 342 info.formatId = pj_info.fmt_id; 343 info.payloadBitsPerSample = pj_info.payload_bits_per_sample; 344 info.sizeBytes = pj_info.size_bytes; 345 info.sizeSamples = pj_info.size_samples; 346 347 return info; 348 } 349 350 pj_uint32_t AudioMediaPlayer::getPos() const throw(Error) 351 { 352 pj_ssize_t pos = pjsua_player_get_pos(playerId); 353 if (pos < 0) { 354 PJSUA2_RAISE_ERROR2(-pos, "AudioMediaPlayer::getPos()"); 355 } 356 return (pj_uint32_t)pos; 357 } 358 305 359 void AudioMediaPlayer::setPos(pj_uint32_t samples) throw(Error) 306 360 { … … 312 366 { 313 367 return static_cast<AudioMediaPlayer*>(media); 368 } 369 370 pj_status_t AudioMediaPlayer::eof_cb(pjmedia_port *port, 371 void *usr_data) 372 { 373 AudioMediaPlayer *player = (AudioMediaPlayer*)usr_data; 374 return player->onEof() ? PJ_SUCCESS : PJ_EEOF; 314 375 } 315 376
Note: See TracChangeset
for help on using the changeset viewer.