Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
Added ability to store in directories
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlapshin committed Nov 26, 2009
1 parent 46ed782 commit 7a33bb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/media/media_provider.erl
Expand Up @@ -133,6 +133,7 @@ open_media_entry({Name, Type}, #media_provider{opened_media = OpenedMedia} = Med
undefined -> undefined ->
case ems_sup:start_media(Name, Type) of case ems_sup:start_media(Name, Type) of
{ok, Pid} -> {ok, Pid} ->
?D({"ZZZ:", Type, Pid}),
link(Pid), link(Pid),
ets:insert(OpenedMedia, #media_entry{name = Name, handler = Pid}), ets:insert(OpenedMedia, #media_entry{name = Name, handler = Pid}),
?D({"Opened", Type, Name, Pid}), ?D({"Opened", Type, Name, Pid}),
Expand Down
4 changes: 3 additions & 1 deletion src/media/stream_media.erl
Expand Up @@ -57,6 +57,7 @@ init([Name, record]) ->
Clients = ets:new(clients, [set, private]), Clients = ets:new(clients, [set, private]),
FileName = filename:join([file_play:file_dir(), Name ++ ".flv"]), FileName = filename:join([file_play:file_dir(), Name ++ ".flv"]),
(catch file:delete(FileName)), (catch file:delete(FileName)),
ok = filelib:ensure_dir(FileName),
Header = flv:header(#flv_header{version = 1, audio = 1, video = 1}), Header = flv:header(#flv_header{version = 1, audio = 1, video = 1}),
?D({"Recording to file", FileName}), ?D({"Recording to file", FileName}),
case file:open(FileName, [write, {delayed_write, 1024, 50}]) of case file:open(FileName, [write, {delayed_write, 1024, 50}]) of
Expand All @@ -65,6 +66,7 @@ init([Name, record]) ->
Recorder = #media_info{type=record, device = Device, file_name = FileName, ts_prev = 0, clients = Clients}, Recorder = #media_info{type=record, device = Device, file_name = FileName, ts_prev = 0, clients = Clients},
{ok, Recorder, ?TIMEOUT}; {ok, Recorder, ?TIMEOUT};
_Error -> _Error ->
error_logger:error_msg("Failed to start recording stream to ~p because of ~p", [FileName, _Error]),
ignore ignore
end. end.


Expand Down Expand Up @@ -120,7 +122,7 @@ handle_call({set_owner, _Owner}, _From, #media_info{owner = Owner} = MediaInfo)


handle_call({publish, Channel}, _From, #media_info{device = Device, clients = Clients} = Recorder) -> handle_call({publish, Channel}, _From, #media_info{device = Device, clients = Clients} = Recorder) ->
Tag = ems_flv:to_tag(Channel), Tag = ems_flv:to_tag(Channel),
?D({"Record",Channel#channel.type, Channel#channel.timestamp}), % ?D({"Record",Channel#channel.type, Channel#channel.timestamp}),
case Device of case Device of
undefined -> ok; undefined -> ok;
_ -> file:write(Device, Tag) _ -> file:write(Device, Tag)
Expand Down

0 comments on commit 7a33bb1

Please sign in to comment.