@startuml autonumber participant ApplicationManager participant RialtoServerManager ApplicationManager -> RialtoServerManager: initiateApplication(application_id, AppState::Inactive, app_config) note right: app_config allows app manager to specify the socket name to use for Rialto client/server session management opt Socket name not specified in app_config RialtoServerManager -> RialtoServerManager: Generate unique session_management_socket_name for Rialto Client to Rialto Application Session Server communication end RialtoServerManager -> RialtoServerManager: Generate socketpair for Rialto Session Server to Server Manager communication RialtoServerManager -> RialtoApplicationSessionServer **: Spawn(socket) 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, resources, 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 RialtoApplicationSessionServer -// RialtoServerManager: stateChanged(AppState::Inactive) RialtoServerManager -// ApplicationManager: StateChanged(application_id, AppState::Inactive) ApplicationManager -> RialtoServerManager: getAppConnectionInfo() RialtoServerManager --> ApplicationManager: session_management_socket_name else State transition failed RialtoApplicationSessionServer -> RialtoApplicationSessionServer: 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: Unbind/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 |
3. socketpair is used to create the point-to-point IPC channel used for all Rialto Server Manager to Rialto Application Session Server communications
7/8. Session server creates the share memory region and listening socket that the app will use for sending AV data and control respectively.
10. Application Session Server sends first message so Server Manager knows that it is now up and running
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.
@startuml autonumber participant ApplicationManager participant RialtoServerManager participant RialtoApplicationSessionServer ApplicationManager -> RialtoServerManager: changeSessionServerState(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. RialtoServerManager will need to look up which RialtoApplicationSessionServer to which to send the notification
Same sequence as Not Running→Inactive but change target state to Active and allocate shared memory buffer after creating session management socket.
@startuml autonumber participant ApplicationManager participant RialtoServerManager participant RialtoApplicationSessionServer ApplicationManager -> RialtoServerManager: changeSessionServerState(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.
@startuml autonumber participant ApplicationManager participant RialtoServerManager participant RialtoApplicationSessionServer ApplicationManager -> RialtoServerManager: changeSessionServerState(application_id, AppState::NotRunning) RialtoServerManager -> RialtoApplicationSessionServer: SetState(AppState::NotRunning) RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Close IPC connection with app RialtoApplicationSessionServer -> RialtoApplicationSessionServer: Set current_state = NotRunning RialtoApplicationSessionServer -// RialtoServerManager: stateChanged(AppState::NotRunning) RialtoApplicationSessionServer -> RialtoApplicationSessionServer !!: Exit process RialtoServerManager -// ApplicationManager: stateChanged(application_id, AppState::NotRunning) @enduml |
6. The Session Server process should self terminate once it has sent the NotRunning notification to the Server Manager.
Not shown for brevity, but should perform all of the cleanup operations in Rialto Sessions server shown in Active→Inactive & Inactive->Not Running.
@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 |
@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 |
@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 |
@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 |
@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 |
@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 |
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.
@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 |