Novak Djokovic needed more than five hours and five sets to beat Stanislas Wawrinka at the Australian Open.