FileDocCategorySizeDatePackage
Parser.javaAPI DocFobs4JMF API 0.4.18691Fri Jan 12 11:15:46 GMT 2007com.omnividea.media.parser.video

Parser

public class Parser extends Object implements Demultiplexer
FOBS Java CrossPlatform JMF PlugIn Copyright (c) 2004 Omnividea Multimedia S.L Coded by Jose San Pedro Wandelmer This file is part of FOBS. FOBS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. FOBS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with FOBS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Fields Summary
private int
peer
private Object
peerSync
protected DataSource
dataSource
private ContentDescriptor[]
inputContent
private Track[]
tracks
private Time
duration
private int
videoWidth
private int
videoHeight
private double
videoBitRate
private float
videoFrameRate
private boolean
isAudioPresent
private boolean
isVideoPresent
private int
trackNumber
private double
audioBitRate
private double
audioSampleRate
private int
audioChannelNumber
public static double
lastAudioTime
public static double
lastVideoTime
private boolean
positionable
private boolean
randomAccess
Constructors Summary
public Parser()

    super();
  
Methods Summary
private native booleanavClose(int peer, boolean freePeer)

private native doubleavGetAudioBitRate(int peer)

private native intavGetAudioChannelNumber(int peer)

private native doubleavGetAudioSampleRate(int peer)

private native intavGetAudioSampleSize(int peer)

private native doubleavGetAudioSampleTimestamp(int peer)

private native doubleavGetBitRate(int peer)

private native doubleavGetDurationSec(int peer)

private native doubleavGetFirstAudioTime(int peer)

private native doubleavGetFirstVideoTime(int peer)

private native floatavGetFrameRate(int peer)

private native intavGetHeight(int peer)

private native doubleavGetNextFrameTime(int peer)

private native intavGetWidth(int peer)

private native voidavInit(java.lang.String filename)

private native booleanavIsAudioPresent(int peer)

public static native booleanavIsBigEndian()

private native booleanavIsSeekable(int peer)

private native booleanavIsVideoPresent(int peer)

private native booleanavOpen(int peer)

private native booleanavProcess(int peer, java.lang.Object outData, long outDataBytes, long length, boolean useNativeBuffers, int frameFormat)

private native booleanavProcessAudio(int peer, java.lang.Object outData, long outDataBytes, long length)

private native doubleavSetPosition(int peer, double position)

public voidclose()

    System.out.println("Closing "+Thread.currentThread());
      synchronized(peerSync) {avClose(peer, true);}
    
public intgetAudioSampleNumber()

    return avGetAudioSampleSize(peer);
  
public doublegetAudioSampleTimestamp()

    return avGetAudioSampleTimestamp(peer);
  
public java.lang.ObjectgetControl(java.lang.String s)

    return null;
  
public java.lang.Object[]getControls()

    return null;
  
public javax.media.TimegetDuration()

    return duration;
  
public javax.media.TimegetMediaTime()

    //System.out.println("PARSER getMediaTime");
    return new Time(avGetNextFrameTime(peer));
  
public java.lang.StringgetName()

    return "FOBS PARSER";
  
public synchronized booleangetNextAudioFrame(java.lang.Object outData, long outDataBytes, long length)

    return avProcessAudio(peer, outData, outDataBytes, length);
  
public synchronized booleangetNextFrame(java.lang.Object outData, long outDataBytes, long length)

    return avProcess(peer, outData, outDataBytes, length, FobsConfiguration.useNativeBuffers, FobsConfiguration.videoFrameFormat);
  
public javax.media.protocol.ContentDescriptor[]getSupportedInputContentDescriptors()

    return inputContent;
  
public doublegetTimestamp()

    return avGetNextFrameTime(peer);
  
public javax.media.Track[]getTracks()

    return tracks;
  
public static booleanisBigEndian()


   
  try {
    //System.loadLibrary("fobs4jmf");
    NativeLibraryFinder.loadLibrary(Parser.class, "fobs4jmf");
    System.out.println("Fobs4JMF - Native shared library found");
  }
  catch (UnsatisfiedLinkError e) {
    System.out.println("Fobs4JMF - Native shared library NOT found");
    e.printStackTrace();
    throw new ExceptionInInitializerError(e.getMessage());
  }

    return avIsBigEndian();
  
public booleanisPositionable()

    return positionable;
  
public booleanisRandomAccess()

    return randomAccess;
  
public voidopen()

    System.out.println("Opening "+Thread.currentThread());
    synchronized(peerSync) {avOpen(peer);}
  
public voidreset()

    System.out.println("Resetting "+Thread.currentThread());
      synchronized(peerSync) {avClose(peer, false);}
      open();
    
public javax.media.TimesetPosition(javax.media.Time where, int rounding)

    System.out.println("Setting position "+Thread.currentThread());
    double newTime = 0.0;
    synchronized(peerSync) {newTime = avSetPosition(peer, where.getSeconds());}
    return new Time(newTime);
  
public voidsetSource(javax.media.protocol.DataSource source)

    // is it our DataSource?
    //if (! (source instanceof com.omnividea.media.protocol.file.DataSource))
	//System.out.println("Coming a "  + source.getContentType() + " file.");
	if(!source.getContentType().equals("video.ffmpeg"))
    {
      IncompatibleSourceException exp = new IncompatibleSourceException("Invalid DataSource");
      exp.printStackTrace();
      throw exp;
    }
    else {
      dataSource = (com.omnividea.media.protocol.DataSource) source;
      //System.out.println("\tPARSER URL: "+dataSource.getUrlName());
      if (dataSource.getUrlName() == null) {
        throw new IncompatibleSourceException("Invalid Datasource");
      }
    } // else is our DS

    //Call ffmpeg for data

    avInit(dataSource.getUrlName());
    synchronized(peerSync) {

      if(avOpen(peer) == false)
		throw new IncompatibleSourceException("Fobs cannot read such url");


	
    duration = new Time(avGetDurationSec(peer));
    trackNumber = 0;
    isVideoPresent = avIsVideoPresent(peer);
    if(isVideoPresent)
    {
        trackNumber++;
        videoWidth = avGetWidth(peer);
        videoHeight = avGetHeight(peer);
        videoBitRate = avGetBitRate(peer);
        videoFrameRate = avGetFrameRate(peer);
    }
    isAudioPresent = avIsAudioPresent(peer);
    if(isAudioPresent)
    {
        trackNumber++;
      audioBitRate = avGetAudioBitRate(peer);
      audioSampleRate = avGetAudioSampleRate(peer);
      audioChannelNumber = avGetAudioChannelNumber(peer);
    }
	

    
	positionable = true;

    randomAccess = avIsSeekable(peer);
    //isAudioPresent = false;
    
    tracks = new javax.media.Track[trackNumber];
    int trackIndex = 0;
    if(isVideoPresent)
    {
        Time firstVideoTime = new Time(avGetFirstVideoTime(peer));
        tracks[trackIndex++] = new VideoTrack(videoWidth, videoHeight, videoFrameRate, duration, firstVideoTime, this);
    }
    if(isAudioPresent)
    {
      Time firstAudioTime = new Time(avGetFirstAudioTime(peer));
      tracks[trackIndex++] = new AudioTrack(audioSampleRate, audioChannelNumber,
                                 videoFrameRate, duration, firstAudioTime, this);
    }
    
    }//synchronized

  
public voidstart()

  
public voidstop()