Interface IMediaCacheHTTPByteReader

  • All Known Subinterfaces:
    IMediaCacheHTTPByteReader2

    public interface IMediaCacheHTTPByteReader
    
    Interface for HTTP byte reader implementations
    
    This should be used in conjunction with IMediaCacheItemHTTPReaderFactory and any implementation has to return head and read results.
    
    
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Close any open connection.
      com.wowza.wms.mediacache.impl.MediaCacheHTTPByteReaderResult head​(String path)
      void init()
      Initialize the byte reader.
      com.wowza.wms.mediacache.impl.MediaCacheHTTPByteReaderResult read​(String path, long pos, int flen)
      void setConnectionTimeout​(int connectionTimeout)
      Set the connection timeout, milliseconds.
      void setDestinationAddress​(String host, int port)
      Set the destination host and port where to retrieve data.
      void setMaxRetries​(int maxRetries)
      Set the maximum number retries.
      void setProxyAddress​(String host, int port)
      Set the proxy host and port.
      void setReadTimeout​(int readTimeout)
      Set the read timeout for data, milliseconds.
      void setReceiveBufferSize​(int receiveBufferSize)
      Set the receive buffer size, byte size.
      void setRequestFullURL​(boolean requestFullURL)
      Flag to set if a full URL is required as part of the head/read request.
      void setSendBufferSize​(int sendBufferSize)
      Set the send buffer size, byte size.
    • Method Detail

      • init

        void init()
        Initialize the byte reader.
      • head

        com.wowza.wms.mediacache.impl.MediaCacheHTTPByteReaderResult head​(String path)
        
        Retrieve asset information via a HEAD request. Parameters are the path of the object.
        
        This of course does not need to be an actual head command to the remote side, but something that returns the asset length and preferably last modified time.
        
        Assume contentLength and lastModified were populated from any code implemented you can then create a return object with.
        
        long startTime = System.nanoTime();
        ret = new MediaCacheHTTPByteReaderResult();
        ret.status = 200;
        ret.contentLength = contentLength;
        ret.lastModified = lastModified;
        ret.elapseTime = (System.nanoTime()-startTime)/1000000L;
        
        A return status other than 200 may cause failure within MediaCache and consequently cause any client requests to be rejected.
        
                 
        Parameters:
        path -
        Returns:
        MediaCacheHTTPByteReaderResult
      • read

        com.wowza.wms.mediacache.impl.MediaCacheHTTPByteReaderResult read​(String path,
                                                                          long pos,
                                                                          int flen)
        
        Retrieve data from the remote service/server. Parameters are the path of the object, the current position into the object and the amount of data to get (flen).
        
        The remote source should support HTTP/1.1 so partial requests can be made.
        
        The data size returned in the MediaCacheHTTPByteReadResult must match the flen requested otherwise the data will be considered invalid.
        
        Consider you have an input and out byteStream object
        
        long startTime = System.nanoTime();
        InputStream input = myConnectionToSomeWhere.getInputStream();
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[this.receiveBufferSize];
        int n = - 1;
        while ( (n = input.read(buffer)) != -1)
        {
          byteStream.write(buffer, 0, n);
        }
        
        ret = new MediaCacheHTTPByteReaderResult();
        ret.buffer = byteStream.toByteArray();
        ret.status = 206;
        ret.headerLength = 0;
        ret.contentLength = byteStream.size();
        ret.roffset = requestStart;
        ret.rlen = requestLength;
        ret.lastModified = this.mediaCacheConnection.getLastModified();
        ret.elapseTime = (System.nanoTime()-startTime)/1000000L;
        
        A return status other than >=200 or <=300 may cause failure within MediaCache and consequently cause any client requests to be rejected.
        
        
        Parameters:
        path -
        pos -
        flen -
        Returns:
        MediaCacheHTTPByteReaderResult
      • close

        void close()
        Close any open connection.
      • setDestinationAddress

        void setDestinationAddress​(String host,
                                   int port)
        Set the destination host and port where to retrieve data.
        Parameters:
        host -
        port -
      • setProxyAddress

        void setProxyAddress​(String host,
                             int port)
        Set the proxy host and port. It is up to the specific byte reader implementation to implement support for proxy connections.
        Parameters:
        host -
        port -
      • setRequestFullURL

        void setRequestFullURL​(boolean requestFullURL)
        Flag to set if a full URL is required as part of the head/read request. It is up to the specific byte reader implementation to use this flag.
        Parameters:
        requestFullURL -
      • setReadTimeout

        void setReadTimeout​(int readTimeout)
        Set the read timeout for data, milliseconds. It is up to the specific byte reader implementation to use this setting.
        Parameters:
        readTimeout -
      • setMaxRetries

        void setMaxRetries​(int maxRetries)
        Set the maximum number retries. It is up to the specific byte reader implementation to use this setting.
        Parameters:
        maxRetries -
      • setConnectionTimeout

        void setConnectionTimeout​(int connectionTimeout)
        Set the connection timeout, milliseconds. It is up to the specific byte reader implementation to use this setting.
        Parameters:
        connectionTimeout -
      • setSendBufferSize

        void setSendBufferSize​(int sendBufferSize)
        Set the send buffer size, byte size. It is up to the specific byte reader implementation to use this setting.
        Parameters:
        sendBufferSize -
      • setReceiveBufferSize

        void setReceiveBufferSize​(int receiveBufferSize)
        Set the receive buffer size, byte size. It is up to the specific byte reader implementation to use this setting.
        Parameters:
        receiveBufferSize -