Viewport-adaptive streaming is now a widely used solution for the transmission of omnidirectional video. However, when the user's viewport changes, there will be a delay in switching to high quality video. This delay will significantly affect the user's experience. In this paper, a real-time adaptive switching mechanism was proposed to solve this problem, which can perform video quality switching at any instant. In the proposed real-time adaptive switching mechanism, a technique of Random Access P Frame (RAPF) is proposed, which can serve as the random access to help to achieve the real-time adaptive in practice. In the process of encoding RAPFs, inter prediction encoding method will be used to reduce the size of RAPFs, thereby reducing the bandwidth consumption. The experimental result shows that the proposed mechanism can reduce the delay to the quality switching, while just resulting in a quite small extra bandwidth consumption and negligible quality degradation.