/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include "ICompositeStrategy.idl"

module NMM {
  
  /** Instream composite transport strategy.  
   *
   * This is an interface for the %InstreamCompositeStrategy. 
   * It provides access to child transport strategies and the 
   * multiplexer/demultiplexer unit. 
   * It also defines internal configuration events.
   */
  interface IInstreamCompositeStrategy : ICompositeStrategy
  {
    /** Transport roles.
     */
    //@{
    enum TransportRole {
      RECEIVE_ONE_WAY_BUFFER   = 1,  ///< Receive one-way %Buffer
      RECEIVE_ONE_WAY_CEVENT   = 2,  ///< Receive one-way %CEvent
      SEND_ONE_WAY_BUFFER      = 4,  ///< Send one-way %Buffer
      SEND_ONE_WAY_CEVENT      = 8   ///< Send one-way %CEvent
    };
    
    /** Returns child strategy for receiving one-way Buffers.
     *
     * @return Interface to child strategy for receiving one-way Buffers.
     */
    ITransportStrategy* getOneWayBufferReceiverStrategy() const;

    /** Returns child strategy for receiving one-way CEvents.
     *
     * @return Interface to child strategy for receiving one-way CEvents.
     */
    ITransportStrategy* getOneWayCEventReceiverStrategy() const;

    /** Returns child strategy for sending one-way Buffers.
     *
     * @return Interface to child strategy for sending one-way Buffers.
     */
    ITransportStrategy* getOneWayBufferSenderStrategy() const;

    /** Returns child strategy for sending one-way CEvents.
     *
     * @return Interface to child strategy for sending one-way CEvents.
     */
    ITransportStrategy* getOneWayCEventSenderStrategy() const;
    
    /** @name Internal Events
     */
    //@{
    /** Event acknowledgement.  This event is sent reliably to the
     * partner strategy that sent an instream event. It is used for
     * synchronization of a reliable event sub-binding and an
     * unreliable buffer sub-binding which doesn't preserve message
     * headers.
     *
     * @param stream_counter Sequence number of the event
     */
    void notifyEventReceived(in nmm_int32 stream_counter) instream;
    //@}
    
    /** @name Debugging and Benchmarking
     */
    //@{
    /** Message multiplexing and demultiplexing strategies.
     */
    enum MuxDemuxStrategy {
      SIMPLE_MUX_DEMUX = 0,                  ///< Strategy for exactly one sub-binding.
      RELIABLE_RELIABLE_MUX_DEMUX = 1,       ///< Strategy for reliable event and buffer sub-bindings.
      RELIABLE_UNRELIABLE_MUX_DEMUX = 2,     ///< Strategy for a reliable event sub-binding and an unreliable buffer sub-binding.
      RELIABLE_MULTIMEDIA_MUX_DEMUX = 3      ///< Strategy for a reliable event sub-binding and a buffer sub-binding which does not preserve headers.
    };
    
    /** Sets message multiplexing strategy.  
     *
     * This method sets the strategy for multiplexing messages 
     * from sub-bindings. Normally, the strategy is chosen automatically 
     * after the composite strategy has been configured. 
     * This method should only be used for debuggung and benchmark purposes.
     *
     * @param strategy Multiplexing strategy
     */
    void setInstreamMuxStrategy(in IInstreamCompositeStrategy::MuxDemuxStrategy strategy);
    
    /** Sets message demultiplexing strategy.  
     *
     * This method sets the strategy for demultiplexing messages from
     * sub-bindings. Normally, the strategy is chosen automatically
     * after the composite strategy has been configured. This method
     * should only be used for debuggung and benchmark purposes.
     *
     * @param strategy Demultiplexing strategy
     */
    void setInstreamDemuxStrategy(in IInstreamCompositeStrategy::MuxDemuxStrategy strategy);
    
    /** Sets interval for data loss simulation.  
     *
     * This method sets the interval for simulating data loss. 
     * If the interval is not 0, it specifies the interval of buffers 
     * that should be dropped to simulate an unreliable buffer sub-binding. 
     * Only use this method for debugging and benchmark purposes.
     * 
     * @param loss_interval set interval to drop Buffers
     */
    void setBufferLossInterval(in nmm_uint32 loss_interval);
    //@}
  };
  
}
