diff --git a/apps/precoded_announce/PrecodedAnnounce.cpp b/apps/precoded_announce/PrecodedAnnounce.cpp index c089ba37..eb3d254e 100644 --- a/apps/precoded_announce/PrecodedAnnounce.cpp +++ b/apps/precoded_announce/PrecodedAnnounce.cpp @@ -75,10 +75,21 @@ AmPayloadProviderInterface* PrecodedDialog::getPayloadProvider() { void PrecodedDialog::onSessionStart(const AmSipRequest& req) { - AmPrecodedFileInstance* file = file_def->getFileInstance(rtp_str.getCurrentPayload(), + int current_payload=rtp_str.getCurrentPayload(); + if ((current_payload == -1) && !m_payloads.empty()) { + current_payload = m_payloads[0]->payload_type; + } + AmPrecodedFileInstance* file = file_def->getFileInstance(current_payload, m_payloads); - if (!file || file->open()) - throw string("PrecodedDialog::onSessionStart: Cannot open file\n"); + if (!file) { + ERROR("no payload\n"); + } + if (!file || file->open()) { + ERROR("PrecodedDialog::onSessionStart: Cannot open file\n"); + dlg.bye(); + setStopped(); + return; + } rtp_str.setFormat(file->getRtpFormat());