Creating a Mobile Live Stream Platform With Wowza Media Systems

Posted 3 months ago by Petr Matej

Whether you are watching Coachella live on YouTube, connecting with your followers via Instagram stories, or gaming with more than 10 million other daily active users on Twitch, there’s no denying that live streaming video has become an indispensable part of our lives. All you really need is a reliable internet connection and a device such as a smartphone or a computer to receive content.

At profiq, we’ve been intrigued by the possibilities of live streaming and have been actively pursuing it since 2015. You can read about our ventures into 360° video and VR streaming here How we delved into alternate reality, and why and here Life’s imprints in 360 degrees.

In this article, we continue our exploration of live streaming by building a live stream for our mobile app using Wowza Streaming Cloud and Wowza GoCoder. You can see how well it worked by watching a video of the integration at the end of this article. But before we delve into our use case, let’s first look at how live streaming works.

Understanding streaming

Streaming is a method of delivering video and audio content over the Internet to mobile devices and computers. It is delivered in real-time (live) data streams, or in pre-recorded ones.

Live data streams

Prevalent live stream consumer service providers such as YouTube and Facebook Live regularly deliver events in real time such as breaking news. For example, the two most watched live YouTube videos are SpaceX’s Falcon Heavy rocket launch and Felix Baumgartner’s space jump.

Live data streams are time-bound and are only available for the duration of an event. As a result, there is no need to store data on the mobile device or computer. When the event ends, so do the stream and the content, although some platforms provide the option to record the live stream for replay later. For example, when you live stream on Twitch or Steam, you can watch the video again. YouTube also records live streams and saves them for future replays.

Pre-recorded streams

Unlike live data streams, pre-recorded or on-demand streams are not time-bound or of limited duration. Pre-recorded videos need to be stored on external storages/servers, and can be played on demand once or many times from that location. Some examples of pre-recorded streams are podcasts and movie services like YouTube. Regardless of whether you watch content live or on-demand, both types of live streaming deliver content to you when you request it.

As you know, rendering video is very resource-intensive, so a robust streaming engine and good algorithms are imperative for delivering video in real time. Minimal latency is also crucial for delivery. To accomplish this, video is distributed through content delivery networks (CDNs). CDNs are groups of geographically distributed servers that work together to deliver content quickly. When data is transmitted, it is received by the CDN that is physically the closest to the user to ensure a fast and interruption-free delivery. The following diagram illustrates this process:

Source: Wowza web

While some of the bigger players like Google have their own massive networks and technologies, most content is delivered to users by streaming infrastructure providers, as they have the capacity and the technology to reach millions of users. Some of these well-known streaming infrastructure providers include:

Many of these companies offer tools for developers, which we were interested in for our project. These tools include:

  • Custom embedded video players
  • Mobile phone applications
  • Administration platforms
  • Streaming clouds and servers
  • Android and iOS SDKs with sample codes and apps
  • CDNs

Thus far, we have discussed how live streaming works on a very macro level. In the next section, we’ll show you how to live stream on a micro level; in our case, by delivering live stream video from one mobile device to another mobile device using Wowza’s products.

Introducing Wowza

Founded in 2005, Wowza is a leader in video streaming and video platform software. They offer different types of live streaming including live video, on-demand video, audio only, and IP camera streams. Wowza is also the only infrastructure provider for streaming VR and 360° video. Some examples of their products include:

  • ClearCaster – appliance for broadcast-quality, reliable streaming on Facebook Live
  • Streaming Cloud – fully managed cloud streaming service to power live streaming end-to-end or as one part of a custom streaming platform
  • Streaming Engine – downloadable media server software to power live and on-demand streaming, on premises or in the cloud, with fully customizable software
  • GoCoder Mobile App and SDKs – cross-platform mobile app and SDK for live mobile streaming, enabling video capture and encoding on iOS and Android devices

Using Wowza tools to build our app

We wanted to build a platform to record live video on one mobile device and receive it in our mobile application. We used Wowza GoCoder app and SDK to record the live video. You can sign up for a trial version of the SDK from the website and can download GoCoder from the Android and iOs app stores.

For playback, we implemented Wowza player in our Android app using the provided SDK. After we downloaded Wowza GoCoder, our next step was to set up Wowza Streaming Cloud and GoCoder.

Setting up Wowza Cloud and GoCoder

Registering for Wowza Cloud and using it is pretty straightforward. This link guides you through the Cloud setup. For our configuration, we selected Wowza GoCoder application to record live stream video and left the other settings as default. We recommend disabling authentication for first-time use.

You can also choose to create web page with video player where you can watch your live stream. This feature is excellent, as it can be used for testing, and theoretically, for hosting the stream directly on that page, as it can be white-labeled. After you finish setting up Wowza Cloud, you can connect to the Cloud from GoCoder app. To set up a live stream, follow these steps:

  1. Navigate to the Overview page and locate the activation code.
  2. Enter the code in the GoCoder app and select Start Live Stream on the Cloud web page. It may take a few minutes for the stream to start.
  3. Start recording video from your mobile phone. Your video should appear in the Video Thumbnail section, and your connection statistics should display in the Statistics section. You should see a page similar to this:

Implementing the Wowza Player™

Wowza’s tutorials are well-written and easy to understand. We followed basic tutorials to include Android SDK and implement Wowza video player in our app. The SDK also includes a sample application with all functions of an SDK. You can find all relevant informations about the SDK and API using this link.

It was easy to implement Wowza player. The product documentation is well-written and covered nearly all of the topics we were interested in. There were a few steps that needed clarification, so we included them in the next section. Note that our implementation was in Android OS. Although our comments pertain to Android, the basic idea might also be applicable to iOS.

Entering your trial license key

When you are first setting up your project, remember to enter your Trial License key in your Activity class. This is the key you obtained after registering the trial version of the Wowza SDK:

WowzaGoCoder.init(getApplicationContext(), "GOSK-xxxx-xxxx-xxxx-xxxx-xxxx");

Another part is setting the configuration of the player in your app. In this section of code, I’ll describe some details:

WOWZPlayerConfig mStreamPlayerConfig = new WOWZPlayerConfig();
mStreamPlayerConfig.setIsPlayback(true);
mStreamPlayerConfig.setHostAddress("f5b03e.entrypoint.cloud.wowza.com");
mStreamPlayerConfig.setApplicationName("app-05ee");
mStreamPlayerConfig.setStreamName("89cddf9b");
mStreamPlayerConfig.setPortNumber(1935);

We need to include details from Cloud web page, so we can connect our app to the Cloud player. These settings are not as straightforward, so we wanted to clarify them here:

  • setHostAddress – use just part of the link in Primary Server section as underlined above. You can also choose generated IP after you Start Live Stream, but IP can change after restart.
  • setApplicationName – use the last part of Primary Server link, in our case: app-05ee

If you want to Enable Authentication, you need to add these lines in your code:

mStreamPlayerConfig.setUsername("Source Username");
mStreamPlayerConfig.setPassword("Source Password");

Checking errors and statuses

As with any installation, it is always a good idea to check for errors and statuses. As your Activity class implements the WOWZStatusCallback interface, it provides callback methods. You can log some of status methods inside them as follows:

class StatusCallback implements WOWZStatusCallback {
   @Override
   public void onWZStatus(WOWZStatus wzStatus) {
      System.out.println(wzStatus.getLastError());
   }
   @Override
   public void onWZError(WOWZStatus wzStatus) {
      System.out.println(wzStatus.getLastError());
   }
}

You can also log some of these directly on the Wowza Streaming Player:

mStreamPlayerView.getCurrentStatus();
mStreamPlayerView.getStreamConfig();
mStreamPlayerView.getStreamStats();

More information about logging can be found here.

Running the app

Here is the video demonstrating our final integration of the live stream:

Conclusion

If you are thinking about implementing live streaming in your application/platform, Wowza platform offers all the products you need to do so. Their apps and cloud are ready to use. We were able to set them up in a few hours and did not run into any blocker issues. The number of tutorials and guides is also very pleasant.

If you are targeting a local region or country (in our example, the Czech Republic), you could deploy Wowza Streaming Engine on your own servers, which would be much closer to your target audience.


Also published on Medium.

Petr Matej

Leave a Reply

Related articles

Contact us now

Your message has been sent. Thank you!