|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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>
CloneNotSupportedException
public void setProgramInfo(IProgramInfo programInfo)
public void setFileInfo(String fileName, String storageGroup)
public String getStatus()
IFileTransfer
getStatus
in interface IFileTransfer
OK
or ERROR
public int getSocketID()
IFileTransfer
getSocketID
in interface IFileTransfer
public 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 IFileTransfer
true
on success.
IOException
- on communication errorspublic 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 IFileTransfer
readBlock
in interface ITransferable<IFileTransfer.Props>
buffer
- the byte buffer to fill with datarequestedSize
- the amount of bytes to read
IOException
- on communication errorspublic int requestBlock(int requestedLength) throws IOException
IFileTransfer
requestBlock
in interface IFileTransfer
requestedLength
- the amount of bytes to request.
IOException
- on communication errorspublic int readData(byte[] buffer, int reportedLength) throws IOException
IFileTransfer
readData
in interface IFileTransfer
buffer
- the buffer to fill with datareportedLength
- the amount of data to read
IOException
- on communication errorspublic long seek(long currentPos, long newPos, ITransferable.Seek whence) throws IOException
IFileTransfer
This 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 IFileTransfer
seek
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 IFileTransfer
isOpen
in interface ITransferable<IFileTransfer.Props>
true
if the socket is open.
IOException
- on communication errorspublic 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 IFileTransfer
IOException
QUERY_FILETRANSFER_SET_TIMEOUT
public boolean done() throws IOException
IFileTransfer
done
in interface IFileTransfer
done
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 IFileTransfer
IOException
QUERY_FILETRANSFER_REOPEN
public void close() throws IOException
close
in interface Closeable
close
in interface ITransferable<IFileTransfer.Props>
IOException
public void transferTo(File target) throws IOException
IFileTransfer
This function transfers the full remote file into the specified target file.
transferTo
in interface IFileTransfer
target
- the file to write data to.
IOException
- on communication errorspublic void transferTo(OutputStream fileOut) throws IOException
IFileTransfer
This function transfers the full remote file into the specified target stream.
transferTo
in interface IFileTransfer
fileOut
- the output stream
IOException
- on communication errorspublic InputStream getInputStream() throws IOException
IFileTransfer
This function creates an input-stream that can be used to read the data of this file-transfer object.
getInputStream
in interface IFileTransfer
IOException
- on communication errorspublic 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 IFileTransfer
bufferSize
- 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 |