Who owns the "live action" tv rights to the xmen universe?

I've heard it suggested that marvels owns all the tv rights to the xmen universe, but that fox has to give the OK if marvel wanted to do a live action tv series (presumably so as not to conflict with their movie franchise). If that is true, then an xmen universe tv series would never happen since fox would just veto the project. But if Fox had the live action tv rights then perhaps they could go ahead with a tv series of their own.

It all seems twisted into knots. I remember reading that marvel gave sony the live action rights to spiderman as well, but more recently made a deal that returned spiderman live action tv rights to marvel/disney. We could actually see a miles morales tv series that was not a cartoon if marvel/disney wanted to since they have the rights. And therein lies the reason for the question.

We are still in the golden age of television, shows like arrow are leading the way for other series like the flash, and agents of shield and agent carter. DC seems to be putting some of its more established characters on the small screen, but marvel is only toying around the edges so far. Who would not live to see something like the age of apocalypse done over an entire season of television rather than a single movie? A high production quality series in the vein of game of thrones. Would such an endeavor be too expensive to pull off today? How long before such a thing would be economically feasible? And if it was, would studios like marvel have any interest in doing it?

The ultimate spiderman miles morales story arc seems like it would be the most justifiable character to delve into, not quite so over the top with special effects with the main character, and in a different universe than the standard spiderman so as not to directly contradict the movies sony is making.