tsrc/mceclientstub/inc/mcemediastream.h
changeset 0 f0cf47e981f9
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     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 #ifndef CMCEMEDIASTREAM_H
       
    20 #define CMCEMEDIASTREAM_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // DATA TYPES
       
    26 typedef TUint TMceMediaType;
       
    27  
       
    28 // FORWARD DECLARATIONS
       
    29 class CMceComMediaStream;
       
    30 class TMceFactory;
       
    31 class TMceMediaStreamFactory;
       
    32 class RWriteStream;
       
    33 class RReadStream;
       
    34 class CDesC8Array;
       
    35 class CMceSession;
       
    36 class TMceIds;
       
    37 class TMceEvent;
       
    38 class TMceMediaId;
       
    39 class CMceManager;
       
    40 class CMceSession;
       
    41 class CMceMediaSource;
       
    42 class CMceMediaSink;
       
    43 class MMceComSerializationContext;
       
    44 class MDesC8Array;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 * Base class for MCE media streams.
       
    50 *
       
    51 * MCE Media stream represents stream of data negotiated between two terminals.
       
    52 * Streams may transfer any data.
       
    53 *
       
    54 * Enabling or disabling of a stream is not a local operation, but it requires
       
    55 * always signalling. Thus, these operation require always to be completed by
       
    56 * calling CMceSession::UpdateL() function.
       
    57 *
       
    58 *  @lib mceclient.lib
       
    59 */
       
    60 class CMceMediaStream : public CBase
       
    61 	{
       
    62     public: // Stream states
       
    63 
       
    64         enum TState
       
    65             {
       
    66             EUninitialized,       // Stream is created
       
    67             EInitialized,         // Stream is initialized
       
    68             EBuffering,           // Stream is buffering
       
    69             EIdle,                // Stream is not receiving RTP
       
    70             EStreaming,           // Stream is streaming
       
    71             EDisabled,            // Stream is explicitly disabled
       
    72             ENoResources,         // Stream has no needed resources to stream
       
    73             ETranscodingRequired, // Stream requires non-realtime transcoding
       
    74             ETranscoding          // Stream is transcoding in non-realtime
       
    75             };
       
    76 	        
       
    77 	public: // Destructor
       
    78 
       
    79 	    /**
       
    80 	    * Destructor.
       
    81 	    */
       
    82 		IMPORT_C ~CMceMediaStream();
       
    83 
       
    84 	public: // Functions
       
    85 
       
    86         /**
       
    87         * Gets the state of the stream.
       
    88         * @return the current state of the stream
       
    89         */
       
    90         IMPORT_C CMceMediaStream::TState State() const;
       
    91 
       
    92 	    /**
       
    93 	    * Returns the type of the stream.
       
    94 	    * @return The type of the stream.
       
    95 	    */
       
    96 		IMPORT_C TMceMediaType Type() const;
       
    97 
       
    98 	    /**
       
    99 		* Configures media stream by updating SDP media lines. 
       
   100 		* In order to get complete update, whole session must be 
       
   101 		* updated causing sending of re-invite.
       
   102 	    * @param aMediaSDPLines, application specific SDP media lines for
       
   103 		*		 the stream. Ownership is transferred.
       
   104 	    */
       
   105 		IMPORT_C void SetMediaAttributeLinesL( CDesC8Array* aMediaSDPLines );
       
   106 		
       
   107 		/**
       
   108 		* Gets attribute lines of the media.
       
   109 		* @return array of media attribute lines, owneship is transferred.
       
   110 		*/
       
   111 		IMPORT_C MDesC8Array* MediaAttributeLinesL();
       
   112 		
       
   113 		/** 
       
   114 	    * Sets local media port
       
   115 	    * @param aLocalMediaPort, local port for the media
       
   116 	    */
       
   117 	    IMPORT_C void SetLocalMediaPortL(TUint aLocalMediaPort); 
       
   118 	    
       
   119 	    /**
       
   120 	    * Gets the local media port.
       
   121 	    * @return Local port used for media.
       
   122 	    */
       
   123 	    IMPORT_C TUint LocalMediaPort() const;
       
   124 	    
       
   125 	    /**
       
   126 	    * Gets the session this stream belongs to, if exists. The
       
   127 	    * ownership is not transfered.
       
   128 	    * @return Session object
       
   129 	    */
       
   130 		IMPORT_C CMceSession* Session() const;
       
   131 	              
       
   132 
       
   133 	public: // Local stream control
       
   134 
       
   135 	    /**
       
   136 	    * Enables streaming explicitly.
       
   137 	    */
       
   138 	    virtual void EnableL(); 
       
   139 
       
   140 	    /**
       
   141 	    * Disables streaming explicitly.
       
   142 	    */
       
   143 		virtual void DisableL(); 
       
   144 		
       
   145 		/**
       
   146 	    * Returns the state of the stream.
       
   147 	    * @return ETrue if enabled, EFalse if disabled.
       
   148 	    */
       
   149     	IMPORT_C TBool IsEnabled() const;
       
   150 
       
   151 
       
   152     public: // Source and sink functions
       
   153 
       
   154         /**
       
   155         * Adds source to the stream. CMceMediaStream can only
       
   156         * have one source at a time. Ownership of passed source is transferred.
       
   157         * However, the same source can be also passed to other streams resulting
       
   158         * that streams share ownership of the source. Passing NULL source will
       
   159         * remove source from stream.
       
   160         * In some cases the source might contain a codec. The codec is derived
       
   161         * to the stream when such source is added to the stream. 
       
   162         * Derived codec will get automatically highest preference.
       
   163         * @param aSource source to be added to the stream; ownership is 
       
   164         *        transferred
       
   165         */
       
   166         IMPORT_C void SetSourceL( CMceMediaSource* aSource );
       
   167 
       
   168         /**
       
   169         * Adds sink to the stream. CMceMediaStream can have
       
   170         * many sinks at a time. Ownership of passed sink is transferred.
       
   171         * However, the same sink can be also passed to other streams resulting
       
   172         * that streams share ownership of the sink.
       
   173         * @param aSink sink to be added to the stream; ownership is transferred
       
   174         */
       
   175         IMPORT_C void AddSinkL( CMceMediaSink* aSink );
       
   176 
       
   177         /**
       
   178         * Gets source of the stream. Returns NULL if source is not set.
       
   179         * @return source of the stream; ownership is not transferred
       
   180         */
       
   181         IMPORT_C CMceMediaSource* Source() const;
       
   182 
       
   183         /**
       
   184         * Gets array of sinks of the stream.
       
   185         * @return array of sinks
       
   186         */
       
   187         IMPORT_C const RPointerArray<CMceMediaSink>& Sinks() const;
       
   188 
       
   189         /**
       
   190         * Removes sink from the stream.
       
   191         * @post aSink cannot be used anymore and contents of 
       
   192         *       previously returned sink array (CMceMediaStream::Sinks())
       
   193         *       are not anymore valid
       
   194         * @param aSink sink to be removed from the stream
       
   195         */
       
   196         IMPORT_C void RemoveSinkL( CMceMediaSink& aSink );
       
   197 
       
   198     public: // Binding opposite way stream
       
   199 
       
   200         /**
       
   201         * Binds opposite direction stream to this stream.
       
   202         * @param aStream another stream to be bind to the stream; 
       
   203         *        ownership is transferred
       
   204         */
       
   205         IMPORT_C void BindL( CMceMediaStream* aStream );
       
   206 
       
   207         /**
       
   208         * Gets opposite direction stream of this stream.
       
   209         * @return opposite direction stream
       
   210         */
       
   211         IMPORT_C CMceMediaStream& BoundStreamL() const;
       
   212 
       
   213         /**
       
   214         * Checks if opposite direction stream is set.
       
   215         * @return ETrue if opposite direction stream is set; 
       
   216         *         otherwise EFalse
       
   217         */
       
   218         IMPORT_C TBool BoundStream() const;
       
   219 
       
   220 
       
   221 	public: //internal
       
   222 
       
   223 	    /**
       
   224 	    * Checks if this is binder (biding owner)
       
   225 	    * @return ETrue if this is binder (biding owner)
       
   226 	    */
       
   227 		TBool Binder() const;
       
   228 
       
   229 	    /**
       
   230 	    * Initializes 
       
   231 	    * @param aParent the parent
       
   232 	    */
       
   233 	    virtual void InitializeL( CMceSession& aParent );
       
   234 	    
       
   235 	    /**
       
   236 	    * Initializes 
       
   237 	    * @param aManager the manager. Ownership is NOT transferred
       
   238 	    */
       
   239 	    virtual void InitializeL( CMceManager* aManager );
       
   240 	    
       
   241 	protected:
       
   242 
       
   243 	    /**
       
   244 	     * C++ default constructor.
       
   245 	     */
       
   246 		CMceMediaStream();
       
   247 
       
   248 	private:
       
   249 
       
   250 	    /**
       
   251 	    * Handles event
       
   252 	    * @param aEvent the event
       
   253 	    * @return status, if event was consumed or not or object needs update
       
   254 	    */
       
   255 	    TInt HandleEvent( TMceEvent& aEvent );
       
   256 
       
   257 	    /**
       
   258 	    * one-way bind
       
   259 	    * @param aStream another stream to be bind to the stream.
       
   260 	    */
       
   261 	    void DoBindL( CMceMediaStream* aStream );
       
   262 	    
       
   263 	    /**
       
   264 	    * Deletes sink
       
   265 	    * @param aIndex index of sink in the array
       
   266 	    */
       
   267         void DeleteSink( TInt aIndex );
       
   268         
       
   269 	    /**
       
   270 	    * Deletes source
       
   271 	    */
       
   272     	void DeleteSource();
       
   273 	    
       
   274 
       
   275 	protected: // NOT owned data
       
   276 				
       
   277 	    /**
       
   278 	     * session
       
   279 	     */
       
   280 		CMceSession* iSession;
       
   281 		
       
   282 	protected: // owned data
       
   283 
       
   284 
       
   285 	    /**
       
   286 	     * linked stream. Owned if iLinkOwner is ETrue
       
   287 	     */
       
   288 	    CMceMediaStream* iLinkedStream;	    
       
   289 
       
   290     public: // stub data
       
   291     
       
   292         /**
       
   293 	     * source
       
   294 	     */
       
   295 		CMceMediaSource* iSource;
       
   296 		
       
   297 		/**
       
   298 	     * sinks
       
   299 	     */
       
   300 		RPointerArray<CMceMediaSink> iSinks;
       
   301     
       
   302         TState iState;
       
   303     
       
   304         TMceMediaType iType;
       
   305     
       
   306         TBool iLinkOwner;
       
   307 
       
   308         TBool iIsEnabled;
       
   309         
       
   310         TUint iLocalMediaPort;
       
   311         
       
   312         CDesC8Array* iMediaSDPLines;
       
   313 	};
       
   314 
       
   315 
       
   316 #endif