Skip to content

Instantly share code, notes, and snippets.

@ktoraskartwilio
ktoraskartwilio / twilio-video-force-TURN.java
Created August 17, 2018 00:37
Twilio Video Android code snippet showing how to force TURN
public void connectToRoom(String roomName) {
ConnectOptions connectOptions = new ConnectOptions.Builder(accessToken)
.roomName(roomName)
.audioTracks(localAudioTracks)
.videoTracks(localVideoTracks)
.iceTransportPolicy(IceTransportPolicy.RELAY)
.build();
room = Video.connect(context, connectOptions, this);
}
@ktoraskartwilio
ktoraskartwilio / twilio-video-force-TURN.js
Last active August 15, 2018 21:32
ConnectOptions showing setting iceTransportPolicy property usage
var Video = require('twilio-video');
var token = getAccessToken();
Video.connect(token, {
name: 'my-cool-room',
iceTransportPolicy: 'relay'
}).then(function(room) {
room.on('participantConnected', function(participant) {
console.log(participant.identity + ' has connected');
});
room.once('disconnected', function() {
@ktoraskartwilio
ktoraskartwilio / token_server.js
Created February 9, 2018 06:36
Node.js Token Server
/**
* Twilio Video Token Generation
*
* Pre-requisites
* - Create an API Key (https://www.twilio.com/console/runtime/api-keys)
*/
exports.handler = function(context, event, callback) {
const AccessToken = Twilio.jwt.AccessToken;
const VideoGrant = AccessToken.VideoGrant;
@ktoraskartwilio
ktoraskartwilio / mixing_recordings.md
Last active August 27, 2023 13:47
Mixing Recordings

When mixing the tracks, we need to consider that they might (and probably have) started at different times. If we were to merge tracks without taking this into account, we would end up with synchronization issues. In our example, since Bob got in the room a good 20s (and that’s really a huge time for synchronization of audios), mixing both Alice’s and Bob’s audio tracks together would end up having one speaking over the other.

To make merging easier, the start time of all tracks from the same room is the creation of the room itself. Let’s get the start times for all the tracks from this room

Get Alice's audio start time

//
// ViewController.swift
// VideoQuickStart
//
// Copyright © 2016-2017 Twilio, Inc. All rights reserved.
//
import UIKit
import TwilioVideo
class ViewController: UIViewController {
@ktoraskartwilio
ktoraskartwilio / VideoConstraints_gist.java
Created March 1, 2017 18:56
Twilio Programmable Video - Setting Video Constraints on Android
LocalMedia localMedia = LocalMedia.create(context);
VideoConstraints videoConstraints = new VideoConstraints.Builder()
.minVideoDimensions(new VideoDimensions(320, 180))
.maxVideoDimensions(new VideoDimensions(640, 360))
.minFps(5)
.maxFps(15)
.build();
CameraCapturer cameraCapturer = new CameraCapturer(this, CameraCapturer.CameraSource.FRONT_CAMERA);
cameraVideoTrack = localMedia.addVideoTrack(true, cameraCapturer, videoConstraints);
@ktoraskartwilio
ktoraskartwilio / TwilioProgVideo_ICE_Server_Setup_iOS.mm
Last active February 15, 2017 00:51
Twilio Programmable Video ICE Server setup - iOS
// Create a Client with the access token
if (!self.client) {
self.client = [TVIVideoClient clientWithToken:self.accessToken];
}
// Documentation related to ICE servers can be found here:
// https://media.twiliocdn.com/sdk/ios/video/releases/1.0.0-beta7/docs/Classes/TVIIceServer.html
TVIIceOptions *iceOptions = [TVIIceOptions optionsWithBlock:^(TVIIceOptionsBuilder * _Nonnull builder) {
builder.transportPolicy = TVIIceTransportPolicyAll;
builder.servers = @[[[TVIIceServer alloc] initWithURL:@"stun:foo.bar.address?transport=udp"],
@ktoraskartwilio
ktoraskartwilio / TwilioProgVideo_ICE_Server_Setup.java
Last active February 15, 2017 00:12
TwilioProgVideo_ICE_Server_Setup
VideoClient videoClient = new VideoClient(this, VIDEO_ACCESS_TOKEN);
/*
* Documentation related to ICE servers can be found here:
* https://media.twiliocdn.com/sdk/android/video/releases/1.0.0-beta8/docs/com/twilio/video/IceServer.html
*/
Set<IceServer> iceServers = new HashSet<>();
iceServers.add(new IceServer("stun:foo.bar.address?transport=udp"));
iceServers.add(new IceServer("turn:foo.bar.address:3478?transport=udp", "fake", "pass"));
{
"instruction" "dequeue",
"to": "+14151112222",
"from": "+18001231234",
"post_work_activity_sid": "WA0123456789abcdef0123456789abcdef"
}
{
"task_routing":{
"filters":[
{
"friendly_name":"Gold Tickets",
"expression":"customer_value == 'Gold' AND type == 'ticket'",
"targets":[
{
"queue":"WQ0123456789abcdef0123456789abcdef",
"priority":"2"