-
Notifications
You must be signed in to change notification settings - Fork 262
Decouple UI from the frontend library #110
Decouple UI from the frontend library #110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed all the changes now. I will be doing a QA pass on it too to look for runtime issues today :)
Did a few commits to change some styling things. But also working on fixing a bug(s) where MaxBitrate is getting set to 0 even though initial settings from UE sends a non-zero value. First bug was values are sent as bps but treated internally as kbps, so a division needs to happen on receipt. The second is that the setting of this value needs to be split out from the structure containing Min/Max bitrate and FPS. Basically this bit of code is the problem child I am talking about: this.config._addOnNumericSettingChangedListener(
NumericParameters.WebRTCMaxBitrate,
(newValue: number) => {
Logger.Log(
Logger.GetStackTrace(),
'-------- Sending web rtc settings --------',
7
);
const webRtcSettings: WebRTCSettings = {
FPS: this.config.getNumericSettingValue(
NumericParameters.WebRTCFPS
),
MinBitrate:
this.config.getNumericSettingValue(
NumericParameters.WebRTCMinBitrate
) * 1000, /* kbps to bps */
MaxBitrate: newValue * 1000 /* kbps to bps */
};
this.webRtcController.sendWebRtcSettings(webRtcSettings);
Logger.Log(
Logger.GetStackTrace(),
'-------------------------------------------',
7
);
}
); The
|
Good catch! Seems to have been broken in one of the recent commits where I removed linking from the basic
Nice, the event functions at top level look so much cleaner!
Looks good to me! |
68c3e94
to
353f565
Compare
(Force-pushed to rewrite the latest commit with a signature.) |
While documenting the EventEmitter events, noticed that Needed to check for both states since according to https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/iceconnectionstatechange_event#usage_notes "connected" can be sometimes skipped. And on the other hand we cannot wait for "completed" because it might happen several seconds after the connection has already been established. I'm not fully happy with the extra local context boolean I had to add there to keep track if the event has been already dispatched, but that was the simplest way to ensure that the event is emitted at most once per |
Yeah, it is annoying that icestatechange works like that. Anyways, I just reviewed the commit, lgtm! |
Also @hmuurine thanks for the documentation commits! |
Okay this is addressed in b912071 |
…ease to 0.2.0 as all changes here a non-breaking as far as we have tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Reviewed. QA'd. Bug fixed. I'm landing this!
Is there more detailed document of using frontend library package beacuse now i have to browse the source code to find the usage of a function, or if it is existing, where can i find it? |
@AntiF0 The docs/usage examples are coming soon. We will have these in time for 5.2, but for now we are actively still documenting. You will note the new frontend is only in master (our dev branch) and 5.2 (which is pre-release). Please be patient, docs are coming. In the meantime I have two things for you:
@hmuurine For vis. |
@lukehb Thanks a lot for you and your team's efforts on this project, but I am only a beginner in programming and may not be able to do this. |
@AntiF0 Understood, we will handle this then. Expect more docs in the next few weeks/months. |
Summary
This PR splits the
Frontend/library
code into two parts:library
that provides an API for establishing Pixel Streaming sessionsui-library
that contains all the UI components like settings overlay panel, connection strength indicator, buttons, etc.The
library
code is intended to be used as a library through the Javascript/Typescript API, and it can be used programmatically without the default UI implemented inui-library
. This allows the developers to bring their own UI if they wish to customize the user experience, or even start a Pixel Streaming session without any overlay UI.The wish is to keep the library API stable and try to not make breaking changes if possible. If new non-breaking features are introduced to the API, it would be great if it was reflected in the version numbering following semantic versioning. Breaking changes should increase the major version number, while non-breaking changes increase only the minor or patch version number.
Sample UI applications
There are now two sample UI applications in
Frontend/impelementations/EpicGames
:player.html
/player.ts
that displays the default UI usinglibrary
andui-library
togetheruiless.html
/uiless.ts
that uses onlylibrary
to start a plain Pixel Streaming session without any additional UI componentsThe two sample applications are meant to demonstrate how the library can be used through the JS API either with or without the default UI overlays.
Public API
The Pixel Streaming library can now be configured and used through its public JS/TS API. Here's an example demonstrating the API usage without the default UI:
This demonstrates a number of the new API features:
The default UI uses this same public API and the events emitted by the library to implement its functionality, so it should be versatile enough to implement similar functionality in a custom UI. The events are JS-only and generic enough to be technology-independent, so it should be possible to implement e.g. a React UI using this same API. A number of events are emitted at various stages of establishing the connection, when detecting errors, when receiving new statistics, when connection quality changes, etc.
Implementation principles
When decoupling the UI code out from the rest of the library I tried to follow these principles:
library
toui-library
without any changespixelStreaming
object. Added the minimal API that fulfilled the needs of the sample UI and nothing extraThe biggest changes that couldn't be performed by simply moving code around are in
Config/*.ts
. These files were all split into two:library
code stores the data in JS variables, whereasui-library
code handles rendering the checkboxes, text fields etc. The UI side updates the state of the UI controls whenever receivingsettingsChanged
events from the library.Test plan
Default UI
library
,ui-library
andimplementations/EpicGames
and started the sample application/player.html
ui-library
side) and verified that it still works. Modified a couple of settings including signaling server URL (text field) and auto-play / muted settings (checkboxes / toggles) and verified that the settings were persisted in browser URLRestart
andShow FPS
worked as expectedScreen.Recording.2023-02-20.at.19.06.44.10mb.mp4
The plain Pixel Streaming UI with no overlays
/uiless.html
in FirefoxScreen.Recording.2023-02-20.at.19.09.43.mp4
/uiless.html
in Chrome that does not permit autoplay with the default settings