How to make OpenELEC addon - on MuMuDVB sample

I'm going to show you how I made MuMuDVB addon. All the files are available here and they will be pushed to repository in near future. Of course this guide is also needed: How to build your own OpenELEC distro

This tutorial is far from perfect but I think it could be good start. Please feel free to comment and improve it.

What is MuMuDVB? MuMuDVB a DVB IPTV streaming software.

MuMuDVB (Multi Multicast DVB) is a program for streaming TV over a network originally based on dvbstream. MuMuDVB can redistribute a stream from a DVB source (digital satellite television, digital terrestrial television, or digital cable television) on a network, in multicast or in HTTP unicast. Its main feature is to take a whole transponder and put each channel on a different multicast group. MuMuDVB have a low memory and CPU footprint and is able to run on embedded platforms.

This is daemon which runs in background on the system. Because we don't want to start from scratch we are going too look if any similar addon exist. And it does - HTS Tvheadend - so we took it as base for MuMuDVB.

Source code for MuMuDVB is found on web page in it's repository: Link we click on a mumudvb project and on last commit click on a snapshot:

http://gitweb.braice.net/gitweb?p=mumudvb;a=snapshot;h=eb19b7e79f06260edd8db09f0496dd39a940635a;sf=tgz

we save this file locally and get filename

mumudvb-eb19b7e79f06260edd8db09f0496dd39a940635a.tar.gz

Because we need real filename we save this file and host it on local server.

Then we need to make few files. First one is file meta. Name is mumudvb, version is eb19b7e79f06260edd8db09f0496dd39a940635a. Url is from web server where we host this file. We are using autoreconf because source code needs that. There are also two depends lines. Because MuMuDVB (or some libraries) require other libraries they must be compiled on it's own as own packages. This will be explained later.

meta file
PKG_NAME="mumudvb" PKG_VERSION="eb19b7e79f06260edd8db09f0496dd39a940635a" PKG_URL="hxxp://dl.dropbox.com/u/8224157/OpenELEC-Ultra/mumudvb/$PKG_NAME-$PKG_VERSION.tar.gz" PKG_DEPENDS="libiconv dvb-apps x264 ffmpeg" PKG_BUILD_DEPENDS="toolchain libiconv dvb-apps x264 ffmpeg" PKG_IS_ADDON="yes" PKG_ADDON_TYPE="xbmc.service" PKG_AUTORECONF="yes"

unpack file
Then we make file unpack. This file is usually not needed because build system do this for us. But in this case is needed because folder in archive doesn't include version. That's why we just rename that folder in unpack script.

patches folder
In patches folder we save any required patches for this sources. In this case we have two: one is for supporting old ffmpeg API and the second is for iconv.

build file
In build script we fix some malloc/realloc functions (maybe could be done better), run configure and make. At the end we get program compiled.

addon file
This script is used to copy required files for addon (program and libraries) from different location to addon folder which is zip-ed at the end.

Addon need one icon in icon folder.

The folder source is main part of the addon. The file default.py starts the service addon file in bin folder. The service file is responsible to start the service.

The script in sleep.d folder is responsible to suspend and resume the service.

We create addon with next command in OpenELEC.tv folder

PROJECT=project ARCH=architecture ./scripts/create_addon mumudvb

for Xtreamer Ultra

PROJECT=Ultra ARCH=x86_64 ./scripts/create_addon mumudvb

and we get addon in target/addons folder. It can be installed manually from XBMC.

package dvb-apps

For CAM support in MuMuDVB two libraries are needed: libucsi and libdvben50221. They are part of dvb-apps package which contains some Linux DVB API applications and a set of utilities.

Source code is found on a web page hxxp://linuxtv.org/hg/dvb-apps Open last commit and on left side is link in .tar.bz2 format we get hxxp://linuxtv.org/hg/dvb-apps/archive/d4e8bf5658ce.tar.bz2

Then we make a meta file. Unpack file is needed to unpack the archive because the archive doesn't have name only version. In build script we just make the libraries and nothing else.

package x264

This package is responsible to make x264 library which is used for encoding video streams into the H.264/MPEG-4 AVC format.

Only meta and build file are used.

http://openelec.tv/forum/20-development-discussion/15752-how-to-make-openelec-addon-on-mumudvb-sample