Skip to content
Browse files

Added support for JWV Player

  • Loading branch information...
1 parent 092346f commit 7631edbb97184be402ca6b94df2377cc8a739ab5 @maxlapshin maxlapshin committed Nov 22, 2009
Showing with 48 additions and 15 deletions.
  1. +6 −1 src/apps/apps_streaming.erl
  2. +1 −1 src/ems.erl
  3. +9 −4 src/ems_rtmp.erl
  4. +27 −8 src/media/media_provider.erl
  5. +5 −1 wwwroot/index.html
View
7 src/apps/apps_streaming.erl
@@ -37,7 +37,8 @@
-author('luke@codegent.com').
-include("../../include/ems.hrl").
--export([createStream/2, play/2, deleteStream/2, closeStream/2, pause/2, pauseRaw/2, stop/2, seek/2]).
+-export([createStream/2, play/2, deleteStream/2, closeStream/2, pause/2, pauseRaw/2, stop/2, seek/2,
+ getStreamLength/2]).
-export(['WAIT_FOR_DATA'/2]).
@@ -167,6 +168,10 @@ pause(AMF, #rtmp_client{video_player = Player} = State) ->
pauseRaw(AMF, State) -> pause(AMF, State).
+getStreamLength(AMF, #rtmp_client{video_player = Player} = State) ->
+ ?D({"getStreamLength", AMF}),
+ State.
+
%%-------------------------------------------------------------------------
%% @spec (AMF::tuple(),Channel::tuple) -> any()
%% @doc Processes a seek command and responds
View
2 src/ems.erl
@@ -178,7 +178,7 @@ try_method_chain([Module | Applications], Method, Args) ->
%%--------------------------------------------------------------------
check_app([], _Command, _Arity) ->
- 'apps_rtmp';
+ unhandled;
check_app([Module | Applications], Command, Arity) ->
case respond_to(Module, Command, Arity) of
View
13 src/ems_rtmp.erl
@@ -227,14 +227,12 @@ command(#channel{type = Type} = Channel, State)
command(#channel{type = ?RTMP_INVOKE_AMF0} = Channel, State) ->
AMF = amf0:decode(Channel#channel.msg),
#amf{command = Command} = AMF,
- App = ems:check_app(State,Command, 2),
- App:Command(AMF, State);
+ call_function(ems:check_app(State,Command, 2), Command, State, AMF);
command(#channel{type = ?RTMP_INVOKE_AMF3} = Channel, State) ->
AMF = amf3:decode(Channel#channel.msg),
#amf{command = Command} = AMF,
- App = ems:check_app(State,Command, 2),
- App:Command(AMF, State);
+ call_function(ems:check_app(State,Command, 2), Command, State, AMF);
command(#channel{type = ?RTMP_TYPE_SO_AMF0, msg = Message}, State) ->
decode_shared_object_amf0(Message, State);
@@ -245,6 +243,13 @@ command(#channel{type = Type}, State) ->
?D({"Unhandled message type", Type}),
State.
+call_function(unhandled, Command, #rtmp_client{addr = IP, port = Port} = State, #amf{args = Args}) ->
+ error_logger:error_msg("Client ~p:~p requested unknown function ~p/~p", [IP, Port, Command, length(Args)]),
+ State;
+
+call_function(App, Command, State, AMF) ->
+ App:Command(AMF, State).
+
decode_shared_object_amf0(<<>>, State) -> State;
decode_shared_object_amf0(<<Length:16, SharedObject:Length/binary, _VersionFlags:12/binary, EventType,
View
35 src/media/media_provider.erl
@@ -101,10 +101,10 @@ handle_call({find, Name}, _From, MediaProvider) ->
{reply, find_in_cache(Name, MediaProvider), MediaProvider};
handle_call({open, Name}, {_Opener, _Ref}, MediaProvider) ->
- {reply, open_media_entry(Name, detect_type(Name), MediaProvider), MediaProvider};
+ {reply, open_media_entry(detect_type(Name), MediaProvider), MediaProvider};
handle_call({open, Name, Type}, {_Opener, _Ref}, MediaProvider) ->
- {reply, open_media_entry(Name, Type, MediaProvider), MediaProvider};
+ {reply, open_media_entry({Name, Type}, MediaProvider), MediaProvider};
handle_call(entries, _From, #media_provider{opened_media = OpenedMedia} = MediaProvider) ->
Entries = lists:map(
@@ -124,7 +124,11 @@ find_in_cache(Name, #media_provider{opened_media = OpenedMedia}) ->
_ -> undefined
end.
-open_media_entry(Name, Type, #media_provider{opened_media = OpenedMedia} = MediaProvider) ->
+
+open_media_entry({Name, notfound}, _) ->
+ {notfound, "No file "++Name};
+
+open_media_entry({Name, Type}, #media_provider{opened_media = OpenedMedia} = MediaProvider) ->
case find_in_cache(Name, MediaProvider) of
undefined ->
case ems_sup:start_media(Name, Type) of
@@ -147,17 +151,32 @@ detect_type(Name) ->
detect_mpeg_ts(Name) ->
{ok, Re} = re:compile("http://(.*)"),
case re:run(Name, Re) of
- {match, _Captured} -> mpeg_ts;
+ {match, _Captured} -> {Name, mpeg_ts};
_ -> detect_file(Name)
end.
detect_file(Name) ->
- FileName = filename:join([file_play:file_dir(), Name]),
- case filelib:is_regular(FileName) of
- true -> file;
- _ -> live
+ case check_path(Name) of
+ true -> {Name, file};
+ _ -> detect_prefixed_file(Name)
+ end.
+
+detect_prefixed_file("flv:"++Name) ->
+ case check_path(Name) of
+ true -> {Name, file};
+ _ -> {Name, notfound}
+ end;
+
+detect_prefixed_file("mp4:"++Name) ->
+ case check_path(Name) of
+ true ->
+ ?D({"File found", Name}),
+ {Name, file};
+ _ -> {Name, notfound}
end.
+check_path(Name) ->
+ filelib:is_regular(filename:join([file_play:file_dir(), Name])).
%%-------------------------------------------------------------------------
%% @spec (Msg, State) ->{noreply, State} |
View
6 wwwroot/index.html
@@ -18,7 +18,11 @@
}
</script>
<div class="container">
- <div class="span-24 last"><h3 style="float: left; margin-right: 2em"><a href="/admin">Admin</a></h3> <h3 style="float: left; margin-right: 2em"><a href="/chat.html">Chat</a></h3></div>
+ <div class="span-24 last">
+ <h3 style="float: left; margin-right: 2em"><a href="/admin">Admin</a></h3>
+ <h3 style="float: left; margin-right: 2em"><a href="/chat.html">Chat</a></h3>
+ <h3 style="float: left; margin-right: 2em"><a href="/longtail/index.html">JWV Player</a></h3>
+ </div>
<div class="span-16">
<object width="600" height="620" type="application/x-shockwave-flash" id="flash-program-player" name="flash-program-player" data="player/Player.swf">

0 comments on commit 7631edb

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