Categories: Uncategorized

Surface Layers and the Live Streaming Android SDK


With great power comes great responsibility. OpenGL (while not a superpower per se) is still a mighty library capable of great things. However, like a Hulk temper tantrum, a lack of control can have bad results.

With this in mind, we would like to share some tips about working with OpenGL and surface layers so you can harness that power. We want to help you build successful applications and don’t like it when you’re angry.

Notes about Android and Surface Layers:

  • Surfaces, and related GLSurfaces, allow images to be drawn directly to the Android window. These surfaces are used by the Red5 Pro Android SDK to draw the camera preview. The R5VideoView draws the camera preview with a SurfaceView and an incoming stream’s video with a GLSurfaceView.
  • These SurfaceView objects are drawn separately from the Android UI.
  • They have multiple layers, specifying that only one surface ‘should’ be on each at any one time. From Top to Bottom they are:
  • “OnTop” (Surface Layer)
  • UI (Everything in layouts and non-surface views added programatically)
  • “MediaOverlay” (Surface Layer)
  • Default Surface Layer
  • Having multiple Surfaces on one layer technically leads to undefined behavior. This effectively means that it’s up to the OEM’s discretion to decide how surface layering is handled. Most will have taken care of any issues that might arise from z-fighting.

Tips:

  • Point of confusion:
  • SurfaceViews added in layouts (ie – not added to view hierarchy by addView()) are drawn as normal parts of the UI layer only when they have a background.
  • Important note – This means if your app uses a background on any of its views or layouts in the same window as an R5VideoView. The DebugView will draw on the correct UI layer, but the stream view will be behind the background.
  • The stream will always be drawn under any alert or dialog views.
  • Troubleshooting – if your stream isn’t displaying correctly, make sure there aren’t any backgrounds sharing its draw space.

Red5 Team

Share
Published by
Red5 Team

Recent Posts

Red5 on OCI vs AWS IVS: Why Oracle Cloud Infrastructure is an Excellent Choice for Live Streaming

As organizations evaluate live streaming solutions, Amazon Interactive Video Service (IVS) has emerged as a…

5 days ago

What’s New in Red5 Cloud v1.9.2? Valuable UI/UX Improvements and Bug Fixes

Let’s go over the latest updates introduced in Red5 Cloud since our previous blog covering…

6 days ago

Real-Time Streaming Solutions for 2025: Red5 vs. Phenix vs. Dolby Optiview

When businesses need ultra-low latency streaming capabilities, the choice of platform can significantly influence the…

2 weeks ago

AWS IVS vs Red5: Choosing the Right Live Streaming Solution for Your Business

1Understanding AWS IVS: Strengths and Limitations2Red5: A More Flexible Alternative3When to Choose Red5 Over AWS…

4 weeks ago

What’s New in Red5 Pro v14.2.1 and Red5 Cloud v1.9.1?

Let’s take a look at the latest Red5 Pro and Red5 Cloud releases introduced since…

1 month ago

AV1 vs VP9 vs. VP8: Complete Codec Evolution and Comparison for Live Streaming

1Quick Comparison Overview2The Complete Evolution: VP8 → VP9 → AV13Technical Comparison: VP8 vs VP9 vs…

1 month ago