Skip to content

Commit 36163e6

Browse files
authored
Merge pull request #23 from membraneframework/improve-headers-structure
Improve headers structure
2 parents f1cb09f + 4c07280 commit 36163e6

10 files changed

+74
-70
lines changed

create_new_plugin/create_new_plugin.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Creating your own plugin
1+
# Create your own plugin
22

33
During the development of Membrane Framework we aim at designing fewer, but higher quality plugins. However, we also kept extendability and reusability in mind. That's why it is easy for developers like you to create their own custom plugin, which satisfies their needs.
44

55
In this short guide we provide you with an overview of how to create your own Membrane plugin and how to integrate it into your project.
66

7-
# Membrane plugin template
7+
## Membrane plugin template
88

99
To create a new plugin, we recommend using the [template](https://github.com/membraneframework/membrane_template_plugin) that has been made for this very purpose and which will be the base of your plugin.
1010
It defines necessary dependencies as well as other project specs, e.g. formatting, and guarantees you compliance with other Membrane components.

get_started/simple_pipeline.md renamed to get_started_with_membrane/get_started_with_membrane.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ That might not look too simple for now but don't worry, there'll be a lot of new
5050

5151
The code above is one of the simplest examples of Membrane usage. It plays an mp3 file through your device's `portaudio`. Let's make it work.
5252

53-
### Prerequisites
53+
## Prerequisites
5454

5555
First we need to get all the libraries that Membrane needs to operate in our case. You can read about them more if you'd like, but for now we'll just jump to installation:
5656

@@ -65,7 +65,7 @@ $ brew install clang-format portaudio ffmpeg libmad pkg-config
6565

6666
Alternatively, you can use our docker image that already contains all libraries you need to smoothly run any membrane code. You can read more about how to do it [here](https://tutorials.membraneframework.org/tutorials/videoroom/2_EnvironmentPreparation.html#setting-environment-with-the-use-of-docker).
6767

68-
### Creating a Project
68+
## Creating a Project
6969

7070
By installing Elixir you'll get a bunch of useful tools. One of them is [Mix](https://hexdocs.pm/mix/Mix.html). As you can read in its documentation preface:
7171
> Mix is a build tool that provides tasks for creating, compiling, and testing Elixir projects, managing its dependencies, and more.
@@ -91,11 +91,11 @@ defp deps do
9191
]
9292
end
9393
```
94-
### Our first Pipeline
94+
## Our first Pipeline
9595

9696
The pipeline is one of the basic concepts of Membrane. It's a schema of how the data packets are flowing through our application.
9797

98-
#### Pipeline behaviour
98+
### Pipeline behaviour
9999

100100
Let's start with declaring that we'll be using the `Membrane.Pipeline` behaviour:
101101

@@ -127,7 +127,7 @@ Since we want to spawn children processes and link them, we will use the [`spec_
127127

128128
>If the concept of callbacks and behaviours is new to you, you should probably take some time to read about OTP in Elixir (especially the part starring GenServer and Supervisor). You can find the proper guide [here](https://elixir-lang.org/getting-started/mix-otp/agent.html)
129129
130-
#### Elements
130+
### Elements
131131

132132
The elements we'd like to use to play our mp3 will be:
133133

@@ -157,7 +157,7 @@ children = %{
157157

158158
The keys in the `children` keyword list (`file`, `decoder`, `converter`, `portaudio`) are just convenient names we gave our elements to refer to them later. We're going to need them for linking.
159159

160-
#### Linking elements
160+
### Linking elements
161161

162162
Now we should link them in the proper order. Each Membrane Element can be one of three types: Source, Sink or Filter. The main difference is that Source provides only output pads, Sink only input and Filter both input and output pads. That means only a Source element start pipelines (it's not prepared to receive any data from other elements), Sink can only end pipelines (it will not send any data to subsequent elements), and Filters can be in the middle (they receive, process and send data further). In our case the links declaration will look like this:
163163

@@ -172,7 +172,7 @@ links = [
172172

173173
The file Source reads bytes from our mp3 file and sends them to decoder. Decoder, after decoding, sends them to converter. Converter, after conversion sends them to our portaudio sink, which receives them and plays music through Portaudio 🎶
174174

175-
#### Parent Spec
175+
### Parent Spec
176176

177177
Last but not least we need group our elements and links together into a proper structure:
178178

@@ -225,7 +225,7 @@ defmodule Hello do
225225
end
226226
```
227227

228-
### Running a pipeline
228+
## Running a pipeline
229229

230230
You can start your pipeline from any place in the code but it's convenient to use Elixir's interactive console:
231231

glossary/glossary.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Glossary
12
## Multimedia
23
+ <a name="packet"></a> **Packet** is a formatted unit of data transmitted over network. In order to send data over network it has to be fragmented into packets, which size is limited by [MTU(Maximum Transfer Unit)](https://en.wikipedia.org/wiki/Maximum_transmission_unit) - 1500 bytes when using [Ethernet](https://en.wikipedia.org/wiki/Ethernet_frame).
34
+ <a name="frame"></a> **Frame** can refer to either [network frame](https://en.wikipedia.org/wiki/Frame_(networking)) or **media frame**, which is a basic data unit used by media coding formats. In particular one media frame can represent a single image in a video.
@@ -31,7 +32,6 @@
3132
+ <a name="mcu"></a> **MCU**([Multipoint Control Unit](https://millo-l.github.io/WebRTC-implementation-method-Mesh-SFU-MCU/#23-mcumulti-point-control-unit-server)) is an architecture consisting of a single server, which receives incoming streams from all participants, mixes the streams, and sends them to each of the participants.
3233
+ <a name="p2p"></a> **P2P**([Peer to Peer](https://millo-l.github.io/WebRTC-implementation-method-Mesh-SFU-MCU/#21-signaling-serverp2pmesh)) is an architecture in which each participant is directly connected to all other participants, which eliminates the need for MCU or SFU.
3334

34-
3535
## Membrane Framework
3636
+ <a name="pad"></a> **Pad** is an input or output of an [elements](#element) or a [bin](#bin). Output pads of one element are connected to input pads of another element or bin.
3737
+ <a name="caps"></a> **Caps**(abbr. from capabilities) define [pads](#pad) specification, allowing us to determine whether two elements are compatible with each other.

videoroom/1_Introduction.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ description: >-
99
github.repository_url: https://github.com/membraneframework/membrane_mp4_plugin
1010
---
1111

12-
The scope of this tutorial covers the process of creating your own video room with the use of the Membrane framework.
1312
# Introduction
13+
The scope of this tutorial covers the process of creating your own video room with the use of the Membrane framework.
14+
15+
## What are we doing here?
1416
It hasn't been that long ago when video rooms have become quite a common tool used in many fields of our life. We use them when we want to have an impression of meeting our beloved ones in the manner as they were sitting just next to us. We use them at work, to synchronize our work progress and exchange information between us and our colleagues.
1517
Taking advantage of recent technological improvements and state-of-the-art tools introduced in the field of data transmission, video streaming
1618
has become accessible to everyone at the scale not known previously.

videoroom/2_EnvironmentPreparation.md

+53-53
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ description: >-
77
<br> <b>Forum:</b> <a style="color: white" href=https://elixirforum.com/c/elixir-framework-forums/membrane-forum/104/>Membrane Forum</a>
88
</div>
99
---
10-
# Getting started
10+
# Environment preparation
1111

1212
## Elixir installation
13-
I don't think I can describe it any better: [How to install Elixir](https://elixir-lang.org/install.html).
14-
But do not forget to add the elixir bin to your PATH variable!
13+
I don't think I can describe it any better: [How to install Elixir](https://elixir-lang.org/install.html).
14+
But do not forget to add the elixir bin to your PATH variable!
1515

16-
Take your time and make yourself comfortable with Elixir. Check if you can run Elixir's interactive terminal and if you can compile Elixir's source files with the Elixir compiler.
17-
You can also try to create a new Mix project - we will be using [Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html) as the build automation tool all along with the tutorial.
16+
Take your time and make yourself comfortable with Elixir. Check if you can run Elixir's interactive terminal and if you can compile Elixir's source files with the Elixir compiler.
17+
You can also try to create a new Mix project - we will be using [Mix](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html) as the build automation tool all along with the tutorial.
1818

1919
## Template downloading
2020
Once we have the development environment set up properly (let's hope so!) we can start to work on our project. We don't want you to do it from scratch as the development requires some dull playing around with UI, setting the dependencies, etc. - we want to provide you only the meat! That is why we would like you to download the template project with core parts of the code missing. You can do it by typing:
@@ -32,24 +32,24 @@ git checkout template/start
3232

3333
In case you find yourself lost along with the tutorial, feel free to check the suggested implementation provided by us, which is available on the `template/end` branch of this repository.
3434

35-
# Install native dependencies
35+
## Native dependencies installing
3636
First, some native dependencies are needed. Here is how you can install them and setup the required environment variables.
3737

38-
## Mac OS with M1
38+
### Mac OS with M1
3939
```
4040
brew install node srtp libnice clang-format ffmpeg
4141
export C_INCLUDE_PATH=/opt/homebrew/Cellar/libnice/0.1.18/include:/opt/homebrew/Cellar/opus/1.3.1/include:/opt/homebrew/Cellar/[email protected]/1.1.1l_1/include
4242
export LIBRARY_PATH=/opt/homebrew/Cellar/opus/1.3.1/lib
4343
export PKG_CONFIG_PATH=/opt/homebrew/Cellar/[email protected]/1.1.1l_1/lib/pkgconfig/
4444
```
4545

46-
## Mac OS with Intel
46+
### Mac OS with Intel
4747
```
4848
brew install node srtp libnice clang-format ffmpeg
4949
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
5050
```
5151

52-
## Ubuntu
52+
### Ubuntu
5353

5454
```
5555
sudo apt-get install npm build-essential pkg-config libssl-dev libopus-dev libsrtp2-dev libnice-dev libavcodec-dev libavformat-dev libavutil-dev
@@ -61,7 +61,7 @@ If you installed Elixir from ESL repo, make sure the following erlang packages a
6161
sudo apt-get install erlang-dev erlang-parsetools erlang-src
6262
```
6363

64-
# Setting environment with the use of Docker
64+
### Setting environment with the use of Docker
6565
Alternatively to the steps described in the section above, you can make use of the docker image we have prepared for the purpose of this tutorial.
6666
You won't need to install any native dependencies there nor export environmental variables - however **your computer cannot be running on M1 processor**.
6767

@@ -83,49 +83,49 @@ docker run -p 4000:4000 -it -v `pwd`:/videoroom membraneframeworklabs/docker_mem
8383

8484
After running the command, a container terminal will be attached to your terminal. You will be able to find the project code inside the container in the `/videoroom` directory.
8585

86-
# What do we have here?
87-
Let's make some reconnaissance.
88-
First, let's run the template.
89-
Before running the template we need to install the dependencies using:
90-
```
91-
mix deps.get
92-
npm ci --prefix=assets
93-
```
94-
95-
Then you can simply run the Phoenix server with the following command:
96-
```
97-
mix phx.server
98-
```
99-
If everything went well the application should be available on [http://localhost:4000](http://localhost:4000/).
100-
101-
Play around...but it is not that much to do! We have better inspect what is the structure of our project.
102-
Does the project structure reassemble you the structure of a Phoenix project? (in fact, it should!). We will go through the directories in our project.
103-
+ **assets/** <br>
104-
You can find the front end of our application. The most interesting subdirectory here is src/ - we will be putting our typescript files there. For now, the following files should be present there:
105-
+ **consts.ts** - as the name suggests, you will find there some constant values - media constrains and our local peer id
106-
+ **index.ts** - this one should be empty. It will act as an initialization point for our application and later on, we will spawn a room object there.
107-
+ **room_ui.ts** - methods which modify DOM are put there. You will find these methods helpful while implementing your room's logic - you will be able to simply call a method in order to put a next video tile among previously present video tiles and this whole process (along with rescaling or moving the tiles so they are nicely put on the screen) will be performed automatically
108-
+ **config/** <br>
109-
Here you can find configuration files for given environments. There is nothing we should be interested in.
110-
+ **deps/** <br>
111-
Once you type ```mix deps.get``` all the dependencies listed in mix.lock file will get downloaded and be put into this directory. Once again - this is just how mix works and we do not care about this directory anyhow.
112-
+ **lib/** <br>
113-
This directory contains the server's logic. As mentioned previously, the Phoenix server implements Model-View-Controller architecture so the structure of this directory will reflect this architecture.
114-
The only .ex file in this directory is `videoroom_web.ex` file - it defines the aforementioned parts of the system - **controller** and **view**. Moreover,
115-
it defines ```router``` and ```channel``` - the part of the system which is used for communication. This file is generated automatically with the Phoenix project generator
116-
and there are not that many situations in which you should manually change it.
117-
+ **videoroom/** <br>
118-
This directory contains the business logic of our application, which stands for M (model) in MVC architecture. For now, it should only contain application.ex file which defines the Application module for our video room. As each [application](https://hexdocs.pm/elixir/1.12/Application.html), it can be loaded, started, and stopped, as well as it can bring to life its own children (which constitute the environment created by an application). Later on, we will put into this directory files which will provide some logic of our application - for instance, Videoroom.Room module will be defined there.
119-
+ **videoroom_web/**<br>
120-
This directory contains files that stand for V (view) and C (controller) in the MVC architecture.
121-
As you can see, there are already directories with names "views" and "controllers" present here. The aforementioned (tutorial) (the one available in the "helpful links" sections) describes the structure and contents of this directory in a really clear way so I don't think there is a need to repeat this description here. The only thing I would like to point out is the way in which we are loading our custom Javascript scripts. Take a look at lib/videoroom_web/room/index.html.eex file (as the Phoenix tutorial says, this file should contain an EEx template for your room controller ) - you will find the following line there:
122-
```html
123-
<script src="<%= static_path(@conn, "/js/room.js") %>"></script>
124-
```
125-
As you can see, we are loading a script which is placed in `/js/room.js` (notice, that a path provided there is passed in respect to priv/static/ directory which holds files generated from typescript scripts in assets/src/ directory)
126-
127-
+ **priv/static/** <br>
128-
Here you will find static assets. They can be generated, for instance, from the files contained in assets/ directory (.ts which are in assets/src are converted into .js files put inside priv/static/js). Not interesting at all, despite the fact, that we needed to load /js/room.js script file from here ;)
86+
## What do we have here?
87+
Let's make some reconnaissance.
88+
First, let's run the template.
89+
Before running the template we need to install the dependencies using:
90+
```
91+
mix deps.get
92+
npm ci --prefix=assets
93+
```
94+
95+
Then you can simply run the Phoenix server with the following command:
96+
```
97+
mix phx.server
98+
```
99+
If everything went well the application should be available on [http://localhost:4000](http://localhost:4000/).
100+
101+
Play around...but it is not that much to do! We have better inspect what is the structure of our project.
102+
Does the project structure reassemble you the structure of a Phoenix project? (in fact, it should!). We will go through the directories in our project.
103+
+ **assets/** <br>
104+
You can find the front end of our application. The most interesting subdirectory here is src/ - we will be putting our typescript files there. For now, the following files should be present there:
105+
+ **consts.ts** - as the name suggests, you will find there some constant values - media constrains and our local peer id
106+
+ **index.ts** - this one should be empty. It will act as an initialization point for our application and later on, we will spawn a room object there.
107+
+ **room_ui.ts** - methods which modify DOM are put there. You will find these methods helpful while implementing your room's logic - you will be able to simply call a method in order to put a next video tile among previously present video tiles and this whole process (along with rescaling or moving the tiles so they are nicely put on the screen) will be performed automatically
108+
+ **config/** <br>
109+
Here you can find configuration files for given environments. There is nothing we should be interested in.
110+
+ **deps/** <br>
111+
Once you type ```mix deps.get``` all the dependencies listed in mix.lock file will get downloaded and be put into this directory. Once again - this is just how mix works and we do not care about this directory anyhow.
112+
+ **lib/** <br>
113+
This directory contains the server's logic. As mentioned previously, the Phoenix server implements Model-View-Controller architecture so the structure of this directory will reflect this architecture.
114+
The only .ex file in this directory is `videoroom_web.ex` file - it defines the aforementioned parts of the system - **controller** and **view**. Moreover,
115+
it defines ```router``` and ```channel``` - the part of the system which is used for communication. This file is generated automatically with the Phoenix project generator
116+
and there are not that many situations in which you should manually change it.
117+
+ **videoroom/** <br>
118+
This directory contains the business logic of our application, which stands for M (model) in MVC architecture. For now, it should only contain application.ex file which defines the Application module for our video room. As each [application](https://hexdocs.pm/elixir/1.12/Application.html), it can be loaded, started, and stopped, as well as it can bring to life its own children (which constitute the environment created by an application). Later on, we will put into this directory files which will provide some logic of our application - for instance, Videoroom.Room module will be defined there.
119+
+ **videoroom_web/**<br>
120+
This directory contains files that stand for V (view) and C (controller) in the MVC architecture.
121+
As you can see, there are already directories with names "views" and "controllers" present here. The aforementioned (tutorial) (the one available in the "helpful links" sections) describes the structure and contents of this directory in a really clear way so I don't think there is a need to repeat this description here. The only thing I would like to point out is the way in which we are loading our custom Javascript scripts. Take a look at lib/videoroom_web/room/index.html.eex file (as the Phoenix tutorial says, this file should contain an EEx template for your room controller ) - you will find the following line there:
122+
```html
123+
<script src="<%= static_path(@conn, "/js/room.js") %>"></script>
124+
```
125+
As you can see, we are loading a script which is placed in `/js/room.js` (notice, that a path provided there is passed in respect to priv/static/ directory which holds files generated from typescript scripts in assets/src/ directory)
126+
127+
+ **priv/static/** <br>
128+
Here you will find static assets. They can be generated, for instance, from the files contained in assets/ directory (.ts which are in assets/src are converted into .js files put inside priv/static/js). Not interesting at all, despite the fact, that we needed to load /js/room.js script file from here ;)
129129
<br><br>
130130
[NEXT - System architecture](3_SystemArchitecture.md)<br>
131131
[PREV - Introduction](1_Introduction)<br>

0 commit comments

Comments
 (0)