Yesterday, Periscope announced that it reached 10 Million Periscope accounts. At OpenAir, Sara Haider detailed how she and her colleagues,
faced multiple challenges in developing an Android version of the live video streaming app.
There are two video livestreaming protocols, Haider explained: Real-Time Messaging Protocol (RTMP), which is suitable for low latency and real-time interaction among a few participants but isn’t widely supported; and HTTP Live Streaming (HLS), which sits atop the HTTP layer. HLS offers much higher latency, is ideal for non-interactive broadcasters, and is widely supported.
Low latency for Periscope is a must, however, so both protocols were needed to deliver the user experience on Android.
For playback, Periscope used ExoPlayer, Android’s application-level media player, which began supporting HLS earlier this year but lacks RTMP support. “So we built from scratch a completely custom RTMP broadcasting and playback stack for Periscope on Android,” Haider said.
Because RTMP isn’t widely scalable, Periscope relies on HLS to support scale. For example, when a Periscope video stream chatroom gains a lot of participants, Periscope limits the number of people who can comment to keep things moving smoothly for everyone. Those users get an HLS video stream that keeps them in sync while also enabling Periscope to scale the broadcast “to thousands of users,” Haider said. (Jump to 5:19 in the video to hear more.)
The chats accompanying a video feed are handled on their own Real-Time Chat (RTC) channel and come in instantly, though the video feed has variable latency. Also, Android clocks are “completely unreliable,” Haider said, with variations of as much as 15 seconds behind or ahead. To compensate for those variations, Periscope uses the Network Time Protocol (NTP).
The Periscope Android team consisted, at various times, of three app engineers, one video engineer, and one designer. The “bootstrapped stack” the team built consists of open-source libraries Retrofit, OkHttp, EventBus, Glide, and Spongy Castle. They used the standard tools DexGuard, Crashlytics (Twitter’s crash reporting system), Localytics, Android Studio, and Genymotion. As for application libraries, Periscope used PubNub for its chatroom channel in addition to the ExoPlayer media player. (Go to 14:21 in the video to hear more.)