Skip to content

Commit

Permalink
Merge pull request #3 from membraneframework/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mat-hek authored Jun 6, 2019
2 parents 8a6d0e5 + dde79a7 commit 6d69a30
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 27 deletions.
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2.0
jobs:
build:
docker:
- image: membrane/bionic-membrane:latest
environment:
MIX_ENV: test

working_directory: ~/app

steps:
- checkout
- run: mix deps.get
- run: mix format --check-formatted
- run: mix test
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Membrane Multimedia Framework: MembraneElementSdl
# Membrane Multimedia Framework: SDL element

This package provides an SDL-based video player.
[![Hex.pm](https://img.shields.io/hexpm/v/membrane_element_sdl.svg)](https://hex.pm/packages/membrane_element_sdl)
[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_element_sdl/)
[![CircleCI](https://circleci.com/gh/membraneframework/membrane-element-sdl.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane-element-sdl)

This package provides an [SDL](https://www.libsdl.org/)-based video player.

It is part of [Membrane Multimedia Framework](https://membraneframework.org).

Expand All @@ -24,7 +28,7 @@ The pipeline below displays a sample h264 video from the net (with use of [Hackn

```elixir
defmodule My.Pipeline do
alias Membrane.Element.{FFmpeg.H264, Hackney, Sdl}
alias Membrane.Element.{FFmpeg.H264, Hackney, SDL}
alias Membrane.Pipeline.Spec
use Membrane.Pipeline

Expand All @@ -36,7 +40,7 @@ defmodule My.Pipeline do
},
parser: %H264.Parser{framerate: {30, 1}},
decoder: H264.Decoder,
sdl: Sdl.Sink
sdl: SDL.Player
]

links = %{
Expand All @@ -48,7 +52,6 @@ defmodule My.Pipeline do
{{:ok, %Spec{children: children, links: links}}, %{}}
end
end

```

## Copyright and License
Expand Down
6 changes: 3 additions & 3 deletions bundlex.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Membrane.Element.Sdl.BundlexProject do
defmodule Membrane.Element.SDL.BundlexProject do
use Bundlex.Project

def project do
Expand All @@ -9,8 +9,8 @@ defmodule Membrane.Element.Sdl.BundlexProject do

defp cnodes(_platform) do
[
sink: [
sources: ["sink.c", "cnodeserver.c"],
player: [
sources: ["player.c", "cnodeserver.c"],
deps: [shmex: :lib_cnode, bunch_native: :bunch],
pkg_configs: ["sdl2"]
]
Expand Down
2 changes: 1 addition & 1 deletion c_src/membrane_element_sdl/cnodeserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define _REENTRANT // For some reason __erl_errno is undefined unless _REENTRANT
// is defined
#endif
#include "sink.h"
#include "player.h"
#include <ei.h>
#include <ei_connect.h>
#include <erl_interface.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
#include <sys/mman.h>
#include <unistd.h>

#include "sink.h"
#include "player.h"

int create(int width, int height, State *state) {
char *err_reason = NULL;
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *texture = NULL;

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
err_reason = "init_sdl";
fprintf(stderr, "Error initializing SDL\r\n");
goto exit_create;
}

Expand All @@ -23,23 +22,20 @@ int create(int width, int height, State *state) {
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);

if (!window) {
fprintf(stderr, "Error creating window: %s", SDL_GetError());
err_reason = "create_window";
fprintf(stderr, "Error creating window: %s\r\n", SDL_GetError());
goto exit_create;
}

renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
fprintf(stderr, "Error creating renderer: %s", SDL_GetError());
err_reason = "create_renderer";
fprintf(stderr, "Error creating renderer: %s\r\n", SDL_GetError());
goto exit_create;
}

texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_IYUV,
SDL_TEXTUREACCESS_STREAMING, width, height);
if (!texture) {
fprintf(stderr, "Error creating texture: %s", SDL_GetError());
err_reason = "create_texture";
fprintf(stderr, "Error creating texture: %s\r\n", SDL_GetError());
goto exit_create;
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/membrane_element_sdl.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Membrane.Element.Sdl do
defmodule Membrane.Element.SDL do
@moduledoc false
use Application

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
defmodule Membrane.Element.Sdl.Sink do
defmodule Membrane.Element.SDL.Player do
@moduledoc """
This module provides an [SDL](https://www.libsdl.org/)-based video player sink.
"""

alias Membrane.{Buffer, Time}
alias Membrane.Caps.Video.Raw
alias Bundlex.CNode
Expand All @@ -15,7 +19,7 @@ defmodule Membrane.Element.Sdl.Sink do

@impl true
def handle_stopped_to_prepared(_ctx, state) do
{:ok, cnode} = CNode.start_link(:sink)
{:ok, cnode} = CNode.start_link(:player)
{:ok, %{state | cnode: cnode}}
end

Expand Down
10 changes: 5 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Membrane.Element.Sdl.MixProject do
defmodule Membrane.Element.SDL.MixProject do
use Mix.Project

@version "0.1.0"
@github_url "https://github.com/membraneframework/membrane-element-membrane_element_sdl"
@github_url "https://github.com/membraneframework/membrane-element-sdl"

def project do
[
Expand All @@ -12,9 +12,9 @@ defmodule Membrane.Element.Sdl.MixProject do
compilers: [:unifex, :bundlex] ++ Mix.compilers(),
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
description: "Membrane Multimedia Framework (MembraneElementSdl Element)",
description: "Membrane Multimedia Framework (SDL Element)",
package: package(),
name: "Membrane Element: MembraneElementSdl",
name: "Membrane Element: SDL",
source_url: @github_url,
docs: docs(),
homepage_url: "https://membraneframework.org",
Expand Down Expand Up @@ -56,7 +56,7 @@ defmodule Membrane.Element.Sdl.MixProject do
{:membrane_core, "~> 0.3.0"},
{:membrane_common_c, "~> 0.2.0"},
{:membrane_caps_video_raw, "~> 0.1.0"},
{:bundlex, "~> 0.2.0"},
{:bundlex, "~> 0.2.6"},
{:shmex, "~> 0.2.0"},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.4", only: [:dev], runtime: false}
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"bunch": {:hex, :bunch, "1.1.0", "bf9ca22c788ad4f486afb4d6d5e1211ab09cbee473c5cf370e6e550b1df4bc4b", [:mix], [], "hexpm"},
"bunch_native": {:hex, :bunch_native, "0.2.0", "287a1e3af526df95f3e623faea1c67a7efb4d78ffb827c7a9018ae7528adc29f", [:mix], [{:bundlex, "~> 0.2.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm"},
"bundlex": {:hex, :bundlex, "0.2.5", "dac8288e8388a9ec9855bf786fec59f286440df697708962c270ccd55b2eb0cc", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:secure_random, "~> 0.5", [hex: :secure_random, repo: "hexpm", optional: false]}], "hexpm"},
"bundlex": {:hex, :bundlex, "0.2.6", "230472e4654da17f004a7e4257dfa2ba0caf6945dcbc24e92bd01aa1578b2303", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:secure_random, "~> 0.5", [hex: :secure_random, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.2.1", "cee02918660807cbba9a7229cae9b42d1c6143b768c781fa6cee1eaf03ad860b", [:mix], [], "hexpm"},
Expand Down

0 comments on commit 6d69a30

Please sign in to comment.