Skip to content
Browse files

Added rtmp:reply function

  • Loading branch information...
1 parent d4200b6 commit 58841480aa240fb4e3454b7fe7298d4f9ce2b65c @maxlapshin maxlapshin committed Nov 23, 2009
Showing with 32 additions and 28 deletions.
  1. +1 −1 doc/edoc-info
  2. +1 −1 doc/hacking.edoc
  3. +1 −1 include/ems.hrl
  4. +14 −11 src/apps/apps_rtmp.erl
  5. +8 −7 src/apps/apps_streaming.erl
  6. +1 −1 src/erlmedia.app
  7. +1 −1 src/{ems_rtmp.erl → rtmp.erl}
  8. +5 −5 src/rtmp_client.erl
View
2 doc/edoc-info
@@ -1,5 +1,5 @@
{application,erlmedia}.
{packages,[]}.
{modules,[ems,ems_amf,ems_app,ems_cluster,ems_demo,ems_flv,
- ems_fsm,ems_proxy,ems_rtmp,rtmp_server,ems_test,gen_rtmp,
+ ems_fsm,ems_proxy,rtmp,rtmp_server,ems_test,gen_rtmp,
gen_server_cluster]}.
View
2 doc/hacking.edoc
@@ -12,7 +12,7 @@ Structure is following:
* ems_flv.erl — two meanings module: reading flv files and encoding flv frames. mp4 playback requires this file.
* ems_fsm.erl — worker fsm. One instance per client.
* ems_http.erl — builtin HTTP server, required for RTMPT and can show you nice main page on http://localhost:8082/
- * ems_rtmp.erl — RTMP encoding/decoding module. Knows about all RTMP features.
+ * rtmp.erl — RTMP encoding/decoding module. Knows about all RTMP features.
* rtmp_server.erl — RTMP acceptor.
* ems_sup.erl — EMS supervisor.
* gen_rtmp.erl — Module with functions, exported to flash.
View
2 include/ems.hrl
@@ -219,7 +219,7 @@
type = undefined,
stream = undefined,
msg = <<>>,
- chunk_size = ?RTMP_DEF_CHUNK_SIZE % This field is ONLY for passing channel into ems_rtmp:encode
+ chunk_size = ?RTMP_DEF_CHUNK_SIZE % This field is ONLY for passing channel into rtmp:encode
}).
View
25 src/apps/apps_rtmp.erl
@@ -37,7 +37,7 @@
-author('luke@codegent.com').
-include("../../include/ems.hrl").
--export([connect/2]).
+-export([connect/2, reply/2]).
-export(['WAIT_FOR_DATA'/2]).
@@ -88,19 +88,22 @@ connect(AMF, #rtmp_client{window_size = WindowAckSize} = State) ->
NewState = NewState3,
- NewAMF = AMF#amf{
- command = '_result',
- id = 1, %% muriel: dirty too, but the only way I can make this work
- type = invoke,
- args= [
- [{capabilities, 31}, {fmsVer, "RubyIZUMI/0,1,2,0"}],
- [{code, ?NC_CONNECT_SUCCESS},
- {level, "status"},
- {description, "Connection succeeded."}]]},
- gen_fsm:send_event(self(), {invoke, NewAMF}),
+ reply(1, [
+ [{capabilities, 31}, {fmsVer, "Erlyvideo 1.0"}],
+ [{code, ?NC_CONNECT_SUCCESS},
+ {level, "status"},
+ {description, "Connection succeeded."}]]),
NewState.
+reply(Id, Args) ->
+ gen_fsm:send_event(self(), {invoke, #amf{
+ command = '_result',
+ id = Id, %% muriel: dirty too, but the only way I can make this work
+ type = invoke,
+ args= Args}}).
+
+
'WAIT_FOR_DATA'({control, Type, Stream}, State) ->
gen_fsm:send_event(self(), {send, {#channel{id = 2, timestamp = 0, type = ?RTMP_TYPE_CONTROL, stream = 0}, <<Type:16/big, Stream:32/big>>}}),
View
15 src/apps/apps_streaming.erl
@@ -93,13 +93,14 @@
%%-------------------------------------------------------------------------
createStream(AMF, State) ->
?D({"invoke - createStream", AMF}),
- Id = 1, % New stream ID
- NewAMF = AMF#amf{
- id = 2.0,
- command = '_result',
- args = [null, Id]},
- % gen_fsm:send_event(self(), {send, {#channel{timestamp = 0, id = 2},NewAMF}}),
- gen_fsm:send_event(self(), {invoke, NewAMF}),
+ % Id = 1, % New stream ID
+ % NewAMF = AMF#amf{
+ % id = 2.0,
+ % command = '_result',
+ % args = [null, Id]},
+ % % gen_fsm:send_event(self(), {send, {#channel{timestamp = 0, id = 2},NewAMF}}),
+ % gen_fsm:send_event(self(), {invoke, NewAMF}),
+ apps_rtmp:reply(2.0, [null, 1]),
gen_fsm:send_event(self(), {send, {#channel{timestamp = 0, id = 2, stream = 0, type = ?RTMP_TYPE_CHUNK_SIZE}, ?RTMP_PREF_CHUNK_SIZE}}),
State.
View
2 src/erlmedia.app
@@ -19,7 +19,7 @@
ems_flv,
rtmp_client,
ems_http,
- ems_rtmp,
+ rtmp,
rtmp_server,
ems_sup,
flv,
View
2 src/ems_rtmp.erl → src/rtmp.erl
@@ -30,7 +30,7 @@
%%% THE SOFTWARE.
%%%
%%%---------------------------------------------------------------------------------------
--module(ems_rtmp).
+-module(rtmp).
-author('rsaccon@gmail.com').
-author('simpleenigmainc@gmail.com').
-author('luke@codegent.com').
View
10 src/rtmp_client.erl
@@ -118,7 +118,7 @@ init([]) ->
'WAIT_FOR_HANDSHAKE'({data, Data}, #rtmp_client{buff = Buff} = State) when size(Buff) + size(Data) >= ?HS_BODY_LEN + 1 ->
case <<Buff/binary,Data/binary>> of
<<?HS_HEADER,HandShake:?HS_BODY_LEN/binary, Rest/binary>> ->
- Reply = ems_rtmp:handshake(HandShake),
+ Reply = rtmp:handshake(HandShake),
send_data(State, [?HS_HEADER, Reply]),
{next_state, 'WAIT_FOR_HS_ACK', State#rtmp_client{buff = Rest}, ?TIMEOUT};
_ -> ?D("Handshake Failed"), {stop, normal, State}
@@ -140,7 +140,7 @@ init([]) ->
'WAIT_FOR_HS_ACK'({data, Data}, #rtmp_client{buff = Buff} = State) when size(Buff) + size(Data) >= ?HS_BODY_LEN ->
case <<Buff/binary,Data/binary>> of
<<_HS:?HS_BODY_LEN/binary,Rest/binary>> ->
- NewState = ems_rtmp:decode(State#rtmp_client{buff = Rest}),
+ NewState = rtmp:decode(State#rtmp_client{buff = Rest}),
{next_state, 'WAIT_FOR_DATA', NewState, ?TIMEOUT};
_ -> ?D("Handshake Failed"), {stop, normal, State}
end;
@@ -152,16 +152,16 @@ init([]) ->
%% Notification event coming from client
'WAIT_FOR_DATA'({data, Data}, #rtmp_client{buff = Buff} = State) ->
- {next_state, 'WAIT_FOR_DATA', ems_rtmp:decode(State#rtmp_client{buff = <<Buff/binary, Data/binary>>}), ?TIMEOUT};
+ {next_state, 'WAIT_FOR_DATA', rtmp:decode(State#rtmp_client{buff = <<Buff/binary, Data/binary>>}), ?TIMEOUT};
'WAIT_FOR_DATA'({send, {#channel{type = ?RTMP_TYPE_CHUNK_SIZE} = Channel, ChunkSize}}, #rtmp_client{server_chunk_size = OldChunkSize} = State) ->
- Packet = ems_rtmp:encode(Channel#channel{chunk_size = OldChunkSize}, <<ChunkSize:32/big-integer>>),
+ Packet = rtmp:encode(Channel#channel{chunk_size = OldChunkSize}, <<ChunkSize:32/big-integer>>),
?D({"Set chunk size from", OldChunkSize, "to", ChunkSize}),
send_data(State, Packet),
{next_state, 'WAIT_FOR_DATA', State#rtmp_client{server_chunk_size = ChunkSize}, ?TIMEOUT};
'WAIT_FOR_DATA'({send, {#channel{} = Channel, Data}}, #rtmp_client{server_chunk_size = ChunkSize} = State) ->
- Packet = ems_rtmp:encode(Channel#channel{chunk_size = ChunkSize}, Data),
+ Packet = rtmp:encode(Channel#channel{chunk_size = ChunkSize}, Data),
send_data(State, Packet),
{next_state, 'WAIT_FOR_DATA', State, ?TIMEOUT};

0 comments on commit 5884148

Please sign in to comment.
Something went wrong with that request. Please try again.