 |
R E F E R E N C E D E S I G N |
|
|
|
VIP6086N Advanced digital VOD client based on VIA C3 667MHz |
|
|
|
RG100 Residential Gateway for SOHO and home use |
|
 |
RouterLinux
1.1 based on 100% open source OS to full feature
router |
|
|
 |
|
|
MPEG4 playback development procedure in Linux courtesy of Rafael Barrero, Codehost Inc. |
Before we begin... This procedure is not for the faint of heart. This requires a really good
sense of preparing and configuring kernels, working with kernel modules (compiling, inserting, removing) and linux development (working with gcc, make, and a shell). |
Understanding MPEG playback on the GCT set top box
The GCT set top box comes equipped with two graphics cards. The first graphics card is the TVIA on-board card that handles VGA, composite, and S-Video out.
The other Sigma card merely decodes MPEGs (and also has an SPDIF output).
** In order to display decoded mpegs, you will need to enable the VPE port for video overlay from the Sigma decoder to the
TVIA chipset. This will require the synclock utility that is part of the TVIA SDK.
*** If you synclock before there is data in the video buffer of the MPEG decoder, you will either experience a system
crash, or your video outputs will be unusable. This is why you have to play the video and then initiate the synclock utility.
Warning: During my testing of these drivers, I have found that
depending on the use, you may crash your system or lose your display (in FB mode). Some people have found it easier to laod X windows in order to setup these drivers. However, becuase of my system
restraints, I did not use XFree86 at all, and was able to get this up-and-running in no time. I'll explain later on the advantages and drawbacks of XFree86 and the FrameBuffer approach.
Here we go...
|
If you plan on doing your testing in console mode, I would definitely make use of the TVIA
framebuffer. Load the framebuffer module for your particular kernel.
0. insmod tviafb.o
This will give you a framebuffer console and will allow you some luxuries while testing that a normal
text mode console would not. I also found I had fewer crashes this way. Note: If you want to load this framebuffer module, you will require some basic FB infrastructure compiled into your kernel. See tvia
docs.
1. Gunzip and Untar the drivers (Netstream2000-1.3.62.0.tar.gz)
tar zxvpf Netstream2000-1.3.62.0.tar.gz
2. Compile and load the real magic kerneldriver
cd Netstream2000-1.3.62.0/
./loaddriver 0x8471 (in our case, we're using the mpeg1/2/4 card)
This script will compile the kernel module, insert it and set some environment variables. The 'loaddriver' script takes one argument as
input: 0x8400 or 0x8471 (depending on your hardware decoder). This basically instructs the script which module to compile.
At this point, you have the module loaded and don't necessarily have to logout and login again.
3. Prepare and build the synclock utility
Using 'pico' or 'vi', edit the slkdemo.c file included in the TVIA SDK (tvia/sdkbin.4.20/sample/synclock/slkdemo.c).
You will see two lines: #define TVMODE PAL640x480 #define STD PAL
Change these values to fit your desired output device. Mine look like this:
#define TVMODE NTSC640x480 #define STD NTSC
Now find the line that calls the synclock function. Looks like:
Tvia_DoSyncLock(PORTB, STD, TVMODE, FORMAT);
Change it to:
Tvia_DoSyncLock(PORTA, STD, TVMODE, FORMAT);
Change PORTB to PORTA becuase that's what the GCT folks say we're using.
Type 'make'
If you have build problems, make sure you have your includes and libraries in the right place so that the compiler can find them and use them during compilation.
After compilation, you will have a 'slkdemo' binary. This is your synclock utility!
4. Play your movie
The Sigma Real Magic drivers include some utilities that utilize their API to decode
mpegs. One of these utilities is named 'playfile'. To run this file, you will need to make sure you have the appropriate library dependencies resolved.
You can determine the library dependancies by typing:
ldd playfile
If there are any missing libraries (aka "not found"), locate the Real Magic library directory and add it to your
LD_LIBRARY_PATH or /etc/ld.so.conf file.
For example:
./playfile ./playfile: error in loading shared libraries: libEM84xx.so: cannot open shared object file: no such file or directory
ldd playfile libpthread.so.0 => /lib/libpthread.so.0 (address) libEM84xx.so => (not found) libc.so.6 => /lib/libc.so.6 /lib/ld-linux.so.2 => /lib/ld-linux.so.2
export LD_LIBRARY_PATH=/root/Netstream2000-1.3.62.0/lib/
./playfile (Now it will run and give you usage information)
For my example, I'll play a local MPEG file on my hard drive:
./playfile s /root/video-files/my_movie.mpg
5. Run the synclock utility (slkdemo)
As soon as you have the movie playing, you'll need to run the synclock utility to actually see anything on the output monitor.
If you are running X-Windows, you can simply open another xterm and run the slkdemo binary.
If you don't want to run X-Windows (like me), you can switch to another console (Alt-F2) and run the slkdemo
from there. Please note that if you don't have the tviafb.o module loaded, you may have problems switching to-and-fro from consoles in text mode.
./slkdemo
At this point, you should see the mpeg playback on the output device (composite and s-video only - no vga).
6. Automation
Becuase this is a tedious manual process, we have created some shell
scripts that will insert the appropriate modules, setup the correct environment and run the utilities. The 'loaddriver' script will also do some of this, but it will also compile the kernel module each and
every time, and not play the files, or run the synclock utility.
<snippit> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export USE_KERNEL_CDROM_SEND_PACKET=/yes
export USE_DRIVE=/dev/hdc
insmod tviafb.o insmod realmagic84xx.o quasar_dev_id=0x8471
/usr/local/bin/playfile s /root/my_movie.mpg
/usr/local/bin/slkdemo
</snippit>
7. Further development
Here at Codehost, I found the task of running the 'slkdemo' utility after the 'playfile' a real pain to deal with when attempting to automate and simplify our platform.
In this case, I merged both the 'playfile' source and the 'slkdemo' source into one binary that would handle the two functions appropriately. We also customized the 'playfile' program so that it would
play any number of files it was passed.
8. Help and Resources
GCT AllWell (
tony@gctglobal.com) Codehost (rbarrero@codehost.com
Hope this helps!
-- Rafael Barrero
Sr. Systems Engineer Codehost, IncOther resources:
Digital Video Overlay (DIY Linux test program w/ Source Code) by Ian Levy Remote Control Linux souce Code for DVD playback
by Williams J. Stotts
|
sales@gctglobal.com
|
|
|