I have a curve defined by the following equations over the finite field $\mathbb{F}_q$ with $q=p^r$ with $p \geq 3$: $$C_{h_1,h_2}:\begin{cases} y_1^2=h_1(t) & \\ y_2^2=h_2(t) & \\ \end{cases}$$ with $h_1,h_2$ monic, square-free polynomials in $\mathbb{F}_q[t]$, and $h_1\neq h_2$. This is a so-called biquadratic curve, because its function field is a biquadratic extension of $\mathbb{F}_q(t)$, that we can write as $\mathbb{F}_q(t)(\sqrt{h_1(t)},\sqrt{h_2(t)})$.
If I want to count these curves, I use the formula for counting square-free monic polynomials over finite fields, that is $$\# \lbrace \mbox{square-free monic polynomials of degree n in } \mathbb{F}_q \rbrace= (q-1)q^{n-1}$$ (this is Exercise 3 at page 20 of Rosen's "Number Theory in Function Fields", that uses the zeta function associated to $\mathbb{F}_q[t]$)
So it's easy to see that $$\# \{ C_{h_1,h_2} | \deg h_1=n_1, \deg h_2 = n_2 \}=\frac{(q-1)^2q^{n_1+n_2-2}}{1+\delta_{n_1n_2}} - \delta_{n_1n_2}\frac{(q-1)q^{n_1-1}}{2}$$ where $\delta_{n_1n_2}$ is the Kronecker delta.
My question is:
Is there a formula to compute the following cardinality? $$\# \{ C_{h_1,h_2} | \deg h_1=n_1, \deg h_2 = n_2, \deg f = n \}$$ where $f=(h_1,h_2)$, that is the greatest common divisor of $h_1$ and $h_2$.