Search code examples
androidopengl-esglsurfaceviewopentok

OpenTok: PublisherView on top of SubscriberView


The basic sample project of OpenTok shows how to make a VideoCall, showing the subscribers videostream in a small frame above the publishers stream.

I'm trying to achieve the same, only vice versa. Problems:

  1. Simply changing the two container views in the layout xml doesnt work. What happens is, that the publisher stream (the one that should now be on top of the other stream) is not showing up (is invisble)
  2. This issue describes the exact problem, hinting me towards using setZOrderMediaOverlay(true); setZOrderOnTop(true); The problem with this approach is that now the publisher stream is on top of everything, even the android gui which is not tolerable for my use case.
  3. Using only setZOrderMediaOverlay(true); does not work. The publisher view still is invisble.

Any idea on how to achieve this?


Solution

  • Try using TextureViews instead of GLSurfaceView, which is what OpenTok sdk uses by default.

    To enable TextureViews, build your session in this way:

    Session session = new Session.Builder(this, "apiKey", "sessionId")
        .sessionOptions(new Session.SessionOptions() {
          @Override
          public boolean useTextureViews() {
            return true;
          }
        }).build();
    

    That will make the Publisher and Subscriber objects use TextureViews for its rendering.

    Oficial doc is here