|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface IFileTransfer
An interface to transfer files from and to a backend.
This interface represents the response to a IBackend.annotateFileTransfer request.
This interface is property-aware. See the properties-list for all properties of this interface.
// getting previously recorded programs IProgramInfoList programs = backend.queryRecordings(); // getting the recording to transfer (we just use the first recording) IProgramInfo program = programs.get(0); // annotate a new file transfer IFileTransfer transfer = backend.annotateFileTransfer(program); if (transfer.isOpen()) { // set fast timeout transfer.setTimeout(true); // copy data File tempFile = File.createTempFile("fileTransfer", ".mpg"); transfer.transferTo(tempFile); } // close file transfer transfer.close();
<0>STATUS: OK | <1>SOCKET_ID: 38 | <2>FILESIZE1: 0 | <3>FILESIZE2: 86681 <0>STATUS: OK | <1>SOCKET_ID: 38 | <2>FILESIZE: 86681
IBackend.annotateFileTransfer(IProgramInfo),
ANN_FILE_TRANSFER| Nested Class Summary | |
|---|---|
static class |
IFileTransfer.Props
The properties of an IFileTransfer response. |
| Nested classes/interfaces inherited from interface org.jmythapi.protocol.response.ITransferable |
|---|
ITransferable.Seek |
| Method Summary | |
|---|---|
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 chunkSize)
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)
Requests a new block from backend and reads the block. |
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 size)
Requests data from the backend. |
long |
seek(long currentPos,
long newPos,
ITransferable.Seek whence)
This command wraps the file "seek" function. |
boolean |
setTimeout(boolean fast)
Sets the timout mode. |
void |
transferTo(File target)
Copies the remote file into the local file. |
void |
transferTo(OutputStream target)
Copies the remote file into the given output stream. |
boolean |
updateFileSize()
Updates the file information of the file-transfer object. |
| Methods inherited from interface org.jmythapi.protocol.response.ITransferable |
|---|
close |
| 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 |
| Method Detail |
|---|
String getStatus()
OK or ERRORint getSocketID()
long getFileSize()
For a in progress recording this file size may increase.
Use updateFileSize() to update the file size.
boolean updateFileSize()
throws IOException
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.
true on success.
IOException - on communication errors
int readBlock(byte[] buffer,
int requestedSize)
throws IOException
This method combines requestBlock(int) and readData(byte[], int).
readBlock in interface ITransferable<IFileTransfer.Props>buffer - the byte buffer to fill with datarequestedSize - the amount of bytes to read
IOException - on communication errors
int requestBlock(int size)
throws IOException
size - the amount of bytes to request.
IOException - on communication errors
int readData(byte[] buffer,
int reportedLength)
throws IOException
buffer - the buffer to fill with datareportedLength - the amount of data to read
IOException - on communication errors
long seek(long currentPos,
long newPos,
ITransferable.Seek whence)
throws IOException
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 ITransferable<IFileTransfer.Props>currentPos - the current positionnewPos - the new positionwhence - the seek mode
IOException - on communication errorsQUERY_FILETRANSFER_SEEK
boolean isOpen()
throws IOException
isOpen in interface ITransferable<IFileTransfer.Props>true if the socket is open.
IOException - on communication errors
boolean setTimeout(boolean fast)
throws IOException
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.
IOExceptionQUERY_FILETRANSFER_SET_TIMEOUT
boolean done()
throws IOException
done in interface ITransferable<IFileTransfer.Props>true on success.
IOException - on communication errorsQUERY_FILETRANSFER_DONE
boolean reopen(String filename)
throws IOException
IOExceptionQUERY_FILETRANSFER_REOPEN
void transferTo(File target)
throws IOException
This function transfers the full remote file into the specified target file.
target - the file to write data to.
IOException - on communication errors
void transferTo(OutputStream target)
throws IOException
This function transfers the full remote file into the specified target stream.
target - the output stream
IOException - on communication errors
InputStream getInputStream()
throws IOException
This function creates an input-stream that can be used to read the data of this file-transfer object.
IOException - on communication errors
InputStream getInputStream(int chunkSize)
throws IOException
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.
chunkSize - 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 | |||||||||