Am 16.07.2024 um 19:04 schrieb Pavan Kumar:
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()
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
While I don't know about your specific code;
what I'd do would be to write a method which prints out all confports
and their connections.
That way you can see what ports are connected with each other.
Depending on your setup, it could also be echo in which case
you'd want to install some form of AEC in your audio path.
Best regards,
Andreas
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