Surprisingly, there is actually a wiki page on the matter:
Wikipedia.org - Taking the Piss
Roughly covers the following:
1
- mocking someone
- making a joke at someone's expense
2
- saying/doing something unbelievable
- doing something unfair
- taking more than your fair share
"Are you taking the piss?" is pretty similar to "You've got to be joking, mate!" or "are you fucking kidding me!?!"