Software Development UkraineSoftware Development Outsourcing Provider in Ukraine
AVLib +

Enabling instant video streaming for Android applications

INTRODUCTION

AVLib is an example of overcoming a technological obstacle and coming up with an elegant and flexible solution that had no equivalent on the market.

Onix’ team encountered the problem while working on YouStream,  our live streaming mobile application.  The app had to stream video and audio data at its maximum capacity through the phone’s camera and to restream video from action cameras like GoPro.  It was also necessary to enable support of Android 4.1 as the minimum version,  so that users with older mobile devices could use the application,  and to offer a number of convenient usability settings.

Onix team conducted thorough research to compare existing streaming libraries.  It turned out there was no solution in the market that could perfectly meet our technical needs.

Existing eligible solutions were raw and full of bugs,  commercial libraries worked worse than open-source ones,  and none of them could stream from action cameras and be stable on low Internet connection.

The team quickly decided to create our own external library that could support RTMP streaming for Android.  Since there is a vast number of Android devices and OS versions currently in use,  this library was to support streaming needs of all current Android users.

It was also our ambition to build a flexible and simple RTMP library that any other Android team or developer could integrate into their app.  The library should be lightweight,  and allow integration with two clicks.  And we did it!

The Development,  Technology Stack,  and Challenges

The RTMP library,  which we called AVLib,  took a few months to develop.

To endow it with a high capacity potential, our team chose the C programming language.  The modules which were in charge of encoding,  work with RTMP,  and up to processing,  were built using pure C for maximum performance of the whole system.

The development process was full of challenges and required significant effort and ingenuity from our team.  The entire encoding pipeline and RTMP protocol were implemented in the native module for maximum performance.  One of the challenges was to enable AVLib to stream video and audio from action cameras on the fly.  To enable this feature,  simultaneous work with two network interfaces on the side of the module in C was required.  Making two networks work correctly required thorough research of the source code of Android OS and continuous debugging.

At one point,  the developers had to patch libRtmp and solve the problem of simultaneous work with two network interfaces.  The trickiest part was to make libRtmp work with a socket bound to the selected network.  The problem was that the system after random periods of time was closing the socket created on Java side for a certain network and passed to the libRTMp maze. We did it another way:  bound the socket created inside libRtmp via fwmarkd to the specified network.

Another significant challenge was enabling smooth work with the camera and processing of the broadcast life cycle on different devices. That was rather time-consuming and required careful scrutiny.

The resulting solution is AVLib (aar library) + demo with several pages + custom license which allows using the product for commercial purposes without opening sources.

The Story of the YouStream Mobile App
AVLib became part of a nifty mobile app that allowed users instantly,  in one click,  to start broadcasting on their YouTube channel and share a direct link to the stream.  The minimum viable product consisted of a few screens and featured a simple yet showy user interface.
YouStream was published on Google Play Store in February 2018,  and during the first six months,  enjoyed fine ratings and moderate yet steady user growth.  Despite relatively low retention (the app was not used actively enough),  YouStream was gradually rising in Google Play’s rating list.
The latest version of YouStream was offering:
  • High performance
  • Simple and user-friendly interface
  • Optimal auto-detecting broadcast presets that adjust to the device performance
  • Main/Front cams support
  • Stable running with the low-quality connection
  • Android 4.1+ support
  • FULL HD support
  • No ads or in-app purchases
  • Saving the broadcast mode when the app goes to the background
  • Screen broadcasting (starting from Android 5)
  • Real-time chat with viewers
  • Private and public broadcasts
The team first worked on improving user retention through cycles of assessing the analytics,  user feedback,  and the results of previous experiments,  generating hypotheses,  adding features to validate them,  and analyzing the results.  After several iterations,  live chat and other experimental features helped increase both the number of active users and the retention rate.

A redesign,  mainly focusing on user experience improvements,  followed.  Along with a few more features,  it helped raise the number of downloads.

Everything looked safe and steady,  so we embarked on turning the MVP into a full-fledged app targeting advanced game streamers.  However,  after an ordinary update with bug fixes,  GP rejected it.  Communication with the support concerned an alleged violation of the Impersonation and Intellectual Property policy.  Finally,  we figured out that the app’ s icon was the reason.

The update was approved only after we had tried out several new icon designs and refreshed the entire app’ s visual design.

Google Play kept rejecting updates for about three weeks.  Finally,  for no apparent reason,  the number of installs across all countries plummeted.

Whether it was the number of rejections that through GP’s algorithms affected YouStream’s ranking or just a coincidence,  remains a mystery.  Anyway,  nothing would help the app climb back into the app store’s top search results.
YouStream uses Youtube API for the creation and management of streams on a user’s own channel.   By accident,  the team lost access to the user account under which they created the project for YouStream on Google Cloud.  Therefore,  the project on Google Cloud became inaccessible.  Long communication with the support service didn’t help.
THE RESULTS
The team could not make the YouStream app popular again,   but we were left with the priceless experience and valuable lessons:
It’ s essential to make even an MVP’ s design as beautiful,  bright,  and eye-catching as possible.  YouStream was increasing its visitors to installation conversion rate after each design upgrade.
Careful study of the analytics is indispensable.
All experiments should be independent as much as possible of external factors,  such as country,  seasonality,  time of day,  etc.
It’ s better for an application to be elementary than sophisticated.  The lower the entry threshold,  the sooner the users will be spending time in the application.
It’ s imperative to follow all appropriate Google Play policies
In case of a rejection or ban from Google Play,  the app should be fixed and updated as quickly as possible at any cost.  A rejection of an app may kill organic traffic and jeopardize the app’ s popularity.
Take good care of your Google account; use two-factor authentication.  Google may ban you even through the fault of a developer who has nothing to do with your Google Play account.
Most importantly,  we had built AVLib,  a valuable asset that can be used in more products by Onix and third-party developers.
AVLib in Full Effect

AVLib  combines all the desired features and comprehensively solves the basic task of video broadcasting.   AVLib allows streaming from phones and action cameras to any RTMP server and ensures instant stream recording.  The library’ s SDK is compatible with such RTMP servers as Wowza and YouTube.

AVLib is a ready-to-use tool for Android Studio,  the first of its kind on the market.  The software product consists of libraries for ARM (+ARM 64) platforms and Java module.  The library comes as one .aar file without any dependencies.

AVLib perfectly fulfills the following principles:

Easy integration with Android apps

Depending on the type of mobile app,  it takes Android developers one to four hours to add a video/audio streaming feature to their application.  The library is added as a standard module to the Android project with Gradle.

Maximum capacity

The library uses all device’ s resources at their maximum,  ensuring stable video streaming of any complexity level with optimal FPS,  resolution,  and quality.  It supports broadcasting from the MAIN,  FRONT,  and ACTION cameras and DEVICE SCREEN.  It facilitates the use of auto-detection devices and optimal stream configuration.  Users can stream video both for lower stream settings,  such as 720p 30fps,  and Full HD for phones that support high video quality format.  AVLib also automatically determines optimal presets for the encoder, rendering and streaming for maximum performance on each device.

Excellent performance

Depending on a channel’ s capacity,  AVLib automatically determines the quality of the live stream and the bandwidth.  The video streaming is stable even on poor connection,  with reconnecting logic in place.  Users can handle rotation and size changes without re-initing a stream.  They don’t need to figure out how to change screen orientation and restore any stream states and camera preview aspect ratios because AVLib handles all these issues internally.   Because AVLib is based on the use of neon and vfpv3 architectures that enable hardware acceleration,  the Android RTMP player broadcast quality remains excellent with a smaller consumption of battery life.

Customizable

AVLib is flexible and can be easily adjusted to a customer’s requirements for UI design,  such as buttons or text,  and video settings (i.e.  frame resolution,  audio,  codec quality,  disabled audio,  bitrates,  etc.).

Support of all existing types of Android devices

This RTMP library comes as one .aar file with no dependencies.  AVLib is compatible with various Android devices and supports stable work even on outdated and low-performance devices with Android OS as old as version 4.1.

For Whom This Product Is

AVLib provides a simple,  convenient,  stable,  and flexible solution for developers,   teams,  and companies.  The professional software development tool can speed up and facilitate Android app programming,  reducing the time and cost of app development.