Source: decoderinterface.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                      RTP Audio Server Project                    ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Decoder Interface                                                ####
// ####                                                                  ####
// #### Version 1.00  --  February 04, 2001                              ####
// ####                                                                  ####
// #### Copyright (C) 1999  Thomas Dreibholz                             ####
// ####               2000  Universität Bonn, Abt. IV                    ####
// ####               2001  EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef DECODERINTERFACE_H
#define DECODERINTERFACE_H


#include "system.h"
#ifdef USE_TRANSPORTINFO
#include "transportinfo.h"
#endif
#include "sourcestateinfo.h"
#include "mediainfo.h"


namespace Coral {


/**
  * This structure contains packet information for handleNextPacket() call.
  *
  * @short   DecoderPacket
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
struct DecoderPacket
{
   /**
     * Buffer to write packet payload into.
     */
   void* Buffer;

   /**
     * Maximum length of payload to be written into Buffer.
     */
   cardinal Length;

   /**
     * The packet's sequence number.
     */
   card16 SequenceNumber;

   /**
     * The packet's time stamp.
     */
   card32 TimeStamp;

   /**
     * The packet's payload type.
     */
   card8 PayloadType;

   /**
     * The packet's marker.
     */
   bool Marker;


   /**
     * Source state info array for packet validation within handleNextPacket().
     */
   SourceStateInfo** SSIArray;


   /**
     * The packet's layer number, to be set within handleNextPacket().
     * This is used in RTPReceiver to decide to which layer the packet's
     * FlowInfo belongs. Set Layer (cardinal)-1, if the packet does not belong
     * to a layer, is invalid etc.
     */
   cardinal Layer;

   /**
     * The number of layers of the packet's encoding quality, to be set within handleNextPacket().
     * Set to (cardinal)-1, if the packet does not belong to a layer, is invalid etc.
     */
   cardinal Layers;
};



/**
  * This class is the interface for a decoder.
  *
  * @short   Decoder Interface
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
class DecoderInterface
{
   // ====== Destructor =====================================================
   public:
   /**
     * Virtual destructor.
     */
   virtual ~DecoderInterface();


   // ====== Decoder type ===================================================
   /**
     * Get the decoder's type ID.
     *
     * @return Decoder's type ID.
     */
   virtual const card16 getTypeID() const = 0;
   
   /**
     * Get the decoder's name.
     *
     * @return Decoder's name
     */
   virtual const char* getTypeName() const = 0;


   // ====== Initialization/Clean-up ========================================
   /**
     * Activate the decoder.
     * Usage example: Start an decoder thread.
     */
   virtual void activate() = 0;
   
   /**
     * Deactivate the decoder.
     * Usage example: Stop an decoder thread.
     */
   virtual void deactivate() = 0;
   
   /**
     * Reset the decoder.
     * Usage example: Reset an decoder thread.
     */
   virtual void reset() = 0;


#ifdef USE_TRANSPORTINFO
   // ====== Get TransportInfo ==============================================
   /**
     * Get TransportInfo for encoding.
     *
     * @param transportInfo Pointer to TransportInfo.
     * @param headerSize Size of underlying protocol's header (e.g. RTP packet)
     * @param maxPacketSize Maximum size of packet.
     * @param wantedQuality Audio quality wanted by the receiver.
     * @param calculateLevels true to calculate all level constants; false otherwise.
     *
     * Note: maxPacketSize gives the total size of the packet. The size
     * usable by the encoder is maxPacketSize - headerSize!
     */
   virtual void getTransportInfo(TransportInfo& transportInfo,
                                 const cardinal headerSize,
                                 const cardinal maxPacketSize,
                                 const bool     calculateLevels = true) const = 0;
#endif


   // ====== Check next packet ==============================================
   /**
     * Check next packet. This function has to set valid packet->Layers
     * and packet->Layer value.
     *
     * @param decoderPacket DecoderPacket structure.
     * @return true, if packet is valid; false otherwise.
     */
   virtual bool checkNextPacket(DecoderPacket* packet) = 0;


   // ====== Decode next packet =============================================
   /**
     * Handle next received packet.
     *
     * @param decoderPacket DecoderPacket structure.
     */
   virtual void handleNextPacket(const DecoderPacket* decoderPacket) = 0;


   // ====== Status functions ===============================================
   /**
     * Get media info.
     *
     * @param mediaInfo Reference to store MediaInfo to.
     */
   virtual void getMediaInfo(MediaInfo& mediaInfo) const = 0;

   /**
     * Get error code
     * Usage example: Return error, if reading from file failed.
     *
     * @return Error code
     */
   virtual card8 getErrorCode() const = 0;
   
   /**
     * Get current position in nanoseconds.
     *
     * @return Position in nanoseconds.
     */
   virtual card64 getPosition() const = 0;
   
   /**
     * Get maximum position in nanoseconds.
     *
     * @return Maximum position in nanoseconds.
     */                    
   virtual card64 getMaxPosition() const = 0;
};


}


#endif

Generated by: viper@odin on Sun Feb 4 18:54:51 2001, using kdoc 2.0a22.