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;
32 import javax.media.protocol.*;
33 import javax.media.control.*;
35 import java.io.IOException;
39 public class MonitorCDS extends PushBufferDataSource{
41 private PushBufferDataSource delegate = null;
42 private PushBufferStream [] delStreams = null;
43 private MonitorStream monitorStream = null;
44 private PushBufferStream [] monitorStreams = null;
45 boolean delStarted = false; // variable used by MonitorStream also
46 private Control [] controls;
48 public MonitorCDS(DataSource ds)
50 // Get the stream from the actual datasource
51 // and create a MonitorStream from it
52 // Export the MonitorControl interface of the MonitorStream
53 if (ds instanceof PushBufferDataSource)
55 delegate = (PushBufferDataSource) ds;
56 delStreams = delegate.getStreams();
57 monitorStream = new MonitorStream(delStreams[0], this);
58 monitorStreams = new PushBufferStream[] {monitorStream};
62 public Object [] getControls()
67 public Object getControl(String value) {
68 if (value.equals("jmfsample.MonitorStream") || value.equals("javax.media.control.MonitorControl"))
74 public javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
76 return ((CaptureDevice)delegate).getCaptureDeviceInfo();
79 public FormatControl[] getFormatControls()
81 return ((CaptureDevice)delegate).getFormatControls();
84 public String getContentType()
86 return delegate.getContentType();
89 public void connect() throws IOException
92 throw new IOException("Incompatible DataSource");
93 // Delegate is already connected
96 public void disconnect()
98 monitorStream.setEnabled(false);
99 delegate.disconnect();
102 public synchronized void start() throws IOException
108 public synchronized void stop() throws IOException
110 if (!monitorStream.isEnabled()) {
116 public Time getDuration()
118 return delegate.getDuration();
121 public PushBufferStream [] getStreams()
123 return monitorStreams;
126 void startDelegate() throws IOException
131 void stopDelegate() throws IOException