mediacontent.java

来自「基于MPEG 7 标准,符合未来语义网架构,很值得参考」· Java 代码 · 共 573 行 · 第 1/2 页

JAVA
573
字号
                  return new MediaFrame((short[])data,(int)d.getWidth(),(int)d.getHeight());
		}
		if (rgbf.getDataType() == Format.intArray) {
                  return new MediaFrame((int[])data,(int)d.getWidth(),(int)d.getHeight());
		}
		else throw new UnsupportedOperationException("unknown frame data format");
	}
*/

    /**
     * Gets the next keyframe, according to the setting of keyframeInterval.
     *
     * @return MediaFrame object, representing the desired frame.
     */

    public MediaFrame getNext() {
        return null;
    }
/*          if (mediaType == VIDEO && fpc != null){
			int fnum = fpc.skip(keyframeInterval);
			if (DEBUG) System.err.println("skipped " + fnum + " frames");
			return getFrameData();
          }
          if (mediaType == IMAGE){
            return getImageData();
          }
          return null;

	}
*/

    /**
     * Gets the frame closest to the given time.
     * @param time Time to seek to.
     * @return Media Frame objects, representing the desired frame.
     */
/*
	public MediaFrame getViewAtTime(Time time){
		if (mediaType == VIDEO && fpc != null){
			int fnum = fpc.mapTimeToFrame(time);
			fnum = fpc.seek(fnum);
			if (DEBUG) System.err.println("seeked to frame " + fnum);
			return getFrameData();
		}
		if (mediaType == IMAGE){
			return getImageData();
		}

		return null;
	}
*/

    /**
     * Returns the interval that is used by getNext().
     *
     * @return The current keyframeInterval.
     */
    public int getKeyframeInterval() {
        return keyframeInterval;
    }

    /**
     * Sets the interval (in frames) that is used by getNext().
     *
     * @param frames Number of frames to skip by getNext().
     */
    public void setKeyframeInterval(int frames) {
        keyframeInterval = frames;
    }

    /**
     * Returns the media type of the loaded media.
     *
     * @return IMAGE, VIDEO or UNKNOWN.
     */
    public int getMediaType() {
        return mediaType;
    }

    /**
     * Returns the size (in pixels) of the media.
     *
     * @return Size in pixels.
     */
    public Dimension2D getSize() {
//		if (mediaType == VIDEO && videoFormat != null)
//			return videoFormat.getSize();
        if (mediaType == IMAGE) {
            return new Dimension(image.getWidth(), image.getHeight());
        }

        return null;
    }

    /**
     * Returns the number of frames in the media.
     *
     * @return The number of frames of the video or 1 if mediaType == IMAGE.
     */
    public int getLengthInFrames() {
        if (mediaType == IMAGE) return 1;

//		if (mediaType == VIDEO && videoFormat != null){
//			Time duration = p.getDuration();
//			if (duration == Duration.DURATION_UNKNOWN) return UNKNOWN;
//			return (int) (duration.getSeconds() * videoFormat.getFrameRate());
//		}

        return UNKNOWN;

    }

    /**
     * Returns the number of frames per second in the media.
     *
     * @return FPS of the video or 0 if mediaType == IMAGE.
     */
    public double getFramesPerSecond() {
//		if (mediaType == VIDEO && videoFormat != null)
//			return videoFormat.getFrameRate();
//		else
        return 0;

    }

    /**
     * Returns the colorModel currently set.
     *
     * @return RGB, YUV or UNKNOWN.
     */
    public ColorModel getColorModel() {
        return colorModel;
    }

    /**
     * Sets the color model for retrieved pixels. Pixels returned are internally
     * converted to the desired color model before returning them to the caller.
     *
     * @param model RGB or YUV
     * @throws IllegalArgumentException If model is not RGB or YUV.
     */
    public void setColorModel(ColorModel model) throws IllegalArgumentException {
        colorModel = model;
    }

    /**
     * Called by the video-controller upon state changes.
     */
/*
	public void controllerUpdate(ControllerEvent evt) {

		if (evt instanceof ConfigureCompleteEvent ||
			evt instanceof RealizeCompleteEvent ||
			evt instanceof PrefetchCompleteEvent) {
			synchronized (stateSync) {
			stateTransitionOK = true;
			stateSync.notifyAll();
			}
		} else if (evt instanceof ResourceUnavailableEvent) {
			synchronized (stateSync) {
			stateTransitionOK = false;
			stateSync.notifyAll();
			}
		} else if (evt instanceof EndOfMediaEvent) {
			p.setMediaTime(new Time(0));
		} else if (evt instanceof SizeChangeEvent) {
		}
	}
*/
}

/**
 * A pass-through codec to access individual frames of the video.
 *
 * @author flo ledermann ledermann@ims.tuwien.ac.at
 */
/*
	public class FrameAccessCodec implements Codec {

	/ **
	 * Callback to access individual video frames.
	 * /
	void accessFrame(Buffer frame) {
		frameData = frame;

		if (DEBUG) {
			int fnum = (int)frame.getSequenceNumber();
			long t = (long)(frame.getTimeStamp()/10000000f);

			System.err.println("frame #: " + frame.getSequenceNumber() +
			", time: " + ((float)t)/100f +
			", len: " + frame.getLength());
		}
	}


	protected Format supportedIns[] = new Format [] { new RGBFormat() };
	protected Format supportedOuts[] = new Format [] { new RGBFormat() };


	Format input = null, output = null;

	public String getName() {
		return "Frame Access Codec";
	}

	public void open() {
	}

	public void close() {
	}

	public void reset() {
	}

	/ **
	 * Returns the supported input formats, in our case RGB and YUV.
	 * /
	public Format [] getSupportedInputFormats() {
		return supportedIns;
	}

	/ **
	 * Returns the supported input formats, in our case RGB and YUV.
	 * /
	public Format [] getSupportedOutputFormats(Format in) {
		if (in == null)
		return supportedOuts;
		else {
			// If an input format is given, we use that input format
			// as the output since we are not modifying the bit stream
			// at all.
			Format outs[] = new Format[1];
			outs[0] = in;
			return outs;
		}
	}

	public Format setInputFormat(Format format) {
		input = format;
		if (format instanceof RGBFormat) {
			if (DEBUG) System.err.println("Codec Format: RGB");
		}
		else {
			if (DEBUG) System.err.println("Format: UNKNOWN");
		}
		return input;
	}

	public Format setOutputFormat(Format format) {
		output = format;
		return output;
	}

	/ **
	 * Passes the data through to the output unmodified, storing the data
	 * in our parent class.
	 * /
	public int process(Buffer in, Buffer out) {

		// This is the "Callback" to access individual frames.
		accessFrame(in);

		// Swap the data between the input & output.
		out.copy(in);

		return BUFFER_PROCESSED_OK;
	}

	/ **
	 * No controls for this codec.
	 * /
	public Object[] getControls() {
		return new Object[0];
	}

	/ **
	 * No controls for this codec.
	 * /
	public Object getControl(String type) {
		return null;
	}
	}

} */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?