static int update_media(struct call *call) { const struct sdp_format *sc; struct le *le; int err = 0; /* media attributes */ audio_sdp_attr_decode(call->audio); #ifdef USE_VIDEO if (call->video) video_sdp_attr_decode(call->video); #endif /* Update each stream */ FOREACH_STREAM { stream_update(le->data); } if (call->acc->mnat && call->acc->mnat->updateh && call->mnats) err = call->acc->mnat->updateh(call->mnats); sc = sdp_media_rformat(stream_sdpmedia(audio_strm(call->audio)), NULL); if (sc) { struct aucodec *ac = sc->data; if (ac) { err = audio_decoder_set(call->audio, sc->data, sc->pt, sc->params); err |= audio_encoder_set(call->audio, sc->data, sc->pt, sc->params); } else { info("no common audio-codecs..\n"); } } else { info("audio stream is disabled..\n"); } #ifdef USE_VIDEO sc = sdp_media_rformat(stream_sdpmedia(video_strm(call->video)), NULL); if (sc) { err = video_encoder_set(call->video, sc->data, sc->pt, sc->params); if (err) { warning("call: video stream error: %m\n", err); } } else if (call->video) { info("video stream is disabled..\n"); } #endif return err; }
/** * Use the next audio encoder in the local list of negotiated codecs * * @param audio Audio object */ void audio_encoder_cycle(struct audio *audio) { const struct sdp_format *rc = NULL; if (!audio) return; rc = sdp_media_format_cycle(stream_sdpmedia(audio_strm(audio))); if (!rc) { info("audio: encoder cycle: no remote codec found\n"); return; } (void)audio_encoder_set(audio, rc->data, rc->pt, rc->params); }
static void call_stream_start(struct call *call, bool active) { const struct sdp_format *sc; int err; /* Audio Stream */ sc = sdp_media_rformat(stream_sdpmedia(audio_strm(call->audio)), NULL); if (sc) { struct aucodec *ac = sc->data; if (ac) { err = audio_encoder_set(call->audio, sc->data, sc->pt, sc->params); err |= audio_decoder_set(call->audio, sc->data, sc->pt, sc->params); if (!err) { err = audio_start(call->audio); } if (err) { warning("call: audio stream error: %m\n", err); } } else { info("call: no common audio-codecs..\n"); } } else { info("call: audio stream is disabled..\n"); } #ifdef USE_VIDEO /* Video Stream */ sc = sdp_media_rformat(stream_sdpmedia(video_strm(call->video)), NULL); if (sc) { err = video_encoder_set(call->video, sc->data, sc->pt, sc->params); err |= video_decoder_set(call->video, sc->data, sc->pt, sc->rparams); if (!err) { err = video_start(call->video, call->peer_uri); } if (err) { warning("call: video stream error: %m\n", err); } } else if (call->video) { info("call: video stream is disabled..\n"); } if (call->bfcp) { err = bfcp_start(call->bfcp); if (err) { warning("call: could not start BFCP: %m\n", err); } } #endif if (active) { struct le *le; tmr_cancel(&call->tmr_inv); call->time_start = time(NULL); FOREACH_STREAM { stream_reset(le->data); } } }