-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Update
Component
docs + explain main concepts (#289)
- Loading branch information
Showing
32 changed files
with
613 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
sidebar_position: 7 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-Image.md" | ||
|
||
# Image | ||
|
||
A component for rendering images. | ||
|
||
:::note | ||
To use this component, you need to first register the image with matching `image_id` using [`RegisterRenderer`](../routes#register-renderer) request. | ||
::: | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
import Docs from "@site/pages/api/generated/component-InputStream.md" | ||
|
||
# InputStream | ||
|
||
`InputStream` represents an incoming RTP stream. | ||
|
||
:::note | ||
To use this component, you need to first register the stream with matching `input_id` using [`RegisterInputStream`](../routes#register-input-stream) request. | ||
::: | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-Rescaler.md" | ||
|
||
# Rescaler | ||
|
||
`Rescaler` is a layout component responsible for rescaling other components. | ||
|
||
### Absolute positioning | ||
|
||
A component is absolutely positioned if it defines fields like `top`, `left`, `right`, `bottom`, or `rotation`. | ||
Those fields define the component's position relative to its parent. However, to respect those | ||
values, the parent component has to be a layout component that supports absolute positioning. | ||
|
||
- `Rescaler` **does not** support absolute positioning for its child components. All children will still be rendered, but all fields like `top`, `left`, `right`, `bottom`, and `rotation` will be ignored. | ||
- `Rescaler` can be absolutely positioned relative to its parent, if the parent component supports it. | ||
|
||
### Static positioning | ||
|
||
`Rescaler` always have exactly one child that will be proportionally rescaled to match the parent. | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
sidebar_position: 6 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-Shader.md" | ||
|
||
# Shader | ||
|
||
`Shader` applies transformation defined via WGSL shader on its children. [Learn more.](../../concept/shaders) | ||
|
||
:::note | ||
To use this component, you need to first register the shader with matching `shader_id` using [`RegisterRenderer`](../routes#register-renderer) request. | ||
::: | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-Text.md" | ||
|
||
# Text | ||
|
||
A component for rendering text. | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-Tiles.md" | ||
|
||
# Tiles | ||
|
||
`Tiles` is a layout component that places all the child components next to each other while maximizing the use of available space. The component divides its area into multiple rectangles/tiles, one for each child component. All of those rectangles are the same size and do not overlap over each other. | ||
|
||
### Absolute positioning | ||
|
||
- `Tiles` **does not** support absolute positioning for its child components. All children will still be rendered, but all fields like `top`, `left`, `right`, `bottom`, and `rotation` will be ignored. | ||
- `Tiles` **can not** be absolutely positioned relative to it's parent. | ||
|
||
### Static positioning | ||
|
||
The component calculates the number of rows and columns that children should be divided into. The result is based on: | ||
- The size of the `Tiles` component. | ||
- Aspect ratio of a single tile (`tile_aspect_ratio` field). | ||
- Number of children components. | ||
|
||
An optimal number of rows and columns should result in a layout that covers the biggest part of its area. Children components are placed based on their order, from left to right, and row-by-row from top to bottom. | ||
|
||
When placing a child component inside a tile, the component might change its size. | ||
- Non-layout component scales proportionally to fit inside the parent. If the aspect ratios of a child and its parent do not match, then the component will be centered vertically or horizontally. | ||
- Layout component takes the `width` and `height` of a tile. It ignores its own `width`/`height` fields if they are defined. | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-View.md" | ||
|
||
# View | ||
|
||
`View` is the compositor's core layout mechanism. Its role is analogous to the | ||
`<div>` tag in HTML. It provides a container with basic styling that can be further composed. | ||
|
||
### Absolute positioning | ||
|
||
A component is absolutely positioned if it defines fields like `top`, `left`, `right`, `bottom`, or `rotation`. | ||
Those fields define the component's position relative to its parent. However, to respect those | ||
values, the parent component has to be a layout component that supports absolute positioning. | ||
|
||
- `View` supports absolute positioning for its child components. | ||
- `View` can be absolutely positioned relative to its parent if the parent component supports it. | ||
|
||
### Static positioning | ||
|
||
When children of a `View` component have a static position, they are placed next to each other. | ||
|
||
#### For `direction=row`: | ||
|
||
Children of a `View` component form a row, with items aligned to the top. The size of each child will be calculated in the following way: | ||
- If the `width` or `height` of a child component is defined, then those values take priority. | ||
- If the `height` is not defined, the component will have the same `height` as its parent. | ||
- If the `width` is not defined, we calculate the sum `width` of all components with that value defined. | ||
- If it is larger than the parent's `width`, then the `width` of the rest of the components is zero. | ||
- If it is smaller than the parent's `width`, calculate the difference and divide the resulting value equally between all children with unknown widths. | ||
|
||
#### For `direction=column`: | ||
|
||
Analogous to the `direction=row` case, but children form a column instead, with items aligned to the left. | ||
|
||
<Docs/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
sidebar_position: 8 | ||
--- | ||
import Docs from "@site/pages/api/generated/component-WebView.md" | ||
|
||
# WebView | ||
|
||
`WebView` renders a website using Chromium engine embedded inside the compositor. | ||
|
||
:::note | ||
To use this component, you need to first register the web renderer instance with matching `instance_id` using [`RegisterRenderer`](../routes#register-renderer) request. | ||
::: | ||
|
||
:::warning | ||
Only one component can use specific `instance_id` at the time. | ||
::: | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Docs from "@site/pages/api/generated/renderer-Image.md" | ||
|
||
# Image | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
import Docs from "@site/pages/api/generated/renderer-Shader.md" | ||
|
||
# Shader | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Docs from "@site/pages/api/generated/renderer-WebRenderer.md" | ||
|
||
# Web Renderer | ||
|
||
<Docs /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Component | ||
|
||
A component is a basic block used to define how video streams are composed. | ||
|
||
## Layout Components | ||
|
||
Layout component is a type of component responsible for defining the size and position of other components. | ||
|
||
Currently, we support the following layout components: | ||
- [View](../api/components/View) | ||
- [Tiles](../api/components/Tiles) | ||
- [Rescaler](../api/components/Rescaler) | ||
|
||
Learn more about layouts [here](./layouts). | ||
|
||
## Non-layout components | ||
|
||
Non-layout components have their unique behaviors. In most cases, they do not support or interact with mechanisms introduced by layouts. Sometimes, they even override the behavior of other components. | ||
|
||
For example, if you create a `Shader` component with a `View` component as its child, the properties like `width`, `top`, `rotation` ..., will be ignored. A `Shader` component, when rendering, receives all its children as GPU textures. It will just execute whatever the user-provided shader source implements without applying any layout properties that component might have. | ||
|
||
## Scene | ||
|
||
Component tree that represents what will be rendered for a specific output. | ||
|
||
Example scene: | ||
```typescript | ||
{ | ||
"outputs": [ | ||
{ | ||
"output_id": "example_output_1" | ||
"root": { | ||
"type": "view", | ||
"background_color_rgba": "#0000FFFF" | ||
"children": [ | ||
{ | ||
"type": "input-stream", | ||
"input_id": "example_input_1", | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
In the example above, we define a scene for a single output `example_output_1` where an input stream `example_input_1` is rendered inside a [`View` component](../api/components/View). | ||
|
||
:::note | ||
You need to register `"example_output_1"` and `"example_input_1"` before using them in the scene definition. | ||
::: | ||
|
||
### Renderers | ||
|
||
Renderers are entities capable of producing frames (in some cases based on some provided input). The renderer could be a WGSL shader, web renderer instance, or an image. They are not directly part of the scene definition. Instead, components are using them as part of their internal implementation. | ||
|
||
For example: | ||
- [The `Shader` component](../api/components/Shader) has a field `shader_id` that identifies a [`Shader` renderer](../api/renderers/Shader). | ||
- [The `Image` component](../api/components/Image) has a field `image_id` that identifies an [`Image` renderer](../api/renderers/Image). | ||
|
||
Every renderer, except [`WebRenderer`](../api/renderers/web), can be used in multiple components. For example, you can create a single `Shader` renderer that applies some effect and use that `shader_id` in multiple `Shader` components. | ||
|
||
|
Oops, something went wrong.