org.jmythapi.protocol.impl
Class Backend

java.lang.Object
  extended by org.jmythapi.protocol.impl.Backend
All Implemented Interfaces:
Closeable, EventListener, IVersionable, IMythEventPacketListener, IBackend

public class Backend
extends Object
implements IVersionable, Closeable, IBackend, IMythEventPacketListener


Field Summary
 boolean debugging
           
protected  ProtocolVersion protoVersion
          The MythTV-protocol version used to communicate with the backend
 
Constructor Summary
Backend(IBackendConnection backendConnection)
          Constructs the backend object from an existing backend connection.
Backend(String hostname)
           
Backend(String hostname, int hostPort)
           
 
Method Summary
<Event extends IMythEvent<?>>
void
addEventListener(Class<Event> eventClass, IMythEventListener<Event> listener)
           
 void addEventPacketListener(IMythEventPacketListener listener)
          Registers a new event listener.
 Boolean allowShutdown()
          Allows a backend to shutdown.
 IFileTransfer annotateFileTransfer(IProgramInfo programInfo)
          Announce a new file-transfer connection to the backend.
 FileTransfer annotateFileTransfer(IProgramInfo programInfo, Boolean useReadAhead, Integer retries, Integer timeoutMs)
          Announce a new file-transfer connection to the backend.
 FileTransfer annotateFileTransfer(String fileName, Boolean useReadAhead, Integer retries, Integer timeoutMs, String storageGroup)
          Announce a new file-transfer connection to the backend.
 FileTransfer annotateFileTransfer(String fileName, String storageGroup)
          Announce a new file-transfer connection to the backend.
 FileTransfer annotateFileTransfer(URI fileUrl)
          Announce a new file-transfer connection to the backend.
 boolean annotateMonitor()
          Announces a new monitor connection to the backend.
 boolean annotateMonitor(String clientName)
          Announces a new monitor connection to the backend.
 boolean annotateMonitor(String clientName, EPlaybackSockEventsMode eventsMode)
          Announces a new monitor connection to the backend.
 boolean annotatePlayback()
          Announce a new playback connection to the backend.
 boolean annotatePlayback(String clientName)
          Announce a new playback connection to the backend.
 boolean annotatePlayback(String clientName, EPlaybackSockEventsMode eventsMode)
          Announce a new playback connection to the backend.
 Boolean blockShutdown()
          Prevents a backend from shutting down.
 Integer checkRecording(IProgramInfo programInfo)
          Checks if the given program is currently being recorded.
 void clearSettingsCache()
          Forces the backend to clear its settings cache.
 void close()
           
 void connect()
          Establishes a new connection to the backend.
 void connect(Integer connectionTimeout)
           
protected  IBackendConnection createCommandConnection(String hostname, int hostPort)
           
 boolean deleteFile(String fileName, String storageGroup)
          Delete a remote file.
 boolean deleteFile(URI fileUrl)
          Delete a remote file.
 boolean deleteRecording(Integer channelID, Date recordingStartTime)
          Deletes a recording-file.
 boolean deleteRecording(Integer channelID, Date recordingStartTime, Boolean forceMetadatDelete, Boolean forgetHistory)
          Delets a recording file, recording metadata and recording history.
 boolean deleteRecording(IProgramInfo programInfo)
          Deletes a recording file.
 boolean deleteRecording(IProgramInfo programInfo, Boolean forceMetadatDelete, Boolean forgetHistory)
          Delets a recording file, recording metadata and recording history.
 void disconnect()
          Disconnects from the backend.
 URI downloadFile(URI url, String storageGroup, String fileName)
          Downloads a file to the backend.
 URI downloadFileNow(URI url, String storageGroup, String fileName)
          Downloads a file to the backend.
 IProgramInfo fillProgramInfo(IProgramInfo programInfo)
          Fills in the pathname and file size fields of the given recording.
 IProgramInfo fillProgramInfo(IProgramInfo programInfo, String playBackHostname)
          Fills in the pathname and file size fields of the given recording.
 void fireEvent(IMythPacket eventPacket)
           
 boolean forceDeleteRecording(IProgramInfo programInfo)
          Deletes a recording-file and recording metadata.
 boolean forceDeleteRecording(List<String> programInfo)
           
 boolean forgetRecording(IProgramInfo programInfo)
          Delets recording history.
 boolean forgetRecording(List<String> programInfo)
           
 boolean freeTuner(Integer recorderID)
          Frees a previously locked tuner.
<C extends IBasicChannelInfo>
Map<Integer,C>
getBasicChannelInfoMap()
           
<C extends IBasicChannelInfo>
List<C>
getBasicChannelInfos()
          Get a list of all available channels on all available recorders.
 List<IRecorderChannelInfo> getChannelInfos()
          Get a list of all available channels on all available recorders.
 Map<String,String> getChannelLogoMap(IRecorderNextProgramInfo.Props keyProp)
          Gets a map containing the path to all channel logos.
 IBackendConnection getCommandConnection()
          Get the connection that was established to the backend.
 IRecorderInfo getFreeRecorder()
          A function to get the next free recorder.
 IRecorderInfo getFreeRecorder(String channelNumber)
          Gets the next free recorder that is capable to display the requested channel.
 int getFreeRecorderCount()
          Function to determine the amount of free recorders.
 int[] getFreeRecorderIDs()
          Gets the IDs of all free recorders.
 List<IRecorderInfo> getFreeRecorders()
          Gets the recorder-info objects of all free recorders.
 IBasicFreeSpace getFreeSpaceOverview()
          Gets the free space on the backend.
 String getHostName()
          Get the host name of the backend the client is connected to.
 int getHostPort()
          Get the connection port.
 IRecorderInfo getNextFreeRecorder()
          A function to get an info about the next free recorder.
 IRecorderInfo getNextFreeRecorder(Integer currentRecorderID)
          A function to get the next free recorder.
 IRecorderInfo getNextFreeRecorder(IRecorderInfo currentRecorder)
          A function to get the next free recorder.
 List<IRecorderNextProgramInfo> getNextProgramInfos(Date date)
          Gets the next programs of all known channels.
 Recorder getRecorder(IRecorderInfo recorderInfo)
          Connects to the specified recorder.
 IRecorderInfo getRecorderForNum(int recorderId)
          Returns the recorder-info for the recorder, specified by id.
 IRecorderInfo getRecorderForProgram(IProgramInfo programInfo)
          Checks if the given program is currently being recorded and returns the recorder-info for the recorder or null, if it is not being recorded.
 int[] getRecorderIDs()
          Returns the IDs of all available recorders.
 IRecorderInfo getRecorderNum(IProgramInfo programInfo)
          Determines the recorder, which is currently recording the given program.
 IRecorderInfo getRecorderNum(List<String> programInfo)
           
 List<IRecorderInfo> getRecorders()
          A function to get all available recorders, independently of their busy status.
 ProtocolVersion getVersionNr()
          Gets the protocol-version of an object.
 boolean goToSleep()
          Signals a slave backend to go to sleep.
 boolean hasFreeRecorders()
          Determines if there are any free recorders.
 boolean isActiveBackend()
          Checks if the current backend is active.
 boolean isActiveBackend(String hostname)
          Checks if the given backend is active.
 boolean isConnected()
          Queries the current connection status.
 void liveTvChainUpdate(String chainId)
          XXX: is this event really required for a client?
 ITunerInfo lockTuner()
          Asks the backend to lock the next free tuner.
 ITunerInfo lockTuner(Integer recorderID)
          Asks the backend to lock the given tuner.
static void main(String[] args)
           
 List<String> queryActiveBackends()
          Queries the names of all active backends.
 RecordingsPending queryAllPending()
          Gets all programs that will be recorded soon.
 RecordingsScheduled queryAllScheduled()
          Gets all scheduled recordings.
 Long queryBookmark(Integer channelID, Date recordingStartTime)
          Queries the bookmark position for a given recording.
 Long queryBookmark(IProgramInfo program)
          Queries the bookmark position for a given recording.
 FileStatus queryCheckFile(IProgramInfo programInfo, Boolean checkSlaves)
          Checks if a recording file exists that belongs to the given program.
 RecordingsConflicting queryConflicting()
          Gets all programs that are in conflict which each other.
 RecordingsConflicting queryConflicting(IProgramInfo programInfo)
          Gets all programs that are in conflict with the given program.
 RecordingsExpiring queryExpiring()
          Gets all programs that will expiring soon.
 FileStatus queryFileExists(IProgramInfo programInfo)
          Checks if a recording-file exists for the given program.
 FileStatus queryFileExists(String fileName, String storageGroup)
          Checks if a the named file exists in the named storage group.
 FileStatus queryFileExists(URI fileUrl)
          Checks if given file exists on the backend.
 String queryFileHash(IProgramInfo programInfo)
          Queries a unique hash-value for the recording-file of the given program.
 String queryFileHash(String fileName, String storageGroup)
          Queries a unique hash-value for the given file stored in the given storage group.
 String queryFileHash(String fileName, String storageGroup, String hostName)
          Queries a unique hash-value for the given file stored in the given storage group.
 String queryFileHash(URI fileUrl)
          Queries a unique hash-value for the given remote file.
 FreeSpace queryFreeSpace()
          Deprecated. 17
 FreeSpaceList queryFreeSpaceList(boolean allhosts)
          Returns the free disk space on the connected or on all MythTV backends.
 FreeSpaceSummary queryFreeSpaceSummary()
          Returns the free space on the connected backend.
 boolean queryGenPixmap(IProgramInfo program)
          Generates a preview image of the requested show.
 boolean queryGenPixmap(IProgramInfo program, Boolean inSeconds, Long time, String fileName, Integer width, Integer height)
          Generates a preview image of the requested show.
 boolean queryGenPixmap2(String token, IProgramInfo program)
          Generates a preview image of the requested show.
 boolean queryGenPixmap2(String token, IProgramInfo program, Boolean inSeconds, Long time, String fileName, Integer width, Integer height)
          Generates a preview image of the requested show.
 GuideDataThrough queryGuideDataThrough()
          Queries the guide-date status of the backend.
 String queryHostname()
          Gets the hostname of the backend.
 IRecordingStatus queryIsRecording()
          Queries the current recording status of the backend.
 ILoad queryLoad()
          Queries the current load of the backend.
 IMemStats queryMemStats()
          Queries the current memory state of the backend.
 IPixmap queryPixmap(IProgramInfo program)
          Queries a preview image.
 IPixmap queryPixmap(String previewImageName, String storageGroup)
          Queries a preview image.
 IPixmap queryPixmapIfModified(IProgramInfo program, Date lastModifiedDate, Long maxFileSize)
          Queries a preview image.
 Date queryPixmapLastModified(IProgramInfo program)
          Queries the last-modified date of the pixmap of a given recording.
 IProgramInfo queryRecording(IBasicChannelInfo channel, Date startTime)
          Get a single recording by its channel and recording start-time.
 IProgramInfo queryRecording(Integer channelID, Date recordingStartTime)
          Get a single recording by its channel-id and start-time.
 ProgramInfo queryRecording(String baseName)
          TODO: fallback using a program filter!!!!
 IProgramInfoList queryRecordings()
          Queries for all available recordings.
 IProgramInfoList queryRecordings(ERecordingsType eRecordingsType)
          TODO: sorting for versions >= 65
 Setting querySetting(String hostName, String settingName)
          Queries the remote host for a specific setting.
 StorageGroupFile queryStorageGroupFile(String hostName, String storageGroup, String fileName)
          Queries the a single file from the remote storage group.
 IStorageGroupFileList queryStorageGroupFileList(String hostName, String storageGroup, String path)
          Queries the a list of files from the remote storage group.
 StorageGroupFileList queryStorageGroupFileList(String hostName, String storageGroup, String path, boolean fileNamesOnly)
          Queries the a list of files from the remote storage group.
 ITimezone queryTimeZone()
          Queries the timezone of the backend.
 boolean queryTranscode(IProgramInfo programInfo)
           
 IUptime queryUptime()
          Queries the uptime of the backend.
 boolean queueTranscode(IProgramInfo recording)
          Enqueues the recording for transcoding.
 boolean queueTranscodeCutlist(IProgramInfo recording)
          Enqueues the recording for transcoding and cutlist processing.
 boolean queueTranscodeStop(IProgramInfo recording)
          Stops transcoding of a recording Usage Hint: Use queueTranscode to start transcoding of a recording.
 boolean reactivateRecording(IProgramInfo programInfo)
          Reactivates a inactive recording.
 boolean reactivateRecording(List<String> programInfo)
           
 void recordingListChange()
           
 boolean refreshBackend()
          Forces the backend to reload the backend settings.
<Event extends IMythEvent<?>>
void
removeEventListener(Class<Event> eventClass, IMythEventListener<Event> listener)
           
 void removeEventPacketListener(IMythEventPacketListener listener)
          Unregisters a event listener.
 boolean rescheduleAllRecordings()
          Force MythTV to reschedule all recordings.
 Boolean rescheduleAllRecordingsAndWait(long timeout, TimeUnit unit)
          Forces MythTV to reschedule all recordings and thereafter to wait for an SCHEDULE_CHANGE event.
 boolean rescheduleRecordings(Integer recordID)
          Force MythTV to reschedule the given recording.
 Boolean rescheduleRecordingsAndWait(Integer recordID, long timeout, TimeUnit unit)
          Forces MythTV to reschedule a given recording and waits for an SCHEDULE_CHANGE event.
 boolean rescheduleRecordingsMatch(Integer recordID, Integer sourceID, Integer multiplexID, Date maxStartTime, String reason)
           
 Boolean rescheduleRecordingsMatchAndWait(Integer recordID, Integer sourceID, Integer multiplexID, Date maxStartTime, String reason, long timeout, TimeUnit unit)
           
 boolean scanVideos()
          Trigger a scan of all video folders.
 boolean setBookmark(Integer channelID, Date recordingStartTime, Long bookmarkPosition)
          Sets the bookmark position for the given recording.
 boolean setBookmark(IProgramInfo recording, Long bookmarkPosition)
          Sets the bookmark position for the given recording.
 boolean setChannelInfo(String oldChannelNumber, IRecorderChannelInfo channelInfo)
          Changes detailed infos about the given channel.
 void setInitialVersionNr(ProtocolVersion protoVersion)
          Sets the initial protocol-version that should be used for handshake.
 boolean setSetting(String hostName, String settingName, String settingValue)
          Sets the given setting on the remote host.
 void shutdownNow()
          Forces a slave backend to shutdown now.
 Integer stopRecording(IProgramInfo programInfo)
          Stop a currently active recording.
 String toString()
           
 boolean undeleteRecording(IProgramInfo programInfo)
          Undelets a recording-file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debugging

public boolean debugging

protoVersion

protected ProtocolVersion protoVersion
The MythTV-protocol version used to communicate with the backend

Constructor Detail

Backend

public Backend(String hostname)
Parameters:
hostname - the MythTV-backend hostname to connect to

Backend

public Backend(String hostname,
               int hostPort)
Parameters:
hostname - the MythTV-backend hostname to connect to
hostPort - the MythTV-backend port to connect to

Backend

public Backend(IBackendConnection backendConnection)
Constructs the backend object from an existing backend connection.

Parameters:
backendConnection - the existing backend connection
Method Detail

getCommandConnection

public IBackendConnection getCommandConnection()
Description copied from interface: IBackend
Get the connection that was established to the backend.

Specified by:
getCommandConnection in interface IBackend
Returns:
the BackendConnection used by this backend, or null if connect() was not called so far.

createCommandConnection

protected IBackendConnection createCommandConnection(String hostname,
                                                     int hostPort)

getHostName

public String getHostName()
Description copied from interface: IBackend
Get the host name of the backend the client is connected to.

Specified by:
getHostName in interface IBackend
Returns:
the host name of the backend

getHostPort

public int getHostPort()
Description copied from interface: IBackend
Get the connection port.

Specified by:
getHostPort in interface IBackend
Returns:
the port of the backend

getVersionNr

public ProtocolVersion getVersionNr()
Description copied from interface: IVersionable
Gets the protocol-version of an object.

Specified by:
getVersionNr in interface IVersionable
Specified by:
getVersionNr in interface IBackend
Returns:
the version a given object was created for.

setInitialVersionNr

public void setInitialVersionNr(ProtocolVersion protoVersion)
Description copied from interface: IBackend
Sets the initial protocol-version that should be used for handshake.

Specified by:
setInitialVersionNr in interface IBackend
Parameters:
protoVersion - the initial protocol version

isConnected

public boolean isConnected()
Description copied from interface: IBackend
Queries the current connection status.

Specified by:
isConnected in interface IBackend
Returns:
true if a connection was established.

connect

public void connect()
             throws IOException
Description copied from interface: IBackend
Establishes a new connection to the backend.

Once the connection is established, the protocol-version is negotiated.

Specified by:
connect in interface IBackend
Throws:
IOException - on communication errors

connect

public void connect(Integer connectionTimeout)
             throws IOException
Specified by:
connect in interface IBackend
Throws:
IOException

disconnect

public void disconnect()
Description copied from interface: IBackend
Disconnects from the backend.

Specified by:
disconnect in interface IBackend

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

addEventPacketListener

public void addEventPacketListener(IMythEventPacketListener listener)
Description copied from interface: IBackend
Registers a new event listener.

Specified by:
addEventPacketListener in interface IBackend
Parameters:
listener - the event listener

removeEventPacketListener

public void removeEventPacketListener(IMythEventPacketListener listener)
Description copied from interface: IBackend
Unregisters a event listener.

Specified by:
removeEventPacketListener in interface IBackend
Parameters:
listener - the event listener

addEventListener

public <Event extends IMythEvent<?>> void addEventListener(Class<Event> eventClass,
                                                           IMythEventListener<Event> listener)
Specified by:
addEventListener in interface IBackend

removeEventListener

public <Event extends IMythEvent<?>> void removeEventListener(Class<Event> eventClass,
                                                              IMythEventListener<Event> listener)
Specified by:
removeEventListener in interface IBackend

fireEvent

public void fireEvent(IMythPacket eventPacket)
Specified by:
fireEvent in interface IMythEventPacketListener

annotatePlayback

public boolean annotatePlayback()
                         throws IOException
Description copied from interface: IBackend
Announce a new playback connection to the backend.

This signals that backend that a new client will start playback and prevents it from shutting down the socket.

Specified by:
annotatePlayback in interface IBackend
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_PLAYBACK

annotatePlayback

public boolean annotatePlayback(String clientName)
                         throws IOException
Description copied from interface: IBackend
Announce a new playback connection to the backend.

This signals that backend that a new client will start playback and prevents it from shutting down the socket.

Specified by:
annotatePlayback in interface IBackend
Parameters:
clientName - the name of the client
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_PLAYBACK

annotatePlayback

public boolean annotatePlayback(String clientName,
                                EPlaybackSockEventsMode eventsMode)
                         throws IOException
Description copied from interface: IBackend
Announce a new playback connection to the backend.

This signals that backend that a new client will start playback and prevents it from shutting down the socket.

Specified by:
annotatePlayback in interface IBackend
Parameters:
clientName - the name of this client
eventsMode - the type of events the client is interested in.
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_PLAYBACK

annotateMonitor

public boolean annotateMonitor()
                        throws IOException
Description copied from interface: IBackend
Announces a new monitor connection to the backend.

This signals that backend that a new client will start querying the backend but does not prevents it from shutting down the socket.

Specified by:
annotateMonitor in interface IBackend
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_MONITOR

annotateMonitor

public boolean annotateMonitor(String clientName)
                        throws IOException
Description copied from interface: IBackend
Announces a new monitor connection to the backend.

This signals that backend that a new client will start querying the backend but does not prevents it from shutting down the socket.

Specified by:
annotateMonitor in interface IBackend
Parameters:
clientName - the host name of the client
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_MONITOR

annotateMonitor

public boolean annotateMonitor(String clientName,
                               EPlaybackSockEventsMode eventsMode)
                        throws IOException
Description copied from interface: IBackend
Announces a new monitor connection to the backend.

This signals that backend that a new client will start querying the backend but does not prevents it from shutting down the socket.

Specified by:
annotateMonitor in interface IBackend
Parameters:
clientName - the name of this client
eventsMode - the type of events the client is interested in.
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
ANN_MONITOR

annotateFileTransfer

public IFileTransfer annotateFileTransfer(IProgramInfo programInfo)
                                   throws IOException
Description copied from interface: IBackend
Announce a new file-transfer connection to the backend.

Usage example:


    // 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();
 

Specified by:
annotateFileTransfer in interface IBackend
Parameters:
programInfo - the program, whose file should be transfered
Returns:
a file-transfer object that can be used to fetch the data.
Throws:
IOException - on communication errors
See Also:
IBackend.annotateFileTransfer(String, Boolean, Integer, Integer, String), ANN_FILE_TRANSFER

annotateFileTransfer

public FileTransfer annotateFileTransfer(IProgramInfo programInfo,
                                         Boolean useReadAhead,
                                         Integer retries,
                                         Integer timeoutMs)
                                  throws IOException
Description copied from interface: IBackend
Announce a new file-transfer connection to the backend.

It reads the file-name and storage-group from the given program-info object and calls IBackend.annotateFileTransfer(String, Boolean, Integer, Integer, String).

Specified by:
annotateFileTransfer in interface IBackend
Parameters:
programInfo - the program, whose file should be transfered
useReadAhead - if the backend should read ahead the requested location via a separate thread (since 29)
retries - how many retries should be done before giving up (since 29, deprecated 60)
timeoutMs - the timeout to wait for data in milliseconds (since 60)
Returns:
a file-transfer object that can be used to fetch the data.
Throws:
IOException - on communication errors
See Also:
IBackend.annotateFileTransfer(String, Boolean, Integer, Integer, String), ANN_FILE_TRANSFER

annotateFileTransfer

public FileTransfer annotateFileTransfer(URI fileUrl)
                                  throws IOException
Description copied from interface: IBackend
Announce a new file-transfer connection to the backend.

This method calls URI.getUserInfo() and URI.getPath() to determine the storage-group and file name and calls IBackend.annotateFileTransfer(String, Boolean, Integer, Integer, String) afterwards.

Specified by:
annotateFileTransfer in interface IBackend
Parameters:
fileUrl - the URI to the file to transfer
Returns:
a file-transfer object that can be used to fetch the data.
Throws:
IOException - on communication errors
See Also:
ANN_FILE_TRANSFER

annotateFileTransfer

public FileTransfer annotateFileTransfer(String fileName,
                                         String storageGroup)
                                  throws IOException
Description copied from interface: IBackend
Announce a new file-transfer connection to the backend.

This method internally calls IBackend.annotateFileTransfer(String, Boolean, Integer, Integer, String).

Usage example:


     IBackend backend = ...;      // an already connected backend
     IProgramInfo program = ...;  // a previously recorded program
     
     // the storage group and name of the recording preview image
     String storagGroup = program.getStorageGroup();
     String previewFileName = program.getPreviewImageName();
     
     // transfering the recording preview image to the client
     File targetFile = File.createTempFile("preview", ".png");
     IFileTransfer transfer = backend.annotateFileTransfer(previewFileName,storagGroup);
     transfer.transferTo(targetFile);
     transfer.close();
 

Specified by:
annotateFileTransfer in interface IBackend
Parameters:
fileName - the name of the file to be transfered
storageGroup - the name of the storage-group the file is located in (since 44)
Returns:
a file-transfer object that can be used to fetch the data.
Throws:
IOException - on communication errors
See Also:
ANN_FILE_TRANSFER

annotateFileTransfer

public FileTransfer annotateFileTransfer(String fileName,
                                         Boolean useReadAhead,
                                         Integer retries,
                                         Integer timeoutMs,
                                         String storageGroup)
                                  throws IOException
Description copied from interface: IBackend
Announce a new file-transfer connection to the backend.

This command must be sent as first command after calling IBackend.connect().

Usage example:


     IBackend backend = ...;      // an already connected backend
     IProgramInfo program = ...;  // a previously recorded program
     
     // the storage group and name of the recording preview image
     String storagGroup = program.getStorageGroup();
     String previewFileName = program.getPreviewImageName();
     
     // transfering the recording preview image to the client
     File targetFile = File.createTempFile("preview", ".png");
     IFileTransfer transfer = backend.annotateFileTransfer(previewFileName, Boolean.TRUE, -1, 2000, storagGroup);
     transfer.transferTo(targetFile);
     transfer.close();
 

Specified by:
annotateFileTransfer in interface IBackend
Parameters:
fileName - the name of the file to be transfered
useReadAhead - if the backend should read ahead the requested location via a separate thread. If null then true is used. (since 29)
retries - how many retries should be done before giving up. If null then -1 is used. (since 29, deprecated 60)
timeoutMs - the timeout to wait for data in milliseconds. If null then 2000 is used. (since 60)
storageGroup - the name of the storage-group the file is located in (since 44)
Returns:
a file-transfer object that can be used to fetch the data.
Throws:
IOException - on communication errors
See Also:
ANN_FILE_TRANSFER

getRecorder

public Recorder getRecorder(IRecorderInfo recorderInfo)
                     throws IOException
Description copied from interface: IBackend
Connects to the specified recorder.

This method and returns a recorder object which allows to send command to the recorder.

Usage example:


    IBackend backend = ....; // an already connected backend
 
    // getting the next free recorder
    IRecorderInfo recorderInfo = backend.getNextFreeRecorder();
    if(recorderInfo != null) {
       // connect to the recorder
       IRecorder recorder = backend.getRecorder(recorderInfo);
       
       // send commands to the recorder ...
       
       // e.g., getting all available channel 
       List<IBasicChannelInfo> channels = recorder.getBasicChannelInfos();
       for(IBasicChannelInfo channel : channels) {
          System.out.println(String.format("Channel %d: %s",channel.getChannelID(),channel.getChannelSign()));
       }
    } else {
       System.out.println("No free recorder available");
    }
  

Specified by:
getRecorder in interface IBackend
Parameters:
recorderInfo - informations about the recorder
Returns:
the connected recorder
Throws:
IOException - on communication errors

getNextFreeRecorder

public IRecorderInfo getNextFreeRecorder()
                                  throws IOException
Description copied from interface: IBackend
A function to get an info about the next free recorder.

Specified by:
getNextFreeRecorder in interface IBackend
Throws:
IOException
See Also:
GET_NEXT_FREE_RECORDER

getNextFreeRecorder

public IRecorderInfo getNextFreeRecorder(IRecorderInfo currentRecorder)
                                  throws IOException
Description copied from interface: IBackend
A function to get the next free recorder. Searching is started with the given recorder.

Specified by:
getNextFreeRecorder in interface IBackend
Parameters:
currentRecorder - the current recorder
Returns:
info about the next free recorder or null if no recorder is available.
Throws:
IOException - on communication errors
See Also:
GET_NEXT_FREE_RECORDER

getNextFreeRecorder

public IRecorderInfo getNextFreeRecorder(Integer currentRecorderID)
                                  throws IOException
Description copied from interface: IBackend
A function to get the next free recorder. Searching is started with the given recorder-ID.

Specified by:
getNextFreeRecorder in interface IBackend
Parameters:
currentRecorderID - the current recorder id
Returns:
info about the next free recorder or null if no recorder is available.
Throws:
IOException - on communication errors
See Also:
GET_NEXT_FREE_RECORDER

getFreeRecorder

public IRecorderInfo getFreeRecorder()
                              throws IOException
Description copied from interface: IBackend
A function to get the next free recorder.

This is similar to IBackend.getNextFreeRecorder(), except that it tries to get a recorder on the local machine if possible.

Specified by:
getFreeRecorder in interface IBackend
Throws:
IOException - on communication errors
See Also:
GET_FREE_RECORDER

getFreeRecorder

public IRecorderInfo getFreeRecorder(String channelNumber)
                              throws IOException
Description copied from interface: IBackend
Gets the next free recorder that is capable to display the requested channel.

Specified by:
getFreeRecorder in interface IBackend
Parameters:
channelNumber - the desired channel
Returns:
the next free recorder or null
Throws:
IOException - on communication errors
See Also:
IRecorder.checkChannel(String)

getRecorders

public List<IRecorderInfo> getRecorders()
                                 throws IOException
Description copied from interface: IBackend
A function to get all available recorders, independently of their busy status.

This function uses getRecorderForNum, starting with recorder-index 1, to determine all available recorders.

Usage Hint:

Use getFreeRecorders to only get free recorders.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // determine all available recorders
    List<IRecorderInfo> recorderInfos = backend.getRecorders();
    
    // print out the recorder connection infos
    System.out.println(String.format("%d recorders found:",recorderInfos.size()));
    for(IRecorderInfo recorderInfo : recorderInfos) {
       System.out.println(String.format(
          "%02d: %s:%d",
          recorderInfo.getRecorderID(),
          recorderInfo.getHostName(),
          recorderInfo.getHostPort()
       ));
    }
 

The above example will output, e.g.
 3 recorders found:
 01: 192.168.10.202:6543
 02: 192.168.10.202:6543
 03: 192.168.10.202:6543
 

Specified by:
getRecorders in interface IBackend
Returns:
a list of all available (but not necessarily free) recorders.
Throws:
IOException - on communication errors
See Also:
GET_RECORDER_FROM_NUM, IBackend.getRecorderForNum(int)

getRecorderIDs

public int[] getRecorderIDs()
                     throws IOException
Description copied from interface: IBackend
Returns the IDs of all available recorders.

This method returns all recorders, independently of their busy status.
The returned IDs can be used as argument for function getRecorderForNum to fetch further information about the recorders.

Usage Hint:

Use getFreeRecorderIDs to only get the IDs of all free recorders.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // get the IDs of all available (busy or idle) recorders
    int[] allRecorderIDs = backend.getRecorderIDs();
    System.out.println(String.format(
       "%d recorders are available:", allRecorderIDs.length
    ));
    
    for(int recorderId : allRecorderIDs) {
       // get the recorder info
       IRecorderInfo recorderInfo = backend.getRecorderForNum(recorderId);
       
       // connect to the recorder
       IRecorder recorder = backend.getRecorder(recorderInfo);
       
       // get the recorder status
       boolean isRecording = recorder.isRecording();
       System.out.println(String.format(
          "Recorder %d is currently %s",
          recorderId,
          isRecording?"busy":"idle"
       ));
    }
 

The above example will output, e.g.:
 3 recorders are available:
 Recorder 1 is currently busy
 Recorder 2 is currently idle
 Recorder 3 is currently idle
 

Specified by:
getRecorderIDs in interface IBackend
Returns:
the IDs of all available recorders.
Throws:
IOException - on communication errors
See Also:
GET_RECORDER_FROM_NUM, IBackend.getRecorders()

getRecorderForNum

public IRecorderInfo getRecorderForNum(int recorderId)
                                throws IOException
Description copied from interface: IBackend
Returns the recorder-info for the recorder, specified by id.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // getting recorder info by recorder-id
    IRecorderInfo recorderInfo = backend.getRecorderForNum(recorderId);
    
    // connect to the recorder
    IRecorder recorder = backend.getRecorder(recorderInfo);
    
    // getting the currently active recorder input and channel			
    String recorderInput = recorder.getInput();
    IBasicChannelInfo recorderChannel = recorder.getCurrentChannel();
    System.out.println(String.format(
       "Recorder %d is using input: %s (channel: %s).",
       recorderId, recorderInput, recorderChannel.getChannelSign()
    ));
 

The above example will output, e.g.:
 Recorder 1 is using input: Tuner 1 (channel: PRO7).
 

Specified by:
getRecorderForNum in interface IBackend
Parameters:
recorderId - the recorder id
Returns:
info about the recorder or null if no recorder was found.
Throws:
IOException - on communication errors
See Also:
GET_RECORDER_FROM_NUM

getRecorderNum

public IRecorderInfo getRecorderNum(IProgramInfo programInfo)
                             throws IOException
Description copied from interface: IBackend
Determines the recorder, which is currently recording the given program.

Specified by:
getRecorderNum in interface IBackend
Parameters:
programInfo - the recording
Returns:
the recorder-info object about the recorder, that is currently recording the given program, or null if no recorder was found.
Throws:
IOException - on communication errors
See Also:
GET_RECORDER_NUM

getRecorderNum

public IRecorderInfo getRecorderNum(List<String> programInfo)
                             throws IOException
Throws:
IOException

getFreeRecorderCount

public int getFreeRecorderCount()
                         throws IOException
Description copied from interface: IBackend
Function to determine the amount of free recorders.

Protocol Version Hint:

If this function is called prior to 09, then IBackend.getFreeRecorderIDs() is called to determine the amount of free recorders.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // get the amount of free recorders
    int freeRecorderCount = backend.getFreeRecorderCount();
    System.out.println(String.format(
       "%d free recorders found.",
       freeRecorderCount
    ));
 

Specified by:
getFreeRecorderCount in interface IBackend
Returns:
the current amount of free recorders.
Throws:
IOException - on communication errors
See Also:
GET_FREE_RECORDER_COUNT

getFreeRecorderIDs

public int[] getFreeRecorderIDs()
                         throws IOException
Description copied from interface: IBackend
Gets the IDs of all free recorders.

This function returns a list of free recorders IDs, or an empty list if none. The returned IDs can be used as argument for function IBackend.getRecorderForNum(int) to fetch further information about the recorders.

Usage Hint:

Use getRecorderIDs to get the id of all (busy or idle) recorders.

Protocol Version Hint:

If this function is called prior to protocol-version 17, then it uses IBackend.getNextFreeRecorder(Integer) to determine the IDs of all free recorders.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // query the IDs of all free recorders
    int[] freeRecorderIDs = backend.getFreeRecorderIDs();
    System.out.println(String.format(
       "The following recorders are ready to use: %s",
       Arrays.toString(freeRecorderIDs)
    ));
 

Specified by:
getFreeRecorderIDs in interface IBackend
Returns:
the IDs of all currently free recorders.
Throws:
IOException - on communication errors
See Also:
GET_FREE_RECORDER_LIST

getFreeRecorders

public List<IRecorderInfo> getFreeRecorders()
                                     throws IOException
Description copied from interface: IBackend
Gets the recorder-info objects of all free recorders.

This method internally uses IBackend.getFreeRecorderIDs() to determine all free recorders and IBackend.getRecorderForNum(int) to fetch the information for a recorder.

Usage Hint:

Use getRecorders to get all (busy or idel) recorders.

Specified by:
getFreeRecorders in interface IBackend
Returns:
a list of free recorders
Throws:
IOException - on communication errors
See Also:
GET_FREE_RECORDER_LIST, GET_RECORDER_FROM_NUM

hasFreeRecorders

public boolean hasFreeRecorders()
                         throws IOException
Description copied from interface: IBackend
Determines if there are any free recorders.

This function used getFreeRecorderCount to determine if there is at lease one free recorder available.

Specified by:
hasFreeRecorders in interface IBackend
Returns:
true if there is at least one free recorder available
Throws:
IOException - on communication errors
See Also:
GET_FREE_RECORDER_COUNT

recordingListChange

public void recordingListChange()
                         throws IOException
Specified by:
recordingListChange in interface IBackend
Throws:
IOException - on communication errors
See Also:
BACKEND_MESSAGE_RECORDING_LIST_CHANGE

liveTvChainUpdate

public void liveTvChainUpdate(String chainId)
                       throws IOException
Description copied from interface: IBackend
XXX: is this event really required for a client?

Specified by:
liveTvChainUpdate in interface IBackend
Parameters:
chainId - TODO
Throws:
IOException - on communication errors
See Also:
BACKEND_MESSAGE_LIVETV_CHAIN

queryRecordings

public IProgramInfoList queryRecordings()
                                 throws IOException
Description copied from interface: IBackend
Queries for all available recordings.

Usage Hint:

Use queryAllScheduled to get all scheduled recordings.
Use queryAllPending to get all pending recordings.
Use queryConflicting to get all conflicting recordings.
Use queryExpiring to get all expiring recordings.

Protocol Version Hint:

Prior to protocol version 19 the recording-status was not set properly by the MythTV-backend. For this protocol versions, this function additionally uses IBackend.queryAllPending() to determine, which of the returned recordings are still in progress.

Usage example:


    // query all available recordings
    IProgramInfoList allRecordings = backend.queryRecordings();
    
    // print the channel, length, file-size and title of all recordings
    System.out.println("Channel | Length  | Size     | Title");
    for(IProgramInfo program : allRecordings) {
       // print out the found recodings
       System.out.println(String.format(
          "%-5s | %3d min | %8s | %s",
          program.getChannelSign(),
          program.getDuration(),
          EncodingUtils.getFormattedFileSize(Locale.ENGLISH,program.getFileSize()),
          program.getFullTitle()
       ));			
    }
 

The above example will output, e.g.

 Channel | Length  | Size     | Title
 ATV+    |  55 min |  3.51 GB | Dr. Quinn - Ärztin aus Leidenschaft - Für das Leben der Cheyenne
 RTL2    |  30 min |  2.34 GB | King of Queens - Wer schön sein will ...
 RTL2    |  30 min |  2.34 GB | King of Queens - Das Haus am See
 

Specified by:
queryRecordings in interface IBackend
Returns:
all found recordings
Throws:
IOException - on communication errors
See Also:
QUERY_RECORDINGS, QUERY_ISRECORDING, QUERY_GETALLPENDING

queryRecordings

public IProgramInfoList queryRecordings(ERecordingsType eRecordingsType)
                                 throws IOException
TODO: sorting for versions >= 65

Specified by:
queryRecordings in interface IBackend
Parameters:
eRecordingsType - the type of the requested recordings. Use null or ERecordingsType.Play to query all available recordings.
Returns:
all found recordings for the given type
Throws:
IOException - on communication errors
See Also:
QUERY_RECORDINGS, QUERY_ISRECORDING, QUERY_GETALLPENDING

queryGenPixmap

public boolean queryGenPixmap(IProgramInfo program)
                       throws IOException
Description copied from interface: IBackend
Generates a preview image of the requested show.

Usage Hint:

Use queryPixmapLastModified to query the last modified date of the pixmap.
Use queryPixmap to download the pixmap file.

Protocol Version Hint:

If this method is called with a protocol version greater than 60, then this method calls queryGenPixmap2(...).

Usage example:


      IBackend backend = ....;    // an already connected backend
      IProgramInfo program = ...; // a previously recorded program
 
      // generate the preview image
      if (backend.queryGenPixmap(program) {
          // getting the preview image name
          String imageName = program.getPreviewImageName();
          
          // create a temp file to store the preview image
          File targetFile = File.createTempFile("preview", ".png");
          
          // copy the png to the client
          IFileTransfer transfer = backend.annotateFileTransfer(imageName, null, null, null);
          transfer.transferTo(targetFile);
          transfer.close();
          
          // load the image
          BufferedImage image = ImageIO.read(targetFile);
          System.out.println(String.format(
          	"Image %s has a size of %dx%d",
          	targetFile.getName(),
          	image.getWidth(), image.getHeight()
          ));
      } else {
      	Sytem.error.println("Preview image generation failed.");
      }
 

Specified by:
queryGenPixmap in interface IBackend
Parameters:
program - the recording, for which a preview image should be generated
Throws:
IOException - on communication errors
See Also:
QUERY_GENPIXMAP

queryGenPixmap

public boolean queryGenPixmap(IProgramInfo program,
                              Boolean inSeconds,
                              Long time,
                              String fileName,
                              Integer width,
                              Integer height)
                       throws IOException
Description copied from interface: IBackend
Generates a preview image of the requested show.

Usage Hint:

Use queryPixmapLastModified to query the last modified date of the pixmap.
Use queryPixmap to download the pixmap file.

Protocol Version Hint:

If this method is called with a protocol version greater or equal to 61, then this method calls queryGenPixmap2(...).

Specified by:
queryGenPixmap in interface IBackend
Parameters:
program - the recording, to grab a preview image from
inSeconds - if true time is in seconds, otherwise it is in frames (since 37)
time - the seconds or frames into the video to seek before capturing a frame (since 37)
fileName - the filename to use (since 37)
width - the preview image width (since 37)
height - the preview image height (since 37)
Throws:
IOException - on communication errors
See Also:
QUERY_GENPIXMAP

queryGenPixmap2

public boolean queryGenPixmap2(String token,
                               IProgramInfo program)
                        throws IOException
Description copied from interface: IBackend
Generates a preview image of the requested show.

Usage Hint:

Use queryPixmapLastModified to query the last modified date of the pixmap.
Use queryPixmap to download the pixmap.
Use queryGenPixmap2 to generate an alternative pixmap.

Listen to the event IPixmapGenerated to receive a notification about the finished generation of the pixmap.

Protocol Version Hint:

If this method is called with a protocol version less than 61, then queryGenPixmap is called instead.

Specified by:
queryGenPixmap2 in interface IBackend
Parameters:
token - a unique token that is assigned to the generation job.
program - the recording, for which a preview image should be generated
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
QUERY_GENPIXMAP2

queryGenPixmap2

public boolean queryGenPixmap2(String token,
                               IProgramInfo program,
                               Boolean inSeconds,
                               Long time,
                               String fileName,
                               Integer width,
                               Integer height)
                        throws IOException
Description copied from interface: IBackend
Generates a preview image of the requested show.

Usage Hint:

Use queryPixmapLastModified to query the last modified date of the pixmap.
Use queryPixmap to download the pixmap file.

Listen to the event IPixmapGenerated to receive a notification about the finished generation of the pixmap.

Protocol Version Hint:

If this method is called with a protocol version less than 61, then queryGenPixmap is called instead.

Specified by:
queryGenPixmap2 in interface IBackend
Parameters:
token - a unique token that is assigned to the generation job.
program - the recording, for which a preview image should be generated
inSeconds - if true time is in seconds, otherwise it is in frames
time - the seconds or frames into the video to seek before capturing a frame
fileName - the filename to use
width - the preview image width
height - the preview image height
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
QUERY_GENPIXMAP2

queryPixmap

public IPixmap queryPixmap(String previewImageName,
                           String storageGroup)
                    throws IOException
Description copied from interface: IBackend
Queries a preview image.

This function uses IBackend.annotateFileTransfer(String, String) to download the preview image file with the given name.

See queryPixmapLastModified if you just want to determine the last-modified date of the pixmap.
See queryGenPixmap2 on how to generate the pixmap.

Specified by:
queryPixmap in interface IBackend
Parameters:
previewImageName - the name of the pixmap file
storageGroup - the storage group of the pixmap. If null then Default is used.
Returns:
the downloaded preview image or null
Throws:
IOException - on communication errors
See Also:
IMythCommand.ANN_FILE_TRANSFER

queryPixmap

public IPixmap queryPixmap(IProgramInfo program)
                    throws IOException
Description copied from interface: IBackend
Queries a preview image.

Usage Hint:

Use queryPixmapLastModified to determine the last-modified date of the pixmap.
Use queryGenPixmap2 to generate the pixmap.
Use queryPixmap do download a pixmap with a different name.

Protocol Version Hint:

For version prior to 49, this method uses IBackend.annotateFileTransfer(String, String) to download the preview image. For later versions IBackend.queryPixmapIfModified(IProgramInfo, Date, Long) is used.

Specified by:
queryPixmap in interface IBackend
Parameters:
program - the recording whose pixmap should be returned
Returns:
the downloaded preview image or null
Throws:
IOException - on communication errors
See Also:
IMythCommand.QUERY_PIXMAP_GET_IF_MODIFIED, IMythCommand.ANN_FILE_TRANSFER

queryPixmapLastModified

public Date queryPixmapLastModified(IProgramInfo program)
                             throws IOException
Description copied from interface: IBackend
Queries the last-modified date of the pixmap of a given recording.

Usage Hint:

Use queryGenPixmap2 to generate the pixmap.
Use queryPixmap to download the pixmap.

Usage example:


    IBackend backend = ...;      // an already connected backend
    IProgramInfo program = ...;  // a previously recorded program
    
    // get the pixmal last modified date
    Date lastMod = backend.queryPixmapLastModified(program);
    System.out.println(String.format(
       "Pixmap of program '%s' was last modified at '%tc'.",
       program.getTitle(),
       lastMod
    ));
 

Specified by:
queryPixmapLastModified in interface IBackend
Parameters:
program - the recording whose pixmap should be checked.
Returns:
the last-modified date of the pixmap
Throws:
IOException - on communication errors
See Also:
QUERY_PIXMAP_LASTMODIFIED

queryPixmapIfModified

public IPixmap queryPixmapIfModified(IProgramInfo program,
                                     Date lastModifiedDate,
                                     Long maxFileSize)
                              throws IOException
Description copied from interface: IBackend
Queries a preview image.

This command can be used to download a previously generated preview image.
Optionally it can be specified that the preview image should only be returned:

Usage Hint:

Use queryPixmapLastModified if you just want to determine the last-modified date of the pixmap.
Use queryGenPixmap2 to generate the pixmap.

Protocol Version Hint:

If this funtion is called prior to proto version 49, than it uses queryPixmapLastModified to determine the last modified timestamp of the image, and calls annotateFileTransfer afterwards to download the image.

Specified by:
queryPixmapIfModified in interface IBackend
Parameters:
program - the recording whose pixmap should be returned
lastModifiedDate - the last modified date or null if the preview image should be downloaded
maxFileSize - the maximum file size. If this is 0 only the last modified timestamp is returned.
Use null if you do not care about the size.
Returns:
the downloaded preview image or null if the size was exceeded or if an error has occured.
Throws:
IOException - on communication errors
See Also:
QUERY_PIXMAP_GET_IF_MODIFIED

deleteRecording

public boolean deleteRecording(Integer channelID,
                               Date recordingStartTime)
                        throws IOException
Description copied from interface: IBackend
Deletes a recording-file.

This function marks a recording for deletion, following the existing deletion rules, but does not delete the recording metadata and history.

Usage Hint:

Use forceDeleteRecording for also deleting the recording metadata.
Use forgetRecording for also deleting the recording history.

Protocol Version Hint:

If this function is called prior to 41, than the recording is queried uses IBackend.queryRecording(Integer, Date), and IBackend.deleteRecording(IProgramInfo) is called afterwards.

Specified by:
deleteRecording in interface IBackend
Parameters:
channelID - the channel id of the recording
recordingStartTime - the recording-start-time
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
DELETE_RECORDING

deleteRecording

public boolean deleteRecording(IProgramInfo programInfo,
                               Boolean forceMetadatDelete,
                               Boolean forgetHistory)
                        throws IOException
Description copied from interface: IBackend
Delets a recording file, recording metadata and recording history.

This function marks a recording for deletion, following the existing deletion rules. Optionally this function can delete the metadata of a recording and the recording history.

Protocol Version Hint:

If this function is called under the following conditions ...
... then the following functions are called:

Specified by:
deleteRecording in interface IBackend
Parameters:
programInfo - the recording
forceMetadatDelete - forces deletion of recording metadata (since 56)
forgetHistory - forces deletion of recording history (since 59)
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
DELETE_RECORDING

deleteRecording

public boolean deleteRecording(Integer channelID,
                               Date recordingStartTime,
                               Boolean forceMetadatDelete,
                               Boolean forgetHistory)
                        throws IOException
Description copied from interface: IBackend
Delets a recording file, recording metadata and recording history.

This function marks a recording-file for deletion, following the existing deletion rules. Optionally this function can delete the metadata of a recording and the recording history.

Protocol Version Hint:

If this function is called under the following conditions ...
... then the following functions are called:

Specified by:
deleteRecording in interface IBackend
Parameters:
channelID - the channel id of the recording
recordingStartTime - the recording start time
forceMetadatDelete - forces deletion of recording metadata (since 56)
forgetHistory - forces deletion of recording history (since 59)
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
DELETE_RECORDING

deleteRecording

public boolean deleteRecording(IProgramInfo programInfo)
                        throws IOException
Description copied from interface: IBackend
Deletes a recording file.

This function marks a recording for deletion, following the existing deletion rules, but does not delete the recording-metadata and -history.

Usage Hint

Use forceDeleteRecording for also deleting the recording metadata.
Use forgetRecording for also deleting the recording history.

Usage example:


    IBackend backend = ...;      // an already connected backend
    IProgramInfo program = ...;  // a previously recorded program
    
    // delete the recording
    if(backend.deleteRecording(program)) {
       System.out.println(String.format(
          "Recording '%s' successfully deleted.",
          program.getTitle(),
       ));
    } 
 

Specified by:
deleteRecording in interface IBackend
Parameters:
programInfo - the recording to be deleted.
Returns:
true if the backend respond with -1.
Throws:
IOException - on communication errors
See Also:
DELETE_RECORDING

undeleteRecording

public boolean undeleteRecording(IProgramInfo programInfo)
                          throws IOException
Description copied from interface: IBackend
Undelets a recording-file.

This function undeletes a previously deleted recording.

Usage Note:

Undeleting a recording only works if the MythTV property AutoExpireInsteadOfDelete is set to 1 in the MythTV settings table.

Specified by:
undeleteRecording in interface IBackend
Parameters:
programInfo - the recording to undelete
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
UNDELETE_RECORDING

forgetRecording

public boolean forgetRecording(IProgramInfo programInfo)
                        throws IOException
Description copied from interface: IBackend
Delets recording history.

This function deletes the history of a recording but not the recording itself.
The recording is marked as never duplicates, so it can be re-recorded.

This is similar to the option "Forget Old" on MythWeb.

Usage Hint:

Use forceDeleteRecording to also delete the recording-file and recording-metadata.
Use deleteRecording to only delete the recording.

Specified by:
forgetRecording in interface IBackend
Parameters:
programInfo - the recording to forget
Returns:
true on success
Throws:
IOException - on communication errors.
See Also:
FORGET_RECORDING

forgetRecording

public boolean forgetRecording(List<String> programInfo)
                        throws IOException
Throws:
IOException

forceDeleteRecording

public boolean forceDeleteRecording(IProgramInfo programInfo)
                             throws IOException
Description copied from interface: IBackend
Deletes a recording-file and recording metadata.

This command forces the backend to delete a recording and its metadata.
See IBackend.forgetRecording(IProgramInfo) to also delete the recording-history.

Usage Hint:

Use forgetRecording to just delete the recording history.
Use deleteRecording to just delete the recording but not the recording metadata.

Specified by:
forceDeleteRecording in interface IBackend
Parameters:
programInfo - the recording to delete
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
FORCE_DELETE_RECORDING

forceDeleteRecording

public boolean forceDeleteRecording(List<String> programInfo)
                             throws IOException
Throws:
IOException

reactivateRecording

public boolean reactivateRecording(IProgramInfo programInfo)
                            throws IOException
Description copied from interface: IBackend
Reactivates a inactive recording.

This function allows inactive recordings to be reactivated.

This can be used fro things like restarting a program that was stopped or deleted in progress or starting a program after correcting a low disk space or tuner busy condition.

Protocol Version Hint:

Starting with protocol version 19, a recording can be only reactivated by setting the reactivate property in database table oldrecorded.

Specified by:
reactivateRecording in interface IBackend
Throws:
IOException - on communication errors
See Also:
REACTIVATE_RECORDING

reactivateRecording

public boolean reactivateRecording(List<String> programInfo)
                            throws IOException
Throws:
IOException

rescheduleAllRecordings

public boolean rescheduleAllRecordings()
                                throws IOException
Description copied from interface: IBackend
Force MythTV to reschedule all recordings.

This should be called if you have manually inserted a recording into the record table.

Specified by:
rescheduleAllRecordings in interface IBackend
Returns:
true if rescheduling command was received successfully.
Throws:
IOException - on communication errors
See Also:
RESCHEDULE_RECORDINGS

rescheduleRecordings

public boolean rescheduleRecordings(Integer recordID)
                             throws IOException
Description copied from interface: IBackend
Force MythTV to reschedule the given recording.

This should be called if you have manually inserted a recording into the record table.

Specified by:
rescheduleRecordings in interface IBackend
Parameters:
recordID - the ID of the recording to reschedule (see IProgramInfo.getRecordingId().
null or -1 forces the backend to reschedule all recordings.
Use 0 if the change isn't specific to a single record entry (e.g. channel or record type priorities)
Returns:
true if rescheduling command was transmitted successfully.
Throws:
IOException - on communication errors
See Also:
RESCHEDULE_RECORDINGS

rescheduleRecordingsMatch

public boolean rescheduleRecordingsMatch(Integer recordID,
                                         Integer sourceID,
                                         Integer multiplexID,
                                         Date maxStartTime,
                                         String reason)
                                  throws IOException
Specified by:
rescheduleRecordingsMatch in interface IBackend
Returns:
Throws:
IOException
See Also:
RESCHEDULE_RECORDINGS

rescheduleAllRecordingsAndWait

public Boolean rescheduleAllRecordingsAndWait(long timeout,
                                              TimeUnit unit)
                                       throws IOException,
                                              InterruptedException,
                                              IllegalStateException
Description copied from interface: IBackend
Forces MythTV to reschedule all recordings and thereafter to wait for an SCHEDULE_CHANGE event.

Usage Note

If the current connection needs to be in the events-listening modes EPlaybackSockEventsMode.NORMAL or EPlaybackSockEventsMode.NON_SYSTEM, otherwise an IllegalStateException is thrown.

Specified by:
rescheduleAllRecordingsAndWait in interface IBackend
Returns:
true if rescheduling command was transmitted and the rescheduling was done successfully, or null if the specified waiting time elapses before the rescheduling process finished.
Throws:
IOException - on communication errors
InterruptedException - if interrupted while waiting.
IllegalStateException - if the connection was not annotated with the proper events-listening-mode.

rescheduleRecordingsAndWait

public Boolean rescheduleRecordingsAndWait(Integer recordID,
                                           long timeout,
                                           TimeUnit unit)
                                    throws IOException,
                                           InterruptedException,
                                           IllegalStateException
Description copied from interface: IBackend
Forces MythTV to reschedule a given recording and waits for an SCHEDULE_CHANGE event.

Usage Note:

If the current connection needs to be in the events-listening modes EPlaybackSockEventsMode.NORMAL or EPlaybackSockEventsMode.NON_SYSTEM, otherwise an IllegalStateException is thrown.

Usage example:


    IBackend backend = ...;      // an already connected backend
    Integer recordingId = ...;   // the id of a modfied scheduling rule
    
    // signal the backend to reschedule the recording and wait for
    // the rescheduling process to finish.
    long timeoutSeconds = 5;
    Boolean rescheduled = backend.rescheduleRecordingsAndWait(recordingId,timeoutSeconds,TimeUnit.SECONDS);
    if(rescheduled == null) {
       System.err.println(String.format(
          "The backend did not finish rescheduling for recording-id %d within %d %s",
          recordingId, Long.valueOf(timeoutSeconds),TimeUnit.SECONDS
       ));
    } else if (!rescheduled.booleanValue()) {
       System.err.println(String.format(
          "Unable to transmit the reschedule-recordings command for recording-id %d to the backend.",
          recordingId
       ));
    } else {
       System.err.println(String.format(
          "Rescheduling for recording-id %d was done successfully.",
          recordingId
       ));
    } 
 

Specified by:
rescheduleRecordingsAndWait in interface IBackend
Parameters:
recordID - the ID of the recording to reschedule (see IProgramInfo.getRecordingId(). null or -1 forces the backend to reschedule all recordings.
Returns:
true if rescheduling command was transmitted and the rescheduling was done successfully, or null if the specified waiting time elapses before the rescheduling process finished.
Throws:
IOException - on communication errors
InterruptedException - if interrupted while waiting.
IllegalStateException - if the connection was not annotated with the proper events-listening-mode.

rescheduleRecordingsMatchAndWait

public Boolean rescheduleRecordingsMatchAndWait(Integer recordID,
                                                Integer sourceID,
                                                Integer multiplexID,
                                                Date maxStartTime,
                                                String reason,
                                                long timeout,
                                                TimeUnit unit)
                                         throws IOException,
                                                InterruptedException,
                                                IllegalStateException
Specified by:
rescheduleRecordingsMatchAndWait in interface IBackend
Throws:
IOException
InterruptedException
IllegalStateException

getFreeSpaceOverview

public IBasicFreeSpace getFreeSpaceOverview()
                                     throws IOException
Description copied from interface: IBackend
Gets the free space on the backend.

Protocol Version Hint:

Depending on the used MythTV-protocol, this function uses a different myth-protocol command.
Protocol [min,max) Used function
Min Max
00 17 IBackend.queryFreeSpace()
17 32 IBackend.queryFreeSpaceList(boolean)
32 - IBackend.queryFreeSpaceSummary()

Usage Example:


    // the connected backend
    IBackend backend = ...;
    
    // query the used space
    IBasicFreeSpace freeSpaceOverview = backend.getFreeSpaceOverview();
    System.out.println(String.format(
       "MythTV has used %d space out of %d.", 
       freeSpaceOverview.getTotalSpace(),
       freeSpaceOverview.getUsedSpace()
    ));
 

Specified by:
getFreeSpaceOverview in interface IBackend
Returns:
the free space overview
Throws:
IOException - on communication errors
See Also:
IBackend.queryFreeSpace(), IBackend.queryFreeSpaceList(boolean), IBackend.queryFreeSpaceSummary(), QUERY_FREESPACE, QUERY_FREE_SPACE_LIST, QUERY_FREE_SPACE_SUMMARY

queryFreeSpace

public FreeSpace queryFreeSpace()
                         throws IOException
Deprecated. 17

Description copied from interface: IBackend
Geturns the free space on the backend.

Protocol Version Hint:

If this method is called for versions greater or equal to 17, then IBackend.queryFreeSpaceSummary() is used.

Specified by:
queryFreeSpace in interface IBackend
Returns:
the free space
Throws:
IOException - on communication errors
See Also:
QUERY_FREESPACE

queryFreeSpaceList

public FreeSpaceList queryFreeSpaceList(boolean allhosts)
                                 throws IOException
Description copied from interface: IBackend
Returns the free disk space on the connected or on all MythTV backends.

Usage example:


    // query freespace for all hosts
    IFreeSpaceList freeSpaceList = backend.queryFreeSpaceList(true);
    
    // print the summary
    System.out.println(String.format(
       "MythTV has used %s space out of %s used on %d storage groups.",
       EncodingUtils.getFormattedFileSize(freeSpaceList.getUsedSpace()),
       EncodingUtils.getFormattedFileSize(freeSpaceList.getTotalSpace()),
       freeSpaceList.size()
    ));
    
    // print details for each storage group
    for (IFreeSpaceListEntry entry : freeSpaceList) {
       System.out.println(String.format(
          "- %s : %s space out of %s used",
          entry.getDirectories(),
          EncodingUtils.getFormattedFileSize(entry.getUsedSpace()),
          EncodingUtils.getFormattedFileSize(entry.getTotalSpace())
       ));
    }
 
The above example will output, e.g.
 MythTV has used 3,17 GB space out of 3,72 GB used on 2 storage groups.
 - [mythbox:/mnt/data/mythpinky] : 3,14 GB space out of 3,58 GB used
 - [mythbox:/var/lib/mythtv/livetv, mythbox:/var/lib/mythtv/recordings] : 28,00 MB space out of 137,93 MB used
 

Specified by:
queryFreeSpaceList in interface IBackend
Parameters:
allhosts - if the disk space status of all backends should be returned. if this is false only the current connected backend is returned.
Returns:
the disk space for all backends and a additional summary.
Throws:
IOException - on communication errors
See Also:
QUERY_FREE_SPACE_LIST, QUERY_FREE_SPACE

queryFreeSpaceSummary

public FreeSpaceSummary queryFreeSpaceSummary()
                                       throws IOException
Description copied from interface: IBackend
Returns the free space on the connected backend.

Specified by:
queryFreeSpaceSummary in interface IBackend
Returns:
the free space summary
Throws:
IOException - on communication errors
See Also:
QUERY_FREE_SPACE_SUMMARY

queryLoad

public ILoad queryLoad()
                throws IOException
Description copied from interface: IBackend
Queries the current load of the backend.

Specified by:
queryLoad in interface IBackend
Returns:
the load information
Throws:
IOException - on communication errors
See Also:
QUERY_LOAD

queryUptime

public IUptime queryUptime()
                    throws IOException
Description copied from interface: IBackend
Queries the uptime of the backend.

Specified by:
queryUptime in interface IBackend
Returns:
the uptime-info of the backend
Throws:
IOException - on communication errors
See Also:
QUERY_UPTIME

queryMemStats

public IMemStats queryMemStats()
                        throws IOException
Description copied from interface: IBackend
Queries the current memory state of the backend.

Specified by:
queryMemStats in interface IBackend
Returns:
the current memory state of the backend
Throws:
IOException - on communication errors
See Also:
QUERY_MEMSTATS

queryGuideDataThrough

public GuideDataThrough queryGuideDataThrough()
                                       throws IOException
Description copied from interface: IBackend
Queries the guide-date status of the backend.

Usage example:


    IGuideDataThrough data = backend.queryGuideDataThrough();
    
    System.out.println(String.format(
       "There's guide data until %1$tF %1$tT (%2$d days).",
       data.getDate(),
       EncodingUtils.getMinutesDiff(new Date(), data.getDate()) / 60 / 24
    ));
  

Specified by:
queryGuideDataThrough in interface IBackend
Returns:
the guide-data status.
Throws:
IOException - on communication errors
See Also:
QUERY_GUIDEDATATHROUGH

queryIsRecording

public IRecordingStatus queryIsRecording()
                                  throws IOException
Description copied from interface: IBackend
Queries the current recording status of the backend. The status object contains the amount of current-recordings and live-tv-session.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // query recording status
    IRecordingStatus recordingStatus = backend.queryIsRecording();
    System.out.println(String.format(
       "MythTV has %d active recordings. %d are Live-TV recordings.", 
       recordingStatus.getActiveRecordings(),
       recordingStatus.getLiveTVRecordings()
    ));
  

Specified by:
queryIsRecording in interface IBackend
Returns:
the recording status containing the amount of current-recordings and live-tv-session
Throws:
IOException - on communication errors
See Also:
QUERY_ISRECORDING

queryAllPending

public RecordingsPending queryAllPending()
                                  throws IOException
Description copied from interface: IBackend
Gets all programs that will be recorded soon.

Usage Hint:

Use queryAllScheduled to get all scheduled recordings.
Use queryConflicting to get all conflicting recordings.
Use queryRecordings to get all finished recordings.
Use queryExpiring to get all expiring recordings.

Usage Example:


       IBackend backend = ....;     // an already connected backend
       
       // get all pending recordings
       IRecordingsPending pendingRecords = backend.queryAllPending();
       for (IProgramInfo program : pendingRecords) {
          // we are only interrested in recordings with "WILL_RECORD" status
          IProgramRecordingStatus recStatus = program.getRecordingStatus();
          if(recStatus != null && !recStatus.hasStatus(Status.WILL_RECORD)) continue;
          
          // print out the found recodings
          System.out.println(String.format(
             "%1$tF %1$tT - %2$s (%3$s)",
             program.getStartDateTime(),
             program.getTitle(),
             program.getChannelSign()
          ));
       }
  

The above example will output, e.g.

 MythTV has 4 pending records
 2011-04-17 18:10:00 - Die Simpsons (PRO7)
 2011-04-17 20:15:00 - 10.000 BC (PRO7)
 2011-04-18 22:15:00 - Roter Drache (ZDF)
 2011-04-21 20:15:00 - Dr. House (ORF1)
 

Specified by:
queryAllPending in interface IBackend
Returns:
a list of scheduled programs. If IRecordings.size() returns 0, no scheduled programs were found.
Throws:
IOException - on communication errors
See Also:
QUERY_GETALLPENDING

queryAllScheduled

public RecordingsScheduled queryAllScheduled()
                                      throws IOException
Description copied from interface: IBackend
Gets all scheduled recordings.

Usage Hint:

Use queryAllPending to get all pending recordings.
Use queryConflicting to get all conflicting recordings.
Use queryRecordings to get all finished recordings.
Use queryExpiring to get all expiring recordings.

Usage example


 
       IBackend backend = ....;     // an already connected backend
       
       // getting all recording schedules
       IRecordingsScheduled scheduledRecords = backend.queryAllScheduled();
       System.out.println(String.format("MythTV has %d recording schedules:", scheduledRecords.size()));
       System.out.println(String.format(
          "%-35s | %-4s | %-7s | %-15s | %-22s | %-15s",
          "Title","Prio","Channel","Recording Group","Type","Storage Group"
       ));
       
       // print all scheduled recordings
       for (IProgramInfo program : scheduledRecords) {
          System.out.println(String.format(
             "%-35s | %4d | %-7s | %-15s | %-22s | %-15s",
             program.getTitle(),
             program.getRecordingPriority(),
             program.getChannelSign(),
             program.getRecordingGroup(),
             program.getRecordingType(),
             program.getStorageGroup()
          ));		
       }
  

The above example will output, e.g.

 MythTV has 6 recording schedules:
 Title                               | Prio | Channel | Recording Group | Type                   | Storage Group  
 10.000 BC                           |    0 | PRO7    | Default         | 6=> {FIND_ONE_RECORD}  | Default       
 Die Simpsons                        |    0 | PRO7    | Default         | 3=> {CHANNEL_RECORD}   | Default        
 Dr. House                           |    0 | ORF1    | Default         | 5=> {WEEKSLOT_RECORD}  | Default        
 Fantastic Four: Rise of the Silver  |    0 | ORF1    | Default         | 6=> {FIND_ONE_RECORD}  | Default        
 Geisterhaus (Title Suche)           |    0 | PRO7    | Default         | 6=> {FIND_ONE_RECORD}  | Default              
 Stieg Larsson (Title Suche)         |    5 | PRO7    | Default         | 4=> {ALL_RECORD}       | Default 
 

Specified by:
queryAllScheduled in interface IBackend
Returns:
a list of scheduled recordings. If IRecordings.size() returns 0, no scheduled programs were found.
Throws:
IOException - on communication errors
See Also:
QUERY_GETALLSCHEDULED

queryExpiring

public RecordingsExpiring queryExpiring()
                                 throws IOException
Description copied from interface: IBackend
Gets all programs that will expiring soon.

Usage Hint:

Use queryAllScheduled to get all scheduled recordings.
Use queryAllPending to get all pending recordings.
Use queryConflicting to get all conflicting recordings.
Use queryRecordings to get all finished recordings.

Protocol Version Hint:

If this method is used prior to 23, then IBackend.queryRecordings() is used and the expiring recordings are filtered using the program-flag-filter.

Usage example:


In the example shown below we fetch the list of expiring recordings, print their names and the sum of disk space used by all expiring recordings.

    // fetch all expiring recordings
    IRecordingsExpiring expiringRecords = backend.queryExpiring();
    long spaceUsed = 0;
    
    // print names of expiring recordings
    System.out.println("Expiring records:");
    for(IProgramInfo program : expiringRecords) {
       spaceUsed += program.getFileSize().longValue();
       System.out.println("- " + program.getFullTitle());
    }
    
    // print disk space used by expiring recordings
    System.out.println(String.format(
       "%s used by %d expiring recordings.",
       EncodingUtils.getFormattedFileSize(spaceUsed),
       expiringRecords.size()
    ));
  

The above example will output, e.g.

 Expiring records:
 - King of Queens - E-Mail für dich
 - King of Queens - Wilde Bullen
 - WALL-E - Der Letzte räumt die Erde auf
 9,82 GB used by 3 expiring recordings.
 

Specified by:
queryExpiring in interface IBackend
Returns:
a list of expiring programs. If IRecordings.size() returns 0, no expiring programs were found.
Throws:
IOException - on communication errors
See Also:
QUERY_GETEXPIRING

queryConflicting

public RecordingsConflicting queryConflicting()
                                       throws IOException
Description copied from interface: IBackend
Gets all programs that are in conflict which each other.

Usage Hint:

Use queryAllScheduled to get all scheduled recordings.
Use queryAllPending to get all pending recordings.
Use queryRecordings to get all finished recordings.
Use queryExpiring to get all expiring recordings.

Protocol Version Hint:

Starting with protocol version 57, the backend seens not to return a conflicting recording anymore, without specifying a recording as input parameter. Therefore starting with version 57 we all pending recordings and use a status-filter to get all conflicting recordings.

Usage example:


    // query all conflicting recordings
    IRecordingsConflicting conflictingRecordings = backend.queryConflicting();
    if(!conflictingRecordings.isEmpty()) {
       System.out.println(String.format(
          "%d conflicting records:", 
          conflictingRecordings.size()
       ));
       
       // print all conflicting recordings
       for(IProgramInfo program : conflictingRecordings) {
          System.out.println(String.format(
             "+-- %1$tF %1$tT - %2$s (%3$s)",
             program.getStartDateTime(),
             program.getFullTitle(),
             program.getChannelSign()
          ));
          
          // fetch all recordings the current recording is in conflict with
          IRecordingsConflicting others = backend.queryConflicting(program);
          for(IProgramInfo other : others) {
             System.out.println(String.format(
                "  | %1$tF %1$tT - %2$s (%3$s)",
                other.getStartDateTime(),
                other.getFullTitle(),
                other.getChannelSign()
             ));
          }
       }
    }
  
The above example will output, e.g.
 1 conflicting records:
 +-- 2012-01-10 09:30:00 - Scrubs - Meine Sitcom (PRO7)
   | 2012-01-10 09:30:00 - Mitten im Leben! (RTL)
   | 2012-01-10 09:30:00 - Das Traumhotel (ARD)
 

Specified by:
queryConflicting in interface IBackend
Returns:
a list of conflicting programs. If IRecordings.size() returns 0, no conflicts were found
Throws:
IOException - on communication errors
See Also:
QUERY_GETCONFLICTING

queryConflicting

public RecordingsConflicting queryConflicting(IProgramInfo programInfo)
                                       throws IOException
Description copied from interface: IBackend
Gets all programs that are in conflict with the given program.

Usage Hint:

Use queryConflicting if you need to check all pending recordings for conflicts.

Specified by:
queryConflicting in interface IBackend
Parameters:
programInfo - the program to check
Returns:
a list of conflicting programs. If IRecordings.size() returns 0, no conflicts were found
Throws:
IOException - on communication errors
See Also:
QUERY_GETCONFLICTING

isActiveBackend

public boolean isActiveBackend()
                        throws IOException
Description copied from interface: IBackend
Checks if the current backend is active.

This function internally uses IBackend.queryHostname() to determine the hostname of the connected backend and thereafter calls IBackend.isActiveBackend(String) with this hostname.

Specified by:
isActiveBackend in interface IBackend
Returns:
true if the given backend is active.
Throws:
IOException - on communication errors
See Also:
QUERY_IS_ACTIVE_BACKEND

isActiveBackend

public boolean isActiveBackend(String hostname)
                        throws IOException
Description copied from interface: IBackend
Checks if the given backend is active.

This function can be used on master backends to checks the activation status of slave backends, which has been connected to the master using ANN SlaveBackend.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // the hostname of a backend to check
    String slaveBackendName = "mythbox2";
    
    // checking the is-active status
    boolean isActiveBackend = backend.isActiveBackend(slaveBackendName);
    System.out.println(String.format(
       "The backend '%s' is currently ",
       slaveBackendName,
       (isActiveBackend?"active":"idle")
    ));
 

Specified by:
isActiveBackend in interface IBackend
Parameters:
hostname - the hostname of the backend. This must be the hostname of the mythtv box, using the IP-address seems not to work
Returns:
true if the given backend is active.
Throws:
IOException - on communication errors
See Also:
QUERY_IS_ACTIVE_BACKEND

queryActiveBackends

public List<String> queryActiveBackends()
                                 throws IOException
Description copied from interface: IBackend
Queries the names of all active backends.

This function returns the names of all currently active backends.

Specified by:
queryActiveBackends in interface IBackend
Returns:
a list containing the names of all active backends
Throws:
IOException - on communication errors
See Also:
QUERY_ACTIVE_BACKENDS

refreshBackend

public boolean refreshBackend()
                       throws IOException
Description copied from interface: IBackend
Forces the backend to reload the backend settings.

Specified by:
refreshBackend in interface IBackend
Returns:
true if the backend has reload the backend-settings successfully.
Throws:
IOException - on communication errors

queryCheckFile

public FileStatus queryCheckFile(IProgramInfo programInfo,
                                 Boolean checkSlaves)
                          throws IOException
Description copied from interface: IBackend
Checks if a recording file exists that belongs to the given program.

Usage Hint:

Use queryFileExists to check the existance of a non recording file, e.g. a preview-image or a channel-logo.

Usage Example:


      IBackend backend = ....;       // an already connected backend
      IProgramInfo recording = ....; // a previously recorded program
      
      // check if the file exists
      IFileStatus fileStatus = backend.queryCheckFile(recording);
      if(fileStatus.fileExists()) {
         System.out.println("Recording file found.");
      } else {
         System.out.println("Recording file not found.");
      }
  

Specified by:
queryCheckFile in interface IBackend
Parameters:
programInfo - the given program
checkSlaves - specifies if all slaves should be checked too. (Since 32)
Returns:
detailed information about the found file or null
Throws:
IOException - on communication errors
See Also:
QUERY_CHECKFILE

queryFileExists

public FileStatus queryFileExists(IProgramInfo programInfo)
                           throws IOException
Description copied from interface: IBackend
Checks if a recording-file exists for the given program.

Protocol Version Hint:

If this function is called prior to protocol version 49, then function queryCheckFile is used instead.

Specified by:
queryFileExists in interface IBackend
Parameters:
programInfo - the program for which the file should be searched
Returns:
detailed information about the found file or null
Throws:
IOException - on communication errors
See Also:
IBackend.queryFileExists(String, String), QUERY_FILE_EXISTS

queryFileExists

public FileStatus queryFileExists(URI fileUrl)
                           throws IOException
Description copied from interface: IBackend
Checks if given file exists on the backend.

This method calls URI.getUserInfo() and URI.getPath() to determine the storage-group and file-name and calls IBackend.queryFileExists(String, String) afterwards.

Specified by:
queryFileExists in interface IBackend
Parameters:
fileUrl - the remote file
Returns:
detailed information about the found file or null
Throws:
IOException - on communication errors
See Also:
QUERY_FILE_EXISTS, IBackend.queryFileExists(String, String)

queryFileExists

public FileStatus queryFileExists(String fileName,
                                  String storageGroup)
                           throws IOException
Description copied from interface: IBackend
Checks if a the named file exists in the named storage group.

Protocol Version Hint:

If this function is called prior to protocol version 49, then function IFileTransfer.isOpen() is used to determine the file exists status.

Usage example:


      IBackend backend = ....;     // an already connected backend
      IProgramInfo program = ....; // a previously recorded program
      
      // query if the preview image exists
      String previewImageName = program.getPreviewImageName();
      IFileStatus fileStatus = backend.queryFileExists(previewImageName,"Default");	
      if (fileStatus.fileExists()) {
         System.out.println("Preview image found: " + fileStatus.getFilePath());
      } else {
         System.out.println("Preview image not found.");
      }
 

Specified by:
queryFileExists in interface IBackend
Parameters:
fileName - the remote file name
storageGroup - the storage group name, or null to search in the default group
Returns:
detailed information about the found file or null
Throws:
IOException - on communication errors
See Also:
QUERY_FILE_EXISTS

queryFileHash

public String queryFileHash(IProgramInfo programInfo)
                     throws IOException
Description copied from interface: IBackend
Queries a unique hash-value for the recording-file of the given program.

Specified by:
queryFileHash in interface IBackend
Parameters:
programInfo - the program referencing a file, for which the file hash should be generated.
Returns:
the generated hash-value, e.g. 75aa72141cd08662
Throws:
IOException - on communication errors
See Also:
IBackend.queryFileHash(String, String, String), QUERY_FILE_HASH

queryFileHash

public String queryFileHash(String fileName,
                            String storageGroup)
                     throws IOException
Description copied from interface: IBackend
Queries a unique hash-value for the given file stored in the given storage group.

Usage Hint:

To compate the remotely calculated has with a locally generated one, the class OpenSubtitlesHasher could be used.

Specified by:
queryFileHash in interface IBackend
Parameters:
fileName - the remote file name
storageGroup - the storage group name, or null if the default group should be used
Returns:
the generated hash-value, e.g. 75aa72141cd08662
Throws:
IOException - on communication errors
See Also:
QUERY_FILE_HASH

queryFileHash

public String queryFileHash(URI fileUrl)
                     throws IOException
Description copied from interface: IBackend
Queries a unique hash-value for the given remote file.

This method calls URI.getUserInfo(), URI.getHost() and URI.getPath() to determine the storage-group, host-name and file-name and calls IBackend.queryFileHash(String, String, String) afterwards.

Usage Hint:

To compate the remotely calculated has with a locally generated one, the class OpenSubtitlesHasher could be used.

Specified by:
queryFileHash in interface IBackend
Parameters:
fileUrl - the remote file
Returns:
the generated hash-value, e.g. 75aa72141cd08662
Throws:
IOException - on communication errors
See Also:
QUERY_FILE_HASH

queryFileHash

public String queryFileHash(String fileName,
                            String storageGroup,
                            String hostName)
                     throws IOException
Description copied from interface: IBackend
Queries a unique hash-value for the given file stored in the given storage group.

Usage Hint:

To compate the remotely calculated has with a locally generated one, the class OpenSubtitlesHasher could be used.

Specified by:
queryFileHash in interface IBackend
Parameters:
fileName - the remote file name
storageGroup - the storage group name, or null if the default group should be used
hostName - the name of the backend, storing the file. (since 69). If this is null the current backend will be queried.
Returns:
the generated hash-value, e.g. 75aa72141cd08662
Throws:
IOException - on communication errors
See Also:
QUERY_FILE_HASH

queryStorageGroupFile

public StorageGroupFile queryStorageGroupFile(String hostName,
                                              String storageGroup,
                                              String fileName)
                                       throws IOException
Description copied from interface: IBackend
Queries the a single file from the remote storage group.

Protocol Version Hint:

For protocol versions prior to 58 the given file-path must be an absolute path. If the path is not absolute, IBackend.queryFileExists(String, String) is used to determine the proper absolute path.

Usage example:


     IBackend backend = ...;     // an already connected backend
     IProgramInfo program = ...; // a previously recorded program
     
     // getting all required parameters
     String hostName = program.getHostName();
     String storageGroup = program.getStorageGroup();
     String previewFileName = program.getPreviewImageName();
     
     // query infos about the recording preview image
     IStorageGroupFile previewFile = backend.queryStorageGroupFile(hostName,storageGroup,previewFileName);
     if(previewFile != null) {
        System.out.println(String.format(
           "Preview image path: '%s', last-modified date: '%tF', file-size: '%d'.",
           previewFile.getFilePath(),
           previewFile.getLastModified(),
           previewFile.getSize()
        ));	
     } else {
        System.err.println("Preview image not found");
     }
 

Specified by:
queryStorageGroupFile in interface IBackend
Parameters:
hostName - the backend host to query. if null the result of IBackend.queryHostname() is used to determine the hostname.
storageGroup - the storage group name. If null Default is used.
fileName - the file name to search for. Till 58 this path must be an absolute path.
Returns:
information about the found file or null
Throws:
IOException - on communication errors
See Also:
QUERY_SG_FILEQUERY

queryStorageGroupFileList

public IStorageGroupFileList queryStorageGroupFileList(String hostName,
                                                       String storageGroup,
                                                       String path)
                                                throws IOException
Description copied from interface: IBackend
Queries the a list of files from the remote storage group.

Usage example:


     IBackend backend = ....; // an already connected backend
     
     // query all files stored in the storage-group "Default"
     String hostName = backend.queryHostname();
     IStorageGroupFileList fileList = backend.queryStorageGroupFileList(hostName, "Default", "/", true);
     if(fileList != null) {
         // loop through all found files
         for(IStorageGroupFile file : fileList) {
             // fetch the program info for all found recordings
             final String fileName = file.getFilePath(); // e.g. 1064_20110403184000.mpg			
             if(fileName.matches("\\d+_\\d+\\.mpg")) {
                 // fetch the program info for the recording file
                 IProgramInfo program = backend.queryRecording(fileName);
                 if(program != null) {
                    System.out.println(program);
                 }
             }
         }
     }
  

Specified by:
queryStorageGroupFileList in interface IBackend
Parameters:
hostName - the backend host to query. If this is null IBackend.queryHostname() is used to determine the hostname.
storageGroup - the storage group name. If this is null Default is used.
path - the path to query
Returns:
informations about the found file or null
Throws:
IOException - on communication errors

queryStorageGroupFileList

public StorageGroupFileList queryStorageGroupFileList(String hostName,
                                                      String storageGroup,
                                                      String path,
                                                      boolean fileNamesOnly)
                                               throws IOException
Description copied from interface: IBackend
Queries the a list of files from the remote storage group.

Specified by:
queryStorageGroupFileList in interface IBackend
Parameters:
hostName - the backend host to query. If this is null IBackend.queryHostname() is used to determine the hostname.
storageGroup - the storage group name. If this is null Default is used.
path - the path to query
fileNamesOnly - if only the file names should be returned. (since 49)
Returns:
informations about the found file or null
Throws:
IOException - on communication errors

queryTimeZone

public ITimezone queryTimeZone()
                        throws IOException
Description copied from interface: IBackend
Queries the timezone of the backend.

Specified by:
queryTimeZone in interface IBackend
Returns:
the timezone of the backend
Throws:
IOException - on communication errors
See Also:
QUERY_TIME_ZONE

goToSleep

public boolean goToSleep()
                  throws IOException
Description copied from interface: IBackend
Signals a slave backend to go to sleep.

Specified by:
goToSleep in interface IBackend
Returns:
true if the backend went to sleep or false otherwise
Throws:
IOException - on communication errors
See Also:
GO_TO_SLEEP

queryHostname

public String queryHostname()
                     throws IOException
Description copied from interface: IBackend
Gets the hostname of the backend.

Protocol Version Hint:

If this function is called prior to version 50, and the current backend connection was established using an IP-address, this function compares the backend IP adress with the addresses of all recorders, to determine the proper host-name.
If the current backend connection was established using a hostname, the result of IBackend.getHostName() is returned.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // query the backends host name
    String backendHostName = backend.queryHostname();
    System.out.println("We are connected to backend: " + backendHostName);
 

Specified by:
queryHostname in interface IBackend
Returns:
the hostname of the backend.
Throws:
IOException - on communication errors
See Also:
QUERY_HOSTNAME

blockShutdown

public Boolean blockShutdown()
                      throws IOException
Description copied from interface: IBackend
Prevents a backend from shutting down.

This function prevents a backend from shutting down until a the next call of IBackend.allowShutdown().

Specified by:
blockShutdown in interface IBackend
Returns:
true if the backed has accepted the request
Throws:
IOException - on communication errors
See Also:
BLOCK_SHUTDOWN

allowShutdown

public Boolean allowShutdown()
                      throws IOException
Description copied from interface: IBackend
Allows a backend to shutdown.

This function allows a backend to shut down again after a previous call of IBackend.blockShutdown().

Specified by:
allowShutdown in interface IBackend
Returns:
true if the backed has accepted the request
Throws:
IOException - on communication errors
See Also:
ALLOW_SHUTDOWN

shutdownNow

public void shutdownNow()
                 throws IOException
Description copied from interface: IBackend
Forces a slave backend to shutdown now.

Specified by:
shutdownNow in interface IBackend
Throws:
IOException - on communication errors
See Also:
SHUTDOWN_NOW

querySetting

public Setting querySetting(String hostName,
                            String settingName)
                     throws IOException
Description copied from interface: IBackend
Queries the remote host for a specific setting.

The backend will look in the MySQL database table 'settings', and attempt to return the value for the given setting. It seems only settings with the hostname set can be retrieved by this call.

Usage Hints:

Use setSetting to change backend settings.

Specified by:
querySetting in interface IBackend
Parameters:
hostName - the name of the host, the setting belongs to. This can not be null.
settingName - the name of the setting to query
Returns:
the found settings-value or null if the setting was not found.
Throws:
IOException - on communication errors

setSetting

public boolean setSetting(String hostName,
                          String settingName,
                          String settingValue)
                   throws IOException
Description copied from interface: IBackend
Sets the given setting on the remote host.

Usage Hints:

Use querySetting to read backend settings.
Use clearSettingsCache to notify the backend about changed settings.

Specified by:
setSetting in interface IBackend
Parameters:
hostName - the name of the host, the setting belongs to
settingName - the name of the setting to change
settingValue - the new setting value
Returns:
true if the setting-value was changed successfully.
Throws:
IOException - on communication errors
See Also:
SET_SETTING

clearSettingsCache

public void clearSettingsCache()
                        throws IOException
Description copied from interface: IBackend
Forces the backend to clear its settings cache.

This command should be used after changing any backend settings and forces the backend to reload settings from the database (for example, using MythWeb or Mythtv-setup).

Usage Hints:

Use setSetting to change backend settings.
Use querySetting to read backend settings.

Specified by:
clearSettingsCache in interface IBackend
Throws:
IOException - on communication errors
See Also:
BACKEND_MESSAGE_CLEAR_SETTINGS_CACHE

lockTuner

public ITunerInfo lockTuner()
                     throws IOException
Description copied from interface: IBackend
Asks the backend to lock the next free tuner.

ATTENTION: This only works if your frontend is on the same machine as one of the available tuners.

Usage Hints:

Use freeTuner to unlock a tuner.

Specified by:
lockTuner in interface IBackend
Returns:
informations about the locked tuner
Throws:
IOException - on communication errors
See Also:
IBackend.lockTuner(Integer), LOCK_TUNER

lockTuner

public ITunerInfo lockTuner(Integer recorderID)
                     throws IOException
Description copied from interface: IBackend
Asks the backend to lock the given tuner.

ATTENTION: This only works if your frontend is on the same machine as the tuner you are trying to lock.

Usage Hints:

Use freeTuner to unlock a tuner.

Specified by:
lockTuner in interface IBackend
Parameters:
recorderID - the ID of the recorder to lock
Returns:
informations about the locked tuner
Throws:
IOException - on communication errors
See Also:
LOCK_TUNER

freeTuner

public boolean freeTuner(Integer recorderID)
                  throws IOException
Description copied from interface: IBackend
Frees a previously locked tuner.

Usage Hints:

Use lockTuner to lock a tuner.

Specified by:
freeTuner in interface IBackend
Parameters:
recorderID - the ID of the recorder to free
Returns:
true if the recorder was freed successfully or false otherwise
Throws:
IOException - on communication errors
See Also:
FREE_TUNER

fillProgramInfo

public IProgramInfo fillProgramInfo(IProgramInfo programInfo)
                             throws IOException
Description copied from interface: IBackend
Fills in the pathname and file size fields of the given recording.

Specified by:
fillProgramInfo in interface IBackend
Parameters:
programInfo - the recording, whose information should be updated.
Returns:
the given program with the path-name and file-size filled in
Throws:
IOException - on communication errors
See Also:
FILL_PROGRAM_INFO

fillProgramInfo

public IProgramInfo fillProgramInfo(IProgramInfo programInfo,
                                    String playBackHostname)
                             throws IOException
Description copied from interface: IBackend
Fills in the pathname and file size fields of the given recording.

Calling this function converts the path property from e.g. /var/lib/mythtv/livetv/1004_20120113085933.mpg to myth://192.168.10.207:6543/1004_20120113085933.mpg and additionally updates the file size.

Specified by:
fillProgramInfo in interface IBackend
Parameters:
programInfo - the recording, whose information should be updated.
playBackHostname - the name of the playback host
Returns:
the given program with the path-name and file-size filled in
Throws:
IOException - on communication errors
See Also:
FILL_PROGRAM_INFO

checkRecording

public Integer checkRecording(IProgramInfo programInfo)
                       throws IOException
Description copied from interface: IBackend
Checks if the given program is currently being recorded.

This function return the number of the recorder or null, if the program is not being recorded.

Usage Note:

If the backend is not configured properly and therefore returns an empty string in IProgramInfo.getHostName(), this function uses QUERY_REMOTEENCODER_MATCHES_RECORDING to determine the recorder that is recording this program.

Usage example:


    IBackend backend = ...; // an already connected backend
 
    // get all currently running recordings
    IProgramInfoList recordings = backend.queryRecordings(ERecordingsType.Recording);
    for(IProgramInfo recording : recordings) {
      // getting the ID of the recorder recording the program
      Integer recorderId = backend.checkRecording(recording);
      System.out.println(String.format(
         "Recording '%s' (%s) is currently recorded by recorder-ID: %d",
         recording.getTitle(),recording.getChannelSign(),
         recorderId
      ));
    }	
 

Specified by:
checkRecording in interface IBackend
Parameters:
programInfo - the given program
Returns:
the recorder-ID or null
Throws:
IOException - on communication errors
See Also:
CHECK_RECORDING

stopRecording

public Integer stopRecording(IProgramInfo programInfo)
                      throws IOException
Description copied from interface: IBackend
Stop a currently active recording.

Protocol Version Hint:

Prior to protocol version 19 the file-name of a recording is renamed, if the recording is stopping prior to the originally intended end time! So if you are plaining to delete the recording-file in a next step you need to update the file information.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // get all currently running recordings
    IProgramInfoList recordings = backend.queryRecordings(ERecordingsType.Recording);
    for(IProgramInfo recording : recordings) {
      // search for a recording called "Wetter-Panorama"
      if(recording.getTitle().equals("Wetter-Panorama")) {
         // stop the recording
         Integer recorderId = backend.stopRecording(recording);
         System.out.println(String.format(
            "Recording of program '%s' (%s) stopped on recorder %d.",
            recording.getTitle(), recording.getChannelSign(),
            recorderId
         ));
      }
    }
 

Specified by:
stopRecording in interface IBackend
Parameters:
programInfo - the recording to be stopped.
Returns:
the recorder-ID where the recording was stopped, or -1 if the recording is not found.
Throws:
IOException - on communication errors.
See Also:
STOP_RECORDING

getRecorderForProgram

public IRecorderInfo getRecorderForProgram(IProgramInfo programInfo)
                                    throws IOException
Description copied from interface: IBackend
Checks if the given program is currently being recorded and returns the recorder-info for the recorder or null, if it is not being recorded.

This method combines IBackend.checkRecording(IProgramInfo) and IBackend.getRecorderForNum(int).

Usage example:


    IBackend backend = ...; // an already connected backend
    
    // get all currently running recordings
    IProgramInfoList recordings = backend.queryRecordings(ERecordingsType.Recording);
    for(IProgramInfo recording : recordings) {
       // determine the used recorder
       IRecorderInfo recorder = backend.getRecorderForProgram(recording);
       System.out.println(String.format(
          "Recording '%s' (%s) is currently recorded by: %s",
          recording.getTitle(),recording.getChannelSign(),
          recorder.toString()
       ));
    }
  

Specified by:
getRecorderForProgram in interface IBackend
Parameters:
programInfo - the given program
Returns:
the recorder-info object or null
Throws:
IOException - on communication errors
See Also:
IBackend.checkRecording(IProgramInfo), IBackend.getRecorderForNum(int)

queryRecording

public ProgramInfo queryRecording(String baseName)
                           throws IOException
TODO: fallback using a program filter!!!!

Specified by:
queryRecording in interface IBackend
Parameters:
baseName - the base-name of the recorded program-file, e.g. 1057_20100811133747.mpg.
Returns:
the found recording or null if no matching recording was found
Throws:
IOException - on communication errors
See Also:
QUERY_RECORDING

queryRecording

public IProgramInfo queryRecording(IBasicChannelInfo channel,
                                   Date startTime)
                            throws IOException
Description copied from interface: IBackend
Get a single recording by its channel and recording start-time.

This function internally uses IBasicChannelInfo.getChannelID() to get the channel-id of the recording and calls IBackend.queryRecording(Integer, Date) afterwards.

Usage Hint:

Use IBackend.queryRecording(String) to query a recording by base name.

Specified by:
queryRecording in interface IBackend
Parameters:
channel - the channel of the recording
startTime - the recording starting-time, e.g. 2010-08-11T13:37:47.
Returns:
the found recording or null if no matching recording was found
Throws:
IOException - on communication errors
See Also:
IBackend.queryRecording(Integer, Date), QUERY_RECORDING

queryRecording

public IProgramInfo queryRecording(Integer channelID,
                                   Date recordingStartTime)
                            throws IOException
Description copied from interface: IBackend
Get a single recording by its channel-id and start-time.

Usage Hint:

Use IBackend.queryRecording(String) to query a recording by base name.

Protocol Version Hint:

If this function is used for versions prior to 32, then IBackend.queryRecordings() is called to fetch all recordings, and a program-filter is used afterwards to determine the desired recording.

Specified by:
queryRecording in interface IBackend
Parameters:
channelID - the channel-ID, e.g. 1057
recordingStartTime - the recording starting-time, e.g. 2010-08-11T13:37:47
Returns:
the found recording or null if no matching recording was found
Throws:
IOException - on communication errors
See Also:
IBackend.queryRecording(IBasicChannelInfo, Date), QUERY_RECORDING

getBasicChannelInfoMap

public <C extends IBasicChannelInfo> Map<Integer,C> getBasicChannelInfoMap()
                                                                throws IOException
Throws:
IOException

getBasicChannelInfos

public <C extends IBasicChannelInfo> List<C> getBasicChannelInfos()
                                                       throws IOException
Description copied from interface: IBackend
Get a list of all available channels on all available recorders.

Protocol Version Hint:

If the current protocol-version is less than 28 an IBasicChannelInfo object is returned, otherwise an IRecorderChannelInfo object is returned.

Specified by:
getBasicChannelInfos in interface IBackend
Type Parameters:
C - the return type. is is either a IBasicChannelInfo or an IRecorderChannelInfo
Returns:
the list of all available channels
Throws:
IOException - on communication errors
See Also:
IBackend.getChannelInfos(), IBackend.getRecorders(), IRecorder.getBasicChannelInfos()

getChannelInfos

public List<IRecorderChannelInfo> getChannelInfos()
                                           throws IOException
Description copied from interface: IBackend
Get a list of all available channels on all available recorders.

This method internally uses IBackend.getRecorders() to get a list of all known recorders and calls IRecorder.getChannelInfos() for all recorders.

Usage Hint:

Use IRecorder.getChannelInfo to get the info for a single channel
Use setChannelInfo to change the info for a single channel.

Usage example:


    IBackend backend = ...; // an already connected backend
 
    List<IRecorderChannelInfo> channels = backend.getChannelInfos();
    for(IRecorderChannelInfo channel : channels) {
       System.out.println(String.format(
          "%2s | %-15s | %s",
          channel.getChannelNumber(), channel.getChannelSign(),
          channel.getChannelName()
       ));
    }
  

The above example will output, e.g.

  1 | PRO7            | Pro7
  2 | SAT.1           | SAT.1
  3 | RTL             | RTL
  4 | RTL2            | RTL 2
  5 | ARD             | ARD
  6 | ZDF             | ZDF
  7 | KABE1           | Kabel 1
  ...
 

Specified by:
getChannelInfos in interface IBackend
Returns:
a list of all available channels
Throws:
IOException - on communication errors
See Also:
IBackend.getRecorders(), IRecorder.getBasicChannelInfos()

setChannelInfo

public boolean setChannelInfo(String oldChannelNumber,
                              IRecorderChannelInfo channelInfo)
                       throws IOException
Description copied from interface: IBackend
Changes detailed infos about the given channel.

Usage Hint:

Use getChannelInfos to get infos about all known channels.
Use IRecorder.getChannelInfo to get the info for a single channel

Specified by:
setChannelInfo in interface IBackend
Parameters:
oldChannelNumber - the old channel number
channelInfo - the new channel info
Returns:
true if channel data was changed successfully.
Throws:
IOException - on communication errors
See Also:
SET_CHANNEL_INFO

getNextProgramInfos

public List<IRecorderNextProgramInfo> getNextProgramInfos(Date date)
                                                   throws IOException
Description copied from interface: IBackend
Gets the next programs of all known channels.

This method internally uses IBackend.getRecorders() to get a list of all known recorders and calls IRecorder.getNextProgramInfos(Date) for all recorders.

Usage example:


    IBackend backend = ...; // an already connected backend
    
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY,20);
    cal.set(Calendar.MINUTE,15);
    
    // fetch the programs of all channels today at 8:15 PM
    List<IRecorderNextProgramInfo> nextPrograms = backend.getNextProgramInfos(cal.getTime());
    for(IRecorderNextProgramInfo nextProgram : nextPrograms) {
       if(!nextProgram.isValid()) continue; // if there is no valid program info for a channel
       
       System.out.println(String.format(
          "%tT | %tT | %-15s | %s",
          nextProgram.getStartDateTime(), nextProgram.getEndDateTime(),
          nextProgram.getChannelSign(), nextProgram.getTitle()
       ));
    }
  

The above example will output, e.g.

 20:15:01 | 23:05:01 | RTL             | Harry Potter und der Stein der Weisen
 20:15:01 | 21:15:01 | SAT.1           | Navy CIS
 20:15:01 | 21:45:01 | ARD             | Tatort
 20:15:01 | 21:45:01 | ZDF             | Rosamunde Pilcher: Englischer Wein
 20:15:01 | 21:45:01 | SWBW            | SonntagAbend
 19:45:01 | 21:15:01 | BR3             | Kreuzwege
 18:25:00 | 20:15:00 | PULS4           | American Pie Presents Band Camp
 20:15:01 | 22:20:01 | PRO7            | Wall-E - Der Letzte räumt die Erde auf
 20:15:01 | 22:55:01 | ATV+            | The Missing
 20:15:01 | 22:10:01 | RTL2            | Ungeklärte Morde - Dem Täter auf der Spur
 20:15:01 | 22:45:01 | ARTE            | Fitzcarraldo
 20:15:01 | 21:00:01 | 3SAT            | Neues aus der Anstalt
 20:15:01 | 21:50:01 | ORF2            | Tatort
 20:15:01 | 21:40:01 | ORF1            | WALL-E - Der Letzte räumt die Erde auf
 20:15:01 | 22:45:01 | VOX             | Das perfekte Promi Dinner
 20:15:01 | 21:15:01 | SUPRT           | Abgefahren - Der lange Weg zum Führerschein
 20:15:01 | 20:45:01 | KABE1           | Two and a Half Men
 

Specified by:
getNextProgramInfos in interface IBackend
Parameters:
date - the start time
Returns:
the next programs
Throws:
IOException - on communication errors
See Also:
IBackend.getRecorders(), IRecorder.getNextProgramInfos(Date)

getChannelLogoMap

public Map<String,String> getChannelLogoMap(IRecorderNextProgramInfo.Props keyProp)
                                     throws IOException
Description copied from interface: IBackend
Gets a map containing the path to all channel logos.

This method interally uses IBackend.getNextProgramInfos(Date) to determine the path to all channel logos.

Specified by:
getChannelLogoMap in interface IBackend
Parameters:
keyProp - the property of the program-info object that should be used as key for the map.
If this is null IRecorderNextProgramInfo.Props#CHANNEL_ID is used.
Returns:
a map containing all channel logos
Throws:
IOException

scanVideos

public boolean scanVideos()
                   throws IOException
Description copied from interface: IBackend
Trigger a scan of all video folders.

Specified by:
scanVideos in interface IBackend
Returns:
true if the backend respond with OK
Throws:
IOException - on communication errors
See Also:
SCAN_VIDEOS, IVideoList, IVideoListNoChange, IVideoListChange

queryTranscode

public boolean queryTranscode(IProgramInfo programInfo)
                       throws IOException
Throws:
IOException

downloadFile

public URI downloadFile(URI url,
                        String storageGroup,
                        String fileName)
                 throws IOException
Description copied from interface: IBackend
Downloads a file to the backend.

The file is downloaded asynchronously. The backend sends IDownloadFileUpdate and IDownloadFileFinished-events to inform the client about the downloading status.

Usage example:


 
    // allow the client to receive events
    backend.annotateMonitor("mythClient",EPlaybackSockEventsMode.NORMAL);
    Semaphore downloadFinished = new Semaphore(0);
    
    // register as event listeners
    backend.addEventListener(IDownloadFileUpdate.class,new IMythEventListener<IDownloadFileUpdate>() {
       public void fireEvent(IDownloadFileUpdate event) {			
          System.out.println(String.format(
             "%s of %s (%f%%) downloaded from '%s'.",
             EncodingUtils.getFormattedFileSize(event.getBytesReceived()),
             EncodingUtils.getFormattedFileSize(event.getBytesTotal()),
             event.getReceivedPercent(),
             event.getRemoteURI()
          ));
       }
    });
    backend.addEventListener(IDownloadFileFinished.class,new IMythEventListener<IDownloadFileFinished>() {
       public void fireEvent(IDownloadFileFinished event) {				
          System.out.println(String.format(
             "Download of '%s' (%s) finished",					
             event.getRemoteURI(),
             EncodingUtils.getFormattedFileSize(event.getBytesTotal())					
          ));
          
          // signal that the download has finished
          downloadFinished.release();
       }
    });
    
    // force the backend to download the file
    URI remoteFileUri = URI.create("http://upload.wikimedia.org/wikipedia/de/7/7c/ORF-Logo.svg");
    String localFileName = "ORF-Logo.svg";
    
    URI localFileUri = backend.downloadFile(
       remoteFileUri, 
       null, 
       localFileName
    );
    		
    // waiting for the download to finish
    downloadFinished.acquire();
    
    // transfer the file to the client
    IFileTransfer transfer = backend.annotateFileTransfer(localFileUri);		
    File localFile = new File(localFileName);
    transfer.transferTo(localFile);
    transfer.close();
  

Specified by:
downloadFile in interface IBackend
Parameters:
url - the remote resource to download
storageGroup - the storage group the remote resource should be stored into
fileName - the name of the file to store the remote file into
Returns:
the URI to the downloaded resource
Throws:
IOException - on communication errors
See Also:
DOWNLOAD_FILE

downloadFileNow

public URI downloadFileNow(URI url,
                           String storageGroup,
                           String fileName)
                    throws IOException
Description copied from interface: IBackend
Downloads a file to the backend.

The remote file is downloaded synchronously by the backend.

Usage example:


    backend.annotateMonitor();
    
    // force the backend to download the file
    URI remoteFileUri = URI.create("http://upload.wikimedia.org/wikipedia/de/7/7c/ORF-Logo.svg");
    String localFileName = "ORF-Logo.svg";
    
    URI localFileUri = backend.downloadFileNow(
       remoteFileUri, 
       null, 
       localFileName
    );
    
    // transfer the file to the client
    IFileTransfer transfer = backend.annotateFileTransfer(localFileUri);		
    File localFile = new File(localFileName);
    transfer.transferTo(localFile);
    transfer.close();
  

Specified by:
downloadFileNow in interface IBackend
Parameters:
url - the remote resource to download
storageGroup - the storage group the remote resource should be stored into
fileName - the name of the file to store the remote file into
Returns:
the URI to the downloaded resource
Throws:
IOException - on communication errors
See Also:
DOWNLOAD_FILE_NOW

deleteFile

public boolean deleteFile(URI fileUrl)
                   throws IOException
Description copied from interface: IBackend
Delete a remote file.

This method calls URI.getUserInfo() and URI.getPath() to determine the storage-group and file-name and calls IBackend.deleteFile(String, String) afterwards.

Usage Hint:

Use IBackend.deleteRecording(IProgramInfo) if a recording should be deleted.

Specified by:
deleteFile in interface IBackend
Parameters:
fileUrl - the url to the remote file
Returns:
true if the file was deleted successfully, or false otherwise
Throws:
IOException - on communication errors
See Also:
DELETE_FILE

deleteFile

public boolean deleteFile(String fileName,
                          String storageGroup)
                   throws IOException
Description copied from interface: IBackend
Delete a remote file.

Usage Hint:

Use deleteRecording if a recording should be deleted.

Specified by:
deleteFile in interface IBackend
Parameters:
fileName - the name of the remote file
storageGroup - the storage-group the remote file is stored in.
Returns:
true if the file was deleted successfully, or false otherwise
Throws:
IOException - on communication errors
See Also:
DELETE_FILE

queryBookmark

public Long queryBookmark(IProgramInfo program)
                   throws IOException
Description copied from interface: IBackend
Queries the bookmark position for a given recording.

This function uses IProgramInfo.getChannelID() and IProgramInfo.getRecordingStartTime() to determine the channel-id and recording-start-time and calls IBackend.queryBookmark(Integer, Date) afterwards.

Usage Hint:

Use setBookmark to set the bookmark of a recording.

Usage example:


   // getting a list of recordings
   IProgramInfoList recordings = backend.queryRecordings();
   
   // print the bookmark position for all recordings with bookmarks
   System.out.println("Rercordings with bookmarks: ");
   for(IProgramInfo recording : recordings) {
      // determine if the recording has a bookmark set
      boolean hasBookmark = recording.getProgramFlags().isSet(Flags.FL_BOOKMARK);
      if(hasBookmark) {
         // query the bookmark position
         Long bookmark = backend.queryBookmark(recording);
         System.out.println(String.format(
            "- %s (bookmark: frame %d)",
            recording.getFullTitle(),
            bookmark
         ));
      }
   }
 

Specified by:
queryBookmark in interface IBackend
Parameters:
program - the recording
Returns:
the bookmark position in frames
Throws:
IOException - on communication errors
See Also:
QUERY_BOOKMARK

queryBookmark

public Long queryBookmark(Integer channelID,
                          Date recordingStartTime)
                   throws IOException
Description copied from interface: IBackend
Queries the bookmark position for a given recording.

Usage Hint:

Use setBookmark to set the bookmark of a recording.

Specified by:
queryBookmark in interface IBackend
Parameters:
channelID - the channel-ID of the recording
recordingStartTime - the recording-start-time of the recording
Returns:
the bookmark position in frames
Throws:
IOException - on communication errors
See Also:
QUERY_BOOKMARK

setBookmark

public boolean setBookmark(IProgramInfo recording,
                           Long bookmarkPosition)
                    throws IOException
Description copied from interface: IBackend
Sets the bookmark position for the given recording.

This function uses IProgramInfo.getChannelID() and IProgramInfo.getRecordingStartTime() to determine the channel-id and recording-start-time of the recording and calls IBackend.setBookmark(Integer, Date, Long) afterwards.

Usage Hint:

Use queryBookmark to get the bookmark of a recording.

Specified by:
setBookmark in interface IBackend
Parameters:
recording - the recording for which the bookmark should be set
bookmarkPosition - the bookmark position in frames
Returns:
true if the bookmark was set or false otherwise
Throws:
IOException - on communication errors
See Also:
SET_BOOKMARK

setBookmark

public boolean setBookmark(Integer channelID,
                           Date recordingStartTime,
                           Long bookmarkPosition)
                    throws IOException
Description copied from interface: IBackend
Sets the bookmark position for the given recording.

Usage Hint:

Use queryBookmark to get the bookmark of a recording.

Specified by:
setBookmark in interface IBackend
Parameters:
channelID - the channel ID of the recording
recordingStartTime - the recording-start-time
bookmarkPosition - the bookmark position in frames
Returns:
true if the bookmark was set or false otherwise
Throws:
IOException - on communication errors
See Also:
SET_BOOKMARK

queueTranscode

public boolean queueTranscode(IProgramInfo recording)
                       throws IOException
Description copied from interface: IBackend
Enqueues the recording for transcoding.

Usage Hint:

Use queueTranscodeStop to stop transcoding of a recording.

Specified by:
queueTranscode in interface IBackend
Parameters:
recording - the recording to transcode
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
QUEUE_TRANSCODE

queueTranscodeCutlist

public boolean queueTranscodeCutlist(IProgramInfo recording)
                              throws IOException
Description copied from interface: IBackend
Enqueues the recording for transcoding and cutlist processing.

Usage Hint:

Use queueTranscodeStop to stop transcoding of a recording.

Specified by:
queueTranscodeCutlist in interface IBackend
Parameters:
recording - the recording to transcode
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
QUEUE_TRANSCODE_CUTLIST

queueTranscodeStop

public boolean queueTranscodeStop(IProgramInfo recording)
                           throws IOException
Description copied from interface: IBackend
Stops transcoding of a recording

Usage Hint:

Use queueTranscode to start transcoding of a recording.
Use queueTranscodeCutlist to start transcoding and cutlist processing of a recording.

Specified by:
queueTranscodeStop in interface IBackend
Parameters:
recording - the recording for which transcoding should be stopped
Returns:
true on success
Throws:
IOException - on communication errors
See Also:
QUEUE_TRANSCODE_STOP

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)


Copyright © 2008-2013. All Rights Reserved.