multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesrvstream.h
changeset 0 1bce908db942
child 49 64c62431ac08
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 CMCESRVSTREAM_H
       
    22 #define CMCESRVSTREAM_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <mmccinterfacedef.h>
       
    26 #include <in_sock.h>
       
    27 #include "mcemediadefs.h"
       
    28 #include "mcecommediastream.h"
       
    29 #include "mcesrv.h"
       
    30 
       
    31 class CMceComAudioStream;
       
    32 class CMceComVideoStream;
       
    33 class CMceSrvSource;
       
    34 class CMceSrvSink;
       
    35 class CMceSrvCodec;
       
    36 class CMceComEndpoint;
       
    37 class CMceComMediaSource;
       
    38 class CMceComMediaSink;
       
    39 class CMceComCodec;
       
    40 class CMceMediaManager;
       
    41 class TMceMccComEvent;
       
    42 class CMccCodecInformation;
       
    43 class CMccInterface;
       
    44 class CMceDtmfHandler;
       
    45 class CMceSrvEndpoint;
       
    46 
       
    47 
       
    48 const TBool KMceSrvStreamCallback = ETrue;
       
    49 const TBool KMceSrvStreamNoCallback = EFalse;
       
    50 const TBool KMceSrvStreamDefaultSequence = EFalse;
       
    51 const TBool KMceSrvStreamAlternativeSequence = ETrue;
       
    52 const TBool KMceSrvStreamForce = ETrue;
       
    53 const TBool KMceSrvStreamNoForce = EFalse;
       
    54 const TBool KMceSrvStreamSync = ETrue;
       
    55 const TBool KMceSrvStreamNoSync = EFalse;
       
    56 
       
    57 
       
    58 
       
    59 /**
       
    60  * 
       
    61  *
       
    62  * @lib 
       
    63  */
       
    64 class CMceSrvStream: public CBase
       
    65     {
       
    66 
       
    67 public: // enums
       
    68 
       
    69     /**
       
    70     * Current state in MCC 
       
    71     */
       
    72     enum TState
       
    73         {
       
    74         EAdopted = 1,
       
    75         ECreated,
       
    76         ECreatingLink,
       
    77         ELinkCreated,
       
    78         EPreparing,
       
    79         EPrepared,
       
    80         EStarting,
       
    81         EPending,
       
    82         EStopped,
       
    83         EInactive,
       
    84         EStarted,
       
    85         EPausing,
       
    86         EPaused
       
    87         };
       
    88 
       
    89         
       
    90 public: // Constructors & Destructor
       
    91 
       
    92 
       
    93     /**
       
    94     * Decodes stream to array of server streams.
       
    95     * This is factory method
       
    96     * @return array of server streams
       
    97     */
       
    98     static void DecodeL( RPointerArray<CMceSrvStream>& aStreams,
       
    99                          CMceComMediaStream& aStream,
       
   100                          CMceMediaManager& aManager );
       
   101     
       
   102     
       
   103     /**
       
   104     * Creates srv stream.
       
   105     */
       
   106     static CMceSrvStream* NewL( CMceMediaManager& aManager,
       
   107                                 CMceComMediaStream& aData,
       
   108                                 CMceComMediaSource& aSource,
       
   109                                 CMceComMediaSink& aSink,
       
   110                                 CMceComCodec& aCodec );
       
   111                                 
       
   112     /**
       
   113     * Destructor.
       
   114     */
       
   115      ~CMceSrvStream();
       
   116 
       
   117     
       
   118 public: // static API
       
   119 
       
   120     static CMceSrvStream* EventReceived( 
       
   121                         RPointerArray<CMceSrvStream>& aStreams,
       
   122                         TMceMccComEvent& aEvent,
       
   123                         TBool aConsumeOnlyOnce = EFalse );
       
   124                                         
       
   125 
       
   126 public: // virtual functions
       
   127 
       
   128 
       
   129     /**
       
   130     * Gets session id
       
   131     * @return session id
       
   132     */
       
   133     virtual TUint32 SessionId() const;
       
   134     
       
   135     /**
       
   136     * Gets link id
       
   137     * @return link id
       
   138     */
       
   139     virtual TUint32 LinkId() const;
       
   140 
       
   141     /**
       
   142     * Sets link id
       
   143     * @param aLinkId link id
       
   144     */
       
   145     virtual void SetLinkId( TUint32 aLinkId );
       
   146     
       
   147     /**
       
   148     * Gets IAP id
       
   149     * @return IAP id
       
   150     */
       
   151     virtual TUint32 IapId() const;
       
   152     
       
   153     /**
       
   154     * Gets local media port of stream
       
   155     * @return local media port of stream
       
   156     */
       
   157     virtual TUint LocalMediaPort() const;
       
   158 
       
   159     
       
   160     /**
       
   161     * Handles event from MCC
       
   162     * @return status of operation
       
   163     */
       
   164     virtual TInt EventReceived( TMceMccComEvent& aEvent, TBool aCallback = KMceSrvStreamCallback );
       
   165 
       
   166     /**
       
   167     * Cleans up unused sinks/sources from mcc
       
   168     */
       
   169     virtual void Cleanup();
       
   170 
       
   171     /**
       
   172     * Checks, if this is equal to another stream
       
   173     * @param aStream an another stream
       
   174     * @return ETrue, if this is equal
       
   175     */
       
   176     virtual TBool IsEqual( const CMceSrvStream& aStream ) const;
       
   177 
       
   178     /**
       
   179     * Merges with stream from cloned session
       
   180     */
       
   181     virtual void Merge( CMceSrvStream& aMergeWith, TBool aDeepMerge = EFalse );
       
   182 
       
   183     /**
       
   184     * UnMerges with stream from cloned session
       
   185     */
       
   186     void UnMergeL( CMceSrvStream& aUnMergeFrom );
       
   187 
       
   188     /**
       
   189     * Is Prepared by MCC
       
   190     * @return ETrue, if so
       
   191     */
       
   192     virtual TBool IsMccPrepared() const;
       
   193 
       
   194     /**
       
   195     * Returns state of stream, which depends on states of
       
   196     * sink and source
       
   197     * @return the state
       
   198     */
       
   199     virtual TState State() const;
       
   200 
       
   201     /**
       
   202     * Invalidates the stream
       
   203     */
       
   204     virtual void Invalidate();
       
   205     
       
   206     /**
       
   207     * Is adopted
       
   208     */
       
   209     virtual TBool IsAdopted() const;
       
   210     
       
   211 public: // Data access etc
       
   212 
       
   213     /**
       
   214     * Sets local media port of stream
       
   215     * @param aPort local media
       
   216     */
       
   217     void SetLocalMediaPort( TUint aPort );
       
   218 
       
   219     /**
       
   220     * Gets id
       
   221     * @return id
       
   222     */
       
   223     TUint32& Id();
       
   224 
       
   225     /**
       
   226     * Gets stream type
       
   227     * @return stream type
       
   228     */
       
   229     CMceComMediaStream::TStreamType StreamType() const;
       
   230     
       
   231     /**
       
   232     * Gets direction
       
   233     * @return direction
       
   234     */
       
   235     CMceComMediaStream::TStreamType Direction() const;
       
   236     
       
   237     /**
       
   238     * Is Merged
       
   239     * @return ETrue, if merged
       
   240     */
       
   241     TBool IsMerged() const;
       
   242     
       
   243     /**
       
   244     * Gets the original com stream
       
   245     * @return the original com stream
       
   246     */
       
   247     CMceComMediaStream& Data() const;
       
   248 
       
   249     /**
       
   250     * Gets remote ip address
       
   251     * @return  remote ip address
       
   252     */
       
   253     TInetAddr RemoteIpAddress() const;
       
   254 
       
   255     /**
       
   256     * Gets codec of the mcc stream. 
       
   257     * @return codec of the mcc stream. 
       
   258     */
       
   259     CMceComCodec& Codec() const;
       
   260 
       
   261     /**
       
   262     * Gets source of the mcc stream.
       
   263     * @return source of the mcc stream.
       
   264     */
       
   265     CMceSrvSource& Source() const;
       
   266 
       
   267     /**
       
   268     * Gets sink of the mcc stream. 
       
   269     * @return sink of the mcc stream. 
       
   270     */
       
   271     CMceSrvSink& Sink() const;
       
   272     
       
   273 
       
   274     /**
       
   275     * Gets mcc stream type
       
   276     * @return mcc stream type
       
   277     */
       
   278     TInt MccStreamType() const;
       
   279 
       
   280     /**
       
   281     * Gets mcc link type
       
   282     * @return mcc link
       
   283     */
       
   284     TInt LinkType() const;
       
   285 
       
   286     /**
       
   287     * Checks, if received event matches
       
   288     * @param aEvent an event
       
   289     * @return ETrue, if there is a match
       
   290     */
       
   291     TBool Consumes( const TMceMccComEvent& aEvent ) const;
       
   292     
       
   293     /**
       
   294     * Returns dtmf handler for the stream.
       
   295     * @return dtmf handler
       
   296     */
       
   297     CMceDtmfHandler& DtmfHandlerL( CMccInterface& aMccInterface );
       
   298     
       
   299     /**
       
   300     * Updates sink/source's "is enabled" status.
       
   301     * @param aSinkAffected if sink status is changed
       
   302     * @param aSourceAffected if source status is changed
       
   303     * @param aIsEnabled
       
   304     */
       
   305     void UpdateEndpointStates( TBool aSinkAffected, 
       
   306                                TBool aSourceAffected, 
       
   307                                TBool aIsEnabled );
       
   308     
       
   309     /**
       
   310     * Checks whether stream is associated with certain endpoint.
       
   311     * @param aEndpoint search term
       
   312     * @param aUseProxyMatch
       
   313     */
       
   314     TBool EndpointMatch( const CMceComEndpoint& aEndpoint, 
       
   315                          TBool aUseProxyMatch );
       
   316     
       
   317 public: // new 
       
   318 
       
   319 
       
   320     /**
       
   321     * Hook to allow stream to have alternative create link sequence
       
   322     * @return EFalse to indicate that normal link creation can 
       
   323     * take place. ETrue indicates that link creation is not needed
       
   324     */
       
   325     TBool CreateLinkL();
       
   326     
       
   327     /**
       
   328     * Hook to allow stream to have alternative preparation
       
   329     * @return EFalse to indicate that normal preparation can 
       
   330     * take place. ETrue indicates that stream has been prepared 
       
   331     * by itself
       
   332     */
       
   333     TBool PrepareL();
       
   334 
       
   335     /**
       
   336     * Hook to allow stream to have alternative starting
       
   337     * @return EFalse to indicate that normal starting can 
       
   338     * take place. ETrue indicates that stream has been started 
       
   339     * by itself
       
   340     */
       
   341     TBool StartL();
       
   342 
       
   343     /**
       
   344     * Hook to allow stream to have alternative updating
       
   345     * @return EFalse to indicate that normal updating can 
       
   346     * take place. ETrue indicates that stream has been updated 
       
   347     * by itself
       
   348     */
       
   349     TBool SynchronizeL();
       
   350 
       
   351     /**
       
   352     * Hook to allow stream to have alternative stopping
       
   353     * @return EFalse to indicate that normal stopping can 
       
   354     * take place. ETrue indicates that stream has been stopped 
       
   355     * by itself
       
   356     */
       
   357     TBool Stop();
       
   358 
       
   359     /**
       
   360     * Hook to allow stream to have alternative validation
       
   361     * @return EFalse to indicate that normal validation can 
       
   362     * take place. ETrue indicates that stream has been validated 
       
   363     * by itself
       
   364     */
       
   365     TBool Validate();
       
   366     
       
   367     /**
       
   368     * Called as a part of session unmerge
       
   369     */
       
   370     void UnMerge();
       
   371     
       
   372     /**
       
   373     * Checks if update requires signalling
       
   374     * @param aCurrent current stream, if NULL this is a new stream
       
   375     * @param aMccCurentCodec current codec, if NULL this is a new stream
       
   376     * @param aMccUpdateCodec codec based on update (this)
       
   377     * @return indication of signaling required
       
   378     */
       
   379     TInt RequireSignalling( CMceSrvStream& aCurrent,
       
   380                              CMccCodecInformation& aMccCurentCodec, 
       
   381                              CMccCodecInformation& aMccUpdateCodec ) const;
       
   382                              
       
   383     /**
       
   384     * Called when new stream has beed detected in update
       
   385     * @param aUpdateStreams new streams from update
       
   386     * @return indication of signaling required
       
   387     */
       
   388     TInt RequireSignalling( RPointerArray<CMceSrvStream>& aUpdateStreams ) const;
       
   389     
       
   390     
       
   391     /**
       
   392     * Called after prepare is called for this
       
   393     * stream
       
   394     */
       
   395     void MccPrepareCalledL();
       
   396     
       
   397     
       
   398 protected://CMcc
       
   399 
       
   400     /**
       
   401      * C++ default constructor.
       
   402      */
       
   403     CMceSrvStream();
       
   404     
       
   405 
       
   406     /**
       
   407      * C++ default constructor.
       
   408      */
       
   409     CMceSrvStream( CMceMediaManager* aManager,
       
   410                    CMceComMediaStream* aData,
       
   411                    CMceComCodec* aCodec );
       
   412                    
       
   413     void ConstructL( CMceComMediaSource& aSource,
       
   414                      CMceComMediaSink& aSink );
       
   415 
       
   416 
       
   417 private: // 
       
   418 
       
   419 
       
   420     static void DecodeAudioL( RPointerArray<CMceSrvStream>& aStreams,
       
   421                               CMceComAudioStream& aAudio,
       
   422                               CMceMediaManager& aManager );
       
   423                               
       
   424     static void DecodeVideoL( RPointerArray<CMceSrvStream>& aStreams,
       
   425                               CMceComVideoStream& aVideo,
       
   426                               CMceMediaManager& aManager );
       
   427                               
       
   428     TBool UseDefaultStartupSequence();
       
   429     
       
   430     TBool StreamStateChangeEventReceived( TMceMccComEvent& aEvent );
       
   431     
       
   432     void DoEndpointDisable( CMceSrvEndpoint& aEndpoint );
       
   433                                       
       
   434 protected://not owned data
       
   435 
       
   436     CMceMediaManager* iManager;
       
   437 
       
   438 protected: // owned data
       
   439     
       
   440     CMceSrvSource* iSource;
       
   441     CMceSrvSink* iSink;
       
   442     CMceComMediaStream* iData;
       
   443     CMceComCodec* iCodec;
       
   444 
       
   445     TBool iMerged;
       
   446     
       
   447     CMceDtmfHandler* iDtmfHandler;
       
   448     
       
   449 protected: // NOT owned data
       
   450 
       
   451     TUint32 iID;
       
   452 
       
   453     friend class CMceAdoptedSrvStream;
       
   454     
       
   455 	//definitions for unit testing
       
   456 	MCEMM_UT_DEFINITIONS
       
   457     
       
   458     };
       
   459 
       
   460 
       
   461 
       
   462 #endif //CMCESRVSTREAM_H