javax.media
接口 DataSink

所有超级接口:
Controls, MediaHandler

public interface DataSink
extends MediaHandler, Controls

DataSink is the base interface for objects that read media content delivered by a DataSource and render the media to some destination. The destination is specified with a MediaLocator. One example of a DataSink is a file writer object that stores the media in a file.

A DataSink is created according to the factory mechanism used to create a Player.

从以下版本开始:
JMF 2.0
另请参见:
Manager.createDataSink(javax.media.protocol.DataSource, javax.media.MediaLocator)

方法摘要
 void addDataSinkListener(javax.media.datasink.DataSinkListener listener)
          Adds an event listener for events generated by this DataSink.
 void close()
          Closes the connection to the destination described by the output MediaLocator.
 java.lang.String getContentType()
          Gets a string that describes the content type of the media that this DataSink is consuming.
 MediaLocator getOutputLocator()
          Gets the output MediaLocator that describes where the output of this DataSink goes.
 void open()
          Opens a connection to the destination described by the output MediaLocator.
 void removeDataSinkListener(javax.media.datasink.DataSinkListener listener)
          Removes the specified event listener from this DataSink.
 void setOutputLocator(MediaLocator output)
          Sets the output MediaLocator for this DataSink.
 void start()
          Initiates data transfer.
 void stop()
          Stops the data transfer.
 
从接口 javax.media.MediaHandler 继承的方法
setSource
 
从接口 javax.media.Controls 继承的方法
getControl, getControls
 

方法详细信息

setOutputLocator

void setOutputLocator(MediaLocator output)
Sets the output MediaLocator for this DataSink. This method should only be called once; an error is thrown if the locator has already been set.

参数:
output - A MediaLocator that describes where the output of this DataSink goes.

getOutputLocator

MediaLocator getOutputLocator()
Gets the output MediaLocator that describes where the output of this DataSink goes.

返回:
The output MediaLocator for this DataSink.

start

void start()
           throws java.io.IOException
Initiates data transfer. You must call open before calling the start method.

抛出:
java.io.IOException - If there are IO problems with the source when start is called.

stop

void stop()
          throws java.io.IOException
Stops the data transfer. If the source has not been connected and started, stop does nothing.

抛出:
java.io.IOException - If there are IO problems with the source when stop is called.

open

void open()
          throws java.io.IOException,
                 java.lang.SecurityException
Opens a connection to the destination described by the output MediaLocator. This method establishes a channel between this DataSink and its destination.

抛出:
java.io.IOException - If there are IO problems when open is called.
java.lang.SecurityException - If there are any security violations while attempting to access the destination described by the output MediaLocator.

close

void close()
Closes the connection to the destination described by the output MediaLocator. This method frees the resources used to maintain a connection to the destination. If no resources are in use, close is ignored. If stop hasn't already been called, calling close stops the data transfer. A DataSink can no longer be used once it has been closed.


getContentType

java.lang.String getContentType()
Gets a string that describes the content type of the media that this DataSink is consuming.

返回:
A String that contains the name of the content-type.

addDataSinkListener

void addDataSinkListener(javax.media.datasink.DataSinkListener listener)
Adds an event listener for events generated by this DataSink.

参数:
listener - The DataSinkListener to add.

removeDataSinkListener

void removeDataSinkListener(javax.media.datasink.DataSinkListener listener)
Removes the specified event listener from this DataSink.

参数:
listener - The DataSinkListener to remove.