Cal. Civ. Proc. Code § 1997
If the witness be imprisoned in a jail in the county where the action or proceeding is pending, his production may be required. In all other cases his examination, when allowed, must be taken upon deposition.