How should I play the incoming g729 packets?
The sender sends 2, 10 or 20 byte packets, if there is silence nothing is sent.
On the receiver side I need to add header and feed the packets to decoder.
1) Shall I play the decoded CN (2 byte) packets? Or should I just feed it to decoder and play the NULL frame instead?
2) Should I append NULL frame to the 10 byte packet? My renderer can't play small chunks of 10ms.
3) What should I feed the decoder in case of silence?
If I am not mistaking the G.729 decoder should be called even when you do not receive a frame in case of silence. Every frame generated by the encoder should be passed to the decoder. The CN frame will tell the decoder how to generate noise for "silent" frames. When a frame is missing because of silence, calling the decoder with a NULL input should generate anoutputwhich will be more "comfortable" to the ears than playing a NULL frame.
What annexes did you enable with the G.729 decoder? If you do not need silencesuppression/CN and multiple rates, you might be able to only use G.729A without VAD/CN which makes the implementation simpler because there is no silent frame and all frames can have the same size.
Thanx for the prompt response. I have to use VAD/CN as this is required. However, passing the NULL to decoder results in some unpleasant constant noise (not CN) present, so I presumed the NULL frame is not actually NULL.
Do you know what needs to be passed as silence and instead of lost frames?
I haven't played with the G.729 codec in a while but I will try to describe what I remember after quickly looking at the source (sorry if I am totally off).
If you pass null for the input, the G729 usc decode function will enable its PLC mode and will generate a frame of type -1 (Bad) to the actual decoder object. Inside theG729BaseDecode function if a -1 frame is receive and the variableCNGvaris set the frame is changed to type 0 (untransmited). This type of frame should be the one you want. Note for that to work the variable CNGVar needs to be set which I believe happened after a frame of type 1 (SID) has been received.
You can try to force a frame of type 0 instead of passing NULL to the decode function but make sure you also provide a dummy source buffer (or the frame will be treated the same way as a missing frame).
I would check into the debugger what code pass the decoder takes in case of a NULL input just to make sure that you are actually generating comfort noise.
Hopes this help,