Hello everyone,
I'm working on a subclassing AudioMediaPort that receives audio and responds with audio generated by a bot. However, I'm encountering an issue where the caller hears their own voice when the audio port is not sending any data. Below is a brief overview of my code:
class MyCall : public Call {
private:
MyAudioMediaPort *med_port = nullptr;
public:
void onCallMediaState(OnCallMediaStateParam &prm) {
CallInfo ci = getInfo();
AudioMedia aud_med = getAudioMedia(-1);
if (med_port == nullptr) {
med_port = new MyAudioMediaPort(this, ci);
MediaFormatAudio fmt;
fmt.type = PJMEDIA_TYPE_AUDIO;
fmt.clockRate = 16000;
fmt.channelCount = 1;
fmt.bitsPerSample = 16;
fmt.frameTimeUsec = 20000;
med_port->createPort("med_port", fmt);
med_port->startTransmit(aud_med);
aud_med.startTransmit(*med_port);
}
}
};
class MyAudioMediaPort : public AudioMediaPort {
private:
public:
virtual void onFrameRequested(MediaFrame &frame) {
frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
if (!audioToSend.empty()) {
size_t frameSize = std::min(audioToSend.size(), frame.size);
frame.buf.assign(audioToSend.begin(), audioToSend.begin() + frameSize);
audioToSend.erase(audioToSend.begin(), audioToSend.begin() + frameSize);
}
}
virtual void onFrameReceived(MediaFrame &frame) {
// append to byte vector
receivedData.insert(receivedData.end(), frame.buf.begin(), frame.buf.end());
// Do some processing
}
};
My assumption is, if I don't put any audio data in the onFrameRequested method, nothing should be sent. But the caller's audio is looped back.
Could anyone help me figure out why the caller hears their own voice and how I can stop it? Any insights or suggestions would be greatly appreciated.
Thanks in advance!
Best regards,
Pavan Kumar
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list -- pjsip@xxxxxxxxxxxxxxx To unsubscribe send an email to pjsip-leave@xxxxxxxxxxxxxxx