• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Section E.4. Section Filtering APIs

E.4. Section Filtering APIs

This section presents a simple example of how the section information can be extracted from the MPEG-2 Transport Stream. Here a SectionFilterListener is registered with a SimpleSectionFilter, which filters out sections of a given program identifier (PID) defined in MPEG-2 Systems.

import org.iso.mpeg.mpegj.*;
import java.lang.Boolean;

public class SI_SF_Example implements MPEGlet {
    MpegjTerminal mpegjTerminal;
    SimpleSectionFilter ssFilter;
    SectionFilterListener sfListener;
    int milliSecs;

    // Class public methods
    public SI_SF_Example() {

       // initialize the mpegjterminal
       mpegjTerminal = new MpegjTerminal(this);
       // other initializations go here

       ssFilter = new SimpleSectionFilter();
       sfListener = new SectionFilterListener();

       // Specify an object to be notified of events relating to
       //this SectionFilter object.
       ssFilter.addSectionFilterListener( sfListener);

       //Set the time-out for this section filter
       ssFilter.setTimeOut( milliSecs);

       // create mask and value parameters
       byte[] posValue = new byte[12];
       byte[] posMask  = new byte[12];
       for ( int i=0; i<12; i++ )   {
           posValue[i] = 0;
           posMask[i]  = 0;
       posMask[0] =  (byte)0xFF; // only check first byte
       posValue[0] = (byte)0;    // table_id PAT

       //sets the SectionFilter object as filtering only for
       //sections matching a specific PID and
       //table_id, and where contents of the section match the
       //specified filter pattern.
       ssFilter.startFilter (
         0          // index, the number of this section filter
         , 100      // id, uniquely identifying this filter
                    // action
         , ssFilter // the listener to receive the events
                    // indicating a new section has arrived
         , 0        // PID, in the case of the PAT 0
         , posMask  // mask, which bits to check
         , posValue // value, the value checked bits
                    // should have
         , null     // neg masking not done, always call this
                    // function in ssFilter, other startfilter
                    // methods are incorrect.
         , null

       Section m_section = ssFilter.getSection()
       try {
          byte[] m_data = m_section.getData();
       } catch (NoDataAvailableException ndae) { }

       // sections matching this SectionFilter object will stop.
  public void init() {}
  public void stop(){}
  public void destroy(){}




Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint