Optimal streaming of layered video