Skip to content

Instantly share code, notes, and snippets.

View vladimir-vg's full-sized avatar
🙂

Vladimir Gordeev vladimir-vg

🙂
View GitHub Profile
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);
}
}
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'}])
#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
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
grep IPPROTO_UDP * -n
@vladimir-vg
vladimir-vg / .sh
Last active August 29, 2015 14:20
strace -ff -o strace/log make run
recvfrom(S, Length) ->
recvfrom0(S, Length, -1).
recvfrom(S, Length, infinity) ->
recvfrom0(S, Length, -1);
recvfrom(S, Length, Time) when is_integer(Time), Time < 16#ffffffff ->
recvfrom0(S, Length, Time);
recvfrom(_, _, _) -> {error,einval}.
recvfrom0(S, Length, Time)
recv(S,Len) ->
prim_inet:recvfrom(S, Len).
-spec recv(Socket, Length) ->
{ok, {Address, Port, Packet}} | {error, Reason} when
Socket :: socket(),
Length :: non_neg_integer(),
Address :: inet:ip_address(),
Port :: inet:port_number(),
Packet :: string() | binary(),
Reason :: not_owner | inet:posix().
recv(S,Len) when is_port(S), is_integer(Len) ->
-define(REGION_SIZE, 50).
-define(TIME_CORRECTION_COEF, 1.0).
-define(DELTA_BETWEEN_PACKETS, 5).
handle_info(#frame{mpegts = Bin} = Frame, Pusher) when is_binary(Bin) ->
case put_to_buffer(Pusher, Frame) of
{ok, Pusher1} -> {noreply, Pusher1};
{filled_in, Pusher1} ->
{ok, Pusher2} = send_buffer(Pusher1),
{noreply, Pusher2}