Camera Stream Pipe - event on HLS close & stream with audio broken

Hello, I am a developer of GitHub - JurajNyiri/HomeAssistant-Tapo-Control: Control for Tapo cameras as a Home Assistant component.

Right now I am working on Stream on devices without RTSP by JurajNyiri · Pull Request #1007 · JurajNyiri/HomeAssistant-Tapo-Control · GitHub, which will add stream viewing capability through TPLink proprietary stream protocol.

I am having a few issues I have spent multiple hours searching the docs and forums and have not found an answer for. Hopefully someone experienced can help me out.

  1. Hopefully a simple question: When a stream is opened in a card, function async_create_stream is called. Is there a function for when a stream is closed? I could use this to stop the flow of data from camera and save battery power when stream is not actively viewed.
  2. Challenging: I am encountering a very strange behaviour, when I pipe in the stream without audio, everything works as expected and loads after a couple of seconds. If I pipe in audio as well, the player in browser is stuck on loading and the total seconds keep rising. I have verified the stream itself works and is streaming the data and stream works without issues both when outputed into HLS, or piped into VLC outside of HA.

Thanks for all the insights and advises in advance!