2 * Copyright (c) 1996-2001 Sun Microsystems, Inc. All Rights Reserved.
4 * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
5 * modify and redistribute this software in source and binary code form,
6 * provided that i) this copyright notice and license appear on all copies of
7 * the software; and ii) Licensee does not utilize the software in a manner
8 * which is disparaging to Sun.
10 * This software is provided "AS IS," without a warranty of any kind. ALL
11 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
12 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
13 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
14 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
15 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
16 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
17 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
18 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
19 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
20 * POSSIBILITY OF SUCH DAMAGES.
22 * This software is not designed or intended for use in on-line control of
23 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
24 * the design, construction, operation or maintenance of any nuclear
25 * facility. Licensee represents and warrants that it will not use or
26 * redistribute the Software for such purposes.
28 package jp.nyatla.nyartoolkit.jmf.utils;
31 import javax.media.protocol.*;
32 import javax.media.control.*;
34 import java.io.IOException;
36 public class MonitorCDS extends PushBufferDataSource
39 private PushBufferDataSource delegate = null;
41 private PushBufferStream[] delStreams = null;
43 private MonitorStream monitorStream = null;
45 private PushBufferStream[] monitorStreams = null;
47 boolean delStarted = false; // variable used by MonitorStream also
49 private Control[] controls;
51 public MonitorCDS(DataSource ds)
53 // Get the stream from the actual datasource
54 // and create a MonitorStream from it
55 // Export the MonitorControl interface of the MonitorStream
56 if (ds instanceof PushBufferDataSource) {
57 delegate = (PushBufferDataSource) ds;
58 delStreams = delegate.getStreams();
59 monitorStream = new MonitorStream(delStreams[0], this);
60 monitorStreams = new PushBufferStream[] { monitorStream };
64 public Object[] getControls()
69 public Object getControl(String value)
71 if (value.equals("jmfsample.MonitorStream") || value.equals("javax.media.control.MonitorControl")){
78 public javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
80 return ((CaptureDevice) delegate).getCaptureDeviceInfo();
83 public FormatControl[] getFormatControls()
85 return ((CaptureDevice) delegate).getFormatControls();
88 public String getContentType()
90 return delegate.getContentType();
93 public void connect() throws IOException
96 throw new IOException("Incompatible DataSource");
97 // Delegate is already connected
100 public void disconnect()
102 monitorStream.setEnabled(false);
103 delegate.disconnect();
106 public synchronized void start() throws IOException
112 public synchronized void stop() throws IOException
114 if (!monitorStream.isEnabled()) {
120 public Time getDuration()
122 return delegate.getDuration();
125 public PushBufferStream[] getStreams()
127 return monitorStreams;
130 void startDelegate() throws IOException
135 void stopDelegate() throws IOException