001 package com.github.sarxos.webcam;
002
003 import java.awt.Dimension;
004 import java.awt.image.BufferedImage;
005 import java.nio.ByteBuffer;
006
007
008 /**
009 * Webcam device abstraction.
010 *
011 * @author Bartosz Firyn (SarXos)
012 */
013 public interface WebcamDevice {
014
015 /**
016 * This interface should be implemented by all webcam devices supporting
017 * possibility to access raw bytes or direct bytes buffer from native webcam
018 * device.
019 *
020 * @author Bartosz Firyn (SarXos)
021 */
022 public static interface BufferAccess {
023
024 /**
025 * Get image in form of raw bytes. Do <b>not</b> use this buffer to set
026 * bytes value, it should be used only for read purpose!
027 *
028 * @return Bytes buffer
029 */
030 ByteBuffer getImageBytes();
031
032 }
033
034 /**
035 * Get device name.
036 *
037 * @return Device name
038 */
039 String getName();
040
041 /**
042 * Get the list of all possible image resolutions.
043 *
044 * @return Possible resolutions
045 */
046 Dimension[] getResolutions();
047
048 /**
049 * Get currently set image size.
050 *
051 * @return The size which is currently set
052 */
053 Dimension getResolution();
054
055 /**
056 * Set new expected image size.
057 *
058 * @param size the size to be set
059 */
060 void setResolution(Dimension size);
061
062 /**
063 * Fetch image from underlying camera.
064 *
065 * @return Image
066 */
067 BufferedImage getImage();
068
069 /**
070 * Open device, it can be closed any time.
071 */
072 void open();
073
074 /**
075 * Close device, however it can be open again.
076 */
077 void close();
078
079 /**
080 * Dispose device. After device is disposed it cannot be open again.
081 */
082 void dispose();
083
084 /**
085 * Is webcam device open?
086 *
087 * @return True if webcam device is open, false otherwise
088 */
089 boolean isOpen();
090
091 }