KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inzyme > jmds > DSCapturePin


1 package com.inzyme.jmds;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import javax.media.Format;
7
8 import com.sun.media.vfw.BitMapInfo;
9
10 /**
11  * Represents a single pin on a DirectShow capture device.
12  *
13  * @author Mike Schrag
14  */

15 public class DSCapturePin {
16     private DSCaptureDeviceInfo myCaptureDevice;
17     private String JavaDoc myPinID;
18     private String JavaDoc myName;
19     private Format[] myFormats;
20     
21     private List JavaDoc myFormatsList;
22     
23     /**
24      * Constructs a DSCapturePin.
25      *
26      * @param _captureDevice the DSCaptureDevice that contains this pin
27      * @param _pinID the ID of this pin
28      * @param _name the displayable name of this pin
29      */

30     public DSCapturePin(DSCaptureDeviceInfo _captureDevice, String JavaDoc _pinID, String JavaDoc _name) {
31         myCaptureDevice = _captureDevice;
32         myPinID = _pinID;
33         myName = _name;
34     }
35     
36     /**
37      * Returns this pin's parent capture device.
38      *
39      * @return this pin's parent capture device
40      */

41     public DSCaptureDeviceInfo getCaptureDevice() {
42         return myCaptureDevice;
43     }
44     
45     /**
46      * Returns the ID of this pin.
47      *
48      * @return the ID of this pin
49      */

50     public String JavaDoc getPinID() {
51         return myPinID;
52     }
53     
54     /**
55      * Returns the name of this pin.
56      *
57      * @return the name of this pin
58      */

59     public String JavaDoc getName() {
60         return myName;
61     }
62     
63     /**
64      * Returns an array of Formats that are supported by this pin.
65      *
66      * @return an array of Formats that are supported by this pin
67      */

68     public Format[] getFormats() {
69         if (myFormats == null) {
70             synchronized (this) {
71                 myFormatsList = new ArrayList JavaDoc();
72                 fillInFormats();
73                 myFormats = (Format[])myFormatsList.toArray(new Format[myFormatsList.size()]);
74             }
75         }
76         return myFormats;
77     }
78     
79     private void formatFound(BitMapInfo _bitMapInfo, float _frameRate) {
80         Format format = _bitMapInfo.createVideoFormat(Format.byteArray, _frameRate);
81         myFormatsList.add(format);
82     }
83     
84     private native void fillInFormats();
85     
86     public String JavaDoc toString() {
87         return "[DSCapturePin: captureDevice = " + myCaptureDevice + "; pinID = " + myPinID + "; name = " + myName + "]";
88     }
89 }
90
Popular Tags