multimediacommsengine/mmceshared/inc/mcecomendpoint.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMCECOMENDPOINT_H
       
    22 #define CMCECOMENDPOINT_H
       
    23 
       
    24 #include "mcecomserializable.h"
       
    25 
       
    26 #ifdef MCE_COMMON_SERVER_SIDE
       
    27 class TMceMccComEvent;
       
    28 #endif//MCE_COMMON_SERVER_SIDE
       
    29 
       
    30 class TMceComFactory;
       
    31 class TMceComEvent;
       
    32 class CMceComMediaStream;
       
    33 class CMceComCodec;
       
    34 class MMceComEndPointProxy;
       
    35 class CMceItcSender;
       
    36 class RMce;
       
    37 
       
    38 const TBool KMceEnabledLocal = ETrue;
       
    39 const TBool KMceEnabledE2e = EFalse;
       
    40 
       
    41 typedef TUint8 TMceEndpointCategory;
       
    42 
       
    43 /**
       
    44  * 
       
    45  *
       
    46  * @lib 
       
    47  */
       
    48 class CMceComEndpoint: public CBase, 
       
    49                        public MMceComSerializable
       
    50 	{
       
    51 
       
    52 public: // Destructor
       
    53 
       
    54 	~CMceComEndpoint();
       
    55 
       
    56 
       
    57 public: // from MMceComSerializableMedia
       
    58 
       
    59 
       
    60     /**
       
    61     * Returns serialization id
       
    62     * @return serialization id
       
    63     */
       
    64     TUint64 SerializationId() const;
       
    65     
       
    66     /**
       
    67     * Internalizes flat data
       
    68     * @param aReadStream read stream
       
    69     */
       
    70     void InternalizeFlatL( RReadStream& aReadStream );
       
    71 
       
    72     /**
       
    73     * Externalizes flat data
       
    74     * @param aWriteStream write stream
       
    75     */
       
    76     void ExternalizeFlatL( RWriteStream& aWriteStream );
       
    77     
       
    78     /**
       
    79     * Internalizes
       
    80     * @param aSerCtx context for serialization
       
    81     */
       
    82     void InternalizeL( MMceComSerializationContext& aSerCtx );
       
    83     
       
    84     /**
       
    85     * Externalizes
       
    86     * @param aSerCtx context for serialization
       
    87     */
       
    88     void ExternalizeL( MMceComSerializationContext& aSerCtx );
       
    89     
       
    90 
       
    91 public: // new functions
       
    92 
       
    93     /**
       
    94     * Return category of endpoint.
       
    95     * @return category of endpoint
       
    96     */
       
    97     TMceEndpointCategory Category() const;
       
    98     
       
    99     /**
       
   100     * Returns type of endpoint. NOTE, sources and sinks have currently
       
   101     * overlapping type values so type value checking is not safe without
       
   102     * knowing endpoint category. TBD: remove overlapping from API
       
   103     * @return type of endpoint
       
   104     */
       
   105     TUint8 Type() const;
       
   106 
       
   107     /**
       
   108     * ID 
       
   109     * @return ID
       
   110     */
       
   111 	TMceMediaId Id() const;
       
   112 
       
   113     /**
       
   114     * Factory
       
   115     * @return factory
       
   116     */
       
   117     TMceComFactory BaseFactory();
       
   118 
       
   119     /**
       
   120     * Sets and gets reference count describing to how many
       
   121     * streams sink is associated
       
   122     * @return reference count reference
       
   123     */
       
   124     TInt& ReferenceCount();
       
   125 
       
   126 	/**
       
   127     * Parent object
       
   128     * @return Parent object
       
   129     */
       
   130 	CMceComMediaStream* MediaStream() const;
       
   131 
       
   132     /**
       
   133     * equal operator
       
   134     * @param aEndpoint the enpoint
       
   135     * @return ETrue, if equal
       
   136     */
       
   137     TBool operator==( const CMceComEndpoint& aEndpoint ) const;
       
   138 
       
   139     /**
       
   140     * Stream is been deleted
       
   141     * @param aParent the parent stream
       
   142     */
       
   143     void UnInitialize( CMceComMediaStream& aParent );
       
   144 
       
   145 
       
   146 public: // virtual functions
       
   147 
       
   148 
       
   149     /**
       
   150     * Returns ETrue, if enabled
       
   151     * @param aLocally, if KMceEnabledLocal means locally enabled,
       
   152     *                  KMceEnabledE2e means that local and remote 
       
   153     *                  endpoints are enabled.
       
   154     * @return ETrue, if enabled
       
   155     */
       
   156     virtual TBool IsEnabled( TBool aLocally = KMceEnabledLocal ) const;
       
   157 
       
   158     /**
       
   159     * Sets enabled flag
       
   160     * @param aValue enabled/disabled
       
   161     */
       
   162     void Enabled( TBool aValue );
       
   163 	
       
   164     /**
       
   165     * Traversal event handler
       
   166     * @param aEvent the event
       
   167     * @return status, if event was consumed or not or object needs update
       
   168     */
       
   169     virtual TInt EventReceivedL( TMceComEvent& aEvent ) = 0;
       
   170     
       
   171     /**
       
   172     * Initializes 
       
   173     * @param aParent the parent
       
   174     */
       
   175     virtual void InitializeL( CMceComMediaStream& aParent );
       
   176     
       
   177     /**
       
   178     * Stream has been added to session
       
   179     * @param aParent the parent stream
       
   180     */
       
   181     virtual void StreamAddedL( CMceComMediaStream& aParent );
       
   182 
       
   183     /**
       
   184     * Returns endpoint proxy
       
   185     * @return endpoint proxy
       
   186     */
       
   187 	MMceComEndPointProxy* EndpointProxy() const;
       
   188 
       
   189     /**
       
   190     * Called when stream bundle has beed added to prepare proxy for it
       
   191     * @param aEndpointProxy endpoint proxy setup by another endpoint or NULL
       
   192     */
       
   193     void SetupEndpointProxyL( MMceComEndPointProxy* aEndpointProxy );
       
   194 
       
   195     /**
       
   196     * Called endpoint proxy must be created
       
   197     * @return endpointProxy
       
   198     */
       
   199     virtual MMceComEndPointProxy* CreateEndpointProxyL() const;
       
   200 
       
   201     /**
       
   202     * Should this endpoint use endpoint proxy
       
   203     * @return ETrue, this endpoint uses endpoint proxy
       
   204     */
       
   205     virtual TBool UsesEndpointProxy() const;
       
   206 
       
   207     /**
       
   208     * Is this endpoint re-usable
       
   209     * @return ETrue, if this endpoint is re-usable
       
   210     */
       
   211     virtual TBool Reusable( const CMceComMediaStream& aParent ) const;     
       
   212     /**
       
   213     * Should use RTCP
       
   214     * return ETrue, if uses RTCP
       
   215     */
       
   216     virtual TBool UseRTCP();
       
   217     
       
   218 
       
   219 #ifdef MCE_COMMON_SERVER_SIDE
       
   220 
       
   221 
       
   222 public: //virtual functions 
       
   223 
       
   224     /**
       
   225     * Returns mcc type for mcc endpoint
       
   226     * @return mcc type
       
   227     */
       
   228     virtual const TUid MccType() = 0;
       
   229     
       
   230     /**
       
   231     * Returns init param for mcc endpoint
       
   232     * @return mcc type
       
   233     */
       
   234     virtual const TDesC8& InitParamL( const CMceComCodec& aCodec);
       
   235     
       
   236     /**
       
   237     * Endpoint can be informed about initialization completion
       
   238     */
       
   239     virtual void InitializedL();
       
   240     
       
   241     /**
       
   242     * Enables 'locally' this endpoint
       
   243     * @param aCodec the codec associated to this endpoint
       
   244     */
       
   245     virtual void EnableL( const CMceComCodec& aCodec );
       
   246     
       
   247     /**
       
   248     * Disables 'locally' this endpoint
       
   249     */
       
   250     virtual void DisableL();
       
   251     
       
   252     /**
       
   253     * Prepares this endpoint
       
   254     */
       
   255     virtual void PrepareL();
       
   256     
       
   257     /**
       
   258     * Called after endpoint has been prepared.
       
   259     * @return error code
       
   260     */ 
       
   261     virtual TInt DoPrepared();
       
   262 
       
   263 
       
   264 public: //new functions 
       
   265 
       
   266     /**
       
   267     * Handles event received from mcc
       
   268     * @param aEvent the event from mcc
       
   269     */
       
   270     void EventReceived( TMceMccComEvent& aEvent );
       
   271     
       
   272     /**
       
   273     * Sets state
       
   274     * @param aEvent the event from mcc
       
   275     */
       
   276     void SetState( TMceMccComEvent& aEvent );
       
   277 
       
   278     void Merge( CMceComEndpoint& aMergeWith );
       
   279     
       
   280 #else // MCE CLIENT SIDE
       
   281 
       
   282     /**
       
   283     * Gets itc sender.
       
   284     * @param aItcProvider
       
   285     */
       
   286     CMceItcSender& SenderL( RMce& aItcProvider );
       
   287 #endif//MCE_COMMON_SERVER_SIDE
       
   288 
       
   289 
       
   290 protected: 
       
   291 
       
   292     /**
       
   293     * Updates 
       
   294     * @param aEndpoint an endpoint
       
   295     */
       
   296     void BaseUpdateL( CMceComEndpoint& aEndpoint );
       
   297     
       
   298     /**
       
   299     * Zeroes instance (used in cloning)
       
   300     */
       
   301     void Zero();
       
   302     
       
   303     
       
   304 protected:
       
   305 
       
   306     /**
       
   307      * C++ default constructor.
       
   308      * @param aType
       
   309      */
       
   310 	CMceComEndpoint( TMceEndpointCategory aCategory, TUint8 aType );
       
   311 		
       
   312 
       
   313 public://serialized data
       
   314 
       
   315     /**
       
   316      * category of endpoint
       
   317      */
       
   318     TMceEndpointCategory iCategory;
       
   319     
       
   320     /**
       
   321      * type of endpoint
       
   322      */
       
   323     TUint8 iType;
       
   324 
       
   325     /**
       
   326      * ID
       
   327      */
       
   328     TMceMediaId iID;
       
   329 
       
   330     /**
       
   331      * reference count
       
   332      */
       
   333     TInt iReferenceCount;
       
   334 
       
   335 
       
   336 
       
   337 protected://owned
       
   338 
       
   339     /**
       
   340      * proxy
       
   341      */
       
   342     MMceComEndPointProxy* iEndpointProxy;
       
   343 
       
   344     /**
       
   345      * Is enabled
       
   346      */
       
   347     TBool iIsEnabled;
       
   348     
       
   349     /**
       
   350     * Itc sender used by client when endpoint is not attached to session.
       
   351     */
       
   352     CMceItcSender* iItcSender;
       
   353 
       
   354 private://NOT owned
       
   355 
       
   356 
       
   357 	/**
       
   358     * Parent stream (one of)
       
   359     */
       
   360 	CMceComMediaStream* iStream;
       
   361 	
       
   362 	/**
       
   363     * Parent streams
       
   364     */
       
   365 	RPointerArray<CMceComMediaStream> iParents;
       
   366     
       
   367 	//definitions for unit testing
       
   368 	friend class UT_CMceSrvSource;
       
   369 	};
       
   370 
       
   371 
       
   372 #endif // CMCECOMENDPOINT_H