natfw/natfwconnectionmultiplexer/inc/cncmstream.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Connection multiplexer stream abstraction.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_CNCMSTREAM_H
       
    22 #define C_CNCMSTREAM_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <in_sock.h>
       
    26 
       
    27 
       
    28 class MNATFWMediaWrapper;
       
    29 class CNcmConnection;
       
    30 class MNcmMultiplexerConnectionObserver;
       
    31 class CNcmConnectionObserverHandler;
       
    32 class CNcmMediaSource;
       
    33 
       
    34 /**
       
    35  *  Connection multiplexer stream abstraction.
       
    36  *
       
    37  *  @lib connectionmux.lib
       
    38  *  @since S60 v3.2
       
    39  */
       
    40 NONSHARABLE_CLASS( CNcmStream ) : public CBase
       
    41     {
       
    42 
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Two-phased constructor
       
    47      *
       
    48      * @param   aSessionId          The ID identifying session
       
    49      * @param   aStreamId           The ID identifying stream
       
    50      * @param   aQos                The quality of service
       
    51      * @param   aProtocol           KProtocolInetUdp / KProtocolInetTcp
       
    52      */
       
    53     static CNcmStream* NewL( TUint aSessionId, TUint aStreamId,
       
    54         TInt aQos, TUint aProtocol );
       
    55 
       
    56     /**
       
    57      * Two-phased constructor
       
    58      *
       
    59      * @param   aSessionId          The ID identifying session
       
    60      * @param   aStreamId           The ID identifying stream
       
    61      * @param   aQos                The quality of service
       
    62      * @param   aProtocol           KProtocolInetUdp / KProtocolInetTcp
       
    63      */
       
    64     static CNcmStream* NewLC( TUint aSessionId, TUint aStreamId,
       
    65         TInt aQos, TUint aProtocol );
       
    66 
       
    67     /**
       
    68      * Destructor
       
    69      */
       
    70     virtual ~CNcmStream();
       
    71 
       
    72     /**
       
    73      * Creates a new connection for stream. Will use same protocol as
       
    74      * used in stream.
       
    75      *
       
    76      * This is done synchronously.
       
    77      * 
       
    78      * @since   S60 v3.2
       
    79      * @param   aObserver                   Observer
       
    80      * @param   aConnectionObserverHandler  Connection observer handler
       
    81      * @param   aSocketServ                 Socket server
       
    82      * @param   aConnection                 RConnection
       
    83      * @param   aLocalAddress               Local address    
       
    84      * @param   aReuseAddress               If ETrue reuse the local address             
       
    85      * @return  The ID for the created connection
       
    86      */
       
    87     TUint CreateConnectionL( MNcmMultiplexerConnectionObserver& aObserver,
       
    88         CNcmConnectionObserverHandler& aConnectionObserverHandler,
       
    89         RSocketServ& aSocketServ, RConnection& aConnection,
       
    90         const TInetAddr& aLocalAddress, TBool aReuseAddress );
       
    91     
       
    92     /**
       
    93      * Removes connection
       
    94      *
       
    95      * @since   S60 v3.2
       
    96      * @param   aConnectionId       The ID identifying stream.
       
    97      * @return  void
       
    98      */ 
       
    99     void RemoveConnectionL( TUint aConnectionId );
       
   100     
       
   101     /**
       
   102      * Gets the stream ID
       
   103      *
       
   104      * @since   S60 v3.2
       
   105      * @return  The ID identifying stream.
       
   106      */ 
       
   107     TUint StreamId() const;
       
   108     
       
   109     /**
       
   110      * Gets the quality of service
       
   111      *
       
   112      * @since   S60 v3.2
       
   113      * @return  Quality of service.
       
   114      */ 
       
   115     TInt Qos() const;
       
   116     
       
   117     /**
       
   118      * Sets the qualiy of service
       
   119      *
       
   120      * @since   S60 v3.2
       
   121      * @param   aQos Qualiy of service
       
   122      * @return  void
       
   123      */ 
       
   124     void SetQos( TInt aQos );
       
   125     
       
   126     /**
       
   127      * Gets the protocol used in stream.
       
   128      *
       
   129      * @since   S60 v3.2
       
   130      * @return  The protocol, KProtocolInetUdp / KProtocolInetTcp
       
   131      */ 
       
   132     TUint StreamProtocol() const;
       
   133     
       
   134     /**
       
   135      * Sets the protocol used in stream.
       
   136      *
       
   137      * @since   S60 v3.2
       
   138      * @param   aProtocol       KProtocolInetUdp / KProtocolInetTcp  
       
   139      * @return  void
       
   140      */ 
       
   141     void SetStreamProtocol( TUint aProtocol );
       
   142    
       
   143     /**
       
   144      * Returns pointer to connection. Leaves with KErrNotFound if connection
       
   145      * isn't found.
       
   146      *
       
   147      * @since   S60 v3.2
       
   148      * @param   aConnectionId       The ID identifying sub stream.    
       
   149      * @return  Connection
       
   150      */   
       
   151     CNcmConnection* ConnectionL( TUint aConnectionId ); 
       
   152        
       
   153     /**
       
   154      * Registers a media wrapper into stream. Ownership of wrapper is
       
   155      * also tranferred. Leaves with KErrArgument if pointer to
       
   156      * media wrapper is NULL.
       
   157      *
       
   158      * @since   S60 v3.2
       
   159      * @param   aWrapper         Pointer to Media Wrapper
       
   160      * @return  void
       
   161      */
       
   162     void RegisterWrapperL( MNATFWMediaWrapper* aWrapper );
       
   163     
       
   164     /** 
       
   165      * Returns Media wrapper. Leaves with KErrNotFound if media wrapper 
       
   166      * isn't found.
       
   167      *
       
   168      * @since   S60 v3.2
       
   169      * @return  Media wrapper
       
   170      */
       
   171     MNATFWMediaWrapper* WrapperL();   
       
   172     
       
   173     /** 
       
   174      * Return the MediaConnectionId connection id.
       
   175      *
       
   176      * @since   S60 v3.2
       
   177      * @return  Media connection ID( 0 if not set )
       
   178      */
       
   179     TUint MediaConnectionId() const;
       
   180 
       
   181     /** 
       
   182      * Sets the media connection ID
       
   183      *
       
   184      * @since   S60 v3.2
       
   185      * @param   aMediaConnectionId      Media connection ID
       
   186      * @return  void
       
   187      */
       
   188     void SetMediaConnectionId( TUint aMediaConnectionId );
       
   189       
       
   190     /**
       
   191      * Returns pointer to connection observer handler.
       
   192      *
       
   193      * @since   S60 v3.2   
       
   194      * @return  Connection observer handler.
       
   195      */
       
   196     CNcmConnectionObserverHandler& ConnectionObserverHandler();
       
   197     
       
   198     /**
       
   199      * Find and return the connection ID by destination address.
       
   200      * Connection sender must be active.
       
   201      *
       
   202      * @since   S60 v3.2
       
   203      * @param   aDestinationAddress Destination address   
       
   204      * @return  Connection.
       
   205      */
       
   206     CNcmConnection* ConnectionByDestinationAddressL(
       
   207         const TInetAddr& aDestinationAddress );
       
   208         
       
   209     /**
       
   210      * Register a media source for stream. Ownership of media source is transferred.
       
   211      *
       
   212      * @since   S60 v3.2
       
   213      * @param   aMediaSource             The media source
       
   214      * @return  void
       
   215      */
       
   216     void RegisterMediaSourceL( CNcmMediaSource* aMediaSource );
       
   217     
       
   218 private: //Private constructors
       
   219 
       
   220     CNcmStream( TUint aSessionId, TUint aStreamId,
       
   221         TInt aQos, TUint aProtocol );
       
   222     
       
   223     void ConstructL();
       
   224 
       
   225 private: // data
       
   226 
       
   227     /**
       
   228      * Session ID
       
   229      */
       
   230     TUint iSessionId;
       
   231     
       
   232     /**
       
   233      * Stream ID 
       
   234      */
       
   235     TUint iStreamId;
       
   236 
       
   237     /**
       
   238      * QoS for connections
       
   239      */
       
   240     TInt iQos;
       
   241     
       
   242     /**
       
   243      * Stream protocol, KProtocolInetUdp / KProtocolInetTcp
       
   244      */
       
   245     TUint iStreamProtocol;
       
   246     
       
   247     /**
       
   248      * Registered wrapper
       
   249      * Own.
       
   250      */
       
   251     MNATFWMediaWrapper* iWrapper;
       
   252             
       
   253     /**
       
   254      * Connections within stream, implemented by multiplexers
       
   255      * Own.
       
   256      */
       
   257     RPointerArray<CNcmConnection> iConnections;
       
   258     
       
   259     /**
       
   260      * Next connection ID
       
   261      */
       
   262     TUint iNextConnectionId;
       
   263     
       
   264     /**
       
   265      * Media connection ID
       
   266      * This is zero if media connection is unspecified.
       
   267      * otherwise connection ID will be returned.
       
   268      */
       
   269     TUint iMediaConnectionId;
       
   270     
       
   271     /**
       
   272      * Handler for connection observers
       
   273      * Own.
       
   274      */
       
   275     CNcmConnectionObserverHandler* iConnectionObserverHandler;
       
   276     };
       
   277     
       
   278 #endif // C_CNCMSTREAM_H