📜 ⬆️ ⬇️

Application Development with NexStreaming NexPlayer SDK

Developing a mobile player application is not easy. It is necessary to provide support for many formats of video, audio, subtitles. We'll have to implement the playback of files that are stored locally and on the Internet. If we recall that the result of all these works will be performed in an environment whose resources should be treated carefully, we will have to tackle optimization. How to approach the creation of high-quality, fast and economical player for Android? NexPlayer SDK will help to answer this question.



Preliminary Information


NexStreaming is a global company that develops software for mobile devices. NexStreaming is headquartered in Seoul, Korea, with branches located in Spain, the United States, Japan and China. NexPlayer SDK is its most popular product. This is a software development kit for creating players. It is used in its mobile applications by some very well-known companies that stream video. The player is compatible with all modern DRM-technologies. In addition, its basic functionality can be expanded. For example, add tools to improve the sound, support for advertising inserts, functions of collecting statistical information about the audience.

NexPlayer SDK from NexStreaming provides the means to decode and play video and audio data. Application developers can use the SDK to quickly create their own products. NexPlayer SDK is reliable, stable, compatible with international standards. From this material, you will learn how to create a player designed for the x86 architecture using the NexPlayer SDK.
')

Main features


NexPlayer SDK is optimized for the x86 platform, that is, it is fully supported by devices built on this platform. Here are the main features of the SDK:


How to create a player for the x86 platform using the NexPlayer SDK


First you need to download the SDK from the NexStreaming website, filling out a small form and waiting for an e-mail with the data to enter the closed section of the site, where the materials are located. In particular, among the materials available for download, you can find a demo application in an .apk file that can be immediately installed on an Android device, a sample project that can be imported into the IDE, the SDK itself as a set of libraries, and its documentation . In order to decide which libraries you need, you should read the documentation and look at the examples. Developing an application using the NexPlayer SDK is quite simple and straightforward, and the presence of examples contributes to its rapid development. It takes about an hour to create a working application that uses the NexPlayer SDK.

Integration of the NexPlayer SDK into an Android application designed for the x86 platform consists in copying libraries and source code from the SDK to your project. By following a few simple steps, described below, you will equip the application with basic components that will allow it to work perfectly on devices built on the basis of components from Intel. So, the preparatory stage is as follows:


The set of copied libraries depends on the needs of your application. In order to understand exactly which libraries you need, you should look at the demo and use the recommendations given below.

After copying, NexPlayer SDK will detect changes and will be able to use libraries to organize efficient work with Intel resources. As soon as all the libraries are in the specified directories, the SDK will take over switching between ARM and x86 versions of the application. If you want to update the NexPlayer SDK libraries in an existing project, just overwrite their files.

NexPlayer SDK includes a large number of libraries, including those that are responsible for supporting DRM. They are located in the app / assets / x86 folder. The required set of libraries includes the player engine (engine), decoders (decoders) and rendering layer (rendering layer). Here is a list of them:


Some of the library names contain the abbreviation "ics". It indicates that the library is designed for Android Ice Cream Sandwich. The abbreviation "jb" says that the library is designed for Android Jelly Bean. If your application is designed to support certain versions of Android, libraries for unsupported versions can be removed.

Here are the libraries responsible for supporting codecs:


The following are the libraries whose task is to support subtitles:


In order to reduce the size of the application, include in the project only those libraries that you need.
Libraries from the app / libs / x86 folder need to be downloaded. This is done in the initManager () method of the corresponding class. For example, to use the “NexHDSample”, you need to load the appropriate x86 library in the aforementioned method of the NexHDManager class (app / src / NexHDManager.java) with the following code:
System.loadLibrary ("NexHTTPDownloaderSample_jni");

How to display video on the screen of an application designed for the x86 platform


When working with the NexPlayer SDK, there are two ways to display video. This is the use of NexVideoRenderer and OpenGL based output subsystems. It is recommended to use NexVideoRenderer. The point is that this subsystem provides a level of abstraction on complex operations of managing surfaces and video output tasks. It selects the most appropriate way to output video based on the hardware of the device and the operating system installed on it.

In order to use NexVideoRenderer, you need to do the following:

  1. Pass the context (android.context.Context) to the constructor.
  2. Install event listeners (NexPlayer.IListener and NexPlayer.IVideoRendererListener).
  3. Create an instance of an object of the NexPlayer class.
  4. Make the necessary training NexPlayer (use the methods NexPlayer.setNexAlFactory and NexPlayer.init).
  5. Call the init method of the NexVideoRenderer class object (NexVideoRenderer.init).
  6. Add an instance of NexVideoRenderer as an interface element to the layout.

The NexVideoRenderer class code can be found among SDK usage examples at NexPlayerSample / src / com / nexstreaming / nexplayerengine / NexVideoRenderer.java

Streaming broadcast


HTTP Live Streaming technology allows you to work with several audio and video streams. The SDK supports this feature; its setMediaStream () API allows you to select streams for playback. This can be done from the user interface while playing materials. There are the following options for working with video and sound:

  1. Use a playlist with various soundtrack options. Video and sound with this approach can be selected independently.

  2. Use a playlist with various video options. Each video clip being played contains both sound and video, but the user can select alternative video options. For example, it may be material shot by a camera from different angles or from different points.

  3. The combination of lists of available audio tracks and video. This is a mixture of the two options described above. The main video stream provides video tracks in different bitrates, but reproduced with the same sound. Additional audio tracks are also available, for example, in different languages.

Analysis of performance and power consumption x86-applications NexPlayerDemoApp


Below are the test results, during which the load on the system created by the NexPlayerDemoApp application at startup, simple, playing a local MP4 file and playing streaming video is estimated. The application is developed using the NexPlayer SDK. The VTune analyzer for Android was used for the analysis, as well as the Intel SoC Watch. The tests were carried out on a tablet on which Android 4.4.2 was installed. It is equipped with a 1.6 GHz Intel Atom Z3740 processor and Intel HD Graphics (Gen 7) graphics accelerator. The device is connected to the Internet via Wi-Fi.

Measurement reference point for a device built on the Intel Atom Z3740 processor
Batch processor status% of time spent in the specified state, core # 0% of time spent in the specified state, core number 1% of time spent in the specified state, core number 2% of time spent in the specified state, core number 3% of the time the graphics core
C04.002.500.400.400.30
C695.0095.1098.3098.1099.50

NexPlayerDemoApp application in idle state
Batch processor status% of time spent in the specified state, core # 0% of time spent in the specified state, core number 1% of time spent in the specified state, core number 2% of time spent in the specified state, core number 3% of the time the graphics core
C04.803.701.20.900.00
C693.5094.1093.4093.90100.00

The more time the Intel Atom Z3740 processor spends in the C0 state when the application is idle, the higher the power consumption. In the case of NexPlayerDemoApp, the use of the processor is very close to the reference point of measurement, as a result - the inaction of the application does not create an unnecessary load on the system.

NexPlayerDemoApp application at startup
Batch processor status% of time spent in the specified state, core # 0% of time spent in the specified state, core number 1% of time spent in the specified state, core number 2% of time spent in the specified state, core number 3% of the time the graphics core
C04.803.701.20.900.90
C693.5094.1093.4093.9099.00

These data are also very close to the reference point of measurement.

Playing local video


When playing video, the x86 version of the NexPlayerDemoApp application uses, on average, 33% of processor power. When analyzing this task, no anomalies were identified, and when it is executed, a uniform load is created on the processor.


The load on the processor created by the x86 NexPlayerDemoApp application when playing local video

Streaming video playback


When playing streaming video, the x86 version of the NexPlayerDemoApp application uses, on average, 25% processor power. When analyzing this task, no anomalies were identified, and when it is executed, a uniform load is created on the processor.


The load on the processor generated by the x86 NexPlayerDemoApp application when playing streaming video

power usage


The power consumption of the x86 version of the NexPlayerDemoApp application was approximately 3.8 watts. Most of the time during the measurements, streaming video was played, there was a short period of inactivity. The rest of the time was spent playing back the local video file.

NexPlayerDemoApp app on Android 5.0 Lollipop


Find out how the demo application built using the NexPlayer SDK works on Android 5.0 Lollipop. To test use the tablet Asus Fonepad 8 based on the CPU Intel Atom Z3530. The device is connected to the Internet via Wi-Fi.


Application main screen

On the main screen of the application you can find several buttons:


During the test, the application coped with its functions. In particular, videos from various sources were played at the correct speed and without delays.


Local video playback

Results


With the help of the NexPlayer SDK, you can quickly and easily develop applications whose main task is video playback. In addition, the tests prove the efficiency and low power consumption of such applications on devices built on the x86 platform.

Source: https://habr.com/ru/post/264103/


All Articles