Getting an audio activity flag from LibVLC
Posted: 26 Jul 2020 16:25
I am writing a LibVLCSharp based Windows application for listening to multiple voice audio streams simultaneously. Each stream will carry a single 2-way radio or intercom channel, and may be silent for minutes or hours at a time. The application can monitor a dozen or more channels, and I would like to visually indicate which channels are currently active.
Ideally I would like to poll the audio level of each stream, so that I may detect audio activity, (100-500ms intervals should be sufficient). The maximum amplitude of the last audio frame, or a simple flag indicating amplitude above a threshold is all that I require.
There doesn't appear to be a way to achieve this using vanilla LibVLC, and my initial thought was to write a custom audio filter to do this. After some research, it's not clear to me whether this approach would work.
There are two areas which I'm hoping someone with more VLC experience can help me with:
Ideally I would like to poll the audio level of each stream, so that I may detect audio activity, (100-500ms intervals should be sufficient). The maximum amplitude of the last audio frame, or a simple flag indicating amplitude above a threshold is all that I require.
There doesn't appear to be a way to achieve this using vanilla LibVLC, and my initial thought was to write a custom audio filter to do this. After some research, it's not clear to me whether this approach would work.
There are two areas which I'm hoping someone with more VLC experience can help me with:
- Enabling a custom audio filter
I've had no success enabling any of the supplied audio filters using LibVLC, either by passing an argument to libvlc_new(), or via libvlc_media_add_option(); however, I can successfully use both methods with VLC. I have recently found this comment by Rémi Denis-Courmon, which may indicate why:https://forum.videolan.org/viewtopic.php?t=143056
"This is explicitly not supported by the libvlc_new() documentation. LibVLC controls audio filters (and many other things) internally."
Can anyone tell me how I control LibVLC audio filter selection, and if there is any way for me to specify a custom filter?
- Passing data between the application and the custom filter
Is there a way for an application to access data within a custom module via LibVLC, (e.g. read the value of my custom filter's audio activity flag)?
If this is not possible, then I may be able to use IPC to send the activity flag from the filter to my application; however, with multiple instances of the filter running, I would need a way for each filter to uniquely identify itself to the application. To this end:
Has the filter got access to the MRL, or is there a way to pass data from the application to the audio filter, (e.g. a UUID)?