"Automatically switch to HSP/HFP when an application is requesting to record the microphone. When it stops, revert back to A2DP."
Pulseaudio is already doing this for applications which registers to pulseaudio with "phone" media role, what VOIP applications should do.
You can test it with command line application parec which put on stdout recorded microphone stream:
$ parec --property=media.role=phone
"Automatically switch to HSP/HFP when an application is requesting to record the microphone. When it stops, revert back to A2DP."
Pulseaudio is already doing this for applications which registers to pulseaudio with "phone" media role, what VOIP applications should do.
You can test it with command line application parec which put on stdout recorded microphone stream:
$ parec --property= media.role= phone