Is there a right to protest at royal events?

A number of people have been arrested for protesting at royal events, what does the law say about this?