multimediacommscontroller/mmccanysourcesink/inc/mccanysource.h
changeset 0 1bce908db942
child 49 64c62431ac08
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 #ifndef MCCANYSOURCE_H
       
    22 #define MCCANYSOURCE_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include "mccdatasource.h"
       
    26 #include "mmccevents.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 
       
    30 /**
       
    31 *  
       
    32 */
       
    33 class CMccAnySource: public CMccDataSource
       
    34     {
       
    35 
       
    36     public: // Methods called internally or by the controller
       
    37 
       
    38         /**
       
    39         * Two-phased constructor.
       
    40         */
       
    41         static MDataSource* NewSourceL( TUid aImplementationUid, 
       
    42                                         const TDesC8& aInitData );
       
    43                                         
       
    44 		void ConstructSourceL( const TDesC8& aInitData );
       
    45 		
       
    46 		~CMccAnySource();
       
    47 
       
    48     public: // From MDataSource
       
    49 
       
    50         /**
       
    51         * From MDataSource. Returns the data type as a fourCC code of the data source.
       
    52         *
       
    53         * @since    Series 60 3.0
       
    54         * @param    "aMediaId"
       
    55         *           This identifies the type of media eg audio or video and the stream id.
       
    56         *           Only KUidMediaTypeAudio -mediatype is supported.
       
    57         * @return    The fourCC code identifying the source datatype for the specified aMediaId.
       
    58         */
       
    59         TFourCC SourceDataTypeCode( TMediaId /*aMediaId*/ );
       
    60 
       
    61         /**
       
    62         * From MDataSource. Sets the data type as a fourCC code for the data source
       
    63         *
       
    64         * @since    Series 60 3.0
       
    65         * @param    "aSourceFourCC"
       
    66         *            This specifies the data type as a fourCC code to set the source to.
       
    67         *
       
    68         * @param    "aMediaId"
       
    69         *            This identifies the type of media eg audio or video and the stream id.
       
    70         *           Only KUidMediaTypeAudio -mediatype is supported.
       
    71         *
       
    72         * @return    KErrNone if successful, KErrNotSupported if the source does not support having
       
    73         *            it's data type set, otherwise a system wide error code.
       
    74         */
       
    75         TInt SetSourceDataTypeCode( TFourCC aCodec, 
       
    76                                     TMediaId aMedia );
       
    77 
       
    78         /**
       
    79         * From MDataSource. Not used. Leaves with KErrNotSupported.
       
    80         * 
       
    81         * @since    Series 60 3.0
       
    82         * @param    "aBuffer"
       
    83         *            The buffer that has been emptied by a data sink and is now available for reuse
       
    84         * @return   None
       
    85         */
       
    86         void BufferEmptiedL( CMMFBuffer* aBuffer );
       
    87         
       
    88         /**
       
    89         * From MDataSource. Method to indicate whether the data source can create a buffer.
       
    90         *
       
    91         * @since    Series 60 3.0
       
    92         * 
       
    93         * @return    EFalse
       
    94         */
       
    95         TBool CanCreateSourceBuffer();
       
    96         
       
    97         /**
       
    98         * From MDataSource. Not used. Leaves with KErrNotSupported.
       
    99         *
       
   100         * @since    Series 60 3.0
       
   101         * @param    "aMediaId"
       
   102         *           This identifies the type of media eg audio or video and the stream id.
       
   103         *           This parameter is required in cases where the source can supply data
       
   104         *           of more than one media type and/or multiple strams of data eg a multimedia file.
       
   105         *
       
   106         * @param    "aReference"
       
   107         *           This must be written to by the method to indicate whether the created buffer is
       
   108         *           a 'reference' buffer.  A 'reference' buffer is a buffer that is owned by the source
       
   109         *           and should be used in preference to the sink buffer provided the sink buffer
       
   110         *           is also not a reference buffer.
       
   111         * .  
       
   112         * @return   The created buffer
       
   113         */
       
   114         CMMFBuffer* CreateSourceBufferL( TMediaId, 
       
   115                                          TBool& aReference );
       
   116         
       
   117         /**
       
   118         * From MDataSource. Method to 'logon' the data source to the same thread that source will be supplying data in.
       
   119         *
       
   120         * Jitterbuffer for incoming packets and downlink timeout timer are created here.
       
   121         * 
       
   122         * @param    "aEventHandler"
       
   123         *           This is an MAsyncEventHandler to handle asynchronous events that occur during the
       
   124         *           transfer of multimedia data.  The event handler must be in the same thread as the data transfer
       
   125         *           thread - hence the reason it is passed in the SourceThreadLogon as opposed to say the constructor.
       
   126         *
       
   127         *
       
   128         * @return   KErrNone if successful, otherwise a system wide error code.
       
   129         */
       
   130         TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler );
       
   131         
       
   132         /**
       
   133         * From MDataSource. Method to 'logoff' the data source from the same thread that source supplies data in.
       
   134         *
       
   135         * Jitterbuffer for incoming packets and downlink timeout timer are deleted. Datasource deletes the 
       
   136         * stream(s) and unregisters itself as an observer for the RTP session for incoming RTP and RTCP packets.
       
   137         *
       
   138         * @return None
       
   139         */
       
   140         void SourceThreadLogoff();
       
   141 
       
   142         /**
       
   143         * From MDataSource. Method to 'prime' the data source.
       
   144         *
       
   145         * Datasource is set to primed state.
       
   146         *
       
   147         * @since    Series 60 3.0
       
   148         * @return   None
       
   149         */
       
   150         void SourcePrimeL();
       
   151         
       
   152         /**
       
   153         * From MDataSource. Method to 'play' the data source.
       
   154         *
       
   155         * Downlink timeout timer is started and datasource is set to playing state.
       
   156         *
       
   157         * @since    Series 60 3.0
       
   158         * @return   None
       
   159         */
       
   160         void SourcePlayL();
       
   161         
       
   162         /**
       
   163         * From MDataSource. Method to 'pause' the data source.
       
   164         *
       
   165         * Downlink timeout timer is stopped and datasource is set to paused state.
       
   166         *
       
   167         * @since    Series 60 3.0
       
   168         * @return   None
       
   169         */
       
   170         void SourcePauseL();
       
   171         
       
   172         /**
       
   173         * From MDataSource. Method to 'stop' the data source.
       
   174         *
       
   175         * Downlink timeout timer is stopped and datasource is set to stopped state.
       
   176         *
       
   177         * @since    Series 60 3.0
       
   178         * @return   None
       
   179         */
       
   180         void SourceStopL();
       
   181 
       
   182         /**
       
   183         * From MDataSource. Method called by a MDataSink to request the data source to fill aBuffer with data.
       
   184         *
       
   185         * Datasource gets packet from jitterbuffer and forwards it to the payloadformatdecoder
       
   186         * for further processing. Datasource works synchronously; consumers BufferFilledL
       
   187         * is called when RTP packet is got succesfully from jitterbuffer.
       
   188         * 
       
   189         * @since    Series 60 3.0
       
   190         * @param    "aBuffer"
       
   191         *           The buffer that needs filling with data
       
   192         *
       
   193         * @param    "aConsumer" 
       
   194         *           The data sink that consumes the data. The data source needs this to make the BufferFilledL
       
   195         *           callback on aConsumer when the data source has completed filling the aBuffer.
       
   196         *
       
   197         * @param    "aMediaId"
       
   198         *           This identifies the type of media eg audio or video and the stream id.
       
   199         *           This parameter is required in cases where the source can supply data
       
   200         *           of more than one media type and/or multiple strams of data eg a multimedia file.
       
   201         * @return   None
       
   202         */
       
   203         void FillBufferL( CMMFBuffer* aBuffer,
       
   204                           MDataSink* aConsumer,
       
   205                           TMediaId aMediaId );
       
   206                           
       
   207         /**
       
   208         * From MDataSource
       
   209         */
       
   210         void NegotiateSourceL( MDataSink& aDataSink );	
       
   211         
       
   212     private:
       
   213     	
       
   214 		CMccAnySource();
       
   215 		
       
   216 		void SendStreamEventToClient( TMccEventType aEventType, 
       
   217 		                              TInt aError = KErrNone );
       
   218 
       
   219     private:
       
   220     
       
   221         MAsyncEventHandler* iAsyncEventHandler;
       
   222 	    TBool iPaused;
       
   223 	    TFourCC iFourCC;
       
   224 
       
   225 	#ifdef EUNIT_TEST
       
   226         friend class UT_CMccAnySource;
       
   227     #endif	
       
   228 	
       
   229 	};
       
   230 
       
   231 
       
   232 #endif 
       
   233 
       
   234 
       
   235 // End of file