/* -*- C++ -*- */
// $Id$

#ifndef TAO_SFP_IDL
#define TAO_SFP_IDL

#include <ULongSeq.pidl>
#include <OctetSeq.pidl>

module flowProtocol
{
  typedef CORBA::ULongSeq my_seq_ulong;
  typedef char cmagic_nr[4];

  enum MsgType
  {
    // The MsgTypes Start and struct Start,StartReply and struct
    // StartReply conflicts.
    // Also there are case-only differences for enumerator Credit and struct credit.
    // We suffix _Msg to all enumerators until the AVStreams RTF fixes these.
    // Messages in the forward direction
    //    Start,
    Start_Msg,
    EndofStream_Msg,
    SimpleFrame_Msg,
    SequencedFrame_Msg,
    Frame_Msg,
    SpecialFrame_Msg,
    // Messages in the reverse direction
    //    StartReply,
    StartReply_Msg,
    Credit_Msg,
    // Addition of type for a fragment.
    Fragment_Msg
  };

  struct frameHeader
  {
    cmagic_nr magic_number;
    //    my_seq_char magic_number;
    // '=', 'S', 'F', 'P'
    octet flags;
    // bit 0 = byte order,
    // 1 = fragments, 2-7 always 0
    octet message_type;
    unsigned long message_size;
    // Size following this header
  };

  struct fragment
  {
    //    my_seq_char magic_number;
    cmagic_nr magic_number;
    // 'F', 'R', 'A', 'G'
    octet flags;
    // bit 1 = more fragments, %%bit 0 = byteorder
    unsigned long frag_number;
    // 1,..,n
    unsigned long sequence_num;
    unsigned long frag_sz;
    unsigned long source_id;
    // Required for UDP multicast with multiple sources
  };

  struct Start
  {
    cmagic_nr magic_number;
    //    my_seq_char magic_number;
    // '=', 'S', 'T', 'A'
    octet major_version;
    octet minor_version;
    octet flags;
    // bit 0 = byte order
  };

  // Acknowledge successful processing of
  // Start

  struct StartReply
  {
    //    my_seq_char magic_number;
    cmagic_nr magic_number;
    // "=",'S','T','R'
    octet flags;
    // bit 0 = byte order, 1 = exception
  };

  // If the message_type in frameHeader is sequencedFrame
  // the the frameHeader will be followed by this
  // (See also RTP note)

  struct sequencedFrame
  {
    unsigned long sequence_num;
  };
  // If the message_type is Frame then
  // the frameHeader is followed by this
  // See also RTP note

  struct frame
  {
    unsigned long timestamp;
    unsigned long synchSource;
    my_seq_ulong source_ids;
    unsigned long sequence_num;
  };

  // XXX:The spec hasn't defined frameID.
  typedef unsigned long frameID;
  struct specialFrame
  {
    frameID context_id;
    CORBA::OctetSeq context_data;
  };

  struct credit
  {
    //    my_seq_char magic_number;
    cmagic_nr magic_number;
    // "=",'C','R','E'
    unsigned long cred_num;
  };

};

#endif /* TAO_SFP_IDL */
