Covariant electrodynamics in a medium. I