One of the most common questions we get asked at Mux is "How do I send the RTMP stream from my application".
The Real-Time Messaging Protocol (RTMP) is the most common protocol for creating live streams and sending them to a live streaming service, such as Mux. While RTMP is ubiquitous, as I talked about in depth at Mile High video a couple of weeks ago, it also has significant technical shortcomings when used over the public internet, but that's a subject for another blog post.
The biggest consequence of RTMP's shortcomings is that it's highly sensitive to TCP disconnects. As such, it's critical that any RTMP client implements retry logic around dropped RTMP connections so that they can take advantage of our reconnect window feature. This functionality minimizes the interruption to viewers if the RTMP connection drops unexpectedly.
While many of the RTMP streams that we receive come from desktop applications like OBS, Wirecast, XSplit, or vMix, over the last year we've also seen a huge increase in the number of our customer streaming from mobile devices.
This is because 2020 was different. 2020 was a year where yoga teachers, professors, fitness instructors, standup comedians and even F1 drivers have all become live streamers. While there's a plethora of apps available to create RTMP streams, these often are not the most accessible for non-technical users to configure for their live streams.
For a long time, we've had example applications, demonstrating how to create RTMP streams from iOS and Android using free and open source software. Over time, though, these examples had become distanced from modern best practices; they didn't handle RTMP disconnects well and didn't leverage adaptive bitrate ingest technologies to provide the best performance on variable networks.
We've spent the last couple of weeks putting together updated example applications, which still use the best tools that free and open source software has to offer, but with up-to-date approaches, and a shiny coat of paint.
iOS
On iOS we've rebuilt the example application around the HaishinKit library on a modern toolchain based around XCode 12 with a minimum iOS version of 11. This new example demonstrates most of the common functionality you'd expect from a broadcasting app, including:
- Mid-stream camera switching
- Reconnects on network dropout or network change (EG: Wifi => 4G)
- RTMP Adaptive Bitrate
- FPS and Bitrate monitoring
- 4 basic profiles broadcasting profiles from 360p @ 1mbps to 1080p @ 5mbps
- Rotation prior to broadcast start
While functionality is important, it's also key that the app looks and feels good too, and works elegantly on dark mode. We also made sure it works across a large range of devices, old and new, and even works nicely on iPads.
Android
On Android, we've chosen to use rtmp-rtsp-stream-client-java for our updated application - this has allowed us to develop a modern Android application, with full support for many premium features in only a few hundred lines of Java.
Again, this application is built on a modern toolchain (Android Studio 4.1), and runs on a good variety of Android devices, and targets API version 21 and upwards (that's Android 5.0, around 94% of devices globally). This application also implements most of the features that our iOS application does.
Support
One of the most important changes we've made outside of updating the examples is that we're committing to keep them up-to-date, and maintain them more actively. While we won't formally support any functionality that's not in our example, we'll investigate and do our best to resolve issues found in our implementations. Wherever possible, we'll work with the maintainers of HaishinKit and rtmp-rtsp-stream-client-java to make sure that any underlying issues are raised.
If you're looking for more commercial support on RTMP ingest SDKs for iOS and Android, we continue to recommend that you take a look at either Streamaxia or Larix. Both provide commercially supported RTMP SDKs which have been battle tested with Mux.
The cross-platform 🐘 in the room
Of course, it goes without saying that native applications aren't the only way that people build mobile apps in 2020, toolchains like react-native continue to make significant gains on traditional application development.
We'd love to open source the react-native example application that Erik showed off in his blog article a couple of weeks ago, but we're just waiting for a couple of licensing issues to be resolved in react-native-nodemediaclient before we publish it.
As always, we'd love feedback on our open source and example apps, or even better if you want to contribute to them, we'd love to send you a swag kit to say thanks!