Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Phonebooth/erlang-rtmp
base: 4817120c8c
...
head fork: Phonebooth/erlang-rtmp
compare: 15e6e9de38
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
4 .gitignore
@@ -1 +1,5 @@
*-stamp
+*~
+*.swp
+.eunit/
+ebin/rtmp.app
View
85 Makefile
@@ -1,78 +1,13 @@
-VERSION := $(shell head -1 debian/changelog | ruby -e 'puts STDIN.readlines.first[/\(([\d\.]+)\)/,1]')
-DEBIANREPO=/apps/erlyvideo/debian/public
-DESTROOT=$(CURDIR)/debian/erlang-rtmp
-
-# Assume Linux-style dynamic library flags
-DYNAMIC_LIB_CFLAGS = -fpic -shared
-ifeq ($(shell uname),Darwin)
- DYNAMIC_LIB_CFLAGS = -arch x86_64 -fPIC -bundle -flat_namespace -undefined suppress
-endif
-ifeq ($(shell uname),SunOs)
- DYNAMIC_LIB_CFLAGS = -KPIC -G -z text
-endif
-ERL_INCLUDE_DIR := $(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface,include)])' -s init stop -noshell)
-ERL_LIB_DIR := $(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface,lib)])' -s init stop -noshell)
-ERLDIR := $(shell erl -eval 'io:format("~s", [code:root_dir()])' -s init stop -noshell)/lib/rtmp-$(VERSION)
-ERLANG_DIR := $(shell erl -eval 'io:format("~s", [code:root_dir()])' -s init stop -noshell)
-
-OBJS := $(patsubst src/%c,ebin/%so,$(wildcard src/*.c))
-
-all: $(OBJS)
- erl -make
-
-analyze:
- dialyzer -Wno_improper_lists -c src/*.erl
-
-doc:
- erl -pa `pwd`/ebin \
- -noshell \
- -run edoc_run application "'rtmp'" '"."' '[{def,{vsn,"$(VERSION)"}}]'
-
-ebin/rtmp_codec_drv.so: src/rtmp_codec_drv.c
- gcc -g -O2 -Wall \
- src/rtmp_codec_drv.c \
- -I$(ERL_INCLUDE_DIR) -I$(ERLANG_DIR)/usr/include \
- -L$(ERL_LIB_DIR) -lerl_interface -lei \
- -o ebin/rtmp_codec_drv.so \
- $(DYNAMIC_LIB_CFLAGS)
-
+REBAR=`which rebar || ./rebar`
+.PHONY: all deps compile test clean
+all: deps compile
+deps:
+ @$(REBAR) get-deps
+compile:
+ @$(REBAR) compile
+test:
+ @$(REBAR) skip_deps=true eunit
clean:
- rm -fv ebin/*.beam
- rm -fv erl_crash.dump
-
-clean-doc:
- rm -fv doc/*.html
- rm -fv doc/edoc-info
- rm -fv doc/*.css
-
-install:
- mkdir -p $(DESTROOT)$(ERLDIR)/ebin
- mkdir -p $(DESTROOT)/usr/bin
- mkdir -p $(DESTROOT)$(ERLDIR)/contrib
- mkdir -p $(DESTROOT)$(ERLDIR)/src
- mkdir -p $(DESTROOT)$(ERLDIR)/include
- install -c -m 755 contrib/* $(DESTROOT)$(ERLDIR)/contrib
- install -c -m 755 contrib/rtmp_bench $(DESTROOT)/usr/bin/rtmp_bench
- install -c -m 644 ebin/*.beam $(DESTROOT)$(ERLDIR)/ebin
- install -c -m 644 ebin/*.app $(DESTROOT)$(ERLDIR)/ebin
- install -c -m 644 ebin/*.so $(DESTROOT)$(ERLDIR)/ebin || true
- install -c -m 644 src/* $(DESTROOT)$(ERLDIR)/src
- install -c -m 644 Makefile $(DESTROOT)$(ERLDIR)/Makefile
- install -c -m 644 Emakefile $(DESTROOT)$(ERLDIR)/Emakefile
- install -c -m 644 include/* $(DESTROOT)$(ERLDIR)/include
-
-debian:
- dpkg-buildpackage -rfakeroot -D -i -I -S -sa
- dput erly ../erlang-rtmp_$(VERSION)_source.changes
- debuild -us -uc
- cp ../erlang-rtmp_$(VERSION)*.deb $(DEBIANREPO)/binary/
- rm ../erlang-rtmp_$(VERSION)*
- (cd $(DEBIANREPO)/..; ./update)
-
-deploy-doc:
- (cd doc; rsync -avz . -e ssh erlyvideo.org:/apps/erlyvideo/www/public/rtmp)
-
-.PHONY: doc debian
-
+ @$(REBAR) clean
View
10 ebin/rtmp.app
@@ -1,10 +0,0 @@
-%% This is the application resource file (.app file) for the 'base'
-%% application.
-{application, rtmp,
-[{description, "RTMP handling library"},
- {vsn, "0.1"},
- {modules, [rtmp,rtmp_app,rtmp_bench,rtmp_listener,rtmp_sup,rtmpt,rtmpt_sessions,sha2,hmac256,rtmp_handshake,rtmp_lib,rtmp_socket,rtmp_monitor]},
- {registered,[rtmp,rtmpt_sessions_sup,rtmpt_session_sup,rtmp_socket_sup,rtmp_monitor_sup,rtmp_monitor]},
- {applications, [kernel,stdlib]},
- {mod, {rtmp_app,[]}}
-]}.
View
BIN  rebar
Binary file not shown
View
5 rebar.config
@@ -0,0 +1,5 @@
+{erl_opts, [warnings_as_errors, debug_info]}.
+{cover_enabled, true}.
+{clean_files, ["*.eunit", "ebin/*.beam"]}.
+{eunit_opts, [verbose,
+ {report, {eunit_surefire, [{dir, "."}]}}]}.
View
33 src/rtmp.app.src
@@ -0,0 +1,33 @@
+%% This is the application resource file (.app file) for the 'base'
+%% application.
+{application, rtmp,
+[{description, "RTMP handling library"},
+ {vsn, "0.1"},
+ {modules, [
+ rtmp,
+ rtmp_app,
+ rtmp_bench,
+ rtmp_listener,
+ rtmp_sup,
+ rtmpt,
+ rtmpt_sessions,
+ sha2,
+ hmac256,
+ rtmp_handshake,
+ rtmp_lib,
+ rtmp_socket,
+ rtmp_monitor]},
+ {registered,[
+ rtmp,
+ rtmpt_sessions_sup,
+ rtmpt_session_sup,
+ rtmp_socket_sup,
+ rtmp_monitor_sup,
+ rtmp_monitor]},
+ {applications, [kernel,stdlib,sasl]},
+ {mod, {rtmp_app,[]}},
+ {env, [
+ % use this config param to start rtmp_listener with the app starts
+ % {rtmp_callback, {1935, rtmp_listener1, rtmp_callback_module}}
+ ]}
+]}.
View
21 src/rtmp_handshake.erl
@@ -198,16 +198,17 @@ clientDigest(<<_:8/binary, P1, P2, P3, P4, _/binary>> = C1, version1) ->
<<First:Offset/binary, Seed:32/binary, Last/binary>> = C1,
{First, Seed, Last}.
--spec dhKey(Handshake::binary(), handshake_version()) -> {First::binary(), Seed::binary(), Last::binary()}.
-dhKey(<<_:1532/binary, P1, P2, P3, P4, _/binary>> = C1, version1) ->
- Offset = (P1+P2+P3+P4) rem 632 + 772,
- <<First:Offset/binary, Seed:32/binary, Last/binary>> = C1,
- {First, Seed, Last};
-
-dhKey(<<_:768/binary, P1, P2, P3, P4, _/binary>> = C1, version1) ->
- Offset = (P1+P2+P3+P4) rem 632 + 8,
- <<First:Offset/binary, Seed:32/binary, Last/binary>> = C1,
- {First, Seed, Last}.
+%% commenting out since it's not used to remove compiler warning
+% -spec dhKey(Handshake::binary(), handshake_version()) -> {First::binary(), Seed::binary(), Last::binary()}.
+% dhKey(<<_:1532/binary, P1, P2, P3, P4, _/binary>> = C1, version1) ->
+% Offset = (P1+P2+P3+P4) rem 632 + 772,
+% <<First:Offset/binary, Seed:32/binary, Last/binary>> = C1,
+% {First, Seed, Last};
+%
+% dhKey(<<_:768/binary, P1, P2, P3, P4, _/binary>> = C1, version1) ->
+% Offset = (P1+P2+P3+P4) rem 632 + 8,
+% <<First:Offset/binary, Seed:32/binary, Last/binary>> = C1,
+% {First, Seed, Last}.
-spec validateClientScheme(C1::binary()) -> handshake_version().
validateClientScheme(C1) ->
View
2  src/rtmp_socket.erl
@@ -464,7 +464,7 @@ handle_info({tcp, Socket, Data}, handshake_c3, #rtmp_socket{socket=Socket, buffe
activate_socket(Socket),
{next_state, handshake_c3, State#rtmp_socket{buffer = <<Buffer/binary, Data/binary>>, bytes_read = BytesRead + size(Data)}, ?RTMP_TIMEOUT};
-handle_info({tcp, Socket, Data}, handshake_c3, #rtmp_socket{socket=Socket, consumer = Consumer, buffer = Buffer, bytes_read = BytesRead, active = Active} = State) ->
+handle_info({tcp, Socket, Data}, handshake_c3, #rtmp_socket{socket=Socket, consumer = Consumer, buffer = Buffer, bytes_read = BytesRead, active = _Active} = State) ->
<<_HandShakeC3:?HS_BODY_LEN/binary, Rest/binary>> = <<Buffer/binary, Data/binary>>,
Consumer ! {rtmp, self(), connected},
inet:setopts(Socket, [{active, true}, {nodelay, true}]),
View
152 src/rtmp_sup.erl
@@ -44,85 +44,105 @@
%%--------------------------------------------------------------------
-spec start_link() -> {'error',_} | {'ok',pid()}.
start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
start_rtmpt(SessionID, IP) -> supervisor:start_child(rtmpt_session_sup, [SessionID, IP]).
start_rtmp_socket(Type) -> supervisor:start_child(rtmp_socket_sup, [Type]).
start_rtmp_listener(Port, Name, Callback) ->
- Listener = {
- Name,
- {rtmp_listener, start_link ,[Port, Name, Callback]},
- permanent,
- 10000,
- worker,
- [rtmp_listener]
- },
- supervisor:start_child(?MODULE, Listener).
+ Listener = {
+ Name,
+ {rtmp_listener, start_link ,[Port, Name, Callback]},
+ permanent,
+ 10000,
+ worker,
+ [rtmp_listener]
+ },
+ supervisor:start_child(?MODULE, Listener).
init([rtmp_socket]) ->
- {ok,
- {{simple_one_for_one, 5, 60},
- [
- { undefined, % Id = internal id
- {rtmp_socket,start_link,[]}, % StartFun = {M, F, A}
- temporary, % Restart = permanent | transient | temporary
- 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
- worker, % Type = worker | supervisor
- [] % Modules = [Module] | dynamic
+ {ok,
+ {{simple_one_for_one, 5, 60},
+ [
+ { undefined, % Id = internal id
+ {rtmp_socket,start_link,[]}, % StartFun = {M, F, A}
+ temporary, % Restart = permanent | transient | temporary
+ 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
+ worker, % Type = worker | supervisor
+ [] % Modules = [Module] | dynamic
+ }
+ ]
}
- ]
- }
- };
+ };
init([rtmpt_session]) ->
- {ok,
- {{simple_one_for_one, 5, 60},
- [
- { undefined, % Id = internal id
- {rtmpt,start_link,[]}, % StartFun = {M, F, A}
- temporary, % Restart = permanent | transient | temporary
- 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
- worker, % Type = worker | supervisor
- [] % Modules = [Module] | dynamic
+ {ok,
+ {{simple_one_for_one, 5, 60},
+ [
+ { undefined, % Id = internal id
+ {rtmpt,start_link,[]}, % StartFun = {M, F, A}
+ temporary, % Restart = permanent | transient | temporary
+ 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
+ worker, % Type = worker | supervisor
+ [] % Modules = [Module] | dynamic
+ }
+ ]
}
- ]
- }
- };
+ };
init([]) ->
- Supervisors = [
- {rtmpt_sessions_sup, % Id = internal id
- {rtmpt_sessions,start_link,[]}, % StartFun = {M, F, A}
- permanent, % Restart = permanent | transient | temporary
- 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
- worker, % Type = worker | supervisor
- [rtmpt_sessions] % Modules = [Module] | dynamic
- },
- {rtmpt_session_sup,
- {supervisor,start_link,[{local, rtmpt_session_sup}, ?MODULE, [rtmpt_session]]},
- permanent, % Restart = permanent | transient | temporary
- infinity, % Shutdown = brutal_kill | int() >= 0 | infinity
- supervisor, % Type = worker | supervisor
- [] % Modules = [Module] | dynamic
- },
- {rtmp_socket_sup,
- {supervisor,start_link,[{local, rtmp_socket_sup}, ?MODULE, [rtmp_socket]]},
- permanent, % Restart = permanent | transient | temporary
- infinity, % Shutdown = brutal_kill | int() >= 0 | infinity
- supervisor, % Type = worker | supervisor
- [] % Modules = [Module] | dynamic
- },
- {rtmp_monitor_sup, % Id = internal id
- {rtmp_monitor,start_link,[[{timeout,1000},{threshold,80*60}]]}, % StartFun = {M, F, A}
- permanent, % Restart = permanent | transient | temporary
- 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
- worker, % Type = worker | supervisor
- [rtmp_monitor] % Modules = [Module] | dynamic
- }
- ],
-
- {ok, {{one_for_one, 3, 10}, Supervisors}}.
+ Supervisors = [
+ {rtmpt_sessions_sup, % Id = internal id
+ {rtmpt_sessions,start_link,[]}, % StartFun = {M, F, A}
+ permanent, % Restart = permanent | transient | temporary
+ 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
+ worker, % Type = worker | supervisor
+ [rtmpt_sessions] % Modules = [Module] | dynamic
+ },
+ {rtmpt_session_sup,
+ {supervisor,start_link,
+ [{local, rtmpt_session_sup}, ?MODULE, [rtmpt_session]]},
+ permanent, % Restart = permanent | transient | temporary
+ infinity, % Shutdown = brutal_kill | int() >= 0 | infinity
+ supervisor, % Type = worker | supervisor
+ [] % Modules = [Module] | dynamic
+ },
+ {rtmp_socket_sup,
+ {supervisor,start_link,
+ [{local, rtmp_socket_sup}, ?MODULE, [rtmp_socket]]},
+ permanent, % Restart = permanent | transient | temporary
+ infinity, % Shutdown = brutal_kill | int() >= 0 | infinity
+ supervisor, % Type = worker | supervisor
+ [] % Modules = [Module] | dynamic
+ },
+ {rtmp_monitor_sup, % Id = internal id
+ {rtmp_monitor,start_link,
+ [[{timeout,1000},{threshold,80*60}]]}, % StartFun = {M, F, A}
+ permanent, % Restart = permanent | transient | temporary
+ 2000, % Shutdown = brutal_kill | int() >= 0 | infinity
+ worker, % Type = worker | supervisor
+ [rtmp_monitor] % Modules = [Module] | dynamic
+ }
+ ],
+ %% look in app config, if port and callback is configured... start rtmp_listener now
+ %% instead of relying on rtmp_socket:start_server/3 to be called
+ Specs = case application:get_env(rtmp, rtmp_callback) of
+ {Port, Name, Callback} ->
+ Listener = {
+ Name,
+ {rtmp_listener, start_link ,[Port, Name, Callback]},
+ permanent,
+ 10000,
+ worker,
+ [rtmp_listener]
+ },
+ error_logger:info_msg("Starting rtmp_listener named ~p on port ~p, "
+ "with callback module ~p", [Port, Name, Callback]),
+ [Supervisors | Listener];
+ _ ->
+ Supervisors
+ end,
+ {ok, {{one_for_one, 3, 10}, Specs}}.

No commit comments for this range

Something went wrong with that request. Please try again.