[session:streamFile] Seek when transcoding incorrect

When playing back a file in LUA using session:streamFile, and using a callback function to seek forward or backward in a file, and transcoding audio, the seek is incorrect.

To reproduce, run the following sample code while on a PCMU call and playing a 16kHz file. Pressing 3 or 6 after listening for three or four minutes will rewind instead of fast forwarding.

function dtmf_input(session, type, data, arg)
    if (type == "dtmf") then
        freeswitch.consoleLog("INFO", "streamFile got digit " .. data['digit'] .. "\n");
        if (data['digit'] == "*") then
            exit = true;
            return 0;
        elseif (data['digit'] == "1") then
            return ("seek:-15000");
        elseif (data['digit'] == "3") then
            return ("seek:+15000");
        elseif (data['digit'] == "4") then
            return ("seek:-60000");
        elseif (data['digit'] == "6") then
            return ("seek:+60000");
        elseif (data['digit'] == "0") then
            return true;
        else
            return 0;
        end
    end
end

session:setInputCallback("dtmf_input", "");
session:streamFile(16_khz_file.wav);
session:unsetInputCallback();

The seek function doesn’t detect the current position properly because it assumes 8kHz (the transcoded sample rate) but the file is 16kHz, so pressing 3 actually causes the playback to rewind (the current position is only half the correct value).

The issue appears to be in this line:

Since this code is 11 years old, before filing a bug I figured I’d reach out if anyone knew about this or if I’m doing something wrong.

Thanks in advance.