> is there a recommended best practice to discard the events from an "inactive" VideoRecordEvent listener? In my case, I'd like to identify that the Finalized event belongs to an active recording and not to one that's shutting down.
While it's generally best to create a new listener for each recording, if you must use a single listener, you can identify the correct recording using VideoRecordEvent.getOutputOption(). Compare this with the OutputOptions you provided when starting the recording. If your OutputOptions remain consistent, this method won't be reliable.
> Is there any negative side effect of having a VideoRecordEvent that is "shutting down" while there's a new instance to track the new(and active) recording?
The main concern with multiple recordings is limited device resources. If your device has enough codec resources, the second recording should work fine. If resources are scarce, the second recording may fail to start, resulting in a Finalize event with an error code. CameraX will actually attempt to retry a bit before giving up.
> Is there a way for example, to remove the observer from the current recording session?
Currently, the CameraX API doesn't provide a direct way to remove an observer from a recording session.
Here's a workaround: Create your own class that extends Consumer<VideoRecordEvent>. In this class, you can add logic to ignore or discard events once you've stopped the recording.