Search Results for

    Show / Hide Table of Contents

    Support H.264

    The two video codecs supported by LiveSwitch are VP8 and H.264. All LiveSwitch SDKs support VP8 out-of-the-box, and almost all LiveSwitch SDKs support H.264 as well, but using H.264 in .NET and Android clients requires some additional steps to enable. For these platforms, LiveSwitch uses the OpenH264 library (developed and maintained by Cisco) to provide support for H.264 encoding and decoding. This documentation outlines best practices for working with OpenH264 and adding support for H.264 to your client applications.

    Examples

    Note

    The example applications shipped in the Client SDK demonstrate working code for handling H.264 and follow the best practices outlined here.

    Licensing

    As mentioned, the OpenH264 library is provided by Cisco. It is free to use but there are restrictions when including the binaries in your distributions. The full license terms are available here, but generally if you ship any of the binaries in your release then you must pay the corresponding royalties to MPEG LA. That is why all of the LiveSwitch client example apps download the appropriate version of the library at runtime. Read on to see how.

    Platform Support for H.264

    Web

    Browsers supply their own codecs internally. You do not need to do anything special to support H.264 in Web clients. It depends solely on whether the browser supports the codec.

    Chrome Firefox Edge (40+) IE11 Safari Chrome on Android Safari on iOS Firefox on Android Firefox on iOS Opera
    Yes Yes Yes No Yes No Yes Yes Receive Only Yes
    • Receive Only - getUserMedia is not supported by the browser, so while the codecs are supported, receive only streams are possible whereas send/receive or send only streams are not supported.

    Native Platforms

    .NET Android iOS Obj-C iOS Swift macOS Obj-C macOS Swift .NET MAUI
    Yes Partial1 Partial2 Partial2 Partial2 Partial2 No
    1. On Android, Cisco currently provides OpenH264 binaries for armeabi-v7a only.
    2. Both macOS and iOS support H.264 natively, but there are known issues with VideoToolbox on macOS and iOS that limit H.264 support on these platforms.

    Media Servers

    LiveSwitch Media Servers are already set up to support H.264 as per the best practices outlined here. Your Media Servers download and install the OpenH264 binary automatically. The only action required to enable H.264 on your Media Server is to add the configuration option to turn the feature on. See Video Codecs in the Channel Configuration documentation for more information.

    SFU/MCU Transcoding

    With SFU & MCU connections, the video flows through the Media Server so if 2 clients support different encodings the Media Server will automatically transcode the video as needed. For example, in an SFU connection if user A is sending H.264 up, and user B can only decode VP8, then the Media Server will receive that H.264 video data from user A and transcode it to VP8 on the fly and send that VP8 video data to user B. This happens seamlessly in real-time, with minimal impact on latency or quality

    Note

    Even for those clients that cannot support H.264, either natively or using OpenH264, if you are using MCU/SFU connections then transcoding solves this interoperability problem for you.

    Work With OpenH264

    Downloading the OpenH264 Binary at Runtime

    LiveSwitch provides a utility class that can be easily used to download the appropriate version of the OpenH264 binary at runtime. The utility makes use of a static function DownloadOpenH264 to do the heavy lifting, and it returns a promise that allows you to execute additional code when the download completes, and handle any error case. What follows is a code sample demonstrating how to do this. This same code is shipped in the LiveSwitch Client SDK example applications and can be copied directly from those examples.

    Note

    On Linux-based machines, the OpenH264 binary needs to be downloaded into the runtimes/linux-x64/native subdirectory of your application path.

    • CSharp
    • Android
    #if LINUX
    FM.LiveSwitch.OpenH264.Utility.DownloadOpenH264($"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}/runtimes/linux-x64/native").Then((o) => {
        // Success! The download is complete
        ... start local media ...
    })
    .Fail((ex) => {
        // Failure ... the download failed. Perhaps there is no network connection.
    });
    #else // WINDOWS or other platforms
    // OpenH264 library needs to be downloaded into 'runtimes/linux-x64/native'
    FM.LiveSwitch.OpenH264.Utility.DownloadOpenH264().Then((o) => {
        // Success! The download is complete
        ... start local media ...
    })
    .Fail((ex) => {
        // Failure ... the download failed. Perhaps there is no network connection.
    });
    #endif
    
    fm.liveswitch.openh264.Utility.downloadOpenH264().then((o) -> {
        // Success! The download is complete
        ... start local media ...
    })
    .fail((ex) => {
        // Failure ... the download failed. Perhaps there is no network connection.
    
    });
    

    Best Practices

    For the best user experience we recommend that you:

    • Download the OpenH264 library prior to starting local media.
    • If the app is installable (for example, desktop) you can download at install-time - as long as the download takes place on the client device.
    In This Article
    Back to top Copyright © LiveSwitch Inc. All Rights Reserved.Documentation for LiveSwitch Version 1.24.5