use provisioning;
set autocommit=0;

INSERT INTO voip_preference_groups (name) VALUES ('Media Codec Transcoding Options');
select last_insert_id() into @vpg_id;

-- ptime

insert into voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref,
  prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer,
  data_type, read_only, description)
  values (@vpg_id, 'ptime', 'RTP packet interval', 0, 1, 1, 1, 1, 1, 0,
  now(), 0, 0, 'enum', 0, 'Alter the interval (in milliseconds) between RTP packets for media repacketization');
select last_insert_id() into @vpid;

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'use domain default', NULL, 1, 0, 0, 0, 0, 1);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'unchanged/default', 'default', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '5 ms', '5', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '10 ms', '10', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '20 ms', '20', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '30 ms', '30', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '40 ms', '40', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '50 ms', '50', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '60 ms', '60', 1, 1, 1, 1, 0, 0);



-- codecs

INSERT INTO voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref, prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer, data_type, read_only, description)
VALUES
  (@vpg_id, 'transcode_PCMU', "Transcode to G.711 µ-Law", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec G.711 µ-Law (PCMU, 8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_PCMA', "Transcode to G.711 a-Law", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec G.711 a-Law (PCMA, 8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_G722', "Transcode to G.722", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec G.722 (16 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_G723', "Transcode to G.723.1", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec G.723.1 (8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_G729', "Transcode to G.729", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec G.729 (8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_GSM', "Transcode to GSM", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec GSM Full Rate 06.10 (8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_AMR', "Transcode to AMR", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec AMR (narrowband, 8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_AMR_WB', "Transcode to AMR-WB", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec AMR-WB (wideband, 16 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_opus_mono', "Transcode to Opus mono", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec Opus (1-channel mono, 48 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_opus_stereo', "Transcode to Opus stereo", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec Opus (2-channel stereo, 48 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_speex_8', "Transcode to Speex 8 kHz", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec Speex (8 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_speex_16', "Transcode to Speex 16 kHz", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec Speex (16 kHz) to this subscriber or peer.'),
  (@vpg_id, 'transcode_speex_32', "Transcode to Speex 32 kHz", 0, 1, 1, 1, 1, 1, 0, NOW(), 0, 0, 'boolean', 0, 'Always offer the audio codec Speex (32 kHz) to this subscriber or peer.');


-- Opus options
-- mono

insert into voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref,
  prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer,
  data_type, read_only, description)
  values (@vpg_id, 'opus_mono_bitrate', 'Opus mono bitrate', 0, 1, 1, 1, 1, 1, 0,
  now(), 0, 0, 'enum', 0, 'Encoding bitrate for Opus codec if 1-channel mono is in use');
select last_insert_id() into @vpid;

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'use domain default', NULL, 1, 0, 0, 0, 0, 1);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'default (auto)', 'default', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '10 kbit/s', '10000', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '24 kbit/s', '24000', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '32 kbit/s', '32000', 1, 1, 1, 1, 0, 0);

-- stereo

insert into voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref,
  prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer,
  data_type, read_only, description)
  values (@vpg_id, 'opus_stereo_bitrate', 'Opus stereo bitrate', 0, 1, 1, 1, 1, 1, 0,
  now(), 0, 0, 'enum', 0, 'Encoding bitrate for Opus codec if 2-channel stereo is in use');
select last_insert_id() into @vpid;

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'use domain default', NULL, 1, 0, 0, 0, 0, 1);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'default (auto)', 'default', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '24 kbit/s', '24000', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '32 kbit/s', '32000', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '64 kbit/s', '64000', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '128 kbit/s', '128000', 1, 1, 1, 1, 0, 0);



-- G.723.1
insert into voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref,
  prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer,
  data_type, read_only, description)
  values (@vpg_id, 'g723_bitrate', 'G.723.1 bitrate', 0, 1, 1, 1, 1, 1, 0,
  now(), 0, 0, 'enum', 0, 'Encoding bitrate for G.723.1 (5.3 kbit/s for 20-byte frames or 6.3 kbit/s for 24-byte frames');
select last_insert_id() into @vpid;

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'use domain default', NULL, 1, 0, 0, 0, 0, 1);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, 'default (auto)', 'default', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '5.3 kbit/s', '5300', 1, 1, 1, 1, 0, 0);

insert into voip_preferences_enum (preference_id, label, value, usr_pref, prof_pref, dom_pref, peer_pref,
  contract_pref, default_val) values
  (@vpid, '6.3 kbit/s', '6300', 1, 1, 1, 1, 0, 0);


commit;
