AirenSoft / OvenPlayer

OvenPlayer is JavaScript-based LLHLS and WebRTC Player for OvenMediaEngine.
https://airensoft.com/ome.html
MIT License
515 stars 126 forks source link

restore WebRTC stream connection with OvenMediaEngine server #443

Closed sys-dev-me closed 1 month ago

sys-dev-me commented 1 month ago

I am using OvenMediaEngine (OME) as a media router for restreamers. Occasionally, clients disconnect and reconnect after 1 to 3 minutes. I haven't found a way to configure automatic reconnection to the stream after a disconnection.

sys-dev-me commented 1 month ago

Topology: Camera (RTSP) -> Client (jetson/ffmpeg/MPEG-TS) -> restreaming -> SRT -> OME Server (OvenPlayer)

Issue: When the client loses internet connection, ffmpeg drops the connection and restores it in 5-10 seconds (or sometimes longer, up to 1-2 minutes). The OME server is able to restore the stream after the reconnection, but the OvenPlayer does not resume playing the stream automatically. Manual intervention is required to restart the playback.

sys-dev-me commented 1 month ago

Can be closed? realized with event checking

 this.#player.on("play", () => {
            if (this.#player.getState() !== "error") {
                if (this.stateCheckInterval) {
                    clearInterval(this.stateCheckInterval);
                    this.stateCheckInterval = null;
                    console.log("Stream is playing, stopping state checks.");
                }
            }
        });

        this.#player.on("error", (error) => {
            console.log("Error while playing detected.");
            if (!this.stateCheckInterval) {
                this.stateCheckInterval = setInterval(() => this.checkStreamStatus(), 3000);
            }
        });

        this.#initTabs();
    }

    checkStreamStatus() {
        this.#player.play();
        setTimeout(() => {
            console.log ( "Stop tries for playing" );
            if (this.#player.getState() !== "error") {
            } else { 
                this.#player.stop();
                }
        }, 3000);
    }

    getPlayingStatus() {
        const state = this.#player.getState();
        return state !== "error";
    }
getroot commented 1 month ago

thank you for sharing good experience