
org.jitsi.impl.neomedia.protocol.PullBufferDataSourceDelegate Maven / Gradle / Ivy
/*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.impl.neomedia.protocol;
import java.io.*;
import javax.media.*;
import javax.media.protocol.*;
/**
* Implements most of PullBufferDataSource for a particular
* DataSource and requires extenders to only implement
* {@link PullBufferDataSource#getStreams()}. Intended to allow easier
* overriding of the streams returned by a DataSource.
*
* @param the very type of DataSource to be wrapped in a
* PullBufferDataSourceDelegate
*
* @author Damian Minkov
*/
public abstract class PullBufferDataSourceDelegate
extends CaptureDeviceDelegatePullBufferDataSource
{
/**
* The wrapped DataSource this instance delegates to.
*/
protected final T dataSource;
/**
* Initializes a new PullBufferDataSourceDelegate which is to
* delegate to a specific DataSource.
*
* @param dataSource the DataSource the new instance is to delegate
* to
*/
public PullBufferDataSourceDelegate(T dataSource)
{
super(
(dataSource instanceof CaptureDevice)
? (CaptureDevice) dataSource
: null);
if (dataSource == null)
throw new NullPointerException("dataSource");
this.dataSource = dataSource;
}
/**
* Implements {@link DataSource#connect()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#connect()} because the
* wrapped DataSource may not be a CaptureDevice yet it
* still needs to be connected.
*
* @throws IOException if the wrapped DataSource throws such an
* exception
*/
@Override
public void connect()
throws IOException
{
dataSource.connect();
}
/**
* Implements {@link DataSource#disconnect()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#disconnect()} because
* the wrapped DataSource may not be a CaptureDevice yet
* it still needs to be disconnected.
*/
@Override
public void disconnect()
{
dataSource.disconnect();
}
/**
* Implements {@link DataSource#getContentType()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#getContentType()}
* because the wrapped DataSource may not be a
* CaptureDevice yet it still needs to report the content type.
*
* @return a String value which describes the content type of the
* wrapped DataSource
*/
@Override
public String getContentType()
{
return dataSource.getContentType();
}
/**
* Implements {@link DataSource#getLocator()}. Delegates to the wrapped
* DataSource.
*
* @return a MediaLocator value which describes the locator of the
* wrapped DataSource
*/
@Override
public MediaLocator getLocator()
{
return dataSource.getLocator();
}
/**
* Implements {@link DataSource#getControl(String)}. Delegates to the
* wrapped DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#getControl(String)}
* because the wrapped DataSource may not be a
* CaptureDevice yet it still needs to give access to the control.
*
* @param controlType a String value which names the type of the
* control to be retrieved
* @return an Object which represents the control of the requested
* controlType of the wrapped DataSource
*/
@Override
public Object getControl(String controlType)
{
return dataSource.getControl(controlType);
}
/**
* Implements {@link DataSource#getControls()}. Delegates to the wrapped
* PullBufferDataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#getControls()} because
* the wrapped DataSource may not be a CaptureDevice yet
* it still needs to give access to the controls.
*
* @return an array of Objects which represent the controls of the
* wrapped DataSource
*/
@Override
public Object[] getControls()
{
return dataSource.getControls();
}
/**
* Gets the DataSource wrapped by this instance.
*
* @return the DataSource wrapped by this instance
*/
public T getDataSource()
{
return dataSource;
}
/**
* Implements {@link DataSource#getDuration()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#getDuration()} because
* the wrapped DataSource may not be a CaptureDevice yet
* it still needs to report the duration.
*
* @return the duration of the wrapped DataSource
*/
@Override
public Time getDuration()
{
return dataSource.getDuration();
}
/**
* Gets the PullBufferStreams through which this
* PullBufferDataSource gives access to its media data.
*
* @return an array of PullBufferStreams through which this
* PullBufferDataSource gives access to its media data
*/
@Override
public abstract PullBufferStream[] getStreams();
/**
* Implements {@link DataSource#start()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#start()} because the
* wrapped DataSource may not be a CaptureDevice yet it
* still needs to be started.
*
* @throws IOException if the wrapped DataSource throws such an
* exception
*/
@Override
public void start()
throws IOException
{
dataSource.start();
}
/**
* Implements {@link DataSource#stop()}. Delegates to the wrapped
* DataSource. Overrides
* {@link CaptureDeviceDelegatePullBufferDataSource#stop()} because the
* wrapped DataSource may not be a CaptureDevice yet it
* still needs to be stopped.
*
* @throws IOException if the wrapped DataSource throws such an
* exception
*/
@Override
public void stop()
throws IOException
{
dataSource.stop();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy