├── .gitignore ├── CHANGES ├── INSTALL ├── Makefile.am ├── README ├── configure.ac ├── extras └── javasrc │ ├── externalexample │ └── ExternalExample.java │ ├── parser │ ├── DocumentHandler.java │ ├── LICENSE.txt │ ├── MinML.java │ ├── Parser.java │ └── sax │ │ ├── AttributeList.java │ │ ├── DTDHandler.java │ │ ├── DocumentHandler.java │ │ ├── EntityResolver.java │ │ ├── ErrorHandler.java │ │ ├── InputSource.java │ │ ├── Locator.java │ │ ├── Parser.java │ │ ├── SAXException.java │ │ └── SAXParseException.java │ ├── readme.txt │ ├── testste │ └── Testste.java │ └── yambo │ ├── CGIURL.java │ ├── COPYING │ ├── CarouselManager.java │ ├── ColorKeyManager.java │ ├── EventManager.java │ ├── ExternalClass.java │ ├── IFrameManager.java │ ├── InputManager.java │ ├── KeyPad.java │ ├── KeyPadButton.java │ ├── MinMLWizard.java │ ├── NamedItem.java │ ├── Paint.java │ ├── Painter.java │ ├── Print.java │ ├── Printer.java │ ├── RCManager.java │ ├── RCResourceClient.java │ ├── Singer.java │ ├── TextBox.java │ ├── Timer.java │ ├── VideoManager.java │ └── Wizard.java ├── libs ├── Makefile.am ├── dvbobjects │ ├── Makefile.am │ ├── dvbobjects │ │ ├── DSMCC │ │ │ ├── BIOP │ │ │ │ ├── Binding.py │ │ │ │ ├── IOP.py │ │ │ │ ├── Message.py │ │ │ │ ├── ModuleInfo.py │ │ │ │ ├── Tap.py │ │ │ │ └── __init__.py │ │ │ ├── Descriptors.py │ │ │ ├── Message.py │ │ │ ├── STE.py │ │ │ ├── STEO.py │ │ │ └── __init__.py │ │ ├── DVB │ │ │ ├── DataCarousel.py │ │ │ ├── Descriptors.py │ │ │ ├── Loops.py │ │ │ └── __init__.py │ │ ├── MHP │ │ │ ├── AIT.py │ │ │ ├── Descriptors.py │ │ │ └── __init__.py │ │ ├── MPEG │ │ │ ├── DVBH_Descriptors.py │ │ │ ├── Descriptor.py │ │ │ ├── Descriptors.py │ │ │ ├── EBUTeletext.py │ │ │ ├── Section.py │ │ │ └── __init__.py │ │ ├── PSI │ │ │ ├── CAT.py │ │ │ ├── ECM.py │ │ │ ├── EIT.py │ │ │ ├── EMM.py │ │ │ ├── INT.py │ │ │ ├── NIT.py │ │ │ ├── PAT.py │ │ │ ├── PMT.py │ │ │ ├── SDT.py │ │ │ ├── TDT.py │ │ │ ├── TOT.py │ │ │ ├── UNT.py │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── utils │ │ │ ├── ByteInvert.py │ │ │ ├── ByteParity.py │ │ │ ├── DVBobject.py │ │ │ ├── Hamming.py │ │ │ ├── MJD.py │ │ │ ├── SpecFile.py │ │ │ ├── __init__.py │ │ │ └── crc32.py │ ├── sectioncrc.py.c │ └── setup.py └── sectioncrc │ ├── Makefile.am │ ├── sectioncrc.c │ └── sectioncrc.h └── tools ├── Makefile.am ├── dsmcc-receive ├── Makefile.am ├── assoc.c ├── assoc.h ├── biop.c ├── biop.h ├── carousel.c ├── carousel.h ├── dsmcc-receive.c ├── dsmcc.c ├── dsmcc.h ├── filter.c ├── filter.h ├── fs.c ├── fs.h ├── module.c ├── module.h ├── table.c ├── table.h ├── util.c └── utils.h ├── esaudio2pes ├── Makefile.am └── esaudio2pes.c ├── esaudioinfo ├── Makefile.am └── esaudioinfo.c ├── esvideo2pes ├── Makefile.am └── esvideo2pes.c ├── esvideoinfo ├── Makefile.am └── esvideoinfo.c ├── i13942ts ├── Makefile.am └── i13942ts.c ├── mpe2sec ├── Makefile.am └── mpe.c ├── oc2sec ├── Makefile.am ├── file2mod.py ├── mod2sec.py └── oc-update.sh ├── oddparity ├── Makefile.am └── oddparity.c ├── pes2es ├── Makefile.am └── pes2es.c ├── pes2txt ├── Makefile.am └── pes2txt.c ├── pesaudio2ts ├── Makefile.am └── pesaudio2ts.c ├── pesclock ├── Makefile.am └── pesclock.c ├── pesdata2ts ├── Makefile.am └── pesdata2ts.c ├── pesinfo ├── Makefile.am └── pesinfo.c ├── pesvideo2ts ├── Makefile.am └── pesvideo2ts.c ├── sec2ts ├── Makefile.am └── sec2ts.c ├── totsectionrestamp ├── Makefile.am └── totsectionrestamp.c ├── ts2pes ├── Makefile.am └── ts2pes.c ├── ts2sec ├── Makefile.am └── ts2sec.c ├── tscbrmuxer ├── Makefile.am └── tscbrmuxer.c ├── tsccc ├── Makefile.am └── tsccc.c ├── tsdoubleoutput ├── Makefile.am └── tsdoubleoutput.c ├── tsfilter ├── Makefile.am └── tsfilter.c ├── tsfixcc ├── Makefile.am └── tsfixcc.c ├── tsinputswitch ├── Makefile.am └── tsinputswitch.c ├── tsloop ├── Makefile.am └── tsloop.c ├── tsmodder ├── Makefile.am └── tsmodder.c ├── tsnullfiller ├── Makefile.am └── tsnullfiller.c ├── tsnullshaper ├── Makefile.am └── tsnullshaper.c ├── tsoutputswitch ├── Makefile.am └── tsoutputswitch.c ├── tspcrmeasure ├── Makefile.am └── tspcrmeasure.c ├── tspcrstamp ├── Makefile.am └── tspcrstamp.c ├── tspidmapper ├── Makefile.am └── tspidmapper.c ├── tsstamp ├── Makefile.am └── tsstamp.c ├── tstcpreceive ├── Makefile.am └── tstcpreceive.c ├── tstcpsend ├── Makefile.am └── tstcpsend.c ├── tstdt ├── Makefile.am └── tstdt.c ├── tstimedwrite ├── Makefile.am └── tstimedwrite.c ├── tstimeout ├── Makefile.am └── tstimeout.c ├── tsudpreceive ├── Makefile.am └── tsudpreceive.c ├── tsudpsend ├── Makefile.am └── tsudpsend.c ├── tsvbr2cbr ├── Makefile.am └── tsvbr2cbr.c ├── txt2pes ├── Makefile.am └── txt2pes.c ├── vbv ├── Makefile.am ├── plot.p └── vbv.c └── zpipe ├── Makefile.am └── zpipe.c /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | *.o 4 | *.lo 5 | *.la 6 | .deps 7 | .libs 8 | /aclocal.m4 9 | /autom4te.cache 10 | /config.guess 11 | /config.log 12 | /config.status 13 | /config.sub 14 | /configure 15 | /depcomp 16 | /install-sh 17 | /libtool 18 | /ltmain.sh 19 | /missing 20 | /libs/dvbobjects/build/ 21 | /tools/dsmcc-receive/dsmcc-receive 22 | /tools/esaudio2pes/esaudio2pes 23 | /tools/esaudioinfo/esaudioinfo 24 | /tools/esvideo2pes/esvideo2pes 25 | /tools/esvideoinfo/esvideoinfo 26 | /tools/i13942ts/i13942ts 27 | /tools/pes2es/pes2es 28 | /tools/pes2txt/pes2txt 29 | /tools/pesaudio2ts/pesaudio2ts 30 | /tools/pesclock/pesclock 31 | /tools/pesdata2ts/pesdata2ts 32 | /tools/pesinfo/pesinfo 33 | /tools/pesvideo2ts/pesvideo2ts 34 | /tools/sec2ts/sec2ts 35 | /tools/totsectionrestamp/totsectionrestamp 36 | /tools/ts2pes/ts2pes 37 | /tools/tscbrmuxer/tscbrmuxer 38 | /tools/tsccc/tsccc 39 | /tools/tsdoubleoutput/tsdoubleoutput 40 | /tools/tsfilter/tsfilter 41 | /tools/tsfixcc/tsfixcc 42 | /tools/tsinputswitch/tsinputswitch 43 | /tools/tsloop/tsloop 44 | /tools/tsmodder/tsmodder 45 | /tools/tsnullfiller/tsnullfiller 46 | /tools/tsnullshaper/tsnullshaper 47 | /tools/tsoutputswitch/tsoutputswitch 48 | /tools/tspcrmeasure/tspcrmeasure 49 | /tools/tspcrstamp/tspcrstamp 50 | /tools/tspidmapper/tspidmapper 51 | /tools/tsstamp/tsstamp 52 | /tools/tstcpreceive/tstcpreceive 53 | /tools/tstcpsend/tstcpsend 54 | /tools/tstdt/tstdt 55 | /tools/tstimedwrite/tstimedwrite 56 | /tools/tstimeout/tstimeout 57 | /tools/tsudpreceive/tsudpreceive 58 | /tools/tsudpsend/tsudpsend 59 | /tools/tsvbr2cbr/tsvbr2cbr 60 | /tools/txt2pes/txt2pes 61 | /tools/vbv/vbv 62 | /tools/zpipe/zpipe 63 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | OpenCaster 2 | 3 | Lorenzo Pallara l.pallara@avalpa.com 4 | ============================= 5 | 6 | How to compile and install: 7 | The procedure is tested on a Debian Linux 4.0 and 5.0 i386 on a 32bit architecture, that's our envirorment, 64bit is on test. 8 | Packages usually required but not installed on the Stable are: 9 | binutils, gcc, gcc-4.3, libc6-dev, libgomp1, linux-libc-dev, make, python-dev, python2.5-dev and zlib1g-dev, there are mostly development libraries needed to compile OpenCaster. 10 | The build has been tested also on Ubuntu 8.10 Linux x86 32bit architecture and has been report to build correctly. 11 | N.B. Python version should be 2.4 or 2.5 12 | To build the package you need to type "make" into OpenCaster directory. 13 | To install the tools in the system you need to type "make install" with root privileges. 14 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = libs tools 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | OpenCaster 2 | 3 | Contact: 4 | Lorenzo Pallara (l.pallara@avalpa.com) 5 | 6 | Introduction: 7 | This package is a collection of softwares to generate, process, play out, multiplex and broadcast MPEG2 transport stream format in a Linux system. 8 | 9 | Manual and tutorials: 10 | A .pdf manual is available in manual directory, the tutorials of the manual are in tutorials directory. 11 | 12 | Integration: 13 | OpenCaster has been successfully integrated with a long list of dvb products, among them there are products by Cisco/Scientific Atlanta, Ericsson/Tandberg, Eurotek, Harmonic/Scopus, MainConcept, Mitan, Screen Service, ... 14 | 15 | GUI: 16 | APE, Avalpa Playlist Editor will allow a graphical control of a simple audio/video/interactive playout system based on OpenCaster, keep tuned on www.avalpa.com 17 | 18 | Test: 19 | OpenCaster has been tested with Rohde & Schwarz DVM100L and Dektec StreamXpert 20 | 21 | Features: 22 | - output to DVB-S, DVB-T and DVB-C with pci hardware boards 23 | - output on multicast addresses for TS over IP/UDP (aka IPTV) 24 | - output to DVB-ASI with pci/usb hardware boards 25 | - output on file as store Transport Strem file 26 | - PSI generation (PAT, PMT, NIT, SDT, TDT, AIT, TOT, ...) 27 | - EPG/EIT generation 28 | - Object and data carousel generation and receivement (MHP, MHEG5, DVB-SSU, ...) 29 | - third party software AC-3, MPEG2 audio and MPEG2 video encoder support (ffmpeg among them) 30 | - MPEG2 hardware encoder support 31 | - IP encapsulation (MPE) 32 | - CBR transport stream muxing 33 | - PCR restamping 34 | - Null packet replacement 35 | - PID filtering 36 | - PID remappaing 37 | - Null packet insertion 38 | - Video buffer verifier 39 | - PCR timing verifier 40 | - PES headers analyzer 41 | - MPEG2 video and MPEG2/AC-3 audio ES header analyzer 42 | - fatcaps DVB-H support 43 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([OpenCaster],[2.2]) 2 | AM_INIT_AUTOMAKE([foreign]) 3 | AM_MAINTAINER_MODE 4 | AC_PROG_CC 5 | AC_PROG_LIBTOOL 6 | 7 | AC_MSG_CHECKING([what compiler flags are required for large file access]) 8 | LFS_DEFS=`getconf LFS_CFLAGS 2>/dev/null` 9 | if test x"$LFS_DEFS" = x"" ; then 10 | AC_MSG_RESULT([none]) 11 | else 12 | DEFS="$DEFS $LFS_DEFS" 13 | AC_MSG_RESULT([$LFS_DEFS]) 14 | fi 15 | 16 | AC_CHECK_PROGS([PYTHON24],[python-2.4 python2.4 python]) 17 | 18 | oldlibs="$LIBS" 19 | 20 | AC_CHECK_LIB([z],[gzopen],[ZLIB_LIBS="-lz"]) 21 | AC_SUBST([ZLIB_LIBS]) 22 | LIBS="$oldlibs" 23 | 24 | AC_CHECK_LIB([pcap],[pcap_read],[PCAP_LIBS="-lpcap"]) 25 | AC_SUBST([PCAP_LIBS]) 26 | LIBS="$oldlibs" 27 | 28 | AC_CHECK_LIB([socket],[getaddrinfo],[SOCKET_LIBS="$SOCKET_LIBS -lsocket"]) 29 | AC_CHECK_LIB([nsl],[gethostbyname],[SOCKET_LIBS="$SOCKET_LIBS -lnsl"]) 30 | AC_CHECK_LIB([resolv],[hstrerror],[SOCKET_LIBS="$SOCKET_LIBS -lresolv"]) 31 | AC_SUBST([SOCKET_LIBS]) 32 | LIBS="$oldlibs" 33 | 34 | AC_CHECK_HEADERS([inttypes.h stdint.h netinet/ether.h sys/ethernet.h]) 35 | 36 | AC_MSG_CHECKING([whether to build mpe2sec]) 37 | build_mpe2sec=no 38 | case "$host_os" in 39 | linux-gnu) 40 | build_mpe2sec=yes 41 | ;; 42 | esac 43 | AC_MSG_RESULT([$build_mpe2sec]) 44 | 45 | AM_CONDITIONAL([BUILD_MPE2SEC],[test x"$build_mpe2sec" = x"yes"]) 46 | 47 | AC_CHECK_MEMBER([struct ip_mreqn.imr_multiaddr],[AC_DEFINE([HAVE_IP_MREQN],[1],[define if struct ip_mreqn is present])],,[ 48 | #include 49 | #include 50 | ]) 51 | 52 | AC_CHECK_MEMBER([struct ip_mreq.imr_multiaddr],[AC_DEFINE([HAVE_IP_MREQ],[1],[define if struct ip_mreq is present])],,[ 53 | #include 54 | #include 55 | ]) 56 | 57 | AC_CONFIG_FILES([ 58 | Makefile 59 | libs/Makefile 60 | libs/dvbobjects/Makefile 61 | libs/sectioncrc/Makefile 62 | tools/Makefile 63 | tools/dsmcc-receive/Makefile 64 | tools/esaudio2pes/Makefile 65 | tools/esaudioinfo/Makefile 66 | tools/esvideo2pes/Makefile 67 | tools/esvideoinfo/Makefile 68 | tools/i13942ts/Makefile 69 | tools/mpe2sec/Makefile 70 | tools/oc2sec/Makefile 71 | tools/oddparity/Makefile 72 | tools/pes2es/Makefile 73 | tools/pes2txt/Makefile 74 | tools/pesaudio2ts/Makefile 75 | tools/pesclock/Makefile 76 | tools/pesdata2ts/Makefile 77 | tools/pesinfo/Makefile 78 | tools/pesvideo2ts/Makefile 79 | tools/sec2ts/Makefile 80 | tools/totsectionrestamp/Makefile 81 | tools/ts2pes/Makefile 82 | tools/ts2sec/Makefile 83 | tools/tscbrmuxer/Makefile 84 | tools/tsccc/Makefile 85 | tools/tsdoubleoutput/Makefile 86 | tools/tsfilter/Makefile 87 | tools/tsfixcc/Makefile 88 | tools/tsinputswitch/Makefile 89 | tools/tsloop/Makefile 90 | tools/tsmodder/Makefile 91 | tools/tsnullfiller/Makefile 92 | tools/tsnullshaper/Makefile 93 | tools/tsoutputswitch/Makefile 94 | tools/tspcrmeasure/Makefile 95 | tools/tspcrstamp/Makefile 96 | tools/tspidmapper/Makefile 97 | tools/tsstamp/Makefile 98 | tools/tstcpreceive/Makefile 99 | tools/tstcpsend/Makefile 100 | tools/tstdt/Makefile 101 | tools/tstimedwrite/Makefile 102 | tools/tstimeout/Makefile 103 | tools/tsudpreceive/Makefile 104 | tools/tsudpsend/Makefile 105 | tools/tsvbr2cbr/Makefile 106 | tools/txt2pes/Makefile 107 | tools/vbv/Makefile 108 | tools/zpipe/Makefile 109 | ]) 110 | 111 | AC_OUTPUT 112 | -------------------------------------------------------------------------------- /extras/javasrc/externalexample/ExternalExample.java: -------------------------------------------------------------------------------- 1 | import tv.cineca.apps.yambo.ExternalClass; 2 | import tv.cineca.apps.yambo.CGIURL; 3 | 4 | public class ExternalExample implements tv.cineca.apps.yambo.ExternalClass { 5 | 6 | /* This class has to stay at the carousel root, some mhp stacks have problems to load if from others points */ 7 | 8 | public String getXML(CGIURL url) { 9 | 10 | int i = 0; 11 | int j = 0; 12 | 13 | String value = url.getValue("number1"); 14 | if (value != null) { 15 | i = Integer.parseInt(value); 16 | } 17 | value = url.getValue("number2"); 18 | if (value != null) { 19 | j = Integer.parseInt(value); 20 | } 21 | 22 | int k = i + j; 23 | 24 | return "\n\n\n100\n100\n25\nWhite\nThis is a .class output example, result number is: " + k + "\n\n\n\n"; 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /extras/javasrc/parser/DocumentHandler.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.parser; 2 | 3 | import java.io.Writer; 4 | 5 | import tv.cineca.parser.sax.AttributeList; 6 | import tv.cineca.parser.sax.SAXException; 7 | 8 | 9 | public interface DocumentHandler extends tv.cineca.parser.sax.DocumentHandler { 10 | Writer startDocument(final Writer writer) throws SAXException; 11 | Writer startElement(final String name, final AttributeList attributes, final Writer writer) 12 | throws SAXException; 13 | } 14 | -------------------------------------------------------------------------------- /extras/javasrc/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.parser; 2 | public interface Parser extends tv.cineca.parser.sax.Parser { 3 | void setDocumentHandler(DocumentHandler handler); 4 | } -------------------------------------------------------------------------------- /extras/javasrc/parser/sax/DTDHandler.java: -------------------------------------------------------------------------------- 1 | // SAX DTD handler. 2 | // No warranty; no copyright -- use this as you will. 3 | // $Id: DTDHandler.java,v 1.5 1998/05/12 01:43:24 david Exp $ 4 | 5 | package tv.cineca.parser.sax; 6 | 7 | /** 8 | * Receive notification of basic DTD-related events. 9 | * 10 | *

If a SAX application needs information about notations and 11 | * unparsed entities, then the application implements this 12 | * interface and registers an instance with the SAX parser using 13 | * the parser's setDTDHandler method. The parser uses the 14 | * instance to report notation and unparsed entity declarations to 15 | * the application.

16 | * 17 | *

The SAX parser may report these events in any order, regardless 18 | * of the order in which the notations and unparsed entities were 19 | * declared; however, all DTD events must be reported after the 20 | * document handler's startDocument event, and before the first 21 | * startElement event.

22 | * 23 | *

It is up to the application to store the information for 24 | * future use (perhaps in a hash table or object tree). 25 | * If the application encounters attributes of type "NOTATION", 26 | * "ENTITY", or "ENTITIES", it can use the information that it 27 | * obtained through this interface to find the entity and/or 28 | * notation corresponding with the attribute value.

29 | * 30 | *

The HandlerBase class provides a default implementation 31 | * of this interface, which simply ignores the events.

32 | * 33 | * @author David Megginson (ak117@freenet.carleton.ca) 34 | * @version 1.0 35 | * @see org.xml.sax.Parser#setDTDHandler 36 | * @see org.xml.sax.HandlerBase 37 | */ 38 | public interface DTDHandler { 39 | 40 | 41 | /** 42 | * Receive notification of a notation declaration event. 43 | * 44 | *

It is up to the application to record the notation for later 45 | * reference, if necessary.

46 | * 47 | *

If a system identifier is present, and it is a URL, the SAX 48 | * parser must resolve it fully before passing it to the 49 | * application.

50 | * 51 | * @param name The notation name. 52 | * @param publicId The notation's public identifier, or null if 53 | * none was given. 54 | * @param systemId The notation's system identifier, or null if 55 | * none was given. 56 | * @exception org.xml.sax.SAXException Any SAX exception, possibly 57 | * wrapping another exception. 58 | * @see #unparsedEntityDecl 59 | * @see org.xml.sax.AttributeList 60 | */ 61 | public abstract void notationDecl (String name, 62 | String publicId, 63 | String systemId) 64 | throws SAXException; 65 | 66 | 67 | /** 68 | * Receive notification of an unparsed entity declaration event. 69 | * 70 | *

Note that the notation name corresponds to a notation 71 | * reported by the notationDecl() event. It is up to the 72 | * application to record the entity for later reference, if 73 | * necessary.

74 | * 75 | *

If the system identifier is a URL, the parser must resolve it 76 | * fully before passing it to the application.

77 | * 78 | * @exception org.xml.sax.SAXException Any SAX exception, possibly 79 | * wrapping another exception. 80 | * @param name The unparsed entity's name. 81 | * @param publicId The entity's public identifier, or null if none 82 | * was given. 83 | * @param systemId The entity's system identifier (it must always 84 | * have one). 85 | * @param notation name The name of the associated notation. 86 | * @see #notationDecl 87 | * @see org.xml.sax.AttributeList 88 | */ 89 | public abstract void unparsedEntityDecl (String name, 90 | String publicId, 91 | String systemId, 92 | String notationName) 93 | throws SAXException; 94 | 95 | } 96 | -------------------------------------------------------------------------------- /extras/javasrc/parser/sax/Locator.java: -------------------------------------------------------------------------------- 1 | // SAX locator interface for document events. 2 | // No warranty; no copyright -- use this as you will. 3 | // $Id: Locator.java,v 0.5 1998/05/12 01:45:55 david Exp $ 4 | 5 | package tv.cineca.parser.sax; 6 | 7 | 8 | /** 9 | * Interface for associating a SAX event with a document location. 10 | * 11 | *

If a SAX parser provides location information to the SAX 12 | * application, it does so by implementing this interface and then 13 | * passing an instance to the application using the document 14 | * handler's setDocumentLocator method. The application can use the 15 | * object to obtain the location of any other document handler event 16 | * in the XML source document.

17 | * 18 | *

Note that the results returned by the object will be valid only 19 | * during the scope of each document handler method: the application 20 | * will receive unpredictable results if it attempts to use the 21 | * locator at any other time.

22 | * 23 | *

SAX parsers are not required to supply a locator, but they are 24 | * very strong encouraged to do so. If the parser supplies a 25 | * locator, it must do so before reporting any other document events. 26 | * If no locator has been set by the time the application receives 27 | * the startDocument event, the application should assume that a 28 | * locator is not available.

29 | * 30 | * @author David Megginson (ak117@freenet.carleton.ca) 31 | * @version 1.0 32 | * @see org.xml.sax.DocumentHandler#setDocumentLocator 33 | */ 34 | public interface Locator { 35 | 36 | 37 | /** 38 | * Return the public identifier for the current document event. 39 | *

This will be the public identifier 40 | * @return A string containing the public identifier, or 41 | * null if none is available. 42 | * @see #getSystemId 43 | */ 44 | public abstract String getPublicId (); 45 | 46 | 47 | /** 48 | * Return the system identifier for the current document event. 49 | * 50 | *

If the system identifier is a URL, the parser must resolve it 51 | * fully before passing it to the application.

52 | * 53 | * @return A string containing the system identifier, or null 54 | * if none is available. 55 | * @see #getPublicId 56 | */ 57 | public abstract String getSystemId (); 58 | 59 | 60 | /** 61 | * Return the line number where the current document event ends. 62 | * Note that this is the line position of the first character 63 | * after the text associated with the document event. 64 | * @return The line number, or -1 if none is available. 65 | * @see #getColumnNumber 66 | */ 67 | public abstract int getLineNumber (); 68 | 69 | 70 | /** 71 | * Return the column number where the current document event ends. 72 | * Note that this is the column number of the first 73 | * character after the text associated with the document 74 | * event. The first column in a line is position 1. 75 | * @return The column number, or -1 if none is available. 76 | * @see #getLineNumber 77 | */ 78 | public abstract int getColumnNumber (); 79 | 80 | } 81 | -------------------------------------------------------------------------------- /extras/javasrc/parser/sax/SAXException.java: -------------------------------------------------------------------------------- 1 | // SAX exception class. 2 | // No warranty; no copyright -- use this as you will. 3 | // $Id: SAXException.java,v 1.6 1998/05/01 21:00:01 david Exp $ 4 | 5 | package tv.cineca.parser.sax; 6 | 7 | /** 8 | * Encapsulate a general SAX error or warning. 9 | * 10 | *

This class can contain basic error or warning information from 11 | * either the XML parser or the application: a parser writer or 12 | * application writer can subclass it to provide additional 13 | * functionality. SAX handlers may throw this exception or 14 | * any exception subclassed from it.

15 | * 16 | *

If the application needs to pass through other types of 17 | * exceptions, it must wrap those exceptions in a SAXException 18 | * or an exception derived from a SAXException.

19 | * 20 | *

If the parser or application needs to include information about a 21 | * specific location in an XML document, it should use the 22 | * SAXParseException subclass.

23 | * 24 | * @author David Megginson (ak117@freenet.carleton.ca) 25 | * @version 1.0 26 | * @see org.xml.sax.SAXParseException 27 | */ 28 | public class SAXException extends Exception { 29 | 30 | 31 | /** 32 | * Create a new SAXException. 33 | * 34 | * @param message The error or warning message. 35 | * @see org.xml.sax.Parser#setLocale 36 | */ 37 | public SAXException (String message) { 38 | super(); 39 | this.message = message; 40 | this.exception = null; 41 | } 42 | 43 | 44 | /** 45 | * Create a new SAXException wrapping an existing exception. 46 | * 47 | *

The existing exception will be embedded in the new 48 | * one, and its message will become the default message for 49 | * the SAXException.

50 | * 51 | * @param e The exception to be wrapped in a SAXException. 52 | */ 53 | public SAXException (Exception e) 54 | { 55 | super(); 56 | this.message = null; 57 | this.exception = e; 58 | } 59 | 60 | 61 | /** 62 | * Create a new SAXException from an existing exception. 63 | * 64 | *

The existing exception will be embedded in the new 65 | * one, but the new exception will have its own message.

66 | * 67 | * @param message The detail message. 68 | * @param e The exception to be wrapped in a SAXException. 69 | * @see org.xml.sax.Parser#setLocale 70 | */ 71 | public SAXException (String message, Exception e) 72 | { 73 | super(); 74 | this.message = message; 75 | this.exception = e; 76 | } 77 | 78 | 79 | /** 80 | * Return a detail message for this exception. 81 | * 82 | *

If there is a embedded exception, and if the SAXException 83 | * has no detail message of its own, this method will return 84 | * the detail message from the embedded exception.

85 | * 86 | * @return The error or warning message. 87 | * @see org.xml.sax.Parser#setLocale 88 | */ 89 | public String getMessage () 90 | { 91 | if (message == null && exception != null) { 92 | return exception.getMessage(); 93 | } else { 94 | return this.message; 95 | } 96 | } 97 | 98 | 99 | /** 100 | * Return the embedded exception, if any. 101 | * 102 | * @return The embedded exception, or null if there is none. 103 | */ 104 | public Exception getException () 105 | { 106 | return exception; 107 | } 108 | 109 | 110 | /** 111 | * Convert this exception to a string. 112 | * 113 | * @return A string version of this exception. 114 | */ 115 | public String toString () 116 | { 117 | return getMessage(); 118 | } 119 | 120 | 121 | 122 | ////////////////////////////////////////////////////////////////////// 123 | // Internal state. 124 | ////////////////////////////////////////////////////////////////////// 125 | 126 | private String message; 127 | private Exception exception; 128 | 129 | } 130 | -------------------------------------------------------------------------------- /extras/javasrc/testste/Testste.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.awt.*; 3 | import java.util.*; 4 | import javax.tv.xlet.*; 5 | import javax.tv.graphics.*; 6 | import org.dvb.dsmcc.*; 7 | 8 | 9 | public class Testste extends Component implements Xlet, StreamEventListener { 10 | 11 | private static XletContext context = null; 12 | private static Container rootContainer = null; 13 | private static String toDraw = "waiting..."; 14 | private static DSMCCStreamEvent stream_event_object = null; 15 | 16 | public void initXlet(XletContext xletContext) throws XletStateChangeException { 17 | 18 | context = xletContext; 19 | 20 | try { 21 | rootContainer = TVContainer.getRootContainer(xletContext); 22 | rootContainer.setLayout(new GridLayout(0,1)); 23 | rootContainer.setSize(new Dimension(720, 576)); 24 | rootContainer.setVisible(true); 25 | } 26 | catch (Exception e) { 27 | e.printStackTrace(); 28 | } 29 | 30 | 31 | } 32 | 33 | public void startXlet() throws XletStateChangeException { 34 | 35 | rootContainer.add(this); 36 | setVisible(true); 37 | rootContainer.validate(); 38 | 39 | toDraw = "start xlet"; 40 | repaint(); 41 | 42 | 43 | try { 44 | 45 | /* stream_event_object = new DSMCCStreamEvent("test.event"); */ 46 | DSMCCObject file_object = new DSMCCObject("test.event"); 47 | file_object.synchronousLoad(); 48 | stream_event_object = new DSMCCStreamEvent(file_object); 49 | String[] event_list = stream_event_object.getEventList(); 50 | int i = 0; 51 | for (i = 0; i < event_list.length; i++) { 52 | System.out.println("Testste: event " + i + " name: " + event_list[i]); 53 | } 54 | System.out.println("Testste:subscribe to event:" + event_list[0]); 55 | stream_event_object.subscribe(event_list[0], this); 56 | 57 | 58 | Thread.sleep(60000); 59 | 60 | 61 | } 62 | catch (Exception e) { 63 | toDraw = "got an exception:\n" + e.toString() + "\n"; 64 | repaint(); 65 | try { Thread.sleep(60000); } catch (Exception ex) {} 66 | } 67 | 68 | 69 | 70 | } 71 | 72 | public void receiveStreamEvent(StreamEvent event) { 73 | toDraw = "EventId: " + event.getEventId() + "\nEventName: " + event.getEventName() + "\nEventNPT: " + event.getEventNPT() + "\nEventData: "; 74 | byte[] data = event.getEventData(); 75 | int i = 0; 76 | for (i = 0; i < data.length; i++) { 77 | toDraw = toDraw + data[i]; 78 | } 79 | repaint(); 80 | } 81 | 82 | 83 | 84 | public void paint(Graphics g) { 85 | 86 | FontMetrics fontMetrics = g.getFontMetrics(); 87 | g.setColor(SystemColor.red); 88 | StringTokenizer st = new StringTokenizer(toDraw, "\n"); 89 | int j = 1; 90 | while (st.hasMoreTokens()) { 91 | g.drawString(st.nextToken(), 100, 100 + j * (fontMetrics.getAscent() + 3)); 92 | j++; 93 | } 94 | 95 | } 96 | 97 | public void pauseXlet() { 98 | 99 | } 100 | 101 | public void destroyXlet(boolean flag) throws XletStateChangeException { 102 | 103 | rootContainer.setVisible(false); 104 | rootContainer.removeAll(); 105 | rootContainer = null; 106 | context.notifyDestroyed(); 107 | } 108 | 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/CGIURL.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.io.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | 7 | public class CGIURL 8 | { 9 | public static int exit_protocol = 0; 10 | public static int file_protocol = 1; 11 | public static int dvb_protocol = 2; 12 | public static int http_protocol = 3; 13 | public static int class_protocol = 4; 14 | 15 | public static String exit_str = "exit://"; 16 | 17 | public int carousel_id = -1; 18 | public boolean exit = false; 19 | public String server_name = null; 20 | public String valued_path = null; 21 | public String unvalued_path = null; 22 | public String StringForm = null; 23 | public int protocol = -1; 24 | 25 | private Vector names = null; 26 | private Vector values = null; 27 | 28 | public CGIURL(String URL) { 29 | 30 | String parsed; 31 | String variable_name; 32 | String variable_value; 33 | 34 | /* Parse URL */ 35 | carousel_id = -1; 36 | server_name = null; 37 | exit = false; 38 | StringForm = URL; 39 | if (URL.startsWith("dvb://")) { 40 | parsed = URL.substring(6); 41 | carousel_id = Integer.parseInt(parsed.substring(0, parsed.indexOf('/'))); 42 | protocol = dvb_protocol; 43 | } else if (URL.startsWith("http://")) { 44 | parsed = URL.substring(7); 45 | server_name = parsed.substring(0, parsed.indexOf('/')); 46 | protocol = http_protocol; 47 | } else if (URL.startsWith("file://")) { 48 | parsed = URL.substring(7); 49 | protocol = file_protocol; 50 | } else if (URL.startsWith("class://")) { 51 | parsed = URL.substring(8); 52 | server_name = parsed.substring(0, parsed.indexOf('/')); 53 | protocol = class_protocol; 54 | } else { 55 | exit = true; 56 | valued_path = new String(exit_str); 57 | unvalued_path = new String(exit_str); 58 | StringForm = new String(exit_str); 59 | return; 60 | } 61 | 62 | /* Parse CGI like paramenters if any */ 63 | names = new Vector(); 64 | values = new Vector(); 65 | parsed = parsed.substring(parsed.indexOf('/') + 1); 66 | valued_path = parsed; 67 | unvalued_path = parsed; 68 | if (parsed.indexOf('?') != -1) { 69 | unvalued_path = unvalued_path.substring(0, unvalued_path.indexOf('?') + 1); 70 | parsed = parsed.substring(parsed.indexOf('?') + 1); 71 | while (parsed.length() > 1) { 72 | variable_name = parsed.substring(0, parsed.indexOf('=')); 73 | names.addElement(variable_name); 74 | unvalued_path = unvalued_path + variable_name + "="; 75 | parsed = parsed.substring(parsed.indexOf('=') + 1); 76 | if (parsed.indexOf('&') != -1) { 77 | variable_value = parsed.substring(0, parsed.indexOf('&')); 78 | values.addElement(variable_value); 79 | unvalued_path = unvalued_path + "&"; 80 | parsed = parsed.substring(parsed.indexOf('&') + 1); 81 | } else { 82 | variable_value = parsed.substring(0, parsed.length()); 83 | values.addElement(variable_value); 84 | return; 85 | } 86 | } 87 | } 88 | 89 | } 90 | 91 | /* Substitue "variable_name=&" with "variable_name=variable_value&" or "variable_name=" with "variable_name=variable_value" if "=" is the last char */ 92 | public String Evaluate(String parameters_to_evaluate) { 93 | 94 | int index; 95 | String name; 96 | String before; 97 | String after; 98 | 99 | for (int i = 0; i < names.size(); i++) { 100 | name = (String) names.elementAt(i); 101 | index = parameters_to_evaluate.indexOf(name + "="); 102 | if ((index + name.length() + 1 == parameters_to_evaluate.length()) || ((index > -1) && (parameters_to_evaluate.charAt(index + name.length() + 1) == '&'))) { 103 | before = parameters_to_evaluate.substring(0, index + name.length()); 104 | after = parameters_to_evaluate.substring(index + name.length() + 1, parameters_to_evaluate.length()); 105 | parameters_to_evaluate = before + "=" + values.elementAt(i) + after; 106 | } 107 | } 108 | 109 | return parameters_to_evaluate; 110 | } 111 | 112 | public String getValue(String param) { 113 | 114 | for (int i = 0; i < names.size(); i++) { 115 | String name = (String) names.elementAt(i); 116 | if (name.equals(param)) { 117 | return (String) values.elementAt(i); 118 | } 119 | } 120 | 121 | return null; 122 | 123 | } 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/CarouselManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.xlet.*; 4 | import java.io.*; 5 | import java.lang.*; 6 | import javax.tv.xlet.*; 7 | import java.util.*; 8 | 9 | /* It usefull to get files from a carousel different from where the java class are */ 10 | public class CarouselManager 11 | { 12 | private static Hashtable Carousels = null; 13 | private static org.davic.net.dvb.DvbLocator locator = null; 14 | 15 | public static void configure(org.davic.net.dvb.DvbLocator _locator) { 16 | 17 | locator = _locator; 18 | Carousels = new Hashtable(); 19 | 20 | } 21 | 22 | public static org.dvb.dsmcc.ServiceDomain getCarousel(int carousel_id) { 23 | 24 | Object value = null; 25 | org.dvb.dsmcc.ServiceDomain carousel = null; 26 | 27 | value = Carousels.get((Object)Integer.toString(carousel_id)); 28 | if (value != null) { 29 | 30 | return ((org.dvb.dsmcc.ServiceDomain)value); 31 | 32 | } else { 33 | 34 | carousel = new org.dvb.dsmcc.ServiceDomain(); 35 | try { 36 | carousel.attach((org.davic.net.Locator)locator, carousel_id); 37 | } 38 | catch (Exception e) { 39 | e.printStackTrace(); 40 | return null; 41 | } 42 | Carousels.put((Object)Integer.toString(carousel_id), (Object)carousel); 43 | return carousel; 44 | 45 | } 46 | } 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/ColorKeyManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.awt.*; 4 | import java.util.Vector; 5 | 6 | public class ColorKeyManager { 7 | 8 | public static String RedURL = null; 9 | public static int RedPage = 0; 10 | public static String GreenURL = null; 11 | public static int GreenPage = 0; 12 | public static String BlueURL = null; 13 | public static int BluePage = 0; 14 | public static String YellowURL = null; 15 | public static int YellowPage = 0; 16 | 17 | public static void configure(Vector Items) { 18 | 19 | RedURL = null; 20 | RedPage = 0; 21 | GreenURL = null; 22 | GreenPage = 0; 23 | BlueURL = null; 24 | BluePage = 0; 25 | YellowURL = null; 26 | YellowPage = 0; 27 | 28 | /* Get URLS from color keys */ 29 | for(int i = 0; i < Items.size(); i++) { 30 | 31 | NamedItem item = (NamedItem) Items.elementAt(i); 32 | if (item.Name.equals("RedKeyItem") && RedURL == null) { 33 | RedURL = item.URL; 34 | RedPage = Integer.parseInt(item.URLPage); 35 | } else if (item.Name.equals("GreenKeyItem") && GreenURL == null) { 36 | GreenURL = item.URL; 37 | GreenPage = Integer.parseInt(item.URLPage); 38 | } else if (item.Name.equals("BlueKeyItem") && BlueURL == null) { 39 | BlueURL = item.URL; 40 | BluePage = Integer.parseInt(item.URLPage); 41 | } else if (item.Name.equals("YellowKeyItem") && YellowURL == null) { 42 | YellowURL = item.URL; 43 | YellowPage = Integer.parseInt(item.URLPage); 44 | } 45 | 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/EventManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.io.*; 4 | import java.awt.*; 5 | import java.util.*; 6 | import javax.tv.xlet.*; 7 | import javax.tv.graphics.*; 8 | import org.dvb.dsmcc.*; 9 | import javax.tv.service.selection.*; 10 | import javax.media.Player; 11 | import javax.tv.media.AWTVideoSizeControl; 12 | import javax.tv.media.AWTVideoSize; 13 | import java.awt.Rectangle; 14 | import java.awt.Dimension; 15 | import javax.tv.locator.*; 16 | import javax.tv.xlet.XletContext; 17 | import java.util.*; 18 | 19 | /* wait for stream event messages, if received change page to the event data */ 20 | class EventManager { 21 | 22 | private static Wizard wizard = null; 23 | 24 | public static void configure(Vector Items, Wizard _wizard) { 25 | 26 | wizard = _wizard; 27 | 28 | for(int i = 0; i < Items.size(); i++) { 29 | NamedItem item = (NamedItem) Items.elementAt(i); 30 | if (item.Name.equals("EventItem")) { 31 | try { 32 | CGIURL CGI_URL = new CGIURL(item.URL); 33 | if (CGI_URL.carousel_id > -1) { 34 | org.dvb.dsmcc.DSMCCStreamEvent stream_event_object = new org.dvb.dsmcc.DSMCCStreamEvent((CarouselManager.getCarousel(CGI_URL.carousel_id)).getMountPoint() + "/" + CGI_URL.valued_path); 35 | String[] event_list = stream_event_object.getEventList(); 36 | for (int j = 0; j < event_list.length; j++) { 37 | System.out.println("EventManager:event " + j + " name: " + event_list[j]); 38 | System.out.println("EventManager:subscribe to event:" + event_list[j]); 39 | stream_event_object.subscribe(event_list[j], wizard); 40 | } 41 | } 42 | } 43 | catch(Exception e) { 44 | System.out.println("EventManager exception: " + e); 45 | } 46 | } 47 | } 48 | 49 | } 50 | 51 | 52 | public static void receiveEvent(org.dvb.dsmcc.StreamEvent event) { 53 | 54 | String event_print = "EventId: " + event.getEventId() + "\nEventName: " + event.getEventName() + "\nEventNPT: " + event.getEventNPT() + "\nEventData: "; 55 | /* 56 | byte[] data = event.getEventData(); 57 | String URL = ""; 58 | for (int i = 0; i < data.length; i++) { 59 | URL += data[i]; 60 | } 61 | */ 62 | String URL = new String(event.getEventData()); 63 | System.out.println(event_print + URL); 64 | wizard.ChangePage(URL, 1); 65 | 66 | } 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/ExternalClass.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | /* Stubb class for business logic */ 4 | public interface ExternalClass { 5 | 6 | public String getXML(CGIURL url); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/IFrameManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.service.selection.*; 4 | import javax.media.Player; 5 | import javax.tv.media.AWTVideoSizeControl; 6 | import javax.tv.media.AWTVideoSize; 7 | import java.awt.Rectangle; 8 | import java.awt.Dimension; 9 | import javax.tv.locator.*; 10 | import javax.tv.xlet.XletContext; 11 | import java.util.*; 12 | import org.havi.ui.*; 13 | 14 | /* Change the background */ 15 | class IFrameManager { 16 | 17 | private static RCResourceClient resourceClient = new RCResourceClient(); 18 | 19 | public static void configure(Vector Items) { 20 | 21 | HStillImageBackgroundConfiguration backImageConfiguration = null; 22 | 23 | for(int i = 0; i < Items.size(); i++) { 24 | NamedItem item = (NamedItem) Items.elementAt(i); 25 | if (item.Name.equals("BackgroundItem")) { 26 | System.out.println("IFrameManager: got item " + item.URL); 27 | HScreen screen = HScreen.getDefaultHScreen(); 28 | HBackgroundDevice backDevice = screen.getDefaultHBackgroundDevice(); 29 | HBackgroundConfigTemplate backConfigurationTemplate = new HBackgroundConfigTemplate(); 30 | backConfigurationTemplate.setPreference(HBackgroundConfigTemplate.FLICKER_FILTERING, HBackgroundConfigTemplate.PREFERRED); 31 | HBackgroundConfiguration backConfiguration = backDevice.getBestConfiguration(backConfigurationTemplate); 32 | if (backDevice.reserveDevice(resourceClient)) { 33 | try { 34 | backDevice.setBackgroundConfiguration(backConfiguration); 35 | if(backConfiguration instanceof HStillImageBackgroundConfiguration) { 36 | backImageConfiguration = (HStillImageBackgroundConfiguration) backConfiguration; 37 | } else { 38 | System.out.println("IFrameManager: no background device available"); 39 | backDevice.releaseDevice(); 40 | } 41 | } 42 | catch (Exception e) { 43 | System.out.println("IFrameManager: no background device available"); 44 | backDevice.releaseDevice(); 45 | } 46 | } 47 | 48 | try { 49 | CGIURL CGI_URL = new CGIURL(item.URL); 50 | if (CGI_URL.carousel_id > -1) { 51 | HBackgroundImage backImage = new HBackgroundImage((CarouselManager.getCarousel(CGI_URL.carousel_id)).getMountPoint() + "/" + CGI_URL.valued_path); 52 | backImageConfiguration.displayImage(backImage); 53 | } 54 | } 55 | catch (Exception e) { 56 | System.out.println("IFrameManager: background: " + e); 57 | } 58 | 59 | } 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/InputManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.xlet.*; 4 | import java.util.*; 5 | import java.awt.Color; 6 | import java.awt.*; 7 | import java.awt.event.*; 8 | 9 | class InputManager { 10 | 11 | public static int textX = -1; 12 | public static int textY = -1; 13 | public static int padX = -1; 14 | public static int padY = -1; 15 | public static int Width = -1; 16 | public static String URL = null; 17 | public static int Page = -1; 18 | public static boolean NumberOnly = false; 19 | public static String Variable = null; 20 | 21 | private static KeyPad keypad = null; 22 | private static TextBox textbox = null; 23 | 24 | public static void configure(Vector Items, Wizard _wizard) { 25 | 26 | URL = null; 27 | padX = -1; 28 | padY = -1; 29 | if (keypad != null) { 30 | keypad.stop = true; 31 | keypad = null; 32 | textbox = null; 33 | } 34 | for(int i = 0; i < Items.size(); i++) { 35 | NamedItem item = (NamedItem) Items.elementAt(i); 36 | if (item.Name.equals("InputItem")) { 37 | textX = Integer.parseInt(item.LocationX); 38 | textY = Integer.parseInt(item.LocationY); 39 | Width = Integer.parseInt(item.Width); 40 | NumberOnly = item.InputFlags.equals("Number"); 41 | Variable = item.InputTag; 42 | URL = item.URL; 43 | Page = Integer.parseInt(item.URLPage); 44 | } else if (item.Name.equals("PadHelpItem")) { 45 | padX = Integer.parseInt(item.LocationX); 46 | padY = Integer.parseInt(item.LocationY); 47 | } 48 | } 49 | 50 | if (URL != null) { 51 | keypad = new KeyPad(NumberOnly, padX, padY, _wizard); 52 | textbox = new TextBox(Width * 20, textX, textY); // more or less the size of each char 53 | keypad.setOutput(textbox); 54 | new Thread(keypad).start(); 55 | } 56 | 57 | } 58 | 59 | public static boolean paint(Graphics graphics) { 60 | 61 | System.out.println("InputManager.paint"); 62 | if (keypad != null && textbox != null) { 63 | keypad.paint(graphics); 64 | textbox.paint(graphics); 65 | return true; 66 | } 67 | return false; 68 | 69 | } 70 | 71 | public static String getURL() { 72 | 73 | if (URL.indexOf("?") > 0) { 74 | return (URL + "&" + Variable + "=" + textbox.getString()); 75 | } else { 76 | return (URL + "?" + Variable + "=" + textbox.getString()); 77 | } 78 | 79 | } 80 | 81 | public static void keyPressed(KeyEvent key) 82 | { 83 | System.out.println("Wizard InputManager key pressed: " + key.toString()); 84 | switch(key.getKeyCode()) 85 | { 86 | case KeyEvent.VK_LEFT: // left, 37 87 | case KeyEvent.VK_RIGHT: // right, 39 88 | case KeyEvent.VK_0: // 0, 48 89 | case KeyEvent.VK_1: // 1, 49 90 | case KeyEvent.VK_2: // 2, 50 91 | case KeyEvent.VK_3: // 3, 51 92 | case KeyEvent.VK_4: // 4, 52 93 | case KeyEvent.VK_5: // 5, 53 94 | case KeyEvent.VK_6: // 6, 54 95 | case KeyEvent.VK_7: // 7, 55 96 | case KeyEvent.VK_8: // 8, 56 97 | case KeyEvent.VK_9: // 9, 57 98 | keypad.keyPressed(key); 99 | default: 100 | break; 101 | } 102 | } 103 | 104 | } 105 | 106 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/KeyPadButton.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.awt.*; 4 | 5 | public class KeyPadButton { 6 | 7 | /* Key size */ 8 | public static int KB_WIDTH = 55; 9 | public static int KB_HEIGHT = 52; 10 | 11 | private int keyNumber = 0; 12 | private static Font keyNumberFont = null; 13 | private char[] smallChars = null; 14 | private int smallChCount = 0; 15 | private int activeSmallChar = -1; 16 | private static Font smallChFont = null; 17 | private boolean focused = false; 18 | private int offsetX = 0; 19 | private int offsetY = 0; 20 | 21 | /* Create KeypadButton */ 22 | public KeyPadButton(int keyNum, String keyChars, int _offsetX, int _offsetY) { 23 | keyNumber = keyNum; 24 | keyNumberFont = new Font("Tiresias",Font.PLAIN,25); 25 | smallChars = keyChars.toCharArray(); 26 | smallChCount = keyChars.length(); 27 | smallChFont = new Font("Tiresias", Font.PLAIN,18); 28 | offsetX = _offsetX; 29 | offsetY = _offsetY; 30 | } 31 | 32 | public void paint(Graphics graphics) { 33 | 34 | /* Draw button */ 35 | if (focused) { 36 | graphics.setColor(Color.red); 37 | } else { 38 | graphics.setColor(new Color(0x2a, 0x2a, 0x2a)); 39 | } 40 | graphics.fillRoundRect(offsetX, offsetY, KB_WIDTH, KB_HEIGHT, 10, 10); 41 | graphics.setColor(Color.black); 42 | graphics.fillRoundRect(offsetX + 2, offsetY + 2, KB_WIDTH - 4, KB_HEIGHT - 4, 10, 10); 43 | 44 | /* Draws small characters */ 45 | graphics.setFont(smallChFont); 46 | int charX = (KB_WIDTH - graphics.getFontMetrics().stringWidth(String.valueOf(smallChars))) / 2; 47 | for (int i=0; i < smallChCount; i++) { 48 | if (i == activeSmallChar && focused) { 49 | graphics.setColor(Color.white); 50 | } else { 51 | graphics.setColor(Color.green); 52 | } 53 | graphics.drawString(String.valueOf(smallChars[i]), offsetX + charX, offsetY + 46); 54 | charX += graphics.getFontMetrics().charWidth(smallChars[i]); 55 | } 56 | 57 | /* Draw key number */ 58 | graphics.setFont(keyNumberFont); 59 | graphics.setColor(Color.white); 60 | graphics.drawString(String.valueOf(keyNumber), offsetX + ((KB_WIDTH - graphics.getFontMetrics().stringWidth(String.valueOf(keyNumber))) / 2), offsetY + 26); 61 | } 62 | 63 | public void press() { 64 | focused = true; 65 | activeSmallChar = (activeSmallChar + 1) % smallChCount; 66 | } 67 | 68 | public void unfocus() { 69 | focused = false; 70 | activeSmallChar = -1; 71 | } 72 | 73 | public char getChar() { 74 | if (smallChars != null && activeSmallChar != -1) { 75 | return smallChars[activeSmallChar]; 76 | } 77 | return 0; 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/NamedItem.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.lang.*; 4 | 5 | /* An ugly class that looks like an union, efficient but */ 6 | class NamedItem { 7 | 8 | public String Name = null; 9 | public String LocationX = null; 10 | public String LocationY = null; 11 | public String Width = null; 12 | public String Height = null; 13 | public String Size = null; 14 | public String Time = null; 15 | public String Text = null; 16 | public String Visible = null; 17 | public String URL = null; 18 | public String URLPage = null; 19 | public String Color = null; 20 | public String InputFlags = null; 21 | public String InputTag = null; 22 | 23 | public NamedItem(String _name) { 24 | Name = _name; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Paint.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.awt.*; 4 | import javax.tv.xlet.*; 5 | import java.io.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import java.net.*; 9 | 10 | /* Manage images loading and status */ 11 | public class Paint implements org.dvb.net.rc.ConnectionListener 12 | { 13 | 14 | public int X = -1; 15 | public int Y = -1; 16 | public boolean Visible = false; 17 | public String URL = null; 18 | public boolean unloadable = false; 19 | public Image image = null; 20 | 21 | public Paint() { 22 | 23 | unloadable = false; 24 | image = null; 25 | 26 | } 27 | 28 | public void Load(Wizard _wizard) { 29 | 30 | CGIURL CGI_URL = new CGIURL(URL); 31 | try { 32 | if (CGI_URL.carousel_id > -1) { 33 | System.out.println("Painter loading: " + URL); 34 | image = Toolkit.getDefaultToolkit().getImage((CarouselManager.getCarousel(CGI_URL.carousel_id)).getMountPoint() + "/" + CGI_URL.valued_path ); 35 | Painter.Tracker.addImage(image, 0); 36 | } else if (CGI_URL.server_name == null) { 37 | System.out.println("Painter loading: " + URL); 38 | image = Toolkit.getDefaultToolkit().getImage( CGI_URL.valued_path ); 39 | Painter.Tracker.addImage(image, 0); 40 | } else { 41 | RCManager.Connect(this); 42 | } 43 | } 44 | catch (Exception e) { 45 | e.printStackTrace(); 46 | } 47 | 48 | } 49 | 50 | public void connectionChanged(org.dvb.net.rc.ConnectionRCEvent event) { 51 | 52 | System.out.println("Painter connection changed: " + event.toString() + " for:" + URL); 53 | if (event instanceof org.dvb.net.rc.ConnectionEstablishedEvent) { 54 | try { 55 | System.out.println("Painter loading: " + URL); 56 | image = Toolkit.getDefaultToolkit().getImage(new URL(URL)); 57 | Painter.Tracker.addImage(image, 0); 58 | Painter.Tracker.waitForAll(); 59 | } 60 | catch (Exception e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | } 65 | 66 | } 67 | 68 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Painter.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.xlet.*; 4 | import java.util.*; 5 | import java.awt.*; 6 | import java.io.*; 7 | import java.lang.*; 8 | 9 | /* Manage images as a container*/ 10 | class Painter { 11 | 12 | public static Vector Paints = null; 13 | public static MediaTracker Tracker = null; 14 | 15 | public static void configure(Vector Items, Wizard _wizard) { 16 | 17 | if (Tracker == null) { 18 | Tracker = new MediaTracker(_wizard); 19 | } 20 | 21 | Vector newPaints = new Vector(); 22 | for(int i = 0; i < Items.size(); i++) { 23 | NamedItem item = (NamedItem) Items.elementAt(i); 24 | if (item.Name.equals("GraphicItem")) { 25 | Paint paint = new Paint(); 26 | paint.X = Integer.parseInt(item.LocationX); 27 | paint.Y = Integer.parseInt(item.LocationY); 28 | paint.Visible = item.Visible.equals("Yes"); 29 | paint.URL = item.URL; 30 | /* we keep an eye for images already loaded in this page and previous */ 31 | for(int j = 0; j < newPaints.size(); j++) { 32 | Paint old_paint = (Paint) newPaints.elementAt(j); 33 | if (old_paint.URL.equals(item.URL)) { 34 | paint.image = old_paint.image; 35 | old_paint.unloadable = true; 36 | } 37 | } 38 | if (Paints != null) { 39 | for(int j = 0; j < Paints.size(); j++) { 40 | Paint old_paint = (Paint) Paints.elementAt(j); 41 | if (old_paint.URL.equals(item.URL)) { 42 | paint.image = old_paint.image; 43 | old_paint.unloadable = true; 44 | } 45 | } 46 | } 47 | if (paint.image == null) { 48 | paint.Load(_wizard); 49 | } 50 | newPaints.addElement(paint); 51 | } 52 | } 53 | if (Paints != null) { 54 | for(int i = 0; i < Paints.size(); i++) { 55 | Paint old_paint = (Paint) Paints.elementAt(i); 56 | if (!old_paint.unloadable) { 57 | System.out.println("Flush image: " + old_paint.URL); 58 | // old_paint.image.flush(); 59 | old_paint.image = null; 60 | } 61 | } 62 | } 63 | Paints = newPaints; 64 | 65 | } 66 | 67 | public static boolean ready() { 68 | 69 | if (Paints == null) { 70 | System.out.println("Painter ready there are no paints"); 71 | return true; 72 | } else if (Paints.size() == 0) { 73 | System.out.println("Painter ready there are no paints"); 74 | return true; 75 | } else { 76 | for(int i = 0; i < Paints.size(); i++) { 77 | Paint paint = (Paint) Paints.elementAt(i); 78 | if (paint.image == null) { 79 | System.out.println("Painter not ready, error: paints are not loading"); 80 | return false; 81 | } 82 | } 83 | try { 84 | Tracker.waitForAll(); 85 | System.out.println("Painter ready"); 86 | return true; 87 | } 88 | catch(Exception event) { 89 | event.printStackTrace(); 90 | return false; 91 | } 92 | } 93 | } 94 | 95 | public static boolean paint(Graphics graphics) { 96 | 97 | System.out.println("Painter.paint:"); 98 | if (Paints != null) { 99 | for(int i = 0; i < Paints.size(); i++) { 100 | Paint paint = (Paint) Paints.elementAt(i); 101 | if (paint.Visible) { 102 | try { 103 | System.out.println(paint.URL + " at: " + Integer.toString(paint.X) + "," + Integer.toString(paint.Y)); 104 | graphics.drawImage(paint.image, paint.X, paint.Y, null); 105 | } 106 | catch(Throwable event) { 107 | event.printStackTrace(); 108 | return false; 109 | } 110 | } else { 111 | System.out.println(" " + paint.URL + " at: " + Integer.toString(paint.X) + "," + Integer.toString(paint.Y) + " is invisible"); 112 | } 113 | } 114 | } 115 | 116 | return true; 117 | } 118 | 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Print.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.awt.Color; 4 | import javax.tv.xlet.*; 5 | import java.io.*; 6 | import java.lang.*; 7 | import javax.tv.xlet.*; 8 | import java.util.*; 9 | 10 | /* Manage text resource status, carousel updates and text web links */ 11 | public class Print implements org.dvb.dsmcc.AsynchronousLoadingEventListener, org.dvb.dsmcc.ObjectChangeEventListener, org.dvb.net.rc.ConnectionListener 12 | { 13 | 14 | public int X = -1; 15 | public int Y = -1; 16 | public int size = -1; 17 | public Color color = null; 18 | public String text = null; 19 | public String URL = null; 20 | public boolean drawable = false; 21 | public boolean visible = false; 22 | 23 | private org.dvb.dsmcc.DSMCCObject file = null; 24 | private Wizard wizard = null; 25 | 26 | public Print() { 27 | drawable = false; 28 | text = null; 29 | URL = null; 30 | file = null; 31 | } 32 | 33 | public void Load(Wizard _wizard) { 34 | 35 | wizard = _wizard; 36 | CGIURL CGI_URL = new CGIURL(URL); 37 | try { 38 | if (CGI_URL.carousel_id > -1) { 39 | 40 | file = new org.dvb.dsmcc.DSMCCObject ((CarouselManager.getCarousel(CGI_URL.carousel_id)).getMountPoint(), CGI_URL.valued_path); 41 | file.asynchronousLoad(this); 42 | file.addObjectChangeEventListener(this); 43 | 44 | } else if (CGI_URL.server_name == null) { 45 | 46 | file = new org.dvb.dsmcc.DSMCCObject (CGI_URL.valued_path); 47 | loadFile(); 48 | 49 | } else { 50 | 51 | RCManager.Connect(this); 52 | 53 | } 54 | 55 | } 56 | catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | 60 | } 61 | 62 | public void receiveEvent(org.dvb.dsmcc.AsynchronousLoadingEvent event) { 63 | 64 | System.out.println("Printer synched: " + URL); 65 | loadFile(); 66 | 67 | } 68 | 69 | public void loadFile() { 70 | 71 | try { 72 | LineNumberReader reader = new LineNumberReader(new InputStreamReader (new FileInputStream(file), "UTF-8")); 73 | text = ""; 74 | String new_line = reader.readLine(); 75 | while(new_line != null) { 76 | try { 77 | text = text + new_line + "\n"; 78 | new_line = reader.readLine(); 79 | } 80 | catch (Exception e) { 81 | break; 82 | } 83 | } 84 | drawable = true; 85 | System.out.println("Printer loadFile called repaint"); 86 | wizard.repaint(); 87 | } 88 | catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | 92 | } 93 | 94 | public void connectionChanged(org.dvb.net.rc.ConnectionRCEvent event) { 95 | 96 | System.out.println("connection changed: " + event.toString()); 97 | if (event instanceof org.dvb.net.rc.ConnectionEstablishedEvent) { 98 | try { 99 | text = RCManager.ReadHttp(URL); 100 | drawable = true; 101 | System.out.println("Printer connectionChanged called repaint"); 102 | wizard.repaint(); 103 | } 104 | catch (Exception e) { 105 | e.printStackTrace(); 106 | } 107 | } 108 | 109 | } 110 | 111 | public void removeObjectChangeEvent() { 112 | if (file != null) { 113 | file.removeObjectChangeEventListener(this); 114 | } 115 | } 116 | 117 | public void receiveObjectChangeEvent(org.dvb.dsmcc.ObjectChangeEvent event) { 118 | System.out.println("Printer updated:" + URL); 119 | try { 120 | file.asynchronousLoad(this); 121 | } 122 | catch (Exception e) { 123 | e.printStackTrace(); 124 | } 125 | } 126 | 127 | 128 | } 129 | 130 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Printer.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.xlet.*; 4 | import java.util.*; 5 | import java.awt.Color; 6 | import java.awt.*; 7 | 8 | /* Manage text resource that can chage dinamically */ 9 | class Printer { 10 | 11 | public static Vector Prints = null; 12 | 13 | public static void configure(Vector Items, Wizard _wizard) { 14 | 15 | if (Prints != null) { 16 | for(int i = 0; i < Prints.size(); i++) { 17 | Print print = (Print) Prints.elementAt(i); 18 | print.removeObjectChangeEvent(); 19 | } 20 | } 21 | 22 | Vector newPrints = new Vector(); 23 | for(int i = 0; i < Items.size(); i++) { 24 | NamedItem item = (NamedItem) Items.elementAt(i); 25 | if (item.Name.equals("TextItem") || item.Name.equals("StaticTextItem")) { 26 | Print print = new Print(); 27 | print.X = Integer.parseInt(item.LocationX); 28 | print.Y = Integer.parseInt(item.LocationY); 29 | print.size = Integer.parseInt(item.Size); 30 | if(item.Color.equals("White")) { 31 | print.color = Color.white; 32 | } else if (item.Color.equals("Black")) { 33 | print.color = Color.black; 34 | } else if (item.Color.equals("Red")) { 35 | print.color = Color.red; 36 | } else if (item.Color.equals("Blue")) { 37 | print.color = Color.blue; 38 | } else if (item.Color.equals("Yellow")) { 39 | print.color = Color.yellow; 40 | } else if (item.Color.equals("Green")) { 41 | print.color = Color.green; 42 | } 43 | print.visible = item.Visible.equals("Yes"); 44 | print.URL = item.URL; 45 | print.text = item.Text; 46 | if (print.URL != null) { 47 | if ((Prints != null) && (Prints.size() > 0)) { 48 | for(int j = 0; (j < Prints.size()) && (print.text == null); j++ ) { 49 | Print old_print = (Print) Prints.elementAt(j); 50 | if (old_print.URL != null) { 51 | if (old_print.URL.equals(print.URL)) { 52 | print.text = old_print.text; 53 | } 54 | } 55 | } 56 | } 57 | } 58 | newPrints.addElement(print); 59 | } 60 | } 61 | Prints = newPrints; 62 | for(int i = 0; i < Prints.size(); i++) { 63 | Print print = (Print) Prints.elementAt(i); 64 | if (print.text != null) { 65 | print.drawable = true; 66 | } else { 67 | print.Load(_wizard); 68 | } 69 | } 70 | } 71 | 72 | public static boolean ready() { 73 | 74 | if (Prints == null) { 75 | System.out.println("Printer ready anything to print"); 76 | return true; 77 | } else if (Prints.size() == 0) { 78 | System.out.println("Printer ready anything to print"); 79 | return true; 80 | } 81 | 82 | for(int i = 0; i < Prints.size(); i++) { 83 | Print print = (Print) Prints.elementAt(i); 84 | if (!print.drawable) { 85 | System.out.println("Printer not ready, error: prints are not loading"); 86 | return false; 87 | } 88 | } 89 | System.out.println("Printer ready"); 90 | return true; 91 | } 92 | 93 | 94 | public static boolean paint(Graphics graphics) { 95 | 96 | System.out.println("Printer.paint:"); 97 | 98 | if (Prints != null) { 99 | for(int i = 0; i < Prints.size(); i++) { 100 | Print print = (Print) Prints.elementAt(i); 101 | if (print.visible) { 102 | graphics.setFont(new Font("Tiresias", Font.PLAIN, print.size)); 103 | graphics.setColor(print.color); 104 | try { 105 | System.out.println(print.text + " at: " + Integer.toString(print.X) + "," + Integer.toString(print.Y)); 106 | StringTokenizer st = new StringTokenizer(print.text, "\n"); 107 | int j = 0; 108 | while (st.hasMoreTokens()) { 109 | graphics.drawString(st.nextToken(), print.X, print.Y + j * (print.size + 3)); 110 | j++; 111 | } 112 | } 113 | catch(Throwable event) { 114 | event.printStackTrace(); 115 | } 116 | } 117 | } 118 | } 119 | return true; 120 | 121 | } 122 | 123 | } 124 | 125 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/RCResourceClient.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.io.*; 4 | import java.net.*; 5 | import java.util.*; 6 | 7 | /* Stub class */ 8 | public class RCResourceClient implements org.davic.resources.ResourceClient 9 | { 10 | 11 | public void release(org.davic.resources.ResourceProxy proxy) { 12 | } 13 | 14 | public boolean requestRelease(org.davic.resources.ResourceProxy proxy, Object requestData) { 15 | return false; 16 | } 17 | 18 | public void notifyRelease(org.davic.resources.ResourceProxy proxy) { 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Singer.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.media.*; 4 | import javax.tv.service.selection.*; 5 | import javax.tv.xlet.*; 6 | import java.util.*; 7 | import java.awt.*; 8 | import java.io.*; 9 | import java.lang.*; 10 | import org.havi.ui.*; 11 | import org.dvb.si.*; 12 | import org.dvb.dsmcc.*; 13 | import org.davic.net.dvb.DvbLocator; 14 | 15 | class Singer { 16 | 17 | static HSound song = null; 18 | static String URL = null; 19 | static boolean visible = false; 20 | 21 | public static void configure(Vector Items) { 22 | 23 | boolean foundItem = false; 24 | for(int i = 0; i < Items.size(); i++) { 25 | NamedItem item = (NamedItem) Items.elementAt(i); 26 | if (item.Name.equals("AudioItem")) { 27 | foundItem = true; 28 | visible = item.Visible.equals("Yes"); 29 | if (URL == null) { 30 | load(item.URL); 31 | } else if (!URL.equals(item.URL)) { 32 | load(item.URL); 33 | } 34 | } 35 | } 36 | if (!foundItem) { 37 | song = null; 38 | URL = null; 39 | visible = false; 40 | } 41 | } 42 | 43 | private static void load(String URLtoLoad) { 44 | 45 | try { 46 | CGIURL CGI_URL = new CGIURL(URLtoLoad); 47 | if (CGI_URL.carousel_id > -1) { 48 | System.out.println("Singer loading: " + URLtoLoad); 49 | song = new HSound(); 50 | song.load((CarouselManager.getCarousel(CGI_URL.carousel_id)).getMountPoint() + "/" + CGI_URL.valued_path); /* is flush necessary later ?*/ 51 | } 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | 56 | } 57 | 58 | 59 | public static void play() { 60 | if (song != null && visible == true) { 61 | System.out.println("Singer play"); 62 | song.play(); 63 | } else { 64 | System.out.println("Singer play failed"); 65 | } 66 | } 67 | 68 | } 69 | 70 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/TextBox.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.awt.*; 4 | 5 | 6 | public class TextBox { 7 | 8 | private int width = 0; 9 | private int height = 35; 10 | private int offsetX = 0; 11 | private int offsetY = 0; 12 | private String editStr = ""; /* The currently edited text */ 13 | private char pendingChar = 0; /* An character which has not yet been added to editStr */ 14 | 15 | public TextBox(int _width, int _offsetX, int _offsetY) { 16 | width = _width; 17 | offsetX = _offsetX; 18 | offsetY = _offsetY; 19 | } 20 | 21 | public void paint(Graphics graphics) { 22 | graphics.setColor(Color.blue); 23 | graphics.fillRoundRect(offsetX, offsetY, width, height, height, height); 24 | graphics.setColor(new Color(0xff, 0xff, 0xff)); 25 | graphics.fillRoundRect(offsetX + 2, offsetY + 2, width - 4, height - 4, (height - 4), (height- 4 )); 26 | graphics.setColor(Color.black); 27 | graphics.setFont(new Font("Tireasias", Font.PLAIN, 25)); 28 | if (editStr.length() != 0) { 29 | // Draw the string 30 | graphics.drawString(editStr, offsetX + 10, offsetY + 25); 31 | // Draw the final pending char in red if any 32 | if (pendingChar != 0) { 33 | graphics.setColor(Color.red); 34 | graphics.drawString(String.valueOf(pendingChar), offsetX + 10 + graphics.getFontMetrics().stringWidth(editStr), offsetY + 25); 35 | } 36 | } else if (pendingChar != 0) { 37 | graphics.setColor(Color.red); 38 | graphics.drawString(String.valueOf(pendingChar), offsetX + 10, offsetY + 25); 39 | } 40 | } 41 | 42 | /* Changes the current pending char */ 43 | public void setPending(char c) { 44 | pendingChar = c; 45 | } 46 | 47 | /* Moves pending character to string */ 48 | public void finishPending() { 49 | if (pendingChar != 0) { 50 | editStr += pendingChar; 51 | } 52 | pendingChar = 0; 53 | } 54 | 55 | /* Remove the last character if exists */ 56 | public void backSpace() { 57 | if (editStr.length() > 0) { 58 | editStr = editStr.substring(0, editStr.length() - 1); 59 | } 60 | } 61 | 62 | /* Add a space */ 63 | public void addSpace() { 64 | editStr = editStr + ' '; 65 | } 66 | 67 | /* Get the current string */ 68 | public String getString() { 69 | finishPending(); 70 | return editStr; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/Timer.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import java.util.Vector; 4 | 5 | /* second fine grain threaded timer */ 6 | public class Timer extends Thread { 7 | 8 | public int time = -1; 9 | public String URL = null; 10 | public int Page = -1; 11 | 12 | private Wizard wizard; 13 | 14 | public Timer(Vector Items, Wizard _wizard) { 15 | 16 | NamedItem item; 17 | wizard = _wizard; 18 | time = -1; 19 | for(int i = 0; i < Items.size(); i++) { 20 | item = (NamedItem) Items.elementAt(i); 21 | if (item.Name.equals("TimeItem")) { 22 | time = Integer.parseInt(item.Time); 23 | URL = item.URL; 24 | Page = Integer.parseInt(item.URLPage); 25 | return; 26 | } 27 | } 28 | } 29 | 30 | 31 | public void run() { 32 | try { 33 | sleep(time * 1000); 34 | wizard.ChangePage(URL, Page); 35 | } 36 | catch (InterruptedException e) { 37 | System.out.println("Timer interrupted"); 38 | ; 39 | } 40 | catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /extras/javasrc/yambo/VideoManager.java: -------------------------------------------------------------------------------- 1 | package tv.cineca.apps.yambo; 2 | 3 | import javax.tv.service.selection.*; 4 | import javax.media.Player; 5 | import javax.tv.media.AWTVideoSizeControl; 6 | import javax.tv.media.AWTVideoSize; 7 | import java.awt.Rectangle; 8 | import java.awt.Dimension; 9 | import javax.tv.locator.*; 10 | import javax.tv.xlet.XletContext; 11 | import java.util.*; 12 | 13 | /* Change the video layout */ 14 | class VideoManager { 15 | 16 | private static String program = null; 17 | private static int X = 0; 18 | private static int Y = 0; 19 | private static int width; 20 | private static int height; 21 | private static int old_X; 22 | private static int old_Y; 23 | 24 | public static void configure(Vector Items) { 25 | 26 | program = null; 27 | for(int i = 0; i < Items.size(); i++) { 28 | NamedItem item = (NamedItem) Items.elementAt(i); 29 | if (item.Name.equals("VideoItem")) { 30 | old_X = X; 31 | X = Integer.parseInt(item.LocationX); 32 | old_Y = Y; 33 | Y = Integer.parseInt(item.LocationY); 34 | width = Integer.parseInt(item.Width); 35 | height = Integer.parseInt(item.Height); 36 | } else if (item.Name.equals("ServiceItem")) { 37 | program = item.URL; 38 | } 39 | } 40 | 41 | } 42 | 43 | public static void zap(ServiceContext context) { 44 | 45 | if (program != null && context != null) { 46 | try { 47 | System.out.println("VideoManager change program"); 48 | LocatorFactory locatorFactory = LocatorFactory.getInstance(); 49 | Locator[] locator = new Locator[1]; 50 | locator[0] =locatorFactory.createLocator(program); 51 | context.select(locator); 52 | } 53 | catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | } 58 | 59 | public static void resize(ServiceContext context) { 60 | 61 | ServiceContentHandler[] handlers; 62 | AWTVideoSizeControl awtVideoSizeControl; 63 | Dimension video_size; 64 | Rectangle video_src; 65 | Rectangle video_dst; 66 | 67 | if (context != null) { 68 | 69 | System.out.println("VideoManager resizing video"); 70 | handlers = context.getServiceContentHandlers(); 71 | for(int i=0; i < handlers.length ; i++) { 72 | if (handlers[i] instanceof ServiceMediaHandler) { 73 | javax.media.Player player = (javax.media.Player) handlers[i]; 74 | awtVideoSizeControl = (AWTVideoSizeControl) player.getControl("javax.tv.media.AWTVideoSizeControl"); 75 | video_size = awtVideoSizeControl.getSourceVideoSize(); 76 | /* video_src = new Rectangle(old_X, old_Y, old_X + video_size.width, old_Y + video_size.height); */ 77 | video_src = new Rectangle(0, 0, video_size.width, video_size.height); 78 | video_dst = new Rectangle(X, Y, X + width, Y + height); 79 | awtVideoSizeControl.setSize( new AWTVideoSize(video_src, video_dst)); 80 | return; 81 | } 82 | } 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /libs/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = sectioncrc dvbobjects 2 | -------------------------------------------------------------------------------- /libs/dvbobjects/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = sectioncrc.py.c setup.py 2 | 3 | pyflags = --prefix=${prefix} --exec-prefix=${exec_prefix} 4 | 5 | all-local: 6 | ${PYTHON24} setup.py build 7 | 8 | clean-local: 9 | ${PYTHON24} setup.py clean 10 | 11 | install-exec-local: 12 | ${PYTHON24} setup.py install ${pyflags} 13 | 14 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/BIOP/Binding.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | from dvbobjects.utils import * 23 | 24 | BINDING_TYPE_NOBJECT = 0x01 25 | BINDING_TYPE_NCONTEXT = 0x02 26 | 27 | ###################################################################### 28 | class Binding(DVBobject): 29 | 30 | nameComponents_count = 1 # DVB 31 | 32 | def __init__(self, **kwargs): 33 | 34 | # Initialize SuperClass 35 | apply(DVBobject.__init__, (self,), kwargs) 36 | 37 | assert self.bindingType in ( # DVB 38 | BINDING_TYPE_NOBJECT, 39 | BINDING_TYPE_NCONTEXT) 40 | 41 | def pack(self): 42 | 43 | ior = self.IOR.pack() 44 | 45 | FMT = ( 46 | "!" 47 | "B" # nameComponents_count 48 | "B%ds" # id 49 | "B%ds" # kind 50 | "B" # bindingType 51 | "%ds" # IOP::IOR() 52 | "H%ds" # objectInfo 53 | ) % ( 54 | len(self.nameId), 55 | len(self.nameKind), 56 | len(ior), 57 | len(self.objectInfo), 58 | ) 59 | 60 | return pack( 61 | FMT, 62 | self.nameComponents_count, 63 | len(self.nameId), 64 | self.nameId, 65 | len(self.nameKind), 66 | self.nameKind, 67 | self.bindingType, 68 | ior, 69 | len(self.objectInfo), 70 | self.objectInfo, 71 | ) 72 | 73 | def __repr__(self): 74 | """Overrides DVBobject.__repr_, which is noooiiisy""" 75 | loc = self.IOR.profile.objectLocation 76 | mod = loc.moduleId 77 | key = loc.objectKey 78 | return `(self.nameId, 79 | (mod, key), 80 | )` 81 | 82 | ###################################################################### 83 | class ObjectFileBinding(Binding): 84 | 85 | bindingType = BINDING_TYPE_NOBJECT 86 | nameKind = CDR("fil") 87 | 88 | def __init__(self, **kwargs): 89 | 90 | # Initialize SuperClass 91 | apply(Binding.__init__, (self,), kwargs) 92 | 93 | self.objectInfo = pack("!LL", 0, self.contentSize) 94 | 95 | ###################################################################### 96 | class ObjectStreamEventBinding(Binding): 97 | 98 | bindingType = BINDING_TYPE_NOBJECT 99 | nameKind = CDR("ste") 100 | objectInfo = "" 101 | 102 | def __init__(self, **kwargs): 103 | 104 | # Initialize SuperClass 105 | apply(Binding.__init__, (self,), kwargs) 106 | 107 | ###################################################################### 108 | class ContextBinding(Binding): 109 | 110 | bindingType = BINDING_TYPE_NCONTEXT 111 | nameKind = CDR("dir") # MHP 112 | objectInfo = "" # MHP 113 | 114 | def __init__(self, **kwargs): 115 | 116 | # Initialize SuperClass 117 | apply(Binding.__init__, (self,), kwargs) 118 | 119 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/BIOP/ModuleInfo.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | from dvbobjects.utils import * 23 | import Tap 24 | import string 25 | 26 | ###################################################################### 27 | class ModuleInfo(DVBobject): 28 | 29 | ModuleTimeOut = 0xFFFFFFFF 30 | BlockTimeOut = 0xFFFFFFFF 31 | MinBlockTime = 0x00000000 32 | 33 | userInfo = "" 34 | 35 | def __init__(self, **kwargs): 36 | # Initialize SuperClass 37 | apply(DVBobject.__init__, (self,), kwargs) 38 | self.taps = [ 39 | Tap.object_tap( 40 | assocTag = self.assocTag, 41 | ) 42 | ] 43 | 44 | def pack(self): 45 | 46 | assert len(self.taps) >= 1 # MHP 47 | taps_bytes = string.join(map(lambda t: t.pack(), 48 | self.taps), 49 | "") 50 | user_info_bytes = string.join(map(lambda ui: ui.pack(), 51 | self.userInfo), 52 | "") 53 | 54 | FMT =("!" 55 | "L" # ModuleTimeOut 56 | "L" # BlockTimeOut 57 | "L" # MinBlockTime 58 | "B" # taps_count 59 | "%ds" # taps 60 | "B" 61 | "%ds" # userInfo 62 | ) % ( 63 | len(taps_bytes), 64 | len(user_info_bytes), 65 | ) 66 | 67 | return pack(FMT, 68 | self.ModuleTimeOut, 69 | self.BlockTimeOut, 70 | self.MinBlockTime, 71 | len(self.taps), 72 | taps_bytes, 73 | len(user_info_bytes), 74 | user_info_bytes, 75 | ) 76 | 77 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/BIOP/__init__.py: -------------------------------------------------------------------------------- 1 | # This file is part of the dvbobjects library. 2 | # 3 | # Copyright 2000-2001, GMD, Sankt Augustin 4 | # -- German National Research Center for Information Technology 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | from Message import ServiceGatewayMessage, DirectoryMessage, FileMessage, StreamEventMessage 21 | from Message import ServiceGatewayInfo 22 | from Tap import delivery_para_tap, object_tap 23 | from Binding import ContextBinding, ObjectFileBinding, ObjectStreamEventBinding 24 | from ModuleInfo import ModuleInfo 25 | import IOP 26 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/Descriptors.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | import string 23 | from dvbobjects.utils import * 24 | from dvbobjects.MPEG.Descriptor import Descriptor 25 | 26 | ###################################################################### 27 | class data_broadcast_descriptor(Descriptor): 28 | 29 | descriptor_tag = 0x64 30 | data_broadcast_id = 0x0007 31 | text_chars = "" 32 | 33 | def bytes(self): 34 | self.selector_length = len(self.selector_bytes) 35 | self.text_length = len(self.text_chars) 36 | 37 | FMT = "!HBB%ds%dsB%ds" % ( 38 | self.selector_length, 39 | 3, # ISO_639_language_code 40 | self.text_length, 41 | ) 42 | 43 | return pack( 44 | FMT, 45 | self.data_broadcast_id, 46 | self.component_tag, 47 | self.selector_length, 48 | self.selector_bytes, 49 | self.ISO_639_language_code, 50 | self.text_length, 51 | self.text_chars, 52 | ) 53 | 54 | def sample(self): 55 | self.set( 56 | component_tag = 0x11, 57 | selector_bytes = "012345", 58 | text_chars = "abcde", 59 | ) 60 | 61 | 62 | ###################################################################### 63 | class object_carousel_info(DVBobject): 64 | 65 | carousel_type_id = 0x02 66 | transaction_id = 0xFFFFFFFF 67 | time_out_value_DSI = 0xFFFFFFFF 68 | time_out_value_DII = 0xFFFFFFFF 69 | leak_rate = 0x00 70 | 71 | def pack(self): 72 | 73 | obj_loop_bytes = "" 74 | for obj_name_chars in self.object_names: 75 | object_name_length = len(obj_name_chars) 76 | obj_bytes = pack( 77 | "!3sB%ds" % object_name_length, 78 | self.ISO_639_language_code, 79 | object_name_length, 80 | obj_name_chars, 81 | ) 82 | obj_loop_bytes = obj_loop_bytes + obj_bytes 83 | 84 | 85 | obj_loop_length = len(obj_loop_bytes) 86 | 87 | FMT = "!B4L%ds" % obj_loop_length 88 | return pack( 89 | FMT, 90 | (self.carousel_type_id << 6 | 0x63), 91 | self.transaction_id, 92 | self.time_out_value_DSI, 93 | self.time_out_value_DII, 94 | (0x0C000000 | self.leak_rate), 95 | obj_loop_bytes, 96 | ) 97 | 98 | def sample(self): 99 | self.set( 100 | object_names = ["aaa", "bbbbbb"] 101 | ) 102 | 103 | ###################################################################### 104 | class stream_event_do_it_now_descriptor(Descriptor): 105 | 106 | descriptor_tag = 0x1a 107 | 108 | eventNPT = 0x0 109 | 110 | reserved = 0x0 111 | 112 | def bytes(self): 113 | self.text_length = len(self.private_data) 114 | 115 | FMT = "!HLL%ds" % self.text_length 116 | 117 | return pack( 118 | FMT, 119 | self.event_id, 120 | self.reserved, 121 | self.eventNPT, 122 | self.private_data, 123 | ) 124 | 125 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/STE.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2006 Lorenzo Pallara 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | import string 22 | from dvbobjects.MPEG.Section import Section 23 | from dvbobjects.DSMCC.Descriptors import * 24 | 25 | ###################################################################### 26 | class stream_event_section(Section): 27 | 28 | table_id = 0x3d 29 | 30 | section_max_size = 4096 31 | 32 | def pack_section_body(self): 33 | 34 | self.table_id_extension = self.event_id 35 | self.segment_last_section_number = self.last_section_number 36 | self.last_table_id = self.table_id 37 | 38 | # pack event_loop 39 | stel_bytes = string.join( 40 | map(lambda x: x.pack(), 41 | self.stream_event_descriptor_loop), 42 | "") 43 | 44 | fmt = "!%ds" % len(stel_bytes) 45 | return pack(fmt, 46 | stel_bytes, 47 | ) 48 | 49 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/STEO.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # 4 | # Copyright (C) 2006 Lorenzo Pallara, lpallara@cineca.it 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | import os 21 | import string 22 | 23 | from dvbobjects.DSMCC.BIOP.Tap import * 24 | from dvbobjects.utils import * 25 | 26 | 27 | ############################### 28 | class Event_names(DVBobject): 29 | 30 | def pack(self): 31 | 32 | result = pack("!H", self.eventnames_count) 33 | for name in self.event_name_loop: 34 | name = name + "\x00" 35 | result = result + pack( 36 | "!B%ds" % len(name), 37 | len(name), 38 | name, 39 | ) 40 | return result 41 | 42 | ############################### 43 | class Event_ids(DVBobject): 44 | 45 | def pack(self): 46 | 47 | result = pack("!B", self.eventids_count) 48 | for id in self.event_id_loop: 49 | result = result + pack("!H", id) 50 | return result 51 | 52 | ############################### 53 | class Taps(DVBobject): 54 | 55 | def pack(self): 56 | 57 | result = pack("!B", self.taps_count) 58 | for tap in self.tap_loop: 59 | result = result + tap.pack() 60 | return result 61 | ############################### 62 | 63 | 64 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DSMCC/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/DVB/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/MHP/AIT.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | import string 23 | from dvbobjects.MPEG.Section import Section 24 | from dvbobjects.utils import * 25 | 26 | ###################################################################### 27 | class application_information_section(Section): 28 | 29 | table_id = 0x74 30 | 31 | section_max_size = 1024 32 | 33 | def pack_section_body(self): 34 | 35 | # pack common_descriptor_loop 36 | cdl_bytes = string.join( 37 | map(lambda x: x.pack(), 38 | self.common_descriptor_loop), 39 | "") 40 | 41 | # pack applicaton_loop 42 | apl_bytes = string.join( 43 | map(lambda x: x.pack(), 44 | self.application_loop), 45 | "") 46 | 47 | self.table_id_extension = self.application_type # ??? 48 | 49 | fmt = "!H%dsH%ds" % (len(cdl_bytes), len(apl_bytes)) 50 | return pack(fmt, 51 | 0xF000 | (len(cdl_bytes) & 0x0FFF), 52 | cdl_bytes, 53 | 0xF000 | (len(apl_bytes) & 0x0FFF), 54 | apl_bytes, 55 | ) 56 | 57 | ###################################################################### 58 | class application_loop_item(DVBobject): 59 | 60 | def pack(self): 61 | 62 | # pack application_descriptors_loop 63 | adl_bytes = string.join( 64 | map(lambda x: x.pack(), 65 | self.application_descriptors_loop), 66 | "") 67 | 68 | fmt = "!LHBH%ds" % len(adl_bytes) 69 | return pack(fmt, 70 | self.organisation_id, 71 | self.application_id, 72 | self.application_control_code, 73 | 0xF000 | (len(adl_bytes) & 0x0FFF), 74 | adl_bytes, 75 | ) 76 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/MHP/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | """Package MHP (Multimedia Home Platform). 23 | 24 | Extends packages DVB and DSMCC. 25 | """ 26 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/MPEG/Descriptor.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | from dvbobjects.utils import * 23 | 24 | ###################################################################### 25 | class Descriptor(DVBobject): 26 | """The base class for all Descriptors. 27 | Subclasses must implement a bytes() method, 28 | that returns the descriptor body bytes. 29 | """ 30 | 31 | def pack(self): 32 | bytes = self.bytes() 33 | return pack("!BB%ds" % len(bytes), 34 | self.descriptor_tag, 35 | len(bytes), 36 | bytes, 37 | ) 38 | 39 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/MPEG/Section.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | from dvbobjects.utils import * 23 | 24 | ###################################################################### 25 | class Section(DVBobject): 26 | """The base class of many PSI/SI Sections. 27 | 28 | It implements the general layout of all(?) PSI/SI 29 | sections with 'syntax_indicator' == 1. 30 | 31 | Constant Attributes: 32 | 33 | - 'section_syntax_indicator' = 1, 34 | 35 | - 'current_next_indicator' = 1. 36 | 37 | Attributes to be provided by subclasses: 38 | 39 | - 'table_id' 40 | 41 | - 'table_id_extension' 42 | 43 | Attributes to be provided by other means (e.g. using 'set()'): 44 | 45 | - 'version_number' 46 | 47 | - 'section_number' 48 | 49 | - 'last_section_number' 50 | 51 | Computed Attributes: 52 | 53 | - 'section_length' 54 | 55 | - 'crc_32' 56 | 57 | Subclasses must implement a 'pack_section_body()' method. 58 | """ 59 | section_max_size = 4096 60 | section_syntax_indicator = 1 61 | private_indicator = 0 62 | current_next_indicator = 1 63 | 64 | def __sanity_check(self): 65 | assert self.section_syntax_indicator == 1 66 | assert self.current_next_indicator in (0, 1) 67 | assert 0 <= self.table_id <= 0xff 68 | assert 0 <= self.table_id_extension <= 0xffff 69 | assert 0 <= self.section_length <= self.section_max_size - 3 70 | assert 0 <= self.section_number <= 0xFF 71 | assert 0 <= self.last_section_number <= 0xFF 72 | 73 | def pack(self): 74 | 75 | body = self.pack_section_body() 76 | 77 | self.section_length = ( 78 | 5 # section header rest 79 | + len(body) # section body 80 | + 4 # CRC32 81 | ) 82 | length_info_16 = ( 83 | 0xB000 84 | | (self.section_syntax_indicator<<15) 85 | | (self.private_indicator << 14) 86 | | (self.section_length) 87 | ) 88 | version_info_8 = ( 89 | 0xC0 90 | | ((self.version_number & 0x01f) << 1) 91 | | (self.current_next_indicator) 92 | ) 93 | 94 | self.__sanity_check() 95 | 96 | data = pack("!BHHBBB", 97 | self.table_id, 98 | length_info_16, 99 | self.table_id_extension, 100 | version_info_8, 101 | self.section_number, 102 | self.last_section_number, 103 | ) + body 104 | 105 | return data + self.crc_32(data) 106 | 107 | def crc_32(self, data): 108 | crc = crc32.CRC_32(data) 109 | return pack("!L", crc) 110 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/MPEG/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/MPEG/__init__.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/CAT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/CAT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/ECM.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/ECM.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/EIT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/EIT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/EMM.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/EMM.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/INT.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # Copyright 2007 Andreas Berger 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | import string 20 | from dvbobjects.MPEG.Section import Section 21 | from dvbobjects.utils import * 22 | from dvbobjects.DVB.Descriptors import * 23 | 24 | ###################################################################### 25 | class ip_mac_notification_section(Section): 26 | 27 | table_id = 0x4c 28 | 29 | section_max_size = 4096 30 | 31 | def pack_section_body(self): 32 | 33 | self.action_type = 0x01 34 | self.platform_id_hash = ( (self.platform_id>>16) & 0xff ) ^ ( (self.platform_id>>8) & 0xff ) ^ ( self.platform_id & 0xff ) 35 | 36 | # pack platform descriptor loop 37 | pdl_bytes = string.join( 38 | map(lambda x: x.pack(), 39 | self.platform_descriptor_loop), 40 | "") 41 | 42 | # pack associaton_loop 43 | al_bytes = string.join( 44 | map(lambda x: x.pack(), 45 | self.association_loop), 46 | "") 47 | 48 | pdl_bytes_length = len(pdl_bytes) 49 | self.table_id_extension = self.action_type << 8 | self.platform_id_hash 50 | 51 | fmt = "!BBBBBB%ds%ds" % (len(pdl_bytes), len(al_bytes)) 52 | return pack(fmt, 53 | (self.platform_id >> 16) & 0xFF, 54 | (self.platform_id >> 8) & 0xFF, 55 | self.platform_id & 0xFF, 56 | self.processing_order, 57 | 0xF0 << 8 | (pdl_bytes_length >> 8) & 0x0F, 58 | pdl_bytes_length & 0xFF, 59 | pdl_bytes, 60 | al_bytes 61 | ) 62 | 63 | class association_loop_item(DVBobject): 64 | 65 | def pack(self): 66 | # pack target descriptor loop 67 | tdl_bytes = string.join( 68 | map(lambda x: x.pack(), 69 | self.target_descriptor_loop), 70 | "") 71 | 72 | # pack operational descriptor loop 73 | odl_bytes = string.join( 74 | map(lambda x: x.pack(), 75 | self.operational_descriptor_loop), 76 | "") 77 | 78 | tdl_bytes_length = len(tdl_bytes) 79 | odl_bytes_length = len(odl_bytes) 80 | 81 | fmt = "!BB%dsBB%ds" % (tdl_bytes_length, odl_bytes_length) 82 | 83 | return pack(fmt, 84 | 0xF0 << 8 | (tdl_bytes_length >> 8) & 0x0F, 85 | tdl_bytes_length & 0xFF, 86 | tdl_bytes, 87 | 0xF0 << 8 | (odl_bytes_length >> 8) & 0x0F, 88 | odl_bytes_length & 0xFF, 89 | odl_bytes 90 | ) 91 | 92 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/NIT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/NIT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/PAT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/PAT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/PMT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/PMT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/SDT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/SDT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/TDT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/TDT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/TOT.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/TOT.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/UNT.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2009 Lorenzo Pallara 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | import string 22 | from dvbobjects.MPEG.Section import Section 23 | from dvbobjects.utils import * 24 | from dvbobjects.DVB.Descriptors import * 25 | 26 | ###################################################################### 27 | class update_notification_section(Section): 28 | 29 | table_id = 0x4B 30 | 31 | section_max_size = 4096 32 | 33 | def pack_section_body(self): 34 | 35 | self.table_id_extension = self.action_type << 8 | ((self.OUI >> 16) ^ ((self.OUI >> 8) & 0xFF) ^ (self.OUI & 0xFF)) 36 | 37 | # pack common_descriptor_loop 38 | common_bytes = string.join( 39 | map(lambda x: x.pack(), 40 | self.common_descriptor_loop), 41 | "") 42 | 43 | # pack compatibility_descriptor_loop 44 | compatibility_bytes = string.join( 45 | map(lambda x: x.pack(), 46 | self.compatibility_descriptor_loop), 47 | "") 48 | 49 | fmt = "!HBBH%ds%ds" % (len(common_bytes), len(compatibility_bytes)) 50 | return pack(fmt, 51 | self.OUI >> 8, 52 | self.OUI & 0xFF, 53 | self.processing_order, 54 | 0xF000 | len(common_bytes), 55 | common_bytes, 56 | compatibility_bytes, 57 | ) 58 | 59 | ###################################################################### 60 | class unt_compatibility_descriptor_loop_item(DVBobject): 61 | 62 | def pack(self): 63 | 64 | # pack target_descriptor_loop 65 | tdl_bytes = string.join( 66 | map(lambda x: x.pack(), 67 | self.target_descriptor_loop), 68 | "") 69 | 70 | # pack operational descriptor_loop 71 | odl_bytes = string.join( 72 | map(lambda x: x.pack(), 73 | self.operational_descriptor_loop), 74 | "") 75 | 76 | fmt = "!%dsHH%dsH%ds" % (len(self.compatibility_descriptor), len(tdl_bytes), len(odl_bytes)) 77 | return pack(fmt, 78 | self.compatibility_descriptor, 79 | len(tdl_bytes) + len(odl_bytes), 80 | 0xF000 | len(tdl_bytes), 81 | tdl_bytes, 82 | 0xF000 | len(odl_bytes), 83 | odl_bytes, 84 | ) 85 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/PSI/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/PSI/__init__.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/__init__.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/ByteInvert.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/ByteInvert.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/ByteParity.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/ByteParity.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/DVBobject.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # This file is part of the dvbobjects library. 4 | # 5 | # Copyright 2000-2001, GMD, Sankt Augustin 6 | # -- German National Research Center for Information Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | import string 23 | import pprint 24 | 25 | ###################################################################### 26 | def CDR(s, alignment = 4, gap_byte = 0xFF): 27 | """If necessary, append to 's' a trailing NUL byte 28 | and fill with 'gap_byte' until properly aligned. 29 | """ 30 | 31 | if len(s) % alignment == 0 and s[-1] in ("\x00", "\xFF"): 32 | return s 33 | s = s + "\x00" 34 | 35 | while len(s) % alignment: 36 | s = s + chr(gap_byte) 37 | return s 38 | 39 | ###################################################################### 40 | class DVBobject: 41 | """The base class for many protocol data units. 42 | 43 | Basically it provides functionality similar to a C-struct. 44 | Members are set via keyword arguments either in the constructor 45 | or via the set() method. Other (rather static) attributes 46 | can be defined as (sub-)class attributes. 47 | 48 | Subclasses must implement a 'pack()' method which returns 49 | the properly packed byte string. 50 | 51 | Attributes may come from the following sources: 52 | 53 | 1. (Static) class attributes; 54 | 55 | 2. Keyword arguments given in the constructor; 56 | 57 | 3. Keyword arguments given in the 'set()' method; 58 | 59 | 4. Direct assignment to instance attributes (NOT recommended). 60 | """ 61 | 62 | # 63 | # Default attribute value. 64 | # Subclasses can do that, too! 65 | # 66 | ISO_639_language_code = "deu" 67 | 68 | def __init__(self, **kwargs): 69 | """Initialize instance attributes from keyword arguments. 70 | """ 71 | apply(self.set, (), kwargs) 72 | 73 | def set(self, **kwargs): 74 | """Add (more) instance attributes from keyword arguments. 75 | """ 76 | for k, v in kwargs.items(): 77 | setattr(self, k, v) 78 | 79 | def __repr__(self): 80 | """Used for debugging.""" 81 | def hilite(s): 82 | return "### %s ###" % s 83 | return pprint.pformat( 84 | (hilite(self.__class__.__name__), 85 | self.__dict__)) 86 | 87 | def dump(self): 88 | """Print a simple hexdump of this object to stdout. 89 | """ 90 | BYTES_PER_LINE = 16 91 | bytes = self.pack() 92 | i = 0 93 | for byte in bytes: 94 | if i % BYTES_PER_LINE == 0: 95 | if i: print # start on a fresh line... 96 | print "%04x " % i, 97 | print "%02X" % ord(byte), 98 | i = i+1 99 | print # dump is done => NL 100 | 101 | def test(self): 102 | """Used for debugging.""" 103 | if not self.__dict__: 104 | self.sample() 105 | self.dump() 106 | print self 107 | 108 | -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/Hamming.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/Hamming.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/MJD.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/MJD.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/SpecFile.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/SpecFile.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nexgenta/opencaster/314f3d9c674d616cb9beef74afc8eb4243f150ce/libs/dvbobjects/dvbobjects/utils/__init__.py -------------------------------------------------------------------------------- /libs/dvbobjects/dvbobjects/utils/crc32.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | def CRC_32(data): 4 | 5 | return 0xFFFFFFFF 6 | 7 | try: 8 | import _crc32 9 | CRC_32 = _crc32.sectioncrc 10 | except ImportError: 11 | print "### WRONG CRC32!!!" 12 | pass 13 | -------------------------------------------------------------------------------- /libs/dvbobjects/sectioncrc.py.c: -------------------------------------------------------------------------------- 1 | /* 2 | sectioncrc.py.c -- MPEG-2 checksum calculation, Python Module 3 | 4 | Copyright (C) 2001 Oleg Tchekoulaev, GMD 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | 23 | #include "../sectioncrc/sectioncrc.c" 24 | 25 | unsigned int sectioncrc( unsigned char*, unsigned int ); 26 | static PyObject* do_sectioncrc( PyObject*, PyObject* ); 27 | static PyMethodDef methods [] = { 28 | { "sectioncrc", do_sectioncrc, METH_VARARGS }, 29 | {NULL, NULL} 30 | }; 31 | 32 | 33 | void init_crc32(void) { 34 | Py_InitModule( "_crc32", methods ); 35 | } 36 | 37 | 38 | static PyObject* do_sectioncrc( PyObject *self, PyObject *args ) { 39 | 40 | unsigned int c; 41 | char *buf; 42 | int len; 43 | 44 | if( !PyArg_ParseTuple( args, "s#", &buf, &len ) ) 45 | return NULL; 46 | 47 | c = sectioncrc( buf, len ); 48 | 49 | return Py_BuildValue( "I", c ); 50 | } 51 | -------------------------------------------------------------------------------- /libs/dvbobjects/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | from distutils.core import setup, Extension 4 | 5 | import sys 6 | 7 | # from an original source code by Joachim Kaeber (kaeber@gmd.de) 8 | 9 | _ext_modules = None 10 | 11 | if sys.platform in ['linux2', 'solaris2', 'win32']: 12 | _ext_modules = [ Extension('dvbobjects.utils._crc32', [ 'sectioncrc.py.c'] ), ] 13 | 14 | setup( 15 | name = "dvbobjects", 16 | version = "0.1", 17 | description = "Python Package for dvb transport stream data generation (PAT, PMT, NIT, Object Carousel, ...)", 18 | author = "Lorenzo Pallara", 19 | author_email = "lpallara@cineca.it", 20 | url = "", 21 | 22 | packages = [ 23 | 'dvbobjects', 24 | 'dvbobjects.DSMCC', 25 | 'dvbobjects.DSMCC.BIOP', 26 | 'dvbobjects.DVB', 27 | 'dvbobjects.MHP', 28 | 'dvbobjects.PSI', 29 | 'dvbobjects.MPEG', 30 | 'dvbobjects.utils', 31 | ], 32 | 33 | ext_modules = _ext_modules 34 | ) 35 | -------------------------------------------------------------------------------- /libs/sectioncrc/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libsectioncrc.la 2 | 3 | libsectioncrc_la_SOURCES = sectioncrc.c 4 | -------------------------------------------------------------------------------- /libs/sectioncrc/sectioncrc.h: -------------------------------------------------------------------------------- 1 | /* 2 | sectioncrc.h -- MPEG-2 checksum calculation 3 | 4 | Copyright (C) 2001 Oleg Tchekoulaev, GMD 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include 22 | 23 | uint32_t sectioncrc( unsigned char*, unsigned int ); 24 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = oc2sec sec2ts zpipe tsfilter tsloop tsmodder tsnullfiller \ 2 | tsnullshaper tspcrmeasure tspidmapper esaudio2pes esaudioinfo \ 3 | esvideo2pes esvideoinfo pes2es pesaudio2ts pesvideo2ts pesinfo \ 4 | tsstamp ts2pes mpe2sec tscbrmuxer vbv tstdt i13942ts tsvbr2cbr \ 5 | tsfixcc tsudpreceive tsudpsend dsmcc-receive pesclock tspcrstamp \ 6 | tstcpreceive tstcpsend tstimeout tstimedwrite tsinputswitch \ 7 | tsdoubleoutput pes2txt tsoutputswitch totsectionrestamp tsccc \ 8 | txt2pes pesdata2ts 9 | 10 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = dsmcc-receive 2 | 3 | dsmcc_receive_SOURCES = \ 4 | dsmcc-receive.c carousel.c module.c dsmcc.c biop.c filter.c \ 5 | fs.c table.c assoc.c util.c 6 | 7 | dsmcc_receive_LDADD = @ZLIB_LIBS@ 8 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/assoc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * assoc.c 3 | * 4 | * maps stream_id_descriptors to elementary_PID numbers 5 | */ 6 | 7 | /* 8 | * Copyright (C) 2005, Simon Kilvington 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "assoc.h" 30 | #include "utils.h" 31 | 32 | void 33 | init_assoc(struct assoc *a) 34 | { 35 | a->nassocs = 0; 36 | a->pids = NULL; 37 | a->sids = NULL; 38 | 39 | return; 40 | } 41 | 42 | void 43 | add_assoc(struct assoc *a, uint16_t elementary_pid, uint16_t stream_id) 44 | { 45 | a->nassocs ++; 46 | 47 | a->pids = safe_realloc(a->pids, a->nassocs * sizeof(uint16_t)); 48 | a->sids = safe_realloc(a->sids, a->nassocs * sizeof(uint16_t)); 49 | 50 | a->pids[a->nassocs - 1] = elementary_pid; 51 | a->sids[a->nassocs - 1] = stream_id; 52 | 53 | return; 54 | } 55 | 56 | uint16_t 57 | stream2pid(struct assoc *a, uint16_t stream_id) 58 | { 59 | unsigned int i; 60 | 61 | for(i=0; inassocs; i++) 62 | { 63 | if(a->sids[i] == stream_id) 64 | return a->pids[i]; 65 | } 66 | 67 | error("Unknown PID for association tag 0x%x", stream_id); 68 | 69 | return 0; 70 | } 71 | 72 | 73 | void clean_assoc(struct assoc *a) 74 | { 75 | if (a != 0) { 76 | if (a->pids != 0) { 77 | safe_free(a->pids); 78 | } 79 | if (a->sids != 0) { 80 | safe_free(a->sids); 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/assoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * assoc.h 3 | * 4 | * maps stream_id_descriptors to elementary_PID numbers 5 | */ 6 | 7 | /* 8 | * Copyright (C) 2005, Simon Kilvington 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef __ASSOC_H__ 26 | #define __ASSOC_H__ 27 | 28 | #include 29 | 30 | struct assoc 31 | { 32 | unsigned int nassocs; 33 | uint16_t *pids; 34 | uint16_t *sids; 35 | }; 36 | 37 | void init_assoc(struct assoc *); 38 | void add_assoc(struct assoc *, uint16_t, uint16_t); 39 | void clean_assoc(struct assoc *); 40 | 41 | uint16_t stream2pid(struct assoc *, uint16_t); 42 | 43 | #endif /* __ASSOC_H__ */ 44 | 45 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/biop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * biop.h 3 | * 4 | * BIOP data types from ISO/IEC 13818-6 5 | */ 6 | 7 | /* 8 | * Copyright (C) 2005, Simon Kilvington 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef __BIOP_H__ 26 | #define __BIOP_H__ 27 | 28 | #include 29 | 30 | #include "carousel.h" 31 | #include "assoc.h" 32 | 33 | struct BIOPVersion 34 | { 35 | uint8_t major; 36 | uint8_t minor; 37 | } __attribute__((__packed__)); 38 | 39 | struct BIOPMessageHeader 40 | { 41 | char magic[4]; /* 'BIOP' */ 42 | struct BIOPVersion biop_version; /* 1.0 */ 43 | uint8_t byte_order; /* 0 = big endian */ 44 | uint8_t message_type; /* should be 0 */ 45 | uint32_t message_size; /* not including this header */ 46 | } __attribute__((__packed__)); 47 | 48 | /* magic header value */ 49 | #define BIOP_MAGIC_STR "BIOP" 50 | #define BIOP_MAGIC_LEN 4 51 | 52 | /* version we are expecting */ 53 | #define BIOP_VSN_MAJOR 1 54 | #define BIOP_VSN_MINOR 0 55 | 56 | /* byte order */ 57 | #define BIOP_BIGENDIAN 0 58 | 59 | /* message type we are expecting */ 60 | #define BIOP_MSG_TYPE 0 61 | 62 | /* objectKind types */ 63 | #define BIOP_DIR "dir" 64 | #define BIOP_FILE "fil" 65 | #define BIOP_STREAM "str" 66 | #define BIOP_SERVICEGATEWAY "srg" 67 | #define BIOP_STREAMEVENT "ste" 68 | 69 | /* IOP::IOR profileId_tag values */ 70 | #define TAG_BIOP 0x49534f06 71 | #define TAG_LITE_OPTIONS 0x49534f05 72 | 73 | /* BIOP::ObjectLocation tag */ 74 | #define TAG_ObjectLocation 0x49534f50 75 | 76 | /* DSM::ConnBinder tag */ 77 | #define TAG_ConnBinder 0x49534f40 78 | 79 | /* use types */ 80 | #define BIOP_DELIVERY_PARA_USE 0x0016 81 | 82 | /* selector_type we are expecting */ 83 | #define SELECTOR_TYPE_MESSAGE_LEN 0x0a 84 | #define SELECTOR_TYPE_MESSAGE 0x0001 85 | 86 | /* data type to hold a sequence */ 87 | struct biop_sequence 88 | { 89 | uint32_t size; 90 | unsigned char *data; 91 | }; 92 | 93 | /* data type to hold an IOP::IOR object reference */ 94 | struct biop_iop_ior 95 | { 96 | uint16_t association_tag; /* maps to an elementary_PID */ 97 | uint32_t carousel_id; 98 | uint16_t module_id; 99 | struct biop_sequence key; 100 | }; 101 | 102 | /* functions */ 103 | bool process_biop(char* paramDir, struct carousel *, struct module *, struct BIOPMessageHeader *, uint32_t); 104 | void process_biop_dir(char* paramDir, uint8_t, char *, struct carousel *, unsigned char *, uint32_t); 105 | uint32_t process_iop_ior(uint8_t, unsigned char *, struct biop_iop_ior *); 106 | uint16_t process_biop_service_gateway_info(char* paramDir, uint16_t, struct assoc *, unsigned char *, uint16_t); 107 | 108 | uint16_t biop_uint16(uint8_t, uint16_t); 109 | uint32_t biop_uint32(uint8_t, uint32_t); 110 | 111 | uint32_t biop_sequence255(unsigned char *, struct biop_sequence *); 112 | uint32_t biop_sequence65535(uint8_t, unsigned char *, struct biop_sequence *); 113 | uint32_t biop_sequence(uint8_t, unsigned char *, struct biop_sequence *); 114 | 115 | uint32_t biop_align32(uint32_t); 116 | 117 | #endif 118 | 119 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/carousel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * carousel.h 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2005, Simon Kilvington 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef __CAROUSEL_H__ 24 | #define __CAROUSEL_H__ 25 | 26 | #include 27 | 28 | #include "module.h" 29 | #include "dsmcc.h" 30 | 31 | /* functions */ 32 | int load_carousel(char* paramDir, struct carousel *, int cache_size); 33 | int process_dii(struct carousel *, struct DownloadInfoIndication *, uint32_t); 34 | void process_dsi(char* paramDir, struct carousel *, struct DownloadServerInitiate *); 35 | int process_ddb(char* paramDir, struct carousel *, struct DownloadDataBlock *, uint32_t, uint32_t); 36 | 37 | #endif /* __CAROUSEL_H__ */ 38 | 39 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/dsmcc-receive.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #define _BSD_SOURCE 1 20 | 21 | #ifdef HAVE_CONFIG_H 22 | # include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #ifdef HAVE_INTTYPES_H 33 | # include 34 | #endif 35 | #include 36 | #include 37 | #include 38 | #ifdef HAVE_STDINT_H 39 | # include 40 | #endif 41 | #include 42 | 43 | #include "carousel.h" 44 | #include "utils.h" 45 | #include "table.h" 46 | 47 | void usage(char *); 48 | 49 | int 50 | main(int argc, char *argv[]) 51 | { 52 | char* directory = 0; 53 | char* sections = 0; 54 | int cachesize = 0; 55 | int result = 0; 56 | int pid = 0; 57 | int component_tag = 0; 58 | 59 | if (argc != 5) { 60 | usage(argv[0]); 61 | return 0; 62 | } else { 63 | directory = argv[1]; 64 | cachesize = atoi(argv[2]); 65 | pid = atoi(argv[3]); 66 | component_tag = atoi(argv[4]); 67 | } 68 | 69 | struct carousel a_carousel; 70 | 71 | a_carousel.timeout = 60; /* 1 minute, not used for dsmcc-receive */ 72 | a_carousel.service_id = 1; /* not used for dsmcc-receive */ 73 | a_carousel.carousel_id = 0; /* not used for dsmcc-receive */ 74 | a_carousel.npids = 0; 75 | a_carousel.pids = NULL; 76 | a_carousel.got_dsi = 0; 77 | a_carousel.nmodules = 0; 78 | a_carousel.modules = NULL; 79 | a_carousel.stop = 0; 80 | a_carousel.completed = 0; 81 | a_carousel.current_pid = pid; /* not used for dsmcc-receive */ 82 | add_dsmcc_pid(&a_carousel, pid); /* a carousel can be received from multiple PIDs, add the first we have found, this must carry DSI table or won't load */ 83 | init_assoc(&(a_carousel.assoc)); 84 | add_assoc(&(a_carousel.assoc), pid, component_tag); /* set the mapping between stream_id_descriptors and elementary_PIDs, not used for dsmcc-receive */ 85 | 86 | set_verbose(1); /* 1, 2, 3 */ 87 | 88 | fprintf(stdout, "info: loading carousel on directory %s\n", directory); 89 | 90 | /* 91 | * the file structure will be: 92 | * directory/services/ 93 | * this is a symlink to the root of the carousel 94 | * the actual carousel files and directories are stored under: 95 | * directory/carousels/// 96 | * where is the PID the carousel was downloaded from 97 | * and is the Carousel ID 98 | */ 99 | 100 | result = load_carousel(directory, &(a_carousel), cachesize); 101 | 102 | clean_assoc(&(a_carousel.assoc)); 103 | 104 | fprintf(stdout, "info: load carousel done\n"); 105 | 106 | return result; 107 | } 108 | 109 | void 110 | usage(char *prog_name) 111 | { 112 | fatal("Usage: %s output_directory cache_size pid component_tag < file.sec", prog_name); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/dsmcc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dsmcc.c 3 | * 4 | * helper functions for handling data types for ISO/IEC 13818-6 DSM-CC specs 5 | */ 6 | 7 | /* 8 | * Copyright (C) 2005, Simon Kilvington 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | 27 | #include "dsmcc.h" 28 | #include "utils.h" 29 | 30 | /* 31 | * return a ptr to the message following the dsmccMessageHeader 32 | */ 33 | 34 | unsigned char * 35 | dsmccMessage(struct dsmccMessageHeader *hdr) 36 | { 37 | unsigned char *byte = (unsigned char *) hdr; 38 | unsigned int offset; 39 | 40 | offset = sizeof(struct dsmccMessageHeader); 41 | offset += hdr->adaptionLength; 42 | 43 | return &byte[offset]; 44 | } 45 | 46 | /* 47 | * return the numberOfModules field in a DownloadInfoIndication 48 | */ 49 | 50 | uint16_t 51 | DII_numberOfModules(struct DownloadInfoIndication *dii) 52 | { 53 | unsigned char *byte = (unsigned char *) dii; 54 | unsigned int offset; 55 | 56 | offset = sizeof(struct DownloadInfoIndication); 57 | offset += ntohs(dii->compatibilityDescriptor.compatibilityDescriptorLength); 58 | 59 | /* uint16_t numberOfModules */ 60 | return (byte[offset] << 8) + byte[offset + 1]; 61 | } 62 | 63 | /* 64 | * return info for module n in a DownloadInfoIndication 65 | * numbering starts at 0 66 | */ 67 | 68 | struct DIIModule * 69 | DII_module(struct DownloadInfoIndication *dii, uint16_t n) 70 | { 71 | unsigned char *byte = (unsigned char *) dii; 72 | unsigned int offset; 73 | struct DIIModule *mod; 74 | 75 | /* assert */ 76 | if(n >= DII_numberOfModules(dii)) 77 | fatal("DII_module: index too large"); 78 | 79 | /* offset to first module */ 80 | offset = sizeof(struct DownloadInfoIndication); 81 | offset += ntohs(dii->compatibilityDescriptor.compatibilityDescriptorLength); 82 | offset += sizeof(uint16_t); /* numberOfModules */ 83 | 84 | /* find the module we want */ 85 | while(n != 0) 86 | { 87 | n --; 88 | mod = (struct DIIModule *) &byte[offset]; 89 | offset += sizeof(struct DIIModule); 90 | offset += mod->moduleInfoLength; 91 | } 92 | 93 | return (struct DIIModule *) &byte[offset]; 94 | } 95 | 96 | /* 97 | * returns the number of bytes of data in the DDB block 98 | */ 99 | 100 | uint32_t 101 | DDB_blockDataLength(struct dsmccMessageHeader *hdr) 102 | { 103 | uint32_t length; 104 | 105 | length = ntohs(hdr->messageLength); 106 | length -= hdr->adaptionLength; 107 | length -= sizeof(struct DownloadDataBlock); 108 | 109 | return length; 110 | } 111 | 112 | /* 113 | * returns a ptr to the data bytes in the DDB block 114 | */ 115 | 116 | unsigned char * 117 | DDB_blockDataByte(struct DownloadDataBlock *ddb) 118 | { 119 | return ((unsigned char *) ddb) + sizeof(struct DownloadDataBlock); 120 | } 121 | 122 | /* 123 | * returns a ptr to the private data bytes in the DSI block 124 | */ 125 | 126 | unsigned char * 127 | DSI_privateDataByte(struct DownloadServerInitiate *dsi) 128 | { 129 | /* assert */ 130 | if(dsi->compatibilityDescriptor.compatibilityDescriptorLength != 0) 131 | fatal("Unexpected DSI format"); 132 | 133 | return ((unsigned char *) dsi) + sizeof(struct DownloadServerInitiate); 134 | } 135 | 136 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/filter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "filter.h" 10 | 11 | 12 | void closePidFiltering (int filter_id) { 13 | 14 | ; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/filter.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | void closePidFiltering (int filter_id); 5 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fs.h 3 | * 4 | * file system interactions 5 | */ 6 | 7 | /* 8 | * Copyright (C) 2005, Simon Kilvington 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #ifndef __FS_H__ 26 | #define __FS_H__ 27 | 28 | /* directories */ 29 | #define SERVICES_DIR "services" 30 | #define CAROUSELS_DIR "carousels" 31 | 32 | char *make_carousel_root(char *, uint16_t, uint32_t); 33 | 34 | void save_file(char*, char *, uint16_t, uint32_t, uint16_t, char *, uint32_t, char *, uint32_t, uint8_t); 35 | 36 | void make_service_root(char *, uint16_t, char *, uint16_t, uint32_t, uint16_t, char *, uint32_t); 37 | 38 | char *make_dir(char *,char *, uint16_t, uint32_t, uint16_t, char *, uint32_t, uint8_t); 39 | void add_dir_entry(char *, char *, char *, uint32_t, char *, uint16_t, uint32_t, uint16_t, char *, uint32_t); 40 | 41 | char *convert_key(char *, uint32_t); 42 | 43 | #endif /* __FS_H__ */ 44 | 45 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * module.h 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2005, Simon Kilvington 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef __MODULE_H__ 24 | #define __MODULE_H__ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "dsmcc.h" 32 | #include "assoc.h" 33 | 34 | /* PIDs we are reading */ 35 | struct pid_fds 36 | { 37 | uint16_t pid; /* DVB programme ID */ 38 | bool dsidii_only; /* true if receive only dsidii */ 39 | int filterid; /* id of the current open filter if any */ 40 | }; 41 | 42 | /* data about each module */ 43 | struct module 44 | { 45 | uint16_t module_id; 46 | uint32_t download_id; 47 | uint8_t version; 48 | uint16_t block_size; 49 | uint16_t nblocks; 50 | uint32_t blocks_left; /* number of blocks left to download */ 51 | bool *got_block; /* which blocks we have downloaded so far */ 52 | uint32_t size; /* size of the file */ 53 | unsigned char *data; /* the actual file data */ 54 | }; 55 | 56 | /* the whole carousel */ 57 | struct carousel 58 | { 59 | unsigned int timeout; /* timeout for the DVB devices */ 60 | pid_t downloader; /* ID of the process downloading the carousel */ 61 | uint16_t network_id; /* Original Network ID */ 62 | uint16_t service_id; /* Service ID we are downloading the carousel from */ 63 | uint32_t carousel_id; /* Carousel ID we are downloading */ 64 | uint16_t boot_pid; /* PID containing DSI */ 65 | uint16_t audio_pid; /* PID of default audio stream for this service_id */ 66 | uint8_t audio_type; /* type ID of default audio stream */ 67 | uint16_t video_pid; /* PID of default video stream for this service_id */ 68 | uint8_t video_type; /* type ID of default video stream */ 69 | uint16_t current_pid; /* PID we downloaded the last table from */ 70 | struct assoc assoc; /* map stream_id's to elementary_pid's */ 71 | int32_t npids; /* PIDs we are reading data from */ 72 | struct pid_fds *pids; /* array, npids in length */ 73 | bool got_dsi; /* true if we have downloaded the DSI */ 74 | bool completed; /* true if all the carousel has been retrived and versions are consistent */ 75 | uint32_t nmodules; /* modules we have/are downloading */ 76 | struct module *modules; /* array, nmodules in length */ 77 | bool stop; /* set to true to stop the carousel loading */ 78 | bool used; /* set to true if in use */ 79 | }; 80 | 81 | /* functions */ 82 | struct module *find_module(struct carousel *, uint16_t, uint8_t, uint32_t); 83 | struct module *add_module(struct carousel *, struct DownloadInfoIndication *, struct DIIModule *); 84 | void delete_module(struct carousel *, uint32_t); 85 | void free_module(struct module *); 86 | void download_block(char* paramDir, struct carousel *, struct module *, uint16_t, unsigned char *, uint32_t); 87 | 88 | int uncompress_module(struct module *); 89 | 90 | #endif /* __MODULE_H__ */ 91 | 92 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * table.c 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2008, Lorenzo Pallara 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "dsmcc.h" 36 | #include "carousel.h" 37 | #include "biop.h" 38 | #include "utils.h" 39 | #include "table.h" 40 | 41 | #define SECTION_HEADER_SIZE 3 42 | 43 | 44 | int 45 | read_dsmcc_tables(struct carousel *car, unsigned char* buffer) 46 | { 47 | int result = 0; 48 | u_char section_head[SECTION_HEADER_SIZE]; 49 | u_short temp = 0; 50 | int section_size = 0; 51 | int found = 0; 52 | 53 | verbose("reading dsmcc tables\n"); 54 | 55 | while (!found) { 56 | if (read(STDIN_FILENO, section_head, SECTION_HEADER_SIZE)) { 57 | 58 | /* Parse datagram section size */ 59 | memcpy(&temp, section_head + 1, 2); 60 | temp = ntohs(temp); 61 | temp &= 0x0FFF; 62 | section_size = temp; 63 | fprintf(stderr, "section size is %d\n", section_size); 64 | 65 | /* Read all the section */ 66 | if (section_size <= (MAX_TABLE_LEN - SECTION_HEADER_SIZE)) { 67 | memcpy(buffer, section_head, SECTION_HEADER_SIZE); 68 | read(STDIN_FILENO, buffer + SECTION_HEADER_SIZE, section_size); 69 | result = section_size; 70 | if (buffer[0] & 0x3F) { 71 | found = 1; 72 | } 73 | } else { 74 | fprintf(stderr, "found section too big, size is %d, skipped, section_size\n", section_size); 75 | } 76 | } else { 77 | found = 1; 78 | result = -1; 79 | } 80 | } 81 | 82 | /* 83 | hexdump(buffer, result); 84 | */ 85 | 86 | verbose("reading dsmcc table done\n"); 87 | 88 | return result; 89 | 90 | } 91 | 92 | 93 | 94 | void 95 | add_dsmcc_pid(struct carousel *car, uint16_t pid) 96 | { 97 | ; 98 | } 99 | 100 | int 101 | read_dsi_dii_tables(struct carousel *car, unsigned char* buffer) 102 | { 103 | int found = 0; 104 | int result = 0; 105 | 106 | while(!found) { 107 | result = read_dsmcc_tables(car, buffer); 108 | if (result > 0) { 109 | if (buffer[0] & 0x3B) { 110 | found = 1; 111 | } 112 | } else { 113 | found = 1; 114 | } 115 | } 116 | 117 | verbose("reading dsi dii table done\n"); 118 | 119 | return result; 120 | 121 | } 122 | 123 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * table.h 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2005, Simon Kilvington 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef __TABLE_H__ 24 | #define __TABLE_H__ 25 | 26 | #include 27 | 28 | #include "module.h" 29 | 30 | #define MAX_TABLE_LEN 4096 31 | 32 | int read_dsmcc_tables(struct carousel *, unsigned char*); 33 | 34 | int read_dsi_dii_tables(struct carousel *, unsigned char*); 35 | 36 | void add_dsmcc_pid(struct carousel *, uint16_t); 37 | 38 | #endif /* __TABLE_H__ */ 39 | 40 | -------------------------------------------------------------------------------- /tools/dsmcc-receive/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils.h 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2005, Simon Kilvington 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef __UTILS_H__ 24 | #define __UTILS_H__ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #ifndef MAX 31 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 32 | #endif 33 | 34 | void increase_verbose(void); 35 | void set_verbose(int verbose); 36 | 37 | char *skip_ws(char *); 38 | 39 | char hex_digit(uint8_t); 40 | 41 | void *safe_malloc(size_t); 42 | void *safe_realloc(void *, size_t); 43 | void safe_free(void *); 44 | 45 | void hexdump(unsigned char *, size_t); 46 | 47 | void error(char *, ...); 48 | void fatal(char *, ...); 49 | 50 | /* in rb-download.c */ 51 | void verbose(char *, ...); 52 | void vverbose(char *, ...); 53 | void vhexdump(unsigned char *, size_t); 54 | 55 | int timeval_subtract (struct timeval *result,struct timeval *x,struct timeval *y); 56 | 57 | #endif /* __UTILS_H__ */ 58 | 59 | 60 | -------------------------------------------------------------------------------- /tools/esaudio2pes/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = esaudio2pes 2 | 3 | esaudio2pes_SOURCES = esaudio2pes.c 4 | -------------------------------------------------------------------------------- /tools/esaudioinfo/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = esaudioinfo 2 | 3 | esaudioinfo_SOURCES = esaudioinfo.c 4 | -------------------------------------------------------------------------------- /tools/esvideo2pes/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = esvideo2pes 2 | 3 | esvideo2pes_SOURCES = esvideo2pes.c 4 | -------------------------------------------------------------------------------- /tools/esvideoinfo/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = esvideoinfo 2 | 3 | esvideoinfo_SOURCES = esvideoinfo.c 4 | -------------------------------------------------------------------------------- /tools/i13942ts/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = i13942ts 2 | 3 | i13942ts_SOURCES = i13942ts.c 4 | -------------------------------------------------------------------------------- /tools/i13942ts/i13942ts.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #define _BSD_SOURCE 1 20 | 21 | #ifdef HAVE_CONFIG_H 22 | # include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #ifdef HAVE_INTTYPES_H 33 | # include 34 | #endif 35 | #ifdef HAVE_STDINT_H 36 | # include 37 | #endif 38 | 39 | #define I1394_HEADER_SIZE 4 40 | #define CIP_HEADER_SIZE 8 41 | #define SP_HEADER_SIZE 4 42 | #define TS_PACKET_SIZE 188 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | int byte_read = 0; 47 | FILE* file_i1394 = 0; 48 | int data_length = 0; 49 | unsigned char fmt = 0; 50 | unsigned short dbs_fn_qpc_sph = 0; 51 | unsigned char CIP_header[CIP_HEADER_SIZE]; 52 | unsigned char SP_header[SP_HEADER_SIZE]; 53 | unsigned char ts_packet[TS_PACKET_SIZE]; 54 | unsigned char i1394_header[I1394_HEADER_SIZE]; 55 | 56 | file_i1394 = 0; 57 | if (argc > 1) { 58 | file_i1394 = fopen(argv[1], "rb"); 59 | } 60 | 61 | if (file_i1394 == 0) { 62 | fprintf(stderr, "Usage: 'i13942ts file.iso', where .iso is a ieee1394-6 dump\n"); 63 | return 2; 64 | } 65 | 66 | /* Process the i1394 file */ 67 | byte_read = fread(i1394_header, 1, I1394_HEADER_SIZE, file_i1394); 68 | while (byte_read) { 69 | byte_read = fread(CIP_header, 1, CIP_HEADER_SIZE, file_i1394); 70 | data_length = (htonl(*(unsigned long*)i1394_header) >> 16); 71 | dbs_fn_qpc_sph = (htonl(*(unsigned long*)CIP_header) >> 10) & 0x3fff; 72 | fmt = (htonl(*(unsigned long*)(CIP_header + 4)) >> 24) & 0x3f; 73 | if (fmt == 0x20 && dbs_fn_qpc_sph == 0x01b1) { 74 | data_length -= CIP_HEADER_SIZE; 75 | for ( ; data_length > TS_PACKET_SIZE; data_length -= TS_PACKET_SIZE + SP_HEADER_SIZE) { 76 | fread(SP_header, 1, SP_HEADER_SIZE, file_i1394); 77 | fread(ts_packet, 1, TS_PACKET_SIZE, file_i1394); 78 | fwrite(ts_packet, 1, TS_PACKET_SIZE, stdout); 79 | } 80 | } 81 | byte_read = fread(i1394_header, 1, I1394_HEADER_SIZE, file_i1394); 82 | } 83 | 84 | return 0; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /tools/mpe2sec/Makefile.am: -------------------------------------------------------------------------------- 1 | if BUILD_MPE2SEC 2 | 3 | bin_PROGRAMS = mpe2sec 4 | 5 | mpe2sec_SOURCES = mpe.c 6 | 7 | mpe2sec_LDADD = ../../libs/sectioncrc/libsectioncrc.la 8 | 9 | endif 10 | -------------------------------------------------------------------------------- /tools/mpe2sec/mpe.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | # include "config.h" 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include "../../libs/sectioncrc/sectioncrc.h" 20 | 21 | /* pre 2.4.6 compatibility */ 22 | #define OTUNSETNOCSUM (('T'<< 8) | 200) 23 | #define OTUNSETDEBUG (('T'<< 8) | 201) 24 | #define OTUNSETIFF (('T'<< 8) | 202) 25 | #define OTUNSETPERSIST (('T'<< 8) | 203) 26 | #define OTUNSETOWNER (('T'<< 8) | 204) 27 | 28 | int 29 | tun_open (char *dev) 30 | { 31 | struct ifreq ifr; 32 | int fd; 33 | 34 | if ((fd = open ("/dev/net/tun", O_RDWR)) < 0) 35 | goto failed; 36 | 37 | memset (&ifr, 0, sizeof (ifr)); 38 | ifr.ifr_flags = IFF_TUN | IFF_NO_PI; 39 | if (*dev) 40 | strncpy (ifr.ifr_name, dev, IFNAMSIZ); 41 | 42 | if (ioctl (fd, TUNSETIFF, (void *) &ifr) < 0) 43 | { 44 | if (errno == EBADFD) 45 | { 46 | /* Try old ioctl */ 47 | if (ioctl (fd, OTUNSETIFF, (void *) &ifr) < 0) 48 | goto failed; 49 | } 50 | else 51 | goto failed; 52 | } 53 | 54 | strcpy (dev, ifr.ifr_name); 55 | return fd; 56 | 57 | failed: 58 | perror ("open"); 59 | close (fd); 60 | return -1; 61 | } 62 | 63 | void 64 | send_mpe (int fd, unsigned char *buf, size_t ip_len) 65 | { 66 | unsigned char* mpe_header = buf; 67 | unsigned char* ip_datagram = &buf[12]; 68 | unsigned long crc; 69 | unsigned long i,len; 70 | unsigned short section_len = ip_len + 9 + 4; 71 | mpe_header[0] = 0x3e; 72 | mpe_header[1] = ((section_len >> 8) & 0x0f) | 0xb0; 73 | mpe_header[2] = section_len & 0xff; 74 | mpe_header[3] = 0; 75 | mpe_header[4] = 0; 76 | mpe_header[5] = 0xc1; 77 | mpe_header[6] = 0; 78 | mpe_header[7] = 0; 79 | mpe_header[8] = 0; 80 | mpe_header[9] = 0; 81 | mpe_header[10] = 0; 82 | mpe_header[11] = 0; 83 | if((ip_datagram[16] & 0xe0) == 0xe0) /* multicast */ 84 | { 85 | mpe_header[3] = ip_datagram[19]; 86 | mpe_header[4] = ip_datagram[18]; 87 | mpe_header[8] = ip_datagram[17] & 0x7f; 88 | mpe_header[9] = 0x5e; 89 | mpe_header[10] = 0; 90 | mpe_header[11] = 1; 91 | } 92 | len = 12+ip_len; 93 | crc = htonl(sectioncrc(buf, len)); 94 | memcpy(&buf[len], &crc, 4); 95 | len += 4; 96 | write(fd, buf, len); 97 | } 98 | 99 | int 100 | main (int argc, char **argv) 101 | { 102 | if(argc<2) 103 | { 104 | fprintf(stderr, "usage %s devname\n", argv[0]); 105 | fprintf(stderr, "Create a tun device and send DVB/MPE DSM-CC sections to stdout.\n"); 106 | fprintf(stderr, "Project home page http://code.google.com/p/dvb-mpe-encode\n"); 107 | fprintf(stderr, "Example:\nmpe dvb0 | sec2ts 430 | DtPlay 1000000\n"); 108 | exit(1); 109 | } 110 | int tun_fd = tun_open (argv[1]); 111 | while (1) 112 | { 113 | unsigned char buf[4100]; 114 | unsigned char* mpe_header = buf; 115 | unsigned char* tun_header = &buf[12]; 116 | int n = read (tun_fd, tun_header, sizeof (buf)); 117 | send_mpe(1, mpe_header, n+tun_header-mpe_header); 118 | } 119 | close (tun_fd); 120 | } 121 | -------------------------------------------------------------------------------- /tools/oc2sec/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_SCRIPTS = file2mod.py mod2sec.py oc-update.sh 2 | -------------------------------------------------------------------------------- /tools/oc2sec/mod2sec.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # Copyright 2000-2001, GMD, Sankt Augustin 4 | # -- German National Research Center for Information Technology 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | 20 | import sys 21 | import getopt 22 | 23 | from dvbobjects.utils import * 24 | from dvbobjects.utils.SpecFile import * 25 | from dvbobjects.DVB.DataCarousel import * 26 | from dvbobjects.DVB.Loops import * 27 | 28 | ###################################################################### 29 | def BuildCarousel(INPUT_DIR, OUTPUT_DIR): 30 | 31 | spec = SuperGroupSpec() 32 | spec.read("%s/DSI.spec" % INPUT_DIR) 33 | 34 | # DVB 35 | assert 0x0000 <= spec.transactionId & 0x0000FFFF <= 0x0001 36 | 37 | dsi = SuperGroup( 38 | PATH=spec.PATH, 39 | transactionId = spec.transactionId, 40 | version = spec.version, 41 | ) 42 | 43 | for group in spec.groups: 44 | 45 | dii = Group( 46 | PATH = group.PATH, 47 | transactionId = group.transactionId, 48 | downloadId = group.downloadId, 49 | blockSize = group.blockSize, 50 | version = group.version, 51 | ) 52 | 53 | # DVB 54 | assert 0x0002 <= group.transactionId & 0x0000FFFF <= 0xFFFF 55 | 56 | for mod in group.modules: 57 | if os.path.exists("%s.size" % mod.INPUT): 58 | # print("Compressing %s") % mod.INPUT 59 | m = Module(INPUT="%s" % mod.INPUT, 60 | moduleVersion= mod.moduleVersion, 61 | moduleId = mod.moduleId, 62 | assocTag = group.assocTag, 63 | descriptors = [compressed_descriptor(name = mod.INPUT)], 64 | ) 65 | else: 66 | m = Module(INPUT="%s" % mod.INPUT, 67 | moduleVersion= mod.moduleVersion, 68 | moduleId = mod.moduleId, 69 | assocTag = group.assocTag, 70 | ) 71 | dii.addModule(m) 72 | 73 | dsi.addGroup(dii) 74 | 75 | dsi.generate(OUTPUT_DIR, spec.srg_ior) 76 | if spec.srg_ior == None: 77 | print dsi 78 | 79 | ###################################################################### 80 | OPTIONS = "h" 81 | LONG_OPTIONS = [ 82 | "help", 83 | ] 84 | 85 | def Usage(return_code = 1): 86 | print ("Usage: %s" 87 | " [option...]" 88 | " " 89 | " ") % ( 90 | sys.argv[0]) 91 | sys.exit(return_code) 92 | 93 | def CheckArgs(): 94 | 95 | try: 96 | opts, args = getopt.getopt( 97 | sys.argv[1:], OPTIONS, LONG_OPTIONS) 98 | except getopt.error: 99 | Usage() 100 | 101 | for opt_name, opt_val in opts: 102 | if opt_name in ['-h', '--help']: 103 | Usage(0) 104 | 105 | if len(args) <> 2: 106 | Usage() 107 | 108 | INPUT_DIR, OUTPUT_DIR = args 109 | 110 | BuildCarousel(INPUT_DIR, OUTPUT_DIR) 111 | 112 | ###################################################################### 113 | if __name__ == '__main__': 114 | CheckArgs() 115 | -------------------------------------------------------------------------------- /tools/oc2sec/oc-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 5 ] 4 | then 5 | /bin/echo "Usage:" 6 | /bin/echo "oc-update.sh object_carousel_directory association_tag module_version dsmcc_pid carousel_id [compress_on] [padding_on] [clean_off]" 7 | /bin/echo " carousel_directory: the directory to marshal in an object carousel" 8 | /bin/echo " association_tag aka common tag, referenced by PMTs and AITs, every carousel has its own" 9 | /bin/echo " modules_version, all the modules will have the same version, you need to change this to notify to the box files are changed, goes from 0 to 15" 10 | /bin/echo " pid, referenced by PMTs using this carousel" 11 | /bin/echo " carousel_id, referenced by PMTs using this carousel, every carousel has its own" 12 | /bin/echo " compress_on, compress the carousel, default off" 13 | /bin/echo " padding_on, every section is padded, usuful with some buggy decoder, waste bandwith, default off" 14 | /bin/echo " clean_off, don't delete temp file, default off" 15 | /bin/echo 16 | /bin/echo "Example:" 17 | /bin/echo "oc-update.sh ocdir1 0xB 5 2001 1 1 0 0" 18 | /bin/echo " carousel_directory: ocdir1" 19 | /bin/echo " association_tag: 0xB (11)" 20 | /bin/echo " modules_version: 5" 21 | /bin/echo " pid: 2001" 22 | /bin/echo " carousel_id: 1" 23 | /bin/echo " compress the carousel" 24 | /bin/echo " don't pad" 25 | /bin/echo " delete temp files" 26 | exit 65 27 | fi 28 | 29 | #Parameters passing 30 | OCDIR=$1 31 | ASSOCIATION_TAG=$2 32 | MODULE_VERSION=$3 33 | PID=$4 34 | CAROUSEL_ID=$5 35 | COMPRESS_ON="0" 36 | PAD_ON="0" 37 | NO_DELETE_TEMP="0" 38 | if [ $# -gt 5 ] 39 | then 40 | COMPRESS_ON=$6 41 | fi 42 | if [ $# -gt 6 ] 43 | then 44 | PAD_ON=$7 45 | fi 46 | if [ $# -gt 7 ] 47 | then 48 | NO_DELETE_TEMP=$8 49 | fi 50 | 51 | #Generate temp directories 52 | TEMP_DIR_MOD=`/bin/mktemp -d` 53 | TEMP_DIR_SEC=`/bin/mktemp -d` 54 | 55 | #Generate the modules from the directory, the modules are stored into a tmp directory TEMP_DIR_MOD 56 | /usr/local/bin/file2mod.py $OCDIR $TEMP_DIR_MOD $CAROUSEL_ID $CAROUSEL_ID $ASSOCIATION_TAG $MODULE_VERSION 57 | 58 | #Compress modules if required 59 | if [ "$COMPRESS_ON" = "1" ] 60 | then 61 | for file in $TEMP_DIR_MOD/*.mod 62 | do 63 | /usr/bin/du --apparent-size --block-size 1 $file > $file.size 64 | /usr/local/bin/zpipe < $file > $file.z 65 | /bin/mv $file.z $file 66 | done 67 | fi 68 | 69 | #Generate sections from modules, the sections are stored into a tmp directory TEMP_DIR_SEC 70 | /usr/local/bin/mod2sec.py $TEMP_DIR_MOD $TEMP_DIR_SEC 71 | 72 | # Check if it is necessary to pad every sections or not, unluckly we have found some decoders having buggy section filtering that needed this 73 | if [ "$PAD_ON" = "1" ] 74 | then 75 | #Every section will be padded to the minimum number of packets needed to contain it, all the packets are enqueued into the output ts file 76 | for file in $TEMP_DIR_SEC/*.sec 77 | do 78 | /usr/local/bin/sec2ts $PID < $file >> $TEMP_DIR_SEC/temp_ts 79 | done 80 | /usr/local/bin/tsfixcc $TEMP_DIR_SEC/temp_ts > $OCDIR.ts 81 | rm $TEMP_DIR_SEC/temp_ts 82 | else 83 | # All the single section files are enqueued in a single file, padding will occur only at the end of the last section 84 | for file in $TEMP_DIR_SEC/*.sec 85 | do 86 | /bin/cat $file >> $TEMP_DIR_SEC/temp_sec 87 | done 88 | /usr/local/bin/sec2ts $PID < $TEMP_DIR_SEC/temp_sec > $OCDIR.ts 89 | fi 90 | 91 | # Delete temp files 92 | if [ "$NO_DELETE_TEMP" = "0" ] 93 | then 94 | /bin/rm -rf $TEMP_DIR_MOD 95 | /bin/rm -rf $TEMP_DIR_SEC 96 | else 97 | /bin/echo "Modules generated in $TEMP_DIR_MOD were not delete" 98 | /bin/echo "Sections generated in $TEMP_DIR_SEC were not delete" 99 | fi 100 | -------------------------------------------------------------------------------- /tools/oddparity/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = oddparity 2 | 3 | oddparity_SOURCES = oddparity.c 4 | -------------------------------------------------------------------------------- /tools/oddparity/oddparity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #define _BSD_SOURCE 1 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | int main(int argc, char *argv[]) { 33 | unsigned char byte = 0; 34 | unsigned char paritybyte = 0; 35 | unsigned char parity = 0; 36 | fprintf(stdout, "{ "); 37 | for (byte = 0; byte < 127; byte++) { 38 | parity = ((byte & 0x01) + 39 | ((byte >> 1) & 0x01) + 40 | ((byte >> 2) & 0x01) + 41 | ((byte >> 3) & 0x01) + 42 | ((byte >> 4) & 0x01) + 43 | ((byte >> 5) & 0x01) + 44 | ((byte >> 6) & 0x01) ); 45 | if ((parity % 2) == 0) { 46 | paritybyte = 0x80 | byte; 47 | } else { 48 | paritybyte = byte; 49 | } 50 | fprintf(stdout, "0x%02x, ", paritybyte); 51 | } 52 | fprintf(stdout, " }\n"); 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /tools/pes2es/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pes2es 2 | 3 | pes2es_SOURCES = pes2es.c 4 | -------------------------------------------------------------------------------- /tools/pes2es/pes2es.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define PES_HEADER_SIZE 4 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int byte_read; 36 | int first_found; 37 | unsigned char stream_id; 38 | FILE* file_pes; 39 | unsigned char pes_header[PES_HEADER_SIZE]; 40 | unsigned char byte; 41 | 42 | /* Open pes file */ 43 | if (argc > 2) { 44 | file_pes = fopen(argv[1], "rb"); 45 | stream_id = atoi(argv[2]); 46 | } else { 47 | fprintf(stderr, "Usage: 'pes2es filename.pes stream_id_header_to_skip'\n"); 48 | fprintf(stderr, "Example for audio: 'pes2es filename.pes 192', 192 is 0xc0 \n"); 49 | fprintf(stderr, "Example for video: 'pes2es filename.pes 224', 224 is 0xe0\n"); 50 | return 2; 51 | } 52 | if (file_pes == 0) { 53 | fprintf(stderr, "Can't find file %s\n", argv[1]); 54 | return 2; 55 | } 56 | 57 | /* Start to process the file */ 58 | first_found = 0; 59 | byte_read = fread(pes_header, 1, 4, file_pes); 60 | while(byte_read) { 61 | 62 | /* Skip headers */ 63 | if ((pes_header[0] == 0x00) && (pes_header[1] == 0x00) && (pes_header[2] == 0x01) && (pes_header[3] == stream_id)) { 64 | first_found = 1; 65 | // fprintf(stderr, "header: %02x %02x %02x %02x, ", pes_header[0], pes_header[1], pes_header[2], pes_header[3]); 66 | fseek(file_pes, 4, SEEK_CUR); /* get header size */ 67 | fread(&byte, 1, 1, file_pes); 68 | // fprintf(stderr, "length: %d\n", byte); 69 | fseek(file_pes, byte, SEEK_CUR); /* skip header */ 70 | byte_read = fread(pes_header, 1, PES_HEADER_SIZE, file_pes); 71 | } else { 72 | if (first_found) { 73 | fwrite(pes_header, 1, 1, stdout); 74 | } 75 | pes_header[0] = pes_header[1]; 76 | pes_header[1] = pes_header[2]; 77 | pes_header[2] = pes_header[3]; 78 | byte_read = fread(pes_header+3, 1, 1, file_pes); 79 | } 80 | } 81 | fwrite(pes_header, 1, 3, stdout); 82 | 83 | return 0; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /tools/pes2txt/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pes2txt 2 | 3 | pes2txt_SOURCES = pes2txt.c 4 | -------------------------------------------------------------------------------- /tools/pes2txt/pes2txt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define PES_HEADER_SIZE 4 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int byte_read; 36 | int first_found; 37 | FILE* file_pes; 38 | unsigned char pes_header[PES_HEADER_SIZE]; 39 | unsigned char byte; 40 | 41 | /* Open pes file */ 42 | if (argc > 1) { 43 | file_pes = fopen(argv[1], "rb"); 44 | } else { 45 | fprintf(stderr, "Usage: 'pes2txt filename.pes > txt_units'\n"); 46 | return 2; 47 | } 48 | if (file_pes == 0) { 49 | fprintf(stderr, "Can't find file %s\n", argv[1]); 50 | return 2; 51 | } 52 | 53 | /* Start to process the file */ 54 | first_found = 0; 55 | byte_read = fread(pes_header, 1, 4, file_pes); 56 | while(byte_read) { 57 | 58 | /* Skip headers */ 59 | if ((pes_header[0] == 0x00) && (pes_header[1] == 0x00) && (pes_header[2] == 0x01) && (pes_header[3] == 0xBD)) { 60 | first_found = 1; 61 | // fprintf(stderr, "header: %02x %02x %02x %02x, ", pes_header[0], pes_header[1], pes_header[2], pes_header[3]); 62 | fseek(file_pes, 4, SEEK_CUR); /* get header size */ 63 | fread(&byte, 1, 1, file_pes); 64 | // fprintf(stderr, "length: %d\n", byte); 65 | fseek(file_pes, byte + 1, SEEK_CUR); /* skip header and ebu byte*/ 66 | byte_read = fread(pes_header, 1, PES_HEADER_SIZE, file_pes); 67 | } else { 68 | if (first_found) { 69 | fwrite(pes_header, 1, 1, stdout); 70 | } 71 | pes_header[0] = pes_header[1]; 72 | pes_header[1] = pes_header[2]; 73 | pes_header[2] = pes_header[3]; 74 | byte_read = fread(pes_header+3, 1, 1, file_pes); 75 | } 76 | } 77 | fwrite(pes_header, 1, 3, stdout); 78 | 79 | return 0; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /tools/pesaudio2ts/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pesaudio2ts 2 | 3 | pesaudio2ts_SOURCES = pesaudio2ts.c 4 | -------------------------------------------------------------------------------- /tools/pesclock/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pesclock 2 | 3 | pesclock_SOURCES = pesclock.c 4 | 5 | pesclock_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/pesdata2ts/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pesdata2ts 2 | 3 | pesdata2ts_SOURCES = pesdata2ts.c 4 | -------------------------------------------------------------------------------- /tools/pesinfo/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pesinfo 2 | 3 | pesinfo_SOURCES = pesinfo.c 4 | -------------------------------------------------------------------------------- /tools/pesvideo2ts/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = pesvideo2ts 2 | 3 | pesvideo2ts_SOURCES = pesvideo2ts.c 4 | -------------------------------------------------------------------------------- /tools/sec2ts/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = sec2ts 2 | 3 | sec2ts_SOURCES = sec2ts.c 4 | -------------------------------------------------------------------------------- /tools/totsectionrestamp/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = totsectionrestamp 2 | 3 | totsectionrestamp_SOURCES = totsectionrestamp.c 4 | -------------------------------------------------------------------------------- /tools/totsectionrestamp/totsectionrestamp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define SECTION_MAX_SIZE 4096 32 | #define SECTION_HEADER_SIZE 3 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | int fd_in; 37 | u_char section[SECTION_MAX_SIZE]; 38 | u_char section_head[SECTION_HEADER_SIZE]; 39 | u_short section_size; 40 | u_short temp; 41 | 42 | time_t tim; 43 | struct tm * now; 44 | unsigned short l; 45 | unsigned short MJD; 46 | unsigned char hour; 47 | unsigned char minute; 48 | unsigned char second; 49 | 50 | if (argc < 2) { 51 | fprintf(stderr, "Usage: 'timesectionrestamp tdtortot.sec > restamped.sec '\n"); 52 | fprintf(stderr, "'replace timestamp of tdt and tot with current time from pc clock' \n"); 53 | return 0; 54 | } 55 | fd_in = open(argv[1], O_RDONLY); 56 | if (fd_in < 0) { 57 | fprintf(stderr, "Can't find file %s\n", argv[1]); 58 | return 0; 59 | } 60 | 61 | while (1) { 62 | temp = read(fd_in, section_head, SECTION_HEADER_SIZE); 63 | if (temp <= 0) { 64 | close(fd_in); 65 | fd_in = open(argv[1], O_RDONLY); 66 | temp = read(fd_in, section_head, SECTION_HEADER_SIZE); 67 | } 68 | 69 | /* Parse datagram section size */ 70 | memcpy(&temp, section_head + 1, 2); 71 | temp = ntohs(temp); 72 | temp &= 0x0FFF; 73 | section_size = temp; 74 | 75 | /* Read all the section */ 76 | if (section_size <= (SECTION_MAX_SIZE - SECTION_HEADER_SIZE)) { 77 | memcpy(section, section_head, SECTION_HEADER_SIZE); 78 | read(fd_in, section + SECTION_HEADER_SIZE, section_size); 79 | section_size += SECTION_HEADER_SIZE; 80 | tim = time(NULL); 81 | now = gmtime(&tim); 82 | if (now != NULL) { 83 | /* convert date into modified julian */ 84 | if ((now->tm_mon + 1 == 1) || (now->tm_mon + 1 == 2)) { 85 | l = 1; 86 | } else { 87 | l = 0; 88 | } 89 | MJD = 14956 + now->tm_mday + (unsigned short)((now->tm_year - l) * 365.25f) + (unsigned short)((now->tm_mon + 1 + 1 + l * 12) * 30.6001f); 90 | MJD = htons(MJD); 91 | memcpy(section + 3, &MJD, 2); 92 | /* convert time */ 93 | hour = (now->tm_hour / 10) << 4 | (now->tm_hour % 10); 94 | minute = (now->tm_min / 10) << 4 | (now->tm_min % 10); 95 | second = (now->tm_sec / 10) << 4 | (now->tm_sec %10); 96 | section[5] = hour; 97 | section[6] = minute; 98 | section[7] = second; 99 | } 100 | write(STDOUT_FILENO, section, section_size); 101 | } else { 102 | fprintf(stderr, "invalid section\n"); 103 | write(STDOUT_FILENO, section_head, SECTION_HEADER_SIZE); 104 | } 105 | } 106 | 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /tools/ts2pes/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = ts2pes 2 | 3 | ts2pes_SOURCES = ts2pes.c 4 | -------------------------------------------------------------------------------- /tools/ts2pes/ts2pes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int byte_read; 36 | int fd_ts; /* File descriptor of ts file */ 37 | int ts_header_size; 38 | unsigned char temp; 39 | unsigned short pid; 40 | unsigned short payload_pid; 41 | unsigned int i; 42 | unsigned char* packet_buffer; 43 | unsigned char* current_packet; 44 | unsigned int buffer_size; 45 | 46 | /* Open ts file */ 47 | buffer_size = 0; 48 | if (argc >= 3) { 49 | fd_ts = open(argv[1], O_RDONLY); 50 | payload_pid = atoi(argv[2]); 51 | if (argc > 3) { 52 | buffer_size = atoi(argv[3]); 53 | } 54 | } else { 55 | fprintf(stderr, "Usage: 'ts2pes filename.ts payload_pid [buffer_size_in_packets]'\n"); 56 | return 2; 57 | } 58 | if (fd_ts < 0) { 59 | fprintf(stderr, "Can't find file %s\n", argv[1]); 60 | return 2; 61 | } 62 | if (payload_pid < 2 || payload_pid > MAX_PID-2) { 63 | fprintf(stderr, "Invalid PID, range is [2..8190]\n"); 64 | } 65 | if (buffer_size <= 0) { 66 | if (argv[3] != 0) { 67 | fprintf(stderr, "Buffer size is not valid\n"); 68 | return 2; 69 | } else { 70 | buffer_size = 1; 71 | } 72 | } 73 | buffer_size *= TS_PACKET_SIZE; 74 | packet_buffer = malloc(buffer_size); 75 | if (packet_buffer == NULL) { 76 | fprintf(stderr, "Out of memory\n"); 77 | return 2; 78 | } 79 | 80 | /* Start to process the file */ 81 | byte_read = 1; 82 | while(byte_read) { 83 | 84 | /* read packets */ 85 | byte_read = read(fd_ts, packet_buffer, buffer_size); 86 | 87 | /* check packets pid */ 88 | for (i = 0; i < buffer_size && byte_read; i+=TS_PACKET_SIZE) { 89 | current_packet = packet_buffer+i; 90 | memcpy(&pid, current_packet + 1, 2); 91 | pid = ntohs(pid); 92 | pid = pid & 0x1fff; 93 | if (pid == payload_pid) { /* got the pid we are interested into */ 94 | ts_header_size = 4; 95 | 96 | /* check adaptation field */ 97 | temp = (current_packet[3] >> 4) & 0x03; 98 | if (temp == 0) { 99 | ts_header_size = TS_PACKET_SIZE; /* jump the packet, is invalid ?*/ 100 | fprintf(stderr, "invalid packet!\n"); 101 | } else if (temp == 1) { 102 | ; /* just payload */ 103 | } else if (temp == 2) { 104 | ts_header_size = TS_PACKET_SIZE; /* only adaptation field */ 105 | /* fprintf(stderr, "adapatation field only?\n"); */ 106 | } else if (temp == 3) { 107 | ts_header_size += current_packet[4] + 1; /* jump the adaptation field */ 108 | } 109 | 110 | write(STDOUT_FILENO, current_packet + ts_header_size, TS_PACKET_SIZE - ts_header_size); 111 | } 112 | } 113 | } 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /tools/ts2sec/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = ts2sec 2 | 3 | ts2sec_SOURCES = ts2sec.c 4 | -------------------------------------------------------------------------------- /tools/tscbrmuxer/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tscbrmuxer 2 | 3 | tscbrmuxer_SOURCES = tscbrmuxer.c 4 | -------------------------------------------------------------------------------- /tools/tsccc/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsccc 2 | 3 | tsccc_SOURCES = tsccc.c 4 | -------------------------------------------------------------------------------- /tools/tsccc/tsccc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, lpallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int open_file; 36 | int byte_read; 37 | int fd_ts; /* File descriptor of ts file */ 38 | unsigned short pid; 39 | unsigned int adaptation_field; 40 | unsigned char packet[TS_PACKET_SIZE]; 41 | unsigned char pid_cc_table[MAX_PID]; /* PID table for the continuity counter of the TS packets */ 42 | unsigned char repeated_cc_table[MAX_PID]; 43 | unsigned long long position = 0; 44 | 45 | /* Open first ts file */ 46 | if (argc >= 2) { 47 | open_file = 1; 48 | fd_ts = open(argv[open_file], O_RDONLY); 49 | if (fd_ts < 0) { 50 | fprintf(stderr, "Can't find file %s\n", argv[open_file]); 51 | return 2; 52 | } 53 | } else { 54 | fprintf(stderr, "Usage: 'tsccc filename.ts '\n"); 55 | fprintf(stderr, "Tsccc check continuity counter errors and warnings\n"); 56 | return 2; 57 | } 58 | 59 | /* Start to process the file */ 60 | memset(pid_cc_table, 0x10, MAX_PID); 61 | memset(repeated_cc_table, 0, MAX_PID); 62 | 63 | while(1) { 64 | 65 | /* read packets */ 66 | byte_read = 0; 67 | byte_read = read(fd_ts, packet, TS_PACKET_SIZE); 68 | if (byte_read < TS_PACKET_SIZE) { 69 | return 0; 70 | } 71 | 72 | /* check cc */ 73 | memcpy(&pid, packet + 1, 2); 74 | pid = ntohs(pid); 75 | pid = pid & 0x1fff; 76 | if (pid < MAX_PID) { 77 | adaptation_field = (packet[3] & 0x30) >> 4; 78 | if (pid_cc_table[pid] == 0x10) { 79 | fprintf(stderr, "new pid entry %d\n", pid); 80 | } else { 81 | if (((pid_cc_table[pid] + 1) % 16) != (packet[3] & 0xF)) { 82 | if (adaptation_field == 0x0 || adaptation_field == 0x2) { /* reserved, no increment */ 83 | ; 84 | } else if ((adaptation_field == 0x1) && ((packet[3] & 0x0f) == pid_cc_table[pid]) && (!repeated_cc_table[pid])) { /* double packet accepted only once */ 85 | repeated_cc_table[pid] = 1; 86 | } else if ((adaptation_field == 0x3) && ((packet[3] & 0x0f) == pid_cc_table[pid]) && (!repeated_cc_table[pid])) { /* double packet accepted only once */ 87 | repeated_cc_table[pid] = 1; 88 | } else { 89 | fprintf(stdout, "cc warning at pid %d packet: %llu, expected %d, found %d\n", pid, position, ((pid_cc_table[pid] + 1) % 0xF), (packet[3] & 0xF)); 90 | } 91 | } 92 | } 93 | pid_cc_table[pid] = packet[3] & 0xF; 94 | } 95 | position++; 96 | } 97 | 98 | } 99 | 100 | -------------------------------------------------------------------------------- /tools/tsdoubleoutput/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsdoubleoutput 2 | 3 | tsdoubleoutput_SOURCES = tsdoubleoutput.c 4 | -------------------------------------------------------------------------------- /tools/tsdoubleoutput/tsdoubleoutput.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #define MULTICAST 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | #define TS_PACKET_SIZE 188 40 | 41 | int main(int argc, char *argv[]) 42 | { 43 | int input_file; 44 | int output_file1; 45 | int output_file2; 46 | int byte_read; 47 | unsigned char packet[TS_PACKET_SIZE]; 48 | 49 | if (argc >= 4) { 50 | input_file = open(argv[1], O_RDONLY); 51 | if (input_file < 0) { 52 | fprintf(stderr, "Can't open file %s\n", argv[1]); 53 | return 0; 54 | } 55 | output_file1 = open(argv[2], O_WRONLY); 56 | if (output_file1 < 0) { 57 | fprintf(stderr, "Can't open file %s\n", argv[2]); 58 | return 0; 59 | } 60 | output_file2 = open(argv[3], O_WRONLY); 61 | if (output_file2 < 0) { 62 | fprintf(stderr, "Can't open file %s\n", argv[3]); 63 | return 0; 64 | } 65 | 66 | } else { 67 | fprintf(stderr, "Usage: 'tsdoubleoutput inputfile.ts outputfile1.ts outputfile2.ts'\n"); 68 | fprintf(stderr, "N.B. files must exist, touch them if needed'\n"); 69 | return 0; 70 | } 71 | 72 | 73 | byte_read = 1; 74 | while(byte_read) { 75 | byte_read = read(input_file, packet, TS_PACKET_SIZE); 76 | write(output_file1, packet, TS_PACKET_SIZE); 77 | write(output_file2, packet, TS_PACKET_SIZE); 78 | } 79 | 80 | close(input_file); 81 | close(output_file1); 82 | close(output_file2); 83 | 84 | return 0; 85 | 86 | } 87 | -------------------------------------------------------------------------------- /tools/tsfilter/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsfilter 2 | 3 | tsfilter_SOURCES = tsfilter.c 4 | -------------------------------------------------------------------------------- /tools/tsfilter/tsfilter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | void Usage(void) { 34 | fprintf(stderr, "Usage: 'tsfilter filename.ts +pid1 +pid2 ... +pidn [buffer_size_in_packets]'\n"); 35 | fprintf(stderr, "+pid keeps 'pid' packets\n"); 36 | } 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | int byte_read; 41 | int fd_ts; /* File descriptor of ts file */ 42 | unsigned short pid; 43 | unsigned int i; 44 | unsigned char* packet_buffer; 45 | unsigned char* current_packet; 46 | unsigned int buffer_size; 47 | unsigned char pid_table[MAX_PID]; /* valid PID table */ 48 | 49 | /* Parse input arguments */ 50 | buffer_size = 0; 51 | memset(pid_table, 0, MAX_PID); 52 | if (argc >= 2) { 53 | fd_ts = open(argv[1], O_RDONLY); 54 | if (fd_ts < 0) { 55 | fprintf(stderr, "Can't find file %s\n", argv[1]); 56 | return 2; 57 | } 58 | } else { 59 | Usage(); 60 | return 2; 61 | } 62 | i = 2; 63 | while (i < argc) { 64 | if (argv[i][0] == '+') { 65 | pid = atoi(&(argv[i][1])); 66 | if ( pid < MAX_PID) { 67 | fprintf(stderr, "keep pid %d\n", pid); 68 | pid_table[pid] = 1; 69 | i++; 70 | } else { 71 | fprintf(stderr, "pid range should be from 0 to %d\n", MAX_PID); 72 | return 2; 73 | } 74 | } else { 75 | buffer_size = atoi(&(argv[i][0])); 76 | i++; 77 | } 78 | } 79 | if (buffer_size == 0) { 80 | buffer_size = 1; 81 | } 82 | 83 | /* Allocate packet buffer */ 84 | buffer_size *= TS_PACKET_SIZE; 85 | packet_buffer = malloc(buffer_size); 86 | if (packet_buffer == NULL) { 87 | fprintf(stderr, "Out of memory\n"); 88 | return 2; 89 | } 90 | 91 | /* Start to process the file */ 92 | byte_read = 1; 93 | while(byte_read) { 94 | 95 | /* read packets */ 96 | byte_read = read(fd_ts, packet_buffer, buffer_size); 97 | 98 | /* filter packets on their pids */ 99 | for (i = 0; i < buffer_size; i+=TS_PACKET_SIZE) { 100 | current_packet = packet_buffer+i; 101 | memcpy(&pid, current_packet + 1, 2); 102 | pid = ntohs(pid); 103 | pid = pid & 0x1fff; 104 | if (pid < MAX_PID) { 105 | if (pid_table[pid] == 1) { 106 | write(STDOUT_FILENO, current_packet, TS_PACKET_SIZE); 107 | } 108 | } 109 | } 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /tools/tsfixcc/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsfixcc 2 | 3 | tsfixcc_SOURCES = tsfixcc.c 4 | -------------------------------------------------------------------------------- /tools/tsfixcc/tsfixcc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Lorenzo Pallara, lpallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int open_file; 36 | int byte_read; 37 | int fd_ts; /* File descriptor of ts file */ 38 | unsigned short pid; 39 | unsigned char packet[TS_PACKET_SIZE]; 40 | unsigned char pid_cc_table[MAX_PID]; /* PID table for the continuity counter of the TS packets */ 41 | 42 | /* Open first ts file */ 43 | if (argc >= 2) { 44 | open_file = 1; 45 | fd_ts = open(argv[open_file], O_RDONLY); 46 | if (fd_ts < 0) { 47 | fprintf(stderr, "Can't find file %s\n", argv[open_file]); 48 | return 2; 49 | } 50 | } else { 51 | fprintf(stderr, "Usage: 'tsfixcc filename.ts > filenamefixed.ts'\n"); 52 | fprintf(stderr, "Tsfixcc increases countinuity counter of every packet following each other without adapatation field parsing'\n"); 53 | fprintf(stderr, "Usefull to link ts of sections in a single ts'\n"); 54 | return 2; 55 | } 56 | 57 | /* Start to process the file */ 58 | memset(pid_cc_table, 0x10, MAX_PID); 59 | while(1) { 60 | 61 | /* read packets */ 62 | byte_read = 0; 63 | byte_read = read(fd_ts, packet, TS_PACKET_SIZE); 64 | if (byte_read < TS_PACKET_SIZE) { 65 | return 0; 66 | } 67 | 68 | /* stamp packet cc */ 69 | memcpy(&pid, packet + 1, 2); 70 | pid = ntohs(pid); 71 | pid = pid & 0x1fff; 72 | if (pid < MAX_PID) { 73 | if (pid_cc_table[pid] == 0x10) { 74 | fprintf(stderr, "new pid entry %d\n", pid); 75 | pid_cc_table[pid] = 0; 76 | } else { 77 | pid_cc_table[pid] = (pid_cc_table[pid] + 1) % 0x10; 78 | } 79 | packet[3] = (pid_cc_table[pid] | (packet[3] & 0xf0)); 80 | } 81 | 82 | /* write packet */ 83 | write(STDOUT_FILENO, packet, TS_PACKET_SIZE); 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /tools/tsinputswitch/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsinputswitch 2 | 3 | tsinputswitch_SOURCES = tsinputswitch.c 4 | 5 | tsinputswitch_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/tsloop/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsloop 2 | 3 | tsloop_SOURCES = tsloop.c 4 | -------------------------------------------------------------------------------- /tools/tsloop/tsloop.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int open_file; 36 | int byte_read; 37 | int fd_ts; /* File descriptor of ts file */ 38 | unsigned short pid; 39 | unsigned char adaptation_field; 40 | unsigned char packet[TS_PACKET_SIZE]; 41 | unsigned char pid_cc_table[MAX_PID]; /* PID table for the continuity counter of the TS packets */ 42 | unsigned char previous_cc_table[MAX_PID]; /* two packets can have the same continuity counter under some conditions... */ 43 | 44 | /* Open first ts file */ 45 | if (argc >= 2) { 46 | open_file = 1; 47 | fd_ts = open(argv[open_file], O_RDONLY); 48 | if (fd_ts < 0) { 49 | fprintf(stderr, "Can't find file %s\n", argv[open_file]); 50 | return 2; 51 | } 52 | } else { 53 | fprintf(stderr, "Usage: 'tsloop filename1.ts filename2.ts ... filenameN.ts'\n"); 54 | return 2; 55 | } 56 | 57 | /* Start to process the file */ 58 | memset(pid_cc_table, 0x10, MAX_PID); 59 | memset(previous_cc_table, 0x10, MAX_PID); 60 | while(1) { 61 | 62 | /* read packets */ 63 | byte_read = 0; 64 | byte_read = read(fd_ts, packet, TS_PACKET_SIZE); 65 | if (byte_read < TS_PACKET_SIZE) { 66 | open_file %= argc - 1; 67 | open_file += 1; 68 | close(fd_ts); 69 | memset(previous_cc_table, 0x10, MAX_PID); 70 | fd_ts = open(argv[open_file], O_RDONLY); 71 | if (fd_ts < 0) { 72 | fprintf(stderr, "Can't find file %s\n", argv[open_file]); 73 | return 2; 74 | } 75 | byte_read = read(fd_ts, packet, TS_PACKET_SIZE); 76 | if (byte_read <= 0) { 77 | return 2; 78 | } 79 | 80 | } 81 | 82 | /* check packets cc */ 83 | memcpy(&pid, packet + 1, 2); 84 | pid = ntohs(pid); 85 | pid = pid & 0x1fff; 86 | if (pid < MAX_PID) { 87 | if (pid_cc_table[pid] == 0x10) { 88 | fprintf(stderr, "new pid entry %d\n", pid); 89 | pid_cc_table[pid] = packet[3] & 0x0f; /* new stream to track cc */ 90 | previous_cc_table[pid] = packet[3] & 0x0f; 91 | } else { 92 | adaptation_field = (packet[3] & 0x30) >> 4; 93 | if (adaptation_field == 0x0 || adaptation_field == 0x2) { /* reserved, no increment */ 94 | packet[3] = (pid_cc_table[pid] | (packet[3] & 0xf0)); 95 | } else if ((adaptation_field == 0x1) && ((packet[3] & 0x0f) == previous_cc_table[pid])) { /* double packet accepted only once */ 96 | packet[3] = (pid_cc_table[pid] | (packet[3] & 0xf0)); 97 | previous_cc_table[pid] = 0x10; 98 | } else if ((adaptation_field == 0x3) && ((packet[3] & 0x0f) == previous_cc_table[pid])) { /* double packet accepted only once */ 99 | packet[3] = (pid_cc_table[pid] | (packet[3] & 0xf0)); 100 | previous_cc_table[pid] = 0x10; 101 | } else { /* increase the cc and restamp */ 102 | previous_cc_table[pid] = packet[3] & 0x0f; 103 | pid_cc_table[pid] = (pid_cc_table[pid] + 1) % 0x10; 104 | packet[3] = (pid_cc_table[pid] | (packet[3] & 0xf0)); 105 | } 106 | } 107 | } 108 | 109 | /* write packets */ 110 | write(STDOUT_FILENO, packet, TS_PACKET_SIZE); 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /tools/tsmodder/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsmodder 2 | 3 | tsmodder_SOURCES = tsmodder.c 4 | -------------------------------------------------------------------------------- /tools/tsmodder/tsmodder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define TS_PACKET_SIZE 188 30 | #define MAX_PIDS 8192 31 | 32 | 33 | void Usage (void) { 34 | fprintf(stderr, "Usage: 'tsmodder input.ts [b:buffer_size] +0 pat.ts +pid pmt.ts +pid nit.ts ... '\n"); 35 | fprintf(stderr, "'+pid file.ts' change the packets with 'pid' with the packets from the file.ts\n"); 36 | fprintf(stderr, "'b:buffer_size' set size of the internal buffer to many packets as buffer_size\n"); 37 | } 38 | 39 | int main(int argc, char *argv[]) 40 | { 41 | unsigned int i; 42 | u_short pid; 43 | int buffer_size; 44 | int fd_ts; /* File descriptor of ts input file */ 45 | unsigned char* packet_buffer; 46 | unsigned char* current_packet; 47 | int pid_table[MAX_PIDS]; 48 | 49 | /* Open ts files */ 50 | for (i = 0; i < MAX_PIDS; i++) 51 | pid_table[i] = -1; 52 | if (argc <= 2) { 53 | Usage(); 54 | return 2; 55 | } 56 | fd_ts = open(argv[1], O_RDONLY); 57 | if (fd_ts < 0) { 58 | fprintf(stderr, "Can't find file %s\n", argv[1]); 59 | return 2; 60 | } 61 | buffer_size = 0; 62 | i = 2; 63 | while (i 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define TS_PACKET_SIZE 188 31 | #define MAX_PID 8192 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | unsigned int i; 36 | u_short temp; 37 | int byte_read; 38 | int fd_ts; /* File descriptor of ts file */ 39 | u_short pid; 40 | unsigned int buffer_size; 41 | u_short pid_map_table[MAX_PID]; /* PID map table for the TS packets */ 42 | unsigned char* packet_buffer; 43 | unsigned char* current_packet; 44 | 45 | /* Open ts file */ 46 | buffer_size = 0; 47 | if (argc >= 5) 48 | fd_ts = open(argv[1], O_RDONLY); 49 | else { 50 | fprintf(stderr, "Usage: 'tspidmapper input.ts [b:buffer_size_in_packets] PID1 to PID2 and PID3 to PID4 and ... '\n"); 51 | return 2; 52 | } 53 | if (fd_ts < 0) { 54 | fprintf(stderr, "Can't find file %s\n", argv[1]); 55 | return 2; 56 | } 57 | for (i = 0; i < MAX_PID; i++) { 58 | pid_map_table[i] = MAX_PID; 59 | } 60 | 61 | if ((argv[2] != 0) && (argv[2][0] == 'b') && (argv[2][1] == ':')) { 62 | buffer_size = atoi(&(argv[2][2])); 63 | if (buffer_size == 0) { 64 | fprintf(stderr, "invalid buffer size\n"); 65 | return 2; 66 | } 67 | i = 3; 68 | } else { 69 | i = 2; 70 | } 71 | for (; i < argc ; i+=4 ) { 72 | temp = atoi(argv[i]); 73 | if (temp < MAX_PID) { 74 | pid_map_table[temp] = atoi(argv[i+2]); 75 | fprintf(stderr, "Change %d to %d\n", temp, pid_map_table[temp]); 76 | } 77 | } 78 | if (buffer_size == 0) 79 | buffer_size = 1; 80 | 81 | /* Start to process the file */ 82 | buffer_size *= TS_PACKET_SIZE; 83 | packet_buffer = malloc(buffer_size); 84 | if (packet_buffer == NULL) { 85 | fprintf(stderr, "out of memory\n"); 86 | return 2; 87 | } 88 | byte_read = 1; 89 | while(byte_read) { 90 | 91 | /* Read next packets */ 92 | byte_read = read(fd_ts, packet_buffer, buffer_size); 93 | 94 | /* change pid */ 95 | for (i = 0; i < buffer_size; i += TS_PACKET_SIZE) { 96 | current_packet = packet_buffer + i; 97 | memcpy(&pid, current_packet + 1, 2); 98 | pid = ntohs(pid); 99 | pid = pid & 0x1fff; 100 | if (pid < MAX_PID) { 101 | if (pid_map_table[pid] != MAX_PID) { 102 | memcpy(&temp, current_packet + 1, 2); 103 | temp = ntohs(temp); 104 | temp = temp & 0xe000; 105 | temp = (pid_map_table[pid] & 0x1fff) | temp; 106 | temp = htons(temp); 107 | memcpy(current_packet + 1, &temp, 2); 108 | } 109 | } 110 | } 111 | 112 | /* Write packet buffer */ 113 | if (byte_read) 114 | write(STDOUT_FILENO, packet_buffer, buffer_size); 115 | } 116 | 117 | return 0; 118 | } 119 | -------------------------------------------------------------------------------- /tools/tsstamp/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsstamp 2 | 3 | tsstamp_SOURCES = tsstamp.c 4 | -------------------------------------------------------------------------------- /tools/tstcpreceive/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tstcpreceive 2 | 3 | tstcpreceive_SOURCES = tstcpreceive.c 4 | 5 | tstcpreceive_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/tstcpreceive/tstcpreceive.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define SERVER_PORT 12345 9 | #define TS_PACKET_SIZE 188 10 | #define BUF_SIZE TS_PACKET_SIZE * 7 11 | 12 | int main(int argc, char *argv[]) { 13 | 14 | int i; 15 | int j; 16 | int port; 17 | int rc; 18 | int listen_sd; 19 | int accept_sd; 20 | char buffer[BUF_SIZE]; 21 | char ts_packet[TS_PACKET_SIZE]; 22 | struct sockaddr_in addr; 23 | 24 | if(argc >= 2) { 25 | port = atoi(argv[1]); 26 | } else { 27 | fprintf(stderr, "Usage: %s port\n", argv[0]); 28 | return 0; 29 | } 30 | 31 | listen_sd = socket(AF_INET, SOCK_STREAM, 0); 32 | if(listen_sd < 0) { 33 | fprintf(stderr, "socket() error\n"); 34 | return 0; 35 | } 36 | 37 | int reuse = 1; 38 | if (setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) { 39 | perror("setsockopt() SO_REUSEADDR: error "); 40 | } 41 | 42 | /* 43 | if (setsockopt(listen_sd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse)) < 0) { 44 | perror("setsockopt() SO_REUSEPORT: error "); 45 | } 46 | */ 47 | 48 | fprintf(stderr, "Binding the socket...\n"); 49 | memset(&addr, 0, sizeof(addr)); 50 | addr.sin_family = AF_INET; 51 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 52 | addr.sin_port = htons(port); 53 | rc = bind(listen_sd, (struct sockaddr *)&addr, sizeof(addr)); 54 | if(rc < 0) { 55 | fprintf(stderr, "bind() error\n"); 56 | close(listen_sd); 57 | return 0; 58 | } 59 | 60 | rc = listen(listen_sd, 1); 61 | if(rc < 0) { 62 | fprintf(stderr, "listen() error\n"); 63 | close(listen_sd); 64 | return 0; 65 | } 66 | 67 | 68 | accept_sd = accept(listen_sd, NULL, NULL); 69 | if(accept_sd < 0) { 70 | fprintf(stderr, "accept() error\n"); 71 | close(listen_sd); 72 | return 0; 73 | } 74 | 75 | rc = 1; 76 | j = 0; 77 | i = 0; 78 | while (rc > 0) { 79 | rc = recv(accept_sd, buffer, BUF_SIZE, 0); 80 | for (i = 0; i < rc; i++) { 81 | ts_packet[j] = buffer[i]; 82 | j++; 83 | if (j == TS_PACKET_SIZE) { 84 | write(STDOUT_FILENO, ts_packet, TS_PACKET_SIZE); 85 | j = 0; 86 | } 87 | } 88 | } 89 | 90 | 91 | close(accept_sd); 92 | close(listen_sd); 93 | return 0; 94 | 95 | } 96 | -------------------------------------------------------------------------------- /tools/tstcpsend/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tstcpsend 2 | 3 | tstcpsend_SOURCES = tstcpsend.c 4 | 5 | tstcpsend_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/tstdt/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tstdt 2 | 3 | tstdt_SOURCES = tstdt.c 4 | -------------------------------------------------------------------------------- /tools/tstdt/tstdt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Lorenzo Pallara, lpallara@cineca.it 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define TS_PACKET_SIZE 188 32 | #define MAX_PIDS 8192 33 | #define TDT_PID 20 34 | #define TDT_TABLE_ID 0x70 35 | #define TOT_TABLE_ID 0x73 36 | 37 | void Usage (void) { 38 | fprintf(stderr, "Usage: 'tstdt input.ts [b:buffer_size] '\n"); 39 | fprintf(stderr, "'replace tdt packet with another tdt packe of the current time' \n"); 40 | fprintf(stderr, "'b:buffer_size' set size of the internal buffer to many packets as buffer_size\n"); 41 | } 42 | 43 | int main(int argc, char *argv[]) 44 | { 45 | unsigned int i; 46 | time_t tim; 47 | struct tm * now; 48 | unsigned short l; 49 | unsigned short MJD; 50 | unsigned char hour; 51 | unsigned char minute; 52 | unsigned char second; 53 | u_short pid; 54 | int buffer_size; 55 | int fd_ts; /* File descriptor of ts input file */ 56 | unsigned char* packet_buffer; 57 | unsigned char* current_packet; 58 | 59 | /* Open ts files */ 60 | if (argc < 2) { 61 | Usage(); 62 | return 2; 63 | } 64 | fd_ts = open(argv[1], O_RDONLY); 65 | if (fd_ts < 0) { 66 | fprintf(stderr, "Can't find file %s\n", argv[1]); 67 | return 2; 68 | } 69 | buffer_size = 0; 70 | if (argc == 3) { 71 | if (argv[2][0] == 'b' && argv[2][1] == ':') { 72 | buffer_size = atoi(&(argv[2][2])); 73 | i++; 74 | } 75 | } 76 | if (buffer_size <= 0) { 77 | buffer_size = 1; 78 | } 79 | buffer_size *= TS_PACKET_SIZE; 80 | packet_buffer = malloc(buffer_size); 81 | if (packet_buffer == NULL) { 82 | fprintf(stderr, "Out of memory!\n"); 83 | return 2; 84 | } 85 | 86 | /* Start to process the input */ 87 | int bytes = 1; 88 | while(bytes != 0) { 89 | 90 | /* Read packets */ 91 | bytes = read(fd_ts, packet_buffer, buffer_size); 92 | 93 | /* Check if it's a tdt packet */ 94 | for (i = 0; i < buffer_size; i += TS_PACKET_SIZE) { 95 | current_packet = packet_buffer + i; 96 | memcpy(&pid, current_packet + 1, 2); 97 | pid = ntohs(pid); 98 | pid = pid & 0x1fff; 99 | if (pid < MAX_PIDS && pid == TDT_PID) { 100 | tim = time(NULL); 101 | now = gmtime(&tim); 102 | if (now != NULL) { 103 | /* convert date into modified julian */ 104 | if ((now->tm_mon + 1 == 1) || (now->tm_mon + 1 == 2)) { 105 | l = 1; 106 | } else { 107 | l = 0; 108 | } 109 | MJD = 14956 + now->tm_mday + (unsigned short)((now->tm_year - l) * 365.25f) + (unsigned short)((now->tm_mon + 1 + 1 + l * 12) * 30.6001f); 110 | MJD = htons(MJD); 111 | memcpy(current_packet + 8, &MJD, 2); 112 | /* convert time */ 113 | hour = (now->tm_hour / 10) << 4 | (now->tm_hour % 10); 114 | minute = (now->tm_min / 10) << 4 | (now->tm_min % 10); 115 | second = (now->tm_sec / 10) << 4 | (now->tm_sec %10); 116 | current_packet[10] = hour; 117 | current_packet[11] = minute; 118 | current_packet[12] = second; 119 | } 120 | } 121 | } 122 | 123 | /* Write packets */ 124 | if (bytes != 0) { 125 | write(STDOUT_FILENO, packet_buffer, buffer_size); 126 | } 127 | 128 | } 129 | 130 | return 0; 131 | } 132 | 133 | -------------------------------------------------------------------------------- /tools/tstimedwrite/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tstimedwrite 2 | 3 | tstimedwrite_SOURCES = tstimedwrite.c 4 | -------------------------------------------------------------------------------- /tools/tstimeout/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tstimeout 2 | 3 | tstimeout_SOURCES = tstimeout.c 4 | -------------------------------------------------------------------------------- /tools/tstimeout/tstimeout.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #define MULTICAST 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | #define TS_PACKET_SIZE 188 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | int input_file; 43 | int result; 44 | int stable; 45 | int backup_file; 46 | int byte_read; 47 | int timeout; 48 | int index; 49 | fd_set set; 50 | struct timeval tv; 51 | 52 | unsigned char ts_packet[TS_PACKET_SIZE]; 53 | if (argc >= 4) { 54 | input_file = open(argv[1], O_RDONLY); 55 | if (input_file < 0) { 56 | fprintf(stderr, "Can't open file %s\n", argv[1]); 57 | return 0; 58 | } 59 | backup_file = open(argv[2], O_RDONLY); 60 | if (backup_file < 0) { 61 | fprintf(stderr, "Can't open file %s\n", argv[2]); 62 | return 0; 63 | } 64 | timeout = atoi(argv[3]); 65 | if (timeout == 0) { 66 | fprintf(stderr, "Timeout has to be bigger than 0\n"); 67 | return 0; 68 | } 69 | } else { 70 | fprintf(stderr, "Usage: 'tstimeout inputfile.ts backupfile.ts timeout_in_ms'\n"); 71 | return 0; 72 | } 73 | 74 | fcntl (input_file, F_SETFL, fcntl (input_file, F_GETFL, 0) | O_NONBLOCK); 75 | index = 0; 76 | tv.tv_sec = timeout/1000; 77 | tv.tv_usec = (timeout%1000) * 1000; 78 | stable = 1; 79 | while (1) { 80 | FD_ZERO(&set); 81 | FD_SET(input_file,&set); 82 | if (stable) { 83 | tv.tv_sec = timeout/1000; 84 | tv.tv_usec = (timeout%1000) * 1000; 85 | } else { 86 | tv.tv_sec = 0LL; 87 | tv.tv_usec = 0LL; 88 | } 89 | result = select(input_file+ 1, &set, NULL, NULL, &tv); 90 | if (result > 0) { 91 | if (FD_ISSET(input_file, &set)) { 92 | byte_read = read(input_file, ts_packet + index, TS_PACKET_SIZE - index); 93 | if (byte_read > 0) { 94 | stable = 1; 95 | index += byte_read; 96 | if (index == TS_PACKET_SIZE) { 97 | write(STDOUT_FILENO, ts_packet, TS_PACKET_SIZE); 98 | index = 0; 99 | } 100 | } 101 | } 102 | } else { 103 | stable = 0; 104 | read(backup_file, ts_packet, TS_PACKET_SIZE); 105 | write(STDOUT_FILENO, ts_packet, TS_PACKET_SIZE); 106 | } 107 | } 108 | 109 | close(input_file); 110 | 111 | return 0; 112 | 113 | } 114 | -------------------------------------------------------------------------------- /tools/tsudpreceive/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsudpreceive 2 | 3 | tsudpreceive_SOURCES = tsudpreceive.c 4 | 5 | tsudpreceive_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/tsudpreceive/tsudpreceive.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, Lorenzo Pallara l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | 20 | #define MULTICAST 21 | 22 | #ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #define UDP_MAXIMUM_SIZE 65535 /* theoretical maximum size */ 39 | 40 | int main(int argc, char* argv[]) { 41 | 42 | int sockfd; 43 | struct sockaddr_in addr; 44 | #ifdef HAVE_IP_MREQN 45 | struct ip_mreqn mgroup; 46 | #else 47 | struct ip_mreq mgroup; 48 | #endif 49 | int reuse; 50 | unsigned int addrlen; 51 | int len; 52 | unsigned char udp_packet[UDP_MAXIMUM_SIZE]; 53 | 54 | /* 55 | unsigned long long int bits = 0; 56 | struct timeval time; 57 | memset(&time, 0, sizeof(time)); 58 | */ 59 | 60 | if (argc != 3) { 61 | fprintf(stderr, "Usage: %s ip_addr port > output.ts\n", argv[0]); 62 | return 0; 63 | } else { 64 | memset((char *) &mgroup, 0, sizeof(mgroup)); 65 | mgroup.imr_multiaddr.s_addr = inet_addr(argv[1]); 66 | #ifdef HAVE_IP_MREQN 67 | mgroup.imr_address.s_addr = INADDR_ANY; 68 | #else 69 | mgroup.imr_interface.s_addr = INADDR_ANY; 70 | #endif 71 | memset((char *) &addr, 0, sizeof(addr)); 72 | addr.sin_family = AF_INET; 73 | addr.sin_port = htons(atoi(argv[2])); 74 | addr.sin_addr.s_addr = inet_addr(argv[1]); 75 | addrlen = sizeof(addr); 76 | } 77 | 78 | sockfd = socket(AF_INET, SOCK_DGRAM, 0); 79 | if (sockfd < 0) { 80 | perror("socket(): error "); 81 | return 0; 82 | } 83 | 84 | reuse = 1; 85 | if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) { 86 | perror("setsockopt() SO_REUSEADDR: error "); 87 | } 88 | 89 | if (bind(sockfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { 90 | perror("bind(): error"); 91 | close(sockfd); 92 | return 0; 93 | } 94 | 95 | if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mgroup, sizeof(mgroup)) < 0) { 96 | perror("setsockopt() IPPROTO_IP: error "); 97 | close(sockfd); 98 | return 0; 99 | } 100 | 101 | while(1) { 102 | len = recvfrom(sockfd, udp_packet, UDP_MAXIMUM_SIZE, 0, (struct sockaddr *) &addr,&addrlen); 103 | /* 104 | gettimeofday(&time, 0); 105 | bits += (len * 8); 106 | fprintf(stderr, "received %llu bits, time is %li%06li usec \n", bits, time.tv_sec, time.tv_usec); 107 | */ 108 | if (len < 0) { 109 | perror("recvfrom(): error "); 110 | } else { 111 | /* fprintf(stderr, "packet len is %d\n", len); */ 112 | write(STDOUT_FILENO, udp_packet, len); 113 | 114 | } 115 | } 116 | 117 | } 118 | 119 | -------------------------------------------------------------------------------- /tools/tsudpsend/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsudpsend 2 | 3 | tsudpsend_SOURCES = tsudpsend.c 4 | 5 | tsudpsend_LDADD = @SOCKET_LIBS@ 6 | -------------------------------------------------------------------------------- /tools/tsvbr2cbr/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = tsvbr2cbr 2 | 3 | tsvbr2cbr_SOURCES = tsvbr2cbr.c 4 | -------------------------------------------------------------------------------- /tools/txt2pes/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = txt2pes 2 | 3 | txt2pes_SOURCES = txt2pes.c 4 | -------------------------------------------------------------------------------- /tools/txt2pes/txt2pes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Lorenzo Pallara, l.pallara@avalpa.com 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2.1 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | #define _BSD_SOURCE 1 20 | 21 | #ifdef HAVE_CONFIG_H 22 | # include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #ifdef HAVE_INTTYPES_H 32 | # include 33 | #endif 34 | 35 | #define EBU_UNIT_SIZE 46 36 | 37 | 38 | void stamp_ts (unsigned long long int ts, unsigned char* buffer) 39 | { 40 | if (buffer) { 41 | buffer[0] = ((ts >> 29) & 0x0F) | 0x01; 42 | buffer[1] = (ts >> 22) & 0xFF; 43 | buffer[2] = ((ts >> 14) & 0xFF ) | 0x01; 44 | buffer[3] = (ts >> 7) & 0xFF; 45 | buffer[4] = ((ts << 1) & 0xFF ) | 0x01; 46 | } 47 | } 48 | 49 | 50 | int main(int argc, char *argv[]) 51 | { 52 | unsigned long long int pts_stamp = 3600; 53 | unsigned char* pes_packet; 54 | int byte_read = 0; 55 | int file_es = 0; 56 | int packet_index = 0; 57 | int txtunitperpes = 0; 58 | int pts_increment = 3600; 59 | 60 | /* Parse args */ 61 | if (argc > 2) { 62 | file_es = open(argv[1], O_RDONLY); 63 | txtunitperpes = atoi(argv[2]); 64 | } 65 | if (argc > 3 ) { 66 | pts_stamp = strtoull(argv[3],0,0); 67 | } 68 | if (argc > 4) { 69 | pts_increment = atoi(argv[4]); 70 | } 71 | 72 | if (file_es == 0) { 73 | fprintf(stderr, "Usage: 'txt2pes txt.es txt_units_per_pes_packet [pts_offset [pts_increment]] > pes'\n"); 74 | fprintf(stderr, "txt_unit_per_pes_packet increase bit rate, minimum is 1, max is 24\n"); 75 | fprintf(stderr, "Default pts_offset and increment is 3600, means 2 fields or 1 frame\n"); 76 | fprintf(stderr, "txt.es is 46 byte units of ebu teletext coding\n"); 77 | return 2; 78 | } 79 | 80 | unsigned short pes_size = ((txtunitperpes + 1) * EBU_UNIT_SIZE); 81 | pes_packet = malloc(pes_size); 82 | 83 | fprintf(stderr, "pes packet size without 6 byte header is %d\n", pes_size - 6); 84 | 85 | /* Set some init. values */ 86 | memset(pes_packet, 0xFF, pes_size); 87 | pes_packet[0] = 0x00; 88 | pes_packet[1] = 0x00; 89 | pes_packet[2] = 0x01; /* prefix */ 90 | pes_packet[3] = 0xBD; /* data txt */ 91 | unsigned short temp = htons(pes_size - 6); 92 | memcpy(pes_packet + 4, &temp, sizeof(unsigned short)); 93 | pes_packet[6] = 0x8F; 94 | pes_packet[7] = 0x80; /* flags */ 95 | pes_packet[8] = 0x24; /* header size */ 96 | /* 31 0xFF stuffing is here */ 97 | pes_packet[45] = 0x10; /* ebu teletext */ 98 | packet_index = EBU_UNIT_SIZE; 99 | 100 | /* Process the es txt file */ 101 | byte_read = 1; 102 | while (byte_read) { 103 | /* 104 | byte_read = read(file_es, pes_packet + packet_index, 1); 105 | if (pes_packet[packet_index] == 0x10) { 106 | byte_read = read(file_es, pes_packet + packet_index, EBU_UNIT_SIZE); 107 | } else { 108 | byte_read = read(file_es, pes_packet + packet_index + 1, EBU_UNIT_SIZE - 1); 109 | } 110 | */ 111 | byte_read = read(file_es, pes_packet + packet_index, EBU_UNIT_SIZE); 112 | if (byte_read != 0) { 113 | packet_index += EBU_UNIT_SIZE; 114 | if (packet_index == pes_size) { 115 | stamp_ts(pts_stamp, pes_packet + 9); 116 | write(STDOUT_FILENO, pes_packet, pes_size); 117 | pts_stamp += pts_increment; 118 | packet_index = EBU_UNIT_SIZE; 119 | } 120 | } else { 121 | close(file_es); 122 | file_es = open(argv[1], O_RDONLY); 123 | byte_read = 1; 124 | } 125 | } 126 | 127 | if(pes_packet) { 128 | free(pes_packet); 129 | } 130 | 131 | return 0; 132 | } 133 | 134 | -------------------------------------------------------------------------------- /tools/vbv/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = plot.p 2 | 3 | bin_PROGRAMS = vbv 4 | 5 | vbv_SOURCES = vbv.c 6 | -------------------------------------------------------------------------------- /tools/vbv/plot.p: -------------------------------------------------------------------------------- 1 | plot "vbvData.dat" using 1:2 title 'vbv buffer (kbits)' with lines 2 | pause -1 3 | 4 | -------------------------------------------------------------------------------- /tools/zpipe/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = zpipe 2 | 3 | zpipe_SOURCES = zpipe.c 4 | 5 | zpipe_LDADD = @ZLIB_LIBS@ 6 | --------------------------------------------------------------------------------