You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: create_new_plugin/create_new_plugin.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# Creating your own plugin
1
+
# Create your own plugin
2
2
3
3
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.
4
4
5
5
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.
6
6
7
-
# Membrane plugin template
7
+
##Membrane plugin template
8
8
9
9
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.
10
10
It defines necessary dependencies as well as other project specs, e.g. formatting, and guarantees you compliance with other Membrane components.
Copy file name to clipboardExpand all lines: get_started_with_membrane/get_started_with_membrane.md
+8-8
Original file line number
Diff line number
Diff 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
50
50
51
51
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.
52
52
53
-
###Prerequisites
53
+
## Prerequisites
54
54
55
55
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:
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).
67
67
68
-
###Creating a Project
68
+
## Creating a Project
69
69
70
70
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:
71
71
> 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
91
91
]
92
92
end
93
93
```
94
-
###Our first Pipeline
94
+
## Our first Pipeline
95
95
96
96
The pipeline is one of the basic concepts of Membrane. It's a schema of how the data packets are flowing through our application.
97
97
98
-
####Pipeline behaviour
98
+
### Pipeline behaviour
99
99
100
100
Let's start with declaring that we'll be using the `Membrane.Pipeline` behaviour:
101
101
@@ -127,7 +127,7 @@ Since we want to spawn children processes and link them, we will use the [`spec_
127
127
128
128
>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)
129
129
130
-
####Elements
130
+
### Elements
131
131
132
132
The elements we'd like to use to play our mp3 will be:
133
133
@@ -157,7 +157,7 @@ children = %{
157
157
158
158
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.
159
159
160
-
####Linking elements
160
+
### Linking elements
161
161
162
162
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:
163
163
@@ -172,7 +172,7 @@ links = [
172
172
173
173
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 🎶
174
174
175
-
####Parent Spec
175
+
### Parent Spec
176
176
177
177
Last but not least we need group our elements and links together into a proper structure:
178
178
@@ -225,7 +225,7 @@ defmodule Hello do
225
225
end
226
226
```
227
227
228
-
###Running a pipeline
228
+
## Running a pipeline
229
229
230
230
You can start your pipeline from any place in the code but it's convenient to use Elixir's interactive console:
Copy file name to clipboardExpand all lines: glossary/glossary.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
# Glossary
1
2
## Multimedia
2
3
+ <aname="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).
3
4
+ <aname="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 @@
31
32
+ <aname="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.
32
33
+ <aname="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.
33
34
34
-
35
35
## Membrane Framework
36
36
+ <aname="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.
37
37
+ <aname="caps"></a> **Caps**(abbr. from capabilities) define [pads](#pad) specification, allowing us to determine whether two elements are compatible with each other.
The scope of this tutorial covers the process of creating your own video room with the use of the Membrane framework.
13
12
# 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?
14
16
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.
15
17
Taking advantage of recent technological improvements and state-of-the-art tools introduced in the field of data transmission, video streaming
16
18
has become accessible to everyone at the scale not known previously.
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!
15
15
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.
18
18
19
19
## Template downloading
20
20
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
32
32
33
33
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.
34
34
35
-
#Install native dependencies
35
+
## Native dependencies installing
36
36
First, some native dependencies are needed. Here is how you can install them and setup the required environment variables.
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.
66
66
You won't need to install any native dependencies there nor export environmental variables - however **your computer cannot be running on M1 processor**.
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.
85
85
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:
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:
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 ;)
129
129
<br><br>
130
130
[NEXT - System architecture](3_SystemArchitecture.md)<br>
0 commit comments