mmsharing/mmshengine/inc/musengclipsession.h
changeset 0 f0cf47e981f9
child 13 a184f3d659e6
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 MUSHENGCLIPSESSION_H
       
    20 #define MUSHENGCLIPSESSION_H
       
    21 
       
    22 // USER
       
    23 #include "musengmceoutsession.h"
       
    24 #include "musunittesting.h"
       
    25 
       
    26 
       
    27 class MMusEngClipSessionObserver;
       
    28 class CMusEngLiveSession;
       
    29 class CMceFileSource;
       
    30 class CMceAudioStream;
       
    31 class CMceVideoStream;
       
    32 class CMceAudioCodec;
       
    33 
       
    34 
       
    35 class CMusEngClipSession : public CMusEngMceOutSession
       
    36     {
       
    37     MUS_UNITTEST( UT_CMusEngClipSession )
       
    38     
       
    39     public:
       
    40 
       
    41         /**
       
    42         *
       
    43         */
       
    44         IMPORT_C static CMusEngClipSession* NewL( 
       
    45                                 const TRect& aRect,
       
    46                                 MMusEngSessionObserver& aSessionObserver,
       
    47                                 MMusEngOutSessionObserver& aOutSessionObserver,
       
    48                                 MMusEngClipSessionObserver& aClipSessionObserver,
       
    49                                 TUint aSipProfileId = 0 );
       
    50                                                   
       
    51         /**
       
    52         *
       
    53         */
       
    54         ~CMusEngClipSession();
       
    55 
       
    56 
       
    57     public: // new API
       
    58         
       
    59         /**
       
    60         * Sets file to be shared during session.
       
    61         * @pre File cannot be DRM protected
       
    62         * @post InviteL can be called
       
    63         * @leave One of the system wide error codes
       
    64         * @param aFileName Name of the file to be shared
       
    65         */
       
    66         IMPORT_C void SetClipL( const TDesC& aFileName );
       
    67         
       
    68         /**
       
    69         * Starts or stops fast forwarding the clip. Clip is left paused after
       
    70         * stopping the fast forwarding.
       
    71         * @pre Session is ongoing
       
    72         * @param aUseFFWD ETrue to start FFWD, EFalse to stop it.
       
    73         */
       
    74         IMPORT_C void FastForwardL( TBool aUseFFWD );
       
    75 
       
    76         /**
       
    77         * Starts or stops fast rewinding the clip. Clip is left paused after
       
    78         * stopping the fast rewinding.
       
    79         * @pre Session is ongoing
       
    80         * @param aUseFRWD ETrue to start FRWD, EFalse to stop it.
       
    81         */
       
    82         IMPORT_C void FastRewindL( TBool aUseFRWD );
       
    83 
       
    84         /**
       
    85         * Returns current position as time interval.
       
    86         */
       
    87         IMPORT_C TTimeIntervalSeconds PositionL();
       
    88 
       
    89         /**
       
    90         * Returns duration of current clip as time interval
       
    91         */
       
    92         IMPORT_C TTimeIntervalSeconds DurationL();
       
    93 
       
    94         /**
       
    95         *
       
    96         */
       
    97         IMPORT_C void SetPositionL (const TTimeIntervalSeconds &aPosition);
       
    98 
       
    99         /**
       
   100         * Starts transcoding of file. After the transcoding is complete,
       
   101         * file to be shared is changed into the transcoded file.
       
   102         * @pre MMusEngClipSessionObserver::TranscodingNeeded is called
       
   103         * @param aFileName Name of the transcoding output file.
       
   104         */
       
   105         IMPORT_C void TranscodeL( const TFileName& aFileName );
       
   106 
       
   107         /**
       
   108         * Cancels transcoding of file. 
       
   109         * @pre TranscodeL has been called succesfully and transcoding 
       
   110         *      is not completed
       
   111         */
       
   112         IMPORT_C void CancelTranscodeL();
       
   113 
       
   114 
       
   115     public: // implementation of virtual API from CMusEngMceOutSession
       
   116 
       
   117         /**
       
   118         * Resumes previously paused session. 
       
   119         * Continues showing file on display, resumes clip's audio, continues
       
   120         * playing file and enables streaming to network.
       
   121         * @leave KErrNotReady if called during FFWD or FRWD
       
   122         */
       
   123         IMPORT_C void PlayL();
       
   124 
       
   125         /**
       
   126         * Pauses session.
       
   127         * Holds display, mutes clip's audio, pauses file and 
       
   128         * disables all streaming to network.
       
   129         * @leave KErrNotReady if called during FFWD or FRWD
       
   130         */
       
   131         IMPORT_C void PauseL();
       
   132 
       
   133         /**
       
   134         * Tells whether session is paused or not
       
   135         */
       
   136         IMPORT_C TBool IsPlayingL();
       
   137 
       
   138 
       
   139     protected: // implementation of virtual helper from CMusEngMceOutSession
       
   140 
       
   141         /**
       
   142         * @param aLocalBundle All local streams are supposed to be added to
       
   143         *        this bundle
       
   144         */
       
   145         void CompleteSessionStructureL( CMceStreamBundle& aLocalBundle );        
       
   146 
       
   147 
       
   148     protected: // overrides function from CMusEngMceOutSession
       
   149     
       
   150         /**
       
   151         * Checks that there is no need for transcoding before calling
       
   152         * overridden base class variant of this function.
       
   153         */
       
   154         void EstablishSessionL();
       
   155         
       
   156     
       
   157     private: // from MMceStreamObserver, 
       
   158              // overrides the function in CMusEngMceSession
       
   159 
       
   160         /**
       
   161         * The state of the stream has changed.
       
   162         *
       
   163         * @param aStream, the stream that has changed.
       
   164         */
       
   165         void StreamStateChanged( CMceMediaStream& aStream );
       
   166         
       
   167         /**
       
   168         * The state of the source has changed.
       
   169         * @param aStream, the stream that uses the source.
       
   170         * @param aSource, the source that has changed.
       
   171         */
       
   172         void StreamStateChanged( CMceMediaStream& aStream,
       
   173                                  CMceMediaSource& aSource );
       
   174 
       
   175     private:
       
   176 
       
   177         /**
       
   178         *
       
   179         */
       
   180         CMusEngClipSession( MMusEngSessionObserver& aSessionObserver,
       
   181                             MMusEngOutSessionObserver& aOutSessionObserver,
       
   182                             MMusEngClipSessionObserver& aClipSessionObserver,
       
   183                             const TRect& aRect );
       
   184 
       
   185         /**
       
   186         * @leave KErrPermissionDenied if file is DRM protected
       
   187         */
       
   188         void ConstructL( TUint aSipProfileId );
       
   189 
       
   190 
       
   191     private: // HELPERS
       
   192 
       
   193         /**
       
   194         *
       
   195         */
       
   196         TBool IsProtectedFileL( const TDesC& aClipFile );
       
   197         
       
   198         void AddAmrCodecL( CMceAudioStream& aAudioStream );
       
   199         
       
   200         void AddVideoCodecL( CMceVideoStream& aVideoStream );
       
   201         
       
   202         TBool HasClipEnded();
       
   203 
       
   204         /**
       
   205         * Returns current position as microseconds.
       
   206         * @param aActualPosition ETrue if actual position is wanted, EFalse
       
   207         *   if buffering time is taken in count.
       
   208         */
       
   209         TTimeIntervalMicroSeconds PositionMicroSecondsL( TBool aActualPosition = EFalse );
       
   210 
       
   211         /**
       
   212         * Constructs audio stream structure during session completion and adds
       
   213         * it to session.
       
   214         * @param aLocalBundle All local streams are supposed to be added to
       
   215         *        this bundle
       
   216         * @pre iSession != NULL
       
   217         */
       
   218         void ConstructAudioStructureL( CMceStreamBundle& aLocalBundle );
       
   219         
       
   220         void DetermineBufferingPeriod( CMceMediaStream& aStream );
       
   221 
       
   222         TTimeIntervalMicroSeconds GetVideoSinkRelativeFilePos( 
       
   223             const TTimeIntervalMicroSeconds& aActualPosition,
       
   224             const TTimeIntervalMicroSeconds& aDuration );
       
   225             
       
   226         TBool IsH264Supported() const;
       
   227 
       
   228     private: // Data
       
   229     
       
   230         /**
       
   231         * Reference to live session observer interface.
       
   232         */
       
   233         MMusEngClipSessionObserver& iClipSessionObserver;
       
   234         
       
   235         TFileName iFileName;
       
   236         
       
   237         TBool iTranscodingOngoing;
       
   238         
       
   239         TTime iFFWDStartTime;
       
   240         TTime iFRWDStartTime;
       
   241         
       
   242         TTime iBufferingStartedTime;
       
   243         TTimeIntervalMicroSeconds iBufferingPeriod;
       
   244         
       
   245         TTimeIntervalMicroSeconds iDelayFileEndingPos; 
       
   246         TTimeIntervalMicroSeconds iPreviousPos;
       
   247         TBool iClipEnded;
       
   248         
       
   249         TFileName iTranscodingDestFileName;
       
   250         TBool iRewindedToBeginning;
       
   251         
       
   252     };
       
   253 
       
   254 #endif
       
   255