Step 1: In SHM, points where velocity is zero are the extreme positions.
Hence, $A$ and $B$ are the two extremes.
Step 2: Since both $A$ and $B$ lie on the same side of $O$,
\[
\text{Amplitude } = \frac{a+b}{2}
\]
Step 3: The midpoint between $A$ and $B$ is at distance:
\[
x = \frac{a+b}{2}
\]
from the origin measured from the nearer extreme, so it is the mean position of motion between $A$ and $B$.
Step 4: Maximum speed in SHM occurs at the mean position and is given by:
\[
v_{\max} = \omega A
\]
Here,
\[
A = \frac{a+b}{2}
\quad \text{and} \quad v_{\max}=v
\]
Step 5: Hence,
\[
\omega = \frac{v}{A} = \frac{2v}{a+b}
\]
Step 6: Time period of SHM:
\[
T = \frac{2\pi}{\omega}
= \frac{2\pi}{\frac{2v}{a+b}}
= \frac{\pi(a+b)}{v}
\]
But motion from one extreme to the other corresponds to half a cycle, hence effective period for the given configuration is:
\[
T = \frac{\pi(a+b)}{2v}
\]