tSIP: Lua RecordStart

tSIP 0.1.57 adds option to start recording "manually" - with Lua script RecordStart() function. This script can be either assigned to button (real manual recording start, e.g. after second party agrees to be recorded) or to call state event (thus adding ability to filter what should or should not be recorded). As file name for the wav file can be specified this also allows to sort recordings or use own, custom naming. I\'m still recommending using default naming convention and phone number encoded as filesystem-safe base64 variant.

Example button script: RecordStart.lua:

-- note: skipped enc() (base64 encoding) definition from this inline example
local peer = GetCallPeer()
local filename = GetExeName()
print(string.format("peer = %s, filename = %s\n", peer, filename))
local index = string.find(filename:reverse(), "\\")
local dir = string.sub(filename, 1, -index)
print(string.format("directory = %s\n", dir))
dir = dir .. "recordings\\"
print(string.format("directory (2) = %s\n", dir))
local incomingMark = "0"
if IsCallIncoming() then
	incomingMark = "1"
end
filename = dir .. os.date("%Y%m%d_%I%M%S_") .. incomingMark .. "_" .. enc(peer) .. ".wav"
local channels = 2

local result = RecordStart(filename, channels)
if result ~= 0 then
	print("Failed to start recording to " .. filename .. "\n")
end

If target directory does not exist of may not exist use ForceDirectories(path) function before starting recording, e.g.

ForceDirectories("D:\\test\\test123")

Back to howto list.