Step 1: Building and using the plug-in

This step explains how to build the source code and getting the plug-in to run. The intention is to help you eliminate possible build and boot problems, so you can concentrate on essential coding issues later on.

You don't need to start coding or look at source code at this step yet. However, you need to have a Makefile, which is the "recipe" for how the individual source files are cooked together to form the plug-in. The Makefile is also responsible for taking this plug-in, and producing an IIP (IP-STB Installation Package) from it. An IIP is a package containing the plug-in, some data files and installation information. This IIP is included when building the boot image, and the boot image is used when booting the set-top box.

If the KreaTV Software Development Kit (SDK) is not installed on your system, do that first. Follow the Installation guide provided with your SDK package.

1.1  Write your own plug-in

Please refer to General guideline for plug-in coding for more information. Since the purpose of this step is to give you an overview of the whole development process, here we would simply assume that you have all the plug-in code done already.

1.2  Prepare plug-in related make utility

The plug-in code is designed to be put under the /examples directory, and you need to create a sub folder for it. Assuming you will name the folder npruntime-graphical-plugin all your plug-in code should be within /examples/npruntime-graphical-plugin directory now. In order to compile the source code and generate an IIP, you also need to copy and save content of the three files below to this folder with exact same name.

1.3  Adjust Makefile and build the plug-in and IIP

To begin with, let's try to build the plug-in on your local workstation. Your Makefile saved in step 1.1 has to be adjusted for the location of the SDK, which is specified in the DK_DIR make variable. This variable must point to the SDK directory where the products, examples, bin, include/npapi and include/eklibrary_webkit directories are located. You will also need to adjust EXTRA_FLAGS, lib_srcs and package_version , check below or refer instructions from sample Makefile directly for detail.


DK_DIR = $(CURDIR)/../.. # You can adjust the location of "DK_DIR" here, but better leave it as it is.

EXTRA_FLAGS = -DXP_UNIX # XP_UNIX is a must-have macro. You may need add your own define here.

lib_srcs += YourSource1.cpp # Add all your source files here for compiling.
lib_srcs += YourSource2.cpp

package_version = BSG_BUILD_VERSION # Replace "BSG_BUILD_VERSION" with the "Version" string available in $(DK_DIR)/sdk/build_data.xml.

To build the source files please type the following command:

make VIP=st40  # This will build for ST based STBs like VIP19xx and VIP1003.

The make utility should compile all the C++ source files and then link the results to produce the plug-in.

The resulting plug-in (libnpplugin.so) will also be combined with the contents of the IIP directory to produce the IIP file. Remember to copy this IIP file to the SDK's products directory.

1.4  Build a boot image for your IP-STB

You will need to change to the SDK's examples/build_scripts/ directory now. Edit the config file and add the following line, so the newly built and copied IIP will be included when building a boot image. And please make sure either SVG or Webkit is included in the config file.

example-npruntime-graphical-plugin

A complete discussion of building boot images is beyond the scope of this tutorial. Refer to the documentation:Building a boot image if you are unsure on how to build a boot image. You can also refer to Boot IP-STB with TFTP and How to NFS mount the IP-STB software for booting the IP-STB with it.

The plug-in will be installed in the /usr/browser/plugins directory on the rootdisk.

1.5  Test your plug-in.

Create an HTML page and embed the plug-in object. For more information about the HTML elements to use, see Using HTML to display plug-ins. To see your plug-in in action, simply display the HTML page that calls it in the browser.

You can also use test pages (test.html, test.svg, testdyn.svg) in the sample code to start your first test and debug. Once you have created a boot image, boot the box and start the browser, the plug-in will be loaded automatically when you use these test pages.