multimediacommscontroller/mmccfilesourcesink/inc/mccfilesource.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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 MCCFILESOURCE_H
       
    22 #define MCCFILESOURCE_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include "mccdatasource.h"
       
    26 
       
    27 
       
    28 class CMccFileSourceImpl;
       
    29 class TMccFileSourceSetting;
       
    30 
       
    31 /**
       
    32 *  
       
    33 */
       
    34 class CMccFileSource: public CMccDataSource
       
    35     {
       
    36 
       
    37     public: // Methods called internally or by the controller
       
    38 
       
    39         /**
       
    40         * Two-phased constructor.
       
    41         */
       
    42         static MDataSource* NewSourceL( TUid aImplementationUid, 
       
    43                                         const TDesC8& aInitData );
       
    44                                         
       
    45 		void ConstructSourceL ( const TDesC8& aInitData );
       
    46 		
       
    47 		CMccFileSource();
       
    48 		
       
    49 		virtual ~CMccFileSource();
       
    50 
       
    51     public: // From CMccDataSource
       
    52     
       
    53         virtual void GetParameterL( TUint32 aParam, TDes8& aVal );
       
    54         
       
    55         virtual void SetParameterL( TUint32 aParam, const TDesC8& aVal );
       
    56         
       
    57     public:
       
    58     
       
    59 	    /**
       
    60 	    * Opens a 3GP file for streaming
       
    61 	    * @since SWIS Lite
       
    62 	    * @param TFileName aFileName
       
    63 	    */
       
    64 	    virtual void OpenFileL( TFileName aFileName, TBool aFileChangeMode = EFalse );
       
    65 
       
    66 	    /**
       
    67 	    * Closes the 3GP file
       
    68 	    * @since SWIS Lite
       
    69 	    */
       
    70 	    virtual void CloseFileL();
       
    71 
       
    72         /**
       
    73 	    * Gets filename
       
    74 	    */
       
    75         TFileName& FileNameL();
       
    76         
       
    77 	    /**
       
    78 	    * Seeks to given position in a file
       
    79 	    * @since SWIS Lite
       
    80 	    * @param TTimeIntervalMicroSeconds aPosition
       
    81 	    */
       
    82 	    virtual void SetPositionL( TTimeIntervalMicroSeconds aPosition );
       
    83 	    
       
    84 	    /**
       
    85 	    * Returns the current video framerate
       
    86 	    * @since SWIS Lite
       
    87 	    * @return TReal32
       
    88 	    */
       
    89 	    virtual TReal VideoFrameRateL();
       
    90 
       
    91 	    /**
       
    92 	    * Returns the current audio bitrate
       
    93 	    * @since SWIS Lite
       
    94 	    * @return TUint
       
    95 	    */
       
    96 	    virtual TUint32 AudioBitRateL();
       
    97 
       
    98 	    /**
       
    99 	    * Returns the duration of media clip
       
   100 	    * @since SWIS Lite
       
   101 	    * @return TTimeIntervalMicroSeconds
       
   102 	    */
       
   103 	    virtual TTimeIntervalMicroSeconds DurationL();
       
   104 
       
   105 	    /**
       
   106 	    * Returns the video framesize
       
   107 	    * @since SWIS Lite
       
   108 	    * @return TSize
       
   109 	    */
       
   110 	    virtual TSize VideoFrameSizeL();
       
   111 
       
   112 	    /**
       
   113 	    * Returns the video bitrate
       
   114 	    * @since SWIS Lite
       
   115 	    * @return TUint
       
   116 	    */
       
   117 	    virtual TUint32 VideoBitRateL();
       
   118 
       
   119 	    /**
       
   120 	    * Returns the current reading position
       
   121 	    * @since SWIS Lite
       
   122 	    * @return TTimeIntervalMicroSeconds
       
   123 	    */
       
   124 	    virtual TTimeIntervalMicroSeconds PositionL();
       
   125 	    
       
   126 	    /**
       
   127 	    * Returns the audio fourCC
       
   128 	    * @return TFourCC
       
   129 	    */
       
   130 	    virtual TFourCC AudioFourCCL();
       
   131 	    
       
   132 	    /**
       
   133 	    * Returns the video fourCC
       
   134 	    * @return TFourCC
       
   135 	    */
       
   136 	    virtual TFourCC VideoFourCCL();
       
   137 	    
       
   138     private: // From MDataSource
       
   139 	    
       
   140 	    /**
       
   141 	    * Reads audio frames from file
       
   142 	    * @since SWIS Lite
       
   143 	    * @param 
       
   144 	    * @return
       
   145 	    */
       
   146 	    void ReadAudioFrameL();
       
   147 
       
   148 	    /**
       
   149 	    * Reads one video frame from file
       
   150 	    * @since SWIS Lite
       
   151 	    * @param 
       
   152 	    * @return
       
   153 	    */
       
   154 	    void ReadVideoFrameL();
       
   155 	    
       
   156 	    //\// Callback functions for timers
       
   157 	    /**
       
   158 	    * Callback function for periodic timer
       
   159 	    * @since SWIS Lite
       
   160 	    * @param TAny*
       
   161 	    * @return TInt
       
   162 	    */
       
   163 	    static TInt TickAudio( TAny* aObject ); 
       
   164 
       
   165 	    /**
       
   166 	    * Callback function for periodic timer
       
   167 	    * @since SWIS Lite
       
   168 	    * @param TAny*
       
   169 	    * @return TInt
       
   170 	    */
       
   171 	    static TInt TickVideo( TAny* aObject );
       
   172 	
       
   173     public: // From MDataSource
       
   174 
       
   175         /**
       
   176         * From MDataSource. Returns the data type as a fourCC code of the data source.
       
   177         *
       
   178         * @since    Series 60 3.0
       
   179         * @param    "aMediaId"
       
   180         *           This identifies the type of media eg audio or video and the stream id.
       
   181         *           Only KUidMediaTypeAudio -mediatype is supported.
       
   182         * @return    The fourCC code identifying the source datatype for the specified aMediaId.
       
   183         */
       
   184         TFourCC SourceDataTypeCode( TMediaId /*aMediaId*/ );
       
   185 
       
   186         /**
       
   187         * From MDataSource. Sets the data type as a fourCC code for the data source
       
   188         *
       
   189         * @since    Series 60 3.0
       
   190         * @param    "aSourceFourCC"
       
   191         *            This specifies the data type as a fourCC code to set the source to.
       
   192         *
       
   193         * @param    "aMediaId"
       
   194         *            This identifies the type of media eg audio or video and the stream id.
       
   195         *           Only KUidMediaTypeAudio -mediatype is supported.
       
   196         *
       
   197         * @return    KErrNone if successful, KErrNotSupported if the source does not support having
       
   198         *            it's data type set, otherwise a system wide error code.
       
   199         */
       
   200         TInt SetSourceDataTypeCode( TFourCC aCodec, 
       
   201                                     TMediaId aMedia );
       
   202 
       
   203         /**
       
   204         * From MDataSource. Not used. Leaves with KErrNotSupported.
       
   205         * 
       
   206         * @since    Series 60 3.0
       
   207         * @param    "aBuffer"
       
   208         *            The buffer that has been emptied by a data sink and is now available for reuse
       
   209         * @return   None
       
   210         */
       
   211         void BufferEmptiedL( CMMFBuffer* aBuffer );
       
   212         
       
   213         /**
       
   214         * From MDataSource. Method to indicate whether the data source can create a buffer.
       
   215         *
       
   216         * @since    Series 60 3.0
       
   217         * 
       
   218         * @return    EFalse
       
   219         */
       
   220         TBool CanCreateSourceBuffer();
       
   221         
       
   222         /**
       
   223         * From MDataSource. Not used. Leaves with KErrNotSupported.
       
   224         *
       
   225         * @since    Series 60 3.0
       
   226         * @param    "aMediaId"
       
   227         *           This identifies the type of media eg audio or video and the stream id.
       
   228         *           This parameter is required in cases where the source can supply data
       
   229         *           of more than one media type and/or multiple strams of data eg a multimedia file.
       
   230         *
       
   231         * @param    "aReference"
       
   232         *           This must be written to by the method to indicate whether the created buffer is
       
   233         *           a 'reference' buffer.  A 'reference' buffer is a buffer that is owned by the source
       
   234         *           and should be used in preference to the sink buffer provided the sink buffer
       
   235         *           is also not a reference buffer.
       
   236         * .  
       
   237         * @return   The created buffer
       
   238         */
       
   239         CMMFBuffer* CreateSourceBufferL( TMediaId, 
       
   240                                          TBool& aReference );
       
   241         
       
   242         /**
       
   243         * From MDataSource. Method to 'logon' the data source to the same thread that source will be supplying data in.
       
   244         *
       
   245         * Jitterbuffer for incoming packets and downlink timeout timer are created here.
       
   246         * 
       
   247         * @param    "aEventHandler"
       
   248         *           This is an MAsyncEventHandler to handle asynchronous events that occur during the
       
   249         *           transfer of multimedia data.  The event handler must be in the same thread as the data transfer
       
   250         *           thread - hence the reason it is passed in the SourceThreadLogon as opposed to say the constructor.
       
   251         *
       
   252         *
       
   253         * @return   KErrNone if successful, otherwise a system wide error code.
       
   254         */
       
   255         TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler );
       
   256         
       
   257         /**
       
   258         * From MDataSource. Method to 'logoff' the data source from the same thread that source supplies data in.
       
   259         *
       
   260         * Jitterbuffer for incoming packets and downlink timeout timer are deleted. Datasource deletes the 
       
   261         * stream(s) and unregisters itself as an observer for the RTP session for incoming RTP and RTCP packets.
       
   262         *
       
   263         * @return None
       
   264         */
       
   265         void SourceThreadLogoff();
       
   266 
       
   267         /**
       
   268         * From MDataSource. Method to 'prime' the data source.
       
   269         *
       
   270         * Datasource is set to primed state.
       
   271         *
       
   272         * @since    Series 60 3.0
       
   273         * @return   None
       
   274         */
       
   275         void SourcePrimeL();
       
   276         
       
   277         /**
       
   278         * From MDataSource. Method to 'play' the data source.
       
   279         *
       
   280         * Downlink timeout timer is started and datasource is set to playing state.
       
   281         *
       
   282         * @since    Series 60 3.0
       
   283         * @return   None
       
   284         */
       
   285         void SourcePlayL();
       
   286         
       
   287         /**
       
   288         * From MDataSource. Method to 'pause' the data source.
       
   289         *
       
   290         * Downlink timeout timer is stopped and datasource is set to paused state.
       
   291         *
       
   292         * @since    Series 60 3.0
       
   293         * @return   None
       
   294         */
       
   295         void SourcePauseL();
       
   296         
       
   297         /**
       
   298         * From MDataSource. Method to 'stop' the data source.
       
   299         *
       
   300         * Downlink timeout timer is stopped and datasource is set to stopped state.
       
   301         *
       
   302         * @since    Series 60 3.0
       
   303         * @return   None
       
   304         */
       
   305         void SourceStopL();
       
   306 
       
   307         /**
       
   308         * From MDataSource. Method called by a MDataSink to request the data source to fill aBuffer with data.
       
   309         *
       
   310         * Datasource gets packet from jitterbuffer and forwards it to the payloadformatdecoder
       
   311         * for further processing. Datasource works synchronously; consumers BufferFilledL
       
   312         * is called when RTP packet is got succesfully from jitterbuffer.
       
   313         * 
       
   314         * @since    Series 60 3.0
       
   315         * @param    "aBuffer"
       
   316         *           The buffer that needs filling with data
       
   317         *
       
   318         * @param    "aConsumer" 
       
   319         *           The data sink that consumes the data. The data source needs this to make the BufferFilledL
       
   320         *           callback on aConsumer when the data source has completed filling the aBuffer.
       
   321         *
       
   322         * @param    "aMediaId"
       
   323         *           This identifies the type of media eg audio or video and the stream id.
       
   324         *           This parameter is required in cases where the source can supply data
       
   325         *           of more than one media type and/or multiple strams of data eg a multimedia file.
       
   326         * @return   None
       
   327         */
       
   328         void FillBufferL( CMMFBuffer* aBuffer,
       
   329                           MDataSink* aConsumer,
       
   330                           TMediaId aMediaId );
       
   331                           
       
   332         /**
       
   333         * From MDataSource
       
   334         */
       
   335         void NegotiateSourceL( MDataSink& aDataSink );	
       
   336 
       
   337     private:
       
   338 
       
   339 		/**
       
   340 	    * Updates the current reading position
       
   341 	    * @since SWIS Lite
       
   342 	    * @param 
       
   343 	    */
       
   344 	    void UpdatePositionL();
       
   345 
       
   346 		/**
       
   347 	    * Returns the frame lenght from given audio sample
       
   348 	    * @since SWIS Lite
       
   349 	    */
       
   350 		TUint GetFrameLength( TPtrC8 aData );
       
   351 		
       
   352 		void GetFileInfoL( TMccFileSourceSetting& aSettings );
       
   353 
       
   354     private:
       
   355 	
       
   356 		CMccFileSourceImpl*   iSourceImpl;
       
   357 	#ifdef EUNIT_TEST
       
   358         friend class UT_CMccFileSource;
       
   359         friend class UT_CMccMultiplexer;
       
   360     #endif	
       
   361 	
       
   362 	};
       
   363 
       
   364 
       
   365 #endif 
       
   366 
       
   367 
       
   368 // End of file