A bail bond is entered into either before a magistrate, upon an examination of a criminal accusation, or before a judge upon an application under habeas corpus; or it is taken from the defendant by a peace officer or jailer if authorized by Article 17.20, 17.21, or 17.22.