Пример #1
0
RTPSession *AudioStream::AddAudioWatcher(unsigned clientSessionId,char *sendAudioIp,int sendAudioPort,AudioCodec::RTPMap& rtpMap, AudioCodec::Type watcherCodec)
{
    Log(">Add Audio Watcher[%u, %s,%d]\n",clientSessionId, sendAudioIp,sendAudioPort);

    //Si tenemos video
    if (sendAudioPort==0) {
        Error("No video\n");
        return NULL;
    }

    Rtps::iterator it = rtps.find(clientSessionId);

    RTPSession* rtp = NULL;
    //Si no esta
    if (it == rtps.end()) {
        Error("Rtp not init\n");
        return NULL;
    }
    rtp = (*it).second;

    if(!rtp->Init())
    {
        delete rtp;
        Error("Rtp init error\n");
        return NULL;
    }


    //Iniciamos las sesiones rtp de envio
    if(!rtp->SetRemotePort(sendAudioIp,sendAudioPort))
    {
        delete rtp;
        Error("Rtp SetRemotePort error\n");
        return NULL;
    }

    rtp->SetSendingAudioRTPMap(rtpMap);

    //Set video codec
    if(!rtp->SetSendingAudioCodec(watcherCodec))
    {
        delete rtp;
        //Error
        Error("%s video codec not supported by peer\n",AudioCodec::GetNameFor(watcherCodec));
        return NULL;
    }

    rtps[clientSessionId] = rtp;

    //LOgeamos
    Log("<Add Audio Watcher success [%u]\n",clientSessionId);

    return rtp;
}