001: /*
002: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: */
032:
033: package com.db.layers.underlay;
034:
035: import java.io.IOException;
036: import javax.media.*;
037: import javax.media.control.FormatControl;
038: import javax.media.protocol.*;
039:
040: public class CDSWrapper extends PushBufferDataSource implements
041: CaptureDevice {
042:
043: private PushBufferDataSource inputDS;
044: private boolean firstConnect;
045: private boolean firstDisconnect;
046:
047: public CDSWrapper(PushBufferDataSource pushbufferdatasource) {
048:
049: inputDS = null;
050: firstConnect = true;
051: firstDisconnect = true;
052: inputDS = pushbufferdatasource;
053:
054: }
055:
056: public void close() {
057:
058: if (!firstConnect)
059: inputDS.disconnect();
060:
061: }
062:
063: public void connect() throws IOException {
064:
065: if (firstConnect) {
066: inputDS.connect();
067: firstConnect = false;
068: }
069:
070: }
071:
072: public void disconnect() {
073:
074: if (firstDisconnect)
075: firstDisconnect = false;
076: else
077: close();
078:
079: }
080:
081: public CaptureDeviceInfo getCaptureDeviceInfo() {
082:
083: return ((CaptureDevice) inputDS).getCaptureDeviceInfo();
084:
085: }
086:
087: public String getContentType() {
088:
089: return inputDS.getContentType();
090:
091: }
092:
093: public Object getControl(String s) {
094:
095: return inputDS.getControl(s);
096:
097: }
098:
099: public Object[] getControls() {
100:
101: return inputDS.getControls();
102:
103: }
104:
105: public Time getDuration() {
106:
107: return inputDS.getDuration();
108:
109: }
110:
111: public FormatControl[] getFormatControls() {
112:
113: return ((CaptureDevice) inputDS).getFormatControls();
114:
115: }
116:
117: public MediaLocator getLocator() {
118:
119: return inputDS.getLocator();
120:
121: }
122:
123: public PushBufferStream[] getStreams() {
124:
125: return inputDS.getStreams();
126:
127: }
128:
129: public void start() throws IOException {
130:
131: inputDS.start();
132:
133: }
134:
135: public void stop() throws IOException {
136:
137: inputDS.stop();
138:
139: }
140:
141: }
|