Skip to content

Instantly share code, notes, and snippets.

💭
not much free time for fun stuff

Vladimir Gordeev vladimir-vg

💭
not much free time for fun stuff
Block or report user

Report or block vladimir-vg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View echo_server.erl
-module(echo_server).
-behavior(gen_server).
-export([start_link/0]). % supervisor callback
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]). % gen_server callbacks
-export([handler_loop/1]).
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
@vladimir-vg
vladimir-vg / morpheus_sup.erl
Created Jul 8, 2017
espace demo 07-2017 erl modules
View morpheus_sup.erl
-module(morpheus_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
View es_shell_io_server.erl
-module(es_shell_io_server).
-behaviour(gen_server).
-export([start_link/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
-record(shell_io, {
collector_pid,
parent_pid,
% stale_timeout,
% stale_timer,
View gist:efdd5d8fc6fc0e9332ae
2015-08-11 18:41:31.405 <0.64.0> [TV1000_PREMIUM_HD] avcodec:407 SLAVE: Init aac encoder with options: [{b,128000},{channels,2},{sample_rate,48000},{input_channel_layout,<<"stereo">>},{input_sample_fmt,<<"s16p">>},{input_sample_rate,<<"48000">>}], user: []
2015-08-11 18:41:31.406 <0.65.0> [TV1000_PREMIUM_HD] avcodec:407 SLAVE: Init aac encoder with options: [{b,128000},{channels,2},{sample_rate,48000},{input_channel_layout,<<"5.1(side)">>},{input_sample_fmt,<<"fltp">>},{input_sample_rate,<<"48000">>}], user: []
2015-08-11 18:41:31.413 <0.2399.110> [TV1000_PREMIUM_HD] live_stream_frame:95 DTS forward jump: dts: 54640503 with delta 1740, next_dts: 1740, new delta: 54640503
2015-08-11 18:41:31.413 <0.2399.110> [TV1000_PREMIUM_HD] live_stream_frame:73 resynchronized time. last DTS: 1740, new DTS: 54640503, time delta: 8, new delta: -54638755
2015-08-11 18:41:31.478 <0.2373.110> [TV1000_PREMIUM_HD] mpegts_handler:143 PLAY MPEGTS from ip 192.168.122.1
2015-08-11 18:41:31.478 <0.2399.110> [TV1000_PREMIUM_HD] live_st
View mpegts_udp.c
if(d->len == 0) return;
if(!d->buf) return;
ErlDrvTermData reply[] = {
ERL_DRV_ATOM, atom_udp,
ERL_DRV_PORT, driver_mk_port(d->port),
ERL_DRV_BINARY, (ErlDrvTermData)d->buf, (ErlDrvTermData)d->len, (ErlDrvTermData)0,
ERL_DRV_INT, (ErlDrvTermData)d->packet_count,
ERL_DRV_INT, (ErlDrvTermData)d->error_count,
ERL_DRV_TUPLE, 5
};
View mpegts_udp.c
while((s = recvfrom(d->socket, d->buf->orig_bytes + d->len, d->size - d->len, 0, (struct sockaddr *)&peer, &peer_len)) > 0) {
d->len += s;
if(d->len >= d->limit) {
check_errors(d);
flush(d);
}
}
View diff
1997c1997
< 1 h264 frame 6537388 167( 9860) h264([{aud,2,765877162,{9,240}},{single,9850,1555489264,'P'}])
---
> 1 h264 frame 6537388 167( 8261) h264([{aud,2,765877162,{9,240}},{single,8251,1507530533,'P'}])
3871c3871
< 1 h264 frame 6561078 125( 14187) h264([{aud,2,765877162,{9,240}},{single,14177,339307100,'P'}])
---
> 1 h264 frame 6561078 125( 12715) h264([{aud,2,765877162,{9,240}},{single,12705,3923439548,'P'}])
5669c5669
< 1 h264 frame 6583726 167( 11004) h264([{aud,2,765877162,{9,240}},{single,10994,1060480850,'P'}])
View inet_drv.c
#if defined(IP_TOS) && defined(SOL_IP) && defined(SO_PRIORITY)
static int setopt_prio_tos_trick
(int fd, int proto, int type, char* arg_ptr, int arg_sz, int propagate)
{
/* The relations between SO_PRIORITY, TOS and other options
is not what you (or at least I) would expect...:
If TOS is set after priority, priority is zeroed.
If any other option is set after tos, tos might be zeroed.
Therefore, save tos and priority. If something else is set,
restore both after setting, if tos is set, restore only
View gen_udp.strace
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 28
fcntl(28, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(28, F_SETFL, O_RDWR|O_NONBLOCK) = 0
getsockopt(28, SOL_SOCKET, SO_PRIORITY, [0], [4]) = 0
getsockopt(28, SOL_IP, IP_TOS, [0], [4]) = 0
setsockopt(28, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(28, SOL_IP, IP_TOS, [0], 4) = 0
setsockopt(28, SOL_SOCKET, SO_PRIORITY, [0], 4) = 0
getsockopt(28, SOL_SOCKET, SO_PRIORITY, [0], [4]) = 0
getsockopt(28, SOL_IP, IP_TOS, [0], [4]) = 0
View .sh
grep IPPROTO_UDP * -n
You can’t perform that action at this time.