|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jmythapi.impl.AData<E>
org.jmythapi.protocol.response.impl.AMythResponse<IFileTransfer.Props>
org.jmythapi.protocol.response.impl.FileTransfer
public class FileTransfer
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jmythapi.protocol.response.IFileTransfer |
|---|
IFileTransfer.Props |
| Nested classes/interfaces inherited from interface org.jmythapi.protocol.response.ITransferable |
|---|
ITransferable.Seek |
| Field Summary | |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
|
| Fields inherited from class org.jmythapi.impl.AData |
|---|
logger, propsClass, protoVersion, respArgs |
| Constructor Summary | |
|---|---|
FileTransfer(IBackendConnection commandConnection,
IBackendConnection dataConnection,
IMythPacket packet)
|
|
| Method Summary | |
|---|---|
Object |
clone()
Creates a copy of this object. |
void |
close()
|
boolean |
done()
Closes the file transfer connection. |
long |
getFileSize()
Gets the current file size. |
InputStream |
getInputStream()
Gets an input stream to read the file data. |
InputStream |
getInputStream(int bufferSize)
Gets an input stream to read the file data. |
int |
getSocketID()
Gets the file transfer socket id. |
String |
getStatus()
Gets the file transfer status. |
boolean |
isOpen()
Queries whether a file socket is currently open. |
int |
readBlock(byte[] buffer,
int requestedSize)
This method sends a block request to the backend, but does not wait for the response. |
int |
readData(byte[] buffer,
int reportedLength)
Reads the given amount of data from the backend. |
boolean |
reopen(String fileName)
Reopens the remote file. |
int |
requestBlock(int requestedLength)
Requests data from the backend. |
long |
seek(long currentPos,
long newPos,
ITransferable.Seek whence)
This command wraps the file "seek" function. |
void |
setFileInfo(String fileName,
String storageGroup)
|
void |
setProgramInfo(IProgramInfo programInfo)
|
boolean |
setTimeout(boolean fast)
Sets the timout mode. |
void |
transferTo(File target)
Copies the remote file into the local file. |
void |
transferTo(OutputStream fileOut)
Copies the remote file into the given output stream. |
boolean |
updateFileSize()
Updates the file information of the file-transfer object. |
| Methods inherited from class org.jmythapi.protocol.response.impl.AMythResponse |
|---|
checkSize, decodeProperty, encodeProperty, getExpectedSize, getPacket, getProperties, getProperty, getPropertyIndex |
| Methods inherited from class org.jmythapi.impl.AData |
|---|
equals, getPropertyClass, getPropertyCount, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValueObject, getPropertyValues, getVersionNr, hashCode, init, postProcessArguments, setPropertyValue, setPropertyValue, setPropertyValueObject, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jmythapi.IVersionable |
|---|
getVersionNr |
| Methods inherited from interface org.jmythapi.IPropertyAware |
|---|
getProperties, getProperty, getPropertyClass, getPropertyCount, getPropertyIndex, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValues, setPropertyValue, setPropertyValue, setPropertyValueObject |
| Field Detail |
|---|
public static final int DEFAULT_BUFFER_SIZE
| Constructor Detail |
|---|
public FileTransfer(IBackendConnection commandConnection,
IBackendConnection dataConnection,
IMythPacket packet)
| Method Detail |
|---|
public Object clone()
throws CloneNotSupportedException
AData
clone in class AData<IFileTransfer.Props>CloneNotSupportedExceptionpublic void setProgramInfo(IProgramInfo programInfo)
public void setFileInfo(String fileName,
String storageGroup)
public String getStatus()
IFileTransfer
getStatus in interface IFileTransferOK or ERRORpublic int getSocketID()
IFileTransfer
getSocketID in interface IFileTransferpublic long getFileSize()
IFileTransfer
For a in progress recording this file size may increase.
Use IFileTransfer.updateFileSize() to update the file size.
getFileSize in interface IFileTransfer
public boolean updateFileSize()
throws IOException
IFileTransfer
If the transfer object was initiated from an IProgramInfo object
(see IBackend.annotateFileTransfer(IProgramInfo)), then this function
uses IMythCommand.FILL_PROGRAM_INFO to determine the new file size.
If the transfer object was initialized using a file name, and the current protocol version is
greater or equal 44, then IMythCommand.QUERY_SG_FILEQUERY is used
to determine the new file size. But this method may fail if the requested file is not stored
in a file group, e.g. a channel icon.
updateFileSize in interface IFileTransfertrue on success.
IOException - on communication errors
public int readBlock(byte[] buffer,
int requestedSize)
throws IOException
See DSMyth - RemoteFile.cpp:
The response from REQUEST_BLOCK is not sent until all of the
requested data is sent. That means that we have to read from the data
socket while waiting for the reply on the control socket. If we don't
read data from the data socket the backend will timeout with an error.
This means that the network must be fast enough so we can get the data
before the backend times out.
readBlock in interface IFileTransferreadBlock in interface ITransferable<IFileTransfer.Props>buffer - the byte buffer to fill with datarequestedSize - the amount of bytes to read
IOException - on communication errors
public int requestBlock(int requestedLength)
throws IOException
IFileTransfer
requestBlock in interface IFileTransferrequestedLength - the amount of bytes to request.
IOException - on communication errors
public int readData(byte[] buffer,
int reportedLength)
throws IOException
IFileTransfer
readData in interface IFileTransferbuffer - the buffer to fill with datareportedLength - the amount of data to read
IOException - on communication errors
public long seek(long currentPos,
long newPos,
ITransferable.Seek whence)
throws IOException
IFileTransferThis command wraps the file "seek" function.
The pos and curpos fields are combined into a larger "long long" data type. This returns two values, a split "long long" value for the result.
seek in interface IFileTransferseek in interface ITransferable<IFileTransfer.Props>currentPos - the current positionnewPos - the new positionwhence - the seek mode
IOException - on communication errorsQUERY_FILETRANSFER_SEEK
public boolean isOpen()
throws IOException
IFileTransfer
isOpen in interface IFileTransferisOpen in interface ITransferable<IFileTransfer.Props>true if the socket is open.
IOException - on communication errors
public boolean setTimeout(boolean fast)
throws IOException
IFileTransfer
This command sets whether reading from a file should have a fast or slow timeout.
Slow timeouts are used for live TV ring buffers, and is three seconds. Fast timeouts are
used for static files, and are 0.12 seconds.
setTimeout in interface IFileTransferIOExceptionQUERY_FILETRANSFER_SET_TIMEOUT
public boolean done()
throws IOException
IFileTransfer
done in interface IFileTransferdone in interface ITransferable<IFileTransfer.Props>true on success.
IOException - on communication errorsQUERY_FILETRANSFER_DONE
public boolean reopen(String fileName)
throws IOException
IFileTransfer
reopen in interface IFileTransferIOExceptionQUERY_FILETRANSFER_REOPEN
public void close()
throws IOException
close in interface Closeableclose in interface ITransferable<IFileTransfer.Props>IOException
public void transferTo(File target)
throws IOException
IFileTransferThis function transfers the full remote file into the specified target file.
transferTo in interface IFileTransfertarget - the file to write data to.
IOException - on communication errors
public void transferTo(OutputStream fileOut)
throws IOException
IFileTransferThis function transfers the full remote file into the specified target stream.
transferTo in interface IFileTransferfileOut - the output stream
IOException - on communication errors
public InputStream getInputStream()
throws IOException
IFileTransferThis function creates an input-stream that can be used to read the data of this file-transfer object.
getInputStream in interface IFileTransferIOException - on communication errors
public InputStream getInputStream(int bufferSize)
throws IOException
IFileTransfer
This function creates an input-stream that can be used to read the data of this file-transfer object.
* The maximum size of the data chunks that should be fetched by the stream can be spezified.
getInputStream in interface IFileTransferbufferSize - the maximum size of the data chunks to fetch
IOException - on communication errors
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||