Photonics and optoelectronics using nano-structured hybrid perovskite media and their optical cavities