(a) Any person who violates the dignity and authority of any court, in its presence or so near thereto as to obstruct the administration of justice, or any officer of any court who misbehaves in the conduct of his official duties shall be guilty of contempt and shall be fined not more than five hundred dollars or imprisoned not more than six months or both.

(b) No person charged with violating this section may be tried for the violation before the same judge against whom the alleged contempt was perpetrated.