How to set higher priority for some calls on PRI

Hello,

I have one task that I could not solve so please help me.
I have two different types of calls that are recieved in different contexts. But both are terminated over same PRI connection with 30 channels. Calls in context_1 have higher priority and shall be served first. Call in context_2 shall be served only if there are enough free channels on PRI. I was thinking about some buffer of 3 channels that could help me solve this problem. In this case calls in context_2 shall be processed only if there are more than 3 free channels on PRI. Otherwise they should be rejected. But I could not find any clues how could I determine number of free channels on PRI.
Any help regarding this problem is very appreciated

Bright

Take a look a the goup and group count function.