mirror of
https://github.com/algora-io/tv.git
synced 2024-11-16 00:58:59 +02:00
keep latest stream segment in memory
This commit is contained in:
parent
6a1ae7592f
commit
1baad3c4ae
@ -7,11 +7,12 @@ defmodule Algora.Storage do
|
||||
@pubsub Algora.PubSub
|
||||
|
||||
@enforce_keys [:video]
|
||||
defstruct @enforce_keys ++ [video_header: <<>>]
|
||||
defstruct @enforce_keys ++ [video_header: <<>>, video_segment: <<>>]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
video: Library.Video.t(),
|
||||
video_header: <<>>
|
||||
video_header: <<>>,
|
||||
video_segment: <<>>
|
||||
}
|
||||
|
||||
@impl true
|
||||
@ -71,14 +72,25 @@ defmodule Algora.Storage do
|
||||
case Library.store_thumbnail(video, video_header <> contents) do
|
||||
{:ok, video} ->
|
||||
broadcast_thumbnails_generated!(video)
|
||||
{:ok, %{state | video: video}}
|
||||
{:ok, %{state | video_segment: contents, video: video}}
|
||||
|
||||
_ ->
|
||||
Membrane.Logger.error("Could not generate thumbnails for video #{video.id}")
|
||||
{:ok, state}
|
||||
{:ok, %{state | video_segment: contents}}
|
||||
end
|
||||
end
|
||||
|
||||
defp process_contents(
|
||||
:video,
|
||||
_name,
|
||||
contents,
|
||||
_metadata,
|
||||
%{type: :segment, mode: :binary},
|
||||
state
|
||||
) do
|
||||
{:ok, %{state | video_segment: contents}}
|
||||
end
|
||||
|
||||
defp process_contents(_parent_id, _name, _contents, _metadata, _ctx, state) do
|
||||
{:ok, state}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user