Rialto Application State Changes
Not Running→Inactive
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Not Running to Inactive |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoServerManager
ApplicationManager -> RialtoServerManager: ChangeApplicationState(application_id, AppState::Inactive)
RialtoServerManager -> RialtoServerManager: Generate unique session_management_socket_name for App to Rialto Session Server communication
RialtoServerManager -> RialtoServerManager: Generate socketpair for Rialto Session Server to Server Manager communication
RialtoServerManager -> RialtoApplicationSessionServer **: Spawn(socketpair, session_management_socket_name, AppState::Inactive)
RialtoServerManager -> RialtoServerManager: Start [1] second READY timer
RialtoServerManager --> ApplicationManager: OK/ERROR
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = Uninitiliased
alt RialtoApplicationSessionServer started successfully
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Uninitialised)
RialtoServerManager -> RialtoServerManager: Cancel READY timer
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Uninitialised)
RialtoServerManager -> RialtoApplicationSessionServer: SetConfiguration(session_management_socket_name, AppState::Inactive, Allocate shared memory bufferresources, log_level)
note right
"resources" structure will specify the maximum decoder resources that the
application is permitted to use. For now it shall have a max_playback_sessions
property and a supports_web_audio flag. This may be enhanced for things like
HD/UHD, audio only etc in future.
end note
RialtoApplicationSessionServer --> RialtoServerManager:
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Create listening socket & bind to session_management_socket_name
alt State transition successful
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = Inactive
alt Previous steps succeeded (alloc shm, create socket, Connect)
RialtoApplicationSessionServer -// RialtoServerManager:RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Inactive)
RialtoServerManager ->// RialtoServerManager: Cancel READY timer
RialtoServerManagerApplicationManager: -// ApplicationManager: StateChanged(application_id, AppState::Inactive)
ApplicationManager -> RialtoServerManager: GetAppConnectionInfo()
RialtoServerManager --> ApplicationManager: session_management_socket_name
else SessionState Server initialisationtransition failed
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Close IPC connection with app
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Close listening socket (if created)Unbind/free session management socket (if created)
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Error)
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Error)
RialtoApplicationSessionServer -> RialtoApplicationSessionServer !!: Exit process
end
else Session Server initialisation failed
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Unmap shared memoryUnbind/free session management socket (if created)
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Error)
RialtoServerManager -> RialtoServerManager: Cancel READY timer
RialtoApplicationSessionServer -> RialtoApplicationSessionServer !!: Exit process
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Error)
else READY timer expired
RialtoServerManager -> RialtoServerManager: Kill spawned Rialto Application Session Server process
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Error)
end
@enduml |
...
13/14. Session Manager has an API to allow the Application Manager to get the socket name that the App will use for communication with Rialto which it should fetch as soon as it is notified that Rialto has moved the app out of the Not Running state so that it can be passed to the app/container when it is launched.
Inactive→Active
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Inactive to Active |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoServerManager
participant RialtoApplicationSessionServer
ApplicationManager -> RialtoServerManager: ChangeApplicationState(application_id, AppState::Active)
RialtoServerManager -> RialtoApplicationSessionServer: SetState(AppState::Active)
RialtoApplicationSessionServer --> RialtoServerManager: OK/ERROR
RialtoServerManager --> ApplicationManager: OK/ERROR
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Allocate shared memory buffer
opt State transition successful
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = Active
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Active)
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Active)
else State transition failed
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Free shared memory buffer if allocated
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Error)
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Error)
end
@enduml |
2. RialtoServer manager RialtoServerManager will need to look up which RialtoApplicationSessionServer to which to send the notification
Not Running→Active
Same sequence as Not Running→Inactive but change target state to Active and allocate shared memory buffer after creating session management socket.
Active→Inactive
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Active to Inactive |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoServerManager
participant RialtoApplicationSessionServer
ApplicationManager -> RialtoServerManager: ChangeApplicationState(application_id, AppState::Inactive)
RialtoServerManager -> RialtoApplicationSessionServer: SetState(AppState::Inactive)
RialtoApplicationSessionServer --> RialtoServerManager: OK/ERROR
RialtoServerManager --> ApplicationManager: OK/ERROR
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Free any remaining CDM resources
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Free any remaining Player resources
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Unmap/free shared memory buffer
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = Inactive
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::Inactive)
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Inactive)
@enduml |
...
6. Free any Player resources means close any open GStreamer pipelines, for example those used for AV playback and/or UI audio.
Inactive→Not Running
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Inactive to Not Running |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoServerManager
participant RialtoApplicationSessionServer
ApplicationManager -> RialtoServerManager: ChangeApplicationState(application_id, AppState::NotRunning)
RialtoServerManager -> RialtoApplicationSessionServer: SetState(AppState::NotRunning)
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Close IPC connection with app
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Unmap shared memory
RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = NotRunning
RialtoApplicationSessionServer -// RialtoServerManager: StateChanged(AppState::NotRunning)
RialtoApplicationSessionServer -> RialtoApplicationSessionServer !!: Exit process
RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::NotRunning)
@enduml |
76. The Session Server process should self terminate once it has sent the NotRunning notification to the Server Manager.
Active→Not Running
Not shown for brevity, but should perform all of the cleanup operations in Rialto Sessions server shown in Active→Inactive & Inactive->Not Running.
Application Management
Start Application in Inactive State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Launch application in Inactive state |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-NotRunning→Inactive Not Running to Inactive]]
ApplicationManager -> Application ** : Spawn(AppState::Inactive, listening_socket_name)
Application -> RialtoClient ** : Load RialtoClient library
RialtoClient -> RialtoApplicationSessionServer: Connect(rialto_listening_socket)
note right
Connect is not an API call, it is establishing IPC channel with server
end note
RialtoClient --> Application: status
Application -// ApplicationManager: StateChanged(AppState::Inactive)
@enduml |
Start Application in Running State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Launch application in Running state |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-NotRunning→Active Not Running to Active]]
ApplicationManager -> Application ** : Spawn(AppState::Running, listening_socket_name)
Application -> RialtoClient ** : load RialtoClient library
RialtoClient -> RialtoApplicationSessionServer: Connect(rialto_listening_socket)
note right
Connect is not an API call, it is establishing IPC channel with server
end note
RialtoClient --> Application:
Application -> RialtoClient: setApplicationState(Running)
RialtoClient -> RialtoApplicationSessionServer: GetSharedMemory()
RialtoApplicationSessionServer --> RialtoClient: shm_fd
RialtoClient -> RialtoClient: Map shared memory
RialtoClient --> Application: status
Application -// ApplicationManager: StateChanged(AppState::Running)
@enduml |
Switch Application from Inactive to Running State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Application state change: Inactive to Running |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
participant Application
participant RialtoClient
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-Inactive→Active Inactive to Active]]
ApplicationManager -> Application : NotifyNewState(AppState::Running)
Application -> RialtoClient: setApplicationState(Running)
RialtoClient -> RialtoApplicationSessionServer: GetSharedMemory()
RialtoApplicationSessionServer --> RialtoClient: shm_fd
RialtoClient -> RialtoClient: Map shared memory
RialtoClient --> Application: status
Application -// ApplicationManager: StateChanged(AppState::Running)
@enduml |
Switch Application from Running to Inactive State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Application state change: Running to Inactive |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
participant Application
participant RialtoClient
ApplicationManager -> Application : NotifyNewState(AppState::Inactive)
Application -> RialtoClient: setApplicationState(Inactive)
RialtoClient -> RialtoClient : Free CDM & Player resources
RialtoClient -> RialtoClient: Unmap shared memory
RialtoClient --> Application: status
Application -// ApplicationManager: StateChanged(AppState::Inactive)
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-Active→Inactive Active to Inactive]]
@enduml
|
Stop Application from Inactive State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Application state change: Inactive to Not Running |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
participant Application
participant RialtoClient
ApplicationManager -> Application : NotifyNewState(AppState::NotRunning)
Application -// ApplicationManager: StateChanged(AppState::NotRunning)
Application -> RialtoClient: Unload library
RialtoClient -> RialtoClient !!:
Application -> Application !!:
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-Inactive→NotRunning Inactive to Not Running]]
@enduml |
Stop Application from Running State
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Application state change: Running to Not Running |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoApplicationSessionServer
participant Application
participant RialtoClient
ApplicationManager -> Application : NotifyNewState(AppState::NotRunning)
Application -> RialtoClient: setApplicationState(Inactive)
RialtoClient -> RialtoClient : Free CDM & Player resources
RialtoClient -> RialtoClient: Unmap shared memory
RialtoClient --> Application: status
Application -// ApplicationManager: StateChanged(AppState::NotRunning)
Application -> RialtoClient: Unload library
RialtoClient -> RialtoClient !!:
Application -> Application !!:
ref over ApplicationManager, RialtoApplicationSessionServer : [[#RialtoSessionManagementSequenceDiagrams-Active→NotRunning Active to Not Running]]
@enduml |
Example Application Switch Sequences
Active / Inactive Application Switch
This following diagram shows a typical sequence for when the Application Manager needs to make an application active when a currently running application is using the Player resources that the new application requires. The application manager therefore moves the current application into the inactive state to free up the resources and once that is complete switches the new application into the active state so that it can acquire those resources.
| PlantUML Macro |
|---|
| format | SVG |
|---|
| title | Active / Inactive Application Switch |
|---|
|
@startuml
autonumber
participant ApplicationManager
participant RialtoServerManager
note across : First make App_1 Inactive
ref over ApplicationManager, RialtoServerManager : [[#RialtoSessionManagementSequenceDiagrams-Active→Inactive Active->Inactive(app_id_1)]]
note across
Once Application Manager has received
the state change event to Inactive for
app_id_1 it can then make App_2 Active
end note
ref over ApplicationManager, RialtoServerManager : [[#RialtoSessionManagementSequenceDiagrams-Inactive→Active Inactive->Active(app_id_2)]]
@enduml |