clQueryScheme(3dm)                                          clQueryScheme(3dm)


NAME
     clQueryScheme, clQueryMaxHeaderSize, clReadHeader - Determine the scheme
     and read the stream header

SYNOPSIS
     #include <dmedia/cl.h>

     int clQueryScheme(void *header)
     int clQueryMaxHeaderSize(int scheme)
     int clReadHeader(CLhandle handle, int headerSize, void *header)

ARGUMENTS
     header         A pointer to a buffer containing at least 16 bytes of the
                    header.

     scheme         The decompression scheme to use.

     handle         A handle to the decompressor.

     headerSize     The maximum size of the header in bytes.

     header         A pointer to a buffer containing the header.

     clQueryScheme attempts to determine the appropriate decompression scheme
     from 16 bytes of the stream header.  It can be called before
     clOpenDecompressor to determine which scheme to use.

     Once the scheme has been determined, the handle can be opened and then
     the header can be read using clReadHeader.  The size of the header
     information is obtained from clQueryMaxHeaderSize.

     clReadHeader uses only the data in header and does not depend on any
     implicitly defined buffers.  This call will set up state parameters for
     handle based on information available in the header.  The format of the
     header is scheme-dependent and should not be accessed directly by the
     application.


RETURN VALUES
     On success, clQueryScheme returns the scheme identifier,
     clQueryMaxHeaderSize returns the maximum size of the header, and
     clReadHeader returns the number of header bytes read for all cases except
     for MPEG1, in which case it returns a value of 1. This is becuase many
     different types of headers and much non-header information may need to be
     read enroute to reading the relevant MPEG1 headers.  On failure, these
     calls return negative error codes.


EXAMPLE
          #include <dmedia/cl.h>

          int decompressionScheme;
           ...
          /* Determine the scheme from the first 16 bytes of the header */
          header = malloc(16);
          read(inFile, header, 16);
          decompressionScheme = clQueryScheme(header);
          if(decompressionScheme < 0) {
              fprintf(stderr, "Unknown scheme in stream header.");
              exit(0);
          }
          free(header);

          /* Open the appropriate decompressor */
          clOpenDecompressor(decompressionScheme, &decompressorHdl);

          /* Find out how much header information to provide */
          headerSize = clQueryMaxHeaderSize(decompressionScheme);

          if(headerSize > 0) {

              /* Get the header data */
              header = malloc(headerSize);
              lseek(inFile, 0, SEEK_SET);
              read(inFile, header, headerSize);

              /* Read the header */
              clReadHeader(decompressorHdl, headerSize, header);
              free(header);

              /* Reset the stream */
              lseek(inFile, 0, SEEK_SET);
          }
           ...


SEE ALSO
     CLintro(3dm), clOpenDecompressor(3dm)


                                                                        Page 2