How to get realtime headphone levels in decibel unit

Hello, I am currently developing an application for audiogram testing. What methods can I use to obtain the dB values of headphone levels in real-time?

https://developer.apple.com/documentation/avfoundation/avcaptureaudiochannel https://developer.apple.com/documentation/avfoundation/avcaptureconnection

dB relative to what?

If you're interested in the SPL the user experiences, that's going to depend on the headphone sensitivity.

Even the delivered power isn't very helpful: https://developer.apple.com/documentation/avfoundation/avcaptureaudiochannel/1387368-averagepowerlevel says "averagePowerLevel The instantaneous average power level in decibels." How a measurement can be both average (implying a series of measurements over time) and instantaneous is baffling to me, while a measurement in decibels without a reference power level is also, let's just say non ideal.

How to get realtime headphone levels in decibel unit
 
 
Q