
local api = freeswitch.API();
local rtp_last_audio_codec_string = session:getVariable("rtp_last_audio_codec_string") or "nil";
local rtp_last_video_codec_string = session:getVariable("rtp_last_video_codec_string") or "nil";
local lcc_video_media_flow = session:getVariable("lcc_video_media_flow");
local lcc_first_video_media_flow = session:getVariable("lcc_first_video_media_flow");

if lcc_first_video_media_flow ~= lcc_video_media_flow then
    -- 发起和接听的媒体状态不一致，发起reinvite重协商媒体
    local partner_uuid = session:getVariable("signal_bond") or session:getVariable("originate_signal_bond");
    if partner_uuid then
        local codec_string = "=";
        if rtp_last_audio_codec_string ~= "nil" then
            codec_string = codec_string..rtp_last_audio_codec_string;
        else
            codec_string = codec_string.."=PCMA@8000h@20i@1c";
        end

        if lcc_video_media_flow ~= "inactive" then
            if rtp_last_video_codec_string ~= "nil" then
                codec_string = codec_string..","..rtp_last_video_codec_string;
            else
                codec_string = codec_string..",H264@90000h";
            end
        end
        api:execute("uuid_media_reneg", partner_uuid.." "..codec_string);
    else
        freeswitch.consoleLog("NOTICE", "b call uuid is nil!\n");
    end

    freeswitch.consoleLog("NOTICE", lcc_first_video_media_flow..", "..lcc_video_media_flow.."\n");
end