Skip to content

Instantly share code, notes, and snippets.

View ggarber's full-sized avatar

Gustavo Garcia ggarber

View GitHub Profile
# code from nack_module.cc
on_packet(rtp):
if rtp.seq_num < newest_seq_num: # out of order or retransmnission
return
add_missing(newest_seq_num + 1, rtp.seq_num)
if rtp.is_first_packet_of_keyframe:
keyframes.insert(rtp.seq_num)
newest_seq_num = packet.seq_num
if nack = generate_nack(SEQ):
{
"getUserMedia": [
{
"audio": "",
"origin": "https://tokbox.slack.com",
"pid": 32398,
"rid": 383,
"video": "{width: {max: 1280}, height: {max: 720}}"
},
{
#!/bin/bash
value=$(curl -s http://graphite.domain.com/render/\?target\=summarize\(metric,\%221hour\%22\)\&from\=-2h\&format\=json | /usr/local/bin/jq .[0].datapoints[-2][0] )
echo "W: $value"
#!/usr/bin/env python
import boto3
from datetime import datetime, timedelta
client = boto3.client('cloudwatch', aws_access_key_id=ID,aws_secret_access_key=SECRET, region_name='us-west-2');
metric = client.get_metric_statistics(Namespace="AWS/Firehose", MetricName="DeliveryToRedshift.Records", Period=3600, StartTime=datetime.utcnow() - timedelta(hours=1), EndTime=datetime.utcnow(), Statistics=['Average'], Dimensions=[{"Name":"DeliveryStreamName","Value":STREAM_NAME}]);
print "S: " + str(int(metric['Datapoints'][0]['Average']))
@ggarber
ggarber / kidslists
Last active October 19, 2016 13:37
{ "events":
[ {
"id": "1",
"title": "Museo del Prado",
"age": 12,
"image": "http://get10things.com/wp-content/uploads/2014/10/del-prado1.jpg"
}, {
"id": "2",
"title": "Parque del Espacio",
"age": 3,
import requests
import jwt
import time
import sys
import json
from opentok import OpenTok, MediaModes
API_KEY = ""
API_SECRET = ""
// I think ideally the RequestContext should not be a parameter in all the methods
// but i don't want to discuss that part right now
public void handleCreateRequests(RequestContext context, RaptorV2Message msg) {
Log.info("HandleCreateRequests", context);
Session session = getSession(msg.sessionId()); // <-- see it is not ctx.sessionId()
Connectino connection = getConnection(msg);
CompletableFuture.runAsync(() -> onSessionConnectRequest(context, session, connection), getExecutor(msg));
}
onConnectionCreate(connection)
if (session.connections.count > X) {
throw new Exception();
}
session.connections.add(connection)
session.connections.each((connection) => connections.send(notification))
onConnectionDestroy(connection)
session.streams.remove((stream) => stream.connection == connection)
@ggarber
ggarber / shim_v0.3
Last active September 1, 2015 22:51
var AUDIO_SDP_TEMPLATE = "v=0\r\no=- 3576587452431152789 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\nm=audio 1 RTP/SAVPF 111 0 8\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=ice-ufrag:{2}\r\na=ice-pwd:{3}\r\na=fingerprint:{0} {1}\r\na=setup:actpass\r\na=mid:audio\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=ssrc:748822434 cname:OfO7E/zpleLM7chT\r\na=ssrc:748822434 msid:klYE03jD2B0DB3SriGc3gurGtX1PF8tUr5S8 1229f9a2-1418-4a47-8d9b-c94d356ce409\r\na=ssrc:748822434 mslabel:klYE03jD2B0DB3SriGc3gurGtX1PF8tUr5S8\r\na=ssrc:748822434 label:1229f9a2-1418-4a47-8d9b-c94d356ce409\r\n";
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;

The Subscriber has maxResolution and maxFrameRate properties:

  • maxResolution - Object containing a width and a height property. When set the Subscriber will try to use a resolution that falls within those values.
  • maxFrameRate - The maximum frame rate the Subscriber should use. This is an integer value.

These properties are used to limit the maximum quality of the stream for that specific subscriber and also to prioritize different subscribers in the same endpoint. In case the bandwidth available is not enough to send the video of all the subscribers at maximum quality they will be prioritized based on these properties (for example a subscriber with higher maxResolution/FrameRate will receive more bits when the available bandwidth is limited).

You can initialise these values by passing them to the session.subscribe method eg.