Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.
Introduction
NexStreaming is a global mobile software company with headquarters in Seoul, Korea and branches in Spain, United States, Japan, and China. Its most popular product, NexPlayer* SDK, is a player SDK used by some of the most famous video service providers integrated into mobile applications. The player is compatible with all the leading DRM technologies in the industry. Moreover, it can be combined with other complementing technologies such as advertisement insertion, audience measurements, or audio enhancements. NexStreaming NexPlayer SDK provides audio and video decoding and playback services. Application developers can use the SDK to build custom efficient multimedia players quickly. NexPlayer SDK is reliable and robust and has proven to be compatible with international standards. This paper describes how to create an x86 player app using the NexPlayer SDK.
Platform Compatibility
The NexPlayer SDK is optimized for x86, so it is fully supported by x86 devices. NexPlayer SDK supports the following:
- Android* 1.6 or above
- mp4, 3gp, avi, asf, piff video file formats
- HTTP Live Streaming version 5.0, 3GPP Progressive Download, AES128, HTTPS protocols, h.264, AAC, AAC+, eAAC+ codecs. Both software and hardware codecs are supported by the SDK.
- .smi, .srt, .sub, 3GPP timed text, TTML closed captions (PIFF/CFF only), CEA 608 and CEA 708 closed captions, and Web Video Text Tracks (WebVTT)
How to create an x86 player app using NexPlayer SDK
You need to request the SDK from NexStreaming http://www.nexstreaming.com/downloads-sdk. Once you downloaded the SDK and the demo app, the optimization for the Intel® chipsets will be automatically included. Full documentation is included with the SDK. Refer to the SDK documentation and samples to select the APIs appropriate for your application. App development using the SDK is very easy and straightforward. You can use sample code as a guide. It takes about one hour to develop a complete app with NexPlayer SDK.
To integrate NexPlayer SDK into an x86 Android app and ensure the best experience with the NexPlayer SDK on Intel® devices, you need to perform the following simple steps.
- Copy the libs contained in the SDK/libs/ folder into the assets/x86 folder of your project.
- Copy the libs contained in the SDK/libs folder into the libs/x86 folder of your project.
- Copy the source files contained in the SDK/src folder into the src/com/nexstreaming/nexplayerengine folder of your project.
The NexPlayer SDK will detect that change and use those libraries to take advantage of the Intel resources. Once all libraries are in these directories, switch between ARM and x86 version of an app is automatic and handled by the SDK. If you want to integrate a newer version of NexPlayer SDK, the only thing you need to do is to overwrite the library files above.
NexPlayer SDK includes a large number of libraries including DRM libraries. These libraries are in the app/assets/x86 directory. Required libraries consist of engine, decoders, and the rendering layer:
- libnexplayerengine.so
- libnexalfactory.so
- libnexadaptation_layer_for_dlsdk.so
- libnexralbody_audio.so
- libnexralbody_video_opengl.so
- libnexral_nw_ics.so
- libnexral_nw_jb.so
- libnexcal_oc_ics.so
- libnexcal_oc_jb.so
- libnexcralbody_mc_jb.so
- libnexcal_in_aac_x86.so
- libnexcal_in_mp3_x86.so
- libnexcal_in_amr_x86.so
Some library names contain abbreviations "ics" for Ice Cream Sandwich and "jb" for Jelly Bean. If your app only supports certain version(s) of Android, you can remove the libraries for the unsupported version(s) of the OS.
The libraries that provide support for codecs are:
- libnexcal_h364_x86.so - video lib for H.264
- libnexcal_aac_x86.so - audio lib for AAC, AAC-Plus, and HE-AAC
- libnexcal_mp3_x86.so - audio lib for MP2 and MP3
The following libraries support text captions:
- libnexcal_3gpp_x86.so - for 3GPP timed text captions
- libnexcal_closedcaption_x86.so - for CEA 608 and CEA 708 closed captions
- libnexcal_ttml_x86.so - for TTML (CFF) timed text captions
- libnexcal_webvtt_x86.so - for WebVTT text tracks
To reduce the size of the app, include only the libraries that you need for your app.
The libraries from app/libs/x86 need to be loaded in InitManager()
in Java* source code for the application file. For example, for "NexHDSample" add the corresponding x86 library into app/src/NexHDManager.java in initManager()
:
System.loadLibrary("NexHTTPDownloaderSample_jni");
How to display your x86 app’s video on the screen using the SDK
There are two ways to display a video using NexPLayer SDK: NexVideoRenderer and the OpenGL* renderer. NexVideoRenderer is the recommended way to display video. NexVideoRenderer abstracts the complexities of surface handling and video rendering tasks by choosing the most appropriate renderer based on the device and version of the OS. To implement NexVideoRenderer, do the following:
- Pass in a context (android.content.Context) to the constructor.
- Set up listeners (
NexPlayer.IListener
and NexPlayer.IVideoRendererListener
). - Create an instance of NexPlayer.
- Perform the necessary setup for NexPlayer (
NexPlayer.setNexALFactory
and NexPlayer.init
). - Call init with the NexPlayer instance (NexVideoRenderer.init).
- Add the
NexVideoRenderer
instance as a view to your layout.
A complete example of this renderer is in NexPlayerSample/src/com.nexstreaming.nexplayerengine/NexVideoRenderer.java.
Live Streaming
HTTP Live Streaming supports multiple audio and video streams. setMediaStream()
API allows these streams to be selected from the user interface while content is being played. This is supported by the SDK and is mentioned in this paper just for your information. Three possible use cases are available:
- A variant playlist with alternative audio. In this case video and audio can be selected independently.
- A variant playlist with alternative video. Here each track contains both audio and video, but alternative video streams are available (for example, different camera angles or views of the same content).
- A combination of a variant playlist with alternative video and audio. This use case is a combination of the above cases, where a main video stream provides video tracks at different bitrates but INCLUDES the same audio, and separate audio tracks are available for optional language selection.
PnP Analysis of x86 NexPlayerDemoApp
In the following analysis I evaluated launch and idle as well as playback of local mp4 files and sample streams of a sample app ("NexPlayerDemoApp") developed using NexPLayer SDK. The analysis was performed with the VTune™ analyzer for Android and Intel® SoC Watch on an Intel® Atom™ processor-based tablet Z3740 @1.6 GHz with Intel® HD Graphics (Gen 7) and Wi-Fi* connected, on Android 4.4.2 (KitKat).
Intel® Atom™ processor-based tablet Z3740 Baseline
Table 1.
NexPlayerDemoApp at Idle
Table 2.
High C0 times on the Intel® Atom™ processor-based tablet Z3740 during the application idle will result in increased power consumption, but this is not the case with NexPlayerDemoApp. The numbers are very close to Z3740 baseline.
NexPlayerDemoApp at Launch
Table 3.
The numbers are very close to Z3740 baseline.
Video Playback
During video playback, the x86 version of NexPlayerDemoApp utilizes an average of 33% of the CPU. The activity does not show abnormalities and is consistent with the core total.
Figure 1. Video Playback Time View for x86 NexPlayerDemoApp.
Live Streaming
During live streaming, the x86 version of NexPlayerDemoApp utilizes an average of 25% of the CPU. The activity does not show abnormalities and is consistent with the core total.
Figure 2. Live Streaming Time View for x86 NexPlayerDemoApp.
Battery Consumption
x86 NexPlayerDemoApp utilizes ~3.8W of power during the combination of live streaming (taking the majority of time), video playback, and a very short idle in x86 version.
Conclusion
Developing apps with the NexPlayer SDK is fast and easy and proves to be efficient with low power utilization on x86 mobile devices.
About the Author
Lana Lindberg is a member of the Intel® Software and Solutions Group (SSG), Developer Relations Division, Intel® Atom™ Processor High Touch Software Enabling team. Before joining SSG, Lana was OpenGL ES test developer in graphics software validation team for the Ultra Mobility Group.
References and Helpful Links
- NexStreaming NexPlayer Software-Hardware SDK for Android Version 6.28 Technical Reference Manual. NexStreaming Corporation, January 8, 2015.
- NexStreaming website www.nexstreaming.com