New media sync protocol

See the commit message for details.

Note that this change doesn't affect collection syncing at all (so if you disable media sync it will be identical).