voiceip / oreka

OpenSource G711, G722, G729, Opus & Other Format VoIP SIP Recorder
GNU General Public License v3.0
145 stars 76 forks source link

Fix memory corruption issue on LiveStreamFilter #126

Closed 346 closed 1 year ago

346 commented 1 year ago

We have been experiencing an issue where the RTMP audio stream is occasionally corrupted during the Live Streaming feature. Upon investigating this problem, we found that one of the channels of the AudioChunk is released from memory before the RTMP stream transmission occurs. As a solution, we decided to change the type held by the RingBuffer to AudioChunkRef. Additionally, we have changed the silent buffer from 0x00 to 0xFF. The silence in G711 should be 0xFF.

346 commented 1 year ago

Sorry for the wrong PR.

kingster commented 1 year ago

@346 This fix would be actually helpful for other users. Maybe you want to raise a PR?

346 commented 1 year ago

@kingster I've re-opened a pull request. But this is my first time writing in C++, so I would appreciate it if you could review my code.

kingster commented 1 year ago

Hi @346

Sorry for my late response, was occupied with few other things last two weeks. This PR is good to go :)

However for the silence, it can be multiple values based on the codec

Ideal channel noise makes bits toggle between 01111111 (0x7F) and 11111111 (0xFF) in u-law and between 01010101 (0x55) and 11010101 (0xD5) in a-law. Reference https://serverfault.com/questions/771924/detect-silence-in-rtp-payload

So that is something that needs more handling based on detected codec.