# HG changeset patch # User Pat Downey # Date 1283340037 -3600 # Node ID 13a33d82ad98d029b7b51356ff32547bef89616b # Parent 826cea16efd9b244751e2f0b294917b1164d209a Revert incorrect RCL_3 drop: Revision: 201029 Kit: 201035 diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/EABI/DvrRtpClipHandlerU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/EABI/DvrRtpClipHandlerU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,48 @@ +EXPORTS + _ZN15CRtpClipHandler12StopPlayBackEij @ 1 NONAME + _ZN15CRtpClipHandler13SetSeekPointLEj @ 2 NONAME + _ZN15CRtpClipHandler13StopRecordingEi @ 3 NONAME + _ZN15CRtpClipHandler14NextClipGroupLEv @ 4 NONAME + _ZN15CRtpClipHandler14SaveNextGroupLER5TPtr8jRKN21MRtpFileWriteObserver14TRtpSaveActionE @ 5 NONAME + _ZN15CRtpClipHandler14StartPlayBackLERK16SCRRtpPlayParamsi @ 6 NONAME + _ZN15CRtpClipHandler14StartPlayBackLERK5RFile @ 7 NONAME + _ZN15CRtpClipHandler15StartRecordingLERKN21MRtpFileWriteObserver13SRtpRecParamsERKNS0_14TRtpSaveActionE @ 8 NONAME + _ZN15CRtpClipHandler15TimeShiftPauseLEv @ 9 NONAME + _ZN15CRtpClipHandler16DefaultRecParamsERN21MRtpFileWriteObserver13SRtpRecParamsEi @ 10 NONAME + _ZN15CRtpClipHandler16ResumeRecordingLEv @ 11 NONAME + _ZN15CRtpClipHandler19UpdateRecordEndTimeERK5TTime @ 12 NONAME + _ZN15CRtpClipHandler20RegisterReadObserverEP20MRtpFileReadObserver @ 13 NONAME + _ZN15CRtpClipHandler21RegisterWriteObserverEP21MRtpFileWriteObserver @ 14 NONAME + _ZN15CRtpClipHandler4NewLEv @ 15 NONAME + _ZN15CRtpClipHandlerD0Ev @ 16 NONAME + _ZN15CRtpClipHandlerD1Ev @ 17 NONAME + _ZN15CRtpClipHandlerD2Ev @ 18 NONAME + _ZN15CRtpClipManager12ProtectClipLERK7TDesC16i @ 19 NONAME + _ZN15CRtpClipManager14FixMetaHeaderLEP22MRtpClipRepairObserverRK7TDesC16 @ 20 NONAME + _ZN15CRtpClipManager14FixMetaHeaderLERK7TDesC16 @ 21 NONAME + _ZN15CRtpClipManager15GetClipDetailsLER5RFileRNS_15SRtpClipDetailsE @ 22 NONAME + _ZN15CRtpClipManager15GetClipDetailsLERK7TDesC16RNS_15SRtpClipDetailsE @ 23 NONAME + _ZN15CRtpClipManager17DeleteRtpRepairerEP22MRtpClipRepairObserver @ 24 NONAME + _ZN15CRtpClipManager4NewLEv @ 25 NONAME + _ZN15CRtpClipManager5NewLCEv @ 26 NONAME + _ZN15CRtpClipManagerD0Ev @ 27 NONAME + _ZN15CRtpClipManagerD1Ev @ 28 NONAME + _ZN15CRtpClipManagerD2Ev @ 29 NONAME + _ZNK15CRtpClipHandler11GetClipSdpLEv @ 30 NONAME + _ZNK15CRtpClipHandler13WritingActiveEv @ 31 NONAME + _ZNK15CRtpClipHandler16GetCurrentLengthEv @ 32 NONAME + _ZTI10CRtpToFile @ 33 NONAME ; ## + _ZTI12CRtpFileBase @ 34 NONAME ; ## + _ZTI12CRtpFromFile @ 35 NONAME ; ## + _ZTI14CRtpMetaHeader @ 36 NONAME ; ## + _ZTI15CRtpClipHandler @ 37 NONAME ; ## + _ZTI15CRtpClipManager @ 38 NONAME ; ## + _ZTI16CRtpClipRepairer @ 39 NONAME ; ## + _ZTV10CRtpToFile @ 40 NONAME ; ## + _ZTV12CRtpFileBase @ 41 NONAME ; ## + _ZTV12CRtpFromFile @ 42 NONAME ; ## + _ZTV14CRtpMetaHeader @ 43 NONAME ; ## + _ZTV15CRtpClipHandler @ 44 NONAME ; ## + _ZTV15CRtpClipManager @ 45 NONAME ; ## + _ZTV16CRtpClipRepairer @ 46 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/bwins/DvrRtpClipHandleru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/bwins/DvrRtpClipHandleru.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,30 @@ +EXPORTS + ??1CRtpClipHandler@@UAE@XZ @ 1 NONAME ; CRtpClipHandler::~CRtpClipHandler(void) + ??1CRtpClipManager@@UAE@XZ @ 2 NONAME ; CRtpClipManager::~CRtpClipManager(void) + ?DefaultRecParams@CRtpClipHandler@@QAEXAAVSRtpRecParams@MRtpFileWriteObserver@@H@Z @ 3 NONAME ; void CRtpClipHandler::DefaultRecParams(class MRtpFileWriteObserver::SRtpRecParams &, int) + ?DeleteRtpRepairer@CRtpClipManager@@QAEXPAVMRtpClipRepairObserver@@@Z @ 4 NONAME ; void CRtpClipManager::DeleteRtpRepairer(class MRtpClipRepairObserver *) + ?FixMetaHeaderL@CRtpClipManager@@QAEXABVTDesC16@@@Z @ 5 NONAME ; void CRtpClipManager::FixMetaHeaderL(class TDesC16 const &) + ?FixMetaHeaderL@CRtpClipManager@@QAEXPAVMRtpClipRepairObserver@@ABVTDesC16@@@Z @ 6 NONAME ; void CRtpClipManager::FixMetaHeaderL(class MRtpClipRepairObserver *, class TDesC16 const &) + ?GetClipDetailsL@CRtpClipManager@@QAEXAAVRFile@@AAVSRtpClipDetails@1@@Z @ 7 NONAME ; void CRtpClipManager::GetClipDetailsL(class RFile &, class CRtpClipManager::SRtpClipDetails &) + ?GetClipDetailsL@CRtpClipManager@@QAEXABVTDesC16@@AAVSRtpClipDetails@1@@Z @ 8 NONAME ; void CRtpClipManager::GetClipDetailsL(class TDesC16 const &, class CRtpClipManager::SRtpClipDetails &) + ?GetClipSdpL@CRtpClipHandler@@QBEPAVHBufC8@@XZ @ 9 NONAME ; class HBufC8 * CRtpClipHandler::GetClipSdpL(void) const + ?GetCurrentLength@CRtpClipHandler@@QBEIXZ @ 10 NONAME ; unsigned int CRtpClipHandler::GetCurrentLength(void) const + ?NewL@CRtpClipHandler@@SAPAV1@XZ @ 11 NONAME ; class CRtpClipHandler * CRtpClipHandler::NewL(void) + ?NewL@CRtpClipManager@@SAPAV1@XZ @ 12 NONAME ; class CRtpClipManager * CRtpClipManager::NewL(void) + ?NewLC@CRtpClipManager@@SAPAV1@XZ @ 13 NONAME ; class CRtpClipManager * CRtpClipManager::NewLC(void) + ?NextClipGroupL@CRtpClipHandler@@QAEXXZ @ 14 NONAME ; void CRtpClipHandler::NextClipGroupL(void) + ?ProtectClipL@CRtpClipManager@@QAEXABVTDesC16@@H@Z @ 15 NONAME ; void CRtpClipManager::ProtectClipL(class TDesC16 const &, int) + ?RegisterReadObserver@CRtpClipHandler@@QAEXPAVMRtpFileReadObserver@@@Z @ 16 NONAME ; void CRtpClipHandler::RegisterReadObserver(class MRtpFileReadObserver *) + ?RegisterWriteObserver@CRtpClipHandler@@QAEXPAVMRtpFileWriteObserver@@@Z @ 17 NONAME ; void CRtpClipHandler::RegisterWriteObserver(class MRtpFileWriteObserver *) + ?ResumeRecordingL@CRtpClipHandler@@QAEXXZ @ 18 NONAME ; void CRtpClipHandler::ResumeRecordingL(void) + ?SaveNextGroupL@CRtpClipHandler@@QAEXAAVTPtr8@@IABW4TRtpSaveAction@MRtpFileWriteObserver@@@Z @ 19 NONAME ; void CRtpClipHandler::SaveNextGroupL(class TPtr8 &, unsigned int, enum MRtpFileWriteObserver::TRtpSaveAction const &) + ?SetSeekPointL@CRtpClipHandler@@QAEXI@Z @ 20 NONAME ; void CRtpClipHandler::SetSeekPointL(unsigned int) + ?StartPlayBackL@CRtpClipHandler@@QAEXABUSCRRtpPlayParams@@H@Z @ 21 NONAME ; void CRtpClipHandler::StartPlayBackL(struct SCRRtpPlayParams const &, int) + ?StartPlayBackL@CRtpClipHandler@@QAEXABVRFile@@@Z @ 22 NONAME ; void CRtpClipHandler::StartPlayBackL(class RFile const &) + ?StartRecordingL@CRtpClipHandler@@QAEXABVSRtpRecParams@MRtpFileWriteObserver@@ABW4TRtpSaveAction@3@@Z @ 23 NONAME ; void CRtpClipHandler::StartRecordingL(class MRtpFileWriteObserver::SRtpRecParams const &, enum MRtpFileWriteObserver::TRtpSaveAction const &) + ?StopPlayBack@CRtpClipHandler@@QAEXHI@Z @ 24 NONAME ; void CRtpClipHandler::StopPlayBack(int, unsigned int) + ?StopRecording@CRtpClipHandler@@QAEXH@Z @ 25 NONAME ; void CRtpClipHandler::StopRecording(int) + ?TimeShiftPauseL@CRtpClipHandler@@QAEXXZ @ 26 NONAME ; void CRtpClipHandler::TimeShiftPauseL(void) + ?UpdateRecordEndTime@CRtpClipHandler@@QAEXABVTTime@@@Z @ 27 NONAME ; void CRtpClipHandler::UpdateRecordEndTime(class TTime const &) + ?WritingActive@CRtpClipHandler@@QBEHXZ @ 28 NONAME ; int CRtpClipHandler::WritingActive(void) const + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/group/DvrRtpClipHandler.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/group/DvrRtpClipHandler.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification for DvrRtpClipHandler.dll.* +*/ + + + +#include + +TARGET DvrRtpClipHandler.dll +TARGETTYPE dll +UID 0x1000008d 0x1020844B + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE CRtpClipHandler.cpp +SOURCE CRtpClipManager.cpp +SOURCE CRtpClipRepairer.cpp +SOURCE CRtpFileBase.cpp +SOURCE CRtpToFile.cpp +SOURCE CRtpFromFile.cpp +SOURCE CRtpMetaHeader.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../DvrRtpUtils/inc +USERINCLUDE ../../../../conf + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib // Common +LIBRARY bafl.lib // Bafl utils +LIBRARY efsrv.lib // File server +LIBRARY DvrRtpUtils.lib // DVR rtp utils +LIBRARY flogger.lib // Debug logger +LIBRARY PlatformEnv.lib diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Component description file for DvrRtpClipHandler.dll.* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/dvrrtpcliphandler.iby CORE_MW_LAYER_IBY_EXPORT_PATH(dvrrtpcliphandler.iby) + +PRJ_MMPFILES +DvrRtpClipHandler.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpClipRepairer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpClipRepairer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,206 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP clip repairer for common recording engine.* +*/ + + + + +#ifndef CRTPCLIPREPAIRER_H +#define CRTPCLIPREPAIRER_H + +// INCLUDES +#include +#include "CCRRtpFileSource.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpMetaHeader; + +// CLASS DECLARATION + +/** +* Repairs corrupted DVB-H RTP clip. +* +* @lib DvrRtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpClipRepairer : public CRtpFileBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @since Series 60 3.0 + * @param aObs observer for repair status + * @return None. + */ + static CRtpClipRepairer* NewL( MRtpClipRepairObserver* aObs ); + + /** + * Destructor. + */ + virtual ~CRtpClipRepairer(); + +public: // New functions + + /** + * Check if corrupted meta header can be fixed. + * @since Series 60 3.0 + * @param aClipName a full path of the clip. + * @return None. + */ + void CheckMetaHeaderL( const TDesC& aClipName ); + + /** + * Getter for the clip name under repairing. + * @since Series 60 3.0 + * @return a full path of the clip under repairing. + */ + TPtrC CurrentClipName(); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @since Series 60 3.0 + * @param aObs observer for repair status + */ + CRtpClipRepairer( MRtpClipRepairObserver* aObs ); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From CRtpFileBase. + * Called when request completion event occurs. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CRtpFileBase. + * Handles a leave occurring in the request completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code. + * @return a status of function. + */ + TInt RunError( TInt aError ); + + /** + * From CRtpFileBase : Called when request completion event cancelled. + * @since Series 60 3.0 + * @param none. + * @return None. + */ + void DoCancel(); + +private: // New functions + + /** + * Veryfies that seek header and array are valid. + * @since Series 60 3.0 + * @param none. + * @return true if are, otherwise false. + */ + TBool ValidSeekHeaderL(); + + /** + * Scans whole clip and updates seek array for it. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UpdateSeekArrayL(); + + /** + * Activates asyncronous group header reading. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReadNextGroupHeaderFromFileL(); + + /** + * Appends rec groups to seek array in 30s interval. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void GroupToSeekArrayL(); + + /** + * Adds special packet to the end. + * @since Series 60 3.0 + * @param aType a type of special packet. + * @return none. + */ + void AddSpecialPacketL( const MRtpFileWriteObserver::TRtpType aType ); + + /** + * Saves readed seek array. + * @since Series 60 3.0 + * @param aError a error code. + * @return none. + */ + void FinalizeSeekArrayL( const TInt aError ); + +private: // Data + + /** + * Repair observer. + */ + MRtpClipRepairObserver* iObs; + + /** + * File data buffer. + */ + HBufC8* iFileData; + + /** + * Meta header. + */ + CRtpMetaHeader* iMetaHeader; + + /** + * Last group time. + */ + TUint iLastGroupTime; + + /** + * Seek array point. + */ + TInt iSeekArrayPoint; + + }; + +#endif // CRTPCLIPREPAIRER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpFromFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpFromFile.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,329 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP file read format for Common Recording Engine.* +*/ + + + + + +#ifndef __CRTPFROMFILE_H +#define __CRTPFROMFILE_H + +// INCLUDES +#include +#include +#include "MRtpTimerObserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpToFile; +class CRtpTimer; + +// CLASS DECLARATION + +/** +* RTP format read functionalities for RTP Clip Handler. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpFromFile : public CRtpFileBase, + public MRtpTimerObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aReadObs a reference to file read observer. + * @param aToFile a pointer to RTP save object. + * @return pointer to CRtpFromFile class. + */ + static CRtpFromFile* NewL( MRtpFileReadObserver& aReadObs, + CRtpToFile* aToFile ); + + /** + * Destructor. + */ + virtual ~CRtpFromFile(); + +public: // New functions + + /** + * Initiates RTP packet reading. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @param aVersion a version of the clip. + * @param aTimeShift a mode selection. + * @return none. + */ + void InitRtpReadL( const TDesC& aClipPath, + TInt8& aVersion, + const TBool aTimeShift ); + + /** + * Initiates RTP packet reading. + * @since Series 60 3.0 + * @param aRtpHandle a open file handle for RTP file. + * @param aVersion a version of the clip. + * @param aTimeShift a mode selection. + * @return none. + */ + void InitRtpReadL( const RFile& aFileHandle, + TInt8& aVersion ); + + /** + * Swaps new clip for RTP packet reading. + * @since Series 60 3.0 + * @param aClipPath a full path of clip. + * @return a version of the clip. + */ + TInt8 SwapClipL( const TDesC& aClipPath ); + + /** + * Getter for SDP data from the clip. + * @since Series 60 3.0 + * @param none. + * @return a buffer keeping SDD data. + */ + HBufC8* GetClipSdpL(); + + /** + * Reads next RTP packets group from a clip. + * @since Series 60 3.0 + * @param aGroupPoint a group to read. + * @return KErrInUse if reading already active, + KErrEof if too close to live point, + KErrNone otherwise. + */ + TInt ReadNextGroupL( const TInt aGroupPoint ); + + /** + * Reads skipped RTP packet from a clip. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReadSkippedGroup(); + + /** + * Setter for last seek addres. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UpdateLastSeekAddr(); + + /** + * Sets Seek point of the clip. + * @since Series 60 3.0 + * @param aTime a time where to seek. + * @return none. + */ + void SetSeekPointL( const TUint aTime ); + + /** + * Stops RTP packet reading. + * @since Series 60 3.0 + * @param aStatus a stopping status. + * @param aPlayerBuf a buffer length in player. + * @return none. + */ + void StopRtpRead( const TInt aStatus, + const TUint aPlayerBuf ); + + /** + * Getter for duration of the clip. + * @since Series 60 3.0 + * @param none. + * @return a duration of the clip. + */ + inline TUint Duration(); + + /** + * Getter for time shift mode. + * @since Series 60 3.0 + * @param none. + * @return true if time shift ongoing, otherwise false. + */ + inline TBool IsTimeShift(); + + /** + * Getter for currently active group point. + * @since Series 60 3.0 + * @param none. + * @return a group point of current read. + */ + inline TInt ThisGroup(); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @param aObs a RTP save observer. + * @param aToFile a pointer to RTP save object. + */ + CRtpFromFile( MRtpFileReadObserver& aReadObs, + CRtpToFile* aToFile ); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From CRtpFileBase. + * Called when request completion event occurs. + * @since Series 60 3.0 + * @return none. + */ + void RunL(); + + /** + * From CRtpFileBase. + * Handles a leave occurring in the request completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code. + * @return status of run error handling. + */ + TInt RunError( TInt aError ); + + /** + * From CRtpFileBase. + * Called when request completion event cancelled. + * @since Series 60 3.0 + * @return none. + */ + void DoCancel(); + + /** + * From MRmTimerObserver : Called when timer completion event occurs. + * @since Series 60 3.0 + * @return none + */ + void TimerEventL(); + + /** + * From MRtpTimerObserver. + * Handles a leave occurring in the request completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code. + * @return none. + */ + void TimerError( const TInt aError ); + +private: // New functions + + /** + * Reads clip header from a clip. + * @since Series 60 3.0 + * @param aVersion a version of clip. + * @return none. + */ + void ReadClipHeaderL( TInt8& aVersion ); + + /** + * Reads meta header from a clip. + * @since Series 60 3.0 + * @param aSeekHeaderPoint a seek header point in clip. + * @param aSeekArrayPoint a seek array point in clip. + * @return Version of clip. + */ + TInt8 ReadMetaHeaderL( TInt& aSeekHeaderPoint, + TInt& aSeekArrayPoint ); + + /** + * Reads RTP payload from a clip. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReadNextGroupFromFileL(); + + /** + * Finds group base on seek time. + * @since Series 60 3.0 + * @param aTime a time to use for search. + * @param aArray a array to use for search. + * @return point to group where time with TS exist. + */ + TInt FindSeekGroup( const TUint aTime, + CArrayFix* aArray ); + + /** + * Updates playback count and spot attributes. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UpdatePlayAttL(); + + /** + * Getter for last seek addres. + * @since Series 60 3.0 + * @param none. + * @return a last seek address. + */ + TInt LastSeekAddr(); + +private: // Data + + /** + * RTP read observer. + */ + MRtpFileReadObserver& iReadObs; + + /** + * Pointer to RTP save object. + */ + CRtpToFile* iToFile; + + /** + * File data buffer. + */ + HBufC8* iFileData; + + /** + * Request skipped. + */ + TBool iSkippedRead; + + /** + * Duration of the clip. + */ + TInt iDuration; + + /** + * Group read timer. + */ + CRtpTimer* iTimer; + + }; + +#include "CRtpFromFile.inl" + +#endif //__CRTPFROMFILE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpFromFile.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpFromFile.inl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP read format* +*/ + + + + + +// INCLUDE FILES + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpFromFile::Duration +// Getter for current duration of the clip. +// ----------------------------------------------------------------------------- +// +inline TUint CRtpFromFile::Duration() + { + return iDuration; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ThisGroup +// Getter for currently active group point. +// ----------------------------------------------------------------------------- +// +inline TInt CRtpFromFile::ThisGroup() + { + return iThisGroup; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::IsTimeShift +// Getter for time shift mode. +// ----------------------------------------------------------------------------- +// +inline TBool CRtpFromFile::IsTimeShift() + { + return ( iMode == EModeTimeShift ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpToFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpToFile.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,374 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP file save format for Common Recording Engine.* +*/ + + + + +#ifndef CRTPTOFILE_H +#define CRTPTOFILE_H + +// INCLUDES +#include +#include +#include + +// CONSTANTS +// None + +// MACROS +// none + +// DATA TYPES +// none + +// FORWARD DECLARATIONS +class CRtpMetaHeader; + +// CLASS DECLARATION + +/** +* RTP format write functionalities for RTP Clip Handler. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpToFile : public CRtpFileBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CRtpToFile* NewL( MRtpFileObserver& aObs, + MRtpFileWriteObserver& aHandler ); + + /** + * Destructor. + */ + virtual ~CRtpToFile(); + +public: // New functions + + /** + * Initiates RTP packets saving. + * @since Series 60 3.0 + * @param aObs a RTP save observer. + * @param aParams a recording parameters. + * @param aAction a save action for current group. + * @return none. + */ + void InitRtpSaveL( const MRtpFileWriteObserver::SRtpRecParams& aParams, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ); + + /** + * Setter for packets re-use flag. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ActivateGroupsReuseL(); + + /** + * Swaps new clip for packets saving. + * @since Series 60 3.0 + * @param aParams a recording parameters. + * @return none. + */ + void SwapClipL( const MRtpFileWriteObserver::SRtpRecParams& aParams ); + + /** + * Saves next RTP packet group to a file. + * @since Series 60 3.0 + * @param aGroup a RTP group data. + * @param aGroupLength a length of group. + * @param aAction a save action for current group. + * @return a file location of saved group. + */ + TInt SaveNextGroupL( TPtr8& aGroup, + TUint& aGroupLength, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ); + + /** + * Updates previous time after pause. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UpdatePreviousTimeL(); + + /** + * Stops RTP packet saving. + * @since Series 60 3.0 + * @param aError a stop error code. + * @return none. + */ + void StopRtpSave( const TInt aError ); + + /** + * Getter for a clip path. + * @since Series 60 3.0 + * @param none. + * @return reference to current path. + */ + HBufC* ClipPath(); + + /** + * Getter current length of the clip. + * @since Series 60 3.0 + * @param none. + * @return a total length of the clip. + */ + TUint GetCurrentLength(); + + /** + * Setter recording end time of the clip. + * @since Series 60 3.0 + * @param aEndTime new end time for the clip. + * @return none. + */ + void UpdateRecordEndTime( const TTime& aEndTime ); + + /** + * Updates playback count and spot attributes. + * @since Series 60 3.0 + * @param aNewSpot a new play start spot. + * @return none. + */ + void UpdatePlayAttL( const TInt aNewSpot ); + +public: // New inline functions + + /** + * Getter for packet groups total count. + * @since Series 60 3.0 + * @param none. + * @return a value of groups total count variable. + */ + inline TInt GroupsTotalCount(); + + /** + * Getter for first group address. + * @since Series 60 3.0 + * @param none. + * @return a value of first address variable. + */ + inline TInt FirstSeekAddr(); + + /** + * Getter for last group address. + * @since Series 60 3.0 + * @param none. + * @return a value of last address variable. + */ + inline TInt LastSeekAddr(); + + /** + * Getter for seek header point. + * @since Series 60 3.0 + * @param none. + * @return a value of seek header variable. + */ + inline TInt SeekHeaderPoint(); + + /** + * Getter for seek array. + * @param none. + * @since Series 60 3.0 + * @return a pointer to seek array. + */ + inline CArrayFix* SeekArray(); + + /** + * Getter for current save action + * @param none. + * @since Series 60 3.0 + * @return current saving action (status) + */ + inline MRtpFileWriteObserver::TRtpSaveAction Action() const; + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CRtpToFile( MRtpFileObserver& aObs, + MRtpFileWriteObserver& aHandler ); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From CRtpFileBase : Called when request completion event occurs. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CRtpFileBase : Handles a leave occurring in the request. + * completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code + * @return a status of function + */ + TInt RunError( TInt aError ); + + /** + * From CRtpFileBase : Called when request completion event cancelled. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCancel(); + +private: // New functions + + /** + * Opens new clip and creates initial headers. + * @since Series 60 3.0 + * @param aParams a recording parameters. + * @return none. + */ + void CreateNewClipL( + const MRtpFileWriteObserver::SRtpRecParams& aParams ); + + /** + * Sets variables for a new group. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void AddGroupL(); + + /** + * Calculates group time. + * @since Series 60 3.0 + * @param aGroupLength a length of incoming group. + * @return none. + */ + void GroupTimeL( TUint& aGroupLength ); + + /** + * Writes clip's initial meta data header of the clip. + * @since Series 60 3.0 + * @param aParams a recording parameters. + * @return none. + */ + void WriteInitialMetaHeaderL( + const MRtpFileWriteObserver::SRtpRecParams& aParams ); + + /** + * Writes clip's final meta data header to a clip. + * @since Series 60 3.0 + * @param aStatus a status of recording. + * @return none. + */ + void WriteFinalMetaHeaderL( const TInt aStatus ); + + /** + * Adds RTP group header to a group. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void AddGroupHeaderL(); + + /** + * Updates recording duration. + * @since Series 60 3.0 + * @param aMetaHeader a pointer to meta header. + * @return none. + */ + void UpdateDurationL( CRtpMetaHeader* aMetaHeader ); + + /** + * Getter for current network time. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UpdateCurrentTimeL(); + +private: // Data + + /** + * RTP file observer. + */ + MRtpFileObserver& iFileObs; + + /** + * RTP write observer. + */ + MRtpFileWriteObserver& iWriteObs; + + /** + * Current network time. + */ + TTime iCurrentTime; + + /** + * Previous network time. + */ + TInt64 iPreviousTime; + + /** + * Previous time delta. + */ + TInt iPreviousDelta; + + /** + * Reference recording time. + */ + TInt64 iReferenceTime; + + /** + * Record end time. + */ + TInt64 iRecordEndTime; + + /** + * Reference to seek array delta. + */ + TUint iSeekArrayReference; + + /** + * Group time of the group where recording started. + */ + TUint iStartGroupTime; + + /** + * Total groups for re-use. + */ + TInt iGroupReUse; + + /** + * Current save action. + */ + MRtpFileWriteObserver::TRtpSaveAction iAction; + + }; + +#include "CRtpToFile.inl" + +#endif // CRTPTOFILE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpToFile.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/inc/CRtpToFile.inl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP save format* +*/ + + + + +// INCLUDE FILES +#include + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpToFile::GroupsTotalCount +// Returns: Total count of packet groups. +// ----------------------------------------------------------------------------- +// +inline TInt CRtpToFile::GroupsTotalCount() + { + return iGroupsTotalCount; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::FirstSeekAddr +// Returns: First group's address in RTP file. +// ----------------------------------------------------------------------------- +// +inline TInt CRtpToFile::FirstSeekAddr() + { + return iFirstSeekAddr; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::LastSeekAddr +// Returns: Last group's address in RTP file. +// ----------------------------------------------------------------------------- +// +inline TInt CRtpToFile::LastSeekAddr() + { + return ( iMode == EModeTimeShift )? KMaxTInt: + ( IsActive() )? iPrevGroupPoint: iLastSeekAddr; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::SeekHeaderPoint +// Returns: Seek header point in RTP file. +// ----------------------------------------------------------------------------- +// +inline TInt CRtpToFile::SeekHeaderPoint() + { + return iSeekHeaderPoint; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::SeekArray +// Returns: Seek arry pointer. +// ----------------------------------------------------------------------------- +// +inline CArrayFix* CRtpToFile::SeekArray() + { + return iSeekArray; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::Action +// Returns: Current save action. +// ----------------------------------------------------------------------------- +// +inline MRtpFileWriteObserver::TRtpSaveAction CRtpToFile::Action() const + { + return iAction; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/rom/dvrrtpcliphandler.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/rom/dvrrtpcliphandler.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __DVRRTPCLIPHANDLER_IBY__ +#define __DVRRTPCLIPHANDLER_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\DvrRtpClipHandler.dll SHARED_LIB_DIR\DvrRtpClipHandler.dll + +#endif // __DVRRTPCLIPHANDLER_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipHandler.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,584 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RTP clip handler class.* +*/ + + + + +// INCLUDE FILES +#include +#include "CRtpToFile.h" +#include "CRtpFromFile.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KDvrMaxTimeshiftDelta( 1 * 60 * 60 ); // 1 hour + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpClipHandler* CRtpClipHandler::NewL() + { + CRtpClipHandler* self = new( ELeave ) CRtpClipHandler(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::CRtpClipHandler +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpClipHandler::CRtpClipHandler() + : iClipVersion( 0 ), + iSaveNameIndex( KErrNotFound ), + iReadNameIndex( KErrNotFound ), + iTsPauseState( EFalse ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpClipHandler::ConstructL() + { + LOG( "CRtpClipHandler::ConstructL()" ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::~CRtpClipHandler +// Destructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpClipHandler::~CRtpClipHandler() + { + LOG( "CRtpClipHandler::~CRtpClipHandler() in" ); + + StopRecording( KErrCancel ); + StopPlayBack( KErrCancel, 0 ); + + LOG( "CRtpClipHandler::~CRtpClipHandler() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::RegisterWriteObserver +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::RegisterWriteObserver( + MRtpFileWriteObserver* aObs ) + { + LOG1( "CRtpClipHandler::RegisterWriteObserver(), aObs: %d", aObs ); + iWriteObs = aObs; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::RegisterReadObserver +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::RegisterReadObserver( MRtpFileReadObserver* aObs ) + { + LOG1( "CRtpClipHandler::RegisterReadObserver(), aObs: %d", aObs ); + + iReadObs = aObs; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::StartRecordingL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::StartRecordingL( + const MRtpFileWriteObserver::SRtpRecParams& aRecParams, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ) + { + LOG1( "CRtpClipHandler::StartRecordingL() in, aAction: %d", aAction ); + + // Stop possible existing recording + StopRecording( KErrNone ); + iSaveNameIndex = 0; + + // If InitRtpSaveL leaves, iRtpSave is not NULL, but is in undefined state. + // This causes problems - may crash when StopRecording is called. + // Better to trap and cleanup here. + TRAPD( err, + // Init recording ( iRtpSave deleted in StopRecording() ) + iRtpSave = CRtpToFile::NewL( *this, *iWriteObs ); + iRtpSave->InitRtpSaveL( aRecParams, aAction ); + ); + if ( err ) + { + delete iRtpSave; iRtpSave = NULL; + User::Leave( err ); + } + + LOG( "CRtpClipHandler::StartRecordingL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::SaveNextGroupL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::SaveNextGroupL( + TPtr8& aGroup, + TUint aGroupLength, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ) + { + User::LeaveIfNull( iWriteObs ); + User::LeaveIfNull( iRtpSave ); + + // Passes save action to ring buffer + const TUint seekPoint( iRtpSave->SaveNextGroupL( + aGroup, aGroupLength, aAction ) ); + + // aGroupLength is set to non zero if time shift ongoing? + if ( aGroupLength > 0 ) + { + CRtpFileBase::STimeShiftSeek shiftSeek; + shiftSeek.iGroupTime = aGroupLength; + shiftSeek.iSeekpoint = seekPoint; + shiftSeek.iNameIndex = iSaveNameIndex; + iShiftSeek.Append( shiftSeek ); + + // Time shift max length + if ( ( ( iShiftSeek.Count() - 1 ) * KNormalRecGroupLength ) > + KDvrMaxTimeshiftDelta ) + { + LOG( "CRtpClipHandler::SaveNextGroupL(), Timeshift max time !" ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::WritingActive +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CRtpClipHandler::WritingActive( void ) const + { + if ( iRtpSave ) + { + return iRtpSave->IsActive(); + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::GetCurrentLength +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint CRtpClipHandler::GetCurrentLength( void ) const + { + TUint length( 0 ); + if ( iRtpRead ) + { + length = iRtpRead->Duration(); + } + else + { + if ( iRtpSave ) + { + const TInt count( iShiftSeek.Count() ); + if ( count > 0 ) + { + // Time shift + for ( TInt i( 0 ); i < count; i++ ) + { + length += iShiftSeek[i].iGroupTime; + } + } + else + { + // Rec ongoing + length = iRtpSave->GetCurrentLength(); + } + } + } + + return length; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::TimeShiftPauseL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::TimeShiftPauseL() + { + LOG2( "CRtpClipHandler::TimeShiftPauseL(), iRtpSave: %d, iTsPauseState: %d", + iRtpSave, iTsPauseState ); + User::LeaveIfNull( iRtpSave ); + if ( !iTsPauseState ) + { + // Use clip as a ring buffer + iRtpSave->ActivateGroupsReuseL(); + iTsPauseState = ETrue; + } + else + { + // Switch to next file + iSaveNameIndex++; + MRtpFileWriteObserver::SRtpRecParams recParams; + DefaultRecParams( recParams, iSaveNameIndex ); + iRtpSave->SwapClipL( recParams ); + iTsPauseState = EFalse; + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::DefaultRecParams +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::DefaultRecParams( + MRtpFileWriteObserver::SRtpRecParams& aParams, + const TInt aIndex ) + { + aParams.iClipPath = KDvrTimeShiftFile; + aParams.iClipPath.AppendNum( aIndex ); + aParams.iSdpData.Set( NULL, 0 ); + aParams.iService.Set( KNullDesC ); + aParams.iProgram.Set( KNullDesC ); + aParams.iPostRule = 0; + aParams.iParental = 0; + aParams.iStartTime = 0; + aParams.iEndTime = TInt64( KDvrMaximumTimeShift ) * 1e6; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::UpdateRecordEndTime +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::UpdateRecordEndTime( const TTime& aEndTime ) + { + if ( iRtpSave ) + { + iRtpSave->UpdateRecordEndTime( aEndTime ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::ResumeRecordingL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::ResumeRecordingL( void ) + { + LOG1( "CRtpClipHandler::ResumeRecordingL(), iRtpSave: %d", iRtpSave ); + + if ( iRtpSave ) + { + iRtpSave->UpdatePreviousTimeL(); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::StopRecording +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::StopRecording( const TInt aError ) + { + LOG2( "CRtpClipHandler::StopRecording(), aError: %d, iRtpSave: %d", + aError, iRtpSave ); + + if ( iRtpSave ) + { + // Update clip end point if watching sametime + if ( iRtpRead ) + { + iRtpRead->UpdateLastSeekAddr(); + } + + // Stop recording + iRtpSave->StopRtpSave( aError ); + + // Delete possible time shift files + if ( !iRtpRead ) + { + iRtpSave->DeleteTimeShiftFiles( iShiftSeek ); + } + } + + delete iRtpSave; iRtpSave = NULL; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::StartPlayBackL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::StartPlayBackL( + const SCRRtpPlayParams& aParams, + const TBool aTimeShift ) + { + LOG1( "CRtpClipHandler::StartPlayBackL(), path: %S", &aParams.iFileName ); + LOG1( "CRtpClipHandler::StartPlayBackL(), aTimeShift: %d", aTimeShift ); + + // Stop possible existing + StopPlayBack( KErrNone, 0 ); + + // Time shift mode? + if ( aTimeShift ) + { + // Open file for time shift mode + User::LeaveIfNull( iRtpSave ); + iRtpRead = CRtpFromFile::NewL( *iReadObs, iRtpSave ); + iReadNameIndex = ( iShiftSeek.Count() )? iShiftSeek[0].iNameIndex: 0; + TPath clipPath( KDvrTimeShiftFile ); + clipPath.AppendNum( iReadNameIndex ); + iRtpRead->InitRtpReadL( clipPath, iClipVersion, aTimeShift ); + } + else + { + // Open file, during recording? + if ( iRtpSave && iRtpSave->ClipPath() ) + { + if ( !aParams.iFileName.Compare( iRtpSave->ClipPath()->Des() ) ) + { + iRtpRead = CRtpFromFile::NewL( *iReadObs, iRtpSave ); + } + } + + // Open file, normal playback? + if ( !iRtpRead ) + { + iRtpRead = CRtpFromFile::NewL( *iReadObs, NULL ); + } + + iRtpRead->InitRtpReadL( aParams.iFileName, iClipVersion, EFalse ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::StartPlayBackL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::StartPlayBackL( const RFile& aFileHandle ) + { + LOG( "CRtpClipHandler::StartPlayBackL(), with handle" ); + + // Stop possible existing + StopPlayBack( KErrNone, 0 ); + + // Open file, during recording? + if ( iRtpSave && iRtpSave->ClipPath() ) + { + TPath name( KNullDesC ); + aFileHandle.FullName( name ); + if ( !name.Compare( iRtpSave->ClipPath()->Des() ) ) + { + iRtpRead = CRtpFromFile::NewL( *iReadObs, iRtpSave ); + } + } + + // Open file, normal playback? + if ( !iRtpRead ) + { + iRtpRead = CRtpFromFile::NewL( *iReadObs, NULL ); + } + + iRtpRead->InitRtpReadL( aFileHandle, iClipVersion ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::GetClipSdpL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CRtpClipHandler::GetClipSdpL( void ) const + { + HBufC8* sdp = NULL; + if ( iRtpRead ) + { + sdp = iRtpRead->GetClipSdpL(); + } + + return sdp; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::NextClipGroupL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::NextClipGroupL( void ) + { + User::LeaveIfNull( iRtpRead ); + if ( !iRtpRead->IsTimeShift() ) + { + iRtpRead->ReadNextGroupL( KErrNotFound ); + } + else + { + // Handle time shift + TInt err( KErrNotFound ); + if ( iShiftSeek.Count() ) + { + // Need swap file? + SwapClipIfNeededL(); + + // Read next group + TRAP( err, iRtpRead->ReadNextGroupL( iShiftSeek[0].iSeekpoint ) ); + if ( err != KErrInUse ) + { + iShiftSeek.Remove( 0 ); + } + } + + // End time shift? + if ( err == KErrEof ) + { + LOG( "CRtpClipHandler::NextClipGroupL(), Time shift play reached live !" ); + User::LeaveIfNull( iReadObs ); + iReadObs->ReadStatus( MRtpFileReadObserver::ERtpTimeShifTEnd ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::SetSeekPointL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::SetSeekPointL( const TUint aTime ) + { + LOG1( "CRtpClipHandler::SetSeekPointL(), aTime: %u", aTime ); + + User::LeaveIfNull( iRtpRead ); + if ( !iShiftSeek.Count() ) + { + iRtpRead->SetSeekPointL( aTime ); + } + else + { + const TInt count( iShiftSeek.Count() ); + if ( count > 0 ) + { + TUint total( 0 ); + for ( TInt index( 0 ); index < count && aTime > total; index++ ) + { + total += iShiftSeek[0].iGroupTime; + SwapClipIfNeededL(); + iShiftSeek.Remove( 0 ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::StopPlayBack +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipHandler::StopPlayBack( + const TInt aError, + const TUint aPlayerBuf ) + { + LOG2( "CRtpClipHandler::StopPlayBack(), aError: %d, iRtpRead: %d", + aError, iRtpRead ); + if ( iRtpRead ) + { + iRtpRead->StopRtpRead( aError, aPlayerBuf ); + + // Delete possible time shift files + if ( !iRtpSave ) + { + iRtpRead->DeleteTimeShiftFiles( iShiftSeek ); + } + } + + delete iRtpRead; iRtpRead = NULL; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::RtpGroupSaved +// Indicates that RPT packet save is ready. +// ----------------------------------------------------------------------------- +// +void CRtpClipHandler::RtpGroupSaved( const TInt aAction ) + { + // Inform file reader that new group saved + if ( iRtpRead && aAction >= KErrNone ) + { + iRtpRead->ReadSkippedGroup(); + } + + // Group saved + if ( iWriteObs ) + { + if ( aAction != MRtpFileWriteObserver::ESaveEnd ) + { + // Ready for next group + iWriteObs->GroupSaved(); + } + else + { + // Recording full time + iWriteObs->WriteStatus( KErrNone ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::CurrentFileReadPoint +// Getter for file reader current point. +// ----------------------------------------------------------------------------- +// +TInt CRtpClipHandler::CurrentFileReadPoint( const TInt aIndex ) + { + if ( iShiftSeek.Count() > aIndex ) + { + if ( iShiftSeek[aIndex].iNameIndex == iSaveNameIndex ) + { + return iShiftSeek[aIndex].iSeekpoint; + } + + return KErrNone; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::SwapClipIfNeededL +// Swap to next available clip in time shift array if needed. +// ----------------------------------------------------------------------------- +// +void CRtpClipHandler::SwapClipIfNeededL( void ) + { + if ( iShiftSeek[0].iNameIndex != iReadNameIndex ) + { + iReadNameIndex = iShiftSeek[0].iNameIndex; + TPath clipPath( KDvrTimeShiftFile ); + clipPath.AppendNum( iReadNameIndex ); + iRtpRead->SwapClipL( clipPath ); + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipManager.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,513 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Help methods for propriatary RTP format.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include "CRtpClipRepairer.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt EContentRightsRecordingAllowed( 0 ); +const TInt EContentRightsLockToDevice( 2 ); +const TInt KMaxProgramChars( 8 ); +const TInt KFirstFileIndex( 1 ); +const TInt KMaxFileIndex( 99 ); +_LIT( KDvrClipExtension, ".rtp" ); +_LIT( KIndexFormat, "(%02d)" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpClipManager::NewL +// Static two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpClipManager* CRtpClipManager::NewL() + { + CRtpClipManager* self = CRtpClipManager::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::NewLC +// Static two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpClipManager* CRtpClipManager::NewLC() + { + CRtpClipManager* self = new( ELeave ) CRtpClipManager(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::CRtpClipManager +// +// ----------------------------------------------------------------------------- +// +CRtpClipManager::CRtpClipManager() + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpClipManager::ConstructL() + { + LOG( "CRtpClipManager::ConstructL() in" ); + + // IMEI + TName buf( KNullDesC ); + CRtpUtil::GetImeiL( buf ); + iImei = buf.AllocL(); + LOG1( "CRtpClipManager::ConstructL(), IMEI: %S", &*iImei ); + + // File server + User::LeaveIfError( iFs.Connect() ); + + LOG( "CRtpClipManager::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::~CRtpClipManager +// +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpClipManager::~CRtpClipManager() + { + LOG( "CRtpClipManager::~CRtpClipManager()" ); + + delete iImei; + iRepairQueue.ResetAndDestroy(); + delete iClipRepairer; + iFile.Close(); + iFs.Close(); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::GetClipDetailsL +// Getter for clip details. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::GetClipDetailsL( + const TDesC& aClipPath, + SRtpClipDetails& aDetails ) + { + iFile.Close(); + TBool clipOpen( EFalse ); + iFs.IsFileOpen( aClipPath, clipOpen ); + User::LeaveIfError( iFile.Open( iFs, aClipPath, + EFileShareAny | EFileStream | EFileRead ) ); + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaRead ); + // Attributes + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + + // Under version 2 clips not work any longer + // Recording ongoing without file open indicates interrupted recording + if ( att.iVersion < 2 || ( att.iOngoing && !clipOpen ) ) + { + LOG3( "CRtpClipManager::GetClipDetailsL(), iVersion: %d, iOngoing: %d, clipOpen: %d", + att.iVersion, att.iOngoing, clipOpen ); + iFile.Close(); + User::Leave( KErrGeneral ); + } + + // Details + GetDetailsL( att, aDetails, metaheader ); + CleanupStack::PopAndDestroy( metaheader ); + iFile.Close(); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::GetClipDetailsL +// Getter for clip details. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::GetClipDetailsL( + RFile& aFile, + SRtpClipDetails& aDetails ) + { + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + aFile, CRtpMetaHeader::EMetaRead ); + // Attributes + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + + // Details + GetDetailsL( att, aDetails, metaheader ); + CleanupStack::PopAndDestroy( metaheader ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::ProtectClipL +// Protects clip from deleting automatically during recording. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::ProtectClipL( + const TDesC& aClipPath, + const TBool aProtected ) + { + LOG1( "CRtpClipManager::ProtectClipL(), aClipPath: %S", &aClipPath ); + LOG1( "CRtpClipManager::ProtectClipL(), aProtected: %d", aProtected ); + + iFile.Close(); + User::LeaveIfError( iFile.Open( iFs, aClipPath, + EFileShareExclusive | EFileStream | EFileWrite ) ); + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaUpdate ); + // Read Attributes + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + // Update protected attribute + if ( aProtected != att.iProtected ) + { + att.iProtected = aProtected; + metaheader->WriteAttributesL( att ); + } + + CleanupStack::PopAndDestroy( metaheader ); + iFile.Close(); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::FixMetaHeaderL +// Fixes corrupted clip's meta header. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::FixMetaHeaderL( + MRtpClipRepairObserver* aObs, + const TDesC& aClipPath ) + { + LOG( "RM-CRtpClipManager::FixMetaHeaderL()" ); + + iFile.Close(); + if ( !iClipRepairer ) + { + LOG1( "CRtpClipManager::FixMetaHeaderL(), Fix started: %S", &aClipPath ); + AddClipToRepairQueueL( aClipPath ); + iClipRepairer = CRtpClipRepairer::NewL( aObs ); + iClipRepairer->CheckMetaHeaderL( aClipPath ); + } + else + { + // Verify that not exist in queue + TInt loop( iRepairQueue.Count() - 1 ); + for ( ; loop >= 0; loop-- ) + { + if ( !aClipPath.CompareC( iRepairQueue[loop]->Des() ) ) + { + break; + } + } + + // Add to queue + if ( loop < 0 ) + { + LOG1( "CRtpClipManager::FixMetaHeaderL(), Fix queued: %S", &aClipPath ); + AddClipToRepairQueueL( aClipPath ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::FixMetaHeaderL +// Fixes corrupted clip's meta header syncronously. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::FixMetaHeaderL( const TDesC& aClipPath ) + { + LOG1( "CRtpClipManager::FixMetaHeaderL(), aClipPath: %S", &aClipPath ); + + iFile.Close(); + delete iClipRepairer; iClipRepairer = NULL; + iClipRepairer = CRtpClipRepairer::NewL( NULL ); + iClipRepairer->CheckMetaHeaderL( aClipPath ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::DeleteRtpRepairer +// Kills clip repairer after work done. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpClipManager::DeleteRtpRepairer( MRtpClipRepairObserver* aObs ) + { + // Remove handled name from the queue first + iFile.Close(); + TInt last( iRepairQueue.Count() - 1 ); + if ( last > KErrNotFound && iClipRepairer && + !iRepairQueue[last]->Des().Compare( iClipRepairer->CurrentClipName() ) ) + { + delete iRepairQueue[last]; + iRepairQueue[last] = NULL; + iRepairQueue.Remove( last ); + } + + // Repairer must be deleted in any case + delete iClipRepairer; iClipRepairer = NULL; + TInt err( KErrNotFound ); + last = iRepairQueue.Count() - 1; + LOG1( "CRtpClipManager::DeleteRtpRepairer(), queue count: %d", iRepairQueue.Count() ); + + while ( last > KErrNotFound && err ) + { + // Create new repairer and start it + TPath path( iRepairQueue[last]->Des() ); + TRAP( err, iClipRepairer = CRtpClipRepairer::NewL( aObs ) ); + if ( !err ) + { + TRAP( err, iClipRepairer->CheckMetaHeaderL( path ) ); + if ( err ) + { + LOG1( "CRtpClipManager::DeleteRtpRepairerL(), CheckMetaHeaderL Leaved: %d", err ); + + // Remove clip which can't be repaired from the queue + delete iRepairQueue[last]; + iRepairQueue[last] = NULL; + iRepairQueue.Remove( last ); + + // Ready for the next clip + last = iRepairQueue.Count() - 1; + delete iClipRepairer; iClipRepairer = NULL; + } + } + else + { + LOG1( "CRtpClipManager::DeleteRtpRepairerL(), No memory for new repairer: %d", err ); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::VerifyPostRuleL +// Verifies post acqusition rule of clip. +// ----------------------------------------------------------------------------- +// +TInt CRtpClipManager::VerifyPostRuleL( + const TUint8 aPostRule, + CRtpMetaHeader* aMetaHeader ) + { + LOG( "CRtpClipManager::VerifyPostRule()" ); + + switch ( aPostRule ) + { + case EContentRightsRecordingAllowed: + LOG( "CRtpClipManager::VerifyPostRule(), EContentRightsRecordingAllowed !" ); + break; + + case EContentRightsLockToDevice: + { + TName imei( KNullDesC ); + aMetaHeader->ReadDeviceInfoL( imei ); + if ( !iImei || imei.Compare( iImei->Des() ) ) + { + LOG( "CRtpClipManager::VerifyPostRule(), EContentRightsLockToDevice" ); + LOG1( "CRtpClipManager::VerifyPostRule(), ERmPlayDeviceLockError: %S", &imei ); + LOG1( "CRtpClipManager::VerifyPostRule(), Phone's IMEI: %S", &*iImei ); + return KErrAccessDenied; + } + } + break; + + default: + LOG1( "RM-CRtpClipManager::VerifyPostRule(), Default case: %d", aPostRule ); + break; + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::GetDetailsL +// Updates details from meta header attributes. +// ----------------------------------------------------------------------------- +// +void CRtpClipManager::GetDetailsL( + const CRtpMetaHeader::SAttributes& aAttributes, + SRtpClipDetails& aDetails, + CRtpMetaHeader* aMetaHeader ) + { + aDetails.iRecOngoing = aAttributes.iOngoing; + aDetails.iCompleted = aAttributes.iCompleted; + aDetails.iProtected = aAttributes.iProtected; + aDetails.iFailed = aAttributes.iFailed; + aDetails.iQuality = aAttributes.iQuality; + aDetails.iPlayCount = aAttributes.iPlayCount; + aDetails.iPlaySpot = aAttributes.iPlaySpot; + aDetails.iParental = aAttributes.iParental; + + LOG1( "CRtpClipManager::GetDetailsL(), iRecOngoing: %d", aDetails.iRecOngoing ); + LOG1( "CRtpClipManager::GetDetailsL(), iCompleted: %d", aDetails.iCompleted ); + LOG1( "CRtpClipManager::GetDetailsL(), iProtected: %d", aDetails.iProtected ); + LOG1( "CRtpClipManager::GetDetailsL(), iFailed: %d", aDetails.iFailed ); + LOG1( "CRtpClipManager::GetDetailsL(), iQuality: %d", aDetails.iQuality ); + LOG1( "CRtpClipManager::GetDetailsL(), iPlayCount: %d", aDetails.iPlayCount ); + LOG1( "CRtpClipManager::GetDetailsL(), iPlaySpot: %d", aDetails.iPlaySpot ); + LOG1( "CRtpClipManager::GetDetailsL(), iParental: %d", aDetails.iParental ); + + // ESG + aMetaHeader->ReadEsgDataL( aDetails.iService, aDetails.iProgram ); + LOG1( "CRtpClipManager::GetDetailsL(), iService: %S", &aDetails.iService ); + LOG1( "CRtpClipManager::GetDetailsL(), iProgram: %S", &aDetails.iProgram ); + + // Start time + aMetaHeader->ReadStartTimeL( aDetails.iStartTime ); + + // End time + aMetaHeader->ReadEndTimeL( aDetails.iEndTime ); + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + TName time( KNullDesC ); aDetails.iEndTime.FormatL( time, KTimeDateFormat ); + LOG1( "CRtpClipManager::GetDetailsL(), End time: %S", &time ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + // Duration + aMetaHeader->ReadDurationL( aDetails.iDuration ); + LOG1( "CRtpClipManager::GetDetailsL(), iDuration: %d", aDetails.iDuration ); + aDetails.iDuration/= 1000; // convert to seconds + + // Post acquisition + aDetails.iPostRuleOk = !VerifyPostRuleL( aAttributes.iPostRule, aMetaHeader ); + LOG1( "CRtpClipManager::GetDetailsL(), iPostRuleOk: %d", aDetails.iPostRuleOk ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::NewClipRootL +// Root path of the new clip, depends on user media setting. +// If memory card is selected, but not available, default saving to phone memory. +// ----------------------------------------------------------------------------- +// +void CRtpClipManager::NewClipRootL( TDes& aClipPath, const TDriveNumber aDrive ) + { + // Begin of the save path + if ( aDrive == EDriveC ) + { + aClipPath = PathInfo::PhoneMemoryRootPath(); + aClipPath.Append( PathInfo::VideosPath() ); + } + else + { + aClipPath = PathInfo::MemoryCardRootPath(); + aClipPath.Append( PathInfo::VideosPath() ); + } + + // Verify and create path if not exist + if ( !BaflUtils::PathExists( iFs, aClipPath ) ) + { + TInt err( iFs.MkDirAll( aClipPath ) ); + if ( err && aDrive != EDriveC ) + { + LOG1( "CRtpClipManager::NewClipRootL(), Forced to Use Phone Memory !", err ); + + // Memorycard not acceptable -> Use phone memory + err = KErrNone; + aClipPath = PathInfo::PhoneMemoryRootPath(); + aClipPath.Append( PathInfo::VideosPath() ); + BaflUtils::EnsurePathExistsL( iFs, aClipPath ); + } + + User::LeaveIfError( err ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::NewIndexNameL +// Creates new clip name from program name (eigth first letters + index). +// If program name allready in use, adds indexing to the end of name. +// ----------------------------------------------------------------------------- +// +void CRtpClipManager::NewIndexNameL( TDes& aClipPath, const TDesC& aProgram ) + { + LOG1( "CRtpClipManager::NewIndexNameL(), aClipPath : %S", &aClipPath ); + LOG1( "CRtpClipManager::NewIndexNameL(), aProgram : %S", &aProgram ); + + // Remove special characters + TBuf program( aProgram.Left( KMaxProgramChars ) ); + for ( TInt i( program.Length() - 1 ); i >= 0; i-- ) + { + TChar letter( program[i] ); + // Remove if not alpha nor space + if ( !letter.IsAlphaDigit() && !letter.IsSpace() ) + { + program.Delete( i, 1 ); + } + } + program.TrimRight(); + + TInt index( KFirstFileIndex ); + + // Test name for existing clip check + TPath testName( aClipPath ); + if ( program.Length() ) + { + testName.Append( program ); + } + else + { + // Zero length program name, start from "(01).rtp" + testName.AppendFormat( KIndexFormat, index++ ); + } + + // Name already used ? + testName.Append( KDvrClipExtension ); + if ( BaflUtils::FileExists( iFs, testName ) ) + { + do + { + LOG1( "CRtpClipManager::NewIndexNameL(), Clip exist: %S", &testName ); + + // Abort if file index exceeds "(99)" + User::LeaveIfError( ( index > KMaxFileIndex ) * KErrOverflow ); + + // New test name + testName.Copy( aClipPath ); + testName.Append( program ); + testName.AppendFormat( KIndexFormat, index++ ); + testName.Append( KDvrClipExtension ); + } + while ( BaflUtils::FileExists( iFs, testName ) ); + } + + // Return suitable filename + aClipPath.Copy( testName ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipManager::AddClipToRepairQueueL +// Inserts new clip name to the first in queue. +// ----------------------------------------------------------------------------- +// +void CRtpClipManager::AddClipToRepairQueueL( const TDesC& aClipPath ) + { + HBufC* clip = aClipPath.AllocLC(); + User::LeaveIfError( iRepairQueue.Insert( clip, 0 ) ); + CleanupStack::Pop( clip ); + } + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipRepairer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpClipRepairer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,432 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the common recording engine file repairer class.* +*/ + + + + +// INCLUDE FILES +#include "CRtpClipRepairer.h" +#include +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KMaxGroupTime( 4000 ); // 4s + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::NewL +// Static two-phased constructor. Leaves object to cleanup stack. +// ----------------------------------------------------------------------------- +// +CRtpClipRepairer* CRtpClipRepairer::NewL( MRtpClipRepairObserver* aObs ) + { + CRtpClipRepairer* self = new( ELeave ) CRtpClipRepairer( aObs ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::CRtpClipRepairer +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpClipRepairer::CRtpClipRepairer( MRtpClipRepairObserver* aObs ) + : CRtpFileBase(), + iObs( aObs ), + iSeekArrayPoint( KErrNotFound ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::ConstructL() + { + LOG( "CRtpClipRepairer::ConstructL()" ); + + CRtpFileBase::ConstructL(); + } + +// ----------------------------------------------------------------------------- +// Destructor +// +CRtpClipRepairer::~CRtpClipRepairer() +// ----------------------------------------------------------------------------- + { + LOG( "CRtpClipRepairer::~CRtpClipRepairer()" ); + + Cancel(); + delete iFileData; + delete iMetaHeader; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::CurrentClipName +// Getter for the clip name under repairing. +// ----------------------------------------------------------------------------- +// +TPtrC CRtpClipRepairer::CurrentClipName() + { + if ( iCurrentPath ) + { + return iCurrentPath->Des(); + } + + return KNullDesC(); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::CheckMetaHeaderL +// Checks if corrupted meta header of clip is possible to fix. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::CheckMetaHeaderL( const TDesC& aClipName ) + { + LOG1( "CRtpClipRepairer::CheckMetaHeaderL(), aClipName: %S", &aClipName ); + + // Only one repair at the time + if ( iMetaHeader || iCurrentPath ) + { + User::Leave( KErrAlreadyExists ); + } + + // Open clip and read the meta header + delete iCurrentPath; iCurrentPath = NULL; + iCurrentPath = aClipName.AllocL(); + if ( !iFs.Handle() ) + { + User::LeaveIfError( iFs.Connect() ); + } + iFile.Close(); + User::LeaveIfError( iFile.Open( iFs, aClipName, + EFileShareExclusive | EFileStream | EFileWrite ) ); + delete iMetaHeader; iMetaHeader = NULL; + iMetaHeader = CRtpMetaHeader::NewL( iFile, CRtpMetaHeader::EMetaUpdate ); + + // Attributes + CRtpMetaHeader::SAttributes att; + TRAPD( err, iMetaHeader->ReadAttributesL( att ) ); + + // Verify that clip version not too old? + if ( att.iVersion < KMinValidClipVersion ) + { + LOG( "CRtpClipRepairer::CheckMetaHeaderL(), Not Valid Clip Version" ); + User::Leave( KErrGeneral ); + } + + // If error or rec ongoing -> recording interrupted ie. battery removed + if ( err || att.iOngoing ) + { + att.iOngoing = EFalse; + att.iPlayCount = 0; + att.iPlaySpot = KErrNone; + iMetaHeader->WriteAttributesL( att ); + } + + // Duration + TInt duration( 0 ); + iMetaHeader->ReadDurationL( duration ); + LOG1( "CRtpClipRepairer::CheckMetaHeaderL(), duration: %d", duration ); + + // Update seek array + if ( ( !duration || duration > KSeekArrayInterval ) && !ValidSeekHeaderL() ) + { + UpdateSeekArrayL(); + } + else + { + // Set start time to file date + TTime startTime( 0 ); + iMetaHeader->ReadStartTimeL( startTime ); + iFile.SetModified( startTime ); + iFile.Close(); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::RunL +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::RunL() + { + User::LeaveIfError( iStatus.Int() ); + const TUint prevTime( iGroupTime ); + UpdateGroupHeaderVariablesL( iDataPtr ); + delete iFileData; iFileData = NULL; + + // Current header valid? + if ( iThisGroup > iNextGroupPoint || iThisGroup < iPrevGroupPoint || + iGroupTime < prevTime || iGroupTime > ( prevTime + KMaxGroupTime ) ) + { + iLastSeekAddr = iPrevGroupPoint; + iThisGroup = iSeekArrayPoint; + } + else + { + // Handle readed group + GroupToSeekArrayL(); + } + + // Continue with next group if repair asyncronous? + if ( iObs ) + { + if ( iThisGroup < iSeekArrayPoint ) + { + // Asyncronous ( normal clip repairing ) + ReadNextGroupHeaderFromFileL(); + } + else + { + // All done, finalize the clip + AddSpecialPacketL( MRtpFileWriteObserver::ERtpClipEnd ); + FinalizeSeekArrayL( KErrNone ); + iObs->RtpClipRepaired( KErrNone ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::RunError +// Returns: System wide error code of indication send leave reason +// ----------------------------------------------------------------------------- +// +TInt CRtpClipRepairer::RunError( TInt aError ) + { + LOG1( "CRtpClipRepairer::RunError(), RunL Leaved: %d", aError ); + + TRAP_IGNORE( FinalizeSeekArrayL( aError ) ); + if ( iObs ) + { + iObs->RtpClipRepaired( ( iGroupsTotalCount )? KErrNone: aError ); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::DoCancel +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::DoCancel() + { + LOG( "CRtpClipRepairer::DoCancel()" ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::ValidSeekHeaderL +// Verifies if seek header and seek array are valid. +// ----------------------------------------------------------------------------- +// +TBool CRtpClipRepairer::ValidSeekHeaderL() + { + // Seek header + iSeekHeaderPoint = iMetaHeader->SeekHeaderPoint(); + ReadSeekHeaderL(); + + // Seek array point + iMetaHeader->ReadSeekArrayPointL( iSeekArrayPoint ); + + // Verify seek array + if ( iLastSeekAddr > iFirstSeekAddr && iSeekArrayPoint > iLastSeekAddr ) + { + TInt count( KErrNotFound ); + TRAPD( err, count = ReadSeekArrayL( iSeekArrayPoint ) ); + if ( !err && count > 0 ) + { + // Seek array is ok + return ETrue; + } + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::UpdateSeekArrayL +// Scans all packet groups in clip and updates seek array. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::UpdateSeekArrayL() + { + LOG( "CRtpClipRepairer::UpdateSeekArrayL()" ); + + // Scan complete clip for seek array + ResetSeekArray(); + User::LeaveIfError( iFile.Size( iSeekArrayPoint ) ); + iThisGroup = iFirstSeekAddr; + iGroupTime = 0; + iNextGroupPoint = 0; + iGroupsTotalCount = 0; + + // Start reading + if ( iObs ) + { + // Asyncronous + ReadNextGroupHeaderFromFileL(); + } + else + { + // Syncronous + TInt err( KErrNone ); + do + { + ReadNextGroupHeaderFromFileL(); + TRAP( err, RunL() ); + } + while ( !err && iThisGroup < iSeekArrayPoint ); + + // All done, finalize the clip + AddSpecialPacketL( MRtpFileWriteObserver::ERtpClipPause ); + FinalizeSeekArrayL( KErrNone ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::ReadNextGroupHeaderFromFileL +// Reads RTP payload from a file. +// Payload is allways after data header, so read position set is not needed. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::ReadNextGroupHeaderFromFileL() + { + iLastSeekAddr = iThisGroup; + + iFileData = HBufC8::NewL( KGroupHeaderBytes ); + iDataPtr.Set( iFileData->Des() ); + if ( iObs ) + { + iFile.Read( iThisGroup, iDataPtr, KGroupHeaderBytes, iStatus ); + SetActive(); + } + else + { + iStatus = iFile.Read( iThisGroup, iDataPtr, KGroupHeaderBytes ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::GroupToSeekArrayL +// Appends next rec group's group time to seek array if interval time exeeded. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::GroupToSeekArrayL() + { + iGroupsTotalCount++; + const TInt delta( iGroupTime - iLastGroupTime ); + if ( delta > KSeekArrayInterval ) + { + LOG2( "CRtpClipRepairer::GroupToSeekArrayL(), iGroupsTotalCount: %d, iThisGroup: %d", + iGroupsTotalCount, iThisGroup ); + iLastGroupTime = iGroupTime; + AppendSeekArrayL( iGroupTime, iThisGroup ); + } + + iPrevGroupPoint = iThisGroup; + iThisGroup = iNextGroupPoint; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::AddSpecialPacketL +// Adds special packet to a new group to the end of clip. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::AddSpecialPacketL( + const MRtpFileWriteObserver::TRtpType aType ) + { + LOG1( "CRtpClipRepairer::AddSpecialPacketL(), aType: %d", aType ); + + // Read last group header + iThisGroup = iPrevGroupPoint; + ReadGroupHeaderL(); + + // End packet + HBufC8* bytes = CRtpUtil::SpecialPacketL( aType ); + CleanupStack::PushL( bytes ); + iFile.Write( iThisGroup + iGroupTotalLen, bytes->Des(), KSpecialPacketLength ); + CleanupStack::PopAndDestroy( bytes ); + + // Update group total size (GTS) + iGroupTotalLen+= KSpecialPacketLength; + bytes = CRtpUtil::MakeBytesLC( iGroupTotalLen ); + iFile.Write( iThisGroup, bytes->Des(), KIntegerBytes ); + CleanupStack::PopAndDestroy( bytes ); + + // Update next group point (NGP) + iNextGroupPoint+= KSpecialPacketLength; + bytes = CRtpUtil::MakeBytesLC( iNextGroupPoint ); + iFile.Write( iThisGroup + KIntegerBytes, bytes->Des(), KIntegerBytes ); + CleanupStack::PopAndDestroy( bytes ); + + // Read packets total count (PTC) + bytes = HBufC8::NewLC( KPacketsCountBytes ); + TPtr8 ptr( bytes->Des() ); + iFile.Read( iThisGroup + KGroupHeaderBytes, ptr, KPacketsCountBytes ); + const TInt packetsCount( CRtpUtil::GetValueL( ptr ) ); + User::LeaveIfError( packetsCount ); + CleanupStack::PopAndDestroy( bytes ); + + // Increment packets tolal count (PTC) by one + bytes = CRtpUtil::MakeBytesLC( packetsCount + 1 ); + iFile.Write( iThisGroup + KGroupHeaderBytes, bytes->Des(), KPacketsCountBytes ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRepairer::FinalizeSeekArrayL +// Appends next rec group to seek array. +// ----------------------------------------------------------------------------- +// +void CRtpClipRepairer::FinalizeSeekArrayL( const TInt aError ) + { + LOG1( "CRtpClipRepairer::FinalizeSeekArrayL(), aError: %d", aError ); + + // New seek array point + iMetaHeader->WriteSeekArrayPointL( iNextGroupPoint ); + + // Update duration + iMetaHeader->WriteDurationL( iGroupTime ); + + // Last group time + CRtpMetaHeader::SAttributes att; + iMetaHeader->ReadAttributesL( att ); + att.iFailed = !( !aError ); + att.iOngoing = EFalse; + att.iPlayCount = 0; + att.iPlaySpot = KErrNone; + iMetaHeader->WriteAttributesL( att ); + + // Finalise + SaveSeekArrayL(); + WriteSeekHeaderL(); + iFile.Flush(); + + // Set start time to file date + TTime startTime( 0 ); + iMetaHeader->ReadStartTimeL( startTime ); + iFile.SetModified( startTime ); + iFile.Close(); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpFileBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpFileBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,354 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP file base class.* +*/ + + + + +// INCLUDE FILES +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KFirstIntegerPoint( 0 ); +const TInt KSecondIntegerPoint( KFirstIntegerPoint + KIntegerBytes ); +const TInt KThirdIntegerPoint( KSecondIntegerPoint + KIntegerBytes ); +const TInt KFourthIntegerPoint( KThirdIntegerPoint + KIntegerBytes ); +const TInt KSeekArrayGranularity( 20 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpFileBase::CRtpFileBase +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpFileBase::CRtpFileBase() + : CActive( CActive::EPriorityStandard ), + iMode( EModeNone ), + iThisGroup( KErrNotFound ), + iGroupsTotalCount( KErrNotFound ), + iFirstSeekAddr( KErrNotFound ), + iLastSeekAddr( KErrNotFound ), + iGroupTotalLen( KErrNotFound ), + iNextGroupPoint( KErrNotFound ), + iPrevGroupPoint( KErrNotFound ), + iGroupTime( 0 ), + iSeekHeaderPoint( KErrNotFound ), + iDataPtr( 0, 0 ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::ConstructL() + { + LOG( "CRtpFileBase::ConstructL()" ); + + iSeekArray = new( ELeave ) CArrayFixFlat( KSeekArrayGranularity ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// +// ----------------------------------------------------------------------------- +// +CRtpFileBase::~CRtpFileBase() + { + LOG( "CRtpFileBase::~CRtpFileBase()" ); + // Do not call Cancel here, it will cause crashes (DoCancel of inherited + // class is never called, instead it jumps to foobar address) + iFile.Close(); + iFs.Close(); + delete iCurrentPath; + delete iSeekArray; + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::DeleteTimeShiftFiles +// Deletes files used during time shift mode. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::DeleteTimeShiftFiles( RArray& aShiftSeek ) + { + LOG1( "CRtpFileBase::DeleteTimeShiftFiles(), count: %d", aShiftSeek.Count() ); + + TInt index( KErrNotFound ); + const TInt count( aShiftSeek.Count() ); + for ( TInt i( 0 ); i < count; i++ ) + { + if ( aShiftSeek[i].iNameIndex != index ) + { + TPath clipPath( KDvrTimeShiftFile ); + index = aShiftSeek[i].iNameIndex; + clipPath.AppendNum( index ); + iFs.Delete( clipPath ); + LOG1( "CRtpFileBase::DeleteTimeShiftFiles(), deleted: %S", &clipPath ); + } + } + + aShiftSeek.Reset(); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::WriteSeekHeaderL +// Writes seek header of all groups. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::WriteSeekHeaderL() + { + User::LeaveIfError( iSeekHeaderPoint ); + + HBufC8* data = HBufC8::NewLC( KSeekHeaderBytes ); + TPtr8 ptr( data->Des() ); + + HBufC8* bytes = CRtpUtil::MakeBytesLC( iGroupsTotalCount ); + ptr.Copy( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = CRtpUtil::MakeBytesLC( iFirstSeekAddr ); + ptr.Append( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = CRtpUtil::MakeBytesLC( iLastSeekAddr ); + ptr.Append( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + User::LeaveIfError( iFile.Write( iSeekHeaderPoint, ptr, KSeekHeaderBytes ) ); + CleanupStack::PopAndDestroy( data ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::ReadSeekHeaderL +// Readss seek header of all groups. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::ReadSeekHeaderL() + { + User::LeaveIfError( iSeekHeaderPoint ); + + HBufC8* bytes = HBufC8::NewLC( KSeekHeaderBytes ); + TPtr8 ptr( bytes->Des() ); + User::LeaveIfError( iFile.Read( iSeekHeaderPoint, ptr, KSeekHeaderBytes ) ); + if ( ptr.Length() < KSeekHeaderBytes ) + { + LOG( "CRtpFileBase::ReadSeekHeaderL(), Seek Header Corrupted" ); + User::Leave( KErrCorrupt ); + } + + iGroupsTotalCount = CRtpUtil::GetValueL( ptr.Mid( KFirstIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iGroupsTotalCount ); + iFirstSeekAddr = CRtpUtil::GetValueL( ptr.Mid( KSecondIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iFirstSeekAddr ); + iLastSeekAddr = CRtpUtil::GetValueL( ptr.Mid( KThirdIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iLastSeekAddr ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::ReadGroupHeaderL +// Reads group header. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::ReadGroupHeaderL() + { + User::LeaveIfError( iThisGroup ); + + HBufC8* bytes = HBufC8::NewLC( KGroupHeaderBytes ); + TPtr8 ptr( bytes->Des() ); + + User::LeaveIfError( iFile.Read( iThisGroup, ptr, KGroupHeaderBytes ) ); + UpdateGroupHeaderVariablesL( ptr ); + + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::UpdateGroupHeaderVariablesL +// Updates group header variables from readed data. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::UpdateGroupHeaderVariablesL( const TDesC8& aDataPtr ) + { + if ( aDataPtr.Length() < KGroupHeaderBytes ) + { + LOG( "CRtpFileBase::UpdateGroupHeaderVariablesL(), Group Header Corrupted" ); + User::Leave( KErrCorrupt ); + } + + iGroupTotalLen = CRtpUtil::GetValueL( aDataPtr.Mid( KFirstIntegerPoint , + KIntegerBytes ) ); + User::LeaveIfError( iGroupTotalLen ); + iNextGroupPoint = CRtpUtil::GetValueL( aDataPtr.Mid( KSecondIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iNextGroupPoint ); + iPrevGroupPoint = CRtpUtil::GetValueL( aDataPtr.Mid( KThirdIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iPrevGroupPoint ); + iGroupTime = CRtpUtil::GetValueL( aDataPtr.Mid( KFourthIntegerPoint, + KIntegerBytes ) ); + User::LeaveIfError( iGroupTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::AppendSeekArrayL +// Appends one item to seek array. +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::AppendSeekArrayL( const TUint aTime, const TInt aPoint ) + { +#ifdef CR_ALL_LOGS + LOG2( "CRtpFileBase::AppendSeekArrayL(), aTime: %u, aPoint: %d", + aTime, aPoint ); +#endif // CR_ALL_LOGS + + SSeek seek; + seek.iTime = aTime; + seek.iPoint = aPoint; + iSeekArray->AppendL( seek ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::SaveSeekArrayL +// +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::SaveSeekArrayL() + { + LOG1( "CRtpFileBase::SaveSeekArrayL(), count: %d", iSeekArray->Count() ); + + const TInt len( KIntegerBytes + iSeekArray->Count() * 2 * KIntegerBytes ); + HBufC8* data = HBufC8::NewLC( len ); + TPtr8 ptr( data->Des() ); + + // Total count + HBufC8* bytes = CRtpUtil::MakeBytesLC( iSeekArray->Count() ); + ptr.Copy( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + for ( TInt i( 0 ); i < iSeekArray->Count(); i++ ) + { + // Time + bytes = CRtpUtil::MakeBytesLC( iSeekArray->At( i ).iTime ); + ptr.Append( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Point + bytes = CRtpUtil::MakeBytesLC( iSeekArray->At( i ).iPoint ); + ptr.Append( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + +#ifdef CR_ALL_LOGS + LOG3( "CRtpFileBase::SaveSeekArrayL(), ind: %d, time: %u, point: %d", + i, iSeekArray->At( i ).iTime, iSeekArray->At( i ).iPoint ); +#endif // CR_ALL_LOGS + } + + User::LeaveIfError( iFile.Write( iNextGroupPoint, ptr, len ) ); + CleanupStack::PopAndDestroy( data ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::ReadSeekArrayL +// +// ----------------------------------------------------------------------------- +// +TBool CRtpFileBase::ReadSeekArrayL( const TInt aPoint ) + { + User::LeaveIfError( aPoint ); + HBufC8* bytes = HBufC8::NewLC( KIntegerBytes ); + TPtr8 ptr( bytes->Des() ); + + // Verify read point + TInt size( KErrNotFound ); + iFile.Size( size ); + User::LeaveIfError( ( aPoint > ( size - KIntegerBytes ) ) * KErrCorrupt ); + + // Total count + User::LeaveIfError( iFile.Read( aPoint, ptr, KIntegerBytes ) ); + const TInt count( CRtpUtil::GetValueL( ptr ) ); + CleanupStack::PopAndDestroy( bytes ); + LOG1( "CRtpFileBase::ReadSeekArrayL(), count: %d", count ); + + // Any point stored? + if ( count > 0 ) + { + // Read array from clip + User::LeaveIfError( ( count > ( KMaxTInt / 2 / KIntegerBytes ) ) * KErrCorrupt ); + const TInt len( count * 2 * KIntegerBytes ); + HBufC8* data = HBufC8::NewLC( len ); + ptr.Set( data->Des() ); + User::LeaveIfError( iFile.Read( aPoint + KIntegerBytes, ptr, len ) ); + + // Set seek array + for ( TInt i( 0 ); i < count; i++ ) + { + const TInt next( i * 2 * KIntegerBytes ); + if ( ptr.Length() < ( next + ( 2 * KIntegerBytes ) ) ) + { + LOG( "CRtpFileBase::ReadSeekArrayL(), Seek Array Corrupted" ); + User::Leave( KErrCorrupt ); + } + + // Time + TUint time( CRtpUtil::GetValueL( ptr.Mid( next, KIntegerBytes ) ) ); + // Point + TInt point( CRtpUtil::GetValueL( ptr.Mid( next + KIntegerBytes, + KIntegerBytes ) ) ); + User::LeaveIfError( point ); + AppendSeekArrayL( time, point ); +#ifdef CR_ALL_LOGS + LOG3( "CRtpFileBase::ReadSeekArrayL(), ind: %d, time: %u, point: %d", + i, time, point ); +#endif // CR_ALL_LOGS + } + + CleanupStack::PopAndDestroy( data ); + } + + return ( count > 0 ); + } + +// ----------------------------------------------------------------------------- +// CRtpFileBase::LogVariables +// ----------------------------------------------------------------------------- +// +void CRtpFileBase::LogVariables( const TDesC& aMethod ) + { +#ifdef CR_ALL_LOGS + LOG1( "CRtpFileBase::LogVariables(), Method: %S", &aMethod ); + LOG1( "CRtpFileBase::LogVariables(), iMode : %d", iMode ); + LOG1( "CRtpFileBase::LogVariables(), GTC : %d", iGroupsTotalCount ); + LOG1( "CRtpFileBase::LogVariables(), FSA : %d", iFirstSeekAddr ); + LOG1( "CRtpFileBase::LogVariables(), LSA : %d", iLastSeekAddr ); + LOG1( "CRtpFileBase::LogVariables(), This : %d", iThisGroup ); + LOG1( "CRtpFileBase::LogVariables(), GTL : %d", iGroupTotalLen ); + LOG1( "CRtpFileBase::LogVariables(), NGP : %d", iNextGroupPoint ); + LOG1( "CRtpFileBase::LogVariables(), PGP : %d", iPrevGroupPoint ); + LOG1( "CRtpFileBase::LogVariables(), GTime : %u", iGroupTime ); +#else // CR_ALL_LOGS + ( void )aMethod; +#endif // CR_ALL_LOGS + } + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpFromFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpFromFile.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,663 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the DVB-H Recording Manager RTP read class.* +*/ + + + + +// INCLUDE FILES +#include "CRtpToFile.h" +#include "CRtpFromFile.h" +#include +#include +#include "CRtpTimer.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KReadTimerInterval( 1000 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpFromFile::NewL +// Static two-phased constructor. Leaves object to cleanup stack. +// ----------------------------------------------------------------------------- +// +CRtpFromFile* CRtpFromFile::NewL( + MRtpFileReadObserver& aReadObs, + CRtpToFile* aToFile ) + { + CRtpFromFile* self = new( ELeave ) CRtpFromFile( aReadObs, aToFile ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::CRtpFromFile +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpFromFile::CRtpFromFile( MRtpFileReadObserver& aReadObs, CRtpToFile* aToFile ) + : CRtpFileBase(), + iReadObs( aReadObs ), + iToFile( aToFile ), + iSkippedRead( EFalse ), + iDuration( 0 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::ConstructL() + { + LOG( "CRtpFromFile::ConstructL()" ); + + CRtpFileBase::ConstructL(); + } + +// ----------------------------------------------------------------------------- +// Destructor +// +CRtpFromFile::~CRtpFromFile() +// ----------------------------------------------------------------------------- + { + LOG( "CRtpFromFile::~CRtpFromFile()" ); + + Cancel(); + delete iTimer; iTimer = NULL; + delete iFileData; iFileData = NULL; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::InitRtpReadL +// Sets path of RTP file. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::InitRtpReadL( + const TDesC& aClipPath, + TInt8& aVersion, + const TBool aTimeShift ) + { + LOG1( "CRtpFromFile::InitRtpReadL(), aClipPath: %S", &aClipPath ); + + // File server + if ( !iFs.Handle() ) + { + User::LeaveIfError( iFs.Connect() ); + } + + // Open clip + aVersion = SwapClipL( aClipPath ); + + // Mode + iMode = ( aTimeShift )? EModeTimeShift: EModeNormal; + +#ifdef CR_ALL_LOGS + LogVariables( _L( "InitRtpReadL()" ) ); +#endif // CR_ALL_LOGS + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::InitRtpReadL +// Sets path of RTP file. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::InitRtpReadL( + const RFile& aFileHandle, + TInt8& aVersion ) + { + LOG( "CRtpFromFile::InitRtpReadL(), with handle" ); + + // File handle + if ( !iFs.Handle() ) + { + User::LeaveIfError( iFs.Connect() ); + } + + // Duplicate handle + iFile.Close(); + iFile.Duplicate( aFileHandle ); + + // File header + ReadClipHeaderL( aVersion ); + delete iCurrentPath; iCurrentPath = NULL; + TFileName name( KNullDesC ); + iFile.FullName( name ); + iCurrentPath = name.AllocL(); + + // Mode + iMode = EModeNormal; + +#ifdef CR_ALL_LOGS + LogVariables( _L( "InitRtpReadL()" ) ); +#endif // CR_ALL_LOGS + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::SwapClipL +// Sets new path of RTP file. +// ----------------------------------------------------------------------------- +// +TInt8 CRtpFromFile::SwapClipL( const TDesC& aClipPath ) + { + LOG1( "CRtpFromFile::SwapClipL(), aClipPath: %S", &aClipPath ); + + iFile.Close(); + if ( !iFs.Handle() ) + { + User::Leave( KErrBadHandle ); + } + + // Delete used clip + if ( iMode == EModeTimeShift ) + { + iFs.Delete( *iCurrentPath ); + } + + // Open new + User::LeaveIfError( iFile.Open( iFs, aClipPath, + EFileShareAny | EFileStream | EFileRead ) ); + // File header + TInt8 version( 0 ); + ReadClipHeaderL( version ); + delete iCurrentPath; iCurrentPath = NULL; + iCurrentPath = aClipPath.AllocL(); + + return version; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ReadNextGroupL +// Reads next RTP packets group from a specified file. +// ----------------------------------------------------------------------------- +// +TInt CRtpFromFile::ReadNextGroupL( const TInt aGroupPoint ) + { + User::LeaveIfError( iMode ); + TBool delayedRead( EFalse ); + + // Allready active?? + if ( iFileData ) + { + if ( iTimer || IsActive() ) + { + return KErrInUse; // Read already started, indication, not error + } + else + { + // Packet read may happen during iReadObs.RtpGroupReaded() call + LOG( "CRtpFromFile::ReadNextGroupL(), Delayed read !" ); + delayedRead = ETrue; + } + } + + // Is watch during recording too close to live? + if ( iToFile && iNextGroupPoint >= LastSeekAddr() ) + { + iSkippedRead = ETrue; + LOG( "CRtpFromFile::ReadNextGroupL(), Too close to live !" ); + return KErrEof; // No read actions now, indication, not error + } + + // Group + iThisGroup = ( aGroupPoint > KErrNotFound )? aGroupPoint: iNextGroupPoint; + + // Ok to read more? + if ( iThisGroup > iLastSeekAddr || iGroupTime >= iDuration ) + { + LOG( "CRtpFromFile::ReadNextGroupL(), All packets readed !" ); + User::Leave( KErrEof ); + } + + // Read group + if ( delayedRead ) + { + delete iTimer; iTimer = NULL; + iTimer = CRtpTimer::NewL( *this ); + iTimer->After( KReadTimerInterval ); + } + else + { + ReadGroupHeaderL(); + ReadNextGroupFromFileL(); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::GetClipSdpL +// Reads SDP from a current clip. SDP is stored to meta header during recording. +// ----------------------------------------------------------------------------- +// +HBufC8* CRtpFromFile::GetClipSdpL() + { + User::LeaveIfError( iMode ); + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaRead ); + HBufC8* sdp = metaheader->ReadSdpDataL(); + CleanupStack::PopAndDestroy( metaheader ); + return sdp; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ReadSkippedGroup +// Reads one RTP packet from a specified file if previous read was skipped. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::ReadSkippedGroup() + { + if ( iSkippedRead && iNextGroupPoint < LastSeekAddr() && + iMode != EModeNone && iFileData != NULL ) + { + iSkippedRead = EFalse; + iThisGroup = iNextGroupPoint; + TRAP_IGNORE( ReadGroupHeaderL(); + ReadNextGroupFromFileL() ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::UpdateLastSeekAddr +// Updates final last seek addres from clip write when recording stopped. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::UpdateLastSeekAddr() + { + if ( iToFile ) + { + iDuration = iToFile->GetCurrentLength(); + iLastSeekAddr = iToFile->LastSeekAddr(); + + LOG2( "CRtpFromFile::UpdateLastSeekAddr(), iLastSeekAddr: %d, iDuration: %d", + iLastSeekAddr, iDuration ); + // Recording is stopped + iToFile = NULL; + } + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::SetSeekPointL +// Sets the seek point of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::SetSeekPointL( const TUint aTime ) + { + Cancel(); + delete iTimer; iTimer = NULL; + delete iFileData; iFileData = NULL; + User::LeaveIfError( iMode ); + + // Group from the seek array, accuracy 30s + iThisGroup = FindSeekGroup( aTime, ( iToFile )? iToFile->SeekArray(): iSeekArray ); + LOG2( "CRtpFromFile::SetSeekPointL(), aTime: %d, group from seek array: %d", + aTime, iThisGroup ); + if ( iThisGroup == KErrNotFound ) + { + iThisGroup = iFirstSeekAddr; + } + ReadGroupHeaderL(); + + // Find group basing on the seek time, accuracy 0 - 3 s + if ( aTime > 0 ) + { + while ( aTime > iGroupTime && iNextGroupPoint < iLastSeekAddr ) + { + // Next group + iThisGroup = iNextGroupPoint; + ReadGroupHeaderL(); +#ifdef CR_ALL_LOGS + LOG2( "CRtpFromFile::SetSeekPointL(), iThisGroup: %u, iGroupTime: %u", + iThisGroup, iGroupTime ); +#endif // CR_ALL_LOGS + } + } + + // Prepare for next read, one extra group back looks better + iNextGroupPoint = ( iPrevGroupPoint > iFirstSeekAddr ) ? + iPrevGroupPoint : iThisGroup; + delete iFileData; iFileData = NULL; + + LOG1( "CRtpFromFile::SetSeekPointL(), iNextGroupPoint: %d", + iNextGroupPoint ); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::StopRtpRead +// Stops file reading. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::StopRtpRead( const TInt aStatus, const TUint aPlayerBuf ) + { + LOG2( "CRtpFromFile::StopRtpRead(), aStatus: %d, aPlayerBuf: %u", + aStatus, aPlayerBuf ); + LOG2( "CRtpFromFile::StopRtpRead(), iMode: %d, iGroupTime: %d", + iMode, iGroupTime ); + Cancel(); + if ( iMode != EModeNone ) + { + iFile.ReadCancel(); + +#ifdef CR_ALL_LOGS + LogVariables( _L( "StopRtpRead()" ) ); +#endif // CR_ALL_LOGS + } + + delete iTimer; iTimer = NULL; + delete iFileData; iFileData = NULL; + if ( iMode == EModeNormal || iMode == EModeHandle ) + { + // Try to seek back to what user sees for continue play spot + if ( !aStatus & iThisGroup > 0 && iThisGroup < iLastSeekAddr ) + { + const TInt thisGroup( iThisGroup ); + TRAPD( err, SetSeekPointL( iGroupTime - aPlayerBuf ) ); + if ( err ) + { + LOG1( "CRtpFromFile::StopRtpRead(), SetSeekPointL Leaved: %d", err ); + iThisGroup = thisGroup; + } + } + + // Update meta header if no error + if ( !aStatus ) + { + TInt err ( KErrNone ); + if ( iToFile ) + { + TRAP( err, iToFile->UpdatePlayAttL( iThisGroup ) ); + } + else + { + TRAP( err, UpdatePlayAttL() ); + } + + // Possible error ignored + if ( err ) + { + LOG1( "CRtpFromFile::StopRtpRead(), UpdatePlayAttL Leaved: %d", err ); + } + } + } + + iMode = EModeNone; + iFile.Close(); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::RunL +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + // All groups readed? + if ( iThisGroup >= iLastSeekAddr || + ( iNextGroupPoint >= iLastSeekAddr && + iToFile && iToFile->Action() == MRtpFileWriteObserver::ESavePause ) ) + { + LOG2( "CRtpFromFile::RunL(), All groups readed ! total: %d, iDuration: %d", + iThisGroup, iDuration ); + iGroupTime = iDuration; + } + + iReadObs.GroupReadedL( iDataPtr, iGroupTime, ( iGroupTime >= iDuration ) ); + delete iFileData; iFileData = NULL; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::RunError +// ----------------------------------------------------------------------------- +// +TInt CRtpFromFile::RunError( TInt aError ) + { + LOG1( "CRtpFromFile::RunError(), RunL Leaved: %d", aError ); + + iReadObs.ReadStatus( aError ); + StopRtpRead( aError, 0 ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::DoCancel +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::DoCancel() + { + LOG( "CRtpFromFile::DoCancel()" ); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::TimerEventL +// Internal timer call this when triggered. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::TimerEventL() + { + LOG( "CRtpFromFile::TimerEventL() in" ); + + ReadGroupHeaderL(); + ReadNextGroupFromFileL(); + delete iTimer; iTimer = NULL; + + LOG( "CRtpFromFile::TimerEventL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::TimerError +// Internal timer call this when TimerEventL() leaves. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::TimerError( const TInt aError ) + { + LOG1( "CRtpFromFile::TimerError(), TimerEventL Leaved: %d", aError ); + + StopRtpRead( aError, 0 ); + delete iTimer; iTimer = NULL; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ReadClipHeaderL +// Reads meta data and seek header from the beginning of the file. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::ReadClipHeaderL( TInt8& aVersion ) + { + LOG1( "CRtpFromFile::ReadClipHeaderL(), iToFile: %d", iToFile ); + + if ( !iToFile ) + { + TInt seekArrayPoint( KErrNotFound ); + aVersion = ReadMetaHeaderL( iSeekHeaderPoint, seekArrayPoint ); + ReadSeekHeaderL(); + + // Read seek array if exist + if ( seekArrayPoint > iLastSeekAddr ) + { + ReadSeekArrayL( seekArrayPoint ); + } + } + else // Recording ongoing with the same clip + { + aVersion = KCurrentClipVersion; + iSeekHeaderPoint = iToFile->SeekHeaderPoint(); + iGroupsTotalCount = iToFile->GroupsTotalCount(); + iFirstSeekAddr = iToFile->FirstSeekAddr(); + iLastSeekAddr = iToFile->LastSeekAddr(); + } + + iNextGroupPoint = iFirstSeekAddr; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ReadMetaHeaderL +// Reads meta data header from the beginning of the file. +// ----------------------------------------------------------------------------- +// +TInt8 CRtpFromFile::ReadMetaHeaderL( + TInt& aSeekHeaderPoint, + TInt& aSeekArrayPoint ) + { + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaRead ); + aSeekHeaderPoint = metaheader->SeekHeaderPoint(); + metaheader->ReadSeekArrayPointL( aSeekArrayPoint ); + LOG2( "CRtpFromFile::ReadMetaHeaderL(), aSeekHeaderPoint: %d, aSeekArrayPoint: %d", + aSeekHeaderPoint, aSeekArrayPoint ); + // Clip version + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + metaheader->ReadDurationL( iDuration ); + + // Verify post rule + CRtpClipManager* clipManager = CRtpClipManager::NewLC(); + clipManager->VerifyPostRuleL( att.iPostRule, metaheader ); + CleanupStack::PopAndDestroy( clipManager ); + CleanupStack::PopAndDestroy( metaheader ); + + LOG2( "CRtpFromFile::ReadMetaHeaderL(), Version: %d, Duration: %d", + att.iVersion, iDuration ); + return att.iVersion; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::ReadNextGroupFromFileL +// Reads RTP payload from a file. +// Payload is allways after data header, so read position set is not needed. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::ReadNextGroupFromFileL() + { + LOG2( "CRtpFromFile::ReadNextGroupFromFileL(), iThisGroup: %d, iGroupTime: %u", + iThisGroup, iGroupTime ); +#ifdef CR_ALL_LOGS + LogVariables( _L( "ReadNextGroupFromFileL()" ) ); +#endif // CR_ALL_LOGS + + const TInt len( iGroupTotalLen - KGroupHeaderBytes ); + if ( len <= 0 || iThisGroup < iFirstSeekAddr || iThisGroup > iLastSeekAddr ) + { +#ifdef CR_ALL_LOGS + LogVariables( _L( "ReadNextGroupFromFileL()" ) ); +#endif // CR_ALL_LOGS + + LOG( "CRtpFromFile::ReadNextGroupFromFileL(), No More Groups" ); + User::Leave( KErrEof ); + } + + // Reading should never be active at this point + if ( iFileData != NULL ) + { + LOG( "CRtpFromFile::ReadNextGroupFromFileL(), Invalid usage of class !" ); + User::Leave( KErrGeneral ); + } + + // Start reading group + iFileData = HBufC8::NewL( len ); + iDataPtr.Set( iFileData->Des() ); + iFile.Read( iThisGroup + KGroupHeaderBytes, iDataPtr, len, iStatus ); + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::FindSeekGroup +// Finds closes point with seek array, accuracy about 0 - 30 s. +// ----------------------------------------------------------------------------- +// +TInt CRtpFromFile::FindSeekGroup( const TUint aTime, CArrayFix* aArray ) + { + if ( aArray->Count() && aTime >= aArray->At( 0 ).iTime ) + { + for ( TInt i( aArray->Count() - 1 ); i > 0 ; i-- ) + { +#ifdef CR_ALL_LOGS + LOG3( "CRtpFromFile::FindSeekGroup(), ind: %d, aTime: %u, array time: %u", + i, aTime, aArray->At( i ).iTime ); +#endif //CR_ALL_LOGS + + if ( aTime > aArray->At( i ).iTime ) + { + return aArray->At( i ).iPoint; + } + } + + return aArray->At( 0 ).iPoint; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::UpdatePlayAttL +// Updates clip's playback count and spot attributes after watching. +// ----------------------------------------------------------------------------- +// +void CRtpFromFile::UpdatePlayAttL() + { + // Update attributes + if ( iMode == EModeNormal ) + { + iFile.Close(); + User::LeaveIfError( iFile.Open( iFs, *iCurrentPath, + EFileShareAny | EFileStream | EFileWrite ) ); + } + + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaUpdate ); + TTime startTime( 0 ); + metaheader->ReadStartTimeL( startTime ); + + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + + // Step playback counter by one + att.iPlayCount++; + // Update play spot + att.iPlaySpot = ( iThisGroup > 0 && iThisGroup < iLastSeekAddr )? iThisGroup: + KErrNone; + metaheader->WriteAttributesL( att ); + CleanupStack::PopAndDestroy( metaheader ); + LOG2( "CRtpFromFile::UpdatePlayAttL(), New play count: %d, spot: %d", + att.iPlayCount, att.iPlaySpot ); + // Set start time to file date + iFile.SetModified( startTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::LastSeekAddr +// Gets last seek addres. +// It is either from opened clip or from file writer when recording is ongoing. +// ----------------------------------------------------------------------------- +// +TInt CRtpFromFile::LastSeekAddr() + { + if ( iToFile ) + { + iLastSeekAddr = iToFile->LastSeekAddr(); + } + + return iLastSeekAddr; + } + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpMetaHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpMetaHeader.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,625 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP read class.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::NewL +// Static two-phased constructor. Leaves object to cleanup stack. +// ----------------------------------------------------------------------------- +// +CRtpMetaHeader* CRtpMetaHeader::NewL( RFile& aFile, const TMetaMode& aMode ) + { + CRtpMetaHeader* self = CRtpMetaHeader::NewLC( aFile, aMode ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::NewLC +// Static two-phased constructor. Leaves object to cleanup stack. +// ----------------------------------------------------------------------------- +// +CRtpMetaHeader* CRtpMetaHeader::NewLC( RFile& aFile, const TMetaMode& aMode ) + { + CRtpMetaHeader* self = new( ELeave ) CRtpMetaHeader( aFile, aMode ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::CRtpMetaHeader +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpMetaHeader::CRtpMetaHeader( RFile& aFile, const TMetaMode& aMode ) + : iFile( aFile ), + iMode( aMode ), + iMetaData( NULL ), + iDataPtr( 0, 0 ), + iEsgDataPoint( KErrNotFound ), + iSrtpDataPoint( KErrNotFound ), + iSdpDataPoint( KErrNotFound ), + iMetaTotal( KErrNotFound ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ConstructL() + { + LOG( "CRtpMetaHeader::ConstructL()" ); + + // Mode + if ( iMode == EMetaRead || iMode == EMetaUpdate ) + { + // Read whole meta area + ReadTintFromFileL( KMetaLengthPoint, iMetaTotal ); + + // Meta header has reasonable length? + if ( iMetaTotal > KMaxMetaHeaderLength || iMetaTotal <= 0 ) + { + LOG( "CRtpMetaHeader::ConstructL(), Meta Total Corrupted" ); + User::Leave( KErrCorrupt ); + } + + // Room for header + iMetaData = HBufC8::NewL( iMetaTotal ); + iDataPtr.Set( iMetaData->Des() ); + User::LeaveIfError( iFile.Read( KMetaLengthPoint, iDataPtr, iMetaTotal ) ); + + // All data exist in meta header? + if ( iDataPtr.Length() < iMetaTotal ) + { + LOG( "CRtpMetaHeader::ConstructL(), Meta Header Corrupted" ); + User::Leave( KErrCorrupt ); + } + + // ESG data point ( device info point + device info data ) + iEsgDataPoint = KDeviceInfoPoint + KStringLengthBytes + + iDataPtr[KDeviceInfoPoint]; + + // SRTP data point ( ESG data point + Service name + Program name ) + TInt snp( iEsgDataPoint + KStringLengthBytes + iDataPtr[iEsgDataPoint] ); + iSrtpDataPoint = snp + KStringLengthBytes + iDataPtr[snp]; + + // SDD file point ( SRTP data point + SRTP data ) + const TInt srtplen( CRtpUtil::GetValueL( + iDataPtr.Mid( iSrtpDataPoint, KIntegerBytes ) ) ); + User::LeaveIfError( srtplen ); + iSdpDataPoint = iSrtpDataPoint + KIntegerBytes + srtplen; + } + else // Write + { + iMetaData = HBufC8::NewL( 0 ); + // Room for meta length + iMetaTotal = KMetaLengthPoint; + AddIntegerL( KMetaLengthPoint, KErrNotFound ); + } + } + +// ----------------------------------------------------------------------------- +// Destructor +// +CRtpMetaHeader::~CRtpMetaHeader() +// ----------------------------------------------------------------------------- + { + LOG( "CRtpMetaHeader::~CRtpMetaHeader()" ); + + delete iMetaData; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::SeekHeaderPoint +// Getter for seek header point. +// Returns: Point to seek header +// ----------------------------------------------------------------------------- +// +TInt CRtpMetaHeader::SeekHeaderPoint() + { + return iMetaTotal; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::CommitL +// Writes meta header to the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::CommitL() + { + LOG( "CRtpMetaHeader::CommitL() in" ); + + User::LeaveIfError( iMetaTotal ); + User::LeaveIfError( ( iMetaTotal > KMaxMetaHeaderLength ) * KErrCorrupt ); + + if ( iMode == EMetaWrite ) + { + User::LeaveIfError( iEsgDataPoint ); + User::LeaveIfError( iSrtpDataPoint ); + User::LeaveIfError( iSdpDataPoint ); + + // Meta length + iDataPtr.Delete( KMetaLengthPoint, KIntegerBytes ); + AddIntegerL( KMetaLengthPoint, iMetaTotal ); + + User::LeaveIfError( iFile.Write( iDataPtr, iMetaTotal ) ); + } + + LOG( "CRtpMetaHeader::CommitL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteAttributesL +// Writes atributes to meta data header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteAttributesL( const SAttributes& aAtt ) + { + TInt data( 0 ); + data|= aAtt.iOngoing << KOngoingFlagShift; + data|= aAtt.iCompleted << KCompletedFlagShift; + data|= aAtt.iProtected << KProtectedFlagShift; + data|= aAtt.iFailed << KFailedFlagShift; + data|= aAtt.iVersion << KVersionFieldShift; + data|= aAtt.iQuality << KQualityFieldShift; + data|= aAtt.iPostRule << KPostRuleFieldShift; + data|= aAtt.iParental << KParentalFieldShift; + + AddIntegerL( KAttributesPoint, data ); + AddIntegerL( KPlayCountPoint, aAtt.iPlayCount ); + AddIntegerL( KPlaySpotPoint, aAtt.iPlaySpot ); + + // Reserved room for 4 integers + AddIntegerL( KReservedPoint1, 0 ); + AddIntegerL( KReservedPoint2, 0 ); + AddIntegerL( KReservedPoint3, 0 ); + AddIntegerL( KReservedPoint4, 0 ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteStartTimeL +// Writes start date/time info to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteStartTimeL( const TTime& aTime ) + { + AddTimeL( KStartTimePoint, aTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteEndTimeL +// Writes end date/time info to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteEndTimeL( const TTime& aTime ) + { + AddTimeL( KEndTimePoint, aTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteDurationL +// Writes duration of clip to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteDurationL( const TInt aDuration ) + { + AddIntegerL( KDurationPoint, aDuration ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteSeekArrayPointL +// Writes seek array point of clip to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteSeekArrayPointL( const TInt aPoint ) + { + AddIntegerL( KSeekArrayPoint, aPoint ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteUserIdL +// Writes user id to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteUserIdL( const TDesC& aId ) + { + WriteStringDataL( KUserIdPoint, aId ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteDeviceInfoL +// Writes device info to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteDeviceInfoL( const TDesC& aInfo ) + { + WriteStringDataL( KDeviceInfoPoint, aInfo ); + iEsgDataPoint = KDeviceInfoPoint + KStringLengthBytes + aInfo.Length(); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteEsgDataL +// Writes ESG data to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteEsgDataL( const TDesC& aService, const TDesC& aProgram ) + { + // Device info must exist first + User::LeaveIfError( iEsgDataPoint ); + + // Service name + WriteStringDataL( iEsgDataPoint, aService ); + + // Program name + const TInt prog( iEsgDataPoint + KStringLengthBytes + aService.Length() ); + WriteStringDataL( prog, aProgram ); + iSrtpDataPoint = prog + KStringLengthBytes + aProgram.Length(); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteSrtpDataL +// Writes SRTP data to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteSrtpDataL( const TDesC8& aSrtpData ) + { + // ESG data must exist first + User::LeaveIfError( iSrtpDataPoint ); + User::LeaveIfError( ( iMode!=EMetaWrite ) * KErrAccessDenied ); + + AddIntegerL( iSrtpDataPoint, aSrtpData.Length() ); + AddDataL( iSrtpDataPoint + KIntegerBytes, aSrtpData ); + iSdpDataPoint = iSrtpDataPoint + KIntegerBytes + aSrtpData.Length(); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteSdpDataL +// Writes SDP file data to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteSdpDataL( const TDesC8& aSdpData ) + { + // SRTP data must exist first + User::LeaveIfError( iSdpDataPoint ); + User::LeaveIfError( ( iMode != EMetaWrite ) * KErrAccessDenied ); + + if ( aSdpData.Length() ) + { + AddIntegerL( iSdpDataPoint, aSdpData.Length() ); + AddDataL( iSdpDataPoint + KIntegerBytes, aSdpData ); + } + else + { + AddIntegerL( iSdpDataPoint, 0 ); + } + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadAttributesL +// Reads attributes of meta data header from clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadAttributesL( SAttributes& aAtt ) + { + aAtt.iVersion = 0; + + // Attributes + HBufC8* bytes = iDataPtr.Mid( KAttributesPoint, KIntegerBytes ).AllocLC(); + TUint data( CRtpUtil::GetValueL( bytes->Des() ) ); + CleanupStack::PopAndDestroy( bytes ); + aAtt.iOngoing = ( data >> KOngoingFlagShift ) & ETrue; + aAtt.iCompleted = ( data >> KCompletedFlagShift ) & ETrue; + aAtt.iProtected = ( data >> KProtectedFlagShift ) & ETrue; + aAtt.iFailed = ( data >> KFailedFlagShift ) & ETrue; + aAtt.iVersion = ( TUint8 )( ( data >> KVersionFieldShift ) & 0xF ); + aAtt.iQuality = ( TUint8 )( ( data >> KQualityFieldShift ) & KMaxTUint8 ); + aAtt.iPostRule = ( TUint8 )( ( data >> KPostRuleFieldShift ) & KMaxTUint8 ); + aAtt.iParental = ( TUint8 )( ( data >> KParentalFieldShift ) & KMaxTUint8 ); + + // Play count + bytes = iDataPtr.Mid( KPlayCountPoint, KIntegerBytes ).AllocLC(); + aAtt.iPlayCount = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Play start spot + bytes = iDataPtr.Mid( KPlaySpotPoint, KIntegerBytes ).AllocLC(); + aAtt.iPlaySpot = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Reserved room for 4 integers + /* + bytes = iDataPtr.Mid( KReservedPoint1, KIntegerBytes ).AllocLC(); + aAtt.iReservedX = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = iDataPtr.Mid( KReservedPoint2, KIntegerBytes ).AllocLC(); + aAtt.iReservedX = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = iDataPtr.Mid( KReservedPoint3, KIntegerBytes ).AllocLC(); + aAtt.iReservedX = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = iDataPtr.Mid( KReservedPoint4, KIntegerBytes ).AllocLC(); + aAtt.iReservedX = CRtpUtil::GetValueL( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + */ + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadStartTimeL +// Reads date/time of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadStartTimeL( TTime& aTime ) + { + GetTimeL( KStartTimePoint, aTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadEndTimeL +// Reads date/time of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadEndTimeL( TTime& aTime ) + { + GetTimeL( KEndTimePoint, aTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadDurationL +// Reads clip duration of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadDurationL( TInt& aDuration ) + { + HBufC8* bytes = iDataPtr.Mid( KDurationPoint, KIntegerBytes ).AllocLC(); + aDuration = CRtpUtil::GetValueL( bytes->Des() ); + User::LeaveIfError( aDuration ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadSeekArrayPointL +// Reads seek array point of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadSeekArrayPointL( TInt& aPoint ) + { + HBufC8* bytes = iDataPtr.Mid( KSeekArrayPoint, KIntegerBytes ).AllocLC(); + aPoint = CRtpUtil::GetValueL( bytes->Des() ); + User::LeaveIfError( aPoint ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadUserIdL +// Reads user id of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadUserIdL( TDes& aId ) + { + ReadStringDataL( KUserIdPoint, aId ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadDeviceInfoL +// Reads device info of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadDeviceInfoL( TDes& aInfo ) + { + ReadStringDataL( KDeviceInfoPoint, aInfo ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadEsgDataL +// Reads ESG data of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadEsgDataL( TDes& aService, TDes& aProgram ) + { + User::LeaveIfError( iEsgDataPoint ); + + // Service name + ReadStringDataL( iEsgDataPoint, aService ); + + // Program name + const TInt prog( iEsgDataPoint + KStringLengthBytes + aService.Length() ); + ReadStringDataL( prog, aProgram ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadSrtpDataL +// Reads SRTP data of meta header from the clip. +// ----------------------------------------------------------------------------- +// +HBufC8* CRtpMetaHeader::ReadSrtpDataL() + { + User::LeaveIfError( iSrtpDataPoint ); + + // Length + const TInt len( CRtpUtil::GetValueL( + iDataPtr.Mid( iSrtpDataPoint, KIntegerBytes ) ) ); + // Data + const TInt total( iSrtpDataPoint + KIntegerBytes + len ); + User::LeaveIfError( ( len < 0 || total > iDataPtr.MaxLength() ) * KErrCorrupt ); + HBufC8* buf = iDataPtr.Mid( iSrtpDataPoint + KIntegerBytes, len ).AllocL(); + return buf; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadSdpDataL +// Reads SDP file data of meta header from the clip. +// ----------------------------------------------------------------------------- +// +HBufC8* CRtpMetaHeader::ReadSdpDataL() + { + User::LeaveIfError( iSdpDataPoint ); + + // Length + const TInt len( CRtpUtil::GetValueL( + iDataPtr.Mid( iSdpDataPoint, KIntegerBytes ) ) ); + // Data + const TInt total( iSdpDataPoint + KIntegerBytes + len ); + User::LeaveIfError( ( len <= 0 || total > iDataPtr.MaxLength() ) * KErrCorrupt ); + HBufC8* buf = iDataPtr.Mid( iSdpDataPoint + KIntegerBytes, len ).AllocL(); + return buf; + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::WriteStringDataL +// Writes data with length info to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::WriteStringDataL( const TInt aPosition, const TDesC& aData ) + { + const TInt len( aData.Length() ); + User::LeaveIfError( ( len > TInt( KMaxTUint8 ) ) * KErrArgument ); + User::LeaveIfError( ( iMode != EMetaWrite ) * KErrAccessDenied ); + + // Length + TBuf8 buf( KNullDesC8 ); + buf.Append( KCharSpace ); + buf[0] = ( TUint8 )( len ); + AddDataL( aPosition, buf ); + + // Data to 8-bit + HBufC8* data = HBufC8::NewLC( aData.Length() ); + TPtr8 ptr( data->Des() ); + ptr.Copy( aData ); + AddDataL( aPosition + KStringLengthBytes, ptr ); + CleanupStack::PopAndDestroy( data ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadStringDataL +// Reads data with length info of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadStringDataL( const TInt aPosition, TDes& aData ) + { + User::LeaveIfError( ( aPosition < 0 || aPosition > iDataPtr.Length() ) + * KErrArgument ); + const TInt len( iDataPtr[aPosition] ); + User::LeaveIfError( ( len < 0 || len > TInt( KMaxTUint8 ) ) * KErrCorrupt ); + User::LeaveIfError( ( len > aData.MaxLength() ) * KErrArgument ); + + aData.Copy( iDataPtr.Mid( aPosition + KStringLengthBytes, len ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::AddTimeL +// Writes data/time or duration of clip to meta header of the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::AddTimeL( const TInt aPosition, const TTime& aTime ) + { + HBufC8* bytes = CRtpUtil::MakeBytesLC( I64LOW( aTime.Int64() ) ); + AddDataL( aPosition, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + bytes = CRtpUtil::MakeBytesLC( I64HIGH( aTime.Int64() ) ); + AddDataL( aPosition + KIntegerBytes, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::GetTimeL +// Reads time value of meta header from the clip. +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::GetTimeL( const TInt aPosition, TTime& aTime ) + { + TUint low( CRtpUtil::GetValueL( + iDataPtr.Mid( aPosition, KIntegerBytes ) ) ); + TUint high( CRtpUtil::GetValueL( + iDataPtr.Mid( aPosition + KIntegerBytes, KIntegerBytes ) ) ); + + aTime = TInt64( MAKE_TINT64( high, low ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::AddIntegerL +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::AddIntegerL( const TInt aPosition, const TInt aValue ) + { + HBufC8* bytes = CRtpUtil::MakeBytesLC( aValue ); + AddDataL( aPosition, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::AddDataL +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::AddDataL( const TInt aPosition, const TDesC8& aData ) + { + // Write must be in certain order + User::LeaveIfError( ( aPosition > iMetaTotal ) * KErrWrite ); + + switch ( iMode ) + { + case EMetaWrite: + iMetaTotal = iMetaData->Length() + aData.Length(); + iMetaData = iMetaData->ReAllocL( iMetaTotal ); + iDataPtr.Set( iMetaData->Des() ); + iDataPtr.Insert( aPosition, aData ); + break; + + case EMetaUpdate: + User::LeaveIfError( iFile.Write( aPosition, aData, aData.Length() ) ); + break; + + default: + User::Leave( KErrNotSupported ); + break; + } + } + +// ----------------------------------------------------------------------------- +// CRtpMetaHeader::ReadTintFromFileL +// ----------------------------------------------------------------------------- +// +void CRtpMetaHeader::ReadTintFromFileL( const TInt& aPosition, TInt& aValue ) + { + HBufC8* bytes = HBufC8::NewLC( KIntegerBytes ); + TPtr8 ptr( bytes->Des() ); + User::LeaveIfError( iFile.Read( aPosition, ptr, KIntegerBytes ) ); + + aValue = CRtpUtil::GetValueL( ptr ); + CleanupStack::PopAndDestroy( bytes ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpToFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipHandler/src/CRtpToFile.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,712 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP save format class.* +*/ + + + + +// INCLUDE FILES +#include "CRtpToFile.h" +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TUint KMaxValidDelta( 500 ); // 0.5 s +const TUint8 KDummyFullQuality( 100 ); // 100% + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpToFile::NewL +// Static two-phased constructor. Leaves object to cleanup stack. +// ----------------------------------------------------------------------------- +// +CRtpToFile* CRtpToFile::NewL( + MRtpFileObserver& aFileObs, + MRtpFileWriteObserver& aWriteObs ) + { + CRtpToFile* self = new( ELeave ) CRtpToFile( aFileObs, aWriteObs ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::CRtpToFile +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpToFile::CRtpToFile( + MRtpFileObserver& aFileObs, + MRtpFileWriteObserver& aWriteObs ) + : CRtpFileBase(), + iFileObs( aFileObs ), + iWriteObs( aWriteObs ), + iCurrentTime( 0 ), + iPreviousTime( 0 ), + iPreviousDelta( 0 ), + iReferenceTime( 0 ), + iRecordEndTime( 0 ), + iSeekArrayReference( 0 ), + iGroupReUse( KErrNotFound ), + iAction( MRtpFileWriteObserver::ESaveEnd ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::ConstructL() + { + LOG( "CRtpToFile::ConstructL()" ); + + CRtpFileBase::ConstructL(); + iCurrentPath = HBufC::NewL( 0 ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// +CRtpToFile::~CRtpToFile() +// ----------------------------------------------------------------------------- + { + LOG( "CRtpToFile::~CRtpToFile()" ); + + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::InitRtpSaveL +// Sets path of RTP file and initiates variables. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::InitRtpSaveL( + const MRtpFileWriteObserver::SRtpRecParams& aParams, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ) + { + LOG1( "CRtpToFile::InitRtpSaveL() in, ClipPath: %S", &aParams.iClipPath ); + User::LeaveIfError( ( iMode != EModeNone ) * KErrInUse ); + + // Mode + switch ( aAction ) + { + case MRtpFileWriteObserver::ESaveTimeShift: + iMode = EModeTimeShift; + break; + + default: + iMode = EModeNormal; + break; + } + + // File server + if ( !iFs.Handle() ) + { + User::LeaveIfError( iFs.Connect() ); + } + + // Create clip + CreateNewClipL( aParams ); + + // Real clip's end time + iPreviousTime = 0; + iReferenceTime = iGroupTime * KSiKilo; + UpdateCurrentTimeL(); + TInt64 duration( aParams.iEndTime.Int64() - + aParams.iStartTime.Int64() ); + iRecordEndTime = iCurrentTime.Int64() + duration; + + // Prepare variables + iSeekArrayReference = iGroupTime; + iStartGroupTime = iGroupTime; + + LOG( "CRtpToFile::InitRtpSaveL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::ActivateGroupsReuseL +// Starts reuse packet groups for live record when they are played. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::ActivateGroupsReuseL() + { + LOG2( "CRtpToFile::ActivateGroupsReuseL(), iMode: %d, iGroupReUse: %d", + iMode, iGroupReUse ); + if ( iGroupReUse != KErrNotFound || iMode != EModeTimeShift ) + { + User::Leave( KErrInUse ); + } + + iGroupReUse = KErrInUse; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::SwapClipL +// Sets new path of RTP file and initiates variables. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::SwapClipL( const MRtpFileWriteObserver::SRtpRecParams& aParams ) + { + LOG1( "CRtpToFile::SwapClipL(), aClipPath: %S", &aParams.iClipPath ); + + User::LeaveIfError( ( iMode != EModeTimeShift ) * KErrGeneral ); + + // Update old clip + WriteSeekHeaderL(); + iGroupReUse = KErrNotFound; + + // Open new clip + CreateNewClipL( aParams ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::SaveNextRtpGroupL +// Saves one RTP packet group to a specified file. +// ----------------------------------------------------------------------------- +// +TInt CRtpToFile::SaveNextGroupL( + TPtr8& aGroup, + TUint& aGroupLength, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ) + { + // Verify data and mode + User::LeaveIfError( iMode ); + + // Group + iDataPtr.Set( aGroup ); + + // Set group variables + AddGroupL(); + GroupTimeL( aGroupLength ); + AddGroupHeaderL(); + + // Write to file + iAction = aAction; + iFile.Write( iThisGroup, iDataPtr, iGroupTotalLen, iStatus ); + SetActive(); + + LOG2( "CRtpToFile::SaveNextGroupL(), iThisGroup: %d, iGroupTime: %u", + iThisGroup, iGroupTime ); +#ifdef CR_ALL_LOGS + LogVariables( _L( "SaveNextGroupL()" ) ); +#endif // CR_ALL_LOGS + + return iThisGroup; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::UpdatePreviousTimeL +// Updates previous time after pause. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::UpdatePreviousTimeL() + { + UpdateCurrentTimeL(); + iPreviousTime = iCurrentTime.Int64(); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::StopRtpSave +// Stops file saving and finalizes header. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::StopRtpSave( const TInt aError ) + { + Cancel(); + const TRtpFileMode mode( iMode ); + + // If active + if ( mode != EModeNone ) + { +#ifdef CR_ALL_LOGS + LogVariables( _L( "StopRtpSave()" ) ); +#endif // CR_ALL_LOGS + iMode = EModeNone; + + // Update clip headers + if ( mode != EModeTimeShift ) + { + TRAP_IGNORE( WriteFinalMetaHeaderL( aError ) ); + } + else + { + iLastSeekAddr = KMaxTInt; + TRAP_IGNORE( WriteSeekHeaderL() ); + } + + // Close file + iFile.Flush(); + iFile.Close(); + + if ( aError == KErrNoMemory && !iGroupsTotalCount ) + { + // Failed due to insufficient disk space, and couldn't save any + // packets to clip. Happens when recording is started with disk + // space already below threshold, and failed to free any space. + // Delete the clip completely, otherwise we are just consuming + // space below threshold(s). + LOG( "CRtpToFile::StopRtpSave(), deleting file without packets !" ); + iFs.Delete( *iCurrentPath ); + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::GetClipPath +// Getter for full path of currently recorded clip. +// ----------------------------------------------------------------------------- +// +HBufC* CRtpToFile::ClipPath() + { + return iCurrentPath; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::GetCurrentLength +// Gets the current length of the clip during recording. +// ----------------------------------------------------------------------------- +// +TUint CRtpToFile::GetCurrentLength() + { + return iGroupTime; + } + +// ----------------------------------------------------------------------------- +// CRtpFromFile::UpdateRecordEndTime +// Uppdates the current recording end time. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::UpdateRecordEndTime( const TTime& aEndTime ) + { + if ( aEndTime > iCurrentTime ) + { + iRecordEndTime = aEndTime.Int64(); + } + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::UpdatePlayAttL +// Updates clip's playback count and spot attributes after watching. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::UpdatePlayAttL( const TInt aNewSpot ) + { + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaUpdate ); + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + + // Step playback counter by one + att.iPlayCount++; + // Update playback spot + att.iPlaySpot = ( aNewSpot > 0 && aNewSpot < iLastSeekAddr )? aNewSpot: + KErrNone; + metaheader->WriteAttributesL( att ); + CleanupStack::PopAndDestroy( metaheader ); + LOG2( "CRtpToFile::UpdatePlayAttL(), New playback count: %d, spot: %d", + att.iPlayCount, att.iPlaySpot ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::RunL +// ----------------------------------------------------------------------------- +// +void CRtpToFile::RunL() + { + User::LeaveIfError( iStatus.Int() ); + User::LeaveIfError( iFile.Flush() ); + + // Start packets re-use? + if ( iGroupReUse == KErrInUse ) + { + const TInt point( iFileObs.CurrentFileReadPoint( 0 ) ); + if ( point > ( iSeekHeaderPoint + KSeekHeaderBytes ) ) + { + iGroupReUse = KErrNone; + } + } + + // Stop recording if time shift too close to live + if ( iGroupReUse > KErrNone && + iFileObs.CurrentFileReadPoint( 1 ) < KErrNone ) + { + iAction = MRtpFileWriteObserver::ESaveEnd; + LOG( "CRtpToFile::RunL(), Time shift play too close to record !" ); + } + + // Stop recording if end time reached + if ( iCurrentTime.Int64() > iRecordEndTime ) + { + iAction = MRtpFileWriteObserver::ESaveEnd; + LOG( "CRtpToFile::RunL(), Record end time reached !" ); + } + + iFileObs.RtpGroupSaved( iAction ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::RunError +// ----------------------------------------------------------------------------- +// +TInt CRtpToFile::RunError( TInt aError ) + { + LOG1( "CRtpToFile::RunError(), RunL Leaved: %d", aError ); + + if ( &iWriteObs ) + { + iWriteObs.WriteStatus( aError ); + } + + StopRtpSave( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::DoCancel +// ----------------------------------------------------------------------------- +// +void CRtpToFile::DoCancel() + { + LOG( "CRtpToFile::DoCancel()" ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::CreateNewClipL +// Opens new clip and creates initial headers. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::CreateNewClipL( + const MRtpFileWriteObserver::SRtpRecParams& aParams ) + { + // Open file + iFile.Close(); + User::LeaveIfError( iFile.Replace( iFs, aParams.iClipPath, + EFileShareAny | EFileStream | EFileWrite ) ); + // Headers + WriteInitialMetaHeaderL( aParams ); + WriteSeekHeaderL(); + const TInt firstGroup( iSeekHeaderPoint + KSeekHeaderBytes ); + + // Variables + iGroupTime = 0; + iGroupsTotalCount = 0; + iFirstSeekAddr = firstGroup; + iLastSeekAddr = firstGroup; + iNextGroupPoint = firstGroup; + delete iCurrentPath; iCurrentPath = NULL; + iCurrentPath = aParams.iClipPath.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::AddGroupL +// Updates file and packet group header variables for a new group. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::AddGroupL() + { + // New group + iThisGroup = iNextGroupPoint; + + // Group header + // Note ! KGroupHeaderBytes size is allocated to incoming group in + // CCRRtpRecordSink::ResetGroupVariables(), but data does not exits + // before CRtpToFile::AddGroupHeaderL() method is called. + iGroupTotalLen = KGroupHeaderBytes + iDataPtr.Length(); + iNextGroupPoint = iThisGroup + iGroupTotalLen; + const TInt prevGroup( iLastSeekAddr ); + + // Time shift handling + if ( iGroupReUse > KErrNone ) + { + iGroupReUse--; + } + else + { + iGroupsTotalCount++; + iLastSeekAddr = ( iMode != EModeTimeShift )? iThisGroup: 0; + } + + // Start write to the beginning of the clip? + if ( iGroupReUse == KErrNone ) + { + iGroupReUse = iGroupsTotalCount; + iNextGroupPoint = iSeekHeaderPoint + KSeekHeaderBytes; + LOG2( "CRtpToFile::AddGroupL(), iGroupReUse: %d, iNextGroupPoint: %d", + iGroupReUse, iNextGroupPoint ); + } + + // First group in clip? + if ( iGroupsTotalCount == 1 ) + { + iPrevGroupPoint = 0; + WriteSeekHeaderL(); + iSeekArrayReference = iGroupTime; + } + else + { + iPrevGroupPoint = prevGroup; + } + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::GroupTimeL +// Generates group time from group length reported by ring buffer and actual +// network time difference to previous group. Reference time is used to avoid +// running time error caused by network burst. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::GroupTimeL( TUint& aGroupLength ) + { + UpdateCurrentTimeL(); + TUint syncLength( 0 ); + + // previous time initiated? + if ( iPreviousTime > 0 ) + { + const TInt64 delta( iCurrentTime.Int64() - iPreviousTime ); + iReferenceTime+= delta; + const TInt timeDelta( delta / KSiKilo ); + const TInt burstDelta( Abs( timeDelta - iPreviousDelta ) ); +#ifdef CR_ALL_LOGS + LOG3( "CRtpToFile::GroupTimeL(), aGroupLength: %u, burstDelta: %d, timeDelta: %d", + aGroupLength, burstDelta, timeDelta ); +#endif // CR_ALL_LOGS + + // Use reference time? + if ( timeDelta > KNormalRecGroupLength && + Abs( burstDelta - aGroupLength ) < KMaxValidDelta ) + { + iPreviousDelta = 0; + syncLength = iReferenceTime / KSiKilo; + } + else + { + iPreviousDelta = timeDelta; + syncLength = aGroupLength; + } + } + else + { + // In record start and after pause uses only the reported group length + iPreviousDelta = 0; + syncLength = aGroupLength; + iReferenceTime+= aGroupLength * KSiKilo; + } + + // Update group time + iGroupTime += syncLength; + iPreviousTime = iCurrentTime.Int64(); + + // Time shift ongoing? + if ( iMode == EModeTimeShift ) + { + aGroupLength = syncLength; + } + else + { + // Update seek array + aGroupLength = 0; + if ( ( iGroupTime - iSeekArrayReference ) >= KSeekArrayInterval ) + { + AppendSeekArrayL( iGroupTime, iThisGroup ); + iSeekArrayReference = iGroupTime; + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::WriteInitialMetaHeaderL +// Writes initial meta data header of clip. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::WriteInitialMetaHeaderL( + const MRtpFileWriteObserver::SRtpRecParams& aParams ) + { + LOG( "CRtpToFile::WriteInitialMetaHeaderL() in" ); + + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaWrite ); + // Attributes + CRtpMetaHeader::SAttributes att; + att.iOngoing = ETrue; + att.iCompleted = EFalse; + att.iProtected = EFalse; + att.iFailed = EFalse; + att.iVersion = KCurrentClipVersion; + att.iQuality = KDummyFullQuality; + att.iPostRule = aParams.iPostRule; + att.iParental = aParams.iParental; + att.iPlayCount = 0; + att.iPlaySpot = KErrNone; + metaheader->WriteAttributesL( att ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), iPostRule: %d", att.iPostRule ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), iParental: %d", att.iParental ); + + // Start date/time + metaheader->WriteStartTimeL( aParams.iStartTime ); + TName buf( KNullDesC ); +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + aParams.iStartTime.FormatL( buf, KTimeDateFormat ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), iStartTime: %S", &buf ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + // End time + metaheader->WriteEndTimeL( aParams.iEndTime ); + + // Duration + metaheader->WriteDurationL( 0 ); + + // Seek array point + metaheader->WriteSeekArrayPointL( 0 ); + + // Mime info + CRtpUtil::GetMimeInfo( buf ); + metaheader->WriteUserIdL( buf ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), Mime: %S", &buf ); + + // Device info + CRtpUtil::GetImeiL( buf ); + metaheader->WriteDeviceInfoL( buf ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), IMEI: %S", &buf ); + + // ESG info + metaheader->WriteEsgDataL( aParams.iService, aParams.iProgram ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), Service: %S", + &aParams.iService ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), Program: %S", + &aParams.iProgram ); + // SRTP data ( Reserved for future use ) + TBuf8<3> srtp; + srtp.Num( KErrNotFound ); + metaheader->WriteSrtpDataL( srtp ); + + // SDP file + metaheader->WriteSdpDataL( aParams.iSdpData ); + LOG1( "CRtpToFile::WriteInitialMetaHeaderL(), SDP length: %d", + aParams.iSdpData.Length() ); + metaheader->CommitL(); + iSeekHeaderPoint = metaheader->SeekHeaderPoint(); + CleanupStack::PopAndDestroy( metaheader ); + + LOG( "CRtpToFile::WriteInitialMetaHeaderL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::WriteFinalMetaHeaderL +// Writes final meta data header of clip. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::WriteFinalMetaHeaderL( const TInt aStatus ) + { + LOG( "CRtpToFile::WriteFinalMetaHeaderL() in" ); + CRtpMetaHeader* metaheader = CRtpMetaHeader::NewLC( + iFile, CRtpMetaHeader::EMetaUpdate ); + // Update duration + UpdateDurationL( metaheader ); + + // Attributes + CRtpMetaHeader::SAttributes att; + metaheader->ReadAttributesL( att ); + att.iOngoing = EFalse; + att.iCompleted = !aStatus; + att.iFailed = !iGroupsTotalCount; + metaheader->WriteAttributesL( att ); + LOG1( "CRtpToFile::WriteFinalMetaHeaderL(), Completed: %d", att.iCompleted ); + LOG1( "CRtpToFile::WriteFinalMetaHeaderL(), iFailed : %d", att.iFailed ); + + // End date/time + metaheader->ReadStartTimeL( iCurrentTime ); + iRecordEndTime = iCurrentTime.Int64() + iGroupTime; + metaheader->WriteEndTimeL( iRecordEndTime ); +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + TName buf( KNullDesC ); TTime( iRecordEndTime ).FormatL( buf, KTimeDateFormat ); + LOG1( "CRtpToFile::WriteFinalMetaHeaderL(), endTime: %S", &buf ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + // Seek array point + metaheader->WriteSeekArrayPointL( iNextGroupPoint ); + LOG1( "CRtpToFile::WriteFinalMetaHeaderL(), Seek array: %d", iNextGroupPoint ); + CleanupStack::PopAndDestroy( metaheader ); + + // Final seek header + SaveSeekArrayL(); + WriteSeekHeaderL(); + + // Set orginal start time as file date + iFile.SetModified( iCurrentTime ); + + LOG( "CRtpToFile::WriteFinalMetaHeaderL() out" ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::AddGroupHeaderL +// Adds header of one RTP group. +// Room for group header bytes and packets count comes from CCRRtpRecordSink. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::AddGroupHeaderL() + { + // Packets count (PTC) is added in CCRRtpRecordSink::SaveGroup() + + // Group time + HBufC8* bytes = CRtpUtil::MakeBytesLC( iGroupTime ); + iDataPtr.Insert( 0, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Previous group point + bytes = CRtpUtil::MakeBytesLC( iPrevGroupPoint ); + iDataPtr.Insert( 0, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Next Group point + bytes = CRtpUtil::MakeBytesLC( iNextGroupPoint ); + iDataPtr.Insert( 0, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Group total size + bytes = CRtpUtil::MakeBytesLC( iGroupTotalLen ); + iDataPtr.Insert( 0, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::UpdateDurationL +// Updates clip's duration. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::UpdateDurationL( CRtpMetaHeader* aMetaHeader ) + { + aMetaHeader->WriteDurationL( TInt( iGroupTime ) ); + LOG1( "CRtpToFile::UpdateDurationL(), new duration: %u", iGroupTime ); + } + +// ----------------------------------------------------------------------------- +// CRtpToFile::UpdateCurrentTimeL +// Gets current time as network time. +// ----------------------------------------------------------------------------- +// +void CRtpToFile::UpdateCurrentTimeL() + { + iCurrentTime.UniversalTime(); + } + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/data/10208445.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/data/10208445.rss Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Resource file containg the data for Rtp clip recognizer.* +*/ + + + + +#include + +RESOURCE REGISTRY_INFO r_registry + { + dll_uid = 0x10208445; // dll uid + + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x101F7D87; // Const for all data recognizers + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10208446; // implementation uid + version_no = 1; + display_name = "RTP clip recognizer"; + default_data = "RTP clip recognizer"; + opaque_data = ""; + } + }; + } + }; + } + + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/group/RtpClipRecognizer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/group/RtpClipRecognizer.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification for RtpClipRecognizer.dll.* +*/ + + + +#include + +//OPTION ARMCC --asm --interleave +ALWAYS_BUILD_AS_ARM + +TARGET RtpClipRecognizer.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x10208445 + +CAPABILITY CAP_ECOM_PLUGIN + +SOURCEPATH ../data + +START RESOURCE 10208445.rss +#ifdef SYMBIAN_SECURE_ECOM +TARGET RtpClipRecognizer.rsc +#endif +END + +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE CRtpClipRecognizer.cpp + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY apmime.lib +LIBRARY etel.lib +LIBRARY etelmm.lib +LIBRARY flogger.lib diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Recognizer for DVB-H proprietary file format.* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/dvrrtpcliprecognizer.iby CORE_MW_LAYER_IBY_EXPORT_PATH(dvrrtpcliprecognizer.iby) + +PRJ_MMPFILES +RtpClipRecognizer.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/inc/CRtpClipRecognizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/inc/CRtpClipRecognizer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RTP file recognizer class.* +*/ + + + + +#ifndef CRTPCLIPRECOGNIZER_H +#define CRTPCLIPRECOGNIZER_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TInt KUserIdLength( RMobilePhone::KIMSISize ); +const TInt KDeviceIdLength( RMobilePhone::KPhoneSerialNumberSize ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class to make recognisation for RTP propriatary clip. +* +* @lib RtpClipRecognizer.lib +* @since Series 60 3.0 +*/ +class CRtpClipRecognizer : public CApaDataRecognizerType + { + +public: // Constructors and destructor + + /** + * Static method to create instance of this recognizer. This method is called + * by the framework. Method pointer is delivered to the framework by + * ImplementationTable table returned by ImplementationGroupProxy. + * @since Series 60 3.0 + * @param none. + * @return Pointer to newly created instance of the recognizer. + */ + static CApaDataRecognizerType* CreateRecognizerL(); + + /** + * C++ default constructor. Calls CApaDataRecognizerType in it's initializer + * list to complete construction. + */ + CRtpClipRecognizer(); + +private: // Functions from base classes + + /** + * From CApaDataRecognizerType. + * Method called by the framework. This method returns the amount of data + * to be wanted for recognisation. + * @since Series 60 3.0 + * @param none. + * @return Preferred buffer size for recognisation. + */ + virtual TUint PreferredBufSize(); + + /** + * From CApaDataRecognizerType. + * Method to deliver supported data types by this recognizer. + * @since Series 60 3.0 + * @param aIndex a index pointing out which data type + * of the supported ones is returned. + * @return Corresponding data type of the requested index. + */ + virtual TDataType SupportedDataTypeL( TInt aIndex ) const; + + /** + * From CApaDataRecognizerType. + * Overwritten method to handle recognisation. + * @param aName the name of the data. Typically this is a file name + * containing the data to be recognized. + * @param aBuffer a buffer containing PreferredBufSize() from the + * beginning of the file to be recognized. + * @return none. + */ + virtual void DoRecognizeL( const TDesC& aName, + const TDesC8& aBuffer ); + +private: // New methods + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @return an integer converted from bytes. + */ + TInt GetValueL( const TDesC8& aBytes ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return none. + */ + void GetValueL( const TDesC8& aBytes, TInt& aValue ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return a system wide error code. + */ + TInt GetValue( const TDesC8& aBytes, TInt& aValue ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return a system wide error code. + */ + TInt GetValue( const TDesC8& aBytes, TUint& aValue ); + + /** + * Converts bytes to 64 bit integer (TInt64). + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @return a integer value converted from bytes. + */ + TInt64 GetTInt64L( const TDesC8& aBytes ); + + /** + * Getter for RTP clip mime type info. + * @since Series 60 3.0 + * @param aBuf on return contains the mime type. + * @return None. + */ + void GetMimeInfo( TDes8& aMime ); + + /** + * Reads IMEI of the phone HW. + * @since Series 60 3.0 + * @param aBuf on return contains the IMEI. + * @return none. + */ + void GetImeiL( TDes& aImsi ); + + /** + * Reads mobile info of the phone. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void GetMobilePhoneInfoL( RTelServer& aServer, + RMobilePhone& aPhone ); + +private: // Data + + TBuf8 iImei; + + }; + +#endif // CRTPCLIPRECOGNIZER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/rom/dvrrtpcliprecognizer.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/rom/dvrrtpcliprecognizer.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __DVRRTPCLIPRECOGNIZER_IBY__ +#define __DVRRTPCLIPRECOGNIZER_IBY__ + +#include + +ECOM_PLUGIN(RtpClipRecognizer.dll,RtpClipRecognizer.rsc) + +#endif // __DVRRTPCLIPRECOGNIZER_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/src/CRtpClipRecognizer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpClipRecognizer/src/CRtpClipRecognizer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,399 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RTP file recognizer class.* +*/ + + + + +// INCLUDE FILES +#include "CRtpClipRecognizer.h" +#include +#include + +// CONSTANTS +const TInt KIntegerBytes( 4 ); +const TInt KStringLengthBytes( 1 ); +const TInt KMaxMetaHeaderLength( 2048 ); +const TInt KMetaLengthPoint( 0 ); +const TInt KVersionFieldShift( 4 ); +const TInt KPostRuleFieldShift( 16 ); +const TInt KAttributesPoint( KMetaLengthPoint + KIntegerBytes ); // 4 +const TInt KPlayCountPoint( KAttributesPoint + KIntegerBytes ); // 8 +const TInt KPlaySpotPoint( KPlayCountPoint + KIntegerBytes ); // 12 +const TInt KReservedPoint1( KPlaySpotPoint + KIntegerBytes ); // 16 +const TInt KReservedPoint2( KReservedPoint1 + KIntegerBytes ); // 20 +const TInt KReservedPoint3( KReservedPoint2 + KIntegerBytes ); // 24 +const TInt KReservedPoint4( KReservedPoint3 + KIntegerBytes ); // 28 +const TInt KStartTimePoint( KReservedPoint4 + KIntegerBytes ); // 32 +const TInt KEndTimePoint( KStartTimePoint + 2 * KIntegerBytes ); // 40 +const TInt KDurationPoint( KEndTimePoint + 2 * KIntegerBytes ); // 48 +const TInt KSeekArrayPoint( KDurationPoint + KIntegerBytes ); // 52 +const TInt KUserIdPoint( KSeekArrayPoint + KIntegerBytes ); // 56 +const TInt KDeviceInfoPoint( KUserIdPoint + KStringLengthBytes + // 72 + KUserIdLength ); + +const TInt KMaxRtpPostRule( 3 ); +const TInt KMinRtpVersion( 2 ); +const TInt KMaxRtpVersion( 8 ); +const TInt KMaxDuration( 24 * 60 * 60 * 1000 ); +const TInt KMaxDurationError( 60 * 1000 ); +const TInt EContentRightsLockToDevice( 2 ); +const TInt KSupportedMimeTypes( 1 ); +const TInt KRtpClipRecogImplUIDValue( 0x10208446 ); +const TUid KUidMimeRtpClipRecognizer = { 0x10208445 }; +const TUint KNeededMetaBytes( KDeviceInfoPoint + KDeviceIdLength ); +// Result of: TInt64( 1000 * 60 * 60 * 24 ) * TInt64( 365 * 2000 ) +const TInt64 KSecondInMillenium( 63072000000000 ); +_LIT8( KRtpClipMimetype, "application/x-nokia-teh-rtp" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::CreateRecognizerL +// Static method to create instance of CRtpClipRecognizer +// ----------------------------------------------------------------------------- +// +CApaDataRecognizerType* CRtpClipRecognizer::CreateRecognizerL() + { + CApaDataRecognizerType* rtpRecogType = NULL; + rtpRecogType = new( ELeave ) CRtpClipRecognizer(); + return rtpRecogType; // NULL if new failed + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::CRtpClipRecognizer +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpClipRecognizer::CRtpClipRecognizer() + : CApaDataRecognizerType( KUidMimeRtpClipRecognizer, + CApaDataRecognizerType::EHigh ) + { + iImei.Zero(); + iCountDataTypes = KSupportedMimeTypes; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::PreferredBufSize +// Overwritten method from CApaDataRecognizerType +// ----------------------------------------------------------------------------- +// +TUint CRtpClipRecognizer::PreferredBufSize() + { + return KNeededMetaBytes; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::SupportedDataTypeL +// Overwritten method from CApaDataRecognizerType +// ----------------------------------------------------------------------------- +// +TDataType CRtpClipRecognizer::SupportedDataTypeL( TInt aIndex ) const + { + __ASSERT_DEBUG( aIndex >= 0 && + aIndex < KSupportedMimeTypes, User::Invariant() ); + + switch ( aIndex ) + { + case 0: + { + TDataType type( KRtpClipMimetype ); + return type; + } + + default: + break; + } + + return TDataType(); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::DoRecognizeL +// Overwritten method from CApaDataRecognizerType +// ----------------------------------------------------------------------------- +// +void CRtpClipRecognizer::DoRecognizeL( + const TDesC& /*aName*/, + const TDesC8& aBuffer ) + { + iConfidence = ENotRecognized; + iDataType = TDataType(); + + // Verify invest buffer length + if ( aBuffer.Length() < KNeededMetaBytes ) + { + return; // Nothing to recognize + } + + // Meta length + const TInt metaLength( GetValueL( + aBuffer.Mid( KMetaLengthPoint, KIntegerBytes ) ) ); + if ( metaLength > KErrNotFound && metaLength < KMaxMetaHeaderLength ) + { + // Attributes + TUint attr( GetValueL( + aBuffer.Mid( KAttributesPoint, KIntegerBytes ) ) ); + TUint8 ver( ( TUint8 )( ( attr >> KVersionFieldShift ) & 0xF ) ); + TUint8 post( ( TUint8 )( ( attr >> KPostRuleFieldShift ) & KMaxTUint8 ) ); + + // Atributes valid? + if ( post <= KMaxRtpPostRule && + ver >= KMinRtpVersion && ver <= KMaxRtpVersion ) + { + // Verify mime + TBool certain( EFalse ); + TBuf8 info( KNullDesC8 ); + GetMimeInfo( info ); + const TInt len( aBuffer[KUserIdPoint] ); + if ( len == KUserIdLength ) + { + TPtrC8 mime( aBuffer.Mid( KUserIdPoint + KStringLengthBytes, len ) ); + if ( !mime.Compare( info ) ) + { + certain = ETrue; + } + else // old clip without mime in meta header + { + // Star time, end time, duration + TInt64 start( GetTInt64L( + aBuffer.Mid( KStartTimePoint, KIntegerBytes * 2 ) ) ); + TInt64 end( GetTInt64L( + aBuffer.Mid( KEndTimePoint, KIntegerBytes * 2 ) ) ); + TUint dur( GetValueL( + aBuffer.Mid( KDurationPoint, KIntegerBytes ) ) ); + const TInt delta( TInt( ( end - start ) / 1000 ) ); + + if ( start > KSecondInMillenium && + end > KSecondInMillenium && + delta > 0 && dur < KMaxDuration && + delta > ( ( dur > KMaxDurationError )? + dur - KMaxDurationError: 0 ) ) + { + certain = ETrue; + } + } + } + + // Verify content rights + if ( certain && post == EContentRightsLockToDevice ) + { + // IMSI from the phone + if ( !iImei.Length() ) + { + TBuf buf; + GetImeiL( buf ); + iImei.Copy( buf ); + } + + // Verify IMEI + const TInt len( aBuffer[KDeviceInfoPoint] ); + TPtrC8 imei( NULL, 0 ); + if ( len == KDeviceIdLength ) + { + imei.Set( aBuffer.Mid( KDeviceInfoPoint + + KStringLengthBytes, len ) ); + } + if ( len != KDeviceIdLength || imei.Compare( iImei ) ) + { + certain = EFalse; + } + } + + // Set confidence and mime + if ( certain ) + { + iConfidence = ECertain; + iDataType = TDataType( KRtpClipMimetype ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetValueL +// ----------------------------------------------------------------------------- +// +TInt CRtpClipRecognizer::GetValueL( const TDesC8& aBytes ) + { + TInt value( KErrNotFound ); + GetValueL( aBytes, value ); + return value; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetValueL +// ----------------------------------------------------------------------------- +// +void CRtpClipRecognizer::GetValueL( const TDesC8& aBytes, TInt& aValue ) + { + User::LeaveIfError( GetValue( aBytes, aValue ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetValue +// ----------------------------------------------------------------------------- +// +TInt CRtpClipRecognizer::GetValue( const TDesC8& aBytes, TInt& aValue ) + { + TUint value( 0 ); + TInt err( GetValue( aBytes, value ) ); + aValue = ( TInt )( value ); + return err; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetValue +// ----------------------------------------------------------------------------- +// +TInt CRtpClipRecognizer::GetValue( const TDesC8& aBytes, TUint& aValue ) + { + if ( aBytes.Length() >= KIntegerBytes ) + { + aValue = ( TUint )( aBytes[0] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[1] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[2] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[3] ); + return KErrNone; + } + + return KErrUnderflow; + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetTInt64L +// Reads 64 bits integer from descriptor. +// ----------------------------------------------------------------------------- +// +TInt64 CRtpClipRecognizer::GetTInt64L( const TDesC8& aBytes ) + { + TUint low( GetValueL( aBytes.Mid( 0, KIntegerBytes ) ) ); + TUint high( GetValueL( aBytes.Mid( KIntegerBytes, + KIntegerBytes ) ) ); + return TInt64( MAKE_TINT64( high, low ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetMimeInfo +// Mime type info of propriatary RTP clip. +// ----------------------------------------------------------------------------- +// +void CRtpClipRecognizer::GetMimeInfo( TDes8& aMime ) + { + // Meta header has constant room as user info (IMSI) in old clips + aMime.Copy( KRtpClipMimetype().Right( KUserIdLength ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetImeiL +// Read IMEI on phone HW, use dummy under WINS +// ----------------------------------------------------------------------------- +// +void CRtpClipRecognizer::GetImeiL( TDes& aImei ) + { + aImei.Zero(); + +#if defined( __WINS__ ) || defined( __WINSCW__ ) + _LIT( KEmulatorImei, "147407051877780445" ); + aImei.Copy( KEmulatorImei); +#else // __WINS__ || __WINSCW__ + + RTelServer server; + CleanupClosePushL( server ); + RMobilePhone phone; + CleanupClosePushL( phone ); + GetMobilePhoneInfoL( server, phone ); + + // Get IMEI code + TRequestStatus status; + RMobilePhone::TMobilePhoneIdentityV1 phoneIdentity; + phone.GetPhoneId( status, phoneIdentity ); + User::WaitForRequest( status ); + if ( !status.Int() ) + { + TPtrC imei( phoneIdentity.iSerialNumber ); + for ( TInt i( 0 ); i < imei.Length() && i < aImei.MaxLength(); i++ ) + { + if ( TChar( imei[i] ).IsDigit() ) + { + aImei.Append( TChar( imei[i] ) ); + } + } + } + + CleanupStack::PopAndDestroy( &phone ); + CleanupStack::PopAndDestroy( &server ); + +#endif // __WINS__ || __WINSCW__ + } + +//----------------------------------------------------------------------------- +// CRtpClipRecognizer::GetMobilePhoneInfo +//----------------------------------------------------------------------------- +// +void CRtpClipRecognizer::GetMobilePhoneInfoL( + RTelServer& aServer, + RMobilePhone& aPhone ) + { + TInt numPhone( 0 ); + RTelServer::TPhoneInfo phoneInfo; + User::LeaveIfError( aServer.Connect() ); + User::LeaveIfError( aServer.LoadPhoneModule( KMmTsyModuleName ) ); + User::LeaveIfError( aServer.EnumeratePhones( numPhone ) ); + + TInt found( KErrNotFound ); + TName tsyName( KNullDesC ); + for ( TInt i( 0 ); i < numPhone && found == KErrNotFound; i++ ) + { + User::LeaveIfError( aServer.GetPhoneInfo( i, phoneInfo ) ); + User::LeaveIfError( aServer.GetTsyName( i, tsyName ) ); + if ( tsyName.CompareF( KMmTsyModuleName ) == 0 ) + { + found = KErrNone; + } + } + + User::LeaveIfError( found ); + User::LeaveIfError( aPhone.Open( aServer, phoneInfo.iName ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::ImplementationTable +// Table containing the data concerning CRtpClipRecognizer +// ----------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( KRtpClipRecogImplUIDValue, + CRtpClipRecognizer::CreateRecognizerL ) + }; + +// ----------------------------------------------------------------------------- +// CRtpClipRecognizer::ImplementationGroupProxy +// Function called by framework to return data about this recognizer +// ----------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / + sizeof( TImplementationProxy ); + + return ImplementationTable; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/EABI/DvrRtpUtilsU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/EABI/DvrRtpUtilsU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,46 @@ +EXPORTS + _ZN10CRtpPacket12SetTimeStampEm @ 1 NONAME + _ZN10CRtpPacket4NewLEv @ 2 NONAME + _ZN10CRtpPacket5NewLCEv @ 3 NONAME + _ZN10CRtpPacket8ParseRtpERK6TDesC8 @ 4 NONAME + _ZN10CRtpPacketD0Ev @ 5 NONAME + _ZN10CRtpPacketD1Ev @ 6 NONAME + _ZN10CRtpPacketD2Ev @ 7 NONAME + _ZN15CRtpTsConverter10UnInitiateEv @ 8 NONAME + _ZN15CRtpTsConverter4InitERK6TDesC8 @ 9 NONAME + _ZN15CRtpTsConverter4InitERKj @ 10 NONAME + _ZN15CRtpTsConverter4NewLEj @ 11 NONAME + _ZN15CRtpTsConverter9ConvertTsEji @ 12 NONAME + _ZN15CRtpTsConverter9InitiatedEv @ 13 NONAME + _ZN15CRtpTsConverterD0Ev @ 14 NONAME + _ZN15CRtpTsConverterD1Ev @ 15 NONAME + _ZN15CRtpTsConverterD2Ev @ 16 NONAME + _ZN8CRtpUtil10MakeBytesLERKiR5TDes8 @ 17 NONAME + _ZN8CRtpUtil11GetMimeInfoER5TDes8 @ 18 NONAME + _ZN8CRtpUtil11GetMimeInfoER6TDes16 @ 19 NONAME + _ZN8CRtpUtil11MakeBytesLCERKi @ 20 NONAME + _ZN8CRtpUtil14SpecialPacketLEi @ 21 NONAME + _ZN8CRtpUtil4NewLEv @ 22 NONAME + _ZN8CRtpUtil5NewLCEv @ 23 NONAME + _ZN8CRtpUtil8GetImeiLER6TDes16 @ 24 NONAME + _ZN8CRtpUtil8GetValueERK6TDesC8Ri @ 25 NONAME + _ZN8CRtpUtil8GetValueERK6TDesC8Rj @ 26 NONAME + _ZN8CRtpUtil9GetValueLERK6TDesC8 @ 27 NONAME + _ZN8CRtpUtil9GetValueLERK6TDesC8Ri @ 28 NONAME + _ZN8CRtpUtil9MakeBytesERKiR5TDes8 @ 29 NONAME + _ZN8CRtpUtilD0Ev @ 30 NONAME + _ZN8CRtpUtilD1Ev @ 31 NONAME + _ZN8CRtpUtilD2Ev @ 32 NONAME + _ZN9CRtpTimer4NewLER17MRtpTimerObserverRKN7CActive9TPriorityE @ 33 NONAME + _ZN9CRtpTimerD0Ev @ 34 NONAME + _ZN9CRtpTimerD1Ev @ 35 NONAME + _ZN9CRtpTimerD2Ev @ 36 NONAME + _ZTI10CRtpPacket @ 37 NONAME ; ## + _ZTI15CRtpTsConverter @ 38 NONAME ; ## + _ZTI8CRtpUtil @ 39 NONAME ; ## + _ZTI9CRtpTimer @ 40 NONAME ; ## + _ZTV10CRtpPacket @ 41 NONAME ; ## + _ZTV15CRtpTsConverter @ 42 NONAME ; ## + _ZTV8CRtpUtil @ 43 NONAME ; ## + _ZTV9CRtpTimer @ 44 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/bwins/DvrRtpUtilsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/bwins/DvrRtpUtilsu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,30 @@ +EXPORTS + ??1CRtpPacket@@UAE@XZ @ 1 NONAME ; CRtpPacket::~CRtpPacket(void) + ??1CRtpTimer@@UAE@XZ @ 2 NONAME ; CRtpTimer::~CRtpTimer(void) + ??1CRtpTsConverter@@UAE@XZ @ 3 NONAME ; CRtpTsConverter::~CRtpTsConverter(void) + ??1CRtpUtil@@UAE@XZ @ 4 NONAME ; CRtpUtil::~CRtpUtil(void) + ?ConvertTs@CRtpTsConverter@@QAEIIH@Z @ 5 NONAME ; unsigned int CRtpTsConverter::ConvertTs(unsigned int, int) + ?GetImeiL@CRtpUtil@@SAXAAVTDes16@@@Z @ 6 NONAME ; void CRtpUtil::GetImeiL(class TDes16 &) + ?GetMimeInfo@CRtpUtil@@SAXAAVTDes16@@@Z @ 7 NONAME ; void CRtpUtil::GetMimeInfo(class TDes16 &) + ?GetMimeInfo@CRtpUtil@@SAXAAVTDes8@@@Z @ 8 NONAME ; void CRtpUtil::GetMimeInfo(class TDes8 &) + ?GetValue@CRtpUtil@@SAHABVTDesC8@@AAH@Z @ 9 NONAME ; int CRtpUtil::GetValue(class TDesC8 const &, int &) + ?GetValue@CRtpUtil@@SAHABVTDesC8@@AAI@Z @ 10 NONAME ; int CRtpUtil::GetValue(class TDesC8 const &, unsigned int &) + ?GetValueL@CRtpUtil@@SAHABVTDesC8@@@Z @ 11 NONAME ; int CRtpUtil::GetValueL(class TDesC8 const &) + ?GetValueL@CRtpUtil@@SAXABVTDesC8@@AAH@Z @ 12 NONAME ; void CRtpUtil::GetValueL(class TDesC8 const &, int &) + ?Init@CRtpTsConverter@@QAEXABI@Z @ 13 NONAME ; void CRtpTsConverter::Init(unsigned int const &) + ?Init@CRtpTsConverter@@QAEXABVTDesC8@@@Z @ 14 NONAME ; void CRtpTsConverter::Init(class TDesC8 const &) + ?Initiated@CRtpTsConverter@@QAEHXZ @ 15 NONAME ; int CRtpTsConverter::Initiated(void) + ?MakeBytes@CRtpUtil@@SAHABHAAVTDes8@@@Z @ 16 NONAME ; int CRtpUtil::MakeBytes(int const &, class TDes8 &) + ?MakeBytesL@CRtpUtil@@SAXABHAAVTDes8@@@Z @ 17 NONAME ; void CRtpUtil::MakeBytesL(int const &, class TDes8 &) + ?MakeBytesLC@CRtpUtil@@SAPAVHBufC8@@ABH@Z @ 18 NONAME ; class HBufC8 * CRtpUtil::MakeBytesLC(int const &) + ?NewL@CRtpPacket@@SAPAV1@XZ @ 19 NONAME ; class CRtpPacket * CRtpPacket::NewL(void) + ?NewL@CRtpTimer@@SAPAV1@AAVMRtpTimerObserver@@ABW4TPriority@CActive@@@Z @ 20 NONAME ; class CRtpTimer * CRtpTimer::NewL(class MRtpTimerObserver &, enum CActive::TPriority const &) + ?NewL@CRtpTsConverter@@SAPAV1@I@Z @ 21 NONAME ; class CRtpTsConverter * CRtpTsConverter::NewL(unsigned int) + ?NewL@CRtpUtil@@SAPAV1@XZ @ 22 NONAME ; class CRtpUtil * CRtpUtil::NewL(void) + ?NewLC@CRtpPacket@@SAPAV1@XZ @ 23 NONAME ; class CRtpPacket * CRtpPacket::NewLC(void) + ?NewLC@CRtpUtil@@SAPAV1@XZ @ 24 NONAME ; class CRtpUtil * CRtpUtil::NewLC(void) + ?ParseRtp@CRtpPacket@@QAEHABVTDesC8@@@Z @ 25 NONAME ; int CRtpPacket::ParseRtp(class TDesC8 const &) + ?SetTimeStamp@CRtpPacket@@QAEXK@Z @ 26 NONAME ; void CRtpPacket::SetTimeStamp(unsigned long) + ?SpecialPacketL@CRtpUtil@@SAPAVHBufC8@@H@Z @ 27 NONAME ; class HBufC8 * CRtpUtil::SpecialPacketL(int) + ?UnInitiate@CRtpTsConverter@@QAEXXZ @ 28 NONAME ; void CRtpTsConverter::UnInitiate(void) + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/group/DvrRtpUtils.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/group/DvrRtpUtils.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification for DvrRtpUtils.dll.* +*/ + + + +#include + +TARGET DvrRtpUtils.dll +TARGETTYPE dll +UID 0x1000008d 0x10208451 + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE CRtpUtil.cpp +SOURCE CRtpTimer.cpp +SOURCE CRtpPacket.cpp +SOURCE CRtpTsConverter.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../../../conf + +MW_LAYER_SYSTEMINCLUDE + + +LIBRARY euser.lib // Common +LIBRARY bafl.lib // Bafl utils +LIBRARY etel.lib // +LIBRARY etelmm.lib // +LIBRARY flogger.lib // Debug logger + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Component description file for DvrRtpUtils.dll.* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/dvrrtputils.iby CORE_MW_LAYER_IBY_EXPORT_PATH(dvrrtputils.iby) + +PRJ_MMPFILES +DvrRtpUtils.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpPacket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpPacket.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to parse RTP packets.* +*/ + + + + +#ifndef CRTPPACKET_H +#define CRTPPACKET_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class for RTP header. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpPacket : public CBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return a pointer to the newly created RTP packet object. + */ + IMPORT_C static CRtpPacket* NewL(); + + /** + * Two-phased constructor. + * @return a pointer to the newly created RTP packet object. + */ + IMPORT_C static CRtpPacket* NewLC(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CRtpPacket(); + +public: // New functions + + /** + * Parse RTCP packet buffer to retrive RTCP fields. + * @since Series 60 3.0 + * @param aPktBuf a RTP packet. + * @return system wide error code. + */ + IMPORT_C TInt ParseRtp( const TDesC8& aPktBuf ); + + /** + * Sets syncronised time stamp of packet. + * @since Series 60 3.0 + * @param aTs a new timestamp value. + * @return none. + */ + IMPORT_C void SetTimeStamp( const TUint32 aTs ); + +private: // Constructors and destructor + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @since Series 60 3.0 + */ + CRtpPacket(); + +private: // New functions + + /** + * Read 32 bits from current offset. + * @since Series 60 3.0 + * @param aPktBuf a packet buffer. + * @param aByte a byte index. + * @return an readed unsigned integer. + */ + TUint Read32Bits( const TPtrC8& aPktBuf, + TInt& aByte ); + +public: // Data + + /** + * Header of the packet. + */ + TRtpRecvHeader iRtpRecvHeader; + + /** + * Payload off the packet. + */ + TPtrC8 iPayload; + + }; + +#endif // CRTPPACKET_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpTimer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: A timer.* +*/ + + + + +#ifndef CRTPTIMER_H +#define CRTPTIMER_H + +// INCLUDES +#include + +// CONSTANTS +_LIT( KPaniCRtpTimerError, "RTP Timer panic" ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class MRtpTimerObserver; + +// CLASS DECLARATION + +/** +* A timer for RTP handler. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpTimer : public CTimer + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aObs a notifier which informs when the time passed. + * @param aPrior a priority of the timer. + */ + IMPORT_C static CRtpTimer* NewL( + MRtpTimerObserver& aObs, + const TPriority& aPrior = EPriorityStandard ); + + /** + * Destructor. + */ + IMPORT_C virtual ~CRtpTimer(); + +private: // Constructors and destructor + + /** + * C++ parameter constructor. + * @param aObs The notifier which informs when the time passed + * @param aPrior a priority of the timer. + */ + CRtpTimer( MRtpTimerObserver& aObs, const TPriority& aPrior ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From CActive : Called when request completion event occurs. + * @since Series 60 3.0 + * @return none + */ + void RunL(); + + /** + * From CActive : Handles a leave occurring in the request + * completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code + * @return a status of function + */ + TInt RunError( TInt aError ); + +private: // Data + + // Observer + MRtpTimerObserver& iObs; + + }; + +#endif // CRTPTIMER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpTsConverter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/CRtpTsConverter.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to provide TS conversion for an RTP-stream based on* +*/ + + + + + +#ifndef CRTPTSCONVERTER_H +#define CRTPTSCONVERTER_H + +// INCLUDES +#include + +// CONSTANTS +const TUint KPipelineClockRate( 1000 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class for converting RTP-timestamps. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CRtpTsConverter : public CBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aClockRate the clockrate for the media stream. + */ + IMPORT_C static CRtpTsConverter* NewL( const TUint aClockRate ); + + /** + * Destructor. + */ + IMPORT_C virtual ~CRtpTsConverter(); + +public: // New functions + + /** + * Initialize timestamp converter + * @since Series 60 3.0 + * @param aRtcpPkt a RTCP packet for the media stream to be sychronized. + * @return none. + */ + IMPORT_C void Init( const TDesC8& aRtcpPkt ); + + /** + * Initialize timestamp converter + * @since Series 60 3.0 + * @param aTs intial value of RTP timestamp + * @return none. + */ + IMPORT_C void Init( const TUint& aTs ); + + /** + * Gets status on initialization. + * @since Series 60 3.0 + * @param none. + * @return true if converter initialized, otherwise false. + */ + IMPORT_C TBool Initiated(); + + /** + * Uninitializes the converter. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C void UnInitiate(); + + /** + * Gets time stamp from a RTP packet. + * @since Series 60 3.0 + * @param aTimestamp a RTP packet's TS to convert. + * @param aUseWallClock if true converts to wall clock time. + * @return a time stamp value. + */ + IMPORT_C TUint ConvertTs( const TUint aTimestamp, + const TBool aUseWallClock = EFalse ); + +private: // Constructors and destructor + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aClockRate the clockrate for the media stream. + */ + CRtpTsConverter( const TUint aClockRate ); + + +private: // New functions + + /** + * Calculate the offset for adjusting the RTP timestamps. + * @since Series 60 3.0 + * @param aRtpTime a RTP time stamp. + * @param aSeekTime a wall clock time. + * @param clockRate a wall clock time. + * @return a offset for RTP TS adjustment. + */ + TUint ComputeOffset( const TUint aRtpTime, + const TUint aSeekTime, + const TInt clockRate ); + +private: // Data + + /** + * Clockrate. + */ + const TUint iClockRate; + + /** + * Offset. + */ + TUint iOffset; + + /** + * Initiated. + */ + TBool iInitiated; + + }; + +#endif // CRTPTSCONVERTER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/MRtpTimerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/inc/MRtpTimerObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: A timer observer.* +*/ + + + + +#ifndef MRTPTIMEROBSERVER_H +#define MRTPTIMEROBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* A timer observer. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class MRtpTimerObserver + { + +public: // New functions + + /** + * Called when timer completion event occurs + * @since Series 60 3.0 + * @return none + */ + virtual void TimerEventL() = 0; + + /** + * Handles a leave occurring in the request + * completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code. + * @return None. + */ + virtual void TimerError( const TInt aError ) = 0; + + }; + +#endif // MRTPTIMEROBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/rom/dvrrtputils.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/rom/dvrrtputils.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __DVRRTPUTILS_IBY__ +#define __DVRRTPUTILS_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\DvrRtpUtils.dll SHARED_LIB_DIR\DvrRtpUtils.dll + +#endif // __DVRRTPUTILS_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpPacket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpPacket.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to RTP packet parsing.* +*/ + + + + +// INCLUDE FILES +#include "CRtpPacket.h" + +// CONSTANTS +const TInt KRtpPacketVersion( 2 ); +const TInt KRtpMinHeaderLength( 12 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpPacket::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpPacket* CRtpPacket::NewL() + { + CRtpPacket* self = CRtpPacket::NewLC(); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::NewLC +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpPacket* CRtpPacket::NewLC() + { + CRtpPacket* self = new( ELeave ) CRtpPacket(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::CRtpPacket +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpPacket::CRtpPacket() : iPayload( NULL, 0 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpPacket::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::CRtpPacket +// Destructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpPacket::~CRtpPacket() + { + if ( iRtpRecvHeader.iHeaderExtension ) + { + // Remove iData + delete[] ( iRtpRecvHeader.iHeaderExtension )->iData; + delete iRtpRecvHeader.iHeaderExtension; + } + + if ( iRtpRecvHeader.iCsrcList ) + { + delete[] iRtpRecvHeader.iCsrcList; + } + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::ParseRtcp +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CRtpPacket::ParseRtp( const TDesC8& aPktBuf ) + { + if ( aPktBuf.Length() < KRtpMinHeaderLength ) + { + SetTimeStamp( 0 ); + iPayload.Set( NULL, 0 ); + return KErrUnderflow; + } + + // 1st byte + TInt byte( 0 ); + TUint8 version_flag( ( aPktBuf[byte] & 0xc0 ) >> 6 ); + // v=2 is mandatory + if ( version_flag != KRtpPacketVersion ) + { + SetTimeStamp( 0 ); + iPayload.Set( NULL, 0 ); + return KErrNotSupported; + } + + iRtpRecvHeader.iPadding = ( aPktBuf[byte] >> 5 ) & 1; + iRtpRecvHeader.iExtension = ( aPktBuf[byte] >> 4 ) & 1; + iRtpRecvHeader.iCsrcCount = aPktBuf[byte++] & 0xf; + + // 2nd byte + iRtpRecvHeader.iMarker = ( aPktBuf[byte] >> 7 ) & 1; + iRtpRecvHeader.iPayloadType = aPktBuf[byte++] & 0x7f; + + // 3rd - 4th bytes + TUint16 seq_no( aPktBuf[byte++] << 8 ); + seq_no |= aPktBuf[byte++]; + iRtpRecvHeader.iSeqNum = seq_no; + + // 5th - 8th bytes + TUint32 timestamp( Read32Bits( aPktBuf, byte ) ); + iRtpRecvHeader.iTimestamp = timestamp; + + // 9th - 12th bytes + TInt32 ssrc( Read32Bits( aPktBuf, byte ) ); + + // 13th - bytes (optional) + // total len = 4 * csrc_len (bytes) + if ( iRtpRecvHeader.iCsrcCount > 0 ) + { + iRtpRecvHeader.iCsrcList = new TUint32[iRtpRecvHeader.iCsrcCount]; + //TInt32* csrc = new TInt32[csrc_len]; + for ( TInt i( 0 ); i < iRtpRecvHeader.iCsrcCount; i++ ) + { + iRtpRecvHeader.iCsrcList[i] = Read32Bits( aPktBuf, byte ); + } + } + + // optional extension field + if ( iRtpRecvHeader.iExtension == 1 ) + { + /* + iRtpRecvHeader.iHeaderExtension = new TRtpHeaderExtension(); + // 16 bits + TInt16 op_code( aPktBuf[byte++] << 8 ); + op_code |= aPktBuf[byte++]; + iRtpRecvHeader.iHeaderExtension->iType = op_code; + + // 16 bits + TInt16 op_code_data_length = aPktBuf[byte++] << 8; + op_code_data_length |= aPktBuf[byte++]; + iRtpRecvHeader.iHeaderExtension->iLength = op_code_data_length; + + op_code_data_length * 4 bytes of extension data + op_code_data = new TInt32[op_code_data_length]; + iRtpRecvHeader.iHeaderExtension->iData = new TInt32[op_code_data_length]; + for ( TInt i( 0 ); i < op_code_data_length; i++ ) + { + iRtpRecvHeader.iHeaderExtension)->iData[i] = Read32Bits( aPktBuf, byte ); + } + */ + } + + // The rest is payload data + iPayload.Set( aPktBuf.Mid( byte ) ); + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::SetTimeStamp +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpPacket::SetTimeStamp( const TUint32 aTs ) + { + iRtpRecvHeader.iTimestamp = aTs; + } + +// ----------------------------------------------------------------------------- +// CRtpPacket::Read32Bits +// +// ----------------------------------------------------------------------------- +// +TUint CRtpPacket::Read32Bits( const TPtrC8& aPktBuf, TInt& aByte ) + { + TUint ret( ( ( TUint )( aPktBuf[aByte++] ) ) << 24 ); + ret |= ( ( TUint )( aPktBuf[aByte++] ) ) << 16; + ret |= ( ( TUint )( aPktBuf[aByte++] ) ) << 8; + ret |= ( ( TUint )( aPktBuf[aByte++] ) ); + + return ret; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpTimer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: A timer.* +*/ + + + + +// INCLUDE FILES +#include "CRtpTimer.h" +#include "MRtpTimerObserver.h" + +// CONSTANTS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpTimer::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpTimer* CRtpTimer::NewL( + MRtpTimerObserver& aObs, + const TPriority& aPrior ) + { + CRtpTimer* self= new( ELeave ) CRtpTimer( aObs, aPrior ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpTimer::CRtpTimer +// C++ parameter constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpTimer::CRtpTimer( MRtpTimerObserver& aObs, const TPriority& aPrior ) + : CTimer( aPrior ), + iObs( aObs ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpTimer::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpTimer::~CRtpTimer() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CRtpTimer::RunL +// To inform the notifier that time is up. +// ----------------------------------------------------------------------------- +// +void CRtpTimer::RunL() + { + iObs.TimerEventL(); + } + +// ----------------------------------------------------------------------------- +// CRtpTimer::RunError +// Returns: System wide error code of indication send leave reason +// ----------------------------------------------------------------------------- +// +TInt CRtpTimer::RunError( TInt aError ) + { + iObs.TimerError( aError ); + return KErrNone; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpTsConverter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpTsConverter.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,222 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to provide TS conversion for an RTP-stream based on* +*/ + + + + +// INCLUDE FILES +#include "CRtpTsConverter.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KValidRtcpType( 200 ); +const TInt KTypeBytesPoint( 1 ); +const TInt KNtpSecBytesPoint( 8 ); +const TInt KNtpFracBytesPoint( 12 ); +const TInt KRtcpTsBytesPoint( 16 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpTsConverter* CRtpTsConverter::NewL( const TUint aClockRate ) + { + CRtpTsConverter* self = new( ELeave ) CRtpTsConverter( aClockRate ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::CRtpTsConverter +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpTsConverter::CRtpTsConverter( const TUint aClockRate ) + : iClockRate( aClockRate ), + iOffset( 0 ), + iInitiated( EFalse ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpTsConverter::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::CRtpTsConverter +// Destructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpTsConverter::~CRtpTsConverter() + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::Init +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpTsConverter::Init( const TDesC8& aRtcpPkt ) + { + // Verify packet type? + if ( aRtcpPkt.Length() > ( KRtcpTsBytesPoint + KIntegerBytes ) && + aRtcpPkt[KTypeBytesPoint] == KValidRtcpType && iClockRate > 0 ) + { + // Handle RTCP packet + TUint ntp_sec( 0 ); + TUint ntp_frac( 0 ); + TUint rtcp_ts( 0 ); + TInt err( CRtpUtil::GetValue( + aRtcpPkt.Mid( KNtpSecBytesPoint, KIntegerBytes ), ntp_sec ) ); + if ( !err ) + { + LOG1( "CRtpTsConverter::Init(), NTP Timestamp, MSW: %u", ntp_sec ); + err = CRtpUtil::GetValue( + aRtcpPkt.Mid( KNtpFracBytesPoint, KIntegerBytes ), ntp_frac ); + } + if ( !err ) + { + LOG1( "CRtpTsConverter::Init(), NTP Timestamp, LSW: %u", ntp_frac ); + err = CRtpUtil::GetValue( + aRtcpPkt.Mid( KRtcpTsBytesPoint, KIntegerBytes ), rtcp_ts ); + } + + if ( !err ) + { + LOG1( "CRtpTsConverter::Init(), RTP Timestamp: %u", rtcp_ts ); + // Calculate the wallclock time when this RTCP packet is generated + TUint wallClock( ( ntp_sec & 0x00FF ) * 1000 ); + wallClock += ( ( ( ntp_frac >> 16 ) & 0x0000FFFF ) * 1000 ) >> 16; + + // Compute the proper time offset + iOffset = ComputeOffset( rtcp_ts, wallClock, iClockRate ); + } + } + } +// ----------------------------------------------------------------------------- +// CRtpTsConverter::Init +// Compute the proper time offset. No wallclok time available. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpTsConverter::Init( const TUint& aTs ) + { + iOffset = ComputeOffset( aTs, 0, iClockRate ); + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::Initiated +// Returns: initiated status of converter. +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CRtpTsConverter::Initiated() + { + return iInitiated; + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::UnInitiate +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpTsConverter::UnInitiate() + { + iInitiated = EFalse; + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::ConvertTs +// Returns: converted unsigned integer value of timestamp. +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint CRtpTsConverter::ConvertTs( + const TUint aTimestamp, + TBool aUseWallClock ) + { + TUint ret( KMaxTUint ); + + if ( iClockRate == KPipelineClockRate ) + { + ret = aTimestamp - iOffset; + } + else + { + if ( iClockRate > 0 ) + { + ret = aTimestamp - iOffset; + + if ( aUseWallClock ) + { + TUint sec( ret / iClockRate ); + TUint subSec( ret % iClockRate ); + ret = ( ( sec * KPipelineClockRate ) + + ( subSec * KPipelineClockRate ) / iClockRate ); + } + } + } + + return ret; + } + +// ----------------------------------------------------------------------------- +// CRtpTsConverter::ComputeOffset +// Returns: offset of the RTP timestamp. +// ----------------------------------------------------------------------------- +// +TUint CRtpTsConverter::ComputeOffset( + TUint aRtpTime, + TUint aSeekTime, + TInt aClockRate ) + { + TUint ret( KMaxTUint ); + + if ( aClockRate ) + { + TUint rtpSec( aRtpTime / aClockRate ); + TUint rtpFracSecTU( aRtpTime % aClockRate ); // transport units + TUint seekSec( aSeekTime / 1000 ); + TUint seekFracSecTU( ( ( aSeekTime % 1000) * aClockRate ) / 1000 ); + + TUint offsetSec( rtpSec - seekSec ); + TUint offsetFracSecTU( rtpFracSecTU - seekFracSecTU ); + + if ( rtpFracSecTU < seekFracSecTU ) + { + offsetSec--; + offsetFracSecTU = aClockRate + rtpFracSecTU - seekFracSecTU; + } + + ret = ( offsetSec * aClockRate ) + offsetFracSecTU; + iInitiated = ETrue; + } + + return ret; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrRtpUtils/src/CRtpUtil.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,303 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP convertions.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpUtil::NewL() +// +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpUtil* CRtpUtil::NewL() + { + CRtpUtil* self = CRtpUtil::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::NewLC() +// +// ----------------------------------------------------------------------------- +// +EXPORT_C CRtpUtil* CRtpUtil::NewLC() + { + CRtpUtil* self = new ( ELeave ) CRtpUtil; + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::CRtpUtil +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CRtpUtil::CRtpUtil() + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CRtpUtil::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// Destructor +// +EXPORT_C CRtpUtil::~CRtpUtil() +// ----------------------------------------------------------------------------- + { + // None + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::MakeBytesLC +// Returns: Buffer of four bytes where integer is stored +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CRtpUtil::MakeBytesLC( const TInt& aValue ) + { + HBufC8* bytes = HBufC8::NewLC( KIntegerBytes ); + TPtr8 ptr( bytes->Des() ); + MakeBytesL( aValue, ptr ); + return bytes; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::MakeBytes +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpUtil::MakeBytesL( const TInt& aValue, TDes8& aBuf ) + { + User::LeaveIfError( MakeBytes( aValue, aBuf ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::MakeBytes +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CRtpUtil::MakeBytes( const TInt& aValue, TDes8& aBuf ) + { + if ( aBuf.MaxLength() >= KIntegerBytes ) + { + aBuf.SetLength( KIntegerBytes ); + aBuf[0] = ( TUint8 )( aValue >> 24 ); + aBuf[1] = ( TUint8 )( aValue >> 16 ); + aBuf[2] = ( TUint8 )( aValue >> 8 ); + aBuf[3] = ( TUint8 )( aValue ); + return KErrNone; + } + + return KErrUnderflow; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CRtpUtil::GetValueL( const TDesC8& aBytes ) + { + TInt value( KErrNotFound ); + GetValueL( aBytes, value ); + return value; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpUtil::GetValueL( const TDesC8& aBytes, TInt& aValue ) + { + User::LeaveIfError( GetValue( aBytes, aValue ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetValue +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CRtpUtil::GetValue( const TDesC8& aBytes, TInt& aValue ) + { + TUint value( 0 ); + TInt err( GetValue( aBytes, value ) ); + aValue = ( TInt )( value ); + return err; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetValue +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CRtpUtil::GetValue( const TDesC8& aBytes, TUint& aValue ) + { + if ( aBytes.Length() >= KIntegerBytes ) + { + aValue = ( TUint )( aBytes[0] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[1] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[2] ); + aValue <<= 8; + aValue |= ( TUint )( aBytes[3] ); + return KErrNone; + } + + return KErrUnderflow; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::SpecialPacketL +// Generates new special packet. +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CRtpUtil::SpecialPacketL( const TInt aType ) + { + // Create buffer + HBufC8* packet = HBufC8::NewLC( KSpecialPacketLength ); + TPtr8 ptr( packet->Des() ); + + // Packet length (PTL) + HBufC8* bytes = MakeBytesLC( KSpecialPacketLength ); + ptr.Copy( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Packet type + ptr.Append( KCharSpace ); + ptr[KPacketTypeBytePoint] = ( TUint8 )( aType ); + + // Dummy payload + bytes = MakeBytesLC( KMaxTUint ); + ptr.Append( bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + CleanupStack::Pop( packet ); + return packet; + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetMimeInfo +// Mime type info of propriatary RTP clip. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpUtil::GetMimeInfo( TDes& aMime ) + { + // Meta header has constant room as user info (IMSI) in old clips + aMime.Copy( KRtpClipMimetype().Right( KUserIdLength ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetMimeInfo +// Mime type info of propriatary RTP clip. +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpUtil::GetMimeInfo( TDes8& aMime ) + { + // Meta header has constant room as user info (IMSI) in old clips + aMime.Copy( KRtpClipMimetype().Right( KUserIdLength ) ); + } + +// ----------------------------------------------------------------------------- +// CRtpUtil::GetImeiL +// Read IMEI on phone HW, use dummy under WINS +// ----------------------------------------------------------------------------- +// +EXPORT_C void CRtpUtil::GetImeiL( TDes& aImei ) + { + aImei.Zero(); + +#if defined( __WINS__ ) || defined( __WINSCW__ ) + _LIT( KEmulatorImei, "147407051877780445" ); + aImei.Copy( KEmulatorImei); +#else // __WINS__ || __WINSCW__ + + RTelServer server; + CleanupClosePushL( server ); + RMobilePhone phone; + CleanupClosePushL( phone ); + GetMobilePhoneInfoL( server, phone ); + + // Get IMEI code + TRequestStatus status; + RMobilePhone::TMobilePhoneIdentityV1 phoneIdentity; + phone.GetPhoneId( status, phoneIdentity ); + User::WaitForRequest( status ); + if ( !status.Int() ) + { + TPtrC imei( phoneIdentity.iSerialNumber ); + for ( TInt i( 0 ); i < imei.Length() && i < aImei.MaxLength(); i++ ) + { + if ( TChar( imei[i] ).IsDigit() ) + { + aImei.Append( TChar( imei[i] ) ); + } + } + } + + CleanupStack::PopAndDestroy( &phone ); + CleanupStack::PopAndDestroy( &server ); + +#endif // __WINS__ || __WINSCW__ + } + +//----------------------------------------------------------------------------- +// CRtpUtil::GetMobilePhoneInfo +//----------------------------------------------------------------------------- +// +void CRtpUtil::GetMobilePhoneInfoL( + RTelServer& aServer, + RMobilePhone& aPhone ) + { + TInt numPhone( 0 ); + RTelServer::TPhoneInfo phoneInfo; + User::LeaveIfError( aServer.Connect() ); + User::LeaveIfError( aServer.LoadPhoneModule( KMmTsyModuleName ) ); + User::LeaveIfError( aServer.EnumeratePhones( numPhone ) ); + + TInt found( KErrNotFound ); + TName tsyName( KNullDesC ); + for ( TInt i( 0 ); i < numPhone && found == KErrNotFound; i++ ) + { + User::LeaveIfError( aServer.GetPhoneInfo( i, phoneInfo ) ); + User::LeaveIfError( aServer.GetTsyName( i, tsyName ) ); + if ( tsyName.CompareF( KMmTsyModuleName ) == 0 ) + { + found = KErrNone; + } + } + + User::LeaveIfError( found ); + User::LeaveIfError( aPhone.Open( aServer, phoneInfo.iName ) ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/EABI/DvrSdpParserU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/EABI/DvrSdpParserU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,36 @@ +EXPORTS + _ZN13CDvrSdpParser11AudioIpAddrEv @ 1 NONAME + _ZN13CDvrSdpParser11DataStreamsEv @ 2 NONAME + _ZN13CDvrSdpParser11VideoIpAddrEv @ 3 NONAME + _ZN13CDvrSdpParser12AudioBitrateEv @ 4 NONAME + _ZN13CDvrSdpParser12IsLiveStreamEv @ 5 NONAME + _ZN13CDvrSdpParser12VideoBitrateEv @ 6 NONAME + _ZN13CDvrSdpParser13AudioStreamIdEv @ 7 NONAME + _ZN13CDvrSdpParser13VideoStreamIdEv @ 8 NONAME + _ZN13CDvrSdpParser14IsMultiCastSdpEv @ 9 NONAME + _ZN13CDvrSdpParser15AudioAttributesEv @ 10 NONAME + _ZN13CDvrSdpParser15VideoAttributesEv @ 11 NONAME + _ZN13CDvrSdpParser16AudioControlAddrEv @ 12 NONAME + _ZN13CDvrSdpParser16SupportedContentEv @ 13 NONAME + _ZN13CDvrSdpParser16VideoControlAddrEv @ 14 NONAME + _ZN13CDvrSdpParser17SessionAttributesEv @ 15 NONAME + _ZN13CDvrSdpParser18IsRealMediaContentEv @ 16 NONAME + _ZN13CDvrSdpParser20MediaIdentifierAudioEv @ 17 NONAME + _ZN13CDvrSdpParser20MediaIdentifierVideoEv @ 18 NONAME + _ZN13CDvrSdpParser21AudioTimerGranularityEv @ 19 NONAME + _ZN13CDvrSdpParser21VideoTimerGranularityEv @ 20 NONAME + _ZN13CDvrSdpParser4NewLEv @ 21 NONAME + _ZN13CDvrSdpParser5NewLCEv @ 22 NONAME + _ZN13CDvrSdpParser6GetSdpER6TPtrC8 @ 23 NONAME + _ZN13CDvrSdpParser8NewLineLEiRK6TDesC8 @ 24 NONAME + _ZN13CDvrSdpParser9AudioPortEv @ 25 NONAME + _ZN13CDvrSdpParser9IsIpv4SdpEv @ 26 NONAME + _ZN13CDvrSdpParser9TryParseLERK6TDesC8 @ 27 NONAME + _ZN13CDvrSdpParser9TryParseLERK6TDesC8S2_ @ 28 NONAME + _ZN13CDvrSdpParser9VideoPortEv @ 29 NONAME + _ZN13CDvrSdpParserD0Ev @ 30 NONAME + _ZN13CDvrSdpParserD1Ev @ 31 NONAME + _ZN13CDvrSdpParserD2Ev @ 32 NONAME + _ZTI13CDvrSdpParser @ 33 NONAME ; ## + _ZTV13CDvrSdpParser @ 34 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/bwins/DvrSdpParseru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/bwins/DvrSdpParseru.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,32 @@ +EXPORTS + ??1CDvrSdpParser@@UAE@XZ @ 1 NONAME ; CDvrSdpParser::~CDvrSdpParser(void) + ?AudioAttributes@CDvrSdpParser@@QAEAAV?$RArray@VTPtrC8@@@@XZ @ 2 NONAME ; class RArray & CDvrSdpParser::AudioAttributes(void) + ?AudioBitrate@CDvrSdpParser@@QAEHXZ @ 3 NONAME ; int CDvrSdpParser::AudioBitrate(void) + ?AudioControlAddr@CDvrSdpParser@@QAE?AVTPtrC8@@XZ @ 4 NONAME ; class TPtrC8 CDvrSdpParser::AudioControlAddr(void) + ?AudioIpAddr@CDvrSdpParser@@QAE?AVTPtrC8@@XZ @ 5 NONAME ; class TPtrC8 CDvrSdpParser::AudioIpAddr(void) + ?AudioPort@CDvrSdpParser@@QAEHXZ @ 6 NONAME ; int CDvrSdpParser::AudioPort(void) + ?AudioStreamId@CDvrSdpParser@@QAEHXZ @ 7 NONAME ; int CDvrSdpParser::AudioStreamId(void) + ?AudioTimerGranularity@CDvrSdpParser@@QAEKXZ @ 8 NONAME ; unsigned long CDvrSdpParser::AudioTimerGranularity(void) + ?DataStreams@CDvrSdpParser@@QAEAAV?$RArray@VTPtrC8@@@@XZ @ 9 NONAME ; class RArray & CDvrSdpParser::DataStreams(void) + ?GetSdp@CDvrSdpParser@@QAEHAAVTPtrC8@@@Z @ 10 NONAME ; int CDvrSdpParser::GetSdp(class TPtrC8 &) + ?IsIpv4Sdp@CDvrSdpParser@@QAEHXZ @ 11 NONAME ; int CDvrSdpParser::IsIpv4Sdp(void) + ?IsLiveStream@CDvrSdpParser@@QAEHXZ @ 12 NONAME ; int CDvrSdpParser::IsLiveStream(void) + ?IsMultiCastSdp@CDvrSdpParser@@QAEHXZ @ 13 NONAME ; int CDvrSdpParser::IsMultiCastSdp(void) + ?IsRealMediaContent@CDvrSdpParser@@QAEHXZ @ 14 NONAME ; int CDvrSdpParser::IsRealMediaContent(void) + ?MediaIdentifierAudio@CDvrSdpParser@@QAEHXZ @ 15 NONAME ; int CDvrSdpParser::MediaIdentifierAudio(void) + ?MediaIdentifierVideo@CDvrSdpParser@@QAEHXZ @ 16 NONAME ; int CDvrSdpParser::MediaIdentifierVideo(void) + ?NewL@CDvrSdpParser@@SAPAV1@XZ @ 17 NONAME ; class CDvrSdpParser * CDvrSdpParser::NewL(void) + ?NewLC@CDvrSdpParser@@SAPAV1@XZ @ 18 NONAME ; class CDvrSdpParser * CDvrSdpParser::NewLC(void) + ?NewLineL@CDvrSdpParser@@QAEXHABVTDesC8@@@Z @ 19 NONAME ; void CDvrSdpParser::NewLineL(int, class TDesC8 const &) + ?SessionAttributes@CDvrSdpParser@@QAEAAV?$RArray@VTPtrC8@@@@XZ @ 20 NONAME ; class RArray & CDvrSdpParser::SessionAttributes(void) + ?SupportedContent@CDvrSdpParser@@QAE?AW4TDvrPacketProvidings@1@XZ @ 21 NONAME ; enum CDvrSdpParser::TDvrPacketProvidings CDvrSdpParser::SupportedContent(void) + ?TryParseL@CDvrSdpParser@@QAEXABVTDesC8@@0@Z @ 22 NONAME ; void CDvrSdpParser::TryParseL(class TDesC8 const &, class TDesC8 const &) + ?TryParseL@CDvrSdpParser@@QAEXABVTDesC8@@@Z @ 23 NONAME ; void CDvrSdpParser::TryParseL(class TDesC8 const &) + ?VideoAttributes@CDvrSdpParser@@QAEAAV?$RArray@VTPtrC8@@@@XZ @ 24 NONAME ; class RArray & CDvrSdpParser::VideoAttributes(void) + ?VideoBitrate@CDvrSdpParser@@QAEHXZ @ 25 NONAME ; int CDvrSdpParser::VideoBitrate(void) + ?VideoControlAddr@CDvrSdpParser@@QAE?AVTPtrC8@@XZ @ 26 NONAME ; class TPtrC8 CDvrSdpParser::VideoControlAddr(void) + ?VideoIpAddr@CDvrSdpParser@@QAE?AVTPtrC8@@XZ @ 27 NONAME ; class TPtrC8 CDvrSdpParser::VideoIpAddr(void) + ?VideoPort@CDvrSdpParser@@QAEHXZ @ 28 NONAME ; int CDvrSdpParser::VideoPort(void) + ?VideoStreamId@CDvrSdpParser@@QAEHXZ @ 29 NONAME ; int CDvrSdpParser::VideoStreamId(void) + ?VideoTimerGranularity@CDvrSdpParser@@QAEKXZ @ 30 NONAME ; unsigned long CDvrSdpParser::VideoTimerGranularity(void) + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/group/DvrSdpparser.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/group/DvrSdpparser.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification for DvrSdpParser.dll.* +*/ + + + +#include + +TARGET DvrSdpParser.dll +TARGETTYPE dll +UID 0x1000008d 0x1020844D + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE CDvrSdpParser.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../../../conf + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib // Common +LIBRARY efsrv.lib // File server +LIBRARY insock.lib // Inet address +LIBRARY flogger.lib // Debug logger + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Component description file for DvrSdpParser.dll.* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/dvrsdpparser.iby CORE_MW_LAYER_IBY_EXPORT_PATH(dvrsdpparser.iby) + +PRJ_MMPFILES +DvrSdpParser.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/rom/dvrsdpparser.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/rom/dvrsdpparser.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __DVRSDPPARSER_IBY__ +#define __DVRSDPPARSER_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\DvrSdpParser.dll SHARED_LIB_DIR\DvrSdpParser.dll + +#endif // __DVRSDPPARSER_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/DvrSdpParser/src/CDvrSdpParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/DvrSdpParser/src/CDvrSdpParser.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1063 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Parses SDP file.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +_LIT8( KKeyIpv4Addr, "c=IN IP4 " ); +_LIT8( KKeyIpv6Addr, "c=IN IP6 " ); +_LIT8( KKeyAttribute, "a=" ); +_LIT8( KKeyMedia, "m=" ); +_LIT8( KKeyMediaAudio, "m=audio " ); +_LIT8( KKeyMediaVideo, "m=video " ); +_LIT8( KKeyMediaTitle, "m=title " ); +_LIT8( KKeyDataStream, "m=data " ); +_LIT8( KKeyClockRate, "a=rtpmap:" ); +_LIT8( KKeyControl, "a=control:" ); +//_LIT8( KKeyStreamId, "a=control:streamid=" ); +_LIT8( KRealMediaIndicator, "/x-pn-real" ); +_LIT8( KKeyBandWidth, "b=AS:" ); +_LIT8( KCRSDPRtspUriBegin, "rtsp://" ); +_LIT8( KSPStr, " "); +_LIT8( KCRStr, "\r"); +_LIT8( KLFStr, "\n"); +_LIT8( KCRLFStr, "\r\n"); +_LIT8( KSLStr, "/" ); +_LIT8( KSdpLiveStream, "a=LiveStream:integer;1"); +_LIT8( KSdpRangeHeaderLiveStream, "a=range:npt=now-" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CDvrSdpParser* CDvrSdpParser::NewL() + { + CDvrSdpParser* self = CDvrSdpParser::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::NewLC +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CDvrSdpParser* CDvrSdpParser::NewLC() + { + CDvrSdpParser* self = new( ELeave ) CDvrSdpParser(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::CDvrSdpParser +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CDvrSdpParser::CDvrSdpParser() + : iAudioPort( KErrNotFound ), + iVideoPort( KErrNotFound ), + iTitlePort( KErrNotFound ), + iAudioBitrate( KErrNotFound ), + iVideoBitrate( KErrNotFound ), + iAudioStreamId( KErrNotFound ), + iVideoStreamId( KErrNotFound ), + iVideoTimerGranularity( KMaxTUint32 ), + iAudioTimerGranularity( KMaxTUint32 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::ConstructL() + { + LOG( "CDvrSdpParser::ConstructL()" ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::~CDvrSdpParser +// Destructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CDvrSdpParser::~CDvrSdpParser() + { + LOG( "CDvrSdpParser::~CDvrSdpParser()" ); + delete iBaseUrl; iBaseUrl = NULL; + DeleteVariables(); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::TryParseL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CDvrSdpParser::TryParseL( const TDesC8& aSdp, const TDesC8& aBaseUrl ) + { +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + HBufC* baseLog = HBufC::NewLC( aBaseUrl.Length() ); + TPtr ptr = baseLog->Des(); + ptr.Copy( aBaseUrl ); + LOG2( "CDvrSdpParser::TryParseL(), aSdp length: %d, aBaseUrl: %S", + aSdp.Length(), &ptr ); + CleanupStack::PopAndDestroy( baseLog ); +#endif + + if ( aBaseUrl.Length() ) + { + delete iBaseUrl; iBaseUrl = NULL; + iBaseUrl = aBaseUrl.AllocL(); + } + + TryParseL( aSdp ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::TryParseL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CDvrSdpParser::TryParseL( const TDesC8& aSdp ) + { + LOG1( "CDvrSdpParser::TryParseL(), aSdp length: %d", aSdp.Length() ); + + // Find medias + FindMediasL( aSdp ); + + // Append found medias to the array + for ( TInt i( 0 ); i < iMediaBuf.Count(); i++ ) + { + TInt port( KErrNotFound ); + TPtrC8 ptr( iMediaBuf[i] ); + + // Audio media info found ? + port = GetIntL( ptr, KKeyMediaAudio ); + if ( port != KErrNotFound ) + { + iAudioPort = port; + LOG1( "CDvrSdpParser::TryParseL(), iAudioPort: %d", iAudioPort ); + UpdateMediaInfoL( ptr, iAudioIpAddr ); + // Stream id (Helix takes medias in appearance order) + iAudioStreamId = i; + // Audio clock rate + iAudioTimerGranularity = GetClockRateL( ptr ); + iAudioBitrate = GetIntL( ptr, KKeyBandWidth ); + // Audio attributes + FindAttributesL( ptr, iAudioAttributes ); + // Audio control + GetControlL( ptr, iAudioControlAddr ); + // Find media id 97 from a=rtpmap:97 MP4A-LATM/32000/2 + iMediaIdentifierAudio = GetIntL( ptr, KKeyClockRate ); + } + else + { + // Video media info found ? + port = GetIntL( ptr, KKeyMediaVideo ); + if ( port != KErrNotFound ) + { + iVideoPort = port; + LOG1( "CDvrSdpParser::TryParseL(), iVideoPort: %d", iVideoPort ); + UpdateMediaInfoL( ptr, iVideoIpAddr ); + // Stream id (Helix takes medias in appearance order) + iVideoStreamId = i; + // Video clock rate + iVideoTimerGranularity = GetClockRateL( ptr ); + iVideoBitrate = GetIntL( ptr, KKeyBandWidth ); + // Video attributes + FindAttributesL( ptr, iVideoAttributes ); + // Video control + GetControlL( ptr, iVideoControlAddr ); + // Find media id 96 from a=rtpmap:96 H264/90000 line + iMediaIdentifierVideo = GetIntL( ptr, KKeyClockRate ); + } + else + { + port = GetIntL( ptr, KKeyMediaTitle ); + if ( port != KErrNotFound ) + { + iTitlePort = port; + LOG1( "CDvrSdpParser::TryParseL(), iTitlePort: %d", iTitlePort ); + } + } + } + } + + iMediaBuf.Reset(); + delete iBaseUrl; iBaseUrl = NULL; + delete iCommonIp; iCommonIp = NULL; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::NewLineL +// +// ----------------------------------------------------------------------------- +// +EXPORT_C void CDvrSdpParser::NewLineL( + const TInt aStreamId, + const TDesC8& aLine ) + { + User::LeaveIfNull( iSdp ); + const TInt newLen( iSdp->Length() + aLine.Length() + KCRLFStr().Length() ); + LOG2( "CDvrSdpParser::NewLineL(), aStreamId: %d, New sdp length: %d", + aStreamId, newLen ); + switch( aStreamId ) + { + case KErrNotFound: // Common + { + // Alloc more room + iSdp = iSdp->ReAllocL( newLen ); + TPtr8 ptr( iSdp->Des() ); + + // Find first attribute for new line point + const TInt insertPoint( ptr.Find( KKeyAttribute ) ); + User::LeaveIfError( insertPoint ); + ptr.Insert( insertPoint, KCRLFStr ); + ptr.Insert( insertPoint, aLine ); + } + break; + + case 0: // Audio (usually) + case 1: // Video (usually) + { + iSdp = iSdp->ReAllocL( newLen ); + InserNewLineL( aStreamId, aLine ); + } + break; + + default: + User::Leave( KErrCompletion ); + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetSdp +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::GetSdp( TPtrC8& aSdp ) + { + if ( iSdp ) + { + aSdp.Set( iSdp->Des() ); + return KErrNone; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::SupportedContent +// ----------------------------------------------------------------------------- +// +EXPORT_C CDvrSdpParser::TDvrPacketProvidings CDvrSdpParser::SupportedContent( void ) + { + TDvrPacketProvidings retval( EDvrNoProgramAtAll ); + + if ( iAudioPort > KErrNotFound && iVideoPort > KErrNotFound ) + { + retval = EDvrBothAudioAndVideo; + } + else if ( iAudioPort > KErrNotFound && iVideoPort <= KErrNotFound ) + { + retval = EDvrAudioOnly; + } + else if ( iVideoPort > KErrNotFound && iAudioPort <= KErrNotFound ) + { + retval = EDvrVideoOnly; + } + else + { + LOG( "CDvrSdpParser::SupportedContent(), No media !" ); + } + + return retval; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::SessionAttributes +// +// ----------------------------------------------------------------------------- +// +EXPORT_C RArray& CDvrSdpParser::SessionAttributes( void ) + { + return iSessionAttributes; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioAttributes +// +// ----------------------------------------------------------------------------- +// +EXPORT_C RArray& CDvrSdpParser::AudioAttributes( void ) + { + return iAudioAttributes; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoAttributes +// +// ----------------------------------------------------------------------------- +// +EXPORT_C RArray& CDvrSdpParser::VideoAttributes( void ) + { + return iVideoAttributes; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::DataStreams +// +// ----------------------------------------------------------------------------- +// +EXPORT_C RArray& CDvrSdpParser::DataStreams( void ) + { + return iDataStreams; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::IsIpv4Sdp +// Checks if Ipv4 address in use. +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CDvrSdpParser::IsIpv4Sdp( void ) + { + return iIsIpv4; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::IsMultiCastSdp +// Checks if c= line did specify a multicast addr +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CDvrSdpParser::IsMultiCastSdp( void ) + { + return iIsMulticast; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioControlAddr +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC8 CDvrSdpParser::AudioControlAddr( void ) + { + return ( iAudioControlAddr )? TPtrC8( *iAudioControlAddr ): + TPtrC8( KNullDesC8 ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoControlAddr +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC8 CDvrSdpParser::VideoControlAddr( void ) + { + return ( iVideoControlAddr )? TPtrC8( *iVideoControlAddr ): + TPtrC8( KNullDesC8 ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioIpAddr +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC8 CDvrSdpParser::AudioIpAddr( void ) + { + return ( iAudioIpAddr )? TPtrC8( *iAudioIpAddr ): TPtrC8( KNullDesC8 ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoIpAddr +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC8 CDvrSdpParser::VideoIpAddr( void ) + { + return ( iVideoIpAddr )? TPtrC8( *iVideoIpAddr ): TPtrC8( KNullDesC8 ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioPort +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::AudioPort( void ) + { + return iAudioPort; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoPort +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::VideoPort( void ) + { + return iVideoPort; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioBitrate +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::AudioBitrate( void ) + { + return iAudioBitrate; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoBitrate +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::VideoBitrate( void ) + { + return iVideoBitrate; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioStreamId +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::AudioStreamId( void ) + { + return iAudioStreamId; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoStreamId +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::VideoStreamId( void ) + { + return iVideoStreamId; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::VideoTimerGranularity +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint32 CDvrSdpParser::VideoTimerGranularity( void ) + { + return iVideoTimerGranularity; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::AudioTimerGranularity +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint32 CDvrSdpParser::AudioTimerGranularity( void ) + { + return iAudioTimerGranularity; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::IsRealMediaContent +// Check for realmedia content. +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CDvrSdpParser::IsRealMediaContent( void ) + { + if ( iSdp && iSdp->Des().Find( KRealMediaIndicator ) != KErrNotFound ) + { + LOG( "CDvrSdpParser::IsRealMediaContent(), Yes" ); + return ETrue; + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::MediaIdentifierAudio +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::MediaIdentifierAudio( void ) + { + return iMediaIdentifierAudio ; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::MediaIdentifierVideo +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CDvrSdpParser::MediaIdentifierVideo( void ) + { + return iMediaIdentifierVideo ; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::IsLiveStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CDvrSdpParser::IsLiveStream( void ) + { + TBool isLiveStream = EFalse; + if ( iSdp && + ( iSdp->Des().Find( KSdpLiveStream ) != KErrNotFound || + iSdp->Des().Find( KSdpRangeHeaderLiveStream ) != KErrNotFound ) ) + { + LOG( "CDvrSdpParser::IsLiveStream(), Yes" ); + isLiveStream = ETrue; + } + + return isLiveStream; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindMediasL +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::FindMediasL( const TDesC8& aSdp ) + { + LOG1( "CDvrSdpParser::FindMediasL(), aSdp length: %d", aSdp.Length() ); + + // Find medias from SDP + DeleteVariables(); + iSdp = aSdp.AllocL(); + RArray points; + CleanupClosePushL( points ); + FindMediaPointsL( points ); + MakeMediaBuffersL( points ); + FindSessionAttributesL( points ); + CleanupStack::PopAndDestroy( &points ); + FindDataStreamsL( iSdp->Des(), iDataStreams ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindMediaPointsL +// Find points of all medias. +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::FindMediaPointsL( RArray& aPoints ) + { + TInt lastPoint( 0 ); + User::LeaveIfNull( iSdp ); + TPtrC8 ptr( iSdp->Des() ); + TInt start( MediaSectionStart( ptr ) ); + + // Loop all media sections + while ( start > KErrNotFound && lastPoint < iSdp->Length() ) + { + // Find whole media section, up to next media or EOF + start += lastPoint; + TInt len( MediaSectionStart( ptr.Mid( start + KKeyMedia().Length() ) ) ); + len = ( len > KErrNotFound )? len + KKeyMedia().Length() - 1: + ptr.Length() - start - 1; + // New media point + SMediaPoint point; + point.iStart = start; + point.iLength = len; + lastPoint = ( start + len ); + User::LeaveIfError( aPoints.Append( point ) ); + LOG3( "CDvrSdpParser::FindMediaPointsL(), start: %d, len: %d, lastPoint: %d", + start, len, lastPoint ); + // Next section + start = MediaSectionStart( ptr.Mid( lastPoint ) ); + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::MediaSectionStart +// +// ----------------------------------------------------------------------------- +// +TInt CDvrSdpParser::MediaSectionStart( const TDesC8& aPtr ) + { + TInt start( aPtr.Find( KKeyMedia ) ); + while ( start > KErrNotFound ) + { + // Verify that not data stream keyword? ( i.e not 'm=data' ) + const TInt keywordlen( KKeyDataStream().Length() ); + TPtrC8 ptr( aPtr.Mid( start, keywordlen ) ); + if ( ptr.Find( KKeyDataStream ) == KErrNotFound ) + { + // Audio, video or subtitle + return start; + } + + start += keywordlen; + const TInt next( aPtr.Mid( start ).Find( KKeyMedia ) ); + start = ( next > KErrNotFound )? start + next: KErrNotFound; + } + + return start; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::MakeMediaBuffersL +// Make media buffers +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::MakeMediaBuffersL( RArray& aPoints ) + { + User::LeaveIfNull( iSdp ); + for ( TInt i( 0 ); i < aPoints.Count(); i++ ) + { + TPtrC8 media( iSdp->Des().Mid( aPoints[i].iStart, aPoints[i].iLength ) ); + User::LeaveIfError( iMediaBuf.Append( media ) ); + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindSessionAttributesL +// Find session attributes (common section before any media) +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::FindSessionAttributesL( RArray& aPoints ) + { + User::LeaveIfNull( iSdp ); + if ( aPoints.Count() ) + { + TPtrC8 common( iSdp->Des().Left( aPoints[0].iStart ) ); + FindAttributesL( common, iSessionAttributes ); + + // IP in common section + delete iCommonIp; iCommonIp = NULL; + iCommonIp = GetIpAddrL( common ); + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::InserNewLineL +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::InserNewLineL( + TInt aStreamId, + const TDesC8& aLine ) + { + RArray points; + CleanupClosePushL( points ); + FindMediaPointsL( points ); + + // Add new line to first after media description + if ( aStreamId >= 0 && aStreamId < points.Count() ) + { + User::LeaveIfNull( iSdp ); + TPtr8 ptr( iSdp->Des() ); + TInt insertPoint( GetLen( ptr.Mid( points[aStreamId].iStart, + points[aStreamId].iLength ), ETrue ) ); + User::LeaveIfError( insertPoint ); + ptr.Insert( insertPoint, aLine ); + ptr.Insert( insertPoint, KCRLFStr ); + } + else + { + User::Leave( KErrCompletion ); + } + + CleanupStack::PopAndDestroy( &points ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::UpdateMediaInfoL +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::UpdateMediaInfoL( + const TDesC8& aMediaPtr, + HBufC8*& aAddress ) + { + // Search for IP address (Ipv6/Ipv4) + aAddress = GetIpAddrL( aMediaPtr ); + if ( !aAddress && iCommonIp ) + { + aAddress = iCommonIp->AllocL(); + } + User::LeaveIfNull( aAddress ); + TPtr8 ptr( aAddress->Des() ); + + // IP Address + if ( iIsIpv4 ) + { + LOG( "CDvrSdpParser::UpdateMediaInfoL(), Removing v4 subnet mask" ); + // Remove possible subnet mask (e.g. c=IN IP4 225.0.1.15/64) + const TInt maskPos( aAddress->Find( KSLStr ) ); + if ( maskPos != KErrNotFound ) + { + ptr.SetLength( maskPos ); + } + } + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + TName buf; buf.Copy( ptr ); + LOG1( "CDvrSdpParser::UpdateMediaInfoL(), aAddress: %S", &buf ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + /* Stream Id + const TInt streamId( GetIntL( aMediaPtr, KKeyStreamId ) ); + LOG1( "CDvrSdpParser::UpdateMediaInfoL(), Stream Id: %d", streamId ); + return streamId; + */ + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetIpAddrL +// +// ----------------------------------------------------------------------------- +// +HBufC8* CDvrSdpParser::GetIpAddrL( const TDesC8& aPtr ) + { + iIsIpv4 = EFalse; + HBufC8* ipAddr = GetStringL( aPtr, KKeyIpv6Addr ); + if ( !ipAddr ) + { + ipAddr = GetStringL( aPtr, KKeyIpv4Addr ); + if ( ipAddr ) + { + iIsIpv4 = ETrue; + } + } + + // Verify multicast + if ( ipAddr ) + { + TPtrC8 addr( ipAddr->Des() ); + if ( addr.Length() <= KMaxName ) + { + CheckForMulticast( addr ); + } + else + { + LOG1( "Ipaddress length too long: %d, leaving....", addr.Length() ); + delete ipAddr; ipAddr = NULL; + User::Leave( KErrOverflow ); + } + } + + return ipAddr; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetClockRateL +// +// ----------------------------------------------------------------------------- +// +TUint CDvrSdpParser::GetClockRateL( const TDesC8& aPtr ) + { + // Find clock rate keyword + TInt start( FindStart( aPtr, KKeyClockRate ) ); + User::LeaveIfError( start ); + + // Len up to first slash ( i.e: rtpmap:97 MP4A-LATM/32000/2 ) + TInt slash( aPtr.Mid( start ).Find( KSLStr ) ); + User::LeaveIfError( slash ); + start += ( slash + KSLStr().Length() ); + TInt len( GetLen( aPtr, start ) ); + + // Len up to second slash ( i.e: rtpmap:97 MP4A-LATM/32000/2 ) + slash = aPtr.Mid( start, len ).Find( KSLStr ); + len = ( slash != KErrNotFound )? slash: len; + return StrToUint( aPtr.Mid( start, len ) ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetControlL() +// Checks if a=control line specifies a control for media. +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::GetControlL( const TDesC8& aMediaPtr, HBufC8*& aControlAddr ) + { + delete aControlAddr; aControlAddr = NULL; + HBufC8* control = GetStringL( aMediaPtr, KKeyControl ); + if ( control ) + { + CleanupStack::PushL( control ); + if ( control->Des().FindC( KCRSDPRtspUriBegin ) == KErrNotFound ) + { + // relative url + if ( iBaseUrl ) + { + aControlAddr = HBufC8::NewL( iBaseUrl->Des().Length() + + control->Des().Length() + + KSLStr().Length() ); + aControlAddr->Des().Append ( iBaseUrl->Des() ); + aControlAddr->Des().Append ( KSLStr ) ; + aControlAddr->Des().Append ( control->Des() ); + } + } + else + { + // absolute url + aControlAddr = control->Des().AllocL(); + } + + CleanupStack::PopAndDestroy( control ); + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::CheckForMulticast() +// Checks if c= line specifies a multicast addr +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::CheckForMulticast( const TDesC8& aLine ) + { + TInetAddr controladdr; + TName addr( KNullDesC ); + addr.Copy( aLine ); + TInt err( controladdr.Input( addr ) ); + if ( err != KErrNone ) + { + LOG1( "CDvrSdpParser: invalid control address in SDP connection line '%S'", &addr ); + } + else + { + // just do check for multicast, actual address is taken from SETUP response + iIsMulticast = controladdr.IsMulticast(); + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + /* Commented out, for some reason can crash with RTP playback in debug. + if ( iIsMulticast ) + { + LOG1( "CDvrSdpParser: detected MULTICAST (%S) control address in SDP", &addr ); + } + else + { + LOG1( "CDvrSdpParser: detected unicast (%S) control address in SDP", &addr ); + } + */ +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + } + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindAttributesL +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::FindAttributesL( + const TDesC8& aSdpSection, + RArray& aAttributeList ) + { + TInt last( 0 ); + TInt start( KErrNotFound ); + do + { + // Rest of the SDP section + TPtrC8 rest( aSdpSection.Mid( last ) ); + start = rest.Find( KKeyAttribute ); + if ( start > KErrNotFound ) + { + last += start; + TInt len( GetLen( rest, start, ETrue ) ); + if ( len > 0 ) + { + // Add other than control attribute + if ( rest.Mid( start, len ).Find( KKeyControl ) == KErrNotFound ) + { + TPtrC8 ptr( rest.Mid( start, len ) ); + User::LeaveIfError( aAttributeList.Append( ptr ) ); + } + + last += len; + } + } + } + while( start > KErrNotFound ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindDataStreamsL +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::FindDataStreamsL( + const TDesC8& aSdpSection, + RArray& aStreamsList ) + { + TInt last( 0 ); + TInt start( KErrNotFound ); + do + { + // Rest of the SDP block + TPtrC8 rest( aSdpSection.Mid( last ) ); + start = rest.Find( KKeyDataStream ); + if ( start > KErrNotFound ) + { + last += start; + TInt len( GetLen( rest, start, ETrue ) ); + if ( len > 0 ) + { + TPtrC8 ptr( rest.Mid( start, len ) ); + User::LeaveIfError( aStreamsList.Append( ptr ) ); + last += len; + } + } + } + while( start > KErrNotFound ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetIntL +// +// ----------------------------------------------------------------------------- +// +TInt CDvrSdpParser::GetIntL( const TDesC8& aPtr, const TDesC8& aKeyword ) + { + TInt ret( KErrNotFound ); + HBufC8* buf = GetStringL( aPtr, aKeyword ); + if ( buf ) + { + ret = StrToUint( buf->Des() ); + delete buf; + } + + return ret; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetStringL +// +// ----------------------------------------------------------------------------- +// +HBufC8* CDvrSdpParser::GetStringL( const TDesC8& aPtr, const TDesC8& aKeyword ) + { + const TInt start( FindStart( aPtr, aKeyword ) ); + const TInt len( GetLen( aPtr, start ) ); + + HBufC8* buf = NULL; + if ( start > KErrNotFound && len > 0 && ( start + len ) <= aPtr.Length() ) + { + buf = aPtr.Mid( start, len ).AllocL(); + } + + return buf; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::FindStart +// +// ----------------------------------------------------------------------------- +// +TInt CDvrSdpParser::FindStart( const TDesC8& aPtr, const TDesC8& aKeyword ) + { + TInt start( aPtr.Find( aKeyword ) ); + + if ( start > KErrNotFound ) + { + start += aKeyword.Length(); + } + + return start; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::GetLen +// +// ----------------------------------------------------------------------------- +// +TInt CDvrSdpParser::GetLen( + const TDesC8& aPtr, + const TInt aStart, + const TBool aIgnoreSpace ) + { + if ( aStart > KErrNotFound && aStart < aPtr.Length() ) + { + // Find next LF, CR or CRLF combination + TInt len1( MinNonError( aPtr.Mid( aStart ).Find( KLFStr ), + aPtr.Mid( aStart ).Find( KCRStr ) ) ); + // Find space + TInt len2( ( aIgnoreSpace )? KErrNotFound: + aPtr.Mid( aStart ).Find( KSPStr ) ); + + if ( len1 == KErrNotFound && len2 == KErrNotFound ) + { + // Rest of the buffer + return ( aPtr.Length() - aStart ); + } + else + { + // CRLF or space + return MinNonError( len1, len2 ); + } + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::MinNonError +// +// ----------------------------------------------------------------------------- +// +TInt CDvrSdpParser::MinNonError( const TInt aValue1, const TInt aValue2 ) + { + if ( aValue1 > KErrNotFound && aValue2 > KErrNotFound ) + { + return Min( aValue1, aValue2 ); + } + + return ( ( aValue1 > KErrNotFound )? aValue1: + ( aValue2 > KErrNotFound )? aValue2: KErrNotFound ); + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::StrToUint +// Convert string to integer. +// ----------------------------------------------------------------------------- +// +TUint CDvrSdpParser::StrToUint( const TDesC8& aString ) + { + TLex8 templex; + templex.Assign( aString ); + TUint ret( KMaxTUint ); + templex.Val( ret ); + return ret; + } + +// ----------------------------------------------------------------------------- +// CDvrSdpParser::DeleteVariables +// +// ----------------------------------------------------------------------------- +// +void CDvrSdpParser::DeleteVariables( void ) + { + delete iSdp; iSdp = NULL; + delete iCommonIp; iCommonIp = NULL; + iMediaBuf.Reset(); + iSessionAttributes.Reset(); + iAudioAttributes.Reset(); + iVideoAttributes.Reset(); + iDataStreams.Reset(); + delete iAudioControlAddr; iAudioControlAddr = NULL; + delete iVideoControlAddr; iVideoControlAddr = NULL; + delete iAudioIpAddr; iAudioIpAddr = NULL; + delete iVideoIpAddr; iVideoIpAddr = NULL; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/group/CommonRecordingEngine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/group/CommonRecordingEngine.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification common recording engine* +*/ + + + +#include +#include "../inc/CRServerConsts.hrh" +#include "../inc/VideoServiceUtilsConf.hrh" + +//OPTION ARMCC --asm --interleave +ALWAYS_BUILD_AS_ARM + +TARGET CommonRecordingEngine.exe +TARGETTYPE exe +UID 0x1000008d KCRServerUid + +CAPABILITY CAP_APPLICATION NetworkControl -DRM -AllFiles +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE CCRServer.cpp +SOURCE CCRSession.cpp +SOURCE CCREngine.cpp +SOURCE CCRPacketBuffer.cpp +SOURCE CCRRtspSink.cpp +SOURCE CCRNullSink.cpp +SOURCE CCRStreamingSession.cpp +SOURCE CCRRtspPacketSource.cpp +SOURCE CCRRtpTcpStreamer.cpp +SOURCE CCRRtpTcpStream.cpp +SOURCE CCRConnection.cpp +SOURCE CCRRtspResponse.cpp +SOURCE CCRRtspCommand.cpp +SOURCE CCRRtspCommon.cpp +SOURCE CCRSock.cpp +SOURCE CCRTimer.cpp +SOURCE CCRPacketSinkBase.cpp +SOURCE CCRPacketSourceBase.cpp +SOURCE CCRPunchPacketSender.cpp +SOURCE CCRClientInformer.cpp +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +SOURCE CCRRtpFileSource.cpp +SOURCE CCRNullSource.cpp +SOURCE CCRRtpRecordSink.cpp +SOURCE CCRXpsSink.cpp +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + +USERINCLUDE ../inc +USERINCLUDE ../../../conf/ + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +USERINCLUDE ../DvrRtpClipHandler/inc +USERINCLUDE ../DvrRtpUtils/inc +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY esock.lib // Network connection +LIBRARY insock.lib // Inet address +LIBRARY inetprotutil.lib // URI parsing utils +LIBRARY commdb.lib // TCommDbConnPref et al. +LIBRARY hash.lib // CMD5 class +LIBRARY rtp.lib // RTP +LIBRARY efsrv.lib // File server +LIBRARY connmon.lib // RConnectionMonitor +LIBRARY centralrepository.lib // +LIBRARY DvrSdpparser.lib // DVR SDP parser +LIBRARY flogger.lib // File logger +LIBRARY PlatformEnv.lib +LIBRARY imut.lib // TImCodecB64 + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +STATICLIBRARY XPSPacketSink.lib // XPS packet sink +LIBRARY DvrRtpclipHandler.lib // Propriatary rtp format +LIBRARY DvrRtpUtils.lib // DVR rtp utils +#ifdef VIA_FEA_IPTV_USE_IPDC +LIBRARY H264GenrToLocalDepack.lib +#endif // VIA_FEA_IPTV_USE_IPDC +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + +START WINS +//EXPORTUNFROZEN +END + +START MARM +// ?marm_specific_information +END diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common recording engine server side build info file* +*/ + + + + +#include "../DvrSdpParser/group/bld.inf" + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/commonrecordingengine.iby CORE_MW_LAYER_IBY_EXPORT_PATH(commonrecordingengine.iby) + +PRJ_MMPFILES +CommonRecordingEngine.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRClientInformer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRClientInformer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Sends message to client with message queue.* +*/ + + + + +#ifndef CCRCLIENTINFORMER_H +#define CCRCLIENTINFORMER_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Packet sink that does not forward packets. Good for testing. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRClientInformer : public CBase + { + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @return CCRClientInformer pointer. + */ + static CCRClientInformer* NewL( void ); + + /** + * Destructor + */ + virtual ~CCRClientInformer( ); + +public: // New methods + + /** + * Send a message thrue the message queue. + * @since Series 60 3.0 + * @param aQueueName a name of queue. + * @param aInfo a info of the message. + * @return a system wide error code. + */ + TInt SendMessage( const TDes& aQueueName, + SCRQueueEntry& aInfo ); + +private: // Constructors and destructors + + /** + * By default default constructor is private + */ + CCRClientInformer(); + + }; + +#endif // CCRCLIENTINFORMER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRConnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRConnection.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,351 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for wrapping RConnection* +*/ + + + + +#ifndef __CCRCONNECTION_H +#define __CCRCONNECTION_H + +// INCLUDES +#include "MCRConnectionObserver.h" +#include +#include +#include +#include +#include + +// CONSTANTS +/** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : GRPS */ +const TInt KCRBandwidthGPRS( 40200 ); +/** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : EGRPS */ +const TInt KCRBandwidthEdgeGPRS( 89600 ); +/** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : 3G */ +const TInt KCRBandwidthWCDMA( 384000 ); +/** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : WLAN */ +const TInt KCRBandwidthWLAN( 1432572 ); +/** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : LAN */ +const TInt KCRBandwidthLAN( 3000000 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRConnection; + +// CLASS DECLARATION + +/** +* RConnection wrapper +*/ +class CCRConnection : public CActive, + public MConnectionMonitorObserver + { + +public: // Data types + + /** + * Enumeration for different connection stages + */ + enum TConnectionState + { + EIdle, /**< Connection idle */ + EFindingAP, /**< Search access point */ + EFindingBearer, /**< Finding bearer */ + EOpen, /**< Opening connection */ + EConnecting /**< Connecting */ + }; + + /** + * Heuristics for the connection, ie, characteristics from the + * connection discovered during run-time and that may affect it's usage. + */ + enum TConnectionHeuristic + { + /** + * Connection is unable to stream RTP over UDP, + * most likely due to firewall blocking. + */ + EUdpStreamingBlocked = 0 + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aSockServer + * @return CCRConnection pointer to CCRConnection class + */ + static CCRConnection* NewL( RSocketServ& aSockServer ); + + /** + * Destructor. + */ + virtual ~CCRConnection( ); + +public: // New methods + /** + * Method for starting and attaching a connection. + * @since Series 60 3.0 + * @param aConnectionId Connection id. + * @return none. + */ + void Attach( TUint aConnectionId ); + + /** + * Method for getting the rconnection to use. This is useful only + * when connection state is open. + * @since Series 60 3.0 + * @param none. + * @return reference to RConnection. + */ + RConnection& Connection( void ); + + /** + * Method for getting state of the connection. + * @since Series 60 3.0 + * @param none. + * @return connection state. + */ + TConnectionState State( void ) const; + + /** + * Gets bearer for current connection. + * @since Series 60 3.0 + * @param none. + * @return bearer type + */ + TConnMonBearerType BearerType() const; + + /** + * Gets (estimated) maximum available connection bandwidth. + * @since Series 60 3.0 + * @param none. + * @return bandwidth in bit/s, zero if unkown or connection not available. + */ + TInt MaximumBandwidth(); + + /** + * Check if bearer is considered 3G, WLAN or similar + * @since Series 60 3.0 + * @param none. + * @return TBool + */ + TBool IsBearerWLANor3G( TConnMonBearerType aBearer ); + + /** + * Add observer for connection status. + * @since Series 60 3.0 + * @param aObserver new observer + * @return TInt + */ + TInt RegisterObserver( MCRConnectionObserver* aObserver ); + + /** + * remove observer for connection status. + * @since Series 60 3.0 + * @param aObserver observer to be removed. + * @return TInt. + */ + TInt UnregisterObserver( MCRConnectionObserver* aObserver ); + + /** + * Retrives a heuristic associated with the connection. + * @since Series 60 3.0 + * @param aHeuristic + * @return value associated with the heuristic. + */ + TBool GetHeuristic( TConnectionHeuristic aHeuristic ); + + /** + * Sets a heuristic associated with the connection + * @since Series 60 3.0 + * @param aHeuristic + * @param aValue value associated with the heuristic. + * @return none. + */ + void SetHeuristic( TConnectionHeuristic aHeuristic, + TBool aValue ); + +private: // Methods from base classes + + /** + * From CActive. + * Cancel protocol implementation. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCancel(); + + /** + * From CActive. + * Outstanding request completed. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CActive. + * Handle error. + * @since Series 60 3.0 + * @param aError Error code. + * @return KErrNone. + */ + TInt RunError( TInt aError ); + + /** + * From MConnectionMonitorObserver. + * Receives event notifications from connection monitor, + * specifically for bearer changes. + * @since Series 60 3.0 + * @param aConnMonEvent + * @return none. + */ + void EventL( const CConnMonEventBase& aConnMonEvent ); + +private: // New methods + + /** + * Method for sending connection error events to message queue. + * @since Series 60 3.0 + * @param aError is Error code. + * @return none + */ + void SendConnectionErrorToQueue( TInt aError ); + + /** + * Close internal RConnection iConnection. + * @since Series 60 3.0 + * @param none. + * @return none + */ + void CloseRConnection(); + + /** + * Finds access point. + * @since Series 60 3.0 + * @param none. + * @return none + */ + TInt FindApL(); + + /** + * Finds bearer. + * @since Series 60 3.0 + * @param none. + * @return none + */ + void FindBearerL(); + + /** + * Notify UI about connection. + * @since Series 60 3.0 + * @param none. + * @return none + */ + void NotificationL(); + +private: // Constructors and destructors + + /** + * default constructor + * @param aSockServer a reference to socket server. + */ + CCRConnection( RSocketServ& aSockServer ); + + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // Data + + /** + * Socker server. + */ + RSocketServ& iSockServer; + + /** + * Connection. + */ + RConnection iConnection; + + /** + * Observers. + */ + RPointerArray iObservers; + + /** + * Current state. + */ + TConnectionState iState; + + /** + * Connection preference. + */ + TCommDbConnPref iConnPref; + + /** + * variable for getting notification when interface goes up or down + */ + TNifProgressBuf iNotification; + + /** + * Connection id to be used + */ + TUint iCurrentConnectionId; + + /** + * Connection monitor + */ + RConnectionMonitor iConMon; + + /** + * How many active connections were found by connection monitor + */ + TUint iConnectionCount; + + /** + * Heuristics for connection + */ + TUint32 iHeuristics; + + /** + * Bearer type for current connection + */ + TConnMonBearerType iBearerType; + + /** + * Bearer type detected after change + */ + TConnMonBearerType iNewBearerType; + + /** + * Whether we have connection progress notification pending or not + */ + TBool iConMonProgressNotifyPending ; + + }; + +#endif // __CCRCONNECTION_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCREngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCREngine.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,538 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Engine part of the engine. Engineered to keep count* +*/ + + + + +#ifndef CCRENGINE_H +#define CCRENGINE_H + +// INCLUDES +#include "CCRConnection.h" +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CAsyncCallBack; +class CCRSession; +class CCRStreamingSession; +class CCRClientInformer; +class CRtpClipHandler; + +// CLASS DECLARATION + +/** +* Server's bookkeeping part: knows what clients there are and thru which +* client sessions, what streaming sessions there are and passes commands +* to those sessions and sinks. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCREngine : public CObject, + public MCRConnectionObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCREngine pointer to CCREngine class + */ + static CCREngine* NewL( void ); + + /** + * Destructor. + */ + virtual ~CCREngine(); + +public: // New functions + + /** + * Does the general message handling. + * @since Series 60 3.0 + * @param aMessage contains data from the client. + * @return none. + */ + void GeneralServiceL( const RMessage2& aMessage ); + + /** + * Method that streams call to ask for resignation. + * @since Series 60 3.0 + * @param aSession is pointer to streamingsession that wants to quit. + * @return none. + */ + void SessionStop( CCRStreamingSession* aSession ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCREngine( void ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +public: // Methods from base classes + + /** + * From MCRConnectionObserver. + * receives notifications of connection status changes, + * used to clear heuristics on streaming capabilities. + * @since Series 60 3.0 + * @param aSessionId a session id. + * @param aStatus is the new status of the connection. + * @param aErr contains error code if new status is failure status. + * @return none. + */ + void ConnectionStatusChange( TInt aSessionId, + TCRConnectionStatus aStatus, + TInt aErr ); + +private: // New methods + + /** + * Verifies needed cababilities of DVR client user. + * @since Series 60 3.0 + * @param aMessage contains data from the client. + * @return None. + */ + void VerifyCapabilitiesL( const RMessage2& aMessage ); + + /** + * Sets connection. + * @since Series 60 3.0 + * @param aIap ?. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt SetConnectionId( const SCRRtspIapParams& aIap ); + + /** + * Cancel connetion set. + * @since Series 60 3.0 + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt CancelSetConnectionId(); + + /** + * Starts RTSP URL streaming. + * @since Series 60 3.0 + * @param aRtspParams a RTPS params. + * @return a session definition checksum. + */ + TUint PlayRtspUrlL( const SCRRtspParams& aRtspParams ); + + /** + * Starts DVB-H live streaming. + * @since Series 60 3.0 + * @param aLiveParams is set of parameters required for DVB-H. + * @return a session definition checksum. + */ + TUint PlayDvbhLiveL( const SCRLiveParams& aLiveParams ); + + /** + * Change service (channel) of DVB-H live stream. + * @since Series 60 3.0 + * @param aCurrentSessionChk a current service session checksum. + * @param aLiveParams is set of parameters required for DVB-H. + * @return a session definition checksum. + */ + TUint ChangeDvbhServiceL( const TUint aSessionChk, + const SCRLiveParams& aLiveParams ); + + /** + * Starts RTP file format playing. + * @since Series 60 3.0 + * @param aRtpParams a RTP clip play params. + * @return a session definition checksum. + */ + TUint PlayRtpFileL( const SCRRtpPlayParams& aRtpParams ); + + /** + * Starts RTP file format playing. + * @since Series 60 3.0 + * @param aFileHandle a open file handle for RTP file. + * @return a session definition checksum. + */ + TUint PlayRtpFileL( const RFile& aFileHandle ); + + /** + * Starts recording of current stream. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @param aRecordParams a recording parameters. + * @return none. + */ + void RecordCurrentStreamL( const TUint aSessionChk, + const SCRRecordParams& aRecordParams ); + + /** + * Starts recording of RTSP stream. + * @since Series 60 3.0 + * @param aRtspUrl is set of parameters required for rtsp. + * @param aRecordParams a recording parameters. + * @return a session definition checksum. + */ + TUint RecordRtspStreamL( const SCRRtspParams& aRtspUrl, + const SCRRecordParams& aRecordParams ); + + /** + * Starts recording of DVB-H stream. + * @since Series 60 3.0 + * @param aLiveParams is set of parameters required for DVB-H. + * @param aRecordParams a recording parameters. + * @return a session definition checksum. + */ + TUint RecordDvbhStreamL( const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ); + + /** + * Pauses/Resumes current recording. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @param aStart a start or end pausing. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt PauseRecordStream( const TUint aSessionChk, + const TBool& aStart ); + + /** + * Stops current recording. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt StopRecordStream( const TUint aSessionChk ); + + /** + * Starts time shifting. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt StartTimeShiftL( const TUint aSessionChk ); + + /** + * Stops time shifting. + * @since Series 60 3.0 + * @param aTimeShiftChk a session definition checksum. + * @param aCurrentChk a session definition of existing session. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt StopTimeShift( const TUint aTimeShiftChk, + const TUint aCurrentChk ); + + /** + * Play command for wanted source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt PlayCommand( const TUint aSessionChk, + const TReal aStartPos, + const TReal aEndPos ); + + /** + * Pause command for wanted source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt PauseCommand( const TUint aSessionChk ); + + /** + * Stop command for wanted source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt StopCommand( const TUint aSessionChk ); + + /** + * Setter for source position. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @param aPosition a current play position of the clip. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt SetPosition( const TUint aSessionChk, + const TInt64 aPosition ); + + /** + * Getter for source position. + * @since Series 60 3.0 + * @param aSessionChk a session defination checksum. + * @param aPosition a current play position of the clip. + * @param aDuration a duration of the clip. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt GetPosition( const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ); + + /** + * Closes wanted source and all sinks. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if succesful, otherwise system wide error code. + */ + TInt CloseSession( const TUint aSessionChk ); + + /** + * Emulates live source from a .rtp clip. + * @since Series 60 3.0 + * @param none. + * @return a session definition checksum. + */ + TUint PlayNullSourceL(); + + /** + * Sends RTSP stream packets to null sink. + * @since Series 60 3.0 + * @param aRtspParams a RTPS params. + * @return a session definition checksum. + */ + TUint PlayRtspUrlToNullSinkL( const SCRRtspParams& aRtspParams ); + + /** + * Creates connection. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CreateConnectionL( void ); + + /** + * Creates RTP clip handler. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CreateClipHandlerL( void ); + + /** + * Verifies if RTSP session with params is already available. + * @since Series 60 3.0 + * @param aRtspParams a RTPS params. + * @return an index to sessions array if session found, + otherwise KErrNotFound. + */ + TInt VerifyRtspSessionL( const SCRRtspParams& aRtspParams ); + + /** + * Verifies if DVB-H session with params is already available. + * @since Series 60 3.0 + * @param aLiveParams is set of parameters required for DVB-H. + * @return an index to sessions array if session found, + otherwise KErrNotFound. + */ + TInt VerifyDvbhSessionL( const SCRLiveParams& aLiveParams ); + + /** + * Verifies if DVB-H session with params is already available. + * @since Series 60 3.0 + * @param aRtpParams a RTP clip play params. + * @return an index to sessions array if session found, + otherwise KErrNotFound. + */ + TInt VerifyRtpFileSessionL( const SCRRtpPlayParams& aRtpParams ); + + /** + * Verifies if session with defination name is available. + * @since Series 60 3.0 + * @param aFileHandle a open file handle for RTP file. + * @return an index to sessions array if names match, + otherwise KErrNotFound. + */ + TInt VerifyRtpFileSessionL( const RFile& aFileHandle ); + + /** + * Verifies if session with defination name is available. + * @since Series 60 3.0 + * @param aName a definition name of the session. + * @return an index to sessions array if names match, + otherwise KErrNotFound. + */ + TInt VerifySession( const TDesC& aName ); + + /** + * Verifies if session with definition checksum is available. + * @since Series 60 3.0 + * @param aSessionChk a session checksum to verify for. + * @return an index to sessions array if names match, + otherwise KErrNotFound. + */ + TInt VerifySession( const TUint aSessionChk ); + + /** + * Creates recording sin base on file format. + * @since Series 60 3.0 + * @param aSessionIndex a session index. + * @param aRecordParams a recording parameters. + * @return none. + */ + void CreateRecordingSinkL( const TInt aSessionIndex, + const SCRRecordParams& aRecordParams ); + + /** + * Static callback called via CAsyncCallBack to initiate cleaning of a sessions. + * @since Series 60 3.0 + * @param aThis ?. + * @return KErrNone if succesful, otherwise system wide error code. + */ + static TInt SessionStopCallBack( TAny* aThis ); + + /** + * Method for cleaning a sessions. Called from StreamStopCallBack. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoSessionStop( void ); + + /** + * Method for deleting RTP clip handler if it is not used in any session. + * @since Series 60 3.0 + * @param aCurrentSessionIndex a index of active session. + * @return none. + */ + void DeleteClipHandler( const TInt aCurrentSessionIndex ); + + /** + * Reads non unicode descriptor buffer to client address space. + * @since Series 60 3.0 + * @param aMessage an object which encapsulates a client request. + * @param aParam a index value identifying the argument. + * @param aDes a buffer to be read. + * @return None. + */ + void Read( const RMessage2& aMessage, + const TInt& aParam, + TDes8& aDes ); + + /** + * Reads unicode descriptor buffer to client address space. + * @since Series 60 3.0 + * @param aMessage an object which encapsulates a client request. + * @param aParam a index value identifying the argument. + * @param aDes a buffer to be read. + * @return None. + */ + void Read( const RMessage2& aMessage, + const TInt& aParam, + TDes16& aDes ); + + /** + * Writes non unicode descriptor buffer to client address space. + * @since Series 60 3.0 + * @param aMessage an object which encapsulates a client request. + * @param aParam a index value identifying the argument. + * @param aDes a data to be written. + * @return None. + */ + void Write( const RMessage2& aMessage, + const TInt& aParam, + const TDesC8& aDes ); + + /** + * Writes unicode descriptor buffer to client address space. + * @since Series 60 3.0 + * @param aMessage an object which encapsulates a client request. + * @param aPtr a pointer to client address space. + * @param aDes a data to be written. + * @return None. + */ + void Write( const RMessage2& aMessage, + const TInt& aParam, + const TDesC16& aDes ); + + /** + * Method for panicing a client. + * @since Series 60 3.0 + * @param aPanic is the panic reason, essentially a symbian error code. + * @aMessage is the message causing the panic. + * @return none. + */ + void PanicClient( TInt aPanic, + const RMessage2& aMessage ); + +private: // Data + + /** + * Name of the queue. + */ + HBufC* iQueueName; + + /** + * Callstack-cutter for cleanup purpose. + */ + CAsyncCallBack* iCleanUp; + + /** + * Connection manager. + */ + CCRConnection* iConnection; + + /** + * Clip handler for RTP clip. + */ + CRtpClipHandler* iClipHandler; + + /** + * Sends messages to client's message queue + */ + CCRClientInformer* iInformer; + + /** + * Socket server. + */ + RSocketServ iSockServer; + + /** + * Streamong sessions. + */ + RPointerArray iSessions; + + /** + * Array of sessions that have declared that they want to be deleted + */ + RPointerArray iSessionsToDelete; + + /** + * Loopback port. + */ + TInt iLoopbackPort; + + }; + +#endif // CCRENGINE_H + +// End of file + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRNullSink.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRNullSink.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet sink where no-one gets the streaming* +*/ + + + + +#ifndef CCRNULLSINK_H +#define CCRNULLSINK_H + +// INCLUDES +#include "CCRPacketSinkBase.h" +#include "CCRPacketBuffer.h" +#include "MCRTimerObserver.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRConnection; +class RSocketServ; +class CCRStreamingSession; +class CCRTimer; +class MCRConnectionObserver; + +// CLASS DECLARATION + +/** +* Packet sink that does not forward packets. Good for testing. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRNullSink : public CCRPacketSinkBase, + public MCRTimerObserver + { + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @return CCRNullSink pointer. + */ + static CCRNullSink* NewL( CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor + */ + virtual ~CCRNullSink(); + +public: // Public methods, testing purpose + /** + * Register a test observer to receive streaming information + * @param aObserver pointer to observer + */ + void RegisterConnectionObs( MCRConnectionObserver* aObserver ); + + /** + * Method that source uses to communicate its status. + * @since Series 60 3.0 + * @param aNewState is the new state of the source. + * @return none. + */ + virtual void StatusChanged( MCRPacketSource::TCRPacketSourceState aNewState ); + +protected: // Constructors and destructors + + /** + * By default default constructor is private + * @param aSinkId that this class needs to use when reporting progress back to owner + * @param aOwningSession is the streaming session that owns this instance + */ + CCRNullSink( CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ); + + /** + * Second phase of 2-phased construction + */ + void ConstructL(); + +private: // Methods from base classes + + /** + * From CCRPacketSinkBase. + * Connects the given buffer with this sink. + * @since Series 60 3.0 + * @param aBuffer is the buffer to connect with. + * @return none. + */ + void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * From CCRPacketSinkBase. + * Method for setting the sdp in use. + * @since Series 60 3.0 + * @param aSdp is the new sdp. + * @return none. + */ + void SetSdpL( const TDesC8& aSdp ); + + /** + * From CCRPacketSinkBase. + * Adds packet to the sink. + * @since Series 60 3.0 + * @return none. + */ + void NewPacketAvailable(); + + /** + * From MCRTimerObserver. + * The function to be called when a timeout occurs. + * @since Series 60 3.0 + * @param aTimer a pointer to timer. + * @return none. + */ + void TimerExpired( CCRTimer* aTimer ); + +private: // Data + + /** + * SDP in use. + */ + HBufC8* iSdp; + + /** + * Flow control timer. + */ + CCRTimer* iFlowTimer; + + /** + * when TBool in iPacketPendingInBuffer is ETrue it means that the buffer + * in iBuffer having same array index as said TBool has a packet. + * waiting to be sent to rop + */ + TBool iPacketPendingInBuffer; + + /** + * Test client observer + */ + MCRConnectionObserver* iObserver; + }; + +#endif // CCRNULLSINK_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRNullSource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRNullSource.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,256 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that reads packets from a .rtp clip for testing purposes.* +*/ + + + + +#ifndef CCRNULLSOURCE_H +#define CCRNULLSOURCE_H + +// INCLUDES +#include "CCRPacketSourceBase.h" +#include +#include +#include "MRtpTimerObserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpClipHandler; +class CRtpTimer; + +// CLASS DECLARATION + +/** +* Class that negotiaties RTP stream using RTSP. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRNullSource : public CCRPacketSourceBase, + public MRtpFileReadObserver, + public MRtpTimerObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCRNullSource pointer to CCRNullSource class + */ + static CCRNullSource* NewL( const TDesC& aClipName, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor. + */ + virtual ~CCRNullSource(); + +public: // New functions + + /** + * + * @since Series 60 3.0 + * @param none. + * @return none. + */ + //void PunchPacketsSent(); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @param aSessionObs a session observer. + * @param aOwningSession a owning session. + */ + CCRNullSource( MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( const TDesC& aClipName ); + +private: // Methods from base classes + + /** + * From CCRPacketSourceBase. + * Method for acquiring sdp. + * @since Series 60 3.0 + * @param aSdp is string pointer that will be .Set() to contain the sdp. + * If no sdp is available no .Set() will occur. + * @return KErrNotReady if no sdp available. + */ + TInt GetSdp( TPtrC8& aSdp ); + + /** + * From CCRPacketSourceBase. + * Method for setting buffers to packet source + * @since Series 60 3.0 + * @param aBuffer is buffer to be set. + * @return none. + */ + void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * From CCRPacketSourceBase. + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void PostActionL(); + + /** + * From CCRPacketSourceBase. + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void Restore(); + + /** + * From CCRPacketSourceBase. + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return a system wide error code. + */ + TInt Play( const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * From CCRPacketSourceBase. + * Method for stopping play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Stop(); + + /** + * From CCRPacketSourceBase. + * Getter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @param aDuration a duration of playback. + * @return a system wide error code. + */ + TInt GetPosition( TInt64& aPosition, + TInt64& aDuration ); + + /** + * From MRtpFileReadObserver. + * Called when RTP packets group readed from a file. + * @since Series 60 3.0 + * @param aGroup a RTP data readed from a file. + * @param aGroupTime a group time in milli seconds. + * @param aLastGroup a indication of last group in clip. + * @return none. + */ + void GroupReadedL( const TDesC8& aGroup, + const TUint aGroupTime, + const TBool aLastGroup ); + + /** + * From MRtpFileReadObserver. + * File handler status of playback. + * @since Series 60 3.0 + * @param aStatus a status of file reading. + * @return none. + */ + void ReadStatus( TInt aStatus ); + + /** + * From MRtpTimerObserver. + * Called when timer completion event occurs + * @since Series 60 3.0 + * @return none + */ + void TimerEventL(); + + /** + * From MRtpTimerObserver. + * Handles a leave occurring in the request + * completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code. + * @return None. + */ + void TimerError( const TInt aError ); + +private: // New methods + + /** + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt NextClipGroup(); + + /** + * Converts old RTP propriatary format packet type to stream id. + * @since Series 60 3.0 + * @param aType a packet type from a clip. + * @param aStream a stream id to update. + * @return true if packet valid, otherwise false. + */ + TBool TypeToStream( const MRtpFileWriteObserver::TRtpType& aType, + MCRPacketSource::TCRPacketStreamId& aStream ); + +private: // Data + + /** + * Session observer. + */ + MCRStreamObserver& iSessionObs; + + /** + * RTP clip handler. + */ + CRtpClipHandler* iClipHandler; + + /** + * SDP data. + */ + HBufC8* iSdp; + + /** + * Packets flow timer. + */ + CRtpTimer* iFlowTimer; + + /** + * Time of last readed group. + */ + TUint iGroupTime; + + }; + +#endif // CCRNULLSOURCE_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRPacketBuffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRPacketBuffer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,351 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Ring buffer for storing packets from source.* +*/ + + + + +#ifndef _CCRPACKETBUFFER_H +#define _CCRPACKETBUFFER_H + +// INCLUDES +#include "MCRPacketSource.h" +#include "CCRPacketSinkBase.h" +#include +#include + +// CONSTANTS +const TInt KStreamTypeBytePoint( 0 ); +const TInt KStreamTypeBytesLength( 1 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketSinkBase; + +// CLASS DECLARATION + +/** +* Ring buffer where to store RTP packets. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRPacketBuffer : public CBase + { + +public: // Constructors and destructors + + /** + * Allocation method for buffer. + * @param aMaxPackets a maximum packets count in buffer. + * @return buffer id. + */ + static CCRPacketBuffer* NewL( const TInt aMaxPackets ); + + /** + * De-allocation method. + */ + ~CCRPacketBuffer(); + +public: // New methods + + /** + * Method for setting sink for buffer + * @since Series 60 3.0 + * @param aSink is the sink to set + * @return KErrNone if ok, otherwise system-wide error codes. + */ + TInt AddSink( CCRPacketSinkBase* aSink ); + + /** + * Method for adding a packet to buf. Succeeds always. + * If memory allocation fails this silently fails. + * @since Series 60 3.0 + * @param aStream a type of packet. + * @param aHeader a pointer to packet header. + * @param aPacket a pointer to packet payload. + * @return none + */ + void AddPacket( const MCRPacketSource::TCRPacketStreamId& aStream, + const TDesC8& aHeader, + const TDesC8& aPacket ); + + /** + * Method for adding a packet to buf. + * If memory allocation fails this silently fails. + * @since Series 60 3.0 + * @param aStream a type of packet. + * @param aPacket is pointer to data that will be stored to buf. + * @return none + */ + void AddPacket( const MCRPacketSource::TCRPacketStreamId& aStream, + const TDesC8& aPacket ); + + /** + * Setter for buffer's flow control mode. + * @since Series 60 3.0 + * @param aState a state to set. + * @return none + */ + void ContinousStream( const TBool aState ); + + /** + * Getter for buffer's flow control mode. + * @since Series 60 3.0 + * @return true if continous stream, + false if needs flow control. + */ + TBool ContinousStream(); + + /** + * Setter for buffer's flow control state. + * @since Series 60 3.0 + * @param aState a state to set. + * @return none + */ + void MoreComing( const TBool aState ); + + /** + * Getter for buffer's flow control state. + * @since Series 60 3.0 + * @return more coming state. + */ + TBool MoreComing(); + + /** + * Getter for stream of next packet. + * @since Series 60 3.0 + * @param aId a id of requester. + * @param a stream of the packet. + * @return a book keeping index of sink. + */ + TInt GetStream( const CCRStreamingSession::TCRSinkId& aId, + MCRPacketSource::TCRPacketStreamId& aStreamId ); + + /** + * Getter for stream of packet in given offset. + * @since Series 60 3.0 + * @param aId a id of requester. + * @param a stream of the packet. + * @return a book keeping index of sink. + */ + TInt GetStream( const CCRStreamingSession::TCRSinkId& aId, + const TInt aOffset, + MCRPacketSource::TCRPacketStreamId& aStreamId ); + + /** + * Method for taking packet from a buffer. + * @since Series 60 3.0 + * @param aId a id of requester. + * @param aReturnedData is pointer where the data is read. + * NULL if nothing found. + * @return none. + */ + void GetPacket( const CCRStreamingSession::TCRSinkId& aId, + TPtr8& aReturnedData ); + + /** + * Method for taking packet from a buffer. + * @since Series 60 3.0 + * @param aBookKeeping a book keeping index. + * @param aReturnedData is pointer where the data is read. + * NULL if nothing found. + * @return none. + */ + void GetPacket( const TInt aBookKeeping, + TPtr8& aReturnedData ); + + /** + * Method for peeking at a packet in particular offset. This does not + * set the packet to be removed from the buffer. + * + * @since S60 v3.0 + * @param aId a id of requester. + * @param aReturnedData is pointer where the data is read. + * NULL if nothing found. + * @param aOffset offset of the packet to be peeked. If zero, the next + * packet in the buffer is peeked. + */ + void PeekPacket( const CCRStreamingSession::TCRSinkId& aId, + TPtr8& aReturnedData, + const TInt aOffset ); + + /** + * Method for peeking at a packet in particular offset. This does not + * set the packet to be removed from the buffer. + * + * @since S60 v3.0 + * @param aBookKeeping a book keeping index. + * @param aReturnedData is pointer where the data is read. + * NULL if nothing found. + * @param aOffset offset of the packet to be peeked. If zero, the next + * packet in the buffer is peeked. + */ + void PeekPacket( const TInt aBookKeeping, + TPtr8& aReturnedData, + const TInt aOffset ); + + /** + * Method for asking how much packets there are in buf for certain sink. + * @since Series 60 3.0 + * @param aId a id of requester. + * @return number of packets in buffer. + */ + TInt PacketsCount( const CCRStreamingSession::TCRSinkId& aId ); + + /** + * Method for asking how much packets there are in buf in any sink. + * @since Series 60 3.0 + * @param none. + * @return minimum number of packets in buffer. + */ + TInt PacketsMinCount(); + + /** + * Method for removing a sink. + * @since Series 60 3.0 + * @param aSink is the sink to delete + * @return number of sinks remaining + */ + TInt RemoveSink( CCRPacketSinkBase* aSink ); + + /** + * Method for handle buffer wrapping. + * @since Series 60 3.0 + * @return None. + */ + void HandleBufferSize(); + + /** + * Method for handle buffer size adjust. + * @since Series 60 3.0 + * @return None. + */ + void AdjustBuffer(); + + /** + * Method for handle buffer resetting. + * @since Series 60 3.0 + * @return None. + */ + void ResetBuffer(); + +private: // Constructors and destructor + + /** + * Second pat of construction + */ + void ConstructL(); + + /** + * Default constructor is private. + * @param aMaxPackets a maximum packets count in buffer. + */ + CCRPacketBuffer( const TInt aMaxPackets ); + +private: // New methods + + /** + * Method for handling maximum packets in buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void VerifyRoom(); + + /** + * Method for taking book keeping index from sink id. + * @since Series 60 3.0 + * @param aId a id of requester. + * @return a book keeping index of sink. + */ + TInt GetBookKeeping( const CCRStreamingSession::TCRSinkId& aId ); + + /** + * Method for taking book keeping index from sink id. + * @since Series 60 3.0 + * @param aBookKeeping a book keeping index. + * @return an buffer index base on sink. + */ + TInt GetBufferIndex( const TInt aBookKeeping ); + + /** + * Method for update book keeping of the packets. + * @since Series 60 3.0 + * @param aDataLength a data length of packet. + * @return None. + */ + void PacketToBookKeeping(); + +private: // Data types + + // Book keeping array + class SBookKeeping + { + + public: // Data + + /** + * Sink id. + */ + CCRStreamingSession::TCRSinkId iId; + + /** + * Buffer index. + */ + TInt iIndex; + + }; + +private: // Data + + /** + * Maximum memory usage. + */ + const TInt iMaxPackets; + + /** + * Flow control mode. + */ + TBool iContinousStream; + + /** + * Flow control state. + */ + TBool iMoreComing; + + /** + * Buffer to keep packets. + */ + RPointerArray iBuffer; + + /** + * Keeps track of point of each user. + */ + RArray iBookKeeping; + + /** + * Zero or more packet sinks that are fed via this buffer. + */ + RPointerArray iSinkArray; + + }; + +#endif // _CCRPACKETBUFFER_H diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRPacketSinkBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRPacketSinkBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,182 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common interface for sinks* +*/ + + + + +#ifndef CCRPACKETSINKBASE_H +#define CCRPACKETSINKBASE_H + +// INCLUDES +#include +#include "CCRStreamingSession.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketBuffer; + +// CLASS DECLARATION + +/** +* Interface to sink. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRPacketSinkBase : public CBase + { + +public: // Constructors and destructors + + /** + * Destructor + */ + virtual ~CCRPacketSinkBase(); + +public: // New methods + + /** + * Connects the given buffer with this sink. + * @since Series 60 3.0 + * @param aBuffer is the buffer to connect with. + * @param aBufId a id of the buffer. + * @return none. + */ + void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * Method for setting the sdp in use. + * @since Series 60 3.0 + * @param aSdp is the new sdp. + * @return none. + */ + virtual void SetSdpL( const TDesC8& aSdp ) = 0; + + /** + * Adds packet to sink + * @since Series 60 3.0 + * @return none. + */ + virtual void NewPacketAvailable() = 0; + + /** + * Buffer reset info for the sink. + * @since Series 60 3.0 + * @return none. + */ + virtual void BufferResetDone(); + + /** + * Method that source uses to communicate its status. + * @since Series 60 3.0 + * @param aNewState is the new state of the source. + * @return none. + */ + virtual void StatusChanged( MCRPacketSource::TCRPacketSourceState aNewState ); + + /** + * Method that owner of sink may utilitze to distinguish between sinks. + * @since Series 60 3.0 + * @param none. + * @return Id that may have been set. + */ + virtual CCRStreamingSession::TCRSinkId Id( void ) const; + + /** + * Method for pause action for sink. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Pause(); + + /** + * Method for restore action for sink. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Restore(); + + /** + * Method for stopping action for sink. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + virtual void Stop(); + + /** + * method for setting initial seq+ts _before_ the stream is played. + * @since Series 60 3.0 + * @param aAudioSeq is the initial rtp seq number for audio packets. + * @param aAudioTS is the initial rtp timestamp number for audio packets. + * @param aVideoSeq is the initial rtp seq number for video packets. + * @param aVideoTS is the initial rtp timestamp number for video packets. + * @return none. + */ + virtual void SetSeqAndTS( TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ); + + /** + * method for setting play range before the stream is played. + * @param aLower is where clip range begins, in seconds. + * @param aUpper is where clip range ends, usually clip end, in seconds. + * @return none. + */ + virtual void SetRange( TReal aLower, + TReal aUpper ); + +protected: // Constructors and destructors + + /** + * Default constructor + */ + CCRPacketSinkBase( CCRStreamingSession& aSession, + CCRStreamingSession::TCRSinkId aSinkId ); + +protected: // Data + + /** + * Pointer to streaming session that owns us. + */ + CCRStreamingSession& iOwningSession; + + /** + * Buffer used by sinks. + */ + CCRPacketBuffer* iBuffer; + + /** + * Sink id, set by owner. + */ + const CCRStreamingSession::TCRSinkId iSinkId; + + }; + +#endif // CCRPACKETSINKBASE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRPacketSourceBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRPacketSourceBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common interface for sources* +*/ + + + +#ifndef MCRPACKETSOURCEBASE_H +#define MCRPACKETSOURCEBASE_H + +// INCLUDES +#include "CCRStreamingSession.h" +#include "MCRPacketSource.h" +#include "MCRConnectionObserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +// None + +/** +* Interface to source. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRPacketSourceBase : public CBase, + public MCRPacketSource + { + +public: // Constructors and destructors + + /** + * Destructor + */ + virtual ~CCRPacketSourceBase(); + +public: // Methods from base classes + + /** + * From MCRPacketSource. + * Method for setting buffers to packet source. + * @since Series 60 3.0 + * @param aBuffer is buffer to be set. + * @return none. + */ + virtual void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * From MCRPacketSource. + * Method for acquiring sdp. + * @since Series 60 3.0 + * @param aSdp is string pointer that will be .Set() to contain the sdp. + * If no sdp is available no .Set() will occur. + * @return KErrNotReady if no sdp available. + */ + virtual TInt GetSdp( TPtrC8& aSdp ) = 0; + + /** + * From MCRPacketSource. + * Method for acquiring (almost) up-to-date sequence and ts numbers. + * @since Series 60 3.0 + * @param aAudioSeq is reference to TUint that will be set by this + * method to contain latest available sequence number for + * audio stream being received via this packet source. + * @param aAudioTS rtp timestamp for audio. + * @param aVideoSeq rtp seq for video. If no video, value will not be touched. + * @param aVideoTS rtp ts for video. + * @return KErrNone if data available. + */ + virtual TInt SeqAndTS( TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ); + + /** + * From MCRPacketSource. + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return a system wide error code. + */ + virtual TInt Play( const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * From MCRPacketSource. + * Method for pausing play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Pause(); + + /** + * From MCRPacketSource. + * Method for stopping play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Stop(); + + /** + * From MCRPacketSource. + * Setter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @return a system wide error code. + */ + virtual TInt SetPosition( const TInt64 aPosition ); + + /** + * From MCRPacketSource. + * Getter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @param aDuration a duration of playback. + * @return a system wide error code. + */ + virtual TInt GetPosition( TInt64& aPosition, + TInt64& aDuration ); + + /** + * From MCRPacketSource. + * Method for getting range of stream. If no range/duration + * is available this method will set the return values to + * 0.0,-1.0 and that may be quite normal state live streams. + * @since Series 60 3.0 + * @param aLower is where to start from. + If no value available, value of aLower must be set to 0. + * @param aUpper is where to stop. Negative values mean eternity. + * @return none. + */ + virtual void GetRange( TReal& aLower, + TReal& aUpper ); + + /** + * From MCRPacketSource. + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + virtual void PostActionL(); + + /** + * From MCRPacketSource. + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + virtual void Restore(); + +public: // New methods + + /** + * Method that owner of source may utilitze to distinguish + * between sources + * @since Series 60 3.0 + * @param none. + * @return Id that may have been set. + */ + virtual CCRStreamingSession::TCRSourceId Id( void ) const; + + /** + * Registers connection observer. + * @since Series 60 3.0 + * @param aObserver aObserver. + * @return none. + */ + virtual void RegisterConnectionObs( MCRConnectionObserver* aObserver ); + +protected: // Constructors and destructors + + /** + * Default constructor + */ + CCRPacketSourceBase( CCRStreamingSession& aSession, + CCRStreamingSession::TCRSourceId aSourceId ); + +protected: // Data + + /** + * Pointer to streaming session that owns us. + */ + CCRStreamingSession& iOwningSession; + + /** + * Buffer used by sources. + */ + CCRPacketBuffer* iBuffer; + + /** + * Source id, set by owner + */ + const CCRStreamingSession::TCRSourceId iSourceId; + + }; + +#endif // MCRPACKETSOURCEBASE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRPunchPacketSender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRPunchPacketSender.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for sending a punch packet* +*/ + + + + +#ifndef __CCRPUNCHPACKRTSENDER_H +#define __CCRPUNCHPACKRTSENDER_H + +// INCLUDES +#include +#include "CCRSock.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRConnection; +class CAsyncCallBack; +class CCRRtspPacketSource; + +// CLASS DECLARATION + +/** +* Class that punches holes to firewall. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRPunchPacketSender : public CBase, public MCRSockObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCRPunchPacketSender pointer to CCRPunchPacketSender class + */ + static CCRPunchPacketSender* NewL( RConnection& aConnection, + RSocketServ& aSockServer, + TInetAddr& aFromAddr, + TInetAddr& aRemoteAddr , + TUint32 aMySSRC, + CCRRtspPacketSource& aOwner ); + + /** + * Destructor. + */ + virtual ~CCRPunchPacketSender( ); + +private: // Methods from base classes + + /** + * From MCRSockObserver. + * This method is called after some data has been received from socket. + * @since Series 60 3.0 + * @param aData is descriptor containing the data received. + * ownership of data is not passed via this call. + * @return none. + */ + void DataReceived( TInt aSockId, + const TDesC8 &aData ); + + /** + * From MCRSockObserver. + * This method is called after status of socket changes. + * @since Series 60 3.0 + * @param aStatus is sock status. + * @return none. + */ + void SockStatusChange( TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ); + +private: + + /** + * Default constructor. + * @param aConnection a connection. + * @param aSockServer a socket server. + * @param aFromAddr a address. + * @param aRemoteAddr + * @param aMySSRC + * @param aOwner + */ + CCRPunchPacketSender( RConnection& aConnection, + RSocketServ& aSockServer, + TInetAddr& aFromAddr, + TInetAddr& aRemoteAddr , + TUint32 aMySSRC, + CCRRtspPacketSource& aOwner ); + + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // new methods + + /** + * Method that is called when this instace is finishing business. + * @since Series 60 3.0 + * @param aSelf + * @return TInt + */ + static TInt CleanupCallBack ( TAny* aSelf ); + +private: // Data types + + /** + * Connection. + */ + RConnection& iConnection; + + /** + * Socket server. + */ + RSocketServ& iSockServer; + + /** + * Socket 1. + */ + CCRSock* iSock1; + + /** + * Socket 2 + */ + CCRSock* iSock2; + + /** + * Address. + */ + TInetAddr iFromAddr; + + /** + * Remote address. + */ + TInetAddr iRemoteAddr; + + /** + * Sender report. + */ + TUint32 iMySSRC; + + /** + * Owner. + */ + CCRRtspPacketSource& iOwner; + + /** + * Asyncronic cleanup. + */ + CAsyncCallBack* iCleanUp; + + /** + * Socket 1 state. + */ + TBool iSentViaSock1; + + /** + * Socket 2 state. + */ + TBool iSentViaSock2; + + }; + +#endif // __CCRPUNCHPACKRTSENDER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRTSPCommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRTSPCommand.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,310 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for parsing and producing a command string* +*/ + + + + +#ifndef CCRRTSPCOMMAND_H +#define CCRRTSPCOMMAND_H + +// INCLUDES +#include "CRRtspCommon.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class that parses and produces rtsp commands as in rfc2326. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtspCommand : public CCRRtspCommon + { + +public: // Data types + + /** + * Enum for subset of RTSP commands + */ + enum TCommand + { + ERTSPCommandPLAY = 0, /**< Command for triggering clip that has been SETUP */ + ERTSPCommandPAUSE, /**< Command for pausing a clip that is already playing */ + ERTSPCommandTEARDOWN, /**< Command for quitting a session */ + ERTSPCommandOPTIONS, /**< No operation, except ping */ + ERTSPCommandDESCRIBE, /**< Command for acquiring an SDP */ + ERTSPCommandSETUP, /**< Command for setting up audio or video stream */ + ERTSPCommandNOCOMMAND /**< init value, no-operation */ + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCRRtspCommand pointer to CCRRtspCommand class. + */ + static CCRRtspCommand* NewL(); + + /** + * Destructor. + */ + virtual ~CCRRtspCommand( ); + +public: // New functions + + /** + * Method that is used to give rtsp command to this class. + * command is something alike: + * "PLAY rtsp://vishnu.wipsl.com/oops/winter_fun.mp4/ RTSP/1.0\r\n..." + * @since Series 60 3.0 + * @param aString is the response string + * @return none. + * May leave with symbian error codes. At least following may be + * seen: KErrUnderflow if there is \r\n\r\n sequence in the string + * marking end of response or if there is content (like SDP) and the + * content lenght is too short; KErrNotSupported if it doesn't look + * like RTSP at all. + */ + void TryParseL( const TDesC8 &aString ); + + /** + * Method for getting URL. + * @since Series 60 3.0 + * @param aURL is string descriptor allocated by caller that + * will have its content set to block allocated by instance + * of this class containing the session id. + * @return KErrNone if no error, KErrNotFound if URL is not there. + */ + TInt URL( TPtrC8& aURL ); + + /** + * Method for setting URL. + * @since Series 60 3.0 + * @param aURL is string descriptor allocated by caller. + * @return none. + */ + void SetURL( const TDesC8& aURL ); + + /** + * Method for setting command. + * @since Series 60 3.0 + * @param aCommand is the command that will be set. + * @return none. + */ + void SetCommand( TCommand aCommand ); + + /** + * Method for setting authentication info. + * @since Series 60 3.0 + * @param aAuth is ETrue if authentication is to be used. + * When constructing command string, authentication headers + * will be added. See also SetUserNameL et al. + * @return none. + */ + void SetAuthentication( TBool aAuth ); + + /** + * Sets identification string to be sent as 'UserAgent' header. + * No header is sent if not identification is not set. + * @since Series 60 3.0 + * @param aUserAgent user agent identification. + * @return none. + */ + void SetUserAgentL( const TDesC8& aUserAgent ); + + /** + * Sets connection bandwidth to be sent as 'Bandwidth' header. + * No header is sent if bandwidth is not set. + * @since Series 60 3.0 + * @param aBandwidth connection bandwidth in bit/s. + * @return none. + */ + void SetBandwidth( TInt aBandwidth ); + + /** + * Sets profile identification for 'x-wap-profile' header. + * @since Series 60 3.0 + * No header is sent if identification is not set. + * @param aWapProfile profile identification. + * @return none. + */ + void SetWapProfileL( const TDesC8& aWapProfile ); + + /** + * Method for getting command. + * @since Series 60 3.0 + * @param none. + * @return the command. + */ + CCRRtspCommand::TCommand Command( void ) const; + + /** + * Method that does opposite of parse: it produces a RTSP command. + * @since Series 60 3.0 + * @param none. + * @return string descriptor containing the command + */ + TPtrC8& ProduceL( void ); + + /** + * Appends string to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aTxt a string to append. + * @return none. + */ + void AppendL( HBufC8*& aBuffer, + const TDesC8& aTxt ); + + /** + * Appends integer value as text to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aNum a numerical value to append. + * @return none. + */ + void AppendNumL( HBufC8*& aBuffer, + const TInt aNum ); + + /** + * Appends formatted text to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aFmt a format string to use. + * @return none. + */ + void AppendFormatL( HBufC8*& aBuffer, + TRefByValue aFmt, ... ); + +private: // Constructors and destructors + + /** + * default constructor + */ + CCRRtspCommand(); + + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // new methods: + + /** + * Method for finding the URL this command is about + * @since Series 60 3.0 + * @param none. + * @return none but will leave with KErrNotSupported + * if it doesn't look like RTSP + */ + void FindURLL( void ); + + /** + * Generates authentication header iAuthHeader using given values. + * Method described in RFC 2069 "An Extension to HTTP : Digest Access + * Authentication". + * @since Series 60 3.0 + * @param aMethod Method name (e.g. "DESCRIBE" / "SETUP" / etc.) + */ + void CalculateDigestResponseL( const TDesC8& aMethod ); + + /** + * Generates authentication header iAuthHeader using given values. + * Method described in RFC 2617 "HTTP Authentication: Basic and Digest + * Access Authentication". + * @since Series 60 3.0 + * @param aMethod Method name (e.g. "DESCRIBE" / "SETUP" / etc.) + */ + void CalculateBasicResponseL( const TDesC8& aMethod ); + + /** + * Calculates MD5 hash of the message. + * @since Series 60 3.0 + * @param aMessage Message. + * @param aHash On return, contains message hash. + */ + void HashL( const TDesC8& aMessage, TDes8& aHash ); + +private: // Data + + /** + * What command this is. + */ + TCommand iCommand; + + /** + * What is the URL that this command is about. + */ + TPtrC8 iURL; + + /** + * String descriptor that we retur with ProduceL. + */ + TPtrC8 iProductDescriptor; + + /** + * Authentication header. + */ + HBufC8* iAuthHeader; + + /** + * MD5 message digest class. Required for HTTP digest authentication. + */ + CMD5* iMD5Calculator; + + /** + * If authentication is needed. + */ + TBool iAuthenticationNeeded; + + /** + * User Agent header if present. + */ + HBufC8* iUserAgent; + + /** + * Connection bandwidth in bit/s for 'Bandwidth' header. + */ + TInt iBandwidth; + + /** + * Bandwidth present. + */ + TBool iBandwidthAvailable; + + /** + * x-wap-profile if present. + */ + HBufC8* iWapProfile; + + }; + +#endif // CCRRTSPCOMMAND_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRTSPPacketSource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRTSPPacketSource.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1052 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that negotiaties RTP stream using RTSP* +*/ + + + + +#ifndef CCRRTSPPACKETSOURCE_H +#define CCRRTSPPACKETSOURCE_H + +// INCLUDES +#include "CCRPacketSourceBase.h" +#include "CCRStreamingSession.h" +#include "CCRConnection.h" +#include "CCRRtspResponse.h" +#include "CCRRtpTcpObserver.h" +#include "CCRSock.h" +#include "MCRTimerObserver.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRRtspCommand; +class CDvrSdpParser; +class RRtpSession; +class RRtpReceiveSource; +class TRtpEvent; +class CCRTimer; +class CCRPunchPacketSender; +class CCRRtpTcpStreamer; + +// CLASS DECLARATION + +/** +* Class that negotiaties RTP stream using RTSP. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtspPacketSource : public CCRPacketSourceBase, + public MCRSockObserver, + public MCRRtpTcpObserver, + public MCRConnectionObserver, + public MCRTimerObserver + { + +public: // Data types + + /** + * RTP packet memory layout structure + */ + struct TCRRtpMessageHeader + { + TUint iVersion:2; + TUint iPadding:1; + TUint iExtension:1; + TUint iCsrcCount:4; + TUint iMarker:1; + TUint iPayloadType:7; + TUint iSeq:16; + TUint32 iTimestamp; + TUint32 iSSRC; + }; + + /** + * RTCP sender report memory layout + */ + struct TCRRtpSRReportHeader + { + // Note the order of first 3 items: + unsigned char iReportCount:5; // this and + unsigned char iPadding:1; // this and + unsigned char iVersion:2; // this are first 8 bits. + // Note that above order is reversed from spec. + unsigned char iPacketType; + TUint16 iLength; + TUint32 iSenderSSRC; + TUint32 iMSWTimestamp; + TUint32 iLSWTimestamp; + TUint32 iRTPTimestamp; + TUint32 iSenderPacketCount; + TUint32 iSenderOctetCount; + }; + + /** + * Enum for identifying sockets. Sockets return this via Id() + * and this is also used as an array index. + */ + enum TCRRTPSockId + { + ERTPControl=0, /**< placeholder for RTSP sock */ + ERTPVideoSend1, /**< RTP video payload */ + ERTPVideoSend2, /**< RTCP video */ + ERTPAudioSend1, /**< RTP audio payload */ + ERTPAudioSend2, /**< RTCP audio */ + ERTPMaxSockets /**< Just max value, no real socket assigned for this */ + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * Calling this method will finally cause a call to DoConnectL() so + * this class will start connecting as soon as it is constructed, + * address where to connect to is in aParams. + * @param aParams is the stream address + * @param aConnection is handle to RConnection wrapper to use + * @param aSessionObs is pointer to our observer + * @aOwningSession is the streaming session that owns this packet source + * @return CCRRtspPacketSource pointer to CCRRtspPacketSource class + */ + static CCRRtspPacketSource* NewL( const SCRRtspParams& aParams, + CCRConnection& aConnection, + RSocketServ& aSockServer, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor. + */ + virtual ~CCRRtspPacketSource(); + +public: // New functions + + /** + * Method for aquiring the URI being streamed here + * @since Series 60 3.0 + * @param none. + * @return URI. + */ + TPtr URI(); + + /** + * Method that packet puncher calls to tell + * it has finished punching the firewall. + * @since Series 60 3.0 + * @param aPuncher tells the number of the port + * where the punch packet was sent to. + * @return none. + */ + void PunchPacketsSent( CCRPunchPacketSender* aPuncher ); + + /** + * Method for setting observer that this source will report its status to. + * @since Series 60 3.0 + * @param aObserver is the observer instance implementing MCRConnectionObserver. + * @return none. + */ + void RegisterConnectionObs( MCRConnectionObserver* aObserver ); + + /** + * Method for removing status observer + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void UnregisterConnectionObs(); + +public: // Methods from base classes + + /** + * From CCRPacketSourceBase. + * Method for acquiring sdp. + * @since Series 60 3.0 + * @param aSdp is string pointer that will be .Set() to contain the sdp. + * If no sdp is available no .Set() will occur. + * @return KErrNotReady if no sdp available. + */ + TInt GetSdp( TPtrC8& aSdp ); + + /** + * From CCRPacketSourceBase. + * Method for acquiring (almost) up-to-date sequence and ts numbers. + * @since Series 60 3.0 + * @param aAudioSeq is reference to TUint that will be set by this + * method to contain latest available sequence number for + * audio stream being received via this packet source. + * @param aAudioTS rtp timestamp for audio. + * @param aVideoSeq rtp seq for video. If no video, value will not be touched. + * @param aVideoTS rtp ts for video. + * @return KErrNone if data available. + */ + TInt SeqAndTS( TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ); + + /** + * From CCRPacketSourceBase. + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void PostActionL(); + + /** + * From CCRPacketSourceBase. + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return a system wide error code. + */ + TInt Play( const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * From CCRPacketSourceBase. + * Method for pausing play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Pause(); + + /** + * From CCRPacketSourceBase. + * Method for stopping play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Stop(); + + /** + * From CCRPacketSourceBase. + * Method for getting range of stream. If no range/duration + * is available this method will set the return values to + * 0.0,-1.0 and that may be quite normal state live streams. + * @since Series 60 3.0 + * @param aLower is where to start from. If no value available, + * value of aLower must be set to 0 + * @param aUpper is where to stop. Negative values mean eternity. + * @return none. + */ + void GetRange( TReal& aLower, + TReal& aUpper ); + + /** + * From CCRPacketSourceBase. + * Setter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @return a system wide error code. + */ + virtual TInt SetPosition( const TInt64 aPosition ) ; + + /** + * From MCRSockObserver. + * This method is called after some data has been received from socket. + * @since Series 60 3.0 + * @param aSockId identifies the socket where the data came from. + * @param aData is descriptor containing the data received. + * ownership of data is not passed via this call. + * @return none. + */ + void DataReceived( TInt aSockId, + const TDesC8& aData ); + + /** + * From MCRSockObserver. + * This method is called after status of socket changes. + * @since Series 60 3.0 + * @param aSockId Identifies the socket that had the status change + * @param aStatus is the new status of the sock + * @param aError if aStatus was an error-status, this may contain error code + * @return none. + */ + void SockStatusChange( TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ); + + /** + * From MCRRtpTcpObserver. + * Signals an available incoming RTSP control message + * @since Series 60 3.0 + * @param aData a RTSP meaage data. + * @return none. + */ + void RtspMsgAvailable( const TDesC8& aData ); + + /** + * From MCRRtpTcpObserver. + * Receives a RTP/RTCP packet available from TCP streamer and + * forwards to streaming sessions (buffers). + * @since Series 60 3.0 + * @param aChannel specifies channel if in TCP streaming case, in practice + * tells if it is a video/audio packet and if it is RTP or RTCP. + * @param aPacket is the payload of the packet + * @return none. + */ + void RtpTcpPacketAvailable( TInt aChannel, + const TDesC8& aPacket ); + + /** + * From MCRRtpTcpObserver. + * Receives a RTP/RTCP packet and forward to streaming server + * @since Series 60 3.0 + * @param aChunk contains RTP packet with headers suitable to be sent to remote + * via RTSP control socket. + * @return none. + */ + void ForwardRtpTcpChunck( const TDesC8& aChunk ); + + /** + * From MCRConnectionObserver. + * receives notifications of connection status changes, + * used to clear heuristics on streaming capabilities. + * @since Series 60 3.0 + * @param aSessionId a session id. + * @param aStatus is the new status of the connection. + * @param aErr contains error code if new status is failure status. + * @return none. + */ + void ConnectionStatusChange( TInt aSessionId, + TCRConnectionStatus aStatus, + TInt aErr ); + + /** + * From MCRTimerObserver. + * The function to be called when a timeout occurs. + * @since Series 60 3.0 + * @param aTimer is pointer to timer instance that caused call to this method. + * @return none. + */ + void TimerExpired( CCRTimer* aTimer ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @param aConnection is RConnection wrapper to use. + * @param aSockServer is socket server to use when opening sockets. + * @param aSessionObs is pointer to our observer. + * @param aOwningSession is pointer to session that owns this source. + */ + CCRRtspPacketSource( CCRConnection& aConnection, + RSocketServ& aSockServer, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * By default Symbian 2nd phase constructor is private. + * @aParams aParams contains stream address parameters that this packet source + * will try to use to obtain the stream. + * @return none + */ + void ConstructL( const SCRRtspParams& aParams ); + +private: // New methods + + /** + * Method for connecting. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoConnectL(); + + /** + * Method for cleaning up. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CleanUp(); + + /** + * Method for initiating cleanup. + * @since Series 60 3.0 + * @param aSelfPtr is pointer to "this". + * @return none. + */ + static TInt CleanUpCallback( TAny* aSelfPtr ); + + /** + * Method for asking for cleanup in async way. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCleanup(); + + /** + * Method for sending RTSP command. Command in question depends on state. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendRtspCommandL(); + + /** + * Method for parsing and reacting to RTSP reply. + * @since Series 60 3.0 + * @param aData a RTSP response data. + * @return none. + */ + void ProcessRtspResponseL( const TDesC8& aData ); + + /** + * Method for parsing and reacting to RTSP command that + * remote server may send to us + * @since Series 60 3.0 + * @param aData a RTSP response data. + * @return none. + */ + void ProcessRTSPCommandL( const TDesC8& aData ); + + /** + * Method for sending error indication to client side + * if rtsp response was something errorneous. + * @since Series 60 3.0 + * @param aErrorCode is RTSP response code,something else than 200 OK. + * @return none. + */ + void ProcessRtspErrorResponseL( CCRRtspResponse::TResponseCode aErrorCode ); + + /** + * Method for doing SETUP. + * @since Series 60 3.0 + * @param aControlAddr is either absolute or relative controladdr for stream. + * @param aForAudio is ETrue if control addr is for audio. + * @return client port number. + */ + TInt SendSetupCommandL( const TDesC8& aControlAddr, + TBool aForAudio ); + + /** + * Method for doing PLAY. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendPlayCommandL(); + + /** + * Method for doing PAUSE that is sent to remote server. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendPauseCommandL(); + + /** + * Method for doing OPTIONS ping that is sent to remote server. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendOptionsCommandL(); + + /** + * Method for doing TEARDOWN. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendTearDownCommandL(); + + /** + * Method that sets up rtp sessions. Must be called before play is issued. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + TInt SetupRTPSessions(); + + /** + * Method that starts RTSP command response timeout. + * @since Series 60 3.0 + * @param aTime a timer interval. + * @return none. + */ + void StartRtspTimeout( TTimeIntervalMicroSeconds32 aTime ); + + /** + * Callback method from RTP session for audio. + * @since Series 60 3.0 + * @param aPtr is pointer to "this". + * @param aEvent is the event. In practice it contains RTP packet or RTCP packet. + * @return none. + */ + static void AudioRTPCallBack( CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent ); + + /** + * Callback method from RTP session for video. + * @since Series 60 3.0 + * @param aPtr is pointer to "this". + * @param aEvent is the event. In practice it contains RTP packet or RTCP packet. + * @return none. + */ + static void VideoRTPCallBack( CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent ); + + /** + * Callback for RTSP timeout. Just ask session to start cleanup. + * @since Series 60 3.0 + * @param aPtr is pointer to "this". + * @return none. + */ + static TInt RtspTimeoutCallback( TAny* aPtr ); + + /** + * Method for creating sender report header. + * @param aPtr is pointer to "this". + * @param aEvent is the rtp packet event received. + * @param aStreamId a stream id. + * @return none + */ + static void SenderReport( CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent, + MCRPacketSource::TCRPacketStreamId aStreamId ); + + /** + * Method for handling audio. + * @param aPtr is pointer to "this". + * @param aSource a receiver source. + * @param aEvent is the rtp packet event received. + * @return none + */ + static void HandleNewSourceL( CCRRtspPacketSource* aPtr, + RRtpReceiveSource& aSource, + const TRtpEvent& aEvent, + TRtpCallbackFunction aCallback ); + + /** + * Generate DESCRIBE message with authentication information. + * used when server responses with 401 or 407. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendAuthDescribeL(); + + /** + * Adds authentication info to given command. + * @since Series 60 3.0 + * @param aCommand the command where to add authentication info. + * @return none. + */ + void AddAuthenticationL( TInt aCommand ); + + /** + * Setup sessions for RTP stack and issue play command + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SetupSessionsAndPlay(); + + /** + * Initiates sending of punch packets + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendPunchPacketsL(); + + /** + * Creates a socket in iRTPSockArr for multicast streaming: + * binds to local port and join multicast group + * + * @since Series 60 3.0 + * @param aSockId id for RTP socket in iRTPSockArr + * @param aGroupAddr multicast group address, in IPv6 or mapped IPv4 + * @param aPort local UDP port to listen + * @return system error code + */ + TInt CreateMulticastSocket( TCRRTPSockId aSockId, + const TInetAddr& aGroupAddr, + TInt aPort ); + + /** + * Creates a socket in iRTPSockArr for unicast streaming: + * binds to local port and connects to remote address + * + * @since Series 60 3.0 + * @param aSockId id for RTP socket in iRTPSockArr + * @param aLocalAddr local address and port to listen + * @param aRemoteAddr remote address and port to connect to + * @return system error code + */ + TInt CreateUnicastSocket( TCRRTPSockId aSockId, + const TInetAddr& aLocalAddr, + const TInetAddr& aRemoteAddr ); + + /** + * Method that handles rtp payload packet to buffer. + * @since Series 60 3.0 + * @param aEvent is the rtp packet event received. + * @param aIsAudio indicates whether this is audio or video packet. + * @return none. + */ + void RTPPayloadProcessor ( const TRtpEvent& aEvent, + const TBool aIsAudio ); + + /** + * Method for setting session parameters. + * @since Series 60 3.0 + * @param aSession is reference to either audio or video rtp session. + * from instance variables of this class ; the parameters will + * be set in similar way for both audio and video + * @param aGranularity is number of clock ticks per second, usually found from SDP + * @return none. + */ + void SetRtpSession( RRtpSession& aSession , + TReal aGranularity ); + + /** + * Method for initiating cleanup. + * @since Series 60 3.0 + * @param aSelfPtr is pointer to "this". + * @return symbian error code. + */ + static TInt SendRtspPing( TAny* aSelfPtr ); + + /** + * Method for synchronizing of timestamps and notifying sinks. + * This should be called after sender reports are received + * and with normal packet reception in the beginning of the stream. + * In practice this will be called for about every packet while + * iNoRtpInfoHeader is on, when we know the seq+ts then + * iNoRtpInfoHeader will be turned off and this method will be no longer + * used ; detection of no rtp info header in rtsp play reply will turn + * iNoRtpInfoHeader on. + * + * @param aStreamId identifies the stream + * @param aMSWTimestamp more significant part of wall-clock. Seconds. + * @param aLSWTimestamp less significant part of wall-clock. Fraction of seconds. + * @param aRTPTimestamp rtptimestamp of aMSW+aLSWTimestamp + * @param aSeq sequence number of aRTPTimestamp + */ + void ConstructSeqAndTsForSink ( MCRPacketSource::TCRPacketStreamId aStreamId, + TUint32 aMSWTimestamp, + TUint32 aLSWTimestamp, + TUint32 aRTPTimestamp, + TUint aSeq ); + + /** + * Method for setting up multicast or tcp streaming from setup reply. + * @param none + * @return none + */ + void ConditionallySetupMultiCastOrTcpStreamingL(); + + /** + * Method checks that we all receiveing from all streams, if not returns false. + * @param none + * @return ETrue if receiving from all streams. + */ + TBool CheckReceiveOfStreams(); + + /** + * Method that flags given stream as receiving stream. + * @param aStreamType stream that is receiving + * @return none + */ + void StreamFound( TCRPacketStreamId aStreamType ); + + /** + * Method that resets all created receive streams as non receiving. + * @param none + * @return none + */ + void ResetStreamFlags(); + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + /** + * Method for showing a packet header. + * @since Series 60 3.0 + * @param aRtcpHeader a pointer to packet header. + * @param aEvent is the rtp packet event received. + * @return none. + */ + static void ShowHeader( const TDesC8& aRtcpHeader, + const TCRRtpSRReportHeader& aSrReport ); +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + +private: // Data + + /** + * rtsp URL we're supposed to view. + */ + HBufC* iRtspUri; + + /** + * Hostname -part of iRTSPURI. + */ + TPtrC iRtspUriHost; + /** + * rtsp URL in 8bit descriptor, only because there is no uri parser in 8 bit. + */ + HBufC8* iRtspUri8; + /** + * possible username, if server requires. + */ + HBufC* iUserName; + + /** + * possible password, if server requires. + */ + HBufC* iPassword; + + /** + * Sequence number from rtp info header concerning audio. + */ + TUint iSeqFromRtpInfoForAudio; + + /** + * Sequence number from rtp info header concerning video. + */ + TUint iSeqFromRtpInfoForVideo; + + /** + * RTP Session for audio. + */ + RRtpSession iAudioSession; + + /** + * RTP Session for video. + */ + RRtpSession iVideoSession; + + /** + * Receive stream for audio. + */ + RRtpReceiveSource iRtpRecvSrcAudio; + + /** + * Receive stream for audio. + */ + RRtpReceiveSource iRtpRecvSrcVideo; + + /* + * Socket server reference ; all sockets we use must be via common sock serv. + */ + RSocketServ& iSockServer; + + /* + * RConnection wrapper reference ; all sockets we use must share an RConnection. + */ + CCRConnection& iConnection; + + /* + * Socket to use to talk RTSP to remote server. + */ + CCRSock* iRtspSock; + + /** + * Sockets for incoming multicast RTP data, to bypass RTP stack limitations. + */ + CCRSock* iRTPSockArr[ERTPMaxSockets]; + + /** + * pointer to data sent by us via socket. + */ + HBufC8* iSentData; + + /** + * State of this rtsp client, or stage in discussion. + */ + TCRRTSPStage iStage; + + /** + * Pointers to previous commands sent in various stages. + */ + CCRRtspCommand* iPrevCommands[ERTSPLastStage]; + + /** + * Pointers to responses of various commands. + */ + CCRRtspResponse* iResponses[ERTSPLastStage]; + + /** + * CSeq for rtsp negotiation. + */ + TInt iCSeq; + + /** + * SDP parser. + */ + CDvrSdpParser* iSdpParser; + + /** + * Client portbase. Value used for video, for audio it is this value + 2. + */ + TInt iClientPort; + + /** + * Transport method for RTP. + */ + TCRRTPTransport iTransport; + + /** + * Timer for UDP reception timeout, to fire TCP usage. + */ + CCRTimer* iUdpReceptionTimer; + + /** + * IP packet parser. + */ + CCRRtpTcpStreamer* iRtpTcpStreamer; + + /** + * Session id from server. + */ + TPtrC8 iSessionId; + + /** + * If sink is ready. + */ + TBool iReadyToPlay; + + /** + * RTP time initial value for audio. + */ + TUint32 iRTPTimeStampAudio; + + /** + * RTP time initial value for video. + */ + TUint32 iRTPTimeStampVideo; + + /** + * If authentication is needed. + */ + TBool iAuthenticationNeeded; + + /** + * Nonce of the authentication header. + */ + HBufC8* iNonce; + + /** + * Realm of the authentication header. + */ + HBufC8* iRealm; + + /** + * Authentication type ("Basic" or "Digest"). + */ + HBufC8* iAuthType; + + /** + * Opaque of the authentication header. + */ + HBufC8* iOpaque; + + /** + * User Agent header if present. + */ + HBufC8* iUserAgent; + + /** + * Connection bandwidth in bit/s for 'Bandwidth' header. + */ + TInt iBandwidth; + + /** + * x-wap-profile if present. + */ + HBufC8* iWapProfile; + + /** + * Number of times authentication has failed. + */ + TInt iAuthFailedCount; + + /** + * Our observer. + */ + MCRStreamObserver& iSessionObs; + + /** + * Number of bytes sent in audio rtp packets. + */ + TUint32 iAudioBytes; + + /** + * Number os audio rtp packets sent. + */ + TUint32 iAudioPackets; + + /** + * Number of bytes sent in video rtp packets. + */ + TUint32 iVideoBytes; + + /** + * Number of video packets sent. + */ + TUint32 iVideoPackets; + + /** + * Instance for punch packet sender ; lifetime will be from setup stage + * to delivery of first audio packet. + */ + CCRPunchPacketSender* iPunchPacketSenderAudio; + + /** + * Instance for punch packet sender ; lifetime will be from setup stage + * to delivery of first video packet. + */ + CCRPunchPacketSender* iPunchPacketSenderVideo; + + /** + * Flag for successful sending of punch packets for audio stream. + */ + TBool iPunchPacketSentForAudio; + + /** + * Flag for successful sending of punch packets for video stream. + */ + TBool iPunchPacketSentForVideo; + + /** + * Connection status observer. + */ + MCRConnectionObserver* iObserver; + + /** + * Position where playback will start. Usually will have value 0 but will + * be changed if user seeks the clip. + */ + TReal iStartPos; + + /** + * Position where playback is supposed to end. Most streaming servers won't + * obey this at all but rtsp gives possibility to specify end position so + * we'll support that anyway. + */ + TReal iEndPos; + + /** + * Sends RTSP ping. + */ + CPeriodic* iRtspPingTimer; + + /** + * Timer started when RTSP message is sent and cancelled when reply is received. + * If this timer fires, it means that we didn't get reply in time that in turn + * forces cleanup of this source. + */ + CPeriodic* iRtspTimeout; + + /** + * Sequence number of last rtsp reply received. + */ + TInt iLastReceivedSeq; + + /** + * We have a play-command pending, not yet sent. + */ + TInt iPostPonedPlay; + + /** + * Proxy server addr to use while streaming. + */ + TName iProxyServerAddr; + + /** + * Proxy server port to use while streaming. + */ + TInt iProxyServerPort; + + /** + * Flag telling that there has been no rtp-info header. + * in play-response + */ + TBool iNoRtpInfoHeader; + + /** + * Wall-clock timestamp MSW part for syncronizing. + */ + TUint32 iMSWTimestamp; + + /** + * Wall-clock timestamp LSW part for syncronizing. + */ + TUint32 iLSWTimestamp; + + /** + * Flag set when we manage to get UDP traffic. If we some reason loose + * traffic completely (eg staying too long in PAUSE -state while streaming) + * we dont try TCP at first but after we have tried UDP again. + */ + TBool iUdpFound; + + /** + * Simple container class representing one receive stream. + */ + class TReceiveStream + { + public: + + /** + * Default constructor setting default values. + */ + TReceiveStream() + { + iStreamType = EStreamIdCount; + iDataReceived = EFalse; + }; + + /** + * Stream type, defined in MCRPacketSource. + */ + TCRPacketStreamId iStreamType; + + /** + * Boolean flagging if we have traffic from this stream. + */ + TBool iDataReceived; + }; + + /** + * Array of receive streams. + */ + RArray iReceiveStreams; + + /** + * Boolean flagging if we have found traffic from all receive streams. + */ + TBool iTrafficFound; + + }; + +#endif // CCRRTSPPACKETSOURCE_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRTSPResponse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRTSPResponse.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,261 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for parsing and producing a response string of RTSP as rfc2326* +*/ + + + + +#ifndef CCRRTSPRESPONSE_H +#define CCRRTSPRESPONSE_H + +// INCLUDES +#include "CRRtspCommon.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class for parsing and producing RTSP responses. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtspResponse : public CCRRtspCommon + { + +public: // Data types + + /** + * RTSP response code. From RFC 2326 + */ + enum TResponseCode + { + ERTSPRespContinue = 100, + ERTSPRespOK = 200, /**< OK code, everything ok */ + ERTSPRespCreated = 201, /**< Same as 200 */ + ERTSPRespLowOnStorageSpace = 250, + ERTSPRespMultipleChoices = 300, + ERTSPRespMovedPermanently = 301, + ERTSPRespMovedTemporarily = 302, + ERTSPRespSeeOther = 303, + ERTSPRespNotModified = 304, + ERTSPRespUseProxy = 305, + ERTSPRespBadRequest = 400, + ERTSPRespUnauthorized = 401 , /**< We must re-issue command with authentication headers */ + ERTSPRespPaymentRequired = 402, + ERTSPRespForbidden = 403, + ERTSPRespNotFound = 404, + ERTSPRespMethodNotAllowed = 405, + ERTSPRespNotAcceptable = 406, + ERTSPRespProxyAuthenticationRequired = 407 , /**< We must re-issue command with authentication headers */ + ERTSPRespRequestTimeOut = 408, + ERTSPRespGone = 410, + ERTSPRespLengthRequired = 411, + ERTSPRespPreconditionFailed = 412, + ERTSPRespRequestEntityTooLarge = 413, + ERTSPRespRequestURITooLarge = 414, + ERTSPRespUnsupportedMediaType = 415, + ERTSPRespParameterNotUnderstood = 451, + ERTSPRespConferenceNotFound = 452, + ERTSPRespNotEnoughBandwidth = 453, + ERTSPRespSessionNotFound = 454, + ERTSPRespMethodNotValidInThisState = 455, + ERTSPRespHeaderFieldNotValidForResource = 456, + ERTSPRespInvalidRange = 457, + ERTSPRespParameterIsReadOnly = 458, + ERTSPRespAggregateOperationNotAllowed = 459, + ERTSPRespOnlyAggregateOperationAllowed = 460, + ERTSPRespUnsupportedTransport = 461, + ERTSPRespDestinationUnreachable = 462, + ERTSPRespInternalServerError = 500, + ERTSPRespNotImplemented = 501, + ERTSPRespBadGateway = 502, + ERTSPRespServiceUnavailable = 503, + ERTSPRespGatewayTimeOut = 504, + ERTSPRespRTSPVersionNotSupported = 505, + ERTSPRespOptionNotSupported = 551 + }; + + /** + * Structure for storing rtp-info header contents. + * if len of iFirstURL is zero, then the header has + * not been seen or parsed. Normally rtp-info-header + * has 2 urls and seq+ts for both. + */ + struct SRTPInfoHeader + { + TPtrC8 iFirstURL ; /**< URL string of first url found from header */ + TUint iFirstSeq ; /**< Seq of first URL */ + TUint iFirstTS ; /**< TS of first URL */ + TPtrC8 iSecondURL ;/**< URL string of second url found from header */ + TUint iSecondSeq ; /**< Seq of second URL */ + TUint iSecondTS ; /**< TS of second URL */ + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCRRtspResponse pointer to CCRRtspResponse class + */ + static CCRRtspResponse* NewL(); + + /** + * Destructor. + */ + virtual ~CCRRtspResponse(); + +public: // New functions + + /** + * Method that is used to give rtsp response to this class. + * Response is something alike "RTSP/1.0 200 OK\rCSeq: 200000\r..." + * @since Series 60 3.0 + * @param aString is the response string. + * @return none. May leave with symbian error codes. At least following may be + * seen: KErrUnderflow if there is \r\n\r\n sequence in the string + * marking end of response or if there is content (like SDP) and the + * content lenght is too short; KErrNotSupported if it doesn't look + * like RTSP at all. + */ + virtual void TryParseL( const TDesC8 &aString ); + + /** + * Method for acquiring the response code from command string that was successfully + * parsed. If TryParseL did leave, this may return anything. + * @since Series 60 3.0 + * @param none. + * @return response code, like ERTSPRespOK if it was 200 OK. + */ + CCRRtspResponse::TResponseCode StatusCode( void ); + + /** + * Method for getting server port. + * @since Series 60 3.0 + * @param none. + * @return server port of KErrNotFound if none found. + */ + TInt ServerPort( void ); + + /** + * Method for getting SSRC. + * @since Series 60 3.0 + * @param aSSRC is string descriptor allocated by caller that + * will have its content set to block allocated by instance + * of this class containing the SSRC. + * @return KErrNone if no error, KErrNotFound if SSRC is not there. + */ + TInt SSRC( TPtrC8& aSSRC ); + + + /** + * Method for getting RTP-Info header. + * @since Series 60 3.0 + * @param aRTPInfoHeader is header struct allocated by caller that + * will have its content set to strings (and numbers) allocated + * by instance of this class so once instance of this class + * is deleted, it is not wise to try referring to those + * values any more. + * @return KErrNone if no error, + KErrNotFound if rtp-info header is not there. + */ + TInt RTPInfoHeader( CCRRtspResponse::SRTPInfoHeader &aRTPInfoHeader ); + +protected: // New Methods + + /** + * Method for digging out server ports from (setup) reply + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindServerPorts( void ); + + /** + * Method for digging out SSRC from (setup) reply + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindSSRC( void ); + + /** + * Method for digging out and partially parsing RTP-Info -header + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindRTPInfoHeader( void ); + + /** + * Method for digging out and partially parsing RTP-authentication -header + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindRTPAuthenticationL( void ); + +private: // Constructors and destructors + + /** + * default constructor + */ + CCRRtspResponse( void ); + + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // Data types + + /** + * Code how the command went. + */ + TResponseCode iStatusCode; + + /** + * Possible server port. + */ + TInt iServerPort; + + /** + * Possible synchronization source id. + */ + TPtrC8 iSSRC; + + /** + * Possible contents of rtp info header. + */ + SRTPInfoHeader iRTPInfoHeader; + + }; + +#endif // CCRRTSPRESPONSE_H + +// End of file + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtpFileSource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtpFileSource.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,268 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that reads RTP packets from propriatary file format.* +*/ + + + + +#ifndef CCRRTPFILESOURCE_H +#define CCRRTPFILESOURCE_H + +// INCLUDES +#include "CCRPacketSourceBase.h" +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpClipHandler; + +// CLASS DECLARATION + +/** +* Class that negotiaties RTP stream using RTSP. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtpFileSource : public CCRPacketSourceBase, + public MRtpFileReadObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CCRRtpFileSource pointer to CCRRtpFileSource class + */ + static CCRRtpFileSource* NewL( const SCRRtpPlayParams& aParams, + CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * Two-phased constructor. + * @return CCRRtpFileSource pointer to CCRRtpFileSource class + */ + static CCRRtpFileSource* NewL( const RFile& aRtpHandle, + CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor. + */ + virtual ~CCRRtpFileSource(); + +public: // New functions + + /** + * + * @since Series 60 3.0 + * @param none. + * @return none. + */ + //void PunchPacketsSent(); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @param aSessionObs a session observer. + * @param aOwningSession a owning session. + */ + CCRRtpFileSource( CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( const SCRRtpPlayParams& aParams ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( const RFile& aRtpHandle ); + +private: // Methods from base classes + + /** + * From CCRPacketSourceBase. + * Method for acquiring sdp. + * @since Series 60 3.0 + * @param aSdp is string pointer that will be .Set() to contain the sdp. + * If no sdp is available no .Set() will occur. + * @return KErrNotReady if no sdp available. + */ + TInt GetSdp( TPtrC8& aSdp ); + + /** + * From CCRPacketSourceBase. + * Method for setting buffers to packet source + * @since Series 60 3.0 + * @param aBuffer is buffer to be set. + * @return none. + */ + void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * From CCRPacketSourceBase. + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void PostActionL(); + + /** + * From CCRPacketSourceBase. + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void Restore(); + + /** + * From CCRPacketSourceBase. + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return a system wide error code. + */ + TInt Play( const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * From CCRPacketSourceBase. + * Method for stopping play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Stop(); + + /** + * From CCRPacketSourceBase. + * Setter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @return a system wide error code. + */ + TInt SetPosition( const TInt64 aPosition ); + + /** + * From CCRPacketSourceBase. + * Getter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @param aDuration a duration of playback. + * @return a system wide error code. + */ + TInt GetPosition( TInt64& aPosition, + TInt64& aDuration ); + + /** + * From MRtpFileReadObserver. + * Called when RTP packets group readed from a file. + * @since Series 60 3.0 + * @param aGroup a RTP data readed from a file. + * @param aGroupTime a group time in milli seconds. + * @param aLastGroup a indication of last group in clip. + * @return none. + */ + void GroupReadedL( const TDesC8& aGroup, + const TUint aGroupTime, + const TBool aLastGroup ); + + /** + * From MRtpFileReadObserver. + * File handler status of playback. + * @since Series 60 3.0 + * @param aStatus a status of file reading. + * @return none. + */ + void ReadStatus( TInt aStatus ); + +private: // New methods + + /** + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param aForce if true, forces read packets even buffer more than threshold. + * @return a system wide error code. + */ + TInt NextClipGroup( const TBool aForce ); + + /** + * Setter for current position of .rtp clip. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @return a system wide error code. + */ + TInt RtpPosition( const TUint aPosition ); + + /** + * Converts old RTP propriatary format packet type to stream id. + * @since Series 60 3.0 + * @param aType a packet type from a clip. + * @param aStream a stream id to update. + * @return true if packet valid, otherwise false. + */ + TBool TypeToStream( const MRtpFileWriteObserver::TRtpType& aType, + MCRPacketSource::TCRPacketStreamId& aStream ); + +private: // Data + + /** + * Clip handler for RTP clip. + */ + CRtpClipHandler*& iClipHandler; + + /** + * Session observer. + */ + MCRStreamObserver& iSessionObs; + + /** + * SDP data. + */ + HBufC8* iSdp; + + /** + * Time of initialy readed group. + */ + TUint iInitialTime; + + /** + * Pause packet sent to sink from a clip. + */ + TInt iClipPauseSent; + + }; + +#endif // CCRRTPFILESOURCE_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtpRecordSink.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtpRecordSink.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,326 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet sink where no-one gets the streaming* +*/ + + + +#ifndef CCRRTPRECORDSINK_H +#define CCRRTPRECORDSINK_H + +// INCLUDES +#include "CCRPacketSinkBase.h" +#include +#include "MCRTimerObserver.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketBuffer; +class CCRStreamingSession; +class MCRConnectionObserver; +class CRtpClipHandler; +class CRtpTsConverter; + +// CLASS DECLARATION + +/** +* Packet sink that does not forward packets. Good for testing. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtpRecordSink : public CCRPacketSinkBase, + public MRtpFileWriteObserver + { + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @param aRecordParams a recording parameters. + * @param aSinkId that this class needs to use when reporting progress back to owner. + * @param aOwningSession is the streaming session that owns this instance. + * @param aObserver a pointer to connection observer. + * @param aClipHandler a reference pointer to .rtp clip handler. + * @return CCRRtpRecordSink pointer. + */ + static CCRRtpRecordSink* NewL( const SCRRecordParams& aRecordParams, + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession, + MCRConnectionObserver* aObserver, + CRtpClipHandler*& aClipHandler ); + + /** + * Destructor + */ + virtual ~CCRRtpRecordSink(); + +protected: // Constructors and destructors + + /** + * By default default constructor is private + * @param aSinkId that this class needs to use when reporting progress back to owner. + * @param aObserver a pointer to connection observer. + * @param aClipHandler a reference pointer to .rtp clip handler. + * @param aOwningSession is the streaming session that owns this instance. + */ + CCRRtpRecordSink( CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession, + MCRConnectionObserver* aObserver, + CRtpClipHandler*& aClipHandler ); + + /** + * Second phase of 2-phased construction + * @param aRecordParams a recording parameters. + */ + void ConstructL( const SCRRecordParams& aRecordParams ); + +private: // Methods from base classes + + /** + * From CCRPacketSinkBase. + * Method for setting the sdp in use. + * @since Series 60 3.0 + * @param aSdp is the new sdp. + * @return none. + */ + void SetSdpL( const TDesC8& aSdp ); + + /** + * From CCRPacketSinkBase. + * Adds packet to the sink. + * @since Series 60 3.0 + * @return none. + */ + void NewPacketAvailable(); + + /** + * From CCRPacketSinkBase. + * Buffer reset info for the sink. + * @since Series 60 3.0 + * @return none. + */ + void BufferResetDone(); + + /** + * From CCRPacketSinkBase. + * Method for pause action for sink. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Pause(); + + /** + * From CCRPacketSinkBase. + * Method for restore action for sink. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt Restore(); + + /** + * From CCRPacketSinkBase. + * Method for stopping action for sink. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void Stop(); + + /** + * From MRtpFileWriteObserver. + * Group saved indication. + * @since Series 60 3.0 + * @return none. + */ + void GroupSaved(); + + /** + * From MRtpFileWriteObserver. + * Clip handler status of recording. + * @since Series 60 3.0 + * @param aStatus a status of file writing. + * @return none. + */ + void WriteStatus( const TInt aStatus ); + +private: // New methods + + /** + * Adds RTP packet(s) to a group. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void AddToGroup(); + + /** + * Adds one RTP packet to a group. + * @since Series 60 3.0 + * @param aPacket a packet data. + * @param aType a packet type. + * @return none. + */ + void AddPacketToGroupL( const TDesC8& aPacket, + const MRtpFileWriteObserver::TRtpType& aType ); + + /** + * Saves one RTP packet group to a clip. + * @since Series 60 3.0 + * @param aAction a saving action. + * @return none. + */ + void SaveGroup( MRtpFileWriteObserver::TRtpSaveAction aAction ); + + /** + * Saves one RTP packet group to a clip. + * @since Series 60 3.0 + * @param aAction a saving action. + * @return none. + */ + void SaveGroupL( MRtpFileWriteObserver::TRtpSaveAction aAction ); + + /** + * Converts stream id to old RTP propriatary format packet type. + * @since Series 60 3.0 + * @param aType a packet type from a clip. + * @param aStream a stream id to update. + * @return true if packet valid, otherwise false. + */ + TBool StreamToType( const MCRPacketSource::TCRPacketStreamId& aStream, + MRtpFileWriteObserver::TRtpType& aType ); + + /** + * Handles TS delta calculation from audio packets. + * @since Series 60 3.0 + * @param aPacket a packet data. + * @return a TS of packet. + */ + TUint TsFromPacketL( const TDesC8& aPacket ); + + /** + * Wrapper for AddPausePacketL(). + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void AddPausePacket(); + + /** + * Adds pause packet to group buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void AddPausePacketL(); + + /** + * Resets packets group variables. + * @since Series 60 3.0 + * @param aStatus a reason for recording end. + * @return none. + */ + void ForceStopRecording( const TInt& aStatus ); + + /** + * Resets packets group variables. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ResetGroupVariables(); + +private: // Data + + /** + * Packets group buffer. + */ + HBufC8* iGroupBuffer; + + /** + * Connection status observer. + */ + MCRConnectionObserver* iObserver; + + /** + * Clip handler for RTP clip. + */ + CRtpClipHandler*& iClipHandler; + + /** + * Packets group pointer. + */ + TPtr8 iGroupPointer; + + /** + * Current group size in bytes. + */ + TInt iGroupSize; + + /** + * Current group packets count. + */ + TInt iPacketsCount; + + /** + * Wanted group size. + */ + TInt iWantedGroup; + + /** + * TS converter for audio. + */ + CRtpTsConverter* iAudioConv; + + /** + * Time stamp of oldest audio packet. + */ + TUint iOldestTs; + + /** + * Latest audio packet. + */ + TPtrC8 iLatestAudio; + + /** + * Record mode, can be either normal of time shift. + */ + MRtpFileWriteObserver:: TRtpSaveAction iSaveMode; + + /** + * Next packet(s) mode, can be: normal, pause, end. + */ + MRtpFileWriteObserver:: TRtpSaveAction iGroupMode; + + /** + * Recording parameters. + */ + MRtpFileWriteObserver::SRtpRecParams iRecParams; + + }; + +#endif // CCRRTPRECORDSINK_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtpTcpObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtpTcpObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer for RTP/TCP streamer.* +*/ + + + + +#ifndef CCRRTPTCPOBSERVER_H +#define CCRRTPTCPOBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Observer for RTP/TCP streamer +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class MCRRtpTcpObserver + { + +public: // New methods + + /** + * Signals an available incoming RTSP control message + * @since Series 60 3.0 + * @param aData a RTSP meaage data. + * @return none. + */ + virtual void RtspMsgAvailable( const TDesC8& aData ) = 0; + + /** + * Signals an available incoming RTP/RTCP packet from RTSP/TCP streaming + * @since Series 60 3.0 + * @param aChannel channel through which packet was received. + * Actual interpretation and mapping to media stream (audio, video) + * done by user. + * @param aPacket a RTP/RTCP packet received. + * @return none. + */ + virtual void RtpTcpPacketAvailable( TInt aChannel, + const TDesC8& aPacket ) = 0; + + /** + * Signals an outgoing RTP/RTCP packet to be sent over RTSP/TCP + * @since Series 60 3.0 + * @param aChannel a channel through which packet was received. + * Actual interpretation and mapping to media stream (audio, video) + * done by user. + * @param aPacket RTP/RTCP packet received + * @return none. + */ + virtual void ForwardRtpTcpChunck( const TDesC8& aChunk ) = 0; + + }; + +#endif // CCRRTPTCPOBSERVER_H diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtpTcpStream.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtpTcpStream.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Abstraction for a media stream for RTP/TCP streamer* +*/ + + + + +#ifndef CCRRTPTCPSTREAM_H +#define CCRRTPTCPSTREAM_H + +// INCLUDE FILES +#include + +// FORWARD DECLARATIONS +class MCRRtpTcpObserver; + +/** +* RTP media stream for RTP/TCP streamer +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtpTcpStream : public CBase + { + +public: // Constructors and destructors + + /** + * Two-phased constructor + * @param aObserver + */ + static CCRRtpTcpStream* NewL( MCRRtpTcpObserver& aObserver ); + + /** + * Destructor + */ + virtual ~CCRRtpTcpStream(); + +public: // New methods + + /** + * Handles incoming RTP or RTCP packet + * @since Series 60 3.0 + * @param aChannel Interleaved channel. + * @return none. + */ + void PacketAvailable( TInt aChannel ); + +private: // Constructors and destructors + + /** + * C++ default constructor + */ + CCRRtpTcpStream( MCRRtpTcpObserver& aObserver ); + + /** + * Second phase constructor + */ + void ConstructL(); + +private: // Data + + /** + * Observer for streaming session. + */ + MCRRtpTcpObserver& iObserver; + + /** + * SSRC for this media stream. + */ + TUint32 iSSRC; + + }; + +#endif // CCRRTPTCPSTREAM_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtpTcpStreamer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtpTcpStreamer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP/TCP streamer for RTSP source.* +*/ + + + + +#ifndef CCRRTPTCPSTREAMER_H +#define CCRRTPTCPSTREAMER_H + +// INCLUDE FILES +#include + +// CONSTANTS +const TInt KCRRtpTcpStreamCount( 2 ); /** Max of two streams, audio and video */ + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class MCRRtpTcpObserver; +class CCRRtpTcpStream; + +// CLASS DECLARATION + +/** +* RTP/TCP streamer for RTSP packet source. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtpTcpStreamer : public CBase + { + +public: // Constructors and destructors + + /** + * Two-phased constructor + * @param aObserver a observer to TCP streamer. + */ + static CCRRtpTcpStreamer* NewL( MCRRtpTcpObserver& aObserver ); + + /** + * Destructor + */ + virtual ~CCRRtpTcpStreamer(); + +public: // New methods + + /** + * Signals that input IP packet is available for parsing. + * @since Series 60 3.0 + * @param aIpData raw RTSP/RTP/TCP data received (IP packet). + * @param aInterleaved a TCP interleaving state. + * @return none. + */ + void DataAvailable( const TDesC8& aIpData, + const TBool& aInterleaved ); + +private: // Constructors and destructors + + /** + * C++ default constructor + */ + CCRRtpTcpStreamer( MCRRtpTcpObserver& aObserver ); + + /** + * Second phase constructor + */ + void ConstructL(); + +private: // New methods + + /** + * Handles IP packet when more data is expected. + * @since Series 60 3.0 + * @param aIpData a data of IP packet. + * @return true if not enougth data in IP packet. + */ + TBool HandleMoreExpected( TPtrC8& aData ); + + /** + * Handles TCP interleave packet. + * @since Series 60 3.0 + * @param aData a data of IP packet. + * @return true if not enougth data in IP packet. + */ + TBool HandleTcpPacket( TPtrC8& aData ); + + /** + * Handles RTSP control response. + * @since Series 60 3.0 + * @param aData a data of IP packet. + * @param aInterleaved a TCP interleaving state. + * @return true if not enougth data in IP packet. + */ + TBool HandleRtspResponse( TPtrC8& aData, + const TBool& aInterleaved ); + + /** + * Creates an packet from IP data buffer. + * @since Series 60 3.0 + * @param aData a data of IP packet. + * @param aLength a length of RTSP/RTP packet. + * @return none. + */ + void MakePacket( TPtrC8& aData, const TInt aLength ); + + /** + * Handles incoming RTP or RTCP packet, forwards to user and to RTCP engine. + * @since Series 60 3.0 + * @param aPacket a data of RTP packet. + * @return none. + */ + void ForwardPacket( const TDesC8& aPacket ); + +private: // Data + + /** + * Observer for streaming session. + */ + MCRRtpTcpObserver& iObserver; + + /** + * More expected bytes count. + */ + TInt iMoreExpected; + + /** + * Data received so far. + */ + HBufC8* iIpData; + + /** + * RTSP data received so far. + */ + HBufC8* iRtspData; + + /** + * Media streams + */ + CCRRtpTcpStream* iStreams[KCRRtpTcpStreamCount]; + + }; + +#endif // CCRTCPSTREAMER_H + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRRtspSink.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRRtspSink.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,427 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet sink where real one player gets media stream.* +*/ + + + + +#ifndef CCRRTSPSINK_H +#define CCRRTSPSINK_H + +// INCLUDES +#include "CCRSock.h" +#include "CCRRtspCommand.h" +#include "CCRRtspResponse.h" +#include "CCRPacketBuffer.h" +#include "CCRStreamingSession.h" +#include "CCRPacketSinkBase.h" +#include + +// CONSTANTS +// None. + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CDvrSdpParser; +class CCRConnection; +class RSocketServ; +class CCRStreamingSession; + +// CLASS DECLARATION +/** +* Packet sink that forwards stream to rop plugin via rtsp. +* Implements rtsp server. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 + */ +class CCRRtspSink : public CCRPacketSinkBase, + public MCRSockObserver + { + +public: + + /** + * Enum for 5 socket to use to play to rop plugin. + */ + enum TCRROPSockId + { + EROPControl = 0, /**< control sock, rtsp in tcp spoken here */ + EROPVideoSend1, /**< RTP video payload */ + EROPVideoSend2, /**< RTCP video */ + EROPAudioSend1, /**< RTP audio payload */ + EROPAudioSend2, /**< RTCP audio */ + EROPMaxSockets /**< Just max value, no real socket assigned for this */ + }; + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @param aConnection a connection rerefrence. + * @param aSockServer a socket server refrence. + * @param aSinkId a id of this sink. + * @param aOwningSession a reference to owning session. + * @param aLoopbackPort a RTSP port for loopback socket. + * @return CCRRtspSink pointer. + */ + static CCRRtspSink* NewL( CCRConnection& aConnection, + RSocketServ& aSockServer, + CCRStreamingSession::TCRSinkId aSinkId, + const TInt& aLoopbackPort, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor + */ + virtual ~CCRRtspSink(); + +private: // Methods from base classes + + /** + * From CCRPacketSinkBase. + * Connects the given buffer with this sink. + * @since Series 60 3.0 + * @param aBuffer is the buffer to connect with. + * @return none. + */ + void SetBuffer( CCRPacketBuffer* aBuffer ); + + /** + * From CCRPacketSinkBase. + * Adds packet to the sink. + * @since Series 60 3.0 + * @return none. + */ + void NewPacketAvailable(); + + /** + * From CCRPacketSinkBase. + * Method for setting the sdp in use + * @since Series 60 3.0 + * @param aSdp is the new sdp + * @return none + */ + void SetSdpL( const TDesC8& aSdp ); + + /** + * From CCRPacketSinkBase. + * Method for setting initial seq+ts _before_ the stream is played. + * @since Series 60 3.0 + * @param aAudioSeq is the initial rtp seq number for audio packets. + * @param aAudioTS is the initial rtp timestamp number for audio packets. + * @param aVideoSeq is the initial rtp seq number for video packets. + * @param aVideoTS is the initial rtp timestamp number for video packets. + * @return none. + */ + void SetSeqAndTS( TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ); + + /** + * From CCRPacketSinkBase. + * method for setting play range before the stream is played. + * @since Series 60 3.0 + * @param aLower is where clip range begins, in seconds. + * @param aUpper is where clip range ends, usually clip end, in seconds. + * @return none. + */ + void SetRange( TReal aLower, + TReal aUpper ); + + /** + * From CCRPacketSinkBase. + * Method that source uses to communicate its status. + * @since Series 60 3.0 + * @param aNewState is the new state of the source. + * @return none. + */ + void StatusChanged( MCRPacketSource::TCRPacketSourceState aNewState ); + + /** + * From MCRSockObserver. + * This method is called after some data has been received from socket. + * @since Series 60 3.0 + * @param aData is descriptor containing the data received. + * ownership of data is not passed via this call. + * @return none. + */ + void DataReceived( TInt aSockId, const TDesC8 &aData ); + + /** + * From MCRSockObserver. + * This method is called after status of socket changes. + * @param aSockId + * @param aStatus is sock status. + * @param aError + * @return none. + */ + void SockStatusChange( TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ); + +public: // Constructors and destructors + + /** + * By default default constructor is private + * @param aConnection is the IAP representative that we need to use + * @param aSockServer is the socketserver to use when opening socks + * @param aSinkId that this class needs to use when reporting progress back to owner + * @param aOwningSession is the streaming session that owns this instance + */ + CCRRtspSink( CCRConnection& aConnection, + RSocketServ& aSockServer, + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ); + + /** + * second phase of 2-phased construction + * @param aLoopbackPort a RTSP port for loopback socket. + */ + void ConstructL( const TInt& aLoopbackPort ); + +protected: // New methods + + /** + * Method that produces sdp for rop plugin consumption. + * Needs to have iSDP and parser. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ProduceSDPForRopL(); + + /** + * Method for doing something with commands rop has sent to us + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ProcessRtspCommandL(); + + /** + * Method for doing something after rop has said something to use. + * @since Series 60 3.0 + * @param aLastCommand is the last command rop has sent + * @return none. + */ + void ProduceRtspReplyL( CCRRtspCommand::TCommand aLastCommand ); + + /** + * Method for replying to "options" command. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReplyToOptionsL(); + + /** + * Method for replying to "describe" command. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReplyToDescribeL(); + + /** + * Method for replying to "setup" command + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReplyToSetupL(); + + /** + * Method for replying to "play" command, reply is sent to rop. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReplyToPlayL(); + + /** + * Method for replying to "pause" command. + * @since Series 60 3.0 + * @param symbian error code telling if pausing was ok. + * @return none. + */ + void ReplyToPauseL( TInt aErrorCode ); + + /** + * Method for replying to "teardown" command. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ReplyToTearDownL(); + +private: // New methods + + /** + * Getter for socket sink id basing on stream. + * @since Series 60 3.0 + * @param aStreamId a stream id of packet. + * @return a socket sink id. + */ + TCRROPSockId SocketFromStream( MCRPacketSource::TCRPacketStreamId aStreamId ); + + /** + * Appends string to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aTxt a string to append. + * @return none. + */ + void AppendL( HBufC8*& aBuffer, + const TDesC8& aTxt ); + + /** + * Appends integer value as text to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aNum a numerical value to append. + * @return none. + */ + void AppendNumL( HBufC8*& aBuffer, + const TInt aNum ); + + /** + * Appends formatted text to the buffer. + * @since Series 60 3.0 + * @param aBuffer a buffer where to add text. + * @param aFmt a format string to use. + * @return none. + */ + void AppendFormatL( HBufC8*& aBuffer, + TRefByValue aFmt, ... ); + + /** + * Sends control data to the player. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SendControlData(); + + /** + * This meyhod is called after received data from EROPControl socket. + * @since Series 60 3.1 + * @param aData is descriptor containing the data received. + */ + void HandleReceivedEROPControlL( const TDesC8& aData ); + +private: // Data + + /** + * RConnection wrapper we use for sockets. no ownership. + */ + CCRConnection& iConnection; + + /** + * Socket server we use for sockets. no ownership. + */ + RSocketServ& iSockServer; + + /** + * When TBool in iPacketPendingInBuffer is ETrue it means that the buffer + * in iBuffers having same array index. As said TBool has a packet + * waiting to be sent to rop. + */ + TBool iPacketPendingInBuffer; + + /** + * Have our own sdp parser for parsing the sdp. + */ + CDvrSdpParser* iSdpParser; + + /** + * SDP to give to rop. + */ + HBufC8* iSdpForRop; + + /** + * Sockets for speaking with rop. + */ + CCRSock* iSockArr[EROPMaxSockets]; + + /** + * Stage in rtsp discussions with rop plugin. + */ + TCRRTSPStage iStage; + + /** + * Stage for setup repply received. + */ + TInt iSetupReceived; + + /** + * Pointer to data sent to us via socket from rop. + */ + HBufC8* iReceivedData; + + /** + * Pointers to commands sent by rop in various stages. + */ + CCRRtspCommand *iCommands[CCRRtspCommand::ERTSPCommandNOCOMMAND]; + + /** + * Pointer to string sent to rop. + */ + HBufC8* iRopResponse; + + /** + * Audio seq to begin with. + */ + TUint32 iAudioSeq; + + /** + * Audio TS to begin with. + */ + TUint32 iAudioTS; + + /** + * Video seq to begin with. + */ + TUint32 iVideoSeq; + + /** + * Video TS to begin with + */ + TUint32 iVideoTS; + + /** + * TBool telling if above 4 things (seq+ts*2) has been seen. + */ + TBool iSeqAndTSSet; + + /** + * Range begin pos in play command header. + */ + TReal iLowerRange; + + /** + * Range end pos in play command header. + */ + TReal iUpperRange; + + }; + +#endif // CCRRTSPSINK_H diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRServer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Server class in client/server paradigm of symbian.* +*/ + + + + +#ifndef __CCRSERVER_H +#define __CCRSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES + +// FORWARD DECLARATIONS +class CCREngine; + +// CLASS DECLARATION + +/** +* Server class. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRServer : public CPolicyServer + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aSemaphore a void pointer to semaphore. + */ + static CCRServer* NewLC(); + + /** + * Destructor. + */ + virtual ~CCRServer(); + +public: // New functions + + /** + * Thread function, creates cleanup stack for the thread. + * @since Series 60 3.0 + * @return KErrNone + */ + static TInt ThreadFunction( ); + + /** + * Thread function, the active scheduler is installed and started. + * @since Series 60 3.0 + * @return None. + */ + static void ThreadFunctionL( ); + + /** + * Signals client that server is started. + * @since Series 60 3.0 + * @return None. + */ + static void SignalClientL(); + + /** + * Panics server. + * @since Series 60 3.0 + * @param aPanic panic code. + * @return None. + */ + static void PanicServer( TInt aPanic ); + + /** + * Starts the server thread. + * @since Series 60 3.0 + * @return None. + */ + static TInt StartThread(); + + /** + * Dec + * @since Series 60 3.0 + * @return None. + */ + void Dec(); + + /** + * Inc + * @since Series 60 3.0 + * @return None. + */ + void Inc(); + + /** + * Create new Session. + * @since Series 60 3.0 + * @param aVersion server version number. + * @return CSharableSession pointer to new created session. + */ + CSession2* NewSessionL( const TVersion &aVersion, + const RMessage2& aMessage ) const; + + /** + * Gets engine object. + * @since Series 60 3.0 + * @return CCREngine pointer. + */ + CCREngine* GetEngineObjectL(); + +protected: + +// From CPolicyServer + + /** + * Called by framework to perform custom security check for any + * client messages. + * + * @param aMsg Message. + * @param aAction Action. + * @param aMissing Security info. + * @return Result of security check. + */ + TCustomResult CustomSecurityCheckL( + const RMessage2 &aMsg, + TInt &aAction, + TSecurityInfo &aMissing ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCRServer(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( ); + +private: // Methods from base classes + + /** + * Stops the server thread. + * @since Series 60 3.0 + * @return None. + */ + void StopServer(); + +private: // New methods + + /** + * Deletes CR engine. + * @since Series 60 3.0 + * @return None. + */ + void DeleteRtpEngine(); + +private: // Data + + /** + * Object container index. + */ + CObjectConIx* iContainerIx; + + /** + * Object container. + */ + CObjectCon* iObjectCon; + + /** + * CR engine object. + */ + CCREngine* iEngine; + + /** + * Number of sessions. + */ + TInt iSessionCount; + + }; + +#endif // __CCRSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRSession.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Session part of the client/server paradigm.* +*/ + + + + +#ifndef __CCRSESSION_H +#define __CCRSESSION_H + +// INCLUDES +#include + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +enum TCRPanic + { + ECRPanicServiceHandle, + ECRPanicBadDescriptor, + ECRPanicInvalidRequestType, + ECRPanicRequestAsyncTwice, + ECRPanicBadSubSessionHandle, + ECRPanicZeroLengthDes, + ECRPanicDesLengthNegative, + ECRPanicNullPtrArray, + ECRPanicNullHandle, + ECRPanicHandleNotOpen, + ECRPanicIndexOutOfRange, + ECRPanicHandleNotClosed, + ECRPanicBadRequest, + ECRPanicPanicBadName + }; + +// FORWARD DECLARATIONS +class CCREngine; +class CCRServer; + +// CLASS DECLARATION + +/** +* CCRSession is the server side session that client applications +* talk with. This merely passes commands to CCREngine +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRSession : public CSession2 + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @Param aClient reference client thread + * @Param aServer pointer to Server + * @return CCRSession pointer to CCRSession class + */ + static CCRSession* NewL( CCRServer* aServer ); + + /** + * Destructor. + */ + virtual ~CCRSession(); + +public: // New methods + + /** + * Server. + * @since Series 60 3.0 + * @return a pointer to server. + */ + inline CCRServer* Server() const + { + return REINTERPRET_CAST( CCRServer*, + CONST_CAST( CServer2*, CSession2::Server() ) ); + } + + /** + * Service. + * @since Series 60 3.0 + * @param aMessage contains data from the client. + * @return None. + */ + void ServiceL( const RMessage2& aMessage ); + +private: // New methods + + /** + * Dispatch message. + * @since Series 60 3.0 + * @param aMessage contains data from the client. + * @return None. + */ + void DispatchMessageL( const RMessage2& aMessage ); + + /** + * New Object. + * @since Series 60 3.0 + * @param aMessage contains data from the client. + * @return None. + */ + void NewObjectL( const RMessage2& aMessage ); + + /** + * Deletes object, can't fail - can panic client. + * @since Series 60 3.0 + * @param aHandle handle. + * @return None. + */ + void DeleteObject( TUint aHandle ); + + /** + * Counts resources + * @return Number of resources + */ + TInt CountResources(); + + /** + * Panics client. + * @since Series 60 3.0 + * @param aPanic panic code. + * @return None. + */ + void PanicClient( TInt aPanic ) const; + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @Param aClient reference client thread. + */ + CCRSession(); + + /** + * Symbian 2nd phase constructor. + * @Param aServer pointer to Server. + */ + void ConstructL( CCRServer* aServer ); + +private: // Data + + /** + * Object index for this session. + */ + CObjectIx* iObjects; + + /** + * Total number of resources allocated. + */ + TInt iResourceCount; + + }; + +#endif // __CCRSESSION_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRSock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRSock.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,521 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for wrapping RSocket and CActive* +*/ + + + + +#ifndef CCRSOCK_H +#define CCRSOCK_H + +// INCLUDES +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KMaxDataSize( 8192 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRSock; +class MCRSockObserver; + +// CLASS DECLARATION + +/** +* Class for receiving data via socket. +* +* This is solely owned by CCRSock and considered a helper class. +* Because there may be send and receive operations outstanding +* at the same time, one RSocket needs 2 CActive instances. +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRSockReader : public CActive + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aSock is reference to socket object + * that this class instance serves. + * @since Series 60 3.0 + * @param aConnection a connection. + * @param aSockServer a socket server. + * @return CCRSockReader pointer to CCRSockReader class. + */ + static CCRSockReader* NewL( CCRSock& aSock, + RConnection& aConnection, + RSocketServ& aSockServer ); + /** + * Destructor. + */ + virtual ~CCRSockReader(); + +public: // New Methods + + /** + * Method for starting reading. + * @since Series 60 3.0 + * @param none + * @return always succeeds + */ + void IssueRead( void ); + +private: // Constructors and destructors + + /** + * Default constructor + */ + CCRSockReader( CCRSock& aSock, + RConnection& aConnection, + RSocketServ& aSockServer ); + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // Methods from base classes + + /** + * From CActive. + * This is the work-horse of this class. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CActive. + * This cancels work in progress. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCancel(); + + /** + * From CActive. + * This handles errors. + * @since Series 60 3.0 + * @param none. + * @return none an status of method. + */ + TInt RunError( TInt aError ); + +private: // Data + + /** + * Socket. + */ + CCRSock& iSock; + + /** + * connection to use. + */ + RConnection& iConnection; + + /** + * Socket server. + */ + RSocketServ& iSockServer; + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + TUint recvCount; + TUint recvBytes; +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + }; + +/** +* Encapsulates a socket in easy-to-use way +*/ +class CCRSock : public CActive + { + +public: // Data types + + /** + * Enum for communicating what is going on with this socket + */ + enum TCRSockStatus + { + EInitNeeded = 1000, + EIdle, /**< Nothing in progress */ + EResolving, /**< Finding out addr to connect to */ + EConnecting, /**< Addr found but no connection yet */ + ESending, /**< Request to send has been issued but not yet completed */ + EListening, /**< Request to wait for incoming connection is not yet compl. */ + EFailed /**< Something went wrong */ + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aObserver is reference to object that + * gets notified when something happens + * @param aSockId is a number that this class instance + * will keep, do nothing with, and us the same + * number when reporting statuses back to observer. + * motivation here is that same observer may have + * several instances of this class all reporting + * via same method. + * @param aProtoTCP ETrue for TCP socket, EFalse for UDP + * @param aIssueRead ETrue to automatically receive data from + * socket and return to observer through DataReceived. + * EFalse to let user handle receiving data. + * @return CCRSock pointer to CCRSock class + */ + static CCRSock* NewL( MCRSockObserver& aObserver, + TInt aSockId, + RConnection& aConnection, + RSocketServ& aSockServer, + TBool aProtoTCP, + TBool aIssueRead ); + + /** + * Destructor. + */ + virtual ~CCRSock(); + +public: // New methods + + /** + * method for causing the socket to connect to remote addr. + * @since Series 60 3.0 + * @param aAddr is the addr to connect to + * @param aPort is ip port number to connect to + * @param aLocalPort specifies the local port to bind to. If 0 random + * port is selected + * @return KErrNone is returned if connection is all right + */ + TInt ConnectSock( const TDesC& aAddr, + TUint aPort, + TInt aLocalPort = 0 ); + + /** + * method for causing the socket to connect to remote addr without + * doing DNS lookup. + * @since Series 60 3.0 + * @param aAddr is the addr to connect to + * @param aLocalPort specifies the local port to bind to. If 0 random + * port is selected + * @return KErrNone is returned if connection is all right + */ + TInt ConnectSock( const TSockAddr& aAddr, + TInt aLocalPort = 0); + + /** + * method for causing the socket to start listening at part. + * @since Series 60 3.0 + * @param aPort is the port to listen to + * @return KErrNone is returned if connection is all right + */ + TInt ListenPort( TUint aPort ); + + /** + * method for joining a multicast group + * @since Series 60 3.0 + * @param aGruopAddr IPv6 address of the group to join + * @return KErrNone on success + */ + TInt JoinGroup( const TInetAddr& aGroupAddr ); + + /** + * method for sending data over the sock + * @since Series 60 3.0 + * @param aData is the data that is sent over sock + * @return none, succeeds always, if something goes wrong, it does it in async way + */ + void SendData( const TDesC8& aDataThatIsSentOverSocket ); + + /** + * Method for asking the status: what is going on + * @since Series 60 3.0 + * @param none. + * @return socket status. + */ + CCRSock::TCRSockStatus SockStatus( void ) const; + + /** + * Helper class may frobnicate our private parts: + */ + friend class CCRSockReader; + + /** + * Method for getting the addr this socket is connected to in the other end + * @since Series 60 3.0 + * @param none. + * @return the addr + */ + TInetAddr ConnectedAddr( void ); + + /** + * Method for getting the addr this socket is connected to in the local end + * @since Series 60 3.0 + * @param none. + * @return the addr + */ + TInetAddr LocalAddr( void ); + + /** + * Method for setting the "where to send addr" and this is applicable for UDP socks + * @param aAddr is the new addr. + * @return none + */ + void SetToAddr( const TInetAddr &aAddr ); + + /** + * Gets reference underlying Symbian socket implementation. To be used with caution. + * @since Series 60 3.0 + * @param none. + * @return reference to underlying ES_SOCK socket + */ + RSocket& Socket(); + +private: // Constructors and destructors + + /** + * default constructor + */ + CCRSock( MCRSockObserver& aObserver, + TInt aSockId, + RConnection& aConnection, + RSocketServ& aSockServer, + TBool aProtoTCP, + TBool aIssueRead ); + + /** + * 2nd phase constructor + */ + void ConstructL(); + +private: // Methods from base classes + + /** + * From CActive. + * This is the work-horse of this class. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CActive. + * This cancels work in progress. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCancel(); + + /** + * From CActive. + * This handles errors. + * @since Series 60 3.0 + * @param none. + * @return none an status of method. + */ + TInt RunError( TInt aError ); + +private: // New methods + + /** + * Handles send buffer. + */ + void CopySendData( const TDesC8& aData ); + + /** + * Performs cleanup. + */ + void CleanUp(); + +private: // Data types + + /** + * This is used to read/write. + */ + RSocket iSocket; + + /** + * status for above socket. + */ + TBool iIsiSocketOpen; + + /** + * This is used to listen. + * Not used when we use this class for outgoing connection. + */ + RSocket iListenSocket; + + /** + * Status for above socket. + */ + TBool iIsiListenSocketOpen; + + /** + * This is used to find out addr by name. + */ + RHostResolver iResolver; + /** + * This is needed to get hold of RSocket. + */ + RSocketServ& iSockServer; + + /** + * This is where we connect to. + */ + TNameEntry iHostAddress; + + /** + * this is our internal status. + */ + TCRSockStatus iSockStatus; + + /** + * Our observer. + */ + MCRSockObserver& iObserver; + + /** + * Our own internal id. + */ + const TInt iSockId; + + /** + * This tells whether we're about to connect via udp or tcp. + */ + TBool iProtoTCP; + + /** + * This tells whether receiving data from socket is handled by CCRSockReader or used. + */ + TBool iIssueRead; + + /** + * This tells the port we're about to connect. + */ + TUint iPort; + + /** + * This tells the port we're binding locally. + */ + TUint iLocalPort; + + /** + * This is where we keep the data received. + */ + HBufC8* iReceivedDataBuf; + + /** + * Pointer to received data buffer. + */ + TPtr8 iReceivedData; + + /** + * This is where we keep the data being sent. + */ + HBufC8* iSentDataBuf; + + /** + * Pointer to send data buffer. + */ + TPtr8 iSentData; + + /** + * This tells how much data we got. + */ + TSockXfrLength iReceivedDataLen; + + /** + * This tells how much data we sent. + */ + TSockXfrLength iSentDataLen; + + /** + * This tells where the packet was received from. + */ + TInetAddr iFromAddr; + + /** + * This tells if we've been listening or receiving in the past + */ + TBool iWasListening; + + /** + * This is instance of a helper class doing the reading part. + */ + CCRSockReader *iReader; + + /** + * This tells where to send UDP packets. + */ + TInetAddr iToAddr; + + /** + * Connection to use. + */ + RConnection& iConnection; + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + TUint sendCount; + TUint sendBytes; +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + }; + +/** +* Class for live tv socket "client" e.g. the user of class CCRSock. +*/ +class MCRSockObserver + { + +public: + + /** + * This method is called after some data has been received from socket. + * @since Series 60 3.0 + * @param aData is descriptor containing the data received. + * ownership of data is not passed via this call. + * @return none. + */ + virtual void DataReceived( TInt aSockId, + const TDesC8& aData ) = 0; + + /** + * This method is called after status of socket changes. + * @since Series 60 3.0 + * @param aSockId a socket id. + * @param aStatus is sock status. + * @param aError a error code. + * @return none + */ + virtual void SockStatusChange( TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ) = 0; + }; + +#endif // CCRSOCK_H + +// End of file + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRStreamingSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRStreamingSession.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,469 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Streaming session, eg one url, one channel...* +*/ + + + + +#ifndef _CCRSTREAMINGSESSION_ +#define _CCRSTREAMINGSESSION_ + +// INCLUDES +#include +#include "MCRStreamObserver.h" +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketBuffer; +class CAsyncCallBack; +class CCRConnection; +class CCRPacketSourceBase; +class CCRPacketSinkBase; +class CRtpClipHandler; +class CCREngine; +class MCRPacketSource; + +// CLASS DECLARATION + +/** +* Streaming session. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ + +class CCRStreamingSession : public CBase, + public MCRStreamObserver + { + +public: // Datatype definitions + + enum TCRSinkId + { + ECRRtspSinkId = 7000, + ECRXpsSinkId, + ECR3gpRecSinkId, + ECRRtpRecSinkId, + ECRNullSinkId + }; + + enum TCRSourceId + { + ECRRtspSourceId = 7100, + ECRDvbhSourceId, + ECRRtpSourceId, + ECRNullSourceId + }; + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @return CCRStreamingSession pointer. + */ + static CCRStreamingSession* NewL( RSocketServ& aSockServer, + CCRConnection* aConnection, + CCREngine& aEngine ); + + /** + * Destructor + */ + virtual ~CCRStreamingSession(); + +public: // New methods + + /** + * Method used to start a new RTSP session with parameters. + * @since Series 60 3.0 + * @param aParams specifies the connection addr. + * @param aClipHandler a reference pointer to RTP clip handler. + * @param aSessionDefinition a session definition string. + * @return none. + */ + void OpenSourceL( const SCRRtspParams& aParams, + const TDesC& aSessionDefinition ); + + /** + * Method used to start a new RTP session with parameters. + * @since Series 60 3.0 + * @param aParams specifies the RTP clip parameters. + * @param aClipHandler a reference pointer to RTP clip handler. + * @param aSessionDefinition a session definition string. + * @return none. + */ + void OpenSourceL( const SCRRtpPlayParams& aParams, + CRtpClipHandler*& aClipHandler, + const TDesC& aSessionDefinition ); + + /** + * Method used to start a new RTP session with parameters. + * @since Series 60 3.0 + * @param aRtpHandle a open file handle for RTP file. + * @param aParams specifies the RTP clip parameters. + * @param aSessionDefinition a session definition string. + * @return none. + */ + void OpenSourceL( const RFile& aRtpHandle, + CRtpClipHandler*& aClipHandler, + const TDesC& aSessionDefinition ); + + /** + * Method used to start a new DVB-H session with parameters. + * @since Series 60 3.0 + * @param aLiveParams specifies DVB-H live parameters. + * @param aSessionDefinition a session definition string. + * @return none. + */ + void OpenSourceL( const SCRLiveParams& aLiveParams, + const TDesC& aSessionDefinition ); + + /** + * Method used to start a new Null source session. + * @since Series 60 3.0 + * @param aSessionDefinition a session definition string. + * @return none. + */ + void OpenSourceL( const TDesC& aSessionDefinition ); + + /** + * Calculates source definition checksum: URL, file name etc. + * @since Series 60 3.0 + * @param aName a pointer to defination name. + * @return none. + */ + TUint SourceDefinition( const TDesC& aName ); + + /** + * Getter for source definition checksum. + * @since Series 60 3.0 + * @param none. + * @return a value of source definition checksum. + */ + TUint SourceChecksum(); + + /** + * Method that creates a set of buffers depending on + * number of rtp streams to handle. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CreateAndSetBufferL(); + + /** + * Method that creates a packet sink that forwards + * packets to rop plugin for rendering. + * @since Series 60 3.0 + * @param aLoopbackPort a RTSP port for loopback socket. + * @return none. + */ + void CreateRtspSinkL( const TInt& aLoopbackPort ); + + /** + * Creates XPS sink for passing packets to Helix player. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CreateXpsSinkL(); + + /** + * Creates RTP clip sink for saving packets to a clip. + * @since Series 60 3.0 + * @param aRecordParams a recording parameters. + * @return none. + */ + void Create3gpRecordSinkL( const SCRRecordParams& aRecordParams ); + + /** + * Creates RTP clip sink for saving packets to a clip. + * @since Series 60 3.0 + * @param aRecordParams a recording parameters. + * @param aClipHandler a reference pointer to RTP clip handler. + * @return none. + */ + void CreateRtpRecordSinkL( const SCRRecordParams& aRecordParams, + CRtpClipHandler*& aClipHandler ); + + /** + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void PostActionL(); + + /** + * Play command for current source. + * @since Series 60 3.0 + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return a system wide error code. + */ + TInt PlayCommand( const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * Pause command for current source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt PauseCommand(); + + /** + * Stop command for current source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + TInt StopCommand(); + + /** + * Setter for source position. + * @since Series 60 3.0 + * @param aPosition a current play position of the clip. + * @return a system wide error code. + */ + TInt SetPosition( const TInt64 aPosition ); + + /** + * Getter for source position. + * @since Series 60 3.0 + * @param aPosition a current play position of the clip. + * @param aDuration a duration of the clip. + * @return a system wide error code. + */ + TInt GetPosition( TInt64& aPosition, + TInt64& aDuration ); + + /** + * Pause command for wanted sink. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @return a system wide error code. + */ + TInt PauseCommand( const TCRSinkId& aSinkId ); + + /** + * Restore command for wanted sink. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @return a system wide error code. + */ + TInt RestoreCommand( const TCRSinkId& aSinkId ); + + /** + * Stop command for wanted sink. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @return a system wide error code. + */ + TInt StopCommand( const TCRSinkId& aSinkId ); + + /** + * Method to transfer ownership of existing sink. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @param aTargetSession identifies the sink. + * @return a system wide error code. + */ + TInt TransferSink( const TCRSinkId& aSinkId, + CCRStreamingSession& aTargetSession ); + + /** + * Method to add new sink to session. + * @since Series 60 3.0 + * @param aSink a pointer to the sink to add. + * @return a system wide error code. + */ + TInt AddNewSink( CCRPacketSinkBase* aSink ); + + /** + * Veryfies if source or any sink on session uses RTP clip handler. + * @since Series 60 3.0 + * @param none. + * @return true if clip handler user, otherwise false. + */ + TBool ClipHandlerUsed(); + + /** + * Method that creates a packet sink that forwards. + * packets to bit bucket. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void CreateNullSinkL(); + + /** + * Sets SDP and buffer for sinks. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void InitializeSinks(); + + /** + * Set timestamp and sequence numbers from source to sinks. + * If Range is available, sets it too. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SetSeqAndTs(); + + /** + * Method that sink calls to communicate that it wants to quit its business. + * It is now our responsibility to delete the sink after buffers have been + * notified about the situation. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @return none. + */ + void SinkStops( const TCRSinkId& aSinkId ); + + /** + * Method that source uses to communicate that it wants more packets. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SourceRestore(); + + /** + * Method that source uses to communicate that it wants to be deleted. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SourceStop(); + +private: // Constructors and destructors + + /** + * by default default constructor is private + * @param aSockServer is the socketserver to use when opening socks. + * @param aConnection + * @param aEngine + */ + CCRStreamingSession( RSocketServ& aSockServer, + CCRConnection* aConnection, + CCREngine& aEngine ); + + /** + * second phase of 2-phased construction + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From MCRStreamObserver. + * Source status indication. + * @since Series 60 3.0 + * @param aStatus + * @return none. + */ + void StatusChanged( MCRPacketSource::TCRPacketSourceState aStatus ); + +private: // New methods + + /** + * Static callback called via CAsyncCallBack to initiate cleaning of a sink + * @since Series 60 3.0 + * @param aThis a pointer to owner of call back. + * @return none. + */ + static TInt SinkStopCallBack( TAny* aThis ); + + /** + * Method for cleaning a sink. Called from SinkStopCallBack + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoSinkStop( void ); + + /** + * Method that deletes a packet sink. + * @since Series 60 3.0 + * @param aSinkId identifies the sink. + * @return none. + */ + void DeleteSink( const TCRSinkId& aSinkId ); + +public: // Data + + /** + * Socket server. + */ + RSocketServ& iSockServer; + + /** + * Connections. + */ + CCRConnection* iConnection; + + /** + * Reference to engine object owning this instance. + */ + CCREngine& iEngine; + + /** + * Callback for cutting the call stack in cleanup. + */ + CAsyncCallBack *iCleanUp; + + /** + * Packet sources. + */ + CCRPacketSourceBase* iSource; + + /** + * Source definition checksum. + */ + TUint iSourceChecksum; + + /** + * Packet buffer. + */ + CCRPacketBuffer* iBuffer; + + /** + * Packet sinks. + */ + RPointerArray iSinks; + + /** + * Array of sinks that have declared that they want to be deleted. + */ + RArray iSinksToDelete; + +}; + +#endif // _CCRSTREAMINGSESSION_ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRTimer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrapper for CTimer* +*/ + + + + +#ifndef CCRTIMER_H +#define CCRTIMER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class MCRTimerObserver; + +/** +* CCRTimer +* +* This class will notify an object after a specified timeout. +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRTimer : public CTimer + { + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * Creates a CCRTimer object using two phase construction, + * and returns a pointer to the created object. + * @since Series 60 3.0 + * @param aPriority Priority to use for this timer. + * @param aTimeOutNotify Object to notify of timeout event. + * @return A pointer to the created instance of CCRTimer. + */ + IMPORT_C static CCRTimer* NewL( const TInt aPriority, + MCRTimerObserver& aTimerObserver ); + + /** + * Two-phased constructor. + * Creates a CCRTimer object using two phase construction, + * and returns a pointer to the created object. + * @since Series 60 3.0 + * @param aPriority Priority to use for this timer. + * @param aTimerObserver Object to notify of timeout event. + * @return A pointer to the created instance of CCRTimer. + */ + IMPORT_C static CCRTimer* NewLC( const TInt aPriority, + MCRTimerObserver& aTimerObserver ); + + /** + * Destructor. + * Destroys the object and release all memory objects. + */ + virtual IMPORT_C ~CCRTimer(); + +protected: // Functions from base classes + + /** + * From CActive. + * Called when operation completes. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C void RunL(); + +private: // Constructors and destructors + + /** + * C++ default constructor. + * Performs the first phase of two phase construction. + * @since Series 60 3.0 + * @param aPriority Priority to use for this timer. + * @param aTimeOutNotify An observer to notify. + * @return none. + */ + IMPORT_C CCRTimer( const TInt aPriority, + MCRTimerObserver& aTimerObserver ); + + /** + * ConstructL. + * 2nd phase constructor. + */ + IMPORT_C void ConstructL(); + +private: // Data + + /** + * iNotify, the observer for this objects events. + */ + MCRTimerObserver& iObserver; + + }; + +#endif // CCRTIMER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CCRXpsSink.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CCRXpsSink.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,325 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet sink where XPS gets the streaming.* +*/ + + + +#ifndef CCRXPSSINK_H +#define CCRXPSSINK_H + +// INCLUDES +#include "CCRPacketSinkBase.h" +#include "MCRTimerObserver.h" +#include "VideoServiceUtilsConf.hrh" +#include +#include +#include "videoserviceutilsLogger.h" +#ifdef VIA_FEA_IPTV_USE_IPDC +#include +#endif // VIA_FEA_IPTV_USE_IPDC + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketBuffer; +class CXPSPacketSink; +class CCRStreamingSession; +class CRtpTsConverter; +class CRtpPacket; +class CCRTimer; + +// CLASS DECLARATION + +/** +* Packet sink that does not forward packets. Good for testing. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRXpsSink : public CCRPacketSinkBase, + public MCRTimerObserver, + public MXPSPktSinkObserver + { + +public: // Constructors and destructors + + /** + * Two-phased constructor. + * @return CCRXpsSink pointer. + */ + static CCRXpsSink* NewL( CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ); + + /** + * Destructor + */ + virtual ~CCRXpsSink(); + +protected: // Constructors and destructors + + /** + * By default default constructor is private + * @param aConnection is the IAP representative that we need to use + * @param aSockServer is the socketserver to use when opening socks + * @param aSinkId that this class needs to use when reporting progress back to owner + * @param aOwningSession is the streaming session that owns this instance + */ + CCRXpsSink( CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ); + + /** + * Second phase of 2-phased construction + */ + void ConstructL(); + +private: // Methods from base classes + + /** + * From CCRPacketSinkBase. + * Method for setting the sdp in use. + * @since Series 60 3.0 + * @param aSdp is the new sdp. + * @return none. + */ + void SetSdpL( const TDesC8& aSdp ); + + /** + * From CCRPacketSinkBase. + * Adds packet to the sink. + * @since Series 60 3.0 + * @return none. + */ + void NewPacketAvailable(); + + /** + * From CCRPacketSinkBase. + * Buffer reset info for the sink. + * @since Series 60 3.0 + * @return none. + */ + void BufferResetDone(); + + /** + * From MCRTimerObserver. + * The function to be called when a timeout occurs. + * @since Series 60 3.0 + * @param aTimer a pointer to timer. + * @return none. + */ + void TimerExpired( CCRTimer* aTimer ); + + /** + * From MXPSPktSinkObserver. + * API to inform for resumption of packet supply. + * @since Series 60 3.0 + * @param uStreamId a stream id. + * @return none. + */ + void RestorePacketSupply( TUint uStreamId ); + +private: // New methods + + /** + * Restores sink for new packets. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RestoreSink(); + + /** + * Sends one RTP packet to a player. + * @since Series 60 3.0 + * @param none. + * @return ETrue if packet was sent, EFalse if not. + */ + TBool SendPacket(); + + /** + * Adjust time stamp and enque audio packet to player. + * @since Series 60 3.0 + * @param aPacket a packet payload to send. + * @return a system wide error code of sending. + */ + TInt SendAudioPacket( const TDesC8& aPacket ); + + /** + * Adjust time stamp and enque video packet to player. + * @since Series 60 3.0 + * @param aPacket a packet payload to send. + * @return a system wide error code of sending. + */ + TInt SendVideoPacket( const TDesC8& aPacket ); + + /** + * Adjust time stamp and enque sub title packet to player. + * @since Series 60 3.0 + * @param aPacket a packet payload to send. + * @return a system wide error code of sending. + */ + TInt SendTitlePacket( const TDesC8& aPacket ); + + /** + * Sends packet to the player. + * @since Series 60 3.0 + * @param aStreamId a stream id of packet. + * @return a system wide error code of sending. + */ + TInt EnqueuePacket( const TUint aStreamId ); + + /** + * Serach if buffer contains control stream packets. + * If not, in non continous stream ask more packets to buffer. + * + * @since S60 v3.0 + * @return none. + */ + void SearchForControlStreamPackets(); + + /** + * Checks if the buffer contains control stream packets. This is needed + * if we receive packets for stream that has not yet received any control + * stream packets, so that we do not have to discard the packets. If any + * control stream packets are found for a stream that has not been + * initiated, then that control stream packet is used to initiate that + * stream. + * + * @since S60 v3.0 + * @return ETrue if a control stream packet was found, EFalse othervise. + */ + TBool CheckBufferForControlStreamPackets(); + + /** + * Starts flow timer. + * @since Series 60 3.0 + * @param aInterval a timer interval. + * @return none. + */ + void StartTimer( const TInt& aInterval ); + + /** + * Starts flow timer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void StopTimer(); + +#ifdef VIA_FEA_IPTV_USE_IPDC + /** + * Serach for fmtp string. + * @since Series 60 3.0 + * @param aSdpData a SDP data. + * @return smtp string from SDP. + */ + HBufC8* FindFmtpLC( const TDesC8& aSdpData ); + +#endif // VIA_FEA_IPTV_USE_IPDC + +private: // Data + + /** + * XPS packet sink. + */ + CXPSPacketSink* iPacketSink; + + /** + * Status of XPS buffer. + */ + TInt iWaitPlayer; + + /** + * Requested packet after overflow. + */ + TInt iRequested; + + /** + * Status for XPS reset. + */ + TBool iXpsResetOk; + + /** + * Status of range. + */ + TBool iRangeKnown; + + /** + * Flow control timer. + */ + CCRTimer* iFlowTimer; + + /** + * Audio stream id for XPS. + */ + TInt iAudioStreamId; + + /** + * Audio stream id for XPS. + */ + TInt iVideoStreamId; + + /** + * Sub title stream id for XPS. + */ + TInt iTitleStreamId; + + /** + * TS converter for audio. + */ + CRtpTsConverter* iAudioConv; + + /** + * TS converter for video. + */ + CRtpTsConverter* iVideoConv; + + /** + * TS converter for video. + */ + CRtpTsConverter* iTitleConv; + + /** + * RTP packet to enqueue. + */ + CRtpPacket* iRtpPacket; + +#ifdef VIA_FEA_IPTV_USE_IPDC + /** + * Depacketizer for video stream (ISMACryp). + */ + CH264Mpeg4GenrToFileformat * iVideoDepacketizer; + +#endif // VIA_FEA_IPTV_USE_IPDC + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + /** + * Debug purposes. + */ + TInt iLogXps; + +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + }; + +#endif // CCRXPSSINK_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CRRTSPCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CRRTSPCommon.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common definitions for rtsp implementation* +*/ + + + + +#ifndef CCRRTSPCOMMON_H +#define CCRRTSPCOMMON_H + +// INCLUDES +#include +#include + +// CONSTANTS +/** Max len for synchronization source id texttual presentation. SSRC is 32-bit number + * so this needs to be able to hold 2^^32 numerical value */ +const TInt KSSRCMaxLen( 30 ); +/** Max expected RTP packet len, given to symbian rtp stack that wants to know */ +const TInt KAverageExpectedRtpPacketMaxSize( 1500 ); + +// following five are guestimates +/** Average expected audio packet size */ +const TInt KAverageAudioPacketSize( 400 ); +/** Average expected video packet size */ +const TInt KAverageVideoPacketSize( 700 ); +/** Average expected rtp control packet size */ +const TInt KAverageRTPControlPacketSize( 30 ); +/** Number of rtp packets in our buffer, max */ +const TInt KRTPDataPacketBufferLen( 100 ); +/** Number of rtpc packets in our buffer, max */ +const TInt KRTPControlPacketBufferLen( 20 ); + +// followint strings _MAY_NOT_ be localized. +_LIT8( KCR2NewLines, "\r\n\r\n" ); +_LIT8( KCRCSeq, "CSeq: " ); +_LIT8( KCRRTSP10, "RTSP/1.0" ); +_LIT8( KCROPTIONS, "OPTIONS " ); +_LIT8( KCROPTIONSNoSpace, "OPTIONS" ); +_LIT8( KCRDESCRIBE, "DESCRIBE " ); +_LIT8( KCRDESCRIBENoSpace, "DESCRIBE" ); +_LIT8( KCRTEARDOWN,"TEARDOWN " ); +_LIT8( KCRTEARDOWNNoSpace,"TEARDOWN" ); +_LIT8( KCRPAUSE,"PAUSE " ); +_LIT8( KCRPAUSENoSpace,"PAUSE" ); +_LIT8( KCRSETUP, "SETUP " ); +_LIT8( KCRSETUPNoSpace, "SETUP" ); +_LIT8( KCRClient_Port, "client_port=" ); +_LIT8( KCRInterleaved, "interleaved=" ); +_LIT8( KCRAcceptSDP, "Accept: application/sdp\r\n" ); +_LIT8( KCRPort, "port=" ); +_LIT8( KCRDestination, "destination=" ); +_LIT8( KCRPLAY, "PLAY " ); +_LIT8( KCRPLAYNoSpace, "PLAY" ); +_LIT8( KCRRTSPReplyHeader, "RTSP/1.0 " ); +_LIT8( KCRRTSPContentLength, "Content-length: " ); +_LIT8( KCRRTSPDefaultUserAgent, "NokiaVideoCenter" ); +_LIT8( KCRRTSPUserAgentHeader, "User-Agent: %S\r\n" ); +_LIT8( KCRRTSPXWapProfile, "x-wap-profile: %S\r\n" ); +_LIT8( KCRRTSPBandwidth, "Bandwidth: %d\r\n" ); +_LIT8( KCRSessionStr, "Session: " ); +_LIT8( KCRNewLine, "\r\n" ); +_LIT8( KCRSpace, " " ); +_LIT8( KCRSemiColon, ";" ); +_LIT8( KCRDash, "-" ); +_LIT8( KCRLineFeed, "\n" ); +_LIT8( KCRSDPmLine, "m=" ); +_LIT8( KCRSDPmLineIsVideo, "m=video" ); +_LIT8( KCRSDPRTPAVP, "RTP/AVP" ); +_LIT8( KCRSDPRTPAVPTCP, "RTP/AVP/TCP" ); +_LIT8( KCRSDPRTPAVPUDP, "RTP/AVP/UDP" ); +_LIT8( KCRSDPMulticast, "multicast" ); +_LIT8( KCRSDPmLineIsAudio, "m=audio" ); +_LIT8( KCRSDPcLine, "c=" ); +_LIT8( KCRSDPbLine, "b=AS" ); +_LIT8( KCRNlAndSession, "\r\nSession: " ); +_LIT8( KCRRtpInfo, "RTP-Info: " ); +_LIT8( KCRUrlStr, "url=" ); +_LIT8( KCRSeqStr, "seq=" ); +_LIT8( KCRRtptimeStr, "rtptime=" ); +_LIT8( KCRServerPort, "server_port" ); +_LIT8( KCRSSRC, ";ssrc=" ); +_LIT8( KCRTransportHeaderUDP, "Transport: RTP/AVP;unicast;" + "client_port=%d-%d;mode=play\r\n" ); +_LIT8( KCRTransportHeaderTCP, "Transport: RTP/AVP/TCP;interleaved=%d-%d\r\n" ); +_LIT8( KCRTransportHeaderMulticast, "Transport: RTP/AVP;multicast\r\n" ); +_LIT8( KCRRangeHeader, "Range: npt=" ); +_LIT8( KCRRangeHeaderLiveStream, "Range: npt=now-" ); +_LIT8( KCRRtpMap, "a=rtpmap" ); +_LIT8( KCROptionsReply, + "RTSP/1.0 200 OK\r\nCseq: %d\r\n" + "Public: DESCRIBE, SETUP, PAUSE, " + "TEARDOWN, PLAY, OPTIONS\r\n\r\n" ); + +// Authentication strings +_LIT8( KCRAuthBasic, "Basic" ); +_LIT8( KCRAuthDigest, "Digest" ); +_LIT8( KCRAuthRealm, "realm=\"" ); +_LIT8( KCRAuthNonce, "nonce=\"" ); +_LIT8( KCRAuthOpaque, "opaque=\"" ); +_LIT8( KCRAuthorizationHeader, + "Authorization: Digest username=\"%S\", realm=\"%S\"," + " nonce=\"%S\", uri=\"%S\", response=\"%S\", opaque=\"%S\"\r\n" ); +_LIT8( KCRAuthorizationHeaderNoOpaque, + "Authorization: Digest username=\"%S\"," + " realm=\"%S\", nonce=\"%S\", uri=\"%S\", response=\"%S\"\r\n" ); +_LIT8( KCRContentBaseHeader, "Content-Base: ") ; +_LIT8( KCRAuthorizationBasicHeader, "Authorization: Basic %S\r\n" ); + +// MACROS +// None + +// DATA TYPES +/** +* TCRRTSPStage is used by both RTSP packet source and ROP sink. It is used +* to indicate the stage in RTSP negotiation where the packet source or rop sink +* currently is in +*/ +enum TCRRTSPStage + { + ERTSPInit = 0, /**< nothing done yet , must have numerical id 0 */ + ERTSPOptSent, /**< Options command has been sent */ + ERTSPDescSent, /**< Describe command has been sent */ + ERTSPDelayedSetup, /**< Setup command need to be delayed */ + ERTSPSetupAudioSent, /**< Setup command for audio has been sent */ + ERTSPSetupVideoSent, /**< Setup command has video been sent */ + ERTSPReadyToPlay, /**< Everything in order with remote server */ + ERTSPPlaySent, /**< Play command has been sent */ + ERTSPPauseSent, /**< Pause command has been sent */ + ERTSPPlaying, /**< Play command has been sent and 200 OK received */ + ERTSPTearDownSent, /**< Teardown command has been sent */ + ERTSPLastStage /**< This is not a real stage, keep this identifier as item, used for indexing */ + }; + +/** + * Enum indicating which transport to use for RTP streaming + */ +enum TCRRTPTransport + { + ERTPOverUDP = 0, /**< stream RTP over UDP, default */ + ERTPOverTCP, /**< stream RTP over TCP, interleaved in RTSP stream */ + ERTPOverMulticast /**< stream RTP over multicast UDP */ + }; + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Base-class for RTSP commands and responses. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CCRRtspCommon : public CBase + { + +public: // Constructors and destructor + + /** + * Destructor. + */ + virtual ~CCRRtspCommon( ); + +public: // New functions + + /** + * Method that is used to give rtsp response / command to this class. + * @since Series 60 3.0 + * @param aString is the response string + * @return none. May leave with symbian error codes. At least following may be + * seen: KErrUnderflow if there is \r\n\r\n sequence in the string + * marking end of response or if there is content(like SDP) and the + * content lenght is too short; KErrNotSupported if it doesn't look + * like RTSP at all. + */ + virtual void TryParseL( const TDesC8 &aString ) = 0; + + /** + * Method for getting content len. KErrNotFound if no content. KErrNotReady + * if TryParseL previously did leave + * @since Series 60 3.0 + * @param none . + * @return content len. + */ + TInt ContentLen( void ); + + /** + * Method for getting content. Most usually the content is SDP. + * @since Series 60 3.0 + * @param none + * @return tring descriptor allocated by this class so when + * this class instance gets deleted, the buffer + * content will point to invalid data. + */ + TPtrC8& Content( void ); + + /** + * Method for getting sequence number + * @since Series 60 3.0 + * @param none. + * @return CSeq. + */ + TInt CSeq( void ); + + /** + * Method for setting sequence number + * @since Series 60 3.0 + * @param aCSeq is CSeq number. + * @return none. + */ + void SetCSeq( TInt aCSeq ); + + /** + * Method for getting session id. + * @since Series 60 3.0 + * @param aId is string descriptor allocated by caller that + * will have its content set to block allocated by instance + * of this class containing the session id. + * @return KErrNone if no error, KErrNotFound if session id is not there. + */ + TInt SessionId( TPtrC8& aId ); + + /** + * Method for setting session id. + * @since Series 60 3.0 + * @param aId is string descriptor allocated by caller that contains + * new session id and whose content(memory area pointed by pointer + * returned by Ptr() method call) will remain intact for the + * lifetime of instance of this class. + * @return none. + */ + void SetSessionId( TPtrC8& aId ); + + /** + * Method for getting client port + * @since Series 60 3.0 + * @param none. + * @return client port of KErrNotFound if none found. + */ + TInt ClientPort( void ); + + /** + * Method for setting client port + * @since Series 60 3.0 + * @param aPort is the client port number. + * @return none. + */ + void SetClientPort( TInt aPort ); + + /** + * Method for setting range + * @since Series 60 3.0 + * @param aLower is where to start from. + * @param aUpper is where to stop. Negative values mean eternity. + * @return none + */ + void SetRange( TReal aLower, TReal aUpper ); + + /** + * Method for getting range + * @since Series 60 3.0 + * @param aLower is where to start from. + * @param aUpper is where to stop. Negative values mean eternity. + * @return none. + */ + void GetRange( TReal& aLower, TReal& aUpper ); + + /** + * Method for parsing range header + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void ParseRange( void ); + + /** + * Method for getting session opaque + * @since Series 60 3.0 + * @param none. + * @return reference to opaque or NULL. + */ + TDesC8& OpaqueL( void ); + + /** + * Method for getting session realm + * @since Series 60 3.0 + * @param none. + * @return reference to realm or NULL. + */ + TDesC8& RealmL( void ); + + /** + * Method for getting authentication type. + * @since Series 60 3.0 + * @param none. + * @return Reference to auth type found from RTSP reply. + */ + TDesC8& AuthenticationTypeL( void ); + + /** + * Method for getting session Nonce + * @since Series 60 3.0 + * @param none. + * @return Reference to nonce found from RTSP reply. + */ + TDesC8& NonceL( void ); + + /** + * Method for setting session nonce + * @since Series 60 3.0 + * @param aNonce is the nonce part of authenticated RTSP command/response. + * @return none. + */ + void SetNonceL( const TDesC& aNonce ); + + /** + * Mothod for setting authentication type + * @since Series 60 3.0 + * @param aAuthType is the authentication type. + * @return none. + */ + void SetAuthenticationTypeL( const TDesC8& aAuthType ); + + /** + * Method for setting session opaque + * @since Series 60 3.0 + * @param aOpaque is the opaque part of authenticated response. + * @return none. + */ + void SetOpaqueL( const TDesC& aOpaque ); + + /** + * Method for setting session realm + * @since Series 60 3.0 + * @param aRealm is the realm part of authenticated rtsp command. + * @return none. + */ + void SetRealmL( const TDesC& aRealm ); + + /** + * Method for setting session nonce + * @since Series 60 3.0 + * @param aNonce is the new nonce that will be sent with the command. + * @return none. + */ + void SetNonceL( const TDesC8& aNonce ); + + /** + * Method for setting session opaque + * @since Series 60 3.0 + * @param aOpaque is the new opaque that will be sent with the command. + * @return none. + */ + void SetOpaqueL( const TDesC8& aOpaque ); + + /** + * Method for setting session realm + * @since Series 60 3.0 + * @param aRealm is the new realm that will be sent with the command. + * @return none. + */ + void SetRealmL( const TDesC8& aRealm ); + + /** + * Method for setting rtsp username. + * @since Series 60 3.0 + * @param aUserName is the new username + * @return none. + */ + void SetUserNameL( const TDesC& aUserName ); + + /** + * Method for setting session password. + * @since Series 60 3.0 + * @param aPassWd is the password to use when generating digest for authenticated rtsp + * @return none. + */ + void SetPassWdL( const TDesC& aPassWd ); + + /** + * Method for setting session rtsp uri. + * @since Series 60 3.0 + * @param aUri is the string that will in RTSP command be written between command and text RTSP/1.0 strings. + * @return none. + */ + void SetRtspUriL( const TDesC& aUri ); + + /** + * Gets transport method. + * @since Series 60 3.0 + * @param none. + * @return transport method, default(ERTPOverUDP) if not present on command + */ + TCRRTPTransport Transport(); + + /** + * Sets transport method. + * @since Series 60 3.0 + * @param aTransport is the transport method to. This is used when constructing + * a SETUP command. + * @return none. + */ + void SetTransport( TCRRTPTransport aTransport ); + + /** + * Gets destination IP address if present + * @since Series 60 3.0 + * @param none. + * @return destination IP address or KAFUnspec + */ + const TInetAddr& Destination(); + + /** + * Gets flag whether stream is a live stream. + * @since Series 60 3.0 + * @param none. + * @return ETrue if stream is known to be a live stream. + */ + TBool IsLiveStream( void ); + + /** + * Getter for Content-base rtsp header content + * @since Series 60 3.0 + * @param none. + * @return content of content-base header or empty string + */ + TPtrC8 ContentBase( void ); + +protected: // Constructors and destructor + + /** + * default constructor + */ + CCRRtspCommon( void ); + +protected: // New methods + + /** + * Method for digging out CSeq from response. + * @since Series 60 3.0 + * @param none. + * @return none but will leave with KErrNotSupported if CSeq is not there. + */ + void FindCSeqL( void ); + + /** + * Method for digging out session id from response. Id will be stored in instance variable for future use. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindSessionIdL( void ); + + /** + * Method for digging ContentBase + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindContentBase( void ); + + /** + * Method for digging out content/content len from response + * @since Series 60 3.0 + * @param none. + * @return none but will leave will KErrUnderflow + * if all content not yet received. + */ + void FindContentL( void ); + + /** + * method for finding client port from response or command. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindClientPorts( void ); + + /** + * finds transport method from response or command. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindTransport(); + + /** + * finds destination IP address from SETUP response or command + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void FindDestination(); + +protected: // Data + + /** + * Buffer that holds the text being parsed. + */ + HBufC8* iRtspText; + + /** + * Len of possible content. + */ + TInt iContentLen; + + /** + * Possible content, if no content, set to( NULL, 0 ). + */ + TPtrC8 iContent; + + /** + * Sequence number, must be there. + */ + TInt iCSeq; + + /** + * Possible session id. + */ + TPtrC8 iSessionId; + + /** + * Possible client_port. + */ + TInt iClientPort; + + /** + * Transport method. + */ + TCRRTPTransport iTransport; + + /** + * Destination address + */ + TInetAddr iDestination; + + /** + * Range lower limit for Range: header. + */ + TReal iLowerRange; + + /** + * Range lower limit for Range: header. + */ + TReal iUpperRange; + + /** + * Authentication type. + */ + HBufC8* iAuthType; + + /** + * Realm. + */ + HBufC8* iRealm; + + /** + * Nonce. + */ + HBufC8* iNonce; + + /** + * Opaque. + */ + HBufC8* iOpaque; + + /** + * possible username, if server requires. + */ + HBufC8* iUserName; + + /** + * rtsp URL in 8bit descriptor. + */ + HBufC8* iUri; + + /** + * possible password, if server requires. + */ + HBufC8* iPassword; + + /** + * When this is set, it indicates that rtsp command/reply + * describes a live stream that cannot be paused or position set. + */ + TBool iIsLiveStream; + + /** + * Content of Content-base -header + */ + TPtrC8 iContentBase ; + }; + +#endif // CCRRTSPCOMMON_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/CRServerConsts.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/CRServerConsts.hrh Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common constant definitions* +*/ + + + + + +#ifndef __CRSERVERCONSTS_H +#define __CRSERVERCONSTS_H + +#define KCRServerUid 0x1028242D + +#endif // __CRSERVERCONSTS_H + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/MCRConnectionObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/MCRConnectionObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer class for wrapping RConnection.* +*/ + + + + +#ifndef MCRCONNECTIONOBSERVER_H +#define MCRCONNECTIONOBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Observer for connection interface status. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class MCRConnectionObserver + { + +public: // Data types + + /** + * TCRConnectionStatus is set of indications to be sent to client + */ + enum TCRConnectionStatus + { + ECRBearerChanged, /**< Indicates change in network bearer */ + ECRIapDown, /**< Network connection lost */ + ECRConnectionError, /**< Unable to open connection in RTP engine & CR engine */ + ECRConnecting, /**< Indicates "connection on progress" state to ui */ + ECRAuthenticationNeeded, /**< Used to request username/password from ui */ + ECRNotEnoughBandwidth, /**< Stream has too high bitrate for our network */ + ECRNormalEndOfStream, /**< Clip ends normally */ + ECRSwitchingToTcp, /**< Indicates a udp->tcp switch, client may need to reset player */ + ECRStreamIsLiveStream, /**< Indicates that we have stream that can't be paused */ + ECRAttachCompleted, /**< Sent when attached to RConnection */ + ECRStreamIsRealMedia, /**< Indicates that stream is (unsupported) realmedia format */ + ECRTestSinkData, /**< Data from TestSink (former NullSink) to test client observer */ + ECRSdpAvailable, /**< Used to communicate availability of SDP */ + ECRReadyToSeek, /**< Used to communicate seeking posibility */ + ECRRecordingStarted, /**< Used to communicate recording state */ + ECRRecordingPaused, /**< Used to communicate recording state */ + ECRRecordingEnded /**< Used to communicate recording state */ + }; + + /** + * This method is called after connection status changes or there is an error + * @since Series 60 3.0 + * @param aSessionId Id to session generating the status change or message. 0 points to no session. + * @param aConnection Reference to connection object being used. + * @param aInterfaceUp flags if interface has gone up (ETrue) + * or down (EFalse). + * @param aError error value associated. + * @return none. + */ + virtual void ConnectionStatusChange( TInt aSessionId, + const TCRConnectionStatus aStatus, + TInt aErr ) = 0; + }; + +#endif // MCRCONNECTIONOBSERVER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/MCRPacketSource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/MCRPacketSource.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for all rtp packet sources* +*/ + + + +#ifndef MCRPACKRTSOURCE_H +#define MCRPACKRTSOURCE_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TReal KRealZero( 0.0 ); +const TReal KRealMinusOne( -1.0 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRPacketBuffer; + +// CLASS DECLARATION + +/** +* Interface for packet sources +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class MCRPacketSource + { + +public: // Data types + + /** + * Enum for indicating what stream an individual rtp packet belongs to. + */ + enum TCRPacketStreamId + { + EAudioStream = 0, /**< This rtp stream carries audio content data */ + EAudioControlStream = 1, /**< This rtp stream carries audio control data */ + EVideoStream = 2, /**< This rtp stream carries video content data */ + EVideoControlStream = 3, /**< This rtp stream carries video control data */ + ESubTitleStream = 4, /**< This rtp stream carries sub title content data */ + ESubTitleControlStream = 5, /**< This rtp stream carries sub title control data */ + EDisContinousStream = 6, /**< This is info of discontinous point in stream */ + EStreamEndTag = 7, /**< This is info of end point of stream */ + EStreamIdCount /**< Number of different sources */ + }; + + /** + * Enum for indicating rtp packet source state. + */ + enum TCRPacketSourceState + { + ERtpStateIdle = 0, /**< Nothing started yet */ + ERtpStateSdpAvailable, /**< SDP received */ + ERtpStateSeqAndTSAvailable, /**< Should be ready for prime-time */ + ERtpStateSetupRepply, /**< Setup repply received */ + ERtpStatePlaying, /**< Stream is playing */ + ERtpStateClosing, /**< Stream is about to end */ + ERtpStateCount /**< Count number of different states */ + }; + +public: // New methods + + /** + * Method for acquiring sdp. + * @since Series 60 3.0 + * @param aSdp is string pointer that will be .Set() to contain + * the sdp. If no sdp is available no .Set() will occur. + * @return KErrNotReady if no sdp available. + */ + virtual TInt GetSdp( TPtrC8& aSdp ) = 0; + + /** + * Method for acquiring (almost) up-to-date sequence and ts numbers. + * @since Series 60 3.0 + * @param aAudioSeq is reference to TUint that will be set by this + * method to contain latest available sequence number for + * audio stream being received via this packet source. + * @param aAudioTS rtp timestamp for audio + * @param aVideoSeq rtp seq for video. If no video, + value will not be touched. + * @param aVideoTS rtp ts for video. + * @return KErrNone if data available. + */ + virtual TInt SeqAndTS( TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ) = 0; + + /** + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aStartPos is start position in sends. + * @param aEndPos is play end position in seconds. + * @return a system wide error code. + */ + virtual TInt Play( const TReal& aStartPos, + const TReal& aEndPos ) = 0; + + /** + * Method for ordering "pause" for packet source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Pause() = 0; + + /** + * Method for stopping play from source. + * @since Series 60 3.0 + * @param none. + * @return a system wide error code. + */ + virtual TInt Stop() = 0; + + /** + * Method for getting range of stream. If no range/duration + * is available this method will set the return values to + * 0.0,-1.0 and that may be quite normal state live streams. + * Also, depending on type of source this data may not be always + * available, for instance rtsp sources know the range after + * play command has been issued but not before. + * @since Series 60 3.0 + * @param aLower is where to start from. If no value available, + * value of aLower must be set to 0 + * @param aUpper is where to stop. Negative values mean eternity. + * @return none + */ + virtual void GetRange( TReal& aLower, + TReal& aUpper ) = 0; + + /** + * Post action after source initialized. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + virtual void PostActionL() = 0; + + /** + * Method for requesting more packets to buffer. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + virtual void Restore() = 0; + + /** + * Setter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @return a system wide error code. + */ + virtual TInt SetPosition( const TInt64 aPosition ) = 0; + + /** + * Getter for current position. + * @since Series 60 3.0 + * @param aPosition a postion of playback. + * @param aDuration a duration of playback. + * @return a system wide error code. + */ + virtual TInt GetPosition( TInt64& aPosition, + TInt64& aDuration ) = 0; + + }; + +#endif // MCRPACKRTSOURCE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/MCRStreamObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/MCRStreamObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Streaming observer definition for streaming session.* +*/ + + + + +#ifndef _MCRSTREAMOBSERVER_H +#define _MCRSTREAMOBSERVER_H + +// INCLUDES +#include "MCRPacketSource.h" + +/** +* Stream observer. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class MCRStreamObserver + { + +public: // New methods + + /** + * Source status indication. + * @since Series 60 3.0 + * @param aStatus + * @return none. + */ + virtual void StatusChanged( MCRPacketSource::TCRPacketSourceState aStatus ) = 0; + + }; + +#endif // _MCRSTREAMOBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/MCRTimerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/MCRTimerObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer for CCRTimer* +*/ + + + + +#ifndef CCRTIMEROBSERVER_H +#define CCRTIMEROBSERVER_H + +// INCLUDES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRTimer; + +// CLASS DECLARATION + +/** +* This class specifies the function to be called when a timeout occurs. +* Used in conjunction with CCRTimer class. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class MCRTimerObserver + { + +public: + + /** + * The function to be called when a timeout occurs. + * @since Series 60 3.0 + * @param aTimer a pointer to timer. + * @return none. + */ + virtual void TimerExpired( CCRTimer* aTimer ) = 0; + + }; + +#endif // CCRTIMEROBSERVER_H + +// End of File + + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/VideoServiceUtilsConf.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/VideoServiceUtilsConf.hrh Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +/** +* Flag for .rtp clip support. +* This flag is copied from videocenterconf.hrh +* Do not turn this flag on. Must be always undefined! +*/ +#undef RD_IPTV_FEA_RTP_CLIP_SUPPORT + +/** +* Flag for ipdc database usage. +* This flag is copied from videocenterconf.hrh +* Do not turn this flag on. Must be always undefined! +*/ +#undef VIA_FEA_IPTV_USE_IPDC diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/inc/videoserviceutilsLogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/inc/videoserviceutilsLogger.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __VIDEOSERVICEUTILSLOGGER_H__ +#define __VIDEOSERVICEUTILSLOGGER_H__ + +#include +#include + +_LIT( KDirectory, "livetv" ); +_LIT( KFileName, "livetv2.log" ); +_LIT( KTimeDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); + +//#define LIVE_TV_RDEBUG_TRACE +#ifdef _DEBUG +#define LIVE_TV_FILE_TRACE +#endif // _DEBUG +#ifdef LIVE_TV_RDEBUG_TRACE + #define LIVE_TV_TRACE1(a) RDebug::Print(a) + #define LIVE_TV_TRACE2(a,b) RDebug::Print(a,b) + #define LIVE_TV_TRACE3(a,b,c) RDebug::Print(a,b,c) + #define LIVE_TV_TRACE4(a,b,c,d) RDebug::Print(a,b,c,d) + #define LIVE_TV_TRACE5(a,b,c,d,e) RDebug::Print(a,b,c,d,e) + #define LOG(AAA) { LIVE_TV_TRACE1(_L(AAA)); } + #define LOG1(AAA,BBB) { LIVE_TV_TRACE2(_L(AAA),BBB); } + #define LOG2(AAA,BBB,CCC) { LIVE_TV_TRACE3(_L(AAA),BBB,CCC); } + #define LOG3(AAA,BBB,CCC,DDD) { LIVE_TV_TRACE4(_L(AAA),BBB,CCC,DDD); } + #define LOG4(AAA,BBB,CCC,DDD,EEE) { LIVE_TV_TRACE4(_L(AAA),BBB,CCC,DDD,EEE); } +#else + #ifdef LIVE_TV_FILE_TRACE + #define LIVE_TV_TRACE1(a) { RFileLogger::Write( KDirectory, KFileName, EFileLoggingModeAppend, a ); } + #define LIVE_TV_TRACE2(a,b) { RFileLogger::WriteFormat( KDirectory, KFileName, EFileLoggingModeAppend, a, b );} + #define LIVE_TV_TRACE3(a,b,c) { RFileLogger::WriteFormat( KDirectory, KFileName, EFileLoggingModeAppend, a, b, c ); } + #define LIVE_TV_TRACE4(a,b,c,d) { RFileLogger::WriteFormat( KDirectory, KFileName, EFileLoggingModeAppend, a, b, c, d ); } + #define LIVE_TV_TRACE5(a,b,c,d,e) { RFileLogger::WriteFormat( KDirectory, KFileName, EFileLoggingModeAppend, a, b, c, d, e ); } + #define LOG(AAA) { LIVE_TV_TRACE1(_L(AAA)); } + #define LOG1(AAA,BBB) { LIVE_TV_TRACE2(_L(AAA),BBB); } + #define LOG2(AAA,BBB,CCC) { LIVE_TV_TRACE3(_L(AAA),BBB,CCC); } + #define LOG3(AAA,BBB,CCC,DDD) { LIVE_TV_TRACE4(_L(AAA),BBB,CCC,DDD); } + #define LOG4(AAA,BBB,CCC,DDD,EEE) { LIVE_TV_TRACE4(_L(AAA),BBB,CCC,DDD,EEE); } + #else + #define LIVE_TV_TRACE1(a) + #define LIVE_TV_TRACE2(a,b) + #define LIVE_TV_TRACE3(a,b,c) + #define LIVE_TV_TRACE4(a,b,c,d) + #define LIVE_TV_TRACE5(a,b,c,d,e) + #define LOG(AAA) + #define LOG1(AAA,BBB) + #define LOG2(AAA,BBB,CCC) + #define LOG3(AAA,BBB,CCC,DDD) + #define LOG4(AAA,BBB,CCC,DDD,EEE) + #endif +#endif + +#endif// __VIDEOSERVICEUTILSLOGGER_H__ + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/rom/commonrecordingengine.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/rom/commonrecordingengine.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __COMMONRECORDINGENGINE_IBY__ +#define __COMMONRECORDINGENGINE_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\CommonRecordingEngine.exe PROGRAMS_DIR\CommonRecordingEngine.exe + +#endif // __COMMONRECORDINGENGINE_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRClientInformer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRClientInformer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Sends message to client with message queue.* +*/ + + + + +// INCLUDE FILES +#include "CCRClientInformer.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRClientInformer::NewL +// ----------------------------------------------------------------------------- +// +CCRClientInformer* CCRClientInformer::NewL() + { + CCRClientInformer* self = new( ELeave ) CCRClientInformer(); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRClientInformer::CCRClientInformer +// ----------------------------------------------------------------------------- +// +CCRClientInformer::CCRClientInformer() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRClientInformer::~CCRClientInformer +// ----------------------------------------------------------------------------- +// +CCRClientInformer::~CCRClientInformer() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRClientInformer::SendMessage +// ----------------------------------------------------------------------------- +// +TInt CCRClientInformer::SendMessage( + const TDes& aQueueName, + SCRQueueEntry& aInfo ) + { + LIVE_TV_TRACE2( _L( "CCRClientInformer::SendMessage: aInfo.iErr:%d" ), aInfo.iErr ); + + RMsgQueue queue; + TInt err( queue.OpenGlobal( aQueueName ) ); + if ( err == KErrNone ) + { + err = queue.Send( aInfo ); + if ( err != KErrNone ) + { + LIVE_TV_TRACE2(_L("CCRClientInformer::SendMessage() queue.Send() FAILED: %d"), err); + } + + queue.Close(); + } + else + { + LIVE_TV_TRACE2(_L("CCRClientInformer::SendMessage() queue.OpenGlobal() FAILED: %d"), err); + } + + return err; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRConnection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRConnection.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,586 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrap rconnection* +*/ + + + + +// INCLUDE FILES +#include "CCRConnection.h" +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRConnection::CCRConnection +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRConnection::CCRConnection( RSocketServ& aSockServer ) + : CActive( EPriorityStandard ), + iSockServer( aSockServer ), + iState( CCRConnection::EIdle ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRConnection::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRConnection* CCRConnection::NewL( RSocketServ& aSockServer ) + { + CCRConnection* self = new( ELeave ) CCRConnection( aSockServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRConnection::ConstructL() + { + CActiveScheduler::Add( this ); + User::LeaveIfError( iConnection.Open( iSockServer ) ); + User::LeaveIfError( iConMon.ConnectL() ); + + // Request bearer changes events from RConnectionMonitor + User::LeaveIfError( iConMon.NotifyEventL( *this ) ); + } + +// ----------------------------------------------------------------------------- +// CCRConnection::~CCRConnection +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRConnection::~CCRConnection() + { + LOG( "CCRConnection::~CCRConnection()" ); + + if ( iConMonProgressNotifyPending && iConnection.SubSessionHandle() ) + { + LOG( "~CCRConnection CancelProgressNotification" ); + iConnection.CancelProgressNotification(); + } + + Cancel(); + iConMon.CancelNotifications(); + iConMon.Close(); + CloseRConnection(); + iObservers.Close(); + } + +// ----------------------------------------------------------------------------- +// CCRConnection::Start +// ----------------------------------------------------------------------------- +// +void CCRConnection::Attach( TUint aConnectionId ) + { + LOG1( "CCRConnection::Attach: aConnectionId: %u", aConnectionId ); + Cancel(); + iCurrentConnectionId = aConnectionId; + iConMon.GetConnectionCount( iConnectionCount, iStatus ); + SetActive(); + iState = CCRConnection::EFindingAP; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::DoCancel +// If we need to cancel. +// ----------------------------------------------------------------------------- +// +void CCRConnection::DoCancel() + { + LOG( "CCRConnection::DoCancel" ); + + if ( iState == CCRConnection::EFindingAP ) + { + LOG( "CCRConnection::DoCancel in EFindingAP" ); + iConMon.CancelAsyncRequest( EConnMonGetConnectionCount ); + } + else if ( iState == CCRConnection::EFindingBearer ) + { + LOG( "CCRConnection::DoCancel in EFindingBearer" ); + iConMon.CancelAsyncRequest( EConnMonGetIntAttribute ); + } + else if ( iState == CCRConnection::EOpen && iConnection.SubSessionHandle() ) + { + LOG( "CCRConnection::DoCancel in EOpen" ); + iConMonProgressNotifyPending = EFalse; + iConnection.CancelProgressNotification(); + } + else if ( iState == CCRConnection::EConnecting ) + { + LOG( "CCRConnection::DoCancel in EConnecting" ); + // How to cancel a RConnection::Start? + } + + LOG( "CCRConnection::DoCancel() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRConnection::RunL +// Request succesful completion. +// ----------------------------------------------------------------------------- +// +void CCRConnection::RunL() + { + LOG2( "CCRConnection::RunL(), iState: %d, iStatus: %d", + ( TInt )iState, iStatus.Int() ); + + // Not pending any longer + iConMonProgressNotifyPending = EFalse; + + // Handle state + TInt err( KErrNone ); + if ( iStatus.Int() == KErrNone ) + { + if ( iState == CCRConnection::EFindingAP ) + { + err = FindApL(); + } + else if ( iState == CCRConnection::EFindingBearer ) + { + FindBearerL(); + } + else if ( iState == CCRConnection::EOpen ) + { + NotificationL(); + } + } + else + { + SendConnectionErrorToQueue( iStatus.Int() ); + } + + // Verify status + if ( err ) + { + LOG1( "CCRConnection::RunL(), err: %d", err ); + SendConnectionErrorToQueue( err ); + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::SendConnectionErrorToQueue +// ----------------------------------------------------------------------------- +// +void CCRConnection::SendConnectionErrorToQueue( TInt aError ) + { + LOG1( "CCRConnection::SendConnectionErrorToQueue() aError: %d", aError ); + + iState = CCRConnection::EIdle; + iCurrentConnectionId = 0; + iBearerType = EBearerUnknown; + CloseRConnection(); + MCRConnectionObserver::TCRConnectionStatus status; + status = MCRConnectionObserver::ECRConnectionError; + + for ( TInt i( 0 ); i < iObservers.Count(); i++ ) + { + iObservers[i]->ConnectionStatusChange( 0, status, aError ); + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::RunError +// If anything goes wrong. +// ----------------------------------------------------------------------------- +// +TInt CCRConnection::RunError( TInt aError ) + { + LOG1( "CCRConnection::RunError: aError %d", aError ); + ( void )aError; // Prevent compiler warning + iState = CCRConnection::EIdle; + iCurrentConnectionId = 0; + iBearerType = EBearerUnknown; + CloseRConnection(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::CloseRConnection +// ----------------------------------------------------------------------------- +// +void CCRConnection::CloseRConnection() + { + LOG( "CCRConnection::CloseRConnection()" ); + + if ( iConnection.SubSessionHandle() ) + { + iConnection.Close(); + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::Connection +// Returns the connection. +// ----------------------------------------------------------------------------- +// +RConnection& CCRConnection::Connection ( void ) + { + return iConnection; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::State +// Returns state of connection. +// ----------------------------------------------------------------------------- +// +CCRConnection::TConnectionState CCRConnection::State( void ) const + { + return iState; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::BearerType +// ----------------------------------------------------------------------------- +// +TConnMonBearerType CCRConnection::BearerType() const + { + return iBearerType; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::RegisterObserver +// ----------------------------------------------------------------------------- +// +TInt CCRConnection::RegisterObserver( MCRConnectionObserver* aObserver ) + { + LOG( "CCRConnection::RegisterObserver" ); + return iObservers.Append( aObserver ); + } + +// ----------------------------------------------------------------------------- +// CCRConnection::UnregisterObserver +// ----------------------------------------------------------------------------- +// +TInt CCRConnection::UnregisterObserver( MCRConnectionObserver* aObserver ) + { + LOG( "CCRConnection::UnregisterObserver" ); + TInt pos = iObservers.Find( aObserver ); + if ( pos < KErrNone ) + { + return pos; + } + + iObservers.Remove( pos ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::GetHeuristic +// ----------------------------------------------------------------------------- +// +TBool CCRConnection::GetHeuristic( TConnectionHeuristic aHeuristic ) + { + TInt bit( 1 << ( TInt )aHeuristic ); + return ( TBool )( iHeuristics & bit ); + } + +// ----------------------------------------------------------------------------- +// CCRConnection::SetHeuristic +// ----------------------------------------------------------------------------- +// +void CCRConnection::SetHeuristic( TConnectionHeuristic aHeuristic, TBool aValue ) + { + TInt mask( 1 << ( TInt )aHeuristic ); + if ( aValue ) + { + iHeuristics |= mask; + } + else + { + iHeuristics &= ~mask; + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::EventL +// ----------------------------------------------------------------------------- +// +void CCRConnection::EventL( const CConnMonEventBase& aEvent ) + { + // bearer change events + if( aEvent.EventType()==EConnMonBearerChange && iState==EOpen ) + { + // IMPORTANT: EConnMonBearerChange event report changes in *some* connection, not + // necessarly ours and aEvent.ConnectionId() doest *not* contain plain 'connection id', + // it has 'bearer id'. So make a new bearertype query to make sure it's ours. + LOG2( "CCRConnection::EventL: bearer changed, id=%d, bearer=%d", + aEvent.ConnectionId(), ( ( CConnMonBearerChange* )( &aEvent) )->Bearer() ); + + // Cancel ongoing requests + if ( IsActive() ) + { + Cancel(); + } + + iState = CCRConnection::EFindingBearer; + iConMon.GetIntAttribute( iCurrentConnectionId, 0, KBearer, + ( TInt& )iNewBearerType, iStatus ); + SetActive(); + } + // other unhandled events + else + { + LOG2( "CCRConnection::EventL: unknown event=%d, connection=%d", + aEvent.EventType(), aEvent.ConnectionId() ); + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::IsBearerWLANor3G +// ----------------------------------------------------------------------------- +// +TBool CCRConnection::IsBearerWLANor3G( TConnMonBearerType aBearer ) + { + return aBearer == EBearerWCDMA || // from CIptvNetworkEngine::IsBearer3GOrWLAN, + aBearer == EBearerWLAN || // EBearerLAN is returned by emulator + aBearer == EBearerCDMA2000 || + aBearer == EBearerLAN; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::MaximumBandwidth +// ----------------------------------------------------------------------------- +// +TInt CCRConnection::MaximumBandwidth() + { + // Determine bandwidth based on bearer or from ConnectionMonitor attributes + // (KMaximumBitrateDownlink, KGuaranteedBitrateDownlink) when QoS is supported + TConnMonBearerType bearer = BearerType(); + TInt bandwidth( 0 ); + + switch( bearer ) + { + case EBearerGPRS: + bandwidth = KCRBandwidthGPRS; + break; + + case EBearerEdgeGPRS: + bandwidth = KCRBandwidthEdgeGPRS; + break; + + case EBearerWCDMA: + bandwidth = KCRBandwidthWCDMA; + break; + + case EBearerWLAN: + bandwidth = KCRBandwidthWLAN; + break; + + case EBearerLAN: + bandwidth = KCRBandwidthLAN; + break; + + default: + // None + break; + } + + return bandwidth; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::FindApL +// Request succesful completion. +// ----------------------------------------------------------------------------- +// +TInt CCRConnection::FindApL() + { + CloseRConnection(); + TInt err( iConnection.Open( iSockServer ) ); + if ( err ) + { + LOG1( "CCRConnection::FindApL(), Open iConnection err: %d", err ); + return err; + } + + // Connections + TUint foundConnections( 0 ); + err = iConnection.EnumerateConnections( foundConnections ); + if ( err ) + { + LOG1( "CCRConnection::FindApL(), EnumerateConnections fail: %d", err ); + return err; + } + + // Active connection found + TUint conId( 0 ); // connection id + TUint subId( 0 ); // subconnection id + TUint conToUse( 0 ); + for ( TInt i( 1 ); i <= foundConnections && !err; i++ ) + { + err = iConMon.GetConnectionInfo( i, conId, subId ); + if ( !err && conId == iCurrentConnectionId ) + { + conToUse = i; + i = foundConnections + 1; // break from loop + } + } + if ( err ) + { + LOG1( "CCRConnection::FindApL() GetConnectionInfo loop err: %d", err ); + return err; + } + + // Connection info + TPckgBuf info; + err = iConnection.GetConnectionInfo( conToUse, info ); + if ( err ) + { + LOG1( "CCRConnection::FindApL(), GetConnectionInfo 2 fail: %d", err ); + return err; + } + + // Attach + err = iConnection.Attach( info, RConnection::EAttachTypeNormal ); + if ( err ) + { + LOG1( "CCRConnection::FindApL(), Attach failed: %d", err ); + } + + // Bearer type + iState = CCRConnection::EFindingBearer; + iBearerType = EBearerUnknown; + iConMon.GetIntAttribute( + iCurrentConnectionId, 0, KBearer, ( TInt& )iNewBearerType, iStatus ); + SetActive(); + return err; + } + +// ----------------------------------------------------------------------------- +// CCRConnection::FindBearerL +// Request succesful completion. +// ----------------------------------------------------------------------------- +// +void CCRConnection::FindBearerL() + { + LOG2( "CCRConnection::FindBearerL(), iCurrentConnectionId: %d, iNewBearerType: %d", + iCurrentConnectionId, iNewBearerType ); + + iState = CCRConnection::EOpen; + TBool was3g( IsBearerWLANor3G( iBearerType ) ); + TBool is3g( IsBearerWLANor3G( iNewBearerType ) ); + TBool genChanged( was3g^is3g ); + TBool justConnected( iBearerType == EBearerUnknown ); + iBearerType = iNewBearerType; + + // Notify if connection has just gone up + if ( justConnected ) + { + // Broadcast IapUp&Running for observers + MCRConnectionObserver::TCRConnectionStatus status; + status = MCRConnectionObserver::ECRAttachCompleted; + for ( TInt i( 0 ); i < iObservers.Count(); i++ ) + { + iObservers[i]->ConnectionStatusChange( 0, status, iStatus.Int() ); + } + } + + // Notify if connection has just gone up or generation changed + if ( genChanged ) + { + // Broadcast IapUp&Running for observers + MCRConnectionObserver::TCRConnectionStatus status; + status = MCRConnectionObserver::ECRBearerChanged; + for( TInt i=0 ; iConnectionStatusChange( 0, status, iStatus.Int() ); + } + } + if ( iConnection.SubSessionHandle() ) + { + // Request connection progress notifications from RConnection + iConMonProgressNotifyPending = ETrue; + iConnection.ProgressNotification( iNotification, iStatus ); + SetActive(); + } + } + +// ----------------------------------------------------------------------------- +// CCRConnection::NotificationL +// Request succesful completion. +// ----------------------------------------------------------------------------- +// +void CCRConnection::NotificationL() + { + TNifProgress notification = iNotification(); + LOG2( "CCRConnection::NotificationL stage: %d err: %d", + ( TInt )( notification.iStage ), ( TInt )( notification.iError ) ); + + if ( notification.iError != KErrNone ) + { + // Notify UI + iState = CCRConnection::EIdle; + + MCRConnectionObserver::TCRConnectionStatus status; + status = MCRConnectionObserver::ECRIapDown; + for ( TInt i( 0 ); i < iObservers.Count(); i++ ) + { + iObservers[i]->ConnectionStatusChange( 0, status, notification.iError ); + } + + if ( iConnection.SubSessionHandle() ) + { + iConnection.CancelProgressNotification(); + iConMonProgressNotifyPending = EFalse; + CloseRConnection(); + } + + iCurrentConnectionId = 0; + iBearerType = EBearerUnknown; + } + else + { + switch ( notification.iStage ) + { + case KLinkLayerOpen: + // this means we're open + break; + + case KConfigDaemonStartingDeregistration: + case KConfigDaemonUnloading: + case KConfigDaemonUnloaded: + case KLinkLayerClosed: + // And we're closed or closing + break; + + default: + // Do nothing in rest of the cases + break; + } + + if ( iConnection.SubSessionHandle() ) + { + iConnection.ProgressNotification( iNotification, iStatus ); + iConMonProgressNotifyPending = ETrue; + SetActive(); + } + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCREngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCREngine.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1592 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Engine part of the engine. In practice keeps count on* +*/ + + + + +// INCLUDE FILES +#include +#include "VideoServiceUtilsConf.hrh" +#include "CCREngine.h" +#include "CCRStreamingSession.h" +#include "CCRSession.h" +#include "CCRClientInformer.h" +#include "CCRConnection.h" +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +#include +#include +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT +#include +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TUint KCRELoopbackPortStart( 1106 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCREngine::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCREngine* CCREngine::NewL( void ) + { + CCREngine* self = new( ELeave ) CCREngine(); + + // Use CleanupClosePushL to make sure the Close function defined in CObject + // base class gets called. CObject will delete itself once its reference count + // reaches zero. Using CleanupStack::PushL here results in E32USER-CBase panic 33 + // if there is a leave somewhere in construction + CleanupClosePushL( *self ); + + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCREngine::CCREngine +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCREngine::CCREngine( void ) : iLoopbackPort( KCRELoopbackPortStart ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCREngine::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCREngine::ConstructL() + { + LOG( "CCREngine::ConstructL()" ); + + // Note, quite high priority + iCleanUp = new ( ELeave ) CAsyncCallBack( CActive::EPriorityStandard ); + } + +// ----------------------------------------------------------------------------- +// CCREngine::~CCREngine +// Destructor. +// ----------------------------------------------------------------------------- +// +CCREngine::~CCREngine() + { + LOG( "CCREngine::~CCREngine()" ); + + delete iCleanUp; + iSessions.ResetAndDestroy(); + iSessionsToDelete.Reset(); + delete iConnection; +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + delete iClipHandler; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + iSockServer.Close(); + delete iInformer; + delete iQueueName; + } + +// ----------------------------------------------------------------------------- +// Method for actual message handling. +// +// ----------------------------------------------------------------------------- +// +void CCREngine::GeneralServiceL( const RMessage2& aMessage ) + { +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + if ( aMessage.Function() != ECRGetPosition ) + { + LOG1( "CCREngine::GeneralService(), aMessage: %d", aMessage.Function() ); + } +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + // Verify cababilities + VerifyCapabilitiesL( aMessage ); + + // Handle message + TInt err( KErrNone ); + switch( aMessage.Function() ) + { + case ECRSetIap: + { + TPckgBuf pckg; + Read( aMessage, 0, pckg ); + err = SetConnectionId( pckg() ); + aMessage.Complete( err ); + } + break; + + case ECRCancelSetIap: + aMessage.Complete( CancelSetConnectionId() ); + break; + + case ECRPlayRtspUrl: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = PlayRtspUrlL( pckg1() ) ); + if ( !err ) + { + Write( aMessage, 0, pckg0 ); + } + aMessage.Complete( err ); + } + break; + + case ECRPlayDvbhLive: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = PlayDvbhLiveL( pckg1() ) ); + if ( !err ) + { + Write( aMessage, 0, pckg0 ); + } + aMessage.Complete( err ); + } + break; + + case ECRChangeService: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 0, pckg0 ); + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = ChangeDvbhServiceL( pckg0(), pckg1() ) ); + if ( !err ) + { + Write( aMessage, 0, pckg0 ); + } + aMessage.Complete( err ); + } + break; + + case ECRPlayRtpFile: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = PlayRtpFileL( pckg1() ) ); + if ( !err ) + { + Write( aMessage, 0, pckg0 ); + } + aMessage.Complete( err ); + } + break; + + case ECRPlayRtpHandle: + { + RFile fileHandle; + err = fileHandle.AdoptFromClient( aMessage, 1, 2 ); + if ( !err ) + { + TPckgBuf pckg( 0 ); + TRAP( err, pckg() = PlayRtpFileL( fileHandle ) ); + if ( !err ) + { + Write( aMessage, 0, pckg ); + } + } + fileHandle.Close(); + aMessage.Complete( err ); + } + break; + + case ECRRecordCurrentStream: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TRAP( err, RecordCurrentStreamL( pckg0(), pckg1() ) ); + aMessage.Complete( err ); + } + break; + + case ECRRecordRtspStream: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TPckgBuf pckg2; + Read( aMessage, 2, pckg2 ); + TRAP( err, pckg0() = RecordRtspStreamL( pckg1(), pckg2() ) ); + aMessage.Complete( err ); + } + break; + + case ECRRecordDvbhStream: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TPckgBuf pckg2; + Read( aMessage, 2, pckg2 ); + TRAP( err, pckg0() = RecordDvbhStreamL( pckg1(), pckg2() ) ); + aMessage.Complete( err ); + } + break; + + case ECRPauseRecordStream: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 1, pckg1 ); + aMessage.Complete( PauseRecordStream( pckg0(), pckg1() ) ); + } + break; + + case ECRStopRecordStream: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + aMessage.Complete( StopRecordStream( pckg0() ) ); + } + break; + + case ECRStartTimeShift: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = StartTimeShiftL( pckg1() ) ); + if ( !err ) + { + Write( aMessage, 0, pckg0 ); + } + aMessage.Complete( err ); + } + break; + + case ECRStopTimeShift: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 0, pckg0 ); + Read( aMessage, 1, pckg1 ); + aMessage.Complete( StopTimeShift( pckg0(), pckg1() ) ); + } + break; + + case ECRPlayCommand: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 1, pckg1 ); + TPckgBuf pckg2( 0 ); + Read( aMessage, 2, pckg2 ); + aMessage.Complete( PlayCommand( pckg0(), pckg1(), pckg2() ) ); + } + break; + + case ECRPauseCommand: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + aMessage.Complete( PauseCommand( pckg0() ) ); + } + break; + + case ECRStopCommand: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + aMessage.Complete( StopCommand( pckg0() ) ); + } + break; + + case ECRSetPosition: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 1, pckg1 ); + err = SetPosition( pckg0(), pckg1() ); + aMessage.Complete( err ); + } + break; + + case ECRGetPosition: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + TPckgBuf pckg1( 0 ); + Read( aMessage, 1, pckg1 ); + TPckgBuf pckg2( 0 ); + err = GetPosition( pckg0(), pckg1(), pckg2() ); + Write( aMessage, 1, pckg1 ); + Write( aMessage, 2, pckg2 ); + aMessage.Complete( err ); + } + break; + + case ECRCloseSession: + { + TPckgBuf pckg0( 0 ); + Read( aMessage, 0, pckg0 ); + aMessage.Complete( CloseSession( pckg0() ) ); + } + break; + + case ECRPlayNullSource: + { + TPckgBuf pckg0( 0 ); + TRAP( err, pckg0() = PlayNullSourceL() ); + Write( aMessage, 0, pckg0 ); + aMessage.Complete( err ); + } + break; + + case ECRPlayRtspUrlToNullSink: + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1; + Read( aMessage, 1, pckg1 ); + TRAP( err, pckg0() = PlayRtspUrlToNullSinkL( pckg1() ) ); + Write( aMessage, 0, pckg0 ); + aMessage.Complete( err ); + } + break; + + default: + aMessage.Complete( KErrNotSupported ); + break; + } + } + +//----------------------------------------------------------------------------- +// CCREngine::SessionStop() +// So, a session wants to quit. we can't just delete it here as return. +// Statement would then take us to deleted instance: put up a cleanup +// CAsyncCallBack and return. +//----------------------------------------------------------------------------- +// +void CCREngine::SessionStop( CCRStreamingSession* aSession ) + { + LOG1( "CCREngine::SessionStop(), Delete count: %d", iSessionsToDelete.Count() ); + + // InsertInAddressOrder checks for duplicate, if there is already + // entry for that session, the array will remain unchanged + TRAPD( err, iSessionsToDelete.InsertInAddressOrderL( aSession ) ); + if ( err ) + { + LOG1( "CCREngine::SessionStop(), InsertInAddressOrder leaved: %d", err ); + } + + // If not already active and sessions to delete? + if ( !iCleanUp->IsActive() && iSessionsToDelete.Count() ) + { + TCallBack cb( SessionStopCallBack, this ); + iCleanUp->Set( cb ); + iCleanUp->CallBack(); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::ConnectionStatusChange +// +// ----------------------------------------------------------------------------- +// +void CCREngine::ConnectionStatusChange( + TInt aSessionId, + TCRConnectionStatus aStatus, + TInt aErr ) + { + LOG3( "CCREngine::ConnectionStatusChange(), aSessionId: %d, aStatus: %d, Error: %d", + aSessionId, aStatus, aErr ); + + SCRQueueEntry entry = { ECRMsgQueueConnectionError, KErrNone }; + entry.iSessionId = aSessionId; + + switch ( aStatus ) + { + case ECRConnectionError: + { + entry.iMsg = ECRMsgQueueConnectionError; + entry.iErr = aErr; + } + break; + + case ECRAuthenticationNeeded: + { + entry.iMsg = ECRMsgQueueAuthenticationNeeded; + entry.iErr = KErrNone; + } + break; + + case ECRNotEnoughBandwidth: + { + entry.iMsg = ECRMsgQueueNotEnoughBandwidth; + entry.iErr = KErrNone; + } + break; + + case ECRNormalEndOfStream: + { + entry.iMsg = ECRMsgQueueNormalEndOfStream; + entry.iErr = aErr; + } + break; + + case ECRAttachCompleted: // fall through + case ECRSwitchingToTcp: + { + aStatus == ECRAttachCompleted ? + ( entry.iMsg = ECRMsgQueueAttachCompleted ) : + ( entry.iMsg = ECRMsgQueueSwitchingToTcp ); + + if ( aErr == KErrNone ) + { + // Releasing RSocket takes almost 40 seconds so we need + // to always use different port number, otherwise an + // "Already in use" error will be occurred. + TTime now; + now.UniversalTime(); + TInt port = KCRELoopbackPortStart + now.DateTime().Second(); + iLoopbackPort == port ? ( iLoopbackPort = port + 1 ) : + ( iLoopbackPort = port ); + + // Loopback port for VIA + entry.iErr = iLoopbackPort; + } + else + { + entry.iErr = aErr; + } + } + break; + + case ECRStreamIsLiveStream: + { + entry.iMsg = ECRMsgQueueStreamIsLiveStream; + entry.iErr = aErr; + } + break; + + case ECRStreamIsRealMedia: + { + entry.iMsg = ECRMsgQueueStreamIsRealMedia; + entry.iErr = aErr; + } + break; + + case ECRBearerChanged: + { + // Nobody is interested about this on the other side... + return; + } + + case ECRTestSinkData: + { + entry.iMsg = ECRMsgQueueTestSinkData; + entry.iErr = aErr; + } + break; + + case ECRSdpAvailable: + { + entry.iMsg = ECRMsgQueueSdpAvailable; + entry.iErr = aErr; + } + break; + + case ECRReadyToSeek: + { + entry.iMsg = ECRMsgQueueReadyToSeek; + entry.iErr = aErr; + } + break; + + case ECRRecordingStarted: + { + entry.iMsg = ECRMsgQueueRecordingStarted; + entry.iErr = aErr; + } + break; + + case ECRRecordingPaused: + { + entry.iMsg = ECRMsgQueueRecordingPaused; + entry.iErr = aErr; + } + break; + + case ECRRecordingEnded: + { + entry.iMsg = ECRMsgQueueRecordingEnded; + entry.iErr = aErr; + } + break; + + default: + // None + break; + } + + if ( iQueueName && iInformer ) + { + iInformer->SendMessage( iQueueName->Des(), entry ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifyCapabilitiesL +// Checks capabilities of user of DVR API. +// ----------------------------------------------------------------------------- +// +void CCREngine::VerifyCapabilitiesL( const RMessage2& aMessage ) + { + if ( !aMessage.HasCapability( ECapabilityNetworkServices, + __PLATSEC_DIAGNOSTIC_STRING( "NetworkServices" ) ) ) + { + LOG( "CCREngine::VerifyRbfCapabilitiesL(), Missing: NetworkServices !" ); + User::Leave( KErrPermissionDenied ); + } + + if ( !aMessage.HasCapability( ECapabilityReadUserData, + __PLATSEC_DIAGNOSTIC_STRING( "ReadUserData" ) ) ) + { + LOG( "CCREngine::VerifyRbfCapabilitiesL(), Missing: ReadUserData !" ); + User::Leave( KErrPermissionDenied ); + } + + if ( !aMessage.HasCapability( ECapabilityWriteUserData, + __PLATSEC_DIAGNOSTIC_STRING( "WriteUserData" ) ) ) + { + LOG( "CCREngine::VerifyRbfCapabilitiesL(), Missing: WriteUserData !" ); + User::Leave( KErrPermissionDenied ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::SetConnectionId +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::SetConnectionId( const SCRRtspIapParams& aIap ) + { + LOG( "CCREngine::SetConnectionId() in" ); + + TRAPD ( err, CreateConnectionL() ) ; + if ( err == KErrNone ) + { + delete iQueueName; iQueueName = NULL; + TRAP( err, iQueueName = aIap.iQueueName.AllocL() ); + if ( err == KErrNone ) + { + iConnection->Attach( aIap.iConnectionId ); + } + + } + LOG1( "CCREngine::SetConnectionId() out, err: %d", err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CCREngine::CancelSetConnectionId +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::CancelSetConnectionId() + { + LOG( "CCREngine::CancelSetConnectionId() in" ); + + TInt err( KErrNone ); + if ( iConnection ) + { + iSessions.ResetAndDestroy(); + delete iConnection; iConnection = NULL; + iSockServer.Close(); + err = iSockServer.Connect( KESockDefaultMessageSlots * 3 ); + if ( err == KErrNone ) + { + TRAP( err, iConnection = CCRConnection::NewL( iSockServer ) ); + if ( err == KErrNone && iConnection ) + { + err = iConnection->RegisterObserver( this ); + } + } + } + + LOG1( "CCREngine::CancelSetConnectionId() out, err: %d", err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayRtspUrlL +// Go through stream sessions and try to find if given url is already playing. +// If not, create new RTSP session and add sink to it. +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayRtspUrlL( const SCRRtspParams& aRtspParams ) + { + LOG( "CCREngine::PlayRtspUrlL() in" ); + + const TInt sessionIndex( VerifyRtspSessionL( aRtspParams ) ); + iSessions[sessionIndex]->CreateRtspSinkL( iLoopbackPort ); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayRtspUrlL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayDvbhLiveL +// Go through stream sessions and try to find if current service is already +// If not, create new DVB-H session and add sink to it. +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayDvbhLiveL( const SCRLiveParams& aLiveParams ) + { + LOG( "CCREngine::PlayDvbhLiveL() in" ); + + const TInt sessionIndex( VerifyDvbhSessionL( aLiveParams ) ); + iSessions[sessionIndex]->CreateXpsSinkL(); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayDvbhLiveL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::ChangeDvbhServiceL +// Go through stream sessions and try to find if current service is already +// If not, create new DVB-H session and add sink to it. +// ----------------------------------------------------------------------------- +// +TUint CCREngine::ChangeDvbhServiceL( + const TUint aSessionChk, + const SCRLiveParams& aLiveParams ) + { + LOG( "CCREngine::ChangeDvbhServiceL() in" ); + + // Verify exist session + const TInt currentSession( VerifySession( aSessionChk ) ); + User::LeaveIfError( currentSession ); + + // Can't perform if recording or timeshift ongoing + if ( iSessions[currentSession]->ClipHandlerUsed() ) + { + User::Leave( KErrInUse ); + } + + // New session for new service + const TInt sessionIndex( VerifyDvbhSessionL( aLiveParams ) ); + if ( sessionIndex == currentSession ) + { + // Same service, no actions + return aSessionChk; + } + + // Stop sockets of DVB-H source (filters released) + User::LeaveIfError( iSessions[currentSession]->StopCommand() ); + + // Transfer ownership of existing XPS sink to a new session + User::LeaveIfError( iSessions[currentSession]->TransferSink( + CCRStreamingSession::ECRXpsSinkId, *iSessions[sessionIndex] ) ); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + + // Delete existing unused session + SessionStop( iSessions[currentSession] ); + LOG1( "CCREngine::ChangeDvbhServiceL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayRtpFileL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayRtpFileL( const SCRRtpPlayParams& aRtpParams ) + { + LOG( "CCREngine::PlayRtpFileL() in" ); + + const TInt sessionIndex( VerifyRtpFileSessionL( aRtpParams ) ); + iSessions[sessionIndex]->CreateXpsSinkL(); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayRtpFileL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayRtpFileL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayRtpFileL( const RFile& aFileHandle ) + { + LOG( "CCREngine::PlayRtpFileL() in, with hadle" ); + + TInt sessionIndex( VerifyRtpFileSessionL( aFileHandle ) ); + iSessions[sessionIndex]->CreateXpsSinkL(); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayRtpFileL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::RecordCurrentStreamL +// +// ----------------------------------------------------------------------------- +// +void CCREngine::RecordCurrentStreamL( + const TUint aSessionChk, + const SCRRecordParams& aRecordParams ) + { + LOG1( "CCREngine::StartRecordStreamL() in, aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // Session exist? + if ( sessionIndex > KErrNotFound ) + { + CreateRecordingSinkL( sessionIndex, aRecordParams ); + iSessions[sessionIndex]->PostActionL(); + } + + LOG1( "CCREngine::StartRecordStreamL() out, sessionIndex: %d", sessionIndex ); + } + +// ----------------------------------------------------------------------------- +// CCREngine::RecordRtspStreamL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::RecordRtspStreamL( + const SCRRtspParams& aRtspParams, + const SCRRecordParams& aRecordParams ) + { + LOG( "CCREngine::RecordRtspStreamL() in" ); + + // Verify session + const TInt sessionIndex( VerifyRtspSessionL( aRtspParams ) ); + + // Recording sink + CreateRecordingSinkL( sessionIndex, aRecordParams ); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::RecordRtspStreamL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::RecordDvbhStreamL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::RecordDvbhStreamL( + const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ) + { + LOG( "CCREngine::RecordDvbhStreamL() in" ); + + // Verify session + const TInt sessionIndex( VerifyDvbhSessionL( aLiveParams ) ); + + // Recording sink + CreateRecordingSinkL( sessionIndex, aRecordParams ); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::RecordDvbhStreamL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PauseRecordStream +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::PauseRecordStream( const TUint aSessionChk, const TBool& aStart ) + { + LOG2( "CCREngine::PauseRecordStream() in, aSessionChk: %d, aStart: %d", + aSessionChk, aStart ); + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // Session exist? + if ( sessionIndex > KErrNotFound ) + { + TInt err( KErrNone ); + if ( aStart ) + { + // Clip format not known, so all types must try to pause + err = iSessions[sessionIndex]->PauseCommand( + CCRStreamingSession::ECRRtpRecSinkId ); + if ( err == KErrCompletion ) + { + err = iSessions[sessionIndex]->PauseCommand( + CCRStreamingSession::ECR3gpRecSinkId ); + } + + ConnectionStatusChange( aSessionChk, ECRRecordingPaused, err ); + } + else + { + // Clip format not known, so all types must try to pause + err = iSessions[sessionIndex]->RestoreCommand( + CCRStreamingSession::ECRRtpRecSinkId ); + if ( err == KErrCompletion ) + { + err = iSessions[sessionIndex]->RestoreCommand( + CCRStreamingSession::ECR3gpRecSinkId ); + } + + ConnectionStatusChange( aSessionChk, ECRRecordingStarted, err ); + } + + LOG1( "CCREngine::PauseRecordStream() out, err: %d", err ); + return err; + } + + LOG1( "CCREngine::PauseRecordStream() out, sessionIndex: %d", sessionIndex ); + return sessionIndex; + } + +// ----------------------------------------------------------------------------- +// CCREngine::StopRecordStream +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::StopRecordStream( const TUint aSessionChk ) + { + LOG1( "CCREngine::StopRecordStream() in, aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // Session exist? + if ( sessionIndex > KErrNotFound ) + { + // Clip format not known, so all types must try to stop + iSessions[sessionIndex]->StopCommand( + CCRStreamingSession::ECRRtpRecSinkId ); + iSessions[sessionIndex]->StopCommand( + CCRStreamingSession::ECR3gpRecSinkId ); + // Possible error(s) ignored + } + + LOG1( "CCREngine::StopRecordStream() out, sessionIndex: %d", sessionIndex ); + return sessionIndex; + } + +// ----------------------------------------------------------------------------- +// CCREngine::StartTimeShift +// Existing stream play will be splitted to two sessions. Existing source will +// be directed to recording and existing sink will get new source from playback. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::StartTimeShiftL( const TUint aSessionChk ) + { + LOG1( "CCREngine::StartTimeShiftL() in, aSessionChk: %d", aSessionChk ); + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + // Verify session + const TInt currentSession( VerifySession( aSessionChk ) ); + User::LeaveIfError( currentSession ); + + // Initial time shift clip name + TPath initialName( KDvrTimeShiftFile ); + initialName.AppendNum( 0 ); + + // RTP clip handler + CreateClipHandlerL(); + + // Start recording of stream + SCRRecordParams recordParams; + recordParams.iFileName.Set( initialName ); + recordParams.iFormat = ECRRecordTimeShift; + iSessions[currentSession]->CreateRtpRecordSinkL( recordParams, iClipHandler ); + iSessions[currentSession]->PostActionL(); + + // Create new session for time shift clip playback + SCRRtpPlayParams params; + params.iFileName = initialName; + const TInt timeShiftSession( VerifyRtpFileSessionL( params ) ); + iSessions[timeShiftSession]->PostActionL(); + + // Transfer ownership of existing XPS sink to a new session + User::LeaveIfError( iSessions[currentSession]->TransferSink( + CCRStreamingSession::ECRXpsSinkId, *iSessions[timeShiftSession] ) ); + + // Session checksum + TUint sessionChk( iSessions[timeShiftSession]->SourceChecksum() ); + LOG1( "CCREngine::StartTimeShiftL() out, sessionChk: %d", sessionChk ); + return sessionChk; + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aSessionChk; + return KErrNotSupported; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::StopTimeShift +// Streaming is set back to one session. Streaming orginal source stays and sink +// from temporary playback will be moved back to orginal session. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::StopTimeShift( + const TUint aTimeShiftChk, + const TUint aCurrentChk ) + { + LOG2( "CCREngine::StopTimeShift() in, aTimeShiftChk: %d, aCurrentChk: %d", + aTimeShiftChk, aCurrentChk ); +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + // Verify session + int ret( KErrNotFound ); + const TInt currentSession( VerifySession( aCurrentChk ) ); + const TInt timeShiftSession( VerifySession( aTimeShiftChk ) ); + + // Session exist? + if ( currentSession > KErrNotFound && timeShiftSession > KErrNotFound ) + { + // Stop time shift clip recording + iSessions[currentSession]->StopCommand( + CCRStreamingSession::ECR3gpRecSinkId ); + + // Stop time shift clip playback + iSessions[timeShiftSession]->StopCommand(); + + // Transfer ownership of existing XPS sink back to the old session + ret = iSessions[timeShiftSession]->TransferSink( + CCRStreamingSession::ECRXpsSinkId, *iSessions[currentSession] ); + + // Delete second session + SessionStop( iSessions[timeShiftSession] ); + } + + // Clip handler not needed any longer + DeleteClipHandler( currentSession ); + + LOG1( "CCREngine::StopTimeShift() out, ret: %d", ret ); + return ret; + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aTimeShiftChk; + ( void )aCurrentChk; + return KErrNotSupported; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayCommand +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::PlayCommand( + const TUint aSessionChk, + const TReal aStartPos, + const TReal aEndPos ) + { + LOG1( "CCREngine::PlayCommand(), aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // New session needed? + if ( sessionIndex > KErrNotFound ) + { + return iSessions[sessionIndex]->PlayCommand( aStartPos, aEndPos ); + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PauseCommand +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::PauseCommand( const TUint aSessionChk ) + { + LOG1( "CCREngine::PauseCommand(), aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // New session needed? + if ( sessionIndex > KErrNotFound ) + { + return iSessions[sessionIndex]->PauseCommand(); + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCREngine::StopCommand +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::StopCommand( const TUint aSessionChk ) + { + LOG1( "CCREngine::StopCommand(), aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + + // New session needed? + if ( sessionIndex > KErrNotFound ) + { + return iSessions[sessionIndex]->StopCommand(); + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCREngine::SetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::SetPosition( + const TUint aSessionChk, + const TInt64 aPosition ) + { + LOG1( "CCREngine::SetPosition(), aSessionChk: %d", aSessionChk ); + + const TInt sessionIndex( VerifySession( aSessionChk ) ); + if ( sessionIndex > KErrNotFound ) + { + return iSessions[sessionIndex]->SetPosition( aPosition ); + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCREngine::GetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::GetPosition( + const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ) + { + const TInt sessionIndex( VerifySession( aSessionChk ) ); + if ( sessionIndex > KErrNotFound ) + { + return iSessions[sessionIndex]->GetPosition( aPosition, aDuration ); + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCREngine::CloseSession +// +// ----------------------------------------------------------------------------- +// +TInt CCREngine::CloseSession( const TUint aSessionChk ) + { + LOG1( "CCREngine::CloseSession(), aSessionChk: %d", aSessionChk ); + + // Verify session + const TInt sessionIndex( VerifySession( aSessionChk ) ); + if ( sessionIndex > KErrNotFound ) + { + SessionStop( iSessions[sessionIndex] ); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayNullSourceL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayNullSourceL() + { + LOG( "CCREngine::PlayNullSourceL() in" ); + + _LIT( KNullSourceClip, "NullSource.rtp" ); + TFileName nullSourcePath; +#if ( defined( __WINS__ ) || defined( __WINSCW__ ) ) + nullSourcePath = PathInfo::PhoneMemoryRootPath(); +#else // __WINS__ || __WINSCW__ + nullSourcePath = PathInfo::MemoryCardRootPath(); +#endif // __WINS__ || __WINSCW__ + nullSourcePath.Append( KNullSourceClip ); + + TInt sessionIndex( VerifySession( nullSourcePath ) ); + if ( sessionIndex == KErrNotFound ) + { + CCRStreamingSession* session = CCRStreamingSession::NewL( + iSockServer, iConnection, *this ); + CleanupStack::PushL( session ); + User::LeaveIfError( iSessions.Append( session ) ); + CleanupStack::Pop( session ); + + // Only one source per session + sessionIndex = iSessions.Count() - 1; + iSessions[sessionIndex]->OpenSourceL( nullSourcePath ); + } + + iSessions[sessionIndex]->CreateXpsSinkL(); + //iSessions[sessionIndex]->CreateNullSinkL(); + iSessions[sessionIndex]->PostActionL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayNullSourceL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::PlayRtspUrlToNullSinkL +// +// ----------------------------------------------------------------------------- +// +TUint CCREngine::PlayRtspUrlToNullSinkL( const SCRRtspParams& aRtspParams ) + { + LOG( "CCREngine::PlayRtspUrlToNullSinkL() in" ); + + const TInt sessionIndex( VerifyRtspSessionL( aRtspParams ) ); + iSessions[sessionIndex]->CreateNullSinkL(); + TUint sessionChk( iSessions[sessionIndex]->SourceChecksum() ); + LOG1( "CCREngine::PlayRtspUrlToNullSinkL() out, sessionChk: %d", sessionChk ); + return sessionChk; + } + +// ----------------------------------------------------------------------------- +// CCREngine::CreateConnectionL +// +// ----------------------------------------------------------------------------- +// +void CCREngine::CreateConnectionL( void ) + { + LOG( "CCREngine::CreateConnectionL() in" ); + + if ( iConnection == NULL ) + { + User::LeaveIfError( iSockServer.Connect( KESockDefaultMessageSlots * 3 ) ); + iConnection = CCRConnection::NewL( iSockServer ); + User::LeaveIfError( iConnection->RegisterObserver( this ) ); + + // Informer + if ( iInformer == NULL ) + { + iInformer = CCRClientInformer::NewL(); + } + } + + LOG( "CCREngine::CreateConnectionL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCREngine::CreateClipHandlerL +// +// ----------------------------------------------------------------------------- +// +void CCREngine::CreateClipHandlerL( void ) + { + LOG1( "CCREngine::CreateClipHandlerL(), iClipHandler: %d", iClipHandler ); + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + if ( !iClipHandler ) + { + iClipHandler = CRtpClipHandler::NewL(); + } +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifyRtspSessionL +// Go through stream sessions and try to find if RTSP stream is already playing. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifyRtspSessionL( const SCRRtspParams& aRtspParams ) + { + TInt sessionIndex( VerifySession( aRtspParams.iUrl ) ); + + // New session needed? + if ( sessionIndex == KErrNotFound ) + { + CCRStreamingSession* session = CCRStreamingSession::NewL( + iSockServer, iConnection, *this ); + CleanupStack::PushL( session ); + User::LeaveIfError( iSessions.Append( session ) ); + CleanupStack::Pop( session ); + + // Only one source per session + sessionIndex = iSessions.Count() - 1; + iSessions[sessionIndex]->OpenSourceL( aRtspParams, aRtspParams.iUrl ); + } + + User::LeaveIfError( sessionIndex ); + return sessionIndex; + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifyDvbhSessionL +// Go through stream sessions and try to find if DVB-H live is already playing. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifyDvbhSessionL( const SCRLiveParams& aLiveParams ) + { + // Verify session + HBufC* definition = HBufC::NewLC( aLiveParams.iSdpData.Length() ); + definition->Des().Copy( aLiveParams.iSdpData ); + TInt sessionIndex( VerifySession( *definition ) ); + + // New session needed? + if ( sessionIndex == KErrNotFound ) + { + CCRStreamingSession* session = CCRStreamingSession::NewL( + iSockServer, iConnection, *this ); + CleanupStack::PushL( session ); + User::LeaveIfError( iSessions.Append( session ) ); + CleanupStack::Pop( session ); + + // Only one source per session + sessionIndex = iSessions.Count() - 1; + iSessions[sessionIndex]->OpenSourceL( aLiveParams, *definition ); + } + + CleanupStack::PopAndDestroy( definition ); + User::LeaveIfError( sessionIndex ); + return sessionIndex; + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifyRtpFileSessionL +// Go through stream sessions and try to find if RTP clip is already playing. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifyRtpFileSessionL( const SCRRtpPlayParams& aRtpParams ) + { +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + // Verify session + TInt sessionIndex( VerifySession( aRtpParams.iFileName ) ); + + // New session needed? + if ( sessionIndex == KErrNotFound ) + { + + CCRStreamingSession* session = CCRStreamingSession::NewL( + iSockServer, iConnection, *this ); + CleanupStack::PushL( session ); + User::LeaveIfError( iSessions.Append( session ) ); + CleanupStack::Pop( session ); + + // RTP clip handler + CreateClipHandlerL(); + + // Only one source per session + sessionIndex = iSessions.Count() - 1; + iSessions[sessionIndex]->OpenSourceL( aRtpParams, iClipHandler, + aRtpParams.iFileName ); + } + + User::LeaveIfError( sessionIndex ); + return sessionIndex; + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aRtpParams; + return KErrNotSupported; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifyRtpFileSessionL +// Go through stream sessions and try to find if RTP clip is already playing. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifyRtpFileSessionL( const RFile& aFileHandle ) + { +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + TFileName fileName( KNullDesC ); + aFileHandle.FullName( fileName ); + TInt sessionIndex( VerifySession( fileName ) ); + + // New session needed? + if ( sessionIndex == KErrNotFound ) + { + CCRStreamingSession* session = CCRStreamingSession::NewL( + iSockServer, iConnection, *this ); + CleanupStack::PushL( session ); + User::LeaveIfError( iSessions.Append( session ) ); + CleanupStack::Pop( session ); + + // RTP clip handler + CreateClipHandlerL(); + + // Only one source per session + sessionIndex = iSessions.Count() - 1; + iSessions[sessionIndex]->OpenSourceL( aFileHandle, iClipHandler, fileName ); + } + + User::LeaveIfError( sessionIndex ); + return sessionIndex; + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aFileHandle; + return KErrNotSupported; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifySession +// Go through stream sessions and try to find stream is already playing. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifySession( const TDesC& aName ) + { + if ( iSessions.Count() > 0 ) + { + for ( TInt i( iSessions.Count() - 1 ); i >= 0; i-- ) + { + const TUint chksm( iSessions[i]->SourceDefinition( aName ) ); + if ( chksm == iSessions[i]->SourceChecksum() ) + { + return i; + } + } + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CCREngine::VerifySession +// Go through stream sessions and try to find session index from active sessions. +// ----------------------------------------------------------------------------- +// +TInt CCREngine::VerifySession( const TUint aSessionChk ) + { + if ( iSessions.Count() > 0 ) + { + for ( TInt i( iSessions.Count() - 1 ); i >= 0; i-- ) + { + if ( aSessionChk == iSessions[i]->SourceChecksum() ) + { + return i; + } + } + } + + return KErrNotFound; + } + +//----------------------------------------------------------------------------- +// CCREngine::CreateRecordingSinkL +// +//----------------------------------------------------------------------------- +// +void CCREngine::CreateRecordingSinkL( + const TInt aSessionIndex, + const SCRRecordParams& aRecordParams ) + { + LOG1( "CCREngine::CreateRecordingSinkL(), aSessionIndex: %d", aSessionIndex ); + + User::LeaveIfError( aSessionIndex ); + switch ( aRecordParams.iFormat ) + { +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + case ECRRecordFormatRtp: + // RTP clip handler + CreateClipHandlerL(); + iSessions[aSessionIndex]->CreateRtpRecordSinkL( + aRecordParams, iClipHandler ); + break; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + + case ECRRecordFormat3gp: + iSessions[aSessionIndex]->Create3gpRecordSinkL( aRecordParams ); + break; + + default: + LOG( "CCREngine::CreateRecordingSinkL(), Clip format invalid !"); + User::Leave( KErrNotSupported ); + break; + } + } + +//----------------------------------------------------------------------------- +// CCREngine::SessionStopCallBack +// +//----------------------------------------------------------------------------- +// +TInt CCREngine::SessionStopCallBack ( TAny* aThis ) + { + LOG( "CCREngine::SessionStopCallBack()" ); + + CCREngine* self = static_cast( aThis ); + self->DoSessionStop(); + return self->iSessionsToDelete.Count(); + } + +//----------------------------------------------------------------------------- +// CCREngine::DoSessionStop +// +//----------------------------------------------------------------------------- +// +void CCREngine::DoSessionStop( void ) + { + LOG1( "CCREngine::DoSessionStop() in, iSessionsToDelete.Count = %d", iSessionsToDelete.Count() ); + + for ( TInt i( iSessionsToDelete.Count() - 1 ); i >= 0; i-- ) + { + for ( TInt j( iSessions.Count() - 1 ); j >= 0; j-- ) + { + if ( iSessions[j] == iSessionsToDelete[i] ) + { + delete iSessions[j]; + iSessions.Remove( j ); + } + } + } + + // Supposed to be empty by now + DeleteClipHandler( KErrNotFound ); + iSessionsToDelete.Reset(); + LOG( "CCREngine::DoSessionStop() out" ); + } + +//----------------------------------------------------------------------------- +// CCREngine::DeleteClipHandler +// +//----------------------------------------------------------------------------- +// +void CCREngine::DeleteClipHandler( const TInt aCurrentSessionIndex ) + { + LOG1( "CCREngine::DeleteClipHandler(), aCurrentSessionIndex: %d", + aCurrentSessionIndex ); +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + if ( iClipHandler ) + { + // Find out clip handler usage + TBool notUsed( ETrue ); + for ( TInt i( iSessions.Count() - 1 ); i >= 0; i-- ) + { + if ( i != aCurrentSessionIndex && iSessions[i]->ClipHandlerUsed() ) + { + notUsed = EFalse; + } + } + + // Clip handler not needed any longer? + if ( notUsed ) + { + delete iClipHandler; iClipHandler = NULL; + LOG( "CCREngine::DeleteClipHandler(), RTP ClipHandler deleted !" ); + } + } + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aCurrentSessionIndex; +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCREngine::Read +// Read from the client thread, if unsuccessful, panic the client. +// ----------------------------------------------------------------------------- +// +void CCREngine::Read( + const RMessage2& aMessage, + const TInt& aParam, + TDes8& aDes ) + { + TRAPD( err, aMessage.ReadL( aParam, aDes ) ); + if ( err ) + { + PanicClient( ECRPanicBadDescriptor, aMessage ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::Read +// Read from the client thread, if unsuccessful, panic the client. +// ----------------------------------------------------------------------------- +// +void CCREngine::Read( + const RMessage2& aMessage, + const TInt& aParam, + TDes16& aDes ) + { + TRAPD( err, aMessage.ReadL( aParam, aDes ) ); + if ( err ) + { + PanicClient( ECRPanicBadDescriptor, aMessage ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::Write +// Write to the client thread, if unsuccessful, panic the client. +// ----------------------------------------------------------------------------- +// +void CCREngine::Write( + const RMessage2& aMessage, + const TInt& aParam, + const TDesC8& aDes ) + { + TRAPD( err, aMessage.WriteL( aParam, aDes ) ); + if ( err ) + { + PanicClient( ECRPanicBadDescriptor, aMessage ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::Write +// Write to the client thread, if unsuccessful, panic the client. +// ----------------------------------------------------------------------------- +// +void CCREngine::Write( + const RMessage2& aMessage, + const TInt& aParam, + const TDesC16& aDes ) + { + TRAPD( err, aMessage.WriteL( aParam, aDes ) ); + if ( err ) + { + PanicClient( ECRPanicBadDescriptor, aMessage ); + } + } + +// ----------------------------------------------------------------------------- +// CCREngine::PanicClient +// +// ----------------------------------------------------------------------------- +// +void CCREngine::PanicClient( TInt aPanic, const RMessage2& aMessage ) + { + // Panic the client on server side + _LIT( KRbfClientFault, "Common recording engine" ); + aMessage.Panic( KRbfClientFault, aPanic ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRNullSink.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRNullSink.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that takes packet from buffer and does not put them* +*/ + + + + +// INCLUDE FILES +#include "CCRNullSink.h" +#include "CCRPacketBuffer.h" +#include "CCRStreamingSession.h" +#include "CCRTimer.h" +#include "MCRConnectionObserver.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRNullSink::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRNullSink* CCRNullSink::NewL( + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ) + { + CCRNullSink* self = new( ELeave ) CCRNullSink( aSinkId, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::CCRNullSink +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRNullSink::CCRNullSink( + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ) + : CCRPacketSinkBase( aOwningSession, aSinkId ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::ConstructL +// 2nd phase. +// ----------------------------------------------------------------------------- +// +void CCRNullSink::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::~CCRNullSink +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRNullSink::~CCRNullSink() + { + delete iSdp; + delete iFlowTimer; + iBuffer = NULL; // does not delete and it is right thing. + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::SetSdpL +// as a side-effect causes parsing of the sdp. +// ----------------------------------------------------------------------------- +// +void CCRNullSink::SetSdpL( const TDesC8& aSdp ) + { + LOG1( "CCRNullSink::SetSdpL(), aSdp len: %d", aSdp.Length() ); + + delete iSdp; iSdp = NULL; + iSdp = aSdp.AllocL(); + iOwningSession.PlayCommand( KRealZero, KRealMinusOne ); + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::NewPacketAvailable +// +// ----------------------------------------------------------------------------- +// +void CCRNullSink::NewPacketAvailable() + { + if ( iBuffer ) + { + TPtr8 packet( NULL, 0 ); + MCRPacketSource::TCRPacketStreamId streamId; + const TInt book( iBuffer->GetStream( iSinkId, streamId ) ); + iBuffer->GetPacket( book, packet ); + const TUint8* pointer( &packet[2] ); + TInt seq( BigEndian::Get16( pointer ) ); + LOG2( "CCRNullSink::NewPacketAvailable(), streamId: %u, seq: %u", + streamId, seq ); + // Keep buffer size reasonable + iBuffer->HandleBufferSize(); + + // Handle flow control + if ( !iBuffer->ContinousStream() && !iFlowTimer ) + { + TRAPD( err, iFlowTimer = CCRTimer::NewL( CActive::EPriorityLow, *this ) ); + if ( !err ) + { + if ( iBuffer->PacketsCount( iSinkId ) > KErrNotFound ) + { + iFlowTimer->After( 0 ); + } + else + { + iFlowTimer->At( 2e6 ); + } + } + else + { + delete iFlowTimer; iFlowTimer = NULL; + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::TimerExpired +// ----------------------------------------------------------------------------- +// +void CCRNullSink::TimerExpired( CCRTimer* /*aTimer*/ ) + { + if ( iBuffer->PacketsCount( iSinkId ) > KErrNotFound ) + { + NewPacketAvailable(); + } + else + { + iOwningSession.SourceRestore(); + } + + delete iFlowTimer; iFlowTimer = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::RegisterConnectionObs +// ----------------------------------------------------------------------------- +// +void CCRNullSink::RegisterConnectionObs( MCRConnectionObserver* aObserver ) + { + iObserver = aObserver; + } + +// ----------------------------------------------------------------------------- +// CCRNullSink::StatusChanged +// ----------------------------------------------------------------------------- +// +void CCRNullSink::StatusChanged( MCRPacketSource::TCRPacketSourceState aNewState ) + { + if( iObserver ) + { + TCRTestSinkData data = aNewState==MCRPacketSource::ERtpStateIdle ? ECRTestSinkStateIdle : + aNewState==MCRPacketSource::ERtpStateSdpAvailable ? ECRTestSinkStateSdpAvailable : + aNewState==MCRPacketSource::ERtpStateSeqAndTSAvailable ? ECRTestSinkStateSeqAndTSAvailable : + aNewState==MCRPacketSource::ERtpStatePlaying ? ECRTestSinkStatePlaying : + /*aNewState==MCRPacketSource::ERtpStateClosing?*/ ECRTestSinkStateClosing; + + LOG3( "CCRNullSink::StatusChanged: newState=%d -> ECRTestSinkData, checksum=%d, data=%d", + (TInt)aNewState, (TInt)iOwningSession.SourceChecksum(), (TInt)data ); + iObserver->ConnectionStatusChange( iOwningSession.SourceChecksum(), + MCRConnectionObserver::ECRTestSinkData, + (TInt)data ); + } + } + + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRNullSource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRNullSource.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,433 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that reads packets from a .rtp clip for testing purposes.* +*/ + + + + +// INCLUDE FILES +#include "CCRNullSource.h" +#include +#include "CCRPacketBuffer.h" +#include "CRtpTimer.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KGroupsCountPoint( 0 ); +const TInt KBufferThesholdCount( 20 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRNullSource::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRNullSource* CCRNullSource::NewL( + const TDesC& aClipName, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + { + CCRNullSource* self = new( ELeave ) + CCRNullSource( aSessionObs, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL( aClipName ); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::CCRNullSource +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRNullSource::CCRNullSource( + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + : CCRPacketSourceBase( aOwningSession, CCRStreamingSession::ECRNullSourceId ), + iSessionObs( aSessionObs ), + iGroupTime( KMaxTUint ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRNullSource::ConstructL( const TDesC& aClipName ) + { + LOG1( "CCRNullSource::ConstructL() in, aClipName: %S", &aClipName ); + + iClipHandler = CRtpClipHandler::NewL(); + iClipHandler->RegisterReadObserver( this ); + + // Start playback + SCRRtpPlayParams params; + params.iFileName = aClipName; + iClipHandler->StartPlayBackL( params ); + + LOG( "CCRNullSource::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::~CCRNullSource +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRNullSource::~CCRNullSource() + { + LOG( "CCRNullSource::~CCRNullSource()" ); + + if ( iClipHandler ) + { + iClipHandler->StopPlayBack( KErrNone, 0 ); + } + + delete iClipHandler; iClipHandler = NULL; + delete iFlowTimer; + delete iSdp; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::GetSdp +// ----------------------------------------------------------------------------- +// +TInt CCRNullSource::GetSdp( TPtrC8& aSdp ) + { + if ( iSdp ) + { + aSdp.Set( iSdp->Des() ); + return KErrNone; + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::SetBuffer +// ----------------------------------------------------------------------------- +// +void CCRNullSource::SetBuffer( CCRPacketBuffer* aBuffer ) + { + iBuffer = aBuffer; + iBuffer->ContinousStream( EFalse ); + iBuffer->MoreComing( EFalse ); + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::PostActionL +// ----------------------------------------------------------------------------- +// +void CCRNullSource::PostActionL() + { + LOG( "CCRNullSource::PostActionL(), SDP will be handled !" ); + + // SDP + iSdp = iClipHandler->GetClipSdpL(); + + // Notify that SDP available + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateSdpAvailable ); + delete iSdp; iSdp = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::Restore +// ----------------------------------------------------------------------------- +// +void CCRNullSource::Restore() + { + delete iFlowTimer; iFlowTimer = NULL; + const TInt err( NextClipGroup() ); + if ( err ) + { + LOG1( "CCRNullSource::Restore(), NextClipGroup() err: %d", err ); + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + } + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::Play +// +// ----------------------------------------------------------------------------- +// +TInt CCRNullSource::Play( const TReal& aStartPos, const TReal& aEndPos ) + { + LOG2( "CCRNullSource::Play(), aStartPos: %f, aEndPos: %f", + aStartPos, aEndPos ); + + if ( aStartPos == KRealZero && aEndPos == KRealZero ) + { + Restore(); + } + + return KErrNone; + } + + +// ----------------------------------------------------------------------------- +// CCRNullSource::Stop +// ----------------------------------------------------------------------------- +// +TInt CCRNullSource::Stop() + { + iClipHandler->StopPlayBack( KErrNone, 0 ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::GetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCRNullSource::GetPosition( TInt64& aPosition, TInt64& aDuration ) + { + if ( iBuffer ) + { + if ( iGroupTime != KMaxTUint ) + { + aPosition += TInt64( iGroupTime ) * KSiKilo; + } + + aDuration = TInt64( iClipHandler->GetCurrentLength() ) * KSiKilo; +#ifdef CR_ALL_LOGS + LOG2( "CCRNullSource::GetPosition(), aPosition: %u, aDuration: %u", + ( TUint )( aPosition / KSiKilo ), ( TUint )( aDuration / KSiKilo ) ); +#endif // CR_ALL_LOGS + return KErrNone; + } + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::GroupReadedL +// Adds packets to the buffer when finished asyncronous group reading. +// ----------------------------------------------------------------------------- +// +void CCRNullSource::GroupReadedL( + const TDesC8& aGroup, + const TUint aGroupTime, + const TBool aLastGroup ) + { + // Group time + if ( iGroupTime == KMaxTUint ) + { + iGroupTime = aGroupTime; + } + + // Data valid? + TInt point( KGroupsCountPoint + KPacketsCountBytes ); + const TInt total( aGroup.Length() ); + if ( point > total ) + { + LOG( "CCRNullSource::GroupReadedL(), No Packets Total Count !" ); + User::Leave( KErrCorrupt ); + } + + // Packets total count (PTC) + const TInt totalCount( CRtpUtil::GetValueL( + aGroup.Mid( KGroupsCountPoint, KPacketsCountBytes ) ) ); + if ( totalCount > 0 ) + { + iBuffer->ContinousStream( ETrue ); + } + + // Loop all packets + for ( TInt i( 0 ); i < totalCount; i++ ) + { + // Corrupted? + if ( ( point + KPacketSizeBytesLen ) > total ) + { + LOG( "CCRNullSource::GroupReadedL(), No Packets Size !" ); + User::Leave( KErrCorrupt ); + } + + // Packet total Size (PTS) + TInt packetSize( CRtpUtil::GetValueL( + aGroup.Mid( point, KPacketSizeBytesLen ) ) ); + // Corrupted? + if ( packetSize <= 0 || ( point + packetSize ) > total ) + { + LOG( "CCRNullSource::GroupReadedL(), No Packets Payload !" ); + User::Leave( KErrCorrupt ); + } + + // Packet type + point += KPacketSizeBytesLen; + const MRtpFileWriteObserver::TRtpType type( + ( MRtpFileWriteObserver::TRtpType )( aGroup[point] ) ); + point += KPacketTypeBytesLen; + packetSize -= ( KPacketSizeBytesLen + KPacketTypeBytesLen ); + + // Insert packet to the buffer + const TPtrC8 packet( aGroup.Mid( point, packetSize ) ); + +#ifdef CR_ALL_LOGS + const TUint8* pointer( &packet[2] ); + TInt seq( BigEndian::Get16( pointer ) ); + LOG3( "CCRNullSource::GroupReadedL(), type: %d, packet: %d, seq: %d", + type, packet.Length(), seq ); + //RFileLogger::WriteFormat( _L( "livetv" ), _L( "play.log" ), EFileLoggingModeAppend, + // _L( "GroupReadedL(), type: %d, packet: %d, seq: %d" ), type, packet.Length(), seq ); +#endif // CR_ALL_LOGS + + MCRPacketSource::TCRPacketStreamId stream( MCRPacketSource::EStreamIdCount ); + if ( TypeToStream( type, stream ) ) + { + // Last packet in group? + if ( i >= ( totalCount - 1 ) ) + { + iBuffer->ContinousStream( EFalse ); + if ( aLastGroup && stream != MCRPacketSource::EStreamEndTag ) + { + LOG( "CCRNullSource::GroupReadedL(), Misses last group from clip !" ); + stream = MCRPacketSource::EStreamEndTag; + } + } + + // Packet to buffer + iBuffer->AddPacket( stream, packet ); + } + + point+= packetSize; + } + + if ( !iFlowTimer ) + { + iFlowTimer = CRtpTimer::NewL( *this ); + iFlowTimer->After( KNormalRecGroupLength * KSiKilo ); + } + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::ReadStatus +// ----------------------------------------------------------------------------- +// +void CCRNullSource::ReadStatus( TInt aStatus ) + { + LOG1( "CCRNullSource::ReadStatus(), aStatus: %d", aStatus ); + + switch ( aStatus ) + { + case MRtpFileReadObserver::ERtpTimeShifTEnd: + break; + + default: + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::TimerEventL +// Internal timer call this when triggered. +// ----------------------------------------------------------------------------- +// +void CCRNullSource::TimerEventL() + { + User::LeaveIfError( NextClipGroup() ); + delete iFlowTimer; iFlowTimer = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::TimerError +// Internal timer call this when TimerEventL() leaves. +// ----------------------------------------------------------------------------- +// +void CCRNullSource::TimerError( const TInt aError ) + { + LOG1( "CCRNullSource::TimerError(), TimerEventL() leaved: %d", aError ); + ( void )aError; // Prevent compiler warning + + delete iFlowTimer; iFlowTimer = NULL; + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::NextClipGroup +// ----------------------------------------------------------------------------- +// +TInt CCRNullSource::NextClipGroup() + { + if ( iBuffer && iClipHandler ) + { + if ( iBuffer->PacketsMinCount() < KBufferThesholdCount ) + { + TRAPD( err, iClipHandler->NextClipGroupL() ); + return err; + } + + return KErrNone; + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCRNullSource::TypeToStream +// ----------------------------------------------------------------------------- +// +TBool CCRNullSource::TypeToStream( + const MRtpFileWriteObserver::TRtpType& aType, + MCRPacketSource::TCRPacketStreamId& aStream ) + { + switch ( aType ) + { + case MRtpFileWriteObserver::ERtpAudio: + aStream = MCRPacketSource::EAudioStream; + break; + + case MRtpFileWriteObserver::ERtcpAudio: + aStream = MCRPacketSource::EAudioControlStream; + break; + + case MRtpFileWriteObserver::ERtpVideo: + aStream = MCRPacketSource::EVideoStream; + break; + + case MRtpFileWriteObserver::ERtcpVideo: + aStream = MCRPacketSource::EVideoControlStream; + break; + + case MRtpFileWriteObserver::ERtpSubTitle: + aStream = MCRPacketSource::ESubTitleStream; + break; + + case MRtpFileWriteObserver::ERtcpSubTitle: + aStream = MCRPacketSource::ESubTitleControlStream; + break; + + case MRtpFileWriteObserver::ERtpClipPause: + LOG( "CCRNullSource::TypeToStream(), ERtpClipPause" ); + aStream = MCRPacketSource::EDisContinousStream; + break; + + case MRtpFileWriteObserver::ERtpClipEnd: + LOG( "CCRNullSource::TypeToStream(), ERtpClipEnd" ); + aStream = MCRPacketSource::EStreamEndTag; + break; + + default: + LOG1( "CCRNullSource::TypeToStream(), Default case, aType: %d", + aType ); + return EFalse; + } + + return ETrue; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRPacketBuffer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRPacketBuffer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,544 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Hold rtp packets waiting to be sent* +*/ + + + + +// INCLUDE FILES +#include "CCRPacketBuffer.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRPacketBuffer* CCRPacketBuffer::NewL( const TInt aMaxPackets ) + { + CCRPacketBuffer* self = new( ELeave ) CCRPacketBuffer( aMaxPackets ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::CCRPacketBuffer +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRPacketBuffer::CCRPacketBuffer( const TInt aMaxPackets ) + : iMaxPackets( aMaxPackets ), + iContinousStream( EFalse ), + iMoreComing( EFalse ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::~CCRPacketBuffer +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRPacketBuffer::~CCRPacketBuffer() + { + LOG( "CCRPacketBuffer::~CCRPacketBuffer" ); + + iBuffer.ResetAndDestroy(); + iBookKeeping.Close(); + iSinkArray.Close(); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::AddSink +// +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::AddSink( CCRPacketSinkBase* aSink ) + { + LOG( "CCRPacketBuffer::AddSink() in" ); + + // Check if sink exist already? + TBool exist( EFalse ); + for ( TInt i( iBookKeeping.Count() - 1 ); i >= 0 && !exist; i-- ) + { + exist = ( aSink->Id() == iBookKeeping[i].iId ); + } + + // If not, add sink to list + TInt err( KErrNone ); + if ( !exist ) + { + SBookKeeping book; + book.iId = aSink->Id(); + book.iIndex = KErrNotFound; + err = iBookKeeping.Append( book ); + if ( !err ) + { + err = iSinkArray.Append( aSink ); + if ( err ) + { + // Remove last from book keeping, because sink append failed + LOG1( "CCRPacketBuffer::AddSink(), Sink append error: %d", err ); + iBookKeeping.Remove( iBookKeeping.Count() - 1 ); + } + } + } + + LOG3( "CCRPacketBuffer::AddSink() out, err: %d, iSinkArray count: %d, iBookKeeping count: %d", + err, iSinkArray.Count(), iBookKeeping.Count() ); + return err; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::AddPacket +// Method for add. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::AddPacket( + const MCRPacketSource::TCRPacketStreamId& aStream, + const TDesC8& aHeader, + const TDesC8& aPacket ) + { + // Room + VerifyRoom(); + + // Add packet + const TInt total( KStreamTypeBytesLength + + aHeader.Length() + aPacket.Length() ); + HBufC8* packet = HBufC8::New( total ); + if ( packet ) + { + TPtr8 ptr( packet->Des() ); + ptr.SetLength( KStreamTypeBytesLength ); + ptr[KStreamTypeBytePoint] = ( TUint8 )( aStream ); + ptr.Append( aHeader ); + ptr.Append( aPacket ); + if ( iBuffer.Insert( packet, 0 ) ) + { + delete packet; + } + else + { + PacketToBookKeeping(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::AddPacket +// Method for add. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::AddPacket( + const MCRPacketSource::TCRPacketStreamId& aStream, + const TDesC8& aPacket ) + { + // Room + VerifyRoom(); + + // Add packet + const TInt total( KStreamTypeBytesLength + aPacket.Length() ); + HBufC8* packet = HBufC8::New( total ); + if ( packet ) + { + TPtr8 ptr( packet->Des() ); + ptr.SetLength( KStreamTypeBytesLength ); + ptr[KStreamTypeBytePoint] = ( TUint8 )( aStream ); + ptr.Append( aPacket ); + if ( iBuffer.Insert( packet, 0 ) ) + { + delete packet; + } + else + { + PacketToBookKeeping(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::ContinousStream +// Method for set buffer estimate when it ends. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::ContinousStream( const TBool aState ) + { + LOG1( "CCRPacketBuffer::ContinousStream(), aState: %d", aState ); + iContinousStream = aState; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::ContinousStream +// Method for get the time when buffer should end. +// ----------------------------------------------------------------------------- +// +TBool CCRPacketBuffer::ContinousStream() + { + return iContinousStream; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer:::MoreComing +// Method for set more coming state. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::MoreComing( const TBool aState ) + { + iMoreComing = aState; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer:::MoreComing +// Method for get more coming state. +// ----------------------------------------------------------------------------- +// +TBool CCRPacketBuffer::MoreComing() + { + return iMoreComing; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetStream +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::GetStream( + const CCRStreamingSession::TCRSinkId& aId, + MCRPacketSource::TCRPacketStreamId& aStreamId ) + { + return GetStream( aId, 0, aStreamId ); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetStream +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::GetStream( + const CCRStreamingSession::TCRSinkId& aId, + const TInt aOffset, + MCRPacketSource::TCRPacketStreamId& aStreamId ) + { + const TInt bookKeeping( GetBookKeeping( aId ) ); + if ( bookKeeping > KErrNotFound ) + { + const TInt index( GetBufferIndex( bookKeeping ) - aOffset ); + if ( index > KErrNotFound && index < iBuffer.Count() ) + { + aStreamId = MCRPacketSource::TCRPacketStreamId( + iBuffer[index]->Des()[KStreamTypeBytePoint] ); + } + } + + return bookKeeping; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetPacket +// Method for remove +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::GetPacket( + const CCRStreamingSession::TCRSinkId& aId, + TPtr8& aReturnedData ) + { + const TInt bookKeeping( GetBookKeeping( aId ) ); + GetPacket( bookKeeping, aReturnedData ); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetPacket +// Method for remove +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::GetPacket( const TInt aBookKeeping, TPtr8& aReturnedData ) + { + PeekPacket( aBookKeeping, aReturnedData, 0 ); + + if ( aReturnedData.Ptr() || aReturnedData.Length() > 0 ) + { + // One packet used + iBookKeeping[aBookKeeping].iIndex--; + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::PeekPacket +// Method for peeking +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::PeekPacket( + const CCRStreamingSession::TCRSinkId& aId, + TPtr8& aReturnedData, + const TInt aOffset ) + { + const TInt bookKeeping( GetBookKeeping( aId ) ); + PeekPacket( bookKeeping, aReturnedData, aOffset ); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::PeekPacket +// Method for peeking +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::PeekPacket( + const TInt aBookKeeping, + TPtr8& aReturnedData, + const TInt aOffset ) + { + aReturnedData.Set( NULL, 0, 0 ); + + if ( aBookKeeping > KErrNotFound && aBookKeeping < iBookKeeping.Count() ) + { + const TInt index( GetBufferIndex( aBookKeeping ) - aOffset ); + if ( index > KErrNotFound && index < iBuffer.Count() ) + { + // Data + aReturnedData.Set( + iBuffer[index]->Des().MidTPtr( KStreamTypeBytesLength ) ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::PacketsCount +// Method for asking count of packet available. +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::PacketsCount( const CCRStreamingSession::TCRSinkId& aId ) + { + const TInt bookKeeping( GetBookKeeping( aId ) ); + if ( bookKeeping > KErrNotFound ) + { + return iBookKeeping[bookKeeping].iIndex; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::PacketsMinCount +// Method for asking minimum count of packet available in any sink. +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::PacketsMinCount() + { + TInt ret( KMaxTInt ); + for ( TInt i( iBookKeeping.Count() - 1 ); i >= 0 ; i-- ) + { + if ( iBookKeeping[i].iIndex < ret ) + { + ret = iBookKeeping[i].iIndex; + } + } + + return ret; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::HandleBufferSize +// Removes packets which are used in all book keepings. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::HandleBufferSize() + { + // Find maximum index + TInt max( KErrNotFound ); + for ( TInt i( 0 ); i < iBookKeeping.Count(); i++ ) + { + max = Max( max, iBookKeeping[i].iIndex ); + } + + // Delete used packets + const TInt oldCount( iBuffer.Count() ); + for ( TInt i( oldCount - 1 ); ( i > max ) && ( i > KErrNotFound ); i-- ) + { + delete iBuffer[i]; + iBuffer.Remove( i ); + } + + // Compress if packets deleted + if ( iBuffer.Count() < oldCount ) + { + iBuffer.Compress(); + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::AdjustBuffer +// Drops packets to 25% of buffers max size. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::AdjustBuffer() + { + const TInt limit( iMaxPackets / 4 ); + for ( TInt i( iBookKeeping.Count() - 1 ); i >= 0 ; i-- ) + { + if ( iBookKeeping[i].iIndex > limit ) + { + LOG3( "CCRPacketBuffer::AdjustBuffer(), book: %d, index: %d, limit: %d", + i, iBookKeeping[i].iIndex, limit ); + iBookKeeping[i].iIndex = limit; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::ResetBuffer +// +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::ResetBuffer() + { + // Reset book keeping + for ( TInt i( iBookKeeping.Count() - 1 ); i >= 0 ; i-- ) + { + LOG2( "CCRPacketBuffer::ResetBuffer(), book: %d, index: %d", + i, iBookKeeping[i].iIndex ); + iBookKeeping[i].iIndex = KErrNotFound; + } + + // Notify sinks + for ( TInt i( iSinkArray.Count() - 1 ); i >= 0; i-- ) + { + iSinkArray[i]->BufferResetDone(); + } + + // Reset items + iBuffer.ResetAndDestroy(); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::RemoveSink +// +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::RemoveSink( CCRPacketSinkBase* aSink ) + { + // Sink + for ( TInt i( iSinkArray.Count() - 1 ); i >= 0; i-- ) + { + if ( iSinkArray[i] == aSink ) + { + iSinkArray.Remove( i ); + LOG1( "CCRPacketBuffer::RemoveSink(), removed Sink: %d", i ); + } + } + + // Book keeping + for ( TInt i( iBookKeeping.Count() - 1 ); i >= 0; i-- ) + { + if ( iBookKeeping[i].iId == aSink->Id() ) + { + iBookKeeping.Remove( i ); + LOG1( "CCRPacketBuffer::RemoveSink(), removed Book keeping: %d", i ); + } + } + + return iSinkArray.Count(); + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::VerifyRoom() +// Verify maximum packets in buffer. Will drop packets count to 1/4 if maximum +// size reached. +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::VerifyRoom() + { + TInt count( iBuffer.Count() ); + if ( count >= iMaxPackets ) + { + LOG1( "CCRPacketBuffer::VerifyRoom(), Buffer full ! count: %d", count ); + AdjustBuffer(); + + // Make sure memory not run out because of asyncronous packets deleting + if ( count >= ( iMaxPackets * 2 ) ) + { + ResetBuffer(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetBookKeeping +// Updates book keeping index basing on sink id. +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::GetBookKeeping( const CCRStreamingSession::TCRSinkId& aId ) + { + for ( TInt i( 0 ); i < iBookKeeping.Count(); i++ ) + { + if ( iBookKeeping[i].iId == aId ) + { + return i; + } + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::GetBufferIndex +// Getter for buffer index from book keeping. +// ----------------------------------------------------------------------------- +// +TInt CCRPacketBuffer::GetBufferIndex( const TInt aBookKeeping ) + { + if ( aBookKeeping > KErrNotFound && aBookKeeping < iBookKeeping.Count() ) + { + return iBookKeeping[aBookKeeping].iIndex; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CCRPacketBuffer::PacketToBookKeeping +// +// ----------------------------------------------------------------------------- +// +void CCRPacketBuffer::PacketToBookKeeping() + { + // New packet to book keeping + for ( TInt i( 0 ); i < iBookKeeping.Count(); i++ ) + { + iBookKeeping[i].iIndex++; + } + + // New packet available + for ( TInt i( 0 ); i < iSinkArray.Count(); i++ ) + { + iSinkArray[i]->NewPacketAvailable(); + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRPacketSinkBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRPacketSinkBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for all packet sinks* +*/ + + + + +// INCLUDES +#include "CCRPacketSinkBase.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::CCRPacketSinkBase +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRPacketSinkBase::CCRPacketSinkBase( + CCRStreamingSession& aSession, + CCRStreamingSession::TCRSinkId aSinkId ) + : iOwningSession( aSession ), + iSinkId( aSinkId ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::CCRPacketSinkBase +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRPacketSinkBase::~CCRPacketSinkBase() + { + iBuffer = NULL; // Does not delete and it is right thing. + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::SetBuffer +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::SetBuffer( CCRPacketBuffer* aBuffer ) + { + iBuffer = aBuffer; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::BufferResetDone +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::BufferResetDone() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::StatusChanged +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::StatusChanged( + MCRPacketSource::TCRPacketSourceState /*aNewState*/ ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::Id +// +// ----------------------------------------------------------------------------- +// +CCRStreamingSession::TCRSinkId CCRPacketSinkBase::Id( void ) const + { + return iSinkId; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::Pause +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSinkBase::Pause() + { + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::Restore +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSinkBase::Restore() + { + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::Stop +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::Stop() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::SetSeqAndTS +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::SetSeqAndTS( + TUint& /*aAudioSeq*/, + TUint& /*aAudioTS*/, + TUint& /*aVideoSeq*/, + TUint& /*aVideoTS*/ ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSinkBase::SetRange +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSinkBase::SetRange( TReal /*aLower*/, TReal /*aUpper*/ ) + { + // None + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRPacketSourceBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRPacketSourceBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for all packet sources* +*/ + + + + +// INCLUDES +#include "CCRPacketSourceBase.h" +#include "CCRPacketBuffer.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::CCRPacketSourceBase +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRPacketSourceBase::CCRPacketSourceBase( + CCRStreamingSession& aSession, + CCRStreamingSession::TCRSourceId aSourceId ) + : iOwningSession( aSession ), + iSourceId( aSourceId ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::CCRPacketSourceBase +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRPacketSourceBase::~CCRPacketSourceBase() + { + iBuffer = NULL; // Does not delete and it is right thing. + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::SetBuffer +// +// ----------------------------------------------------------------------------- +// +void CCRPacketSourceBase::SetBuffer( CCRPacketBuffer* aBuffer ) + { + iBuffer = aBuffer; + // By default variables are set for continous streaming + iBuffer->ContinousStream( ETrue ); + iBuffer->MoreComing( ETrue ); + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::SeqAndTS +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::SeqAndTS( + TUint& /*aAudioSeq*/, + TUint& /*aAudioTS*/, + TUint& /*aVideoSeq*/, + TUint& /*aVideoTS*/ ) + { + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::Id +// +// ----------------------------------------------------------------------------- +// +CCRStreamingSession::TCRSourceId CCRPacketSourceBase::Id( void ) const + { + return iSourceId; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::RegisterConnectionObs +// ----------------------------------------------------------------------------- +// +void CCRPacketSourceBase::RegisterConnectionObs( + MCRConnectionObserver* /*aObserver*/ ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::Play +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::Play( + const TReal& /*aStartPos*/, + const TReal& /*aEndPos*/ ) + { + LOG( "CCRPacketSourceBase::Play(), KErrCompletion !" ); + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::Pause +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::Pause() + { + LOG( "CCRPacketSourceBase::Pause(), KErrCompletion !" ); + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::Stop +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::Stop() + { + LOG( "CCRPacketSourceBase::Stop(), KErrCompletion" ); + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::SetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::SetPosition( const TInt64 /*aPosition*/ ) + { + LOG( "CCRPacketSourceBase::SetPosition(), KErrCompletion !" ); + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::GetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCRPacketSourceBase::GetPosition( TInt64& aPosition, TInt64& aDuration ) + { + LOG( "CCRPacketSourceBase::GetPosition(), KErrCompletion !" ); + + aPosition = 0; + aDuration = 0; + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::GetRange +// ----------------------------------------------------------------------------- +// +void CCRPacketSourceBase::GetRange( TReal& aLower, TReal& aUpper ) + { + aLower = KRealZero; + aUpper = KRealMinusOne; + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::PostActionL +// ----------------------------------------------------------------------------- +// +void CCRPacketSourceBase::PostActionL() + { + LOG( "CCRPacketSourceBase::PostActionL(), Leaves KErrCompletion !" ); + + User::Leave( KErrCompletion ); + } + +// ----------------------------------------------------------------------------- +// CCRPacketSourceBase::Restore +// ----------------------------------------------------------------------------- +// +void CCRPacketSourceBase::Restore() + { + // None + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRPunchPacketSender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRPunchPacketSender.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,212 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Firewall/nat box puncher* +*/ + + + + +// INCLUDE FILES +#include "CCRPunchPacketSender.h" +#include "CCRRtspPacketSource.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRPunchPacketSender* CCRPunchPacketSender::NewL( + RConnection& aConnection, + RSocketServ& aSockServer, + TInetAddr& aFromAddr, + TInetAddr& aRemoteAddr , + TUint32 aMySSRC, + CCRRtspPacketSource& aOwner ) + { + CCRPunchPacketSender* self = new( ELeave ) CCRPunchPacketSender( + aConnection, aSockServer, aFromAddr, aRemoteAddr, aMySSRC, aOwner ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::CCRPunchPacketSender +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRPunchPacketSender::CCRPunchPacketSender( + RConnection& aConnection, + RSocketServ& aSockServer, + TInetAddr& aFromAddr, + TInetAddr& aRemoteAddr , + TUint32 aMySSRC, + CCRRtspPacketSource& aOwner ) + : iConnection( aConnection ), + iSockServer( aSockServer ), + iFromAddr( aFromAddr ), + iRemoteAddr( aRemoteAddr ), + iMySSRC( aMySSRC ), + iOwner( aOwner ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRPunchPacketSender::ConstructL() + { + iSock1 = CCRSock::NewL( *this, 1, iConnection, iSockServer, EFalse, EFalse ); + User::LeaveIfError( iSock1->ConnectSock( iRemoteAddr, iFromAddr.Port() ) ); + iSock2 = CCRSock::NewL( *this, 2, iConnection, iSockServer, EFalse, EFalse ); + TInetAddr remoteAddr2 = iRemoteAddr; + remoteAddr2.SetPort ( iRemoteAddr.Port() + 1 ); + User::LeaveIfError( iSock2->ConnectSock( remoteAddr2, iFromAddr.Port() + 1 ) ); + iCleanUp = new ( ELeave ) CAsyncCallBack( CActive::EPriorityStandard ) ; + } + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::~CCRPunchPacketSender +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRPunchPacketSender::~CCRPunchPacketSender() + { + LOG( "CCRPunchPacketSender::~CCRPunchPacketSender" ); + + delete iSock1; + delete iSock2; + delete iCleanUp; + } + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::DataReceived +// +// This is called when data is received from socket. +// ----------------------------------------------------------------------------- +// +void CCRPunchPacketSender::DataReceived( TInt /*aSockId*/, const TDesC8& /*aData*/ ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRPunchPacketSender::SockStatusChange +// +// This is called when socket status changes. +// ----------------------------------------------------------------------------- +// +void CCRPunchPacketSender::SockStatusChange( + TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ) + { + if ( aStatus == CCRSock::EFailed ) + { + LOG3( "CCRPunchPacketSender::SockStatusChange(), aSockId: id: %d, aStatus: %d, aError: %d", + aSockId, ( TInt )aStatus, aError ); + iOwner.SockStatusChange( aSockId, aStatus, aError ); + } + else if ( aStatus == CCRSock::EIdle ) + { + if ( iSentViaSock2 && iSentViaSock1 ) + { + + if ( !iCleanUp->IsActive() ) + { + TCallBack cb( CleanupCallBack, this ); + iCleanUp->Set( cb ); + iCleanUp->CallBack(); + } + } + else + { + // here send + TDesC8* packet = NULL; + if ( iMySSRC ) + { + // construct valid packet only if we have SSRC + TBuf8<8> receiverReport; + receiverReport.Zero(); + receiverReport.AppendFill( 0x0, 7 ); + TUint8 *rrPtr = const_cast( receiverReport.PtrZ() ); + rrPtr[0] = 0x80; // version and count + rrPtr[1] = 0xC9; // packet type 201 = rr + rrPtr[2] = 0x00; // packet len high bits = 0 + rrPtr[3] = 0x01; // packet len low bits = 1 e.g. len = 1 + BigEndian::Put32( ( TUint8* )( &rrPtr[4] ), iMySSRC ); + packet = &receiverReport; + } + else + { + // Atleast construct a kind-of valid packet. + TBuf8<12> appPacket; + appPacket.Zero(); + appPacket.AppendFill( 0x0, 11 ); + TUint8 *rrPtr = const_cast( appPacket.PtrZ() ); + rrPtr[0] = 0x80; // version and subtype + rrPtr[1] = 0xCC; // packet type 204 = APP + rrPtr[2] = 0x00; // packet len high bits = 0 + rrPtr[3] = 0x01; // packet len low bits = 1 e.g. len = 1 + // this is not a valid SSRC + BigEndian::Put32( ( TUint8* )( &rrPtr[4] ), iMySSRC ); + rrPtr[8] = 0x44; // ASCII: D + rrPtr[9] = 0x56; // ASCII: V + rrPtr[10] = 0x52; // ASCII: R + rrPtr[11] = 0x45; // ASCII: E + packet = &appPacket; + } + if ( aSockId == 1 && iSock1 && !iSentViaSock1 ) + { + iSock1->SendData( *packet ); + iSentViaSock1 = ETrue; + } + else if ( aSockId == 2 && iSock2 && !iSentViaSock2 ) + { + iSock2->SendData( *packet ); + iSentViaSock2 = ETrue; + } + else + { + // None + } + } + } + } + +//----------------------------------------------------------------------------- +// CCRPunchPacketSender::CleanupCallBack() +//----------------------------------------------------------------------------- +TInt CCRPunchPacketSender::CleanupCallBack( TAny* aSelf ) + { + LOG( "CCRPunchPacketSender::CleanupCallBack()" ); + + CCRPunchPacketSender* self = static_cast( aSelf ); + delete self->iSock1; self->iSock1 = NULL; + delete self->iSock2; self->iSock2 = NULL; + self->iOwner.PunchPacketsSent( self ); + return KErrNone; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRTSPCommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRTSPCommand.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,761 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTSP command parser and producer* +*/ + + + + +// INCLUDE FILES +#include "CCRRtspCommand.h" +#include "CCRSock.h" +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TReal KRealZero( 0.0 ); +const TReal KRealMinusOne( -1.0 ); +// Length of a digest hash before converting to hex. +const TInt KCRRawHashLength( 16 ); +// Length of a digest hash when represented in hex +const TInt KCRHashLength( 32 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtspCommand* CCRRtspCommand::NewL() + { + CCRRtspCommand* self = new( ELeave ) CCRRtspCommand(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::CCRRtspCommand +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtspCommand::CCRRtspCommand() + : iCommand( ERTSPCommandNOCOMMAND ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::ConstructL() + { + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::~CCRRtspCommand +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtspCommand::~CCRRtspCommand() + { + LOG( "CCRRtspCommand::~CCRRtspCommand" ); + + // iRtspText is deleted in base class destructor + delete iAuthHeader; + delete iMD5Calculator; + delete iUserAgent; + delete iWapProfile; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::TryParseL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::TryParseL( const TDesC8 &aString ) + { + // try to find out if end of the command has been received + // "RTSP/1.0 XXX\r\n\r\n" at least.. + const TInt KDVRMinCommandLen( 14 ); + TInt replyEndOffSet( ( aString.Length() < KDVRMinCommandLen )? + KDVRMinCommandLen: aString.Find( KCR2NewLines() ) ); + if ( replyEndOffSet == KErrNotFound ) + { + // need to have more, do nothing yet + LOG( "CCRRtspCommand::TryParseL() out because response not complete" ); + User::Leave( KErrUnderflow ); + } + + // copy the stuff into local variable: + delete iRtspText; iRtspText = NULL; + iRtspText = aString.AllocL(); + iCommand = ERTSPCommandNOCOMMAND; + + // try each command in order: + if ( iRtspText->Find( KCROPTIONS() ) == 0 ) + { + // it was OPTIONS command + LOG( "CCRRtspCommand::TryParseL() -> OPTIONS" ); + iCommand = ERTSPCommandOPTIONS; + } + else if ( iRtspText->Find( KCRDESCRIBE() ) == 0 ) + { + LOG( "CCRRtspCommand::TryParseL() -> DESCRIBE" ); + iCommand = ERTSPCommandDESCRIBE; + } + else if ( iRtspText->Find( KCRTEARDOWN() ) == 0 ) + { + LOG( "CCRRtspCommand::TryParseL() -> TEARDOWN" ); + iCommand = ERTSPCommandTEARDOWN; + } + else if ( iRtspText->Find( KCRPAUSE() ) == 0 ) + { + LOG( "CCRRtspCommand::TryParseL() -> PAUSE" ); + iCommand = ERTSPCommandPAUSE; + } + else if ( iRtspText->Find( KCRSETUP() ) == 0 ) + { + LOG( "CCRRtspCommand::TryParseL() -> SETUP" ); + iCommand = ERTSPCommandSETUP; + } + else if ( iRtspText->Find( KCRPLAY() ) == 0 ) + { + LOG( "CCRRtspCommand::TryParseL() -> PLAY" ); + iCommand = ERTSPCommandPLAY; + } + else + { + User::Leave( KErrNotSupported ); + } + + // then find CSeq + FindCSeqL(); + // then find session id + FindSessionIdL(); + // then find possible content. for commands it is usually not there + FindContentL(); + // find URL + FindURLL(); + // find possible transport method + // IMPORTANT: should be done before parsing client port + FindTransport(); + // find possible client port + FindClientPorts(); + // find possible range-header + ParseRange(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::FindURLL +// in rtsp the URL is between first and second whitespace. +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::FindURLL( void ) + { +#ifdef _DEBUG + _LIT( KPanicStr, "RTSPCommon" ); + __ASSERT_DEBUG( iRtspText, + User::Panic( KPanicStr, KErrBadHandle ) ); +#endif + + iURL.Set( NULL, 0 ); + TInt spaceOffset( iRtspText->Locate( ' ' ) ); + if ( spaceOffset < 0 ) + { + User::Leave( KErrNotSupported ); + } + + TPtrC8 beginningFromUrl( iRtspText->Right( iRtspText->Length() - + ( spaceOffset + 1 ) ) ) ; + spaceOffset = beginningFromUrl.Locate( ' ' ); + if ( spaceOffset < 0 ) + { + User::Leave( KErrNotSupported ); + } + + iURL.Set( beginningFromUrl.Left( spaceOffset ) ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::URL +// +// method that returns URL +// ----------------------------------------------------------------------------- +// +TInt CCRRtspCommand::URL( TPtrC8& aURL ) + { + if ( iURL.Ptr() != NULL ) + { + aURL.Set ( iURL ); + return KErrNone; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetURL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetURL ( const TDesC8& aURL ) + { + iURL.Set ( aURL ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetAuthentication +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetAuthentication( TBool aAuth ) + { + iAuthenticationNeeded = aAuth; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetUserAgentL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetUserAgentL( const TDesC8& aUserAgent ) + { + delete iUserAgent; iUserAgent = NULL; + iUserAgent = aUserAgent.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetBandwidth +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetBandwidth( TInt aBandwidth ) + { + iBandwidth = aBandwidth; + iBandwidthAvailable = ETrue; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetWapProfileL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetWapProfileL( const TDesC8& aWapProfile ) + { + delete iWapProfile; iWapProfile = NULL; + iWapProfile = aWapProfile.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::SetCommand +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::SetCommand( TCommand aCommand ) + { + iCommand = aCommand; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::Command +// +// ----------------------------------------------------------------------------- +// +CCRRtspCommand::TCommand CCRRtspCommand::Command( void ) const + { + return iCommand; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::ProduceL +// +// ----------------------------------------------------------------------------- +// +TPtrC8& CCRRtspCommand::ProduceL( void ) + { + // First common part for all commands, except actual command + delete iRtspText; iRtspText = NULL; + iRtspText = HBufC8::NewL( KMaxName ); + iRtspText->Des().Zero(); + + switch ( iCommand ) + { + case ERTSPCommandOPTIONS: + AppendL( iRtspText, KCROPTIONS ); + break; + + case ERTSPCommandDESCRIBE: + AppendL( iRtspText, KCRDESCRIBE ); + break; + + case ERTSPCommandTEARDOWN: + AppendL( iRtspText, KCRTEARDOWN ); + break; + + case ERTSPCommandPAUSE: + AppendL( iRtspText, KCRPAUSE ); + break; + + case ERTSPCommandSETUP: + AppendL( iRtspText, KCRSETUP ); + break; + + case ERTSPCommandPLAY : + AppendL( iRtspText, KCRPLAY ); + break; + + default: + User::Leave( KErrNotSupported ); + break; + } + + AppendL( iRtspText, iURL ); + AppendL( iRtspText, KCRSpace ); + AppendL( iRtspText, KCRRTSP10 ); + AppendL( iRtspText, KCRNewLine ); + AppendL( iRtspText, KCRCSeq ); + AppendNumL( iRtspText, iCSeq ); + AppendL( iRtspText, KCRNewLine ); + + if ( iUserAgent ) + { + TPtrC8 useragent( iUserAgent->Des() ); + AppendFormatL( iRtspText, KCRRTSPUserAgentHeader, &useragent ); + } + + // then variable tail depending on command + switch ( iCommand ) + { + case ERTSPCommandOPTIONS: + if ( iSessionId.Ptr() != NULL ) + { + AppendL( iRtspText, KCRSessionStr() ); + AppendL( iRtspText, iSessionId ); // now only session number + AppendL( iRtspText, KCRNewLine ); + } + break; + + case ERTSPCommandDESCRIBE: + { + AppendL( iRtspText, KCRAcceptSDP ); + if ( iWapProfile ) + { + TPtrC8 profile = iWapProfile->Des(); + AppendFormatL( iRtspText, KCRRTSPXWapProfile, &profile ); + } + if ( iBandwidthAvailable ) + { + AppendFormatL( iRtspText, KCRRTSPBandwidth, iBandwidth ); + } + } + break; + + case ERTSPCommandTEARDOWN: + if ( iSessionId.Ptr() != NULL ) + { + AppendL( iRtspText, KCRSessionStr() ); + AppendL( iRtspText, iSessionId ); // now only session number + AppendL( iRtspText, KCRNewLine ); + } + break; + + case ERTSPCommandPAUSE: + if ( iSessionId.Ptr() != NULL ) + { + AppendL( iRtspText, KCRSessionStr() ); + AppendL( iRtspText, iSessionId ); // now only session number + AppendL( iRtspText, KCRNewLine ); + } + break; + + case ERTSPCommandSETUP: + { + // build transport header according to chosen method + switch ( iTransport ) + { + case ERTPOverUDP: + AppendFormatL( iRtspText, KCRTransportHeaderUDP, + iClientPort, iClientPort + 1 ); + break; + case ERTPOverTCP: + AppendFormatL( iRtspText, KCRTransportHeaderTCP, + iClientPort, iClientPort + 1 ); + break; + + case ERTPOverMulticast: + AppendL( iRtspText, KCRTransportHeaderMulticast ); + break; + } + + // Session: 5273458854096827704 + if ( iSessionId.Ptr() != NULL ) + { + AppendL( iRtspText, KCRSessionStr ); + AppendL( iRtspText, iSessionId ); // now only session number + AppendL( iRtspText, KCRNewLine ); + } + if ( iWapProfile ) + { + TPtrC8 profile( iWapProfile->Des() ); + AppendFormatL( iRtspText, KCRRTSPXWapProfile, &profile ); + } + } + break; + + case ERTSPCommandPLAY: + { + if ( !( iLowerRange == KRealZero && iUpperRange == KRealMinusOne ) ) + { + // Range was something else than 0,-1 + TBuf8 buf( KCRRangeHeader ); + TRealFormat format( 10, 3 ); + format.iTriLen = 0; + format.iPoint = '.'; + buf.AppendNum( iLowerRange, format ); + buf.Append( '-' ); + if ( iUpperRange > KRealZero ) + { + buf.AppendNum( iUpperRange, format ); + } + + buf.Append( KCRNewLine ); + AppendL( iRtspText, buf ); + } + if ( iSessionId.Ptr() != NULL ) + { + AppendL( iRtspText, KCRSessionStr() ); + AppendL( iRtspText, iSessionId ); // now only session number + AppendL( iRtspText, KCRNewLine ); + } + } + break; + + default: + User::Leave( KErrNotSupported ); + break; + } + + if ( iAuthenticationNeeded ) + { + TBool useDigest( EFalse ); + + if ( iAuthType && ( iAuthType->FindC( KCRAuthDigest ) != KErrNotFound ) ) + { + useDigest = ETrue; + } + + switch ( iCommand ) + { + case ERTSPCommandOPTIONS : + useDigest ? CalculateDigestResponseL( KCROPTIONSNoSpace ) : + CalculateBasicResponseL( KCROPTIONSNoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + case ERTSPCommandDESCRIBE : + useDigest ? CalculateDigestResponseL( KCRDESCRIBENoSpace ) : + CalculateBasicResponseL( KCRDESCRIBENoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + case ERTSPCommandTEARDOWN : + useDigest ? CalculateDigestResponseL( KCRTEARDOWNNoSpace ) : + CalculateBasicResponseL( KCRTEARDOWNNoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + case ERTSPCommandPAUSE : + useDigest ? CalculateDigestResponseL( KCRPAUSENoSpace ) : + CalculateBasicResponseL( KCRPAUSENoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + case ERTSPCommandSETUP : + useDigest ? CalculateDigestResponseL( KCRSETUPNoSpace ) : + CalculateBasicResponseL( KCRSETUPNoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + case ERTSPCommandPLAY : + useDigest ? CalculateDigestResponseL( KCRPLAYNoSpace ) : + CalculateBasicResponseL( KCRPLAYNoSpace ); + + if ( iAuthHeader ) + { + AppendL( iRtspText, iAuthHeader->Des() ); + } + break; + + default: + User::Leave( KErrNotSupported ); + break; + } + } + + AppendL( iRtspText, KCRNewLine ); + iProductDescriptor.Set( *iRtspText ); + return iProductDescriptor; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::AppendL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::AppendL( HBufC8*& aBuffer, const TDesC8& aStr ) + { + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + aStr.Length() ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + aStr.Length() + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.Append( aStr ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::AppendNumL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::AppendNumL( HBufC8*& aBuffer, const TInt aNum ) + { + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + KMaxInfoName ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + KMaxInfoName + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.AppendNum( aNum ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::AppendFormatL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::AppendFormatL( + HBufC8*& aBuffer, + TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + HBufC8* buf = HBufC8::NewLC( KMaxDataSize ); + buf->Des().FormatList( aFmt, list ); + VA_END( list ); + + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + buf->Length() ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + buf->Length() + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.Append( *buf ); + CleanupStack::PopAndDestroy( buf ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::Hash +// Calculates hash value ( from S60 HttpFilters ) +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::HashL( const TDesC8& aMessage, TDes8& aHash ) + { + LOG( "CCRRtspCommand::HashL() in" ); + // check if md5 calculator is already constructed + if ( !iMD5Calculator ) + { + iMD5Calculator = CMD5::NewL(); + } + // Calculate the 128 bit (16 byte) hash + iMD5Calculator->Reset(); + TPtrC8 hash = iMD5Calculator->Hash( aMessage ); + + // Now print it as a 32 byte hex number + aHash.Zero(); + _LIT8( formatStr, "%02x" ); + TBuf8<2> scratch; + for ( TInt i( 0 ); i < KCRRawHashLength; i++ ) + { + scratch.Zero(); + scratch.Format( formatStr, hash[i] ); + aHash.Append( scratch ); + } + + LOG( "CCRRtspCommand::HashL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::CalculateBasicResponseL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::CalculateBasicResponseL( const TDesC8& /*aMethod*/ ) + { + LOG( "CCRRtspCommand::CalculateBasicResponseL() in" ); + + if ( !( iUserName && iPassword ) ) + { + LOG( "CCRRtspCommand::CalculateBasicResponseL() out, username or password not set" ); + delete iAuthHeader; + iAuthHeader = NULL; + return; // no can do + } + + HBufC8* plainData = HBufC8::NewL( iUserName->Length() + 1 + // ':' + iPassword->Length() ); + + CleanupStack::PushL( plainData ); + + plainData->Des().Append( *iUserName ); + plainData->Des().Append( ':' ); + plainData->Des().Append( *iPassword ); + + // Max size = ((Bytes + 3 - (Bytes MOD 3)) /3) x 4 + TInt base64MaxSize = ( ( plainData->Length() + 3 - + ( plainData->Length() % 3 ) ) / 3 ) * 4; + + HBufC8* encodedData = HBufC8::NewL( base64MaxSize ); + TPtr8 dataPrt( encodedData->Des() ); + CleanupStack::PushL( encodedData ); + + TImCodecB64 b64enc; + b64enc.Initialise(); + b64enc.Encode( *plainData, dataPrt ); + + delete iAuthHeader; + iAuthHeader = NULL; + iAuthHeader = HBufC8::NewL( KCRAuthorizationBasicHeader().Length() + encodedData->Length() ); + iAuthHeader->Des().Format( KCRAuthorizationBasicHeader, encodedData ); + + CleanupStack::PopAndDestroy( encodedData ); + CleanupStack::PopAndDestroy( plainData ); + + LOG( "CCRRtspCommand::CalculateBasicResponseL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommand::CalculateDigestResponseL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommand::CalculateDigestResponseL( const TDesC8& aMethod ) + { + LOG( "CCRRtspCommand::CalculateDigestResponseL() in" ); + + if ( !( iUserName && iPassword && iNonce && iOpaque && iRealm && iUri ) ) + { + LOG( "CCRRtspCommand::CalculateDigestResponseL() out, username or password not set" ); + delete iAuthHeader; iAuthHeader = NULL; + return; // no can do + } + + TBuf8 hash1; + TBuf8 hash2; + TBuf8 finalHash; + + // calculate the hash1 using "username:realm:password" + HBufC8* hashPtr = HBufC8::NewL ( iUserName->Length() + 1 + // ':' + iRealm->Length() + 1 + // ':' + iPassword->Length() ); + hashPtr->Des().Append( *iUserName ); + hashPtr->Des().Append( ':' ); + hashPtr->Des().Append( *iRealm ); + hashPtr->Des().Append( ':' ); + hashPtr->Des().Append( *iPassword ); + + HashL( *hashPtr, hash1 ); + delete hashPtr; hashPtr = NULL; + + // calculate hash2 using "Method:uri" + HBufC8* hashPtr2 = HBufC8::NewL(aMethod.Length() + 1 + iUri->Length() ); + hashPtr2->Des().Append( aMethod ); + hashPtr2->Des().Append( ':' ); + hashPtr2->Des().Append( *iUri ); + + HashL( *hashPtr2, hash2 ); + delete hashPtr2; hashPtr2 = NULL; + + // calculate finalHash to be sent to remote server using + // hash1 + ":" + nonce + ":" + hash2 + HBufC8* hashPtr3 = HBufC8::NewL( hash1.Length() + 1 + // ':' + iNonce->Length() + 1 + // ':' + hash2.Length() ); + hashPtr3->Des().Append( hash1 ); + hashPtr3->Des().Append( ':' ); + hashPtr3->Des().Append( *iNonce ); + hashPtr3->Des().Append( ':' ); + hashPtr3->Des().Append( hash2 ); + + HashL( *hashPtr3, finalHash ); + delete hashPtr3; hashPtr3 = NULL; + + // generate the authentication header + if ( iOpaque->Length() ) + { + delete iAuthHeader; iAuthHeader = NULL; + iAuthHeader = HBufC8::NewL( KCRAuthorizationHeader().Length() + + iUserName->Length() + iRealm->Length() + iNonce->Length() + + iUri->Length() + finalHash.Length() + iOpaque->Length() ); + + iAuthHeader->Des().Format( KCRAuthorizationHeader, iUserName, + iRealm, iNonce, iUri, &finalHash, iOpaque ); + } + else + { + delete iAuthHeader; iAuthHeader = NULL; + iAuthHeader = HBufC8::NewL( KCRAuthorizationHeaderNoOpaque().Length() + + iUserName->Length() + iRealm->Length() + iNonce->Length() + + iUri->Length() + finalHash.Length() ); + + iAuthHeader->Des().Format( KCRAuthorizationHeaderNoOpaque, iUserName, + iRealm, iNonce, iUri, &finalHash ); + } + + LOG( "CCRRtspCommand::CalculateDigestResponseL() out" ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRTSPCommon.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRTSPCommon.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,706 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTSP command/response common part* +*/ + + + + +// INCLUDE FILES +#include "CRRtspCommon.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TReal KRealZero( 0.0 ); +const TReal KRealMinusOne( -1.0 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::CCRRtspCommon +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtspCommon::CCRRtspCommon () + : iContentLen( KErrNotFound ), + iContent( NULL, 0 ), + iCSeq( KErrNotFound ), + iSessionId( NULL, 0 ), + iClientPort( KErrNotFound ), + iLowerRange( KRealZero ), + iUpperRange( KRealMinusOne ), + iIsLiveStream( EFalse ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::~CCRRtspCommon +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtspCommon::~CCRRtspCommon() + { + LOG( "CCRRtspCommon::~CCRRtspCommon()" ); + + delete iRtspText; + delete iRealm; + delete iOpaque; + delete iNonce; + delete iUserName; + delete iUri; + delete iPassword; + delete iAuthType; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::CSeq +// +// ----------------------------------------------------------------------------- +// +TInt CCRRtspCommon::CSeq( void ) + { + return iCSeq; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetCSeq +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetCSeq( TInt aCSeq ) + { + iCSeq = aCSeq; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindCSeqL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindCSeqL( void ) + { + TInt offSet( iRtspText->FindC( KCRCSeq() ) ); + if ( offSet == KErrNotFound ) + { + LOG( "CCRRtspCommon::FindCSeqL FAILED, 'CSeq' not found [1]" ); + User::Leave ( KErrNotSupported ); + } + + offSet += KCRCSeq().Length(); + TInt eolOffSet = iRtspText->Right ( iRtspText->Length() - + offSet ).Find ( KCRNewLine() ); + if ( eolOffSet == KErrNotFound ) + { + LOG1( "CCRRtspCommon::FindCSeqL FAILED, 'CSeq' not found [2], offset=%d", offSet ); + User::Leave ( KErrNotSupported ); + } + TPtrC8 CSeqString ( iRtspText->Mid ( offSet, eolOffSet ) ); + TLex8 CSeqNumberLex( CSeqString ); + User::LeaveIfError ( CSeqNumberLex.Val( iCSeq ) ) ; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindSessionIdL +// +// method that finds session id from RTSP response +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindSessionIdL( void ) + { + iSessionId.Set( NULL, 0 ); + TInt sessionStringOffset( iRtspText->FindC( KCRNlAndSession() ) ); + if ( sessionStringOffset > 0 ) + { + TPtrC8 beginningFromSession( iRtspText->Right( iRtspText->Length() - + ( sessionStringOffset + 11 ) ) ); + TInt lfStringOffset( beginningFromSession.Find( KCRNewLine ) ); + if ( lfStringOffset != KErrNotFound ) + { + iSessionId.Set( beginningFromSession.Mid( 0, lfStringOffset ) ); + // with some servers there is;Timeout=xxx after the session id; + // lets strip that out: + TInt semicolonOffset( iSessionId.Locate( ';' ) ); + if ( semicolonOffset > 0 ) + { + iSessionId.Set( iSessionId.Mid( 0, semicolonOffset ) ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SessionId +// +// method that returns session id string +// ----------------------------------------------------------------------------- +// +TInt CCRRtspCommon::SessionId( TPtrC8& aId ) + { + if ( iSessionId.Ptr() != NULL ) + { + aId.Set( iSessionId ); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetSessionId +// +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetSessionId( TPtrC8& aId ) + { + iSessionId.Set( aId ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindContentL +// +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindContentL( void ) + { +#ifdef _DEBUG + _LIT(KPanicStr, "RTSPCommon"); + __ASSERT_DEBUG( iRtspText, + User::Panic( KPanicStr, KErrBadHandle ) ); +#endif + // find possible content: + // + TInt replyEndOffSet( iRtspText->Find( KCR2NewLines ) ); + if ( replyEndOffSet > KErrNotFound ) + { + replyEndOffSet += KCR2NewLines().Length(); + } + + // next thing to check if there is content-length-header, + // it seems like it may follow about any response.. + // + TInt contentLenOffset( KErrNotFound ); + iContentLen = KErrNotFound; // this will hold (usually SDP) length + if ( ( contentLenOffset = iRtspText->Des().FindC( + KCRRTSPContentLength() ) ) != KErrNotFound ) + { + TLex8 contentLenLex( iRtspText->Des().Mid( contentLenOffset + 16, 5 ) ); + User::LeaveIfError( contentLenLex.Val( iContentLen ) ); + } + + LOG1( "CCRRtspCommon::FindContentL(), iContentLen: %d", iContentLen ); + + // then set content in place + if ( replyEndOffSet > iRtspText->Length() ) + { + LOG( "CCRRtspCommon::FindContentL() out because too litle data !" ); + User::Leave( KErrUnderflow ); + } + if ( iContentLen > KErrNotFound ) + { + iContent.Set( iRtspText->Des().Mid( replyEndOffSet, iContentLen ) ); + } + else + { + iContent.Set( NULL, 0 ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::ContentLen +// +// ----------------------------------------------------------------------------- +// +TInt CCRRtspCommon::ContentLen( void ) + { + return iContentLen; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::Content +// +// ----------------------------------------------------------------------------- +// +TPtrC8& CCRRtspCommon::Content( void ) + { + return iContent ; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindClientPorts +// +// method that finds client port numeric value +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindClientPorts( void ) + { + iClientPort = KErrNotFound; + + // Bend concept of client port to mean also the interleaved channel for TCP streaming + const TDesC8& portdes( ( iTransport == ERTPOverTCP )? KCRInterleaved(): + ( iTransport == ERTPOverMulticast )? KCRPort(): + KCRClient_Port() ); + + TInt portNumberOffset( iRtspText->FindC( portdes ) ); + if ( portNumberOffset != KErrNotFound ) + { + TPtrC8 portNumberStr( iRtspText->Mid( portNumberOffset + portdes.Length() ) ); + TInt endoffset = portNumberStr.FindC( KCRDash() ); + if ( endoffset >= 0 ) + { + portNumberStr.Set( portNumberStr.Left( endoffset ) ); + } + else + { + endoffset = portNumberStr.FindC( KCRSemiColon() ); + if ( endoffset >= 0 ) + { + portNumberStr.Set( portNumberStr.Left( endoffset ) ); + } + } + TLex8 portNumberLex( portNumberStr ); + if ( portNumberLex.Val( iClientPort ) != KErrNone ) + { // something wrong? + LOG( "CCRRtspCommon::FindClientPorts val != KErrNone" ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::ClientPort +// +// method that returns client port numeric value +// ----------------------------------------------------------------------------- +// +TInt CCRRtspCommon::ClientPort( void ) + { + return iClientPort; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetClientPort +// +// method that sets client port numeric value +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetClientPort( TInt aPort ) + { + iClientPort = aPort; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindTransport +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindTransport() + { + // User TCP streaming if 'RTP/AVP/TCP' found + if ( iRtspText->FindC( KCRSDPRTPAVPTCP ) != KErrNotFound ) + { + iTransport = ERTPOverTCP; + } + // multicast UDP if 'multicast' present + else if ( iRtspText->FindC( KCRSDPMulticast ) != KErrNotFound || + iRtspText->FindC( KCRSDPRTPAVPUDP ) != KErrNotFound && + iRtspText->FindC( KCRDestination ) != KErrNotFound ) + { + iTransport = ERTPOverMulticast; + } + // otherwise, plain unicast UDP + else + { + iTransport = ERTPOverUDP; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::Transport +// ----------------------------------------------------------------------------- +// +TCRRTPTransport CCRRtspCommon::Transport() + { + return iTransport; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetTransport +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetTransport( TCRRTPTransport aTransport ) + { + iTransport = aTransport; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindDestination +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindDestination() + { + // resets destination to KAFUnspec + iDestination = TInetAddr(); + + // search for destination + TInt startoffset = iRtspText->FindC( KCRDestination() ); + if ( startoffset >= 0 ) + { + startoffset += KCRDestination().Length(); + TPtrC8 destdes = iRtspText->Mid( startoffset ); + TInt endoffset = destdes.FindC( KCRSemiColon() ); + if ( endoffset >= 0 ) + { + destdes.Set( destdes.Left(endoffset) ); + } + + TBuf<128> destbuf; + destbuf.Copy( destdes.Left(128) ); + TInt err = iDestination.Input( destbuf ); + if ( err != KErrNone ) + { + LOG1( "CCRRtspCommon::FindDestination(), INVALID destination address '%S'", &destbuf ); + } + else + { + LOG1( "CCRRtspCommon::FindDestination(), multicast address '%S'", &destbuf ); + iDestination.ConvertToV4Mapped(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::Destination +// ----------------------------------------------------------------------------- +// +const TInetAddr& CCRRtspCommon::Destination() + { + return iDestination; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetRange +// +// method that sets Range: header values +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetRange( TReal aLower , TReal aUpper ) + { + iLowerRange = aLower; + iUpperRange = aUpper; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::GetRange +// +// method that gets Range: header values +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::GetRange( TReal& aLower , TReal& aUpper ) + { + aLower = iLowerRange; + aUpper = iUpperRange; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::ParseRange +// +// method that tries to parse contents of possible Range: header +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::ParseRange( void ) + { + if ( iRtspText ) + { + TInt rangeHeaderOffset( iRtspText->Des().FindC( KCRRangeHeader ) ); + if ( rangeHeaderOffset > 0 ) + { + // check for live-stream specific range "Range: npt=now-" + if ( iRtspText->Des().FindC( KCRRangeHeaderLiveStream ) > KErrNotFound ) + { // yes, this is a live stream + iLowerRange = KRealZero; + iUpperRange = KRealMinusOne; + iIsLiveStream = ETrue; + LOG( "CCRRtspCommon::ParseRange(), Found livestream range" ); + } + else + { + TPtrC8 rangeHeader = iRtspText->Des().Mid( + rangeHeaderOffset + KCRRangeHeader().Length() ); + TInt minusSignOffset( rangeHeader.Locate( '-' ) ); + if ( minusSignOffset > 0 ) + { + TPtrC8 startPosStr = rangeHeader.Left( minusSignOffset ); + TLex8 startPosLex ( startPosStr ); + startPosLex.Val ( iLowerRange ) ; // if .Val fails, value will just remain zero + LOG1( "CCRRtspCommon::ParseRange(), start: %f", iLowerRange ); + } + + TInt lineFeedOffset( rangeHeader.Locate( '\n' ) ); + if ( lineFeedOffset > ( minusSignOffset + 2 ) ) + { + TPtrC8 endPosStr = rangeHeader.Mid( minusSignOffset + 1, + lineFeedOffset - ( minusSignOffset + 1 ) ); + TLex8 endPosLex ( endPosStr ); + endPosLex.Val ( iUpperRange ) ; // if .Val fails, value will just remain -1.0 + LOG1( "CCRRtspCommon::ParseRange(), end: %f", iUpperRange ); + } + else + { + iUpperRange = KRealMinusOne; + LOG( "CCRRtspCommon::ParseRange(), Setting end range to -1.0" ); + } + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::AuthenticationTypeL +// +// method that returns authentication type +// ----------------------------------------------------------------------------- +// + +TDesC8& CCRRtspCommon::AuthenticationTypeL( void ) + { + if ( !iAuthType ) + { + iAuthType = HBufC8::NewL( 0 ); + } + + return *iAuthType; + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::NonceL +// +// method that returns session nonce +// ----------------------------------------------------------------------------- +// +TDesC8& CCRRtspCommon::NonceL( void ) + { + if ( !iNonce ) + { + iNonce = HBufC8::NewL( 0 ); + } + + return *iNonce; + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::RealmL +// +// method that returns session realm +// ----------------------------------------------------------------------------- +// +TDesC8& CCRRtspCommon::RealmL( void ) + { + if ( !iRealm ) + { + iRealm = HBufC8::NewL( 0 ); + } + + return *iRealm; + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::OpaqueL +// +// method that returns session opaque value +// ----------------------------------------------------------------------------- +// +TDesC8& CCRRtspCommon::OpaqueL( void ) + { + if ( !iOpaque ) + { + iOpaque = HBufC8::NewL( 0 ); + } + + return *iOpaque; + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetNonce +// +// method that sets session nonce +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetNonceL( const TDesC& aNonce ) + { + delete iNonce; iNonce = NULL; + iNonce = HBufC8::NewL( aNonce.Length() ); + iNonce->Des().Copy( aNonce ); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetNonce +// +// method that sets session nonce +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetNonceL( const TDesC8& aNonce ) + { + delete iNonce; iNonce = NULL; + iNonce = aNonce.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetAuthenticationTypeL +// +// method that sets authentication type +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetAuthenticationTypeL( const TDesC8& aAuthType ) + { + delete iAuthType; + iAuthType = NULL; + iAuthType = aAuthType.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetRealmL +// +// method that sets session realm +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetRealmL( const TDesC& aRealm ) + { + delete iRealm; iRealm = NULL; + iRealm = HBufC8::NewL( aRealm.Length()); + iRealm->Des().Copy( aRealm ); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetRealmL +// +// method that sets session realm +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetRealmL( const TDesC8& aRealm ) + { + delete iRealm; iRealm = NULL; + iRealm = aRealm.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetOpaqueL +// +// method that sets session opaque +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetOpaqueL( const TDesC& aOpaque ) + { + delete iOpaque; iOpaque = NULL; + iOpaque = HBufC8::NewL( aOpaque.Length()); + iOpaque->Des().Copy( aOpaque ); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetOpaqueL +// +// method that sets session opaque +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetOpaqueL( const TDesC8& aOpaque ) + { + delete iOpaque; iOpaque = NULL; + iOpaque = aOpaque.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CCRRTSPResponse::SetUserNameL +// +// method that sets session user name +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetUserNameL( const TDesC& aUserName ) + { + delete iUserName; iUserName = NULL; + iUserName = HBufC8::NewL( aUserName.Length() ); + iUserName->Des().Copy( aUserName ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetPassWdL +// +// method that sets session password +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetPassWdL( const TDesC& aPassWd ) + { + delete iPassword; iPassword = NULL; + iPassword = HBufC8::NewL( aPassWd.Length() ); + iPassword->Des().Copy( aPassWd ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::SetRtspUriL +// +// method that sets session uri +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::SetRtspUriL( const TDesC& aUri ) + { + delete iUri; iUri = NULL; + iUri = HBufC8::NewL( aUri.Length() ); + iUri->Des().Copy( aUri ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::IsLiveStream +// +// getter method for livelihood of a stream +// ----------------------------------------------------------------------------- +// +TBool CCRRtspCommon::IsLiveStream( void ) + { + return iIsLiveStream; + } + +// ----------------------------------------------------------------------------- +// CCRRtspCommon::FindContentBase +// +// ----------------------------------------------------------------------------- +// +void CCRRtspCommon::FindContentBase( void ) + { + iContentBase.Set( NULL, 0 ); + TInt cbStringOffset( iRtspText->FindC( KCRContentBaseHeader() ) ); + if ( cbStringOffset > 0 ) + { + TPtrC8 beginningFromCb( iRtspText->Right( iRtspText->Length() - + ( cbStringOffset + KCRContentBaseHeader().Length() ) ) ); + TInt lfStringOffset( beginningFromCb.Find( KCRNewLine ) ); + if ( lfStringOffset != KErrNotFound ) + { + LOG1( "### setting content-base, len = %d", lfStringOffset - 1 ); + iContentBase.Set( beginningFromCb.Mid( 0, lfStringOffset - 1 ) ); // -1 to cut trailing / + } + } + } +// ----------------------------------------------------------------------------- +// CCRRtspCommon::ContentBase +// +// ----------------------------------------------------------------------------- +// +TPtrC8 CCRRtspCommon::ContentBase( void ) + { + return iContentBase; + } + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRTSPPacketSource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRTSPPacketSource.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,2854 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTSP Client impl.* +*/ + + + + +// INCLUDE FILES +#include "CCRRtspPacketSource.h" +#include "CCRPunchPacketSender.h" +#include "CCRRtpTcpStreamer.h" +#include "CCRRtspCommand.h" +#include "CCRPacketBuffer.h" +#include +#include "CCRTimer.h" +#include +#include +#include +#include +#include // ROP error codes + +// DATA TYPES +// ###################################################### +// WARNING: JUMBOJET-SIZED KLUDGE AHEAD: +// ###################################################### +#define private public +// Explanation: timestamp getter in rtcp sender report +// class is broken beyond repair. It may be fixed but the +// broken version is already shipped to millions of phones +// around the world. The broken getter method can't +// be overridden as it requires access to private part +// of sender reports instance variables. The item we +// need (ntp timestamp) is there intact in private instance +// variables but there is useless getter for that. +#include + +/* sender report (SR) */ +class TRtcpSRPart + { +public: + TUint32 ssrc; /**< sender generating this report */ + TUint32 ntp_sec; /**< NTP timestamp */ + TUint32 ntp_frac; /**< Fractal seconds */ + TUint32 rtp_ts; /**< RTP timestamp */ + TUint32 psent; /**< packets sent */ + TUint32 osent; /**< octets sent */ + }; +#undef private +// ###################################################### +// Major kludge ends here. +// ###################################################### + +// CONSTANTS +const TInt KCRPortNumberBase( 16670 ); +const TInt KCSeqForRtspNegoation( 42 ); +const TInt KRtspPortNumber( 554 ); +const TInt KRtpPacketVersion( 2 ); +const TUint KSenderReportPacketType( 0xC8 ); // 200 decimal +const TInt KDVR10Seconds( 10000000 ); + +// The number of sequential packets that must be received +// before a stream is considered good. 1 means no delay, start +// from very first packet +const TInt KDVRMinSequential( 1 ); +// The maximum number of dropped packets to be considered a +// dropout, as opposed to an ended and restarted stream. +const TInt KDVRMaxMisorder( 50 ); +// The maximum number of packets by which a packet can be delayed +// before it is considered dropped. +const TInt KDVRMaxDropOut( 3000 ); +_LIT( KRtspPortString, "554" ); +_LIT8( KCRCName, "N++ " ); +// Timeout for RTP/UDP reception before switching to TCP mode +const TTimeIntervalMicroSeconds32 KCRRtspRtpUdpTimeout( 10 * 1e6 ); +// Timeout for waiting for server response to any RTSP command +const TTimeIntervalMicroSeconds32 KCRRtspResponseTimeout( 15 * 1e6 ); +// Timeout for waiting for server response to TIERDOWN command +const TTimeIntervalMicroSeconds32 KCRRtspTierdownTimeout( 3 * 1e6 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtspPacketSource* CCRRtspPacketSource::NewL( + const SCRRtspParams& aParams, + CCRConnection& aConnection, + RSocketServ& aSockServer, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + { + CCRRtspPacketSource* self = new( ELeave ) + CCRRtspPacketSource( aConnection, aSockServer, aSessionObs, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL( aParams ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::CCRRtspPacketSource +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtspPacketSource::CCRRtspPacketSource( + CCRConnection& aConnection, + RSocketServ& aSockServer, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + : CCRPacketSourceBase( aOwningSession, CCRStreamingSession::ECRRtspSourceId ), + iSockServer( aSockServer ), + iConnection( aConnection ), + iStage( ERTSPInit ), + iCSeq( KCSeqForRtspNegoation ), + iClientPort( KCRPortNumberBase ), + iSessionId(NULL, 0 ), + iReadyToPlay(EFalse), + iSessionObs( aSessionObs ), + iStartPos( KRealZero ), + iEndPos( KRealMinusOne ), + iUdpFound( EFalse ), + iTrafficFound( EFalse ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ConstructL( const SCRRtspParams& aParams ) + { + LOG( "CCRRtspPacketSource::ConstructL() in" ); + if ( aParams.iUrl.Length() == 0 ) + { + User::Leave ( KErrArgument ); + } + + iSentData = HBufC8::NewL ( KCROptionsReply().Length() + KMaxInfoName ); + iRtpTcpStreamer = CCRRtpTcpStreamer::NewL( *this ); + iRtspUri = aParams.iUrl.AllocL(); + iRtspUri8 = HBufC8::NewL( aParams.iUrl.Length()); + iRtspUri8->Des().Copy( aParams.iUrl ); + iUserName = aParams.iUserName.AllocL(); + iPassword = aParams.iPassword.AllocL(); + User::LeaveIfError( iConnection.RegisterObserver( this ) ); + iUdpReceptionTimer = CCRTimer::NewL( EPriorityLow, *this ); + iProxyServerAddr = aParams.iProxyServerAddr; + iProxyServerPort = aParams.iProxyServerPort; + DoConnectL(); // Makes no sense to construct without immediately connecting + + LOG( "CCRRtspPacketSource::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::~CCRRtspPacketSource +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtspPacketSource::~CCRRtspPacketSource() + { + LOG( "CCRRtspPacketSource::~CCRRtspPacketSource() in" ); + // Deletes everything related to session + CleanUp(); + delete iRtspTimeout; + delete iSentData; + delete iAuthType; + delete iRtspUri8; + delete iUserName; + delete iPassword; + delete iNonce; + delete iOpaque; + delete iRealm; + delete iRtpTcpStreamer; + delete iUdpReceptionTimer; + iReceiveStreams.Reset(); + iObserver = NULL; + iConnection.UnregisterObserver( this ); + LOG( "CCRRtspPacketSource::~CCRRtspPacketSource() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::CleanUp +// Callback method called from cleanup-cidle that just calls the actual +// cleanup method. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::CleanUp() + { + LOG( "CCRRtspPacketSource::CleanUp() in" ); + if ( iUdpReceptionTimer ) + { + iUdpReceptionTimer->Cancel(); + } + delete iRtspPingTimer; + iRtspPingTimer = NULL; + + iRtpRecvSrcAudio.Close(); + iRtpRecvSrcVideo.Close(); + iAudioSession.Close(); + iVideoSession.Close(); + iReadyToPlay = EFalse; + delete iSdpParser; iSdpParser = NULL; + delete iRtspUri; iRtspUri = NULL; + delete iRtspSock; iRtspSock = NULL; + + for ( TInt i( 0 ); i < ERTPMaxSockets; i++ ) + { + delete iRTPSockArr[i]; + iRTPSockArr[i] = NULL; + } + for ( TInt i( 0 ); i < ERTSPLastStage; i++ ) + { + delete iPrevCommands[i]; + iPrevCommands[i] = NULL; + delete iResponses[i]; + iResponses[i] = NULL; + } + + iSessionId.Set( NULL, 0 ); + delete iPunchPacketSenderAudio; iPunchPacketSenderAudio = NULL; + delete iPunchPacketSenderVideo; iPunchPacketSenderVideo = NULL; + delete iUserAgent; iUserAgent = NULL; + delete iWapProfile; iWapProfile = NULL; + iStartPos = KRealZero; + iEndPos = KRealMinusOne; + + LOG( "CCRRtspPacketSource::CleanUp() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::DoConnectL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::DoConnectL( void ) + { + if ( !iRtspUri ) + { + User::Leave( KErrNotReady ); + } + if ( iRtspSock ) + { + delete iRtspSock; iRtspSock = NULL; + } + + iRtspSock = CCRSock::NewL( *this, ERTPControl, iConnection.Connection(), + iSockServer, ETrue, ETrue ); + TUriParser uriParser; + User::LeaveIfError( uriParser.Parse( iRtspUri->Des() ) ); + iRtspUriHost.Set( uriParser.Extract( EUriHost ) ); + TPtrC portString( KRtspPortString ); + if ( uriParser.IsPresent( EUriPort ) ) + { + portString.Set( uriParser.Extract( EUriPort ) ); + } + + TLex portLex( portString ); + TInt port( KRtspPortNumber ); + if ( portLex.Val( port ) != KErrNone ) + { + User::Leave( KErrMMInvalidURL ); + } + if ( iProxyServerAddr.Length() && iProxyServerPort ) + { + LOG2( "CCRRtspPacketSource::DoConnectL(), Proxy: %S port: %d", + &iProxyServerAddr, iProxyServerPort ); + User::LeaveIfError( iRtspSock->ConnectSock( iProxyServerAddr, iProxyServerPort ) ); + } + else + { + User::LeaveIfError(iRtspSock->ConnectSock( iRtspUriHost, port ) ); + } + iCSeq = KCSeqForRtspNegoation; + + TTime now; + now.UniversalTime(); + iClientPort = + KCRPortNumberBase + ( ( now.DateTime().MicroSecond() / 1000 ) * 2 ); + + // Get transport method from connection heuristics + iTransport = ( iConnection.GetHeuristic( + CCRConnection::EUdpStreamingBlocked ) )? ERTPOverTCP: ERTPOverUDP; + LOG1( "CCRRtspPacketSource::DoConnectL(), RTP transport: %d (0=UDP, 1=TCP)", iTransport ); + + // Get user agent, bandwidth and wap profile based on connection bearer (3G or not) + TConnMonBearerType bearer = iConnection.BearerType(); + TBool is3g( iConnection.IsBearerWLANor3G( bearer ) ); + + // Fetch wap profile from WebUtils repository + if ( !iWapProfile ) + { + CRepository* repository = CRepository::NewLC( KCRUidWebUtils ); + TUint32 profilekey = ( is3g )? KWebUtilsUaProf3G: KWebUtilsUaProf; + TFileName profilebuf( KNullDesC ); + if ( !repository->Get( profilekey, profilebuf ) ) + { + iWapProfile = HBufC8::NewL( profilebuf.Length() ); + iWapProfile->Des().Copy( profilebuf ); + } + + CleanupStack::PopAndDestroy( repository ); + LOG1( "CCRRtspPacketSource::DoConnectL(), iWapProfile: %S", &profilebuf ); + } + + // Fetch user agent + // Should we add version information to user agent string? + delete iUserAgent; iUserAgent = NULL; + iUserAgent = KCRRTSPDefaultUserAgent().AllocL(); + + // Get bandwidth from connection + iBandwidth = iConnection.MaximumBandwidth(); + + LOG( "CCRRtspPacketSource::DoConnectL out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::URI +// ----------------------------------------------------------------------------- +// +TPtr CCRRtspPacketSource::URI(void) + { + __ASSERT_DEBUG( iRtspUri != NULL , User::Panic( _L( "RTSP source" ), KErrBadHandle ) ); + TPtr retval ( NULL , 0 ); + if ( iRtspUri ) + { + retval.Set( iRtspUri->Des() ); + } + else + { + LOG( "CCRRtspPacketSource::URI iRtspUri was NULL !!!!!!!!!! " ); + } + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::GetSdp +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::GetSdp( TPtrC8& aSdp ) + { + TInt retval( KErrNotReady ); + if ( iSdpParser ) + { + return iSdpParser->GetSdp( aSdp ); + } + + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SeqAndTS +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::SeqAndTS( + TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ) + { + TInt retval( KErrNotReady ); + if ( iSeqFromRtpInfoForVideo != 0 || iSeqFromRtpInfoForAudio != 0 ) + { + aAudioSeq = iSeqFromRtpInfoForAudio; + aAudioTS = iRTPTimeStampAudio; + aVideoSeq = iSeqFromRtpInfoForVideo; + aVideoTS = iRTPTimeStampVideo; + retval = KErrNone; + } + + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::PostActionL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::PostActionL() + { + LOG1( "CCRRtspPacketSource::PostActionL(), SDP will be handled, iSdpParser: %d", + iSdpParser ); + User::LeaveIfNull( iSdpParser ); + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateSdpAvailable ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::Play +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::Play( const TReal& aStartPos, const TReal& aEndPos ) + { + LOG2( "CCRRtspPacketSource::Play(), aStartPos: %f, aEndPos: %f", + aStartPos, aEndPos ); + LOG2( "CCRRtspPacketSource::Play(), sent seq: %d, rec: %d", + iCSeq, iLastReceivedSeq ); + iReadyToPlay = ETrue; + iStartPos = aStartPos; + iEndPos = aEndPos; + ResetStreamFlags(); + + // In xps case we never get startpos with this method. + // instead setposition will be called + if ( iBuffer ) + { + iBuffer->ResetBuffer(); + } + + // If both audio and video sessions are closed, we + // need to open at least one of them: + TInt err( KErrNone ); + if ( iStage == ERTSPReadyToPlay || iStage == ERTSPPauseSent ) + { + if ( iStage == ERTSPReadyToPlay || iCSeq == ( iLastReceivedSeq + 1 ) ) + { + TRAP( err, SendPlayCommandL() ); + } + else + { + // We have a fast-fingered user in charge; play has been issued + // but the previous pause has not been completed yet: postpone this + // operation + iPostPonedPlay = ETrue; + } + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::Pause +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::Pause() + { + LOG1( "CCRRTSPPacketSource::Pause() stage %d", iStage ); + TInt err( KErrNotReady ); + if ( iStage == ERTSPPlaying ) + { + if ( iResponses[ERTSPPlaySent]->IsLiveStream() || iSdpParser->IsLiveStream() ) + { + err = KErrNotSupported; + } + else + { + TRAP( err, SendPauseCommandL() ); + } + } + if ( iStage == ERTSPPauseSent ) + { + err = KErrNone; + } + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::Stop +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::Stop() + { + LOG( "CCRRtspPacketSource::Stop()" ); + + iReadyToPlay = EFalse; + iPostPonedPlay = EFalse; + iStartPos = KRealZero; + TInt err( KErrDisconnected ); + + if ( iStage == ERTSPPlaySent || iStage == ERTSPPlaying || + iStage == ERTSPPauseSent || iStage == ERTSPSetupAudioSent || + iStage == ERTSPSetupVideoSent ) + { + err = KErrNone; + if ( iRtspSock ) + { + iRtspSock->Cancel(); + } + + TRAP_IGNORE( SendTearDownCommandL() ); // if this fails, we don't care + iStage = ERTSPTearDownSent; + StartRtspTimeout( KCRRtspTierdownTimeout ); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SetPosition +// ----------------------------------------------------------------------------- + +TInt CCRRtspPacketSource::SetPosition( const TInt64 aPosition ) + { + LOG1( "CCRRtspPacketSource::SetPosition(), iStartPos: %f", iStartPos ); + + if ( aPosition == -2 ) + { + if ( iStage != ERTSPPlaySent && iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRReadyToSeek, KErrNone ); + } + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::GetRange +// ----------------------------------------------------------------------------- +void CCRRtspPacketSource::GetRange( TReal& aLower, TReal& aUpper ) + { + aLower = KRealZero; + aUpper = KRealMinusOne; + + if ( ( iStage == ERTSPPlaySent || iStage == ERTSPPlaying ) && + iResponses[ERTSPPlaySent] ) + { + iResponses[ERTSPPlaySent]->GetRange(aLower,aUpper); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::DataReceived +// This is called when data is received from socket. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::DataReceived( TInt /*aSockId*/, const TDesC8& aData ) + { + // Find out RTCP message or RTP packet from IP packet + iRtpTcpStreamer->DataAvailable( aData, ( iTransport == ERTPOverTCP ) ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::RtspMsgAvailable +// This is called when data is received from socket. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::RtspMsgAvailable( const TDesC8& aData ) + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + if ( aData.Length() > 0 ) + { + LOG1( "CCRRtspPacketSource::RtspMsgAvailable(), aData len: %d", aData.Length() ); + TName d( KNullDesC ); + for( TInt i( 0 ); i < aData.Length(); i++ ) + { + TChar c = aData[i]; + d.Append( c ); + if ( ( i > 0 ) && ( i % 80 ) == 0 ) + { + LOG1( ">%S<", &d ); + d.Zero(); + } + } + + LOG1( ">%S<", &d ); + } +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + TRAPD( err, ProcessRtspResponseL( aData ) ); + if ( err ) + { + LOG1( "CCRRtspPacketSource::RtspMsgAvailable(), ProcessRtspResponseL Leaved, err: %d", err ); + if ( err == KErrNotSupported ) + { + // The response did not look like rtsp response at all. + // some servers decide to send rtsp commands to us so lets + // try interpreting it as a command + err = KErrNone; + TRAP( err, ProcessRTSPCommandL( aData ) ) + if ( err ) + { + iOwningSession.SourceStop(); + } + } + else + { + iOwningSession.SourceStop(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SockStatusChange +// This is called when socket status changes. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SockStatusChange( + TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ) + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + if ( aStatus == CCRSock::EFailed ) + { + LOG3( "CCRRtspPacketSource::SockStatusChange(), aSockId: %d, aStatus: %d, aError: %d", + aSockId, aStatus, aError ); + } +#else // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + ( void )aSockId; + ( void )aError; +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + if ( aStatus == CCRSock::EFailed ) + { + // Ask session to perform cleanup + iOwningSession.SourceStop(); + + if ( iStage == ERTSPInit && aSockId == ERTPControl && aError == KErrCouldNotConnect ) + { + // map error to different error id, so we can know that showing reconnect query is pointless. + aError = KErrEof; + } + + // Inform the observer that there is a problem. Exclude case where we're closing + // and the error is KErrEof + if ( ! ( iStage == ERTSPTearDownSent && aError == KErrEof ) ) + { + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), ECRConnectionError, aError ); + } + } + else + { + LOG( "CCRRtspPacketSource::SockStatusChange(), eof in closing: normal" ); + } + } + else if ( aSockId == ERTPControl && aStatus == CCRSock::EIdle && + iStage == ERTSPInit ) + { + // Called once from here for lifetime of this object + TRAPD( err, SendRtspCommandL() ); + if ( err ) + { + LOG1( "CCRRtspPacketSource::SockStatusChange(), SendRtspCommandL Leaved: %d", err ); + + // Ask session to perform cleanup + iOwningSession.SourceStop(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::RtpTcpPacketAvailable +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::RtpTcpPacketAvailable( + TInt aChannel, + const TDesC8& aPacket ) + { + // Map embedded TCP channel to streamid: + // video: channel=(0,1) --> id=(2,3) + // audio: channel=(2,3) --> id=(0,1) when video present + // audio: channel=(0,1) --> id=(0,1) when audio only + TInt mappedChannel( ( iSdpParser->VideoControlAddr().Length() )? + ( aChannel + 2 ) % 4: aChannel ); + MCRPacketSource::TCRPacketStreamId streamid( + ( MCRPacketSource::TCRPacketStreamId )( mappedChannel ) ); + + iBuffer->AddPacket( streamid, aPacket ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ForwardRtpTcpChunk +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ForwardRtpTcpChunck( const TDesC8& aChunk ) + { + if ( iRtspSock ) + { + iRtspSock->SendData( aChunk ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::TimerExpired +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::TimerExpired( CCRTimer* ) + { + LOG( "CCRRtspPacketSource::TimerExpired: RTP/UDP timer expired, switching to RTP/TCP" ); + + if ( !iUdpFound ) + { + // Signal heuristic for TCP streaming + LOG( "CCRRtspPacketSource::TimerExpired - Switch to TCP" ); + iConnection.SetHeuristic( CCRConnection::EUdpStreamingBlocked, ETrue ); + } + else + { + // We had UDP before in this session but now it is lost for some reason. + // Try UDP again. + + // Flag UDP found away + iUdpFound = EFalse; + iTrafficFound = EFalse; + + // Clear stream followup + iReceiveStreams.Reset(); + + LOG( "CCRRtspPacketSource::TimerExpired - Trying UDP again" ); + } + + // Notify client to close us and start a new session + if ( iObserver ) + { + // Notify client + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), ECRSwitchingToTcp, KErrNone ); + } + else + { + // If no client observer, teardown and cleanup ourselves + iPostPonedPlay = EFalse; + TRAPD( err, SendTearDownCommandL() ); + if ( err != KErrNone ) + { + LOG1( "CCRRtspPacketSource::TimerExpired() Send TEARDOWN failed: %d", err ); + } + + CleanUp(); + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ProcessRTSPCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ProcessRTSPCommandL( const TDesC8& aData ) + { + LOG1( "CCRRtspPacketSource::ProcessRTSPCommandL(), iStage: %d", ( int )iStage ); + + CCRRtspCommand* cmd = CCRRtspCommand::NewL(); + CleanupStack::PushL( cmd ); + cmd->TryParseL( aData ); + + switch ( cmd->Command() ) + { + case CCRRtspCommand::ERTSPCommandOPTIONS: + iSentData->Des().Format( KCROptionsReply, cmd->CSeq() ); + iRtspSock->SendData( iSentData->Des() ); + break; + + default: + // Server sent us a command and it is not options. + // for sure they want us to stop ; is there + iOwningSession.SourceStop(); + break; + } + + CleanupStack::PopAndDestroy( cmd ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ProcessRtspResponseL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ProcessRtspResponseL( const TDesC8& aData ) + { + LOG1( "CCRRtspPacketSource::ProcessRtspResponseL(), iStage: %d", iStage ); + + // Cancel timeout timer + if ( iRtspTimeout ) + { + iRtspTimeout->Cancel(); + } + + // The server responded to our TEARDOWN command. No need to parse the response + // since we don't care what the server said. Ask session to clean us up. + if ( iStage == ERTSPTearDownSent ) + { + iOwningSession.SourceStop(); + return; + } + + // First parse response + CCRRtspResponse* resp = CCRRtspResponse::NewL(); + CleanupStack::PushL( resp ); + resp->TryParseL( aData ); + + // Then find the command that this resp is associated with: + iLastReceivedSeq = resp->CSeq(); + TBool commandFound( EFalse ); + for ( TInt i( 0 ); i < ERTSPLastStage && !commandFound; i++ ) + { + LOG2( "CCRRtspPacketSource:: prevcommand stage: %d cseq: %d", + i, ( iPrevCommands[i] )? iPrevCommands[i]->CSeq(): KErrNotFound ); + + if ( iPrevCommands[i] && ( iPrevCommands[i]->CSeq() == resp->CSeq() ) ) + { + LOG1( "CCRRtspPacketSource::ProcessRtspResponseL(), matching command: %d", i ); + LOG1( "CCRRtspPacketSource::ProcessRtspResponseL(), cseq was: %d", resp->CSeq() ); + delete iResponses[i]; + CleanupStack::Pop( resp ); + iResponses[i] = resp; + commandFound = ETrue; + if ( i == ERTSPOptSent ) + { + // Process options no further, used only for ping here + return; + } + } + } + + // Delete response if sequency not match + if ( !commandFound ) + { + CleanupStack::PopAndDestroy( resp ); + LOG1( "CCRRtspPacketSource::ProcessRtspResponseL(), Command not found, cseq: %d", resp->CSeq() ); + } + else + { + if ( iResponses[iStage]->StatusCode() == CCRRtspResponse::ERTSPRespOK || // 200 + iResponses[iStage]->StatusCode() == CCRRtspResponse::ERTSPRespCreated ) // 201 + { + // Extract useful information from response depending on stage: + switch ( iStage ) + { + case ERTSPSetupAudioSent: // From setups take session id + case ERTSPSetupVideoSent: + if ( !iSessionId.Ptr() ) + { + iResponses[iStage]->SessionId( iSessionId ); + } + // Check for sdp parser and send punch packets for UDP transport + // (TCP or multicast: session setup and PLAY in SendRTSPCommand) + if ( iSdpParser && iTransport == ERTPOverUDP ) + { + // If we see that we don't need to send further setups, + // do send punch packets now. + if ( ( iSdpParser->VideoControlAddr().Length() && // if we have video + iResponses[ERTSPSetupVideoSent] && // and we have video se tup + iSdpParser->AudioControlAddr().Length() && // and we have audio + iResponses[ERTSPSetupAudioSent] ) || // and we have audio set up or... + ( !iSdpParser->VideoControlAddr().Length() && // if we have no video + !iResponses[ERTSPSetupVideoSent] && // and we've video not set up + iSdpParser->AudioControlAddr().Length() && // and it shows we have audio + iResponses[ERTSPSetupAudioSent] ) || // and we've audio set up or... + ( iSdpParser->VideoControlAddr().Length() && // if we have video + iResponses[ERTSPSetupVideoSent] && // and we have video set up + !iSdpParser->AudioControlAddr().Length() && // and we have no audio + !iResponses[ERTSPSetupAudioSent] ) ) // and we have no audio set up + { + SendPunchPacketsL(); + } + } + + // Notify sink that SETUP repply received + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStateSetupRepply ); + break; + + case ERTSPDescSent: // From desc take sdp + if ( iObserver && iResponses[iStage]->ContentLen() <= 0 ) + { + // This should not happen + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), ECRConnectionError, KErrUnderflow ); + } + iOwningSession.SourceStop(); + } + else + { + delete iSdpParser; iSdpParser = NULL; + iSdpParser = CDvrSdpParser::NewL(); + if ( iResponses[iStage]->ContentBase().Length() ) + { + iSdpParser->TryParseL( iResponses[iStage]->Content(), + iResponses[iStage]->ContentBase() ); + } + else + { + iSdpParser->TryParseL( iResponses[iStage]->Content(), + iRtspUri8->Des() ); + } + // Check for multicast address in SDP + if ( iSdpParser->IsMultiCastSdp() ) + { + iTransport = ERTPOverMulticast; + } + if ( iObserver && iSdpParser->IsRealMediaContent() ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRStreamIsRealMedia, KErrNotSupported ); + iOwningSession.SourceStop(); + return; // Make sure we don't continue with SETUP commands + } + else // do not send realmedia sdp to sinks + { + if ( iObserver && iSdpParser->IsLiveStream() ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRStreamIsLiveStream, KErrNone ); + } + + // then check for bandwidth requirements even before we start: + if ( iObserver ) + { + // Unknown bitrate or bandwidth are returned as zero. + // Bitrates in kbit/s + TInt bitrate( iSdpParser->VideoBitrate() + + iSdpParser->AudioBitrate() ); + TInt bandwidth( iConnection.MaximumBandwidth() / 1000 ); + if ( bitrate && bandwidth && bandwidth < bitrate ) + { + LOG2( "CCRRtspPacketSource::ProcessRtspResponseL(), bitrate:%d, bandwidth: %d -> NotEnoughBandwidth", + bitrate, bandwidth); + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRNotEnoughBandwidth, KErrNone ); + return; // Make sure we don't tell sinks anything about + // sdp that has too high bitrate for our network bearer + } + } + + // But if we didn't have realmedia stream and the bandwidth check + // is also all right, then go on and tell the sinks -> + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStateSdpAvailable ); + } + } + break; + + case ERTSPPlaySent: + { + CCRRtspResponse::SRTPInfoHeader rtpInfo; + iResponses[ERTSPPlaySent]->RTPInfoHeader( rtpInfo ); + + TPtrC8 videoAddr ( NULL, 0 ); + if ( iSdpParser->VideoControlAddr().Length() ) + { + videoAddr.Set ( iSdpParser->VideoControlAddr() ); + } + TPtrC8 audioAddr ( NULL , 0 ); + if ( iSdpParser->AudioControlAddr().Length() ) + { + audioAddr.Set ( iSdpParser->AudioControlAddr() ); + } + + if ( iSdpParser->VideoControlAddr().Length() && + rtpInfo.iFirstURL.Length() && + videoAddr.Find( rtpInfo.iFirstURL ) >= 0 ) + { + iRTPTimeStampVideo = rtpInfo.iFirstTS ? rtpInfo.iFirstTS : 1; + iSeqFromRtpInfoForVideo = rtpInfo.iFirstSeq; + } + if ( iSdpParser->VideoControlAddr().Length() && + rtpInfo.iSecondURL.Length() && + videoAddr.Find( rtpInfo.iSecondURL ) >= 0 ) + { + iRTPTimeStampVideo = rtpInfo.iSecondTS ? rtpInfo.iSecondTS : 1; + iSeqFromRtpInfoForVideo = rtpInfo.iSecondSeq; + } + if ( iSdpParser->AudioControlAddr().Length() && + rtpInfo.iFirstURL.Length() && + audioAddr.Find( rtpInfo.iFirstURL) >= 0 ) + { + iRTPTimeStampAudio = rtpInfo.iFirstTS ? rtpInfo.iFirstTS : 1; + iSeqFromRtpInfoForAudio = rtpInfo.iFirstSeq; + } + if ( iSdpParser->AudioControlAddr().Length() && + rtpInfo.iSecondURL.Length() && + audioAddr.Find( rtpInfo.iSecondURL) >= 0 ) + { + iRTPTimeStampAudio = rtpInfo.iSecondTS ? rtpInfo.iSecondTS : 1; + iSeqFromRtpInfoForAudio = rtpInfo.iSecondSeq; + } + + // ok, if we don't have rtp-info header, we don't know yet. + if ( rtpInfo.iFirstURL.Length() == 0 && + rtpInfo.iSecondURL.Length() == 0 ) + { + iNoRtpInfoHeader++; + } + else + { + // We have RTP-info, so control stream is no longer mandatory + // Mark control streams as "found" + StreamFound( EAudioControlStream ); + StreamFound( EVideoControlStream ); + //StreamFound( ESubTitleControlStream ); + + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStateSeqAndTSAvailable ); + } + + // Live state + if ( iResponses[ERTSPPlaySent]->IsLiveStream() || iSdpParser->IsLiveStream() ) + { + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRStreamIsLiveStream, KErrNone ); + } + } + + // Notify seeking + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRReadyToSeek, KErrNone ); + } + } + break; + + default: + // by default extract no information + break; + } + + // Then continue with business: + SendRtspCommandL(); // will change iStage also + } + + // Authentication needed.. + else if ( iResponses[iStage]->StatusCode() == + CCRRtspResponse::ERTSPRespUnauthorized || // 401 + iResponses[iStage]->StatusCode() == + CCRRtspResponse::ERTSPRespProxyAuthenticationRequired ) // 407 + { + iAuthFailedCount++; + if ( iUserName && + iUserName->Length() && + iPassword && + iAuthFailedCount == 1 ) + { + iAuthenticationNeeded = ETrue; + iAuthType = iResponses[iStage]->AuthenticationTypeL().AllocL(); + iRealm = iResponses[iStage]->RealmL().AllocL(); + iOpaque = iResponses[iStage]->OpaqueL().AllocL(); + iNonce = iResponses[iStage]->NonceL().AllocL(); + SendAuthDescribeL(); + } + else + { + iAuthFailedCount = 0; + LOG( "CCRRtspPacketSource::ProcessRtspResponseL() Authentication failure !" ); + + // Cleanup + iOwningSession.SourceStop(); + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRAuthenticationNeeded, KErrNone ); + } + } + } + else if ( iResponses[iStage]->StatusCode() == CCRRtspResponse::ERTSPRespUnsupportedTransport ) // 461 + { + LOG1( "CCRRtspPacketSource::ProcessRtspResponseL() - Unsupported Transport: %d", iTransport ); + + if ( iConnection.GetHeuristic( CCRConnection::EUdpStreamingBlocked ) ) + { + // Using TCP, change to UDP + LOG( "CCRRtspPacketSource::ProcessRtspResponseL() - Change TCP to UDP" ); + iConnection.SetHeuristic( CCRConnection::EUdpStreamingBlocked, EFalse ); + // Notify observer at client side: + ProcessRtspErrorResponseL( iResponses[iStage]->StatusCode() ); + } + else + { + // Using UDP, change to TCP + LOG( "CCRRtspPacketSource::ProcessRtspResponseL() - Change UDP to TCP"); + iConnection.SetHeuristic( CCRConnection::EUdpStreamingBlocked, ETrue ); + // Notify observer at client side: + ProcessRtspErrorResponseL( iResponses[iStage]->StatusCode() ); + } + } + else + { + // before doing cleanup, notify observer at client side: + ProcessRtspErrorResponseL( iResponses[iStage]->StatusCode() ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ProcessRtspErrorResponseL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ProcessRtspErrorResponseL( + CCRRtspResponse::TResponseCode aErrorCode ) + { + SCRQueueEntry entry; + entry.iMsg = ECRMsgQueueConnectionError; + + switch ( aErrorCode ) + { + case CCRRtspResponse::ERTSPRespLowOnStorageSpace: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespMultipleChoices: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespMovedPermanently: + entry.iErr = KErrNotFound; + break; + + case CCRRtspResponse::ERTSPRespMovedTemporarily: + entry.iErr = KErrNotFound; + break; + + case CCRRtspResponse::ERTSPRespSeeOther: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespNotModified: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespUseProxy: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespBadRequest: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespPaymentRequired: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespForbidden: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespGone: + case CCRRtspResponse::ERTSPRespConferenceNotFound: + case CCRRtspResponse::ERTSPRespNotFound: + entry.iErr = KErrNotFound; + break; + + case CCRRtspResponse::ERTSPRespMethodNotAllowed: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespNotAcceptable: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespRequestTimeOut: + entry.iErr = KErrTimedOut; + break; + + case CCRRtspResponse::ERTSPRespLengthRequired: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespPreconditionFailed: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespRequestEntityTooLarge: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespRequestURITooLarge: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespParameterNotUnderstood: + entry.iErr = KErrArgument; + break; + + case CCRRtspResponse::ERTSPRespNotEnoughBandwidth: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespSessionNotFound: + entry.iErr = KErrCouldNotConnect; + break; + + case CCRRtspResponse::ERTSPRespMethodNotValidInThisState: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespHeaderFieldNotValidForResource: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespInvalidRange: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespParameterIsReadOnly: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespAggregateOperationNotAllowed: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespOnlyAggregateOperationAllowed: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespUnsupportedTransport: + entry.iErr = KErrCouldNotConnect; + break; + + case CCRRtspResponse::ERTSPRespDestinationUnreachable: + entry.iErr = KErrCouldNotConnect; + break; + + case CCRRtspResponse::ERTSPRespInternalServerError: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespNotImplemented: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespBadGateway: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespServiceUnavailable: + entry.iErr = KErrCouldNotConnect; + break; + + case CCRRtspResponse::ERTSPRespGatewayTimeOut: + entry.iErr = KErrGeneral; + break; + + case CCRRtspResponse::ERTSPRespUnsupportedMediaType: + case CCRRtspResponse::ERTSPRespOptionNotSupported: + case CCRRtspResponse::ERTSPRespRTSPVersionNotSupported: + entry.iErr = KErrNotSupported; + break; + + default: + entry.iErr = KErrGeneral; + break; + } + + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), ECRConnectionError, entry.iErr ); + } + + // Try tear down first + if ( Stop() == KErrDisconnected ) + { + iOwningSession.SourceStop(); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::StartRtspTimeout +// Starts RTSP command response timeout. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::StartRtspTimeout( TTimeIntervalMicroSeconds32 aTime ) + { + // Start a timeout timer to wait for the server to respond. + // If the server doesn't respond in time, cleanup will be initialized. + if ( !iRtspTimeout ) + { + TRAPD( err, iRtspTimeout = + CPeriodic::NewL( CActive::EPriorityStandard ) ); + if ( err != KErrNone ) + { + // Timer creation failed, start cleanup immediately + iOwningSession.SourceStop(); + } + } + else + { + iRtspTimeout->Cancel(); + } + + // Start timeout timer + iRtspTimeout->Start( + aTime, + aTime, + TCallBack( RtspTimeoutCallback, this ) ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::RtspTimeoutCallback +// Callback for RTSP response timeout. Just ask session to start cleanup +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::RtspTimeoutCallback( TAny* aPtr ) + { + LOG( "CCRRtspPacketSource::RtspTimeoutCallback()" ); + + CCRRtspPacketSource* self = static_cast( aPtr ); + self->iRtspTimeout->Cancel(); + self->iOwningSession.SourceStop(); + return 0; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendRtspCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendRtspCommandL() + { + LOG1( "CCRRtspPacketSource::SendRtspCommandL(), iStage: %d", iStage ); + + if ( iPostPonedPlay ) + { + iPostPonedPlay = EFalse; + Play( iStartPos, iEndPos ); + } + else + { + switch ( iStage ) + { + case ERTSPInit: + case ERTSPOptSent: + { + delete iPrevCommands[ERTSPDescSent]; + iPrevCommands[ERTSPDescSent] = NULL; + iPrevCommands[ERTSPDescSent] = CCRRtspCommand::NewL(); + iPrevCommands[ERTSPDescSent]->SetCommand( + CCRRtspCommand::ERTSPCommandDESCRIBE ); + + TPtrC8 uriDes ( iRtspUri8->Des() ); + iPrevCommands[ERTSPDescSent]->SetURL( uriDes ); + iPrevCommands[ERTSPDescSent]->SetCSeq( iCSeq++ ); + if ( iUserAgent ) + { + iPrevCommands[ERTSPDescSent]->SetUserAgentL( *iUserAgent ); + } + if ( iWapProfile ) + { + iPrevCommands[ERTSPDescSent]->SetWapProfileL( *iWapProfile ); + } + if ( iBandwidth ) + { + iPrevCommands[ERTSPDescSent]->SetBandwidth( iBandwidth ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[ERTSPDescSent]->ProduceL() ); + StartRtspTimeout( KCRRtspResponseTimeout ); + iStage = ERTSPDescSent; + } + } + break; + + case ERTSPDescSent: + if ( iSdpParser ) + { + const TInt audio( iSdpParser->MediaIdentifierAudio() ); + const TInt video( iSdpParser->MediaIdentifierVideo() ); + TBool videoExists( iSdpParser->VideoControlAddr().Length() > 0 ); + TBool audioExists( iSdpParser->AudioControlAddr().Length() > 0 ); + + /* If both medias are reported with dynamic payload + * type and audio stream is reported with lower + * payload type, then some servers don't work correctly + * if the SETUP commands are not in correct order, ie. + * we need to first SETUP the audio stream here. + */ + const TBool audioBeforeVideo( + audioExists && audio >= 96 && video >= 96 && audio < video ); + + if ( videoExists && !audioBeforeVideo ) + { + SendSetupCommandL( iSdpParser->VideoControlAddr(), EFalse ); + iStage = ERTSPSetupVideoSent; + } + else if ( audioExists ) + { + SendSetupCommandL( iSdpParser->AudioControlAddr(), ETrue ); + iStage = ERTSPSetupAudioSent; + } + else + { + LOG1( "CCRRtspPacketSource::SendRtspCommand stag %d have no audio nor video", + ( TInt )iStage ); + // no audio, no video, el panique grande + iOwningSession.SourceStop(); + } + } + break; + + case ERTSPSetupAudioSent: + { + const TInt audio( iSdpParser->MediaIdentifierAudio() ); + const TInt video( iSdpParser->MediaIdentifierVideo() ); + + if ( audio >= 96 && video >= 96 && audio < video && + iSdpParser && iSdpParser->VideoControlAddr().Length() ) + { + // Video exists also and has not been setup before, so + // let's setup it now. + + TPtrC8 ctrlAddr ( iSdpParser->VideoControlAddr() ); + SendSetupCommandL( ctrlAddr, EFalse ); + iStage = ERTSPSetupVideoSent; + } + else + { + ConditionallySetupMultiCastOrTcpStreamingL(); + } + } + break; + + case ERTSPSetupVideoSent: + { + const TInt audio( iSdpParser->MediaIdentifierAudio() ); + const TInt video( iSdpParser->MediaIdentifierVideo() ); + + // Check explanation for this in case ERTSPDescSent above. + const TBool audioBeforeVideo( + audio >= 96 && video >= 96 && audio < video ); + + // Then send audio, if applicable: + if ( iSdpParser && iSdpParser->AudioControlAddr().Length() && + !audioBeforeVideo ) + { + TPtrC8 ctrlAddr ( iSdpParser->AudioControlAddr() ); + SendSetupCommandL( ctrlAddr, ETrue ); + iStage = ERTSPSetupAudioSent; + } + else + { + // there is no audio that need setup so lets check also multicast+tcp + ConditionallySetupMultiCastOrTcpStreamingL(); + } + } + break; + + case ERTSPPauseSent: + // If we're paused, do zero the buffer, in tcp streaming case + // some servers seem to send packets even after play.. + break; + + case ERTSPReadyToPlay: + // In these stages send no further commands + break; + + case ERTSPPlaySent: + // Start timer for UDP reception and start streaming + if ( iTransport == ERTPOverUDP ) + { + iUdpReceptionTimer->Cancel(); + iUdpReceptionTimer->After( KCRRtspRtpUdpTimeout ); + } + + iStage = ERTSPPlaying; + if ( !iNoRtpInfoHeader ) + { + iSessionObs.StatusChanged( MCRPacketSource::ERtpStatePlaying ); + } + break; + + case ERTSPPlaying: + // None + break; + + case ERTSPTearDownSent: + iPostPonedPlay = EFalse; + iOwningSession.SourceStop(); + break; + + default: + // By default send no further commands + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendPlayCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendPlayCommandL(void) + { + delete iPrevCommands[ERTSPPlaySent]; + iPrevCommands[ERTSPPlaySent] = NULL; + iPrevCommands[ERTSPPlaySent] = CCRRtspCommand::NewL(); + iPrevCommands[ERTSPPlaySent]->SetCommand ( CCRRtspCommand::ERTSPCommandPLAY ); + TPtrC8 uriDes( iRtspUri8->Des() ); + iPrevCommands[ERTSPPlaySent]->SetURL( uriDes ); + iPrevCommands[ERTSPPlaySent]->SetCSeq( iCSeq ++ ); + iPrevCommands[ERTSPPlaySent]->SetRange( iStartPos , iEndPos ); + + if ( iUserAgent ) + { + iPrevCommands[ERTSPPlaySent]->SetUserAgentL( *iUserAgent ); + } + if ( iSessionId.Ptr() ) + { + iPrevCommands[ERTSPPlaySent]->SetSessionId( iSessionId ); + } + if ( iAuthenticationNeeded ) + { + AddAuthenticationL( ERTSPPlaySent ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[ERTSPPlaySent]->ProduceL() ); + StartRtspTimeout( KCRRtspResponseTimeout ); + iStage = ERTSPPlaySent; + } + + iStartPos = KRealZero; + iEndPos = KRealMinusOne; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendPauseCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendPauseCommandL(void) + { + delete iPrevCommands[ERTSPPauseSent]; + iPrevCommands[ERTSPPauseSent] = NULL; + iPrevCommands[ERTSPPauseSent] = CCRRtspCommand::NewL(); + iPrevCommands[ERTSPPauseSent]->SetCommand ( CCRRtspCommand::ERTSPCommandPAUSE ); + TPtrC8 uriDes( iRtspUri8->Des() ); + iPrevCommands[ERTSPPauseSent]->SetURL( uriDes ); + iPrevCommands[ERTSPPauseSent]->SetCSeq( iCSeq ++ ); + + if ( iUserAgent ) + { + iPrevCommands[ERTSPPauseSent]->SetUserAgentL( *iUserAgent ); + } + if ( iSessionId.Ptr() ) + { + iPrevCommands[ERTSPPauseSent]->SetSessionId( iSessionId ); + } + if ( iAuthenticationNeeded ) + { + AddAuthenticationL( ERTSPPauseSent ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[ERTSPPauseSent]->ProduceL() ); + StartRtspTimeout( KCRRtspResponseTimeout ); + iStage = ERTSPPauseSent; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendSetupCommandL +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::SendSetupCommandL( + const TDesC8& aControlAddr, + TBool aForAudio ) + { + TCRRTSPStage newStage = aForAudio ? ERTSPSetupAudioSent : ERTSPSetupVideoSent; + + delete iPrevCommands[newStage]; + iPrevCommands[newStage] = NULL; + iPrevCommands[newStage] = CCRRtspCommand::NewL(); + iPrevCommands[newStage]->SetCommand ( CCRRtspCommand::ERTSPCommandSETUP ); + iPrevCommands[newStage]->SetURL( aControlAddr ); + iPrevCommands[newStage]->SetCSeq( iCSeq ++ ); + iPrevCommands[newStage]->SetTransport( iTransport ); + + // Map stream to port number (when streaming over UDP) or channel (over TCP) + // base: iClientPort for UDP, 0 for TCP + // video: (base+0, base+1) + // audio: (base+2, base+3) or (base+0, base+1) when audio only + TInt portbase( ( iTransport == ERTPOverUDP )? iClientPort: 0 ); + TInt portoffset( ( aForAudio && iSdpParser->VideoControlAddr().Length() )? 2: 0 ); + iPrevCommands[newStage]->SetClientPort( portbase + portoffset ); + + if ( iSessionId.Ptr() ) + { + iPrevCommands[newStage]->SetSessionId ( iSessionId ); + } + if ( iAuthenticationNeeded ) + { + AddAuthenticationL( newStage ); + } + if ( iUserAgent ) + { + iPrevCommands[newStage]->SetUserAgentL( *iUserAgent ); + } + if ( iWapProfile ) + { + iPrevCommands[newStage]->SetWapProfileL( *iWapProfile ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[newStage]->ProduceL() ); + StartRtspTimeout( KCRRtspResponseTimeout ); + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendTearDownCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendTearDownCommandL() + { + CCRRtspCommand*& teardowncmd = iPrevCommands[ERTSPTearDownSent]; + iPostPonedPlay = EFalse; + if ( teardowncmd ) + { + delete teardowncmd; teardowncmd = NULL; + } + + teardowncmd = CCRRtspCommand::NewL(); + teardowncmd->SetCommand( CCRRtspCommand::ERTSPCommandTEARDOWN ); + TPtrC8 uri( iRtspUri8->Des() ); + teardowncmd->SetURL( uri ); + teardowncmd->SetCSeq( iCSeq++ ); + + if ( iSessionId.Ptr() ) + { + teardowncmd->SetSessionId( iSessionId ); + } + if ( iUserAgent ) + { + teardowncmd->SetUserAgentL( *iUserAgent ); + } + if ( iAuthenticationNeeded ) + { + AddAuthenticationL( ERTSPTearDownSent ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( teardowncmd->ProduceL() ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendOptionsCommandL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendOptionsCommandL(void) + { + delete iPrevCommands[ERTSPOptSent]; + iPrevCommands[ERTSPOptSent] = NULL; + iPrevCommands[ERTSPOptSent] = CCRRtspCommand::NewL(); + iPrevCommands[ERTSPOptSent]->SetCommand ( CCRRtspCommand::ERTSPCommandOPTIONS ); + TPtrC8 uriDes ( iRtspUri8->Des() ); + iPrevCommands[ERTSPOptSent]->SetURL ( uriDes ); + iPrevCommands[ERTSPOptSent]->SetCSeq ( iCSeq ++ ); + + if ( iUserAgent ) + { + iPrevCommands[ERTSPOptSent]->SetUserAgentL( *iUserAgent ); + } + if ( iSessionId.Ptr() ) + { + iPrevCommands[ERTSPOptSent]->SetSessionId ( iSessionId ); + } + if ( iAuthenticationNeeded ) + { + AddAuthenticationL( ERTSPOptSent ); + } + + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[ERTSPOptSent]->ProduceL() ); + } + // Sending options ping does not change our state + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SetupRTPSessions +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::SetupRTPSessions( void ) + { + TInt retval( KErrNone ); + if ( !iRtspSock ) + { + retval = KErrNotReady; + } + else + { + TInetAddr localAddr( iRtspSock->LocalAddr() ); + TInetAddr remoteAddr( iRtspSock->ConnectedAddr() ); + + // Clear used streams + iReceiveStreams.Reset(); + iTrafficFound = EFalse; + + // First audio: + if ( iRtspSock && iResponses[ERTSPSetupAudioSent] ) + { + if ( iTransport == ERTPOverMulticast ) + { + retval = CreateMulticastSocket( ERTPAudioSend1, + iResponses[ERTSPSetupAudioSent]->Destination(), + iResponses[ERTSPSetupAudioSent]->ClientPort() ); + if ( retval == KErrNone ) + { + retval = CreateMulticastSocket( ERTPAudioSend2, + iResponses[ERTSPSetupAudioSent]->Destination(), + iResponses[ERTSPSetupAudioSent]->ClientPort()+1 ); + } + } + else + { + localAddr.SetPort( iResponses[ERTSPSetupAudioSent]->ClientPort() ); + remoteAddr.SetPort( iResponses[ERTSPSetupAudioSent]->ServerPort() ); + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + TName _addr; + localAddr.Output( _addr ); + LOG2( "localaddr for video is %S:%d", &_addr, localAddr.Port() ); + remoteAddr.Output( _addr ); + LOG2( "remoteAddr for video is %S:%d", &_addr, remoteAddr.Port() ); +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + retval = CreateUnicastSocket( ERTPAudioSend1, localAddr, remoteAddr ); + if ( retval == KErrNone ) + { + localAddr.SetPort( localAddr.Port()+1 ); + remoteAddr.SetPort( remoteAddr.Port()+1 ); + retval = CreateUnicastSocket( ERTPAudioSend2, localAddr, remoteAddr ); + } + } + + if ( retval == KErrNone ) + { + TRAP( retval, iAudioSession.OpenL( + iRTPSockArr[ERTPAudioSend1]->Socket(), + KAverageExpectedRtpPacketMaxSize, + iRTPSockArr[ERTPAudioSend2]->Socket(), + EPriorityNormal, KCRCName() ) ); + } + + LOG1( "CCRRtspPacketSource::SetupRTPSessions audio sess open: %d", retval ); + if ( !retval ) + { + SetRtpSession( iAudioSession , iSdpParser->AudioTimerGranularity() ); + iAudioSession.SetBandwidth( iSdpParser->AudioBitrate() * 1000 ); + TRAP( retval, iAudioSession.PrivRegisterEventCallbackL( ERtpNewSource, + ( TRtpCallbackFunction )CCRRtspPacketSource::AudioRTPCallBack, this ) ); + + TReceiveStream audioDataStream; + audioDataStream.iStreamType = EAudioStream; + audioDataStream.iDataReceived = EFalse; + iReceiveStreams.Append( audioDataStream ); + LOG( "CCRRtspPacketSource::SetupRTPSessions - AudioStream found" ); + TReceiveStream audioControlStream; + audioControlStream.iStreamType = EAudioControlStream; + audioControlStream.iDataReceived = EFalse; + LOG( "CCRRtspPacketSource::SetupRTPSessions - AudioControlStream found" ); + iReceiveStreams.Append( audioControlStream ); + + LOG2( "CCRRtspPacketSource::SetupRTPSessions audio stat: %d, ts: %u", + retval, ( TUint )iRTPTimeStampAudio ); + } + else + { + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRConnectionError, retval ); + } + iOwningSession.SourceStop(); + } + } + + // Then video + if ( retval == KErrNone && iRtspSock && iResponses[ERTSPSetupVideoSent] ) + { + if ( iTransport==ERTPOverMulticast ) + { + retval = CreateMulticastSocket( ERTPVideoSend1, + iResponses[ERTSPSetupVideoSent]->Destination(), + iResponses[ERTSPSetupVideoSent]->ClientPort() ); + if ( retval==KErrNone ) + { + retval = CreateMulticastSocket( ERTPVideoSend2, + iResponses[ERTSPSetupVideoSent]->Destination(), + iResponses[ERTSPSetupVideoSent]->ClientPort()+1 ); + } + } + else + { + localAddr.SetPort( iResponses[ERTSPSetupVideoSent]->ClientPort() ); + remoteAddr.SetPort( iResponses[ERTSPSetupVideoSent]->ServerPort() ); + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + TName _addr; + localAddr.Output( _addr ); + LOG2( "localaddr for video is %S:%d", &_addr, localAddr.Port() ); + remoteAddr.Output( _addr ); + LOG2( "remoteAddr for video is %S:%d", &_addr, remoteAddr.Port() ); +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + retval = CreateUnicastSocket( ERTPVideoSend1, localAddr, remoteAddr ); + if ( retval == KErrNone ) + { + localAddr.SetPort( localAddr.Port() + 1 ); + remoteAddr.SetPort( remoteAddr.Port() + 1 ); + retval = CreateUnicastSocket( ERTPVideoSend2, localAddr, remoteAddr ); + } + } + + if ( retval == KErrNone ) + { + TRAP( retval, iVideoSession.OpenL( iRTPSockArr[ERTPVideoSend1]->Socket(), + KAverageExpectedRtpPacketMaxSize, iRTPSockArr[ERTPVideoSend2]->Socket(), + EPriorityNormal, KCRCName() ) ); + } + + LOG1( "CCRRtspPacketSource::SetupRTPSessions video sess open: %d", retval ); + if ( !retval ) + { + SetRtpSession( iVideoSession , iSdpParser->VideoTimerGranularity() ); + iVideoSession.SetBandwidth( iSdpParser->VideoBitrate() * 1000 ); + TRAP( retval, iVideoSession.PrivRegisterEventCallbackL( ERtpNewSource, + ( TRtpCallbackFunction )CCRRtspPacketSource::VideoRTPCallBack, this ) ); + + TReceiveStream videoDataStream; + videoDataStream.iStreamType = EVideoStream; + videoDataStream.iDataReceived = EFalse; + LOG( "CCRRtspPacketSource::SetupRTPSessions - VideoStream found" ); + iReceiveStreams.Append( videoDataStream ); + TReceiveStream videoControlStream; + videoControlStream.iStreamType = EVideoControlStream; + videoControlStream.iDataReceived = EFalse; + LOG( "CCRRtspPacketSource::SetupRTPSessions - VideoControlStream found" ); + iReceiveStreams.Append( videoControlStream ); + + LOG2( "CCRRtspPacketSource::SetupRTPSessions video stat: %d, ts: %u", + retval, ( TUint )iRTPTimeStampVideo ); + } + else + { + if ( iObserver ) + { + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), + ECRConnectionError, retval ); + } + iOwningSession.SourceStop(); + } + } + } + + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::CreateMulticastSocket +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::CreateMulticastSocket( + TCRRTPSockId aSockId, + const TInetAddr& aGroupAddr, + TInt aPort ) + { + // Alias for socket being created + CCRSock*& sock = iRTPSockArr[aSockId]; + + // Delete if already existing + if ( sock ) + { + delete sock; + sock = NULL; + } + + // Create socket + TRAPD( err, sock = CCRSock::NewL( *this, aSockId, iConnection.Connection(), + iSockServer, EFalse, EFalse) ); + if ( err != KErrNone ) + { + LOG2( "CCRRtspPacketSource::CreateMulticastSocket: CCRSock::NewL FAILED, sockId: %d, err: %d", + aSockId, err ); + return err; + } + + // Bind socket to local UDP port, issue no reads -> handled by RRtpSession + err = sock->ListenPort( aPort ); + if ( err != KErrNone ) + { + LOG2( "CCRRtspPacketSource::CreateMulticastSocket: ListenPort FAILED, port: %d, err: %d", + aPort, err ); + return err; + } + + err = sock->JoinGroup( aGroupAddr ); + if ( err != KErrNone ) + { + LOG1( "CCRRtspPacketSource::CreateMulticastSocket: JoinGroup FAILED, err: %d", err ); + return err; + } + +#if defined(LIVE_TV_FILE_TRACE) || defined(LIVE_TV_RDEBUG_TRACE) + TName group; + aGroupAddr.Output( group ); + LOG3( "CCRRtspPacketSource::CreateMulticastSocket: sockid: %d, group: '%S', port: %d OK", + aSockId, &group, aPort ); +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::CreateUnicastSocket +// ----------------------------------------------------------------------------- +TInt CCRRtspPacketSource::CreateUnicastSocket( + TCRRTPSockId aSockId, + const TInetAddr& aLocalAddr, + const TInetAddr& /*aRemoteAddr*/ ) + { + // Alias for socket being created + CCRSock*& sock = iRTPSockArr[aSockId]; + + // Delete if already existing + if ( sock ) + { + delete sock; + sock = NULL; + } + + // Create socket: EFalse=UDP, EFalse=issue no read (handled by RRtpSession) + TRAPD( err, sock = CCRSock::NewL( *this,aSockId, iConnection.Connection(), + iSockServer, EFalse, EFalse ) ); + if ( err != KErrNone ) + { + LOG2( "CCRRtspPacketSource::CreateUnicastSocket: CCRSock::NewL FAILED, sockId: %d, err: %d", + aSockId, err ); + return err; + } + + // Bind to local port, ignore remote address and port + TInt port = aLocalAddr.Port(); + err = sock->ListenPort( port ); + if ( err != KErrNone ) + { + LOG2( "CCRRtspPacketSource::CreateUnicastSocket: ListenPort FAILED, port: %d, err: %d", + port, err ); + return err; + } + +#if defined(LIVE_TV_FILE_TRACE) || defined(LIVE_TV_RDEBUG_TRACE) + LOG2( "CCRRtspPacketSource::CreateUnicastSocket: sockid: %d, port: %d OK", + aSockId, port ); +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::RTPPayloadProcessor +// This is called from audio and video callbacks when real payload packet +// is received from rtp stack. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::RTPPayloadProcessor( + const TRtpEvent& aEvent, + const TBool aIsAudio ) + { + // If udp traffic hasn't been flagged as found + // keep marking streams as found + if ( !iTrafficFound ) + { + if ( aIsAudio ) + { + StreamFound( EAudioStream ); + } + else + { + StreamFound( EVideoStream ); + } + + // Cancel UDP timer, so as not to trigger TCP streaming + if ( CheckReceiveOfStreams() ) + { + // We have traffic from all needed streams, cancel reception timer + // and set UDP flag. + iUdpReceptionTimer->Cancel(); + iUdpFound = ETrue; + iTrafficFound = ETrue; + } + } + + // Here process packet + RRtpReceivePacket p = aEvent.ReceiveSource().Packet(); + TUint32 flag( 0 ); + BigEndian::Put32( ( TUint8* )&flag, p.Flags() ); + + // Header + TCRRtpMessageHeader packetHeader; + memcpy( &packetHeader, &flag, sizeof( flag ) ); + BigEndian::Put32( ( TUint8* )&packetHeader.iTimestamp, p.Timestamp() ); + BigEndian::Put32( ( TUint8* )&packetHeader.iSSRC, p.SSRC() ); + TPtrC8 rtpHeader( ( TUint8* )&packetHeader, sizeof( packetHeader ) ); + + if ( iNoRtpInfoHeader ) + { + ConstructSeqAndTsForSink( + aIsAudio ? MCRPacketSource::EAudioStream : MCRPacketSource::EVideoStream, + 0 /*nop*/, 0 /*nop*/, 0 /*nop*/, p.SequenceNumber() ); + } + + // Stream + MCRPacketSource::TCRPacketStreamId stream( + ( aIsAudio )? MCRPacketSource::EAudioStream : + MCRPacketSource::EVideoStream ); + iBuffer->AddPacket( stream, rtpHeader, p.Payload() ); + + // Count of packets + if ( aIsAudio ) + { + iAudioBytes += p.Payload( ).Length(); + iAudioPackets ++; + } + else + { + iVideoBytes += p.Payload( ).Length(); + iVideoPackets ++; + } + + p.Close(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::AudioRTPCallBack +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::AudioRTPCallBack( + CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent ) + { + switch ( aEvent.Type() ) + { + case ERtpPacketReceived: + static_cast( aPtr )-> + RTPPayloadProcessor( aEvent, ETrue ); + break; + + // RTCP + case ERtpSR: + { + // We have audio control traffic + if ( !aPtr->iTrafficFound ) + { + aPtr->StreamFound( EAudioControlStream ); + if ( aPtr->CheckReceiveOfStreams() ) + { + // Cancel UDP timer, so as not to trigger TCP streaming + aPtr->iUdpReceptionTimer->Cancel(); + aPtr->iUdpFound = ETrue; + aPtr->iTrafficFound = ETrue; + } + } + + // Sender report + SenderReport( aPtr, aEvent, MCRPacketSource::EAudioControlStream ); + } + break; + + case ERtpNewSource: + { + // Handle audio + TRAPD( err, HandleNewSourceL( aPtr, aPtr->iRtpRecvSrcAudio, aEvent, + ( TRtpCallbackFunction )CCRRtspPacketSource::AudioRTPCallBack ) ); + if ( err ) + { + LOG1( "CCRRtspPacketSource::AudioRTPCallBack(), HandleNewSourceL Leaved: %d", err ); + aPtr->iOwningSession.SourceStop(); + } + } + break; + + case ERtpSessionFail: + case ERtpSourceFail: + LOG( "CCRRtspPacketSource::VideoRTPCallBack(), source/session fail" ); + aPtr->iOwningSession.SourceStop(); + if ( aPtr->iObserver ) + { + aPtr->iObserver->ConnectionStatusChange( + aPtr->iOwningSession.SourceChecksum(), + ECRNormalEndOfStream, KErrSessionClosed ); + } + break; + + case ERtpBYE: + LOG( "CCRRtspPacketSource::AudioRTPCallBack(), ERtpBYE" ); + if ( aPtr->iObserver ) + { + aPtr->iObserver->ConnectionStatusChange( + aPtr->iOwningSession.SourceChecksum(), + ECRNormalEndOfStream, KErrNone ); + } + break; + + default: + LOG1( "CCRRtspPacketSource::AudioRTPCallBack default case, type 0x%x", + ( TUint )( aEvent.Type() ) ); + // by do nothing + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::VideoRTPCallBack +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::VideoRTPCallBack( + CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent ) + { + switch ( aEvent.Type() ) + { + case ERtpPacketReceived: + static_cast( aPtr )-> + RTPPayloadProcessor( aEvent, EFalse ); + break; + + // RTCP + case ERtpSR: + { + // We have video control traffic + if ( !aPtr->iTrafficFound ) + { + aPtr->StreamFound( EVideoControlStream ); + if ( aPtr->CheckReceiveOfStreams() ) + { + // Cancel UDP timer, so as not to trigger TCP streaming + aPtr->iUdpReceptionTimer->Cancel(); + aPtr->iUdpFound = ETrue; + aPtr->iTrafficFound = ETrue; + } + } + + // Sender report + SenderReport( aPtr, aEvent, MCRPacketSource::EVideoControlStream ); + } + break; + + case ERtpNewSource: + { + // Handle video + TRAPD( err, HandleNewSourceL( aPtr, aPtr->iRtpRecvSrcVideo, aEvent, + ( TRtpCallbackFunction )CCRRtspPacketSource::VideoRTPCallBack ) ); + if ( err ) + { + LOG1( "CCRRtspPacketSource::VideoRTPCallBack(), HandleNewSourceL Leaved: %d", err ); + aPtr->iOwningSession.SourceStop(); + } + } + break; + + case ERtpSessionFail: + case ERtpSourceFail: + LOG( "CCRRtspPacketSource::VideoRTPCallBack(), Source/session fail" ); + aPtr->iOwningSession.SourceStop(); + if ( aPtr->iObserver ) + { + aPtr->iObserver->ConnectionStatusChange( + aPtr->iOwningSession.SourceChecksum(), + ECRNormalEndOfStream, KErrSessionClosed ); + } + break; + + case ERtpBYE: + LOG( "CCRRtspPacketSource::VideoRTPCallBack(), ERtpBYE" ); + if ( aPtr->iObserver ) + { + aPtr->iObserver->ConnectionStatusChange( + aPtr->iOwningSession.SourceChecksum(), + ECRNormalEndOfStream, KErrNone ); + } + break; + + default: + LOG1( "CCRRtspPacketSource::VideoRTPCallBack default case, type 0x%x", + ( TUint )( aEvent.Type() ) ); + // By do nothing + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SenderReport +// rfc-1305: +// NTP timestamps are represented as a 64-bit unsigned fixed- +// point number, in seconds relative to 0h on 1 January 1900. +// The integer part is in the first 32 bits and the fraction +// part in the last 32 bits. +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SenderReport( + CCRRtspPacketSource* aPtr, + const TRtpEvent& aEvent, + MCRPacketSource::TCRPacketStreamId aStreamId ) + { + TCRRtpSRReportHeader srReport; + srReport.iVersion = KRtpPacketVersion; // value is 2 + srReport.iPadding = 0; + srReport.iReportCount = 0; + srReport.iPacketType = KSenderReportPacketType; + RRtpReceiveSource source( aEvent.ReceiveSource() ); + BigEndian::Put16( ( TUint8* )&srReport.iLength, 6 ); + BigEndian::Put32( ( TUint8* )&srReport.iSenderSSRC, + source.SSRC() ); + BigEndian::Put32( ( TUint8* )&srReport.iMSWTimestamp, + source.GetSR().iSrPtr.ntp_sec ); + BigEndian::Put32( ( TUint8* )&srReport.iLSWTimestamp, + source.GetSR().iSrPtr.ntp_frac ); + BigEndian::Put32( ( TUint8* )&srReport.iRTPTimestamp, + source.GetSR().RTPTimestamp() ); + BigEndian::Put32( ( TUint8* )&srReport.iSenderPacketCount, + aPtr->iAudioPackets ); + BigEndian::Put32( ( TUint8* )&srReport.iSenderOctetCount, + aPtr->iAudioBytes ); + TPtrC8 rtcpHeader( ( TUint8* )&srReport, sizeof( srReport ) ); + aPtr->iBuffer->AddPacket( aStreamId, rtcpHeader ); + + // Verify Seq and Ts + if ( aPtr->iNoRtpInfoHeader ) + { + aPtr->ConstructSeqAndTsForSink ( + aStreamId, + source.GetSR().iSrPtr.ntp_sec, + source.GetSR().iSrPtr.ntp_frac, + source.GetSR().RTPTimestamp(), + 0 ); // 0 not used + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::HandleNewSourceL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::HandleNewSourceL( + CCRRtspPacketSource* aPtr, + RRtpReceiveSource& aSource, + const TRtpEvent& aEvent, + TRtpCallbackFunction aCallback ) + { + // Cancel UDP timer, so as not to trigger TCP streaming + aPtr->iUdpReceptionTimer->Cancel(); + delete aPtr->iPunchPacketSenderAudio; + aPtr->iPunchPacketSenderAudio = NULL; + if ( aSource.IsOpen() ) + { + aSource.Close(); + } + + // Source + aSource = aEvent.Session().NewReceiveSourceL(); + aSource.PrivRegisterEventCallbackL( ERtpPacketReceived, aCallback, aPtr ); + aSource.PrivRegisterEventCallbackL( ERtpSR, aCallback, aPtr ); + aSource.PrivRegisterEventCallbackL( ERtpBYE, aCallback, aPtr ); + aSource.PrivRegisterEventCallbackL( ERtpSessionFail, aCallback, aPtr ); + aSource.PrivRegisterEventCallbackL( ERtpSourceFail, aCallback, aPtr ); + + // Ping Timer + if ( !aPtr->iRtspPingTimer ) + { + aPtr->iRtspPingTimer = CPeriodic::NewL( CActive::EPriorityLow ); + aPtr->iRtspPingTimer->Start( + KDVR10Seconds, 2 * KDVR10Seconds, TCallBack( SendRtspPing, aPtr ) ); + } + + aEvent.Session().SendAPPL( KCRCName() ); + aEvent.Session().SetRTCPAutoSend( ETrue ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendAuthDescribeL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendAuthDescribeL( ) + { + delete iPrevCommands[ERTSPDescSent]; + iPrevCommands[ERTSPDescSent] = NULL; + iPrevCommands[ERTSPDescSent] = CCRRtspCommand::NewL(); + iPrevCommands[ERTSPDescSent]->SetCommand ( + CCRRtspCommand::ERTSPCommandDESCRIBE ); + TPtrC8 uriDes ( iRtspUri8->Des() ); + iPrevCommands[ERTSPDescSent]->SetURL ( uriDes ); + iPrevCommands[ERTSPDescSent]->SetCSeq ( iCSeq ++ ); + + if ( iAuthType ) + { + iPrevCommands[ERTSPDescSent]->SetAuthenticationTypeL( iAuthType->Des() ); + } + if ( iNonce ) + { + iPrevCommands[ERTSPDescSent]->SetNonceL( iNonce->Des() ); + } + if ( iRealm ) + { + iPrevCommands[ERTSPDescSent]->SetRealmL( iRealm->Des() ); + } + if ( iOpaque ) + { + iPrevCommands[ERTSPDescSent]->SetOpaqueL( iOpaque->Des() ); + } + if ( iUserAgent ) + { + iPrevCommands[ERTSPDescSent]->SetUserAgentL( *iUserAgent ); + } + if ( iWapProfile ) + { + iPrevCommands[ERTSPDescSent]->SetWapProfileL( *iWapProfile ); + } + if ( iBandwidth ) + { + iPrevCommands[ERTSPDescSent]->SetBandwidth( iBandwidth ); + } + + iPrevCommands[ERTSPDescSent]->SetUserNameL( iUserName->Des() ); + iPrevCommands[ERTSPDescSent]->SetPassWdL( iPassword->Des() ); + iPrevCommands[ERTSPDescSent]->SetRtspUriL( iRtspUri->Des() ); + iPrevCommands[ERTSPDescSent]->SetAuthentication ( iAuthenticationNeeded ); + if ( iRtspSock ) + { + iRtspSock->SendData( iPrevCommands[ERTSPDescSent]->ProduceL() ); + StartRtspTimeout( KCRRtspResponseTimeout ); + } + iStage = ERTSPDescSent; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::AddAuthenticationL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::AddAuthenticationL( TInt aCommand ) + { + if ( iPrevCommands[aCommand] && iNonce && + iOpaque && iUserName && iPassword ) + { + iPrevCommands[aCommand]->SetAuthenticationTypeL( iAuthType->Des() ); + iPrevCommands[aCommand]->SetNonceL( iNonce->Des() ); + iPrevCommands[aCommand]->SetRealmL( iRealm->Des() ); + iPrevCommands[aCommand]->SetOpaqueL( iOpaque->Des() ); + iPrevCommands[aCommand]->SetUserNameL( iUserName->Des() ); + iPrevCommands[aCommand]->SetPassWdL( iPassword->Des() ); + iPrevCommands[aCommand]->SetRtspUriL( iRtspUri->Des() ); + iPrevCommands[aCommand]->SetAuthentication ( iAuthenticationNeeded ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::PunchPacketsSent +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::PunchPacketsSent( CCRPunchPacketSender* aPuncher ) + { + if ( iPunchPacketSenderVideo && aPuncher == iPunchPacketSenderVideo ) + { + iPunchPacketSentForVideo = ETrue; + } + if ( iPunchPacketSenderAudio && aPuncher == iPunchPacketSenderAudio ) + { + iPunchPacketSentForAudio = ETrue; + } + if ( ( iPunchPacketSenderVideo && !iPunchPacketSenderAudio && + iPunchPacketSentForVideo ) || + ( !iPunchPacketSenderVideo && iPunchPacketSenderAudio && + iPunchPacketSentForAudio ) || + ( iPunchPacketSenderVideo && iPunchPacketSenderAudio && + iPunchPacketSentForVideo && iPunchPacketSentForAudio ) ) + { + LOG1( "PunchPacketsSent, play readiness: %d", iReadyToPlay ); + SetupSessionsAndPlay(); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SetupSessionsAndPlay +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SetupSessionsAndPlay() + { + // all needed punch packets are sent: + if ( SetupRTPSessions() != KErrNone ) + { + iOwningSession.SourceStop(); + } + else + { + // if we're ready to play, play + if ( iReadyToPlay ) + { + TRAPD( err, SendPlayCommandL() ); + if ( err != KErrNone ) + { + iOwningSession.SourceStop(); + } + } + else + { + iStage = ERTSPReadyToPlay; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendPunchPackets +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SendPunchPacketsL( void ) + { + LOG( "CCRRtspPacketSource::SendPunchPacketsL in" ); + delete iPunchPacketSenderAudio; + iPunchPacketSenderAudio = NULL; + delete iPunchPacketSenderVideo; + iPunchPacketSenderVideo = NULL; + + if ( iSdpParser &&iRtspSock && iResponses[ERTSPSetupVideoSent] ) + { + TInetAddr localAddr = iRtspSock->LocalAddr(); + TInetAddr remoteAddr = iRtspSock->ConnectedAddr(); + localAddr.SetPort(iResponses[ERTSPSetupVideoSent]->ClientPort()); + remoteAddr.SetPort(iResponses[ERTSPSetupVideoSent]->ServerPort()); + iPunchPacketSenderVideo = CCRPunchPacketSender::NewL( + iConnection.Connection(), iSockServer, + localAddr, remoteAddr, 0, *this ); + } + if ( iSdpParser && iRtspSock && iResponses[ERTSPSetupAudioSent] ) + { + TInetAddr localAddr = iRtspSock->LocalAddr(); + TInetAddr remoteAddr = iRtspSock->ConnectedAddr(); + localAddr.SetPort(iResponses[ERTSPSetupAudioSent]->ClientPort()); + remoteAddr.SetPort(iResponses[ERTSPSetupAudioSent]->ServerPort()); + iPunchPacketSenderAudio = CCRPunchPacketSender::NewL( + iConnection.Connection(), iSockServer, + localAddr, remoteAddr, 0, *this ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ConnectionStatusChange +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ConnectionStatusChange( + TInt /*aSessionId*/, + TCRConnectionStatus aStatus, + TInt /* aErr */ ) + { + switch( aStatus ) + { + // Connection has gone up or bearer has changed -> check bandwidth + case ECRBearerChanged: + { + LOG( "CCRRtspPacketSource::ConnectionStatusChange: IapUp or IapUp2G" ); + if ( iSdpParser && iObserver ) + { + // Unknown bitrate or bandwidth are returned as zero. Bitrates in kbit/s + TInt bitrate( iSdpParser->VideoBitrate() + + iSdpParser->AudioBitrate() ); + TInt bandwidth( iConnection.MaximumBandwidth() / 1000 ); + if ( bitrate > 0 && bandwidth > 0 && bandwidth < bitrate ) + { + LOG2( "CCRRtspPacketSource::ConnectionStatusChange: clip_bitrate: %d, connection_bandwidth: %d -> NotEnoughBandwidth", + bitrate, bandwidth ); + iObserver->ConnectionStatusChange( + iOwningSession.SourceChecksum(), ECRNotEnoughBandwidth, KErrNone ); + } + } + break; + } + + // Connection has gone down or error occured -> switch back to RTP/UDP transport + case ECRConnectionError: + case ECRIapDown: + { + LOG( "CCRRtspPacketSource::ConnectionStatusChange: IapDown or ConnectionError -> switch to RTP/UDP streaming" ); + iConnection.SetHeuristic( CCRConnection::EUdpStreamingBlocked, EFalse ); + break; + } + + // Nothing to do for: + // ECRConnecting + // ECRAuthenticationNeeded + // ECRNotEnoughBandwidth + // ECRNormalEndOfStream + default: + { + LOG1( "CCRRtspPacketSource::ConnectionStatusChange: unhandled status: %d", aStatus ); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::RegisterConnectionObs +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::RegisterConnectionObs( MCRConnectionObserver* aObserver ) + { + iObserver = aObserver; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::UnregisterConnectionObs +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::UnregisterConnectionObs( ) + { + iObserver = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SetRtpSession +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::SetRtpSession( + RRtpSession& aSession, + TReal aGranularity ) + { + // Unit is 1/second + __ASSERT_DEBUG( iSdpParser != NULL, User::Panic( _L( "RTSP source" ), KErrBadHandle ) ); + TUint32 howManyNanoSecondsIsOneTick( + ( TUint32 )( TReal( 1000000000.0L ) / aGranularity ) ); + LOG1( "CCRRtspPacketSource::SetRtpSession clock tick: %u", howManyNanoSecondsIsOneTick ); + aSession.SetRTPTimeConversion( 0, howManyNanoSecondsIsOneTick ); + aSession.SetRtpStreamParameters( KDVRMinSequential, // 1 + KDVRMaxMisorder, // 50 + KDVRMaxDropOut ); // 3000 + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::SendRtspPing +// ----------------------------------------------------------------------------- +// +TInt CCRRtspPacketSource::SendRtspPing( TAny* aSelfPtr ) + { + CCRRtspPacketSource* ptr = static_cast ( aSelfPtr ); + TRAPD( err, ptr->SendOptionsCommandL() ); + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ConstructSeqAndTsForSink +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ConstructSeqAndTsForSink ( + MCRPacketSource::TCRPacketStreamId aStreamId, + TUint32 aMSWTimestamp, + TUint32 aLSWTimestamp, + TUint32 aRTPTimestamp, + TUint aSeq ) + { + switch ( aStreamId ) + { + case EAudioStream: + if ( iRTPTimeStampAudio ) + { + iSeqFromRtpInfoForAudio = aSeq; + if ( iSeqFromRtpInfoForAudio == 0 ) + { + iSeqFromRtpInfoForAudio++; + } + LOG1( "CCRRtspPacketSource::ConstructSeqAndTsForSink(), Audio seq: %d ", ( int )aSeq ); + // We may declare that we have seq+ts if we're here and have only audio or + // if we're here and have both audio and video and have also seq for video + if ( ( iSdpParser->SupportedContent() == CDvrSdpParser::EDvrAudioOnly ) || + ( iSdpParser->SupportedContent() == CDvrSdpParser::EDvrBothAudioAndVideo && + iSeqFromRtpInfoForVideo && iRTPTimeStampVideo ) ) + { + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStateSeqAndTSAvailable ); + iNoRtpInfoHeader = EFalse; + if ( iStage == ERTSPPlaying ) + { + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStatePlaying ); + } + } + } + break; + + case EAudioControlStream: + if ( !iMSWTimestamp ) + { // no wall clock time yet set + iMSWTimestamp = aMSWTimestamp; + iLSWTimestamp = aLSWTimestamp; + iRTPTimeStampAudio = aRTPTimestamp; + if ( iRTPTimeStampAudio == 0 ) + { + iRTPTimeStampAudio++; + } + } + else + { + // Sync audio with video + TInt64 wallClockOfVideo = MAKE_TINT64 ( iMSWTimestamp , iLSWTimestamp ); + TInt64 wallClockOfAudio = MAKE_TINT64 ( aMSWTimestamp , aLSWTimestamp ); + // Then figure out the difference. unit is now difficult ; upper + // 32 bits contain whole seconds, lower contains fraction + TInt64 wallClockDifference( wallClockOfVideo - wallClockOfAudio ); + // Now, the aRTPTimestamp has different scale, declared in SDP. + // first make one second that has same scale as wallClockDifference + TInt64 granularity( MAKE_TINT64( 1, 0 ) ); + // Then divide that one second with the given granularity. variable + // granularity will now contain in its low 32 bits the fraction of the + // second that re-presents one clock tick (e.g. 1/90000 sec for video) + granularity = granularity / static_cast( + iSdpParser->AudioTimerGranularity() ); + // Then divide our difference with this fraction of second + TInt64 wallClockDifferenceGranular = wallClockDifference / granularity; + // unit of wallClockDifferenceGranular is now 2^32 / granularity + TInt32 wallClockDifferenceGranular32 = wallClockDifferenceGranular; + LOG2( "CCRRtspPacketSource::ConstructSeqAndTsForSink(), Audio ts: %u adjust by: %d", + aRTPTimestamp , wallClockDifferenceGranular32 ); + iRTPTimeStampAudio = aRTPTimestamp + wallClockDifferenceGranular32; + if ( iRTPTimeStampAudio == 0 ) + { + iRTPTimeStampAudio++; + } + } + break; + + case EVideoStream: + if ( iRTPTimeStampVideo ) + { + iSeqFromRtpInfoForVideo = aSeq; + if ( iSeqFromRtpInfoForVideo == 0 ) + { + iSeqFromRtpInfoForVideo++; + } + LOG1( "CCRRtspPacketSource::ConstructSeqAndTsForSink(), Video seq: %d ", + ( int )aSeq ); + + // We may declare that we have seq+ts if we're here and have only video or + // if we're here and have both and have also seq for video + if ( ( iSdpParser->SupportedContent() == CDvrSdpParser::EDvrVideoOnly ) || + ( iSdpParser->SupportedContent() == CDvrSdpParser::EDvrBothAudioAndVideo && + iSeqFromRtpInfoForAudio && iRTPTimeStampAudio ) ) + { + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStateSeqAndTSAvailable ); + iNoRtpInfoHeader = EFalse; + if ( iStage == ERTSPPlaying ) + { + iSessionObs.StatusChanged( + MCRPacketSource::ERtpStatePlaying ); + } + } + } + break; + + case EVideoControlStream: + if ( !iMSWTimestamp ) + { // No wall clock time yet set + iMSWTimestamp = aMSWTimestamp; + iLSWTimestamp = aLSWTimestamp; + iRTPTimeStampVideo = aRTPTimestamp; + if ( iRTPTimeStampVideo == 0 ) + { + iRTPTimeStampVideo++; + } + } + else + { + // Sync audio with video + TInt64 wallClockOfAudio = MAKE_TINT64 ( iMSWTimestamp , iLSWTimestamp ); + TInt64 wallClockOfVideo = MAKE_TINT64 ( aMSWTimestamp , aLSWTimestamp ); + // Then figure out the difference. unit is now difficult ; upper + // 32 bits contain whole seconds, lower contains fraction + TInt64 wallClockDifference( wallClockOfAudio - wallClockOfVideo ); + // Now, the aRTPTimestamp has different scale, declared in SDP. + // first make one second that has same scale as wallClockDifference + TInt64 granularity( MAKE_TINT64( 1, 0 ) ); + // Then divide that one second with the given granularity. variable + // granularity will now contain in its low 32 bits the fraction of the + // second that re-presents one clock tick (e.g. 1/90000 sec for video) + granularity = granularity / static_cast( + iSdpParser->VideoTimerGranularity()); + // Then divide our difference with this fraction of second + TInt64 wallClockDifferenceGranular = wallClockDifference / granularity; + // Unit of wallClockDifferenceGranular is now 2^32 / granularity + TInt32 wallClockDifferenceGranular32 = wallClockDifferenceGranular; + LOG2( "CCRRtspPacketSource::ConstructSeqAndTsForSink(), Video ts: %u adjust by: %d", + aRTPTimestamp , wallClockDifferenceGranular32 ); + iRTPTimeStampVideo = aRTPTimestamp + wallClockDifferenceGranular32; + if ( iRTPTimeStampVideo == 0 ) + { + iRTPTimeStampVideo++; + } + } + break; + + default: + // no thing + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ConditionallySetupMultiCastOrTcpStreamingL +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ConditionallySetupMultiCastOrTcpStreamingL ( void ) + { + // UDP: Punch packets or play sent in ProcessRTSPResponseL, so do nothing. + if ( iTransport == ERTPOverUDP ) + { + } + // Multicast: no punch packets needed but session setup yes + else if ( iTransport == ERTPOverMulticast ) + { + SetupSessionsAndPlay(); + } + + // TCP: no punch packets or session, just send PLAY .. but wait for UI + else if ( iTransport == ERTPOverTCP ) + { + if ( iReadyToPlay ) + { + SendPlayCommandL(); + } + else + { + iStage = ERTSPReadyToPlay; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::CheckReceiveOfStreams +// ----------------------------------------------------------------------------- +// +TBool CCRRtspPacketSource::CheckReceiveOfStreams() + { + TBool retVal( ETrue ); + + // Go through all streams and check that all streams have receive flag on, + // if not return false. + for ( TInt i = 0 ; i < iReceiveStreams.Count() ; i++ ) + { + if ( iReceiveStreams[i].iDataReceived == EFalse ) + { + LOG1( "CCRRtspPacketSource::CheckReceiveOfStreams - Missing atleast stream %d", iReceiveStreams[i].iStreamType ); + retVal = EFalse; + break; + } + } + + if ( retVal ) + { + LOG( "CCRRtspPacketSource::CheckReceiveOfStreams - Receiving from all streams!" ); + } + + return retVal; + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::StreamFound +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::StreamFound( TCRPacketStreamId aStreamType ) + { + // Go through streams and find correct stream to set the receive flag. + for ( TInt i = 0 ; i < iReceiveStreams.Count(); i++ ) + { + if ( iReceiveStreams[i].iStreamType == aStreamType ) + { + iReceiveStreams[i].iDataReceived = ETrue; + LOG1( "CCRRtspPacketSource::StreamFound - Stream %d found", iReceiveStreams[i].iStreamType ); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ResetStreamFlags +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ResetStreamFlags( ) + { + // Go through streams and clear receiving flag. + for ( TInt i = 0 ; i < iReceiveStreams.Count() ; i++ ) + { + iReceiveStreams[i].iDataReceived = EFalse; + } + + // We have to check receive again + iTrafficFound = EFalse; + } + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) +// ----------------------------------------------------------------------------- +// CCRRtspPacketSource::ShowHeader +// ----------------------------------------------------------------------------- +// +void CCRRtspPacketSource::ShowHeader( + const TDesC8& aRtcpHeader, + const TCRRtpSRReportHeader& aSrReport ) + { + TBuf<100> b( KNullDesC ); + LOG1( "CCRRtspPacketSource::TCP control packet len: %d", aRtcpHeader.Length() ); + for ( TInt j( 0 ); j < 32 && j < aRtcpHeader.Length(); j++ ) + { + b.AppendFormat( _L( "%2X " ), ( unsigned )( aRtcpHeader[j] ) ); + if ( j > 0 && ( ( j % 16 ) == 0 ) ) + { + LOG2( "%d -> %S", j, &b ); + b.Zero(); + } + } + + LOG1( "iVersion %u", ( unsigned )aSrReport.iVersion ); + LOG1( "iPadding %u", ( unsigned )aSrReport.iPadding ); + LOG1( "iReportCount %u",( unsigned )aSrReport.iReportCount ); + LOG1( "iPacketType %u", ( unsigned )aSrReport.iPacketType ); + LOG1( "iLength %u", + ( unsigned)BigEndian::Get16( ( const TUint8* )&aSrReport.iLength ) ); + LOG1( "iSenderSSRC %u", + ( unsigned )BigEndian::Get32( ( const TUint8* )&aSrReport.iSenderSSRC ) ); + LOG1( "iMSWTimestamp %u", + ( unsigned )BigEndian::Get32( ( const TUint8* )&aSrReport.iMSWTimestamp) ); + LOG1( "iLSWTimestamp %u", + ( unsigned)BigEndian::Get32( ( const TUint8* )&aSrReport.iLSWTimestamp ) ); + LOG1( "iRTPTimestamp %u", + ( unsigned )BigEndian::Get32( ( const TUint8* )&aSrReport.iRTPTimestamp ) ); + LOG1( "iSenderPacketCount %u", + ( unsigned )BigEndian::Get32( ( const TUint8* )&aSrReport.iSenderPacketCount) ); + LOG1( "iSenderOctetCount %u", + ( unsigned )BigEndian::Get32( ( const TUint8* )&aSrReport.iSenderOctetCount ) ); + + } +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRTSPResponse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRTSPResponse.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,510 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTSP response parser and producer* +*/ + + + + +// INCLUDE FILES +#include "CCRRtspResponse.h" +#include "CRRTSPCommon.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KDVRMinRTSPResponseLen( 14 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::CCRRtspResponse +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtspResponse::CCRRtspResponse() + : iStatusCode( ERTSPRespContinue ), + iServerPort( KErrNotFound ), + iSSRC( NULL, 0 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtspResponse* CCRRtspResponse::NewL() + { + CCRRtspResponse* self = new( ELeave ) CCRRtspResponse(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::~CCRRtspResponse +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtspResponse::~CCRRtspResponse() + { + LOG( "CCRRtspResponse::~CCRRtspResponse" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::TryParseL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::TryParseL( const TDesC8 &aString ) + { + if ( aString.Length() < KDVRMinRTSPResponseLen ) + { + LOG( "CCRRtspResponse::TryParseL(), Length less than minimum, Leaved: KErrUnderflow" ); + User::Leave( KErrUnderflow ); + } + + // Copy the stuff into local variable: + delete iRtspText; iRtspText = NULL; + iRtspText = aString.AllocL(); + + const TInt KReplyHeaderOffset( KCRRTSPReplyHeader().Length() ); + const TInt KStatusNumberLen( 5 ); + + // Try to find out if end of the command has been received + // "RTSP/1.0 XXX\r\n\r\n" at least.. + TInt replyEndOffSet = aString.FindC( KCR2NewLines() ); + if ( replyEndOffSet == KErrNotFound ) + { + // Need to have more, do nothing yet.. except that some servers + // do not append 2 newlines to 404 or other error responses: + if ( !aString.Left( KReplyHeaderOffset ).CompareC( KCRRTSPReplyHeader() ) ) + { + TPtrC8 statusNumberString( + aString.Mid( KReplyHeaderOffset, KStatusNumberLen ) ); + TLex8 statusNumberLex( statusNumberString ); + TInt statusCodeInteger( KErrNotFound ); + User::LeaveIfError ( statusNumberLex.Val( statusCodeInteger ) ) ; + iStatusCode = static_cast( statusCodeInteger ); + if ( iStatusCode != ERTSPRespOK && + iStatusCode != ERTSPRespCreated && + iStatusCode != ERTSPRespProxyAuthenticationRequired && + iStatusCode != ERTSPRespUnauthorized ) + { + // Was something else than ok or unauthorized-401 + FindCSeqL(); + LOG1( "CCRRtspResponse::TryParseL() out, with rtsp error code: %d", iStatusCode ); + return; + } + } + + LOG( "CCRRtspResponse::TryParseL() out, because response not complete" ); + User::Leave( KErrUnderflow ); + } + + LOG1( "CCRRtspResponse::TryParseL(), replyEndOffSet: %d", replyEndOffSet ); + + // Find status code: + if ( iRtspText->Left( KReplyHeaderOffset ).CompareC( KCRRTSPReplyHeader() ) == 0 ) + { + TPtrC8 statusNumberString( iRtspText->Mid( + KReplyHeaderOffset, KStatusNumberLen ) ); + TLex8 statusNumberLex( statusNumberString ); + TInt statusCodeInteger( KErrNotFound ); + User::LeaveIfError ( statusNumberLex.Val( statusCodeInteger ) ); + iStatusCode = ( TResponseCode )( statusCodeInteger ); + } + else + { + LOG( "CCRRtspResponse::TryParseL(), Statuscode integer not found !" ); + User::Leave( KErrNotSupported ); + } + + LOG1( "CCRRtspResponse::TryParseL(), iStatusCode: %d", iStatusCode ); + + FindContentL(); + // Then find CSeq + FindCSeqL(); + // Then find session id + FindSessionIdL(); + // Then find server ports + FindServerPorts(); + // Then find SSRC + FindSSRC(); + // Then try finding rtp-info header if it was play reply + FindRTPInfoHeader(); + // Find possible transport method + // IMPORTANT: should be done before parsing client port + FindTransport(); + // Find possible client port + FindClientPorts(); + if ( iServerPort == KErrNotFound && iClientPort != KErrNotFound ) + { + LOG( "CCRRtspResponse::TryParseL(), using client port as server port -> UGLY!!" ); + iServerPort = iClientPort ; + } + // Find destination address is existing + FindDestination(); + // Try finding authentication + FindRTPAuthenticationL(); + // Try to find range header + ParseRange(); + // Try to find session-base header + FindContentBase(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::StatusCode +// +// ----------------------------------------------------------------------------- +// +CCRRtspResponse::TResponseCode CCRRtspResponse::StatusCode( void ) + { + return iStatusCode; + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::FindServerPorts +// +// method that finds server port numeric value +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::FindServerPorts( void ) + { + iServerPort = KErrNotFound; + TInt portNumberOffset( iRtspText->FindC( KCRServerPort ) ); + if ( portNumberOffset != KErrNotFound ) + { + const TInt KDVRPortNumberMaxLen ( 5 ) ; + TPtrC8 portNumberStr( iRtspText->Mid( + portNumberOffset + KCRServerPort().Length() + 1, KDVRPortNumberMaxLen ) ); + TLex8 portNumberLex( portNumberStr ); + if ( portNumberLex.Val( iServerPort ) != KErrNone ) + { // something wrong? + LOG( "CCRRtspResponse::FindServerPorts(), portNumberLex.Val() != KErrNone" ); + iServerPort = KErrNotFound; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::ServerPort +// +// method that returns server port numeric value +// ----------------------------------------------------------------------------- +// +TInt CCRRtspResponse::ServerPort( void ) + { + return iServerPort; + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::FindSSRC +// +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::FindSSRC( void ) + { + LOG( "CCRRtspResponse::FindSSRC() in" ); + TInt SSRCOffset( KErrNotFound ); + iSSRC.Set( NULL, 0 ); + + if ( ( SSRCOffset = iRtspText->FindC( KCRSSRC ) ) != KErrNotFound ) + { + TPtrC8 SSRCStr( iRtspText->Right( + ( iRtspText->Length() - SSRCOffset ) - 6 ) ); + TInt SSRCLen( 0 ); + for ( TInt i( 0 ); i < SSRCStr.Length(); i++ ) + { + if ( TChar( SSRCStr[i] ).IsAlphaDigit() ) + { + SSRCLen++; + } + else + { + iSSRC.Set( SSRCStr.Mid( 0, SSRCLen ) ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::SSRC +// +// method that returns SSRC string +// ----------------------------------------------------------------------------- +// +TInt CCRRtspResponse::SSRC( TPtrC8& aSSRC ) + { + if ( iSSRC.Ptr() != NULL ) + { + aSSRC.Set( iSSRC ); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::FindRTPInfoHeader +// +// method that partially parses rtp info header +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::FindRTPInfoHeader( void ) + { + TInt offset = iRtspText->FindC( KCRRtpInfo ); // "Rtp-Info: " + TInt url2OffSet( KErrNotFound ); + + iRTPInfoHeader.iFirstURL.Set( NULL , 0 ); + iRTPInfoHeader.iFirstSeq = 0; + iRTPInfoHeader.iFirstTS = 0; + iRTPInfoHeader.iSecondURL.Set( NULL, 0 ); + iRTPInfoHeader.iSecondSeq = 0; + iRTPInfoHeader.iSecondTS = 0; + + if ( offset > 0 ) + { + // Yes, there is header. That seems to be sucky to parse. We have delimiting + // characters ,; and nl and we may or may not find words url, seq and rtptime + // and maybe something else. We may be confident that there will be at max + // 2 url srings + offset += KCRRtpInfo().Length(); // add the len of "RTP-Info: " + TPtrC8 rtpInfoContent = iRtspText->Right( iRtspText->Length() - offset ); + TInt urlOffSet = rtpInfoContent.FindC( KCRUrlStr ); + + for ( TInt i( 0 ); urlOffSet != KErrNotFound && i < 2; i ++ ) + { + // At least one url string found + TPtrC8 urlContent( iRtspText->Right( iRtspText->Length() - + ( offset + urlOffSet + 4 ) ) ); + // Above string now contains rest of the PLAY commands RTSP OK response + // so in practice there is 2 url-strings. If so, find the next one + // and cut our string + if ( ( url2OffSet = urlContent.FindC( KCRUrlStr ) ) > 0 ) + { + urlContent.Set( urlContent.Left( url2OffSet ) ); + } + + // Ok, now there is only one url string in urlContent. + // then just find seq and ts + TInt seqOffSet = urlContent.FindC( KCRSeqStr ); + if ( seqOffSet != KErrNotFound ) + { + TPtrC8 seqContent( urlContent.Right( urlContent.Length() - + ( seqOffSet + KCRSeqStr().Length() ) ) ); + TLex8 seqLex( seqContent ); + if ( seqLex.Val( ( iRTPInfoHeader.iFirstURL.Length() == 0 )? + iRTPInfoHeader.iFirstSeq : iRTPInfoHeader.iSecondSeq, + EDecimal ) == KErrNone ) + { + TInt tsOffSet( urlContent.FindC( KCRRtptimeStr ) ); + if ( tsOffSet != KErrNotFound ) + { + TPtrC8 tsContent( urlContent.Right( urlContent.Length() - + ( tsOffSet + KCRRtptimeStr().Length() ) ) ); + TLex8 tsLex( tsContent ); + tsLex.Val( ( iRTPInfoHeader.iFirstURL.Length() == 0 )? + iRTPInfoHeader.iFirstTS: + iRTPInfoHeader.iSecondTS, EDecimal ); + } + } + else + { + urlContent.Set ( NULL , 0 ) ; + } + } + else + { + urlContent.Set ( NULL , 0 ) ; + } + + if ( urlContent.Length() > 0 ) + { + TInt semicolonOffSet( urlContent.Locate(';') ); + const TInt KDVRMinSemicolonOffset ( 5 ) ; + if ( iRTPInfoHeader.iFirstURL.Length() == 0 && semicolonOffSet > KDVRMinSemicolonOffset ) + { + iRTPInfoHeader.iFirstURL.Set( + urlContent.Mid( 0, semicolonOffSet ) ); + } + else + { + const TInt KDVRURLBeginOffset ( 4 ) ; + iRTPInfoHeader.iSecondURL.Set( + urlContent.Mid( KDVRURLBeginOffset, + semicolonOffSet - KDVRURLBeginOffset ) ); + } + } + + // Then continue with next url + urlOffSet = url2OffSet; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::RTPInfoHeader +// +// method that returns rtp-info header content +// ----------------------------------------------------------------------------- +// +TInt CCRRtspResponse::RTPInfoHeader( + CCRRtspResponse::SRTPInfoHeader &aRTPInfoHeader ) + { + if ( iRTPInfoHeader.iFirstURL.Length() == 0 ) + { + return KErrNotFound; + } + else + { + aRTPInfoHeader.iFirstURL.Set( iRTPInfoHeader.iFirstURL ); + aRTPInfoHeader.iFirstSeq = iRTPInfoHeader.iFirstSeq; + aRTPInfoHeader.iFirstTS = iRTPInfoHeader.iFirstTS; + aRTPInfoHeader.iSecondURL.Set( iRTPInfoHeader.iSecondURL ); + aRTPInfoHeader.iSecondSeq = iRTPInfoHeader.iSecondSeq; + aRTPInfoHeader.iSecondTS = iRTPInfoHeader.iSecondTS; + + return KErrNone; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspResponse::FindRTPAuthenticationL +// +// method that partially parses rtp authentication header +// ----------------------------------------------------------------------------- +// +void CCRRtspResponse::FindRTPAuthenticationL( void ) + { + TInt endPos( KErrNotFound ); + + // First look for authorization method(basic / digest) + TInt pos = iRtspText->FindC( KCRAuthDigest ); + + // digest + if ( pos != KErrNotFound ) + { + // Digest found, we can continue + LOG( "CCRRtspResponse::FindRTPAuthenticationL() Digest found" ); + + delete iAuthType; + iAuthType = NULL; + iAuthType = HBufC8::NewL( KCRAuthDigest().Length() ); + iAuthType->Des().Copy( KCRAuthDigest ); + + // find "realm" + pos = iRtspText->FindC( KCRAuthRealm ); + if ( pos != KErrNotFound ) + { + LOG( "CCRRtspResponse::FindRTPAuthenticationL() realm found" ); + pos = pos + KCRAuthRealm().Length(); // realm + endPos = iRtspText->Mid( pos ).LocateF( '"' ); + + if ( endPos != KErrNotFound ) + { + TPtrC8 data = iRtspText->Mid( pos ).Left( endPos ); + delete iRealm; + iRealm = NULL; + iRealm = HBufC8::NewL( data.Length() ); + iRealm->Des().Copy( data ); + } + } + + // Find "nonce" + pos = iRtspText->FindC( KCRAuthNonce() ); + if ( pos != KErrNotFound ) + { + LOG( "CCRRtspResponse::FindRTPAuthenticationL() nonce found" ); + pos = pos + KCRAuthNonce().Length(); // nonce + endPos = iRtspText->Mid( pos ).LocateF( '"' ); + if ( endPos != KErrNotFound ) + { + TPtrC8 nonceData = iRtspText->Mid( pos ).Left( endPos ); + delete iNonce; + iNonce = NULL; + iNonce = HBufC8::NewL( nonceData.Length() ); + iNonce->Des().Copy( nonceData ); + } + } + + // Find "opaque"(it seems that Darwin streaming server does not send this one) + pos = iRtspText->FindC( KCRAuthOpaque() ); + if ( pos != KErrNotFound ) + { + LOG( "CCRRtspResponse::FindRTPAuthenticationL() opaque found" ); + pos = pos + KCRAuthOpaque().Length(); // opaque + endPos = iRtspText->Mid( pos ).LocateF( '"' ); + if ( endPos != KErrNotFound ) + { + TPtrC8 opaqData = iRtspText->Mid( pos ).Left( endPos ); + delete iOpaque; + iOpaque = NULL; + iOpaque = HBufC8::NewL( opaqData.Length() ); + iOpaque->Des().Copy( opaqData ); + } + } + } + + // basic + else + { + pos = iRtspText->FindC( KCRAuthBasic ); + + if ( pos != KErrNotFound ) + { + LOG( "CCRRtspResponse::FindRTPAuthenticationL() Basic found" ); + + delete iAuthType; + iAuthType = NULL; + iAuthType = HBufC8::NewL( KCRAuthBasic().Length() ); + iAuthType->Des().Copy( KCRAuthBasic ); + + // find "realm" + pos = iRtspText->FindC( KCRAuthRealm ); + + if ( pos != KErrNotFound ) + { + LOG( "CCRRtspResponse::FindRTPAuthenticationL() realm found" ); + pos = pos + KCRAuthRealm().Length(); // realm + endPos = iRtspText->Mid( pos ).LocateF( '"' ); + + if ( endPos != KErrNotFound ) + { + TPtrC8 data = iRtspText->Mid( pos ).Left( endPos ); + delete iRealm; + iRealm = NULL; + iRealm = HBufC8::NewL( data.Length() ); + iRealm->Des().Copy( data ); + } + } + } + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRtpFileSource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRtpFileSource.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,521 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that reads RTP packets from propriatary file format.* +*/ + + + + +// INCLUDE FILES +#include "CCRRtpFileSource.h" +#include +#include "CCRPacketBuffer.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KGroupsCountPoint( 0 ); +const TInt KBufferThesholdCount( 20 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtpFileSource* CCRRtpFileSource::NewL( + const SCRRtpPlayParams& aParams, + CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + { + CCRRtpFileSource* self = new( ELeave ) + CCRRtpFileSource( aClipHandler, aSessionObs, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL( aParams ); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtpFileSource* CCRRtpFileSource::NewL( + const RFile& aRtpHandle, + CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + { + CCRRtpFileSource* self = new( ELeave ) + CCRRtpFileSource( aClipHandler, aSessionObs, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL( aRtpHandle ); + CleanupStack::Pop(); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::CCRRtpFileSource +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtpFileSource::CCRRtpFileSource( + CRtpClipHandler*& aClipHandler, + MCRStreamObserver& aSessionObs, + CCRStreamingSession& aOwningSession ) + : CCRPacketSourceBase( aOwningSession, CCRStreamingSession::ECRRtpSourceId ), + iClipHandler( aClipHandler ), + iSessionObs( aSessionObs ), + iInitialTime( KMaxTUint ), + iClipPauseSent( 0 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::ConstructL( const SCRRtpPlayParams& aParams ) + { + const TBool timeShift( + aParams.iFileName.Find( KDvrTimeShiftFile ) > KErrNotFound ); + LOG1( "CCRRtpFileSource::ConstructL() in, timeShift: %d", timeShift ); + + // RTP clip handler + User::LeaveIfNull( iClipHandler ); + iClipHandler->RegisterReadObserver( this ); + iClipHandler->StartPlayBackL( aParams, timeShift ); + + LOG( "CCRRtpFileSource::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::ConstructL( const RFile& aRtpHandle ) + { + LOG( "CCRRtpFileSource::ConstructL() in" ); + + User::LeaveIfNull( iClipHandler ); + iClipHandler->RegisterReadObserver( this ); + iClipHandler->StartPlayBackL( aRtpHandle ); + + LOG( "CCRRtpFileSource::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::~CCRRtpFileSource +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtpFileSource::~CCRRtpFileSource() + { + LOG( "CCRRtpFileSource::~CCRRtpFileSource()" ); + + if ( iClipHandler ) + { + iClipHandler->StopPlayBack( KErrNone, 0 ); + } + + delete iSdp; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::GetSdp +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::GetSdp( TPtrC8& aSdp ) + { + if ( iSdp ) + { + aSdp.Set( iSdp->Des() ); + return KErrNone; + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::SetBuffer +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::SetBuffer( CCRPacketBuffer* aBuffer ) + { + iBuffer = aBuffer; + iBuffer->ContinousStream( EFalse ); + iBuffer->MoreComing( EFalse ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::PostActionL +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::PostActionL() + { + LOG( "CCRRtpFileSource::PostActionL(), SDP will be handled !" ); + + // SDP + if ( iClipHandler ) + { + iSdp = iClipHandler->GetClipSdpL(); + } + + // Notify that SDP available + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateSdpAvailable ); + delete iSdp; iSdp = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::Restore +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::Restore() + { + const TInt err( NextClipGroup( ETrue ) ); + if ( err && err != KErrEof ) + { + LOG1( "CCRRtpFileSource::Restore(), NextClipGroup() err: %d", err ); + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::Play +// +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::Play( const TReal& aStartPos, const TReal& aEndPos ) + { + LOG3( "CCRRtpFileSource::Play(), aStartPos: %f, aEndPos: %f, iClipPauseSent: %d", + aStartPos, aEndPos, iClipPauseSent ); + // Play for player? + if ( aStartPos == KRealZero && aEndPos == KRealZero ) + { + iInitialTime = KMaxTUint; + return NextClipGroup( EFalse ); + } + + // Loading started in player? + if ( aStartPos == KRealMinusOne && aEndPos == KRealMinusOne ) + { + const TBool pauseSent( iClipPauseSent > 0 ); + if ( pauseSent ) + { + iClipPauseSent--; + iBuffer->ResetBuffer(); + } + + // Read more from clip + TInt err( NextClipGroup( EFalse ) ); + if ( !err && pauseSent ) + { + iInitialTime = KMaxTUint; + err = ECRStreamPauseHanling; + LOG( "CCRRtpFileSource::Play(), ECRStreamPauseHanling" ); + } + else + { + if ( err == KErrEof ) + { + err = KErrNone; + if ( iClipHandler ) + { + TRAP( err, iClipHandler->SetSeekPointL( 0 ) ); + } + if ( !err ) + { + err = ECRStreamEndHandling; + LOG( "CCRRtpFileSource::Play(), ECRStreamEndHandling" ); + } + } + } + + return err; + } + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::Stop +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::Stop() + { + LOG( "CCRRtpFileSource::Stop()" ); + + return RtpPosition( 0 ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::SetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::SetPosition( const TInt64 aPosition ) + { + TInt err( RtpPosition( TUint( aPosition / KSiKilo ) ) ); + if ( !err ) + { + err = NextClipGroup( EFalse ); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::GetPosition +// +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::GetPosition( TInt64& aPosition, TInt64& aDuration ) + { + if ( iBuffer && iClipHandler ) + { + if ( iInitialTime != KMaxTUint ) + { + aPosition += TInt64( iInitialTime ) * KSiKilo; + } + else + { + LOG( "CCRRtpFileSource::GetPosition(), iInitialTime not valid !" ); + } + + aDuration = TInt64( iClipHandler->GetCurrentLength() ) * KSiKilo; +#ifdef CR_ALL_LOGS + LOG2( "CCRRtpFileSource::GetPosition(), aPosition: %u, aDuration: %u", + ( TUint )( aPosition / KSiKilo ), ( TUint )( aDuration / KSiKilo ) ); +#endif // CR_ALL_LOGS + return KErrNone; + } + + return KErrCompletion; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::GroupReadedL +// Adds packets to the buffer when finished asyncronous group reading. +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::GroupReadedL( + const TDesC8& aGroup, + const TUint aGroupTime, + const TBool aLastGroup ) + { + // Group time + if ( iInitialTime == KMaxTUint ) + { + iInitialTime = aGroupTime; + } + + // Data valid? + TInt point( KGroupsCountPoint + KPacketsCountBytes ); + const TInt total( aGroup.Length() ); + if ( point > total ) + { + LOG( "CCRRtpFileSource::GroupReadedL(), No Packets Total Count !" ); + User::Leave( KErrCorrupt ); + } + + // Packets total count (PTC) + const TInt totalCount( CRtpUtil::GetValueL( + aGroup.Mid( KGroupsCountPoint, KPacketsCountBytes ) ) ); + if ( totalCount > 0 ) + { + iBuffer->MoreComing( ETrue ); + } + + // Loop all packets + for ( TInt i( 0 ); i < totalCount; i++ ) + { + // Corrupted? + if ( ( point + KPacketSizeBytesLen ) > total ) + { + LOG( "CCRRtpFileSource::GroupReadedL(), No Packets Size !" ); + User::Leave( KErrCorrupt ); + } + + // Packet total Size (PTS) + TInt packetSize( CRtpUtil::GetValueL( + aGroup.Mid( point, KPacketSizeBytesLen ) ) ); + // Corrupted? + if ( packetSize <= 0 || ( point + packetSize ) > total ) + { + LOG( "CCRRtpFileSource::GroupReadedL(), No Packets Payload !" ); + User::Leave( KErrCorrupt ); + } + + // Packet type + point += KPacketSizeBytesLen; + const MRtpFileWriteObserver::TRtpType type( + ( MRtpFileWriteObserver::TRtpType )( aGroup[point] ) ); + point += KPacketTypeBytesLen; + packetSize -= ( KPacketSizeBytesLen + KPacketTypeBytesLen ); + + // Insert packet to the buffer + const TPtrC8 packet( aGroup.Mid( point, packetSize ) ); + +#ifdef CR_ALL_LOGS + const TUint8* pointer( &packet[2] ); + TInt seq( BigEndian::Get16( pointer ) ); + LOG3( "CCRRtpFileSource::GroupReadedL(), type: %d, packet: %d, seq: %d", + type, packet.Length(), seq ); + //RFileLogger::WriteFormat( _L( "livetv" ), _L( "play.log" ), EFileLoggingModeAppend, + // _L( "GroupReadedL(), type: %d, packet: %d, seq: %d" ), type, packet.Length(), seq ); +#endif // CR_ALL_LOGS + + MCRPacketSource::TCRPacketStreamId stream( MCRPacketSource::EStreamIdCount ); + if ( TypeToStream( type, stream ) ) + { + // Last packet in group? + if ( i >= ( totalCount - 1 ) ) + { + iBuffer->MoreComing( EFalse ); + if ( aLastGroup && stream != MCRPacketSource::EStreamEndTag ) + { + LOG( "CCRRtpFileSource::GroupReadedL(), Misses last group from clip !" ); + stream = MCRPacketSource::EStreamEndTag; + } + } + + // Packet to buffer + iBuffer->AddPacket( stream, packet ); + } + + point+= packetSize; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::ReadStatus +// ----------------------------------------------------------------------------- +// +void CCRRtpFileSource::ReadStatus( TInt aStatus ) + { + LOG1( "CCRRtpFileSource::ReadStatus(), aStatus: %d", aStatus ); + + switch ( aStatus ) + { + case MRtpFileReadObserver::ERtpTimeShifTEnd: + break; + + default: + iSessionObs.StatusChanged( MCRPacketSource::ERtpStateClosing ); + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::NextClipGroup +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::NextClipGroup( const TBool aForce ) + { + if ( iBuffer && iClipHandler ) + { + if ( aForce || iBuffer->PacketsMinCount() < KBufferThesholdCount ) + { + TRAPD( err, iClipHandler->NextClipGroupL() ); + return err; + } + + return KErrNone; + } + + return KErrNotReady; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::RtpPosition +// ----------------------------------------------------------------------------- +// +TInt CCRRtpFileSource::RtpPosition( const TUint aPosition ) + { + LOG1( "CCRRtpFileSource::RtpPosition(), aPosition: %d", aPosition ); + + TInt err( KErrCompletion ); + if ( iBuffer && iClipHandler ) + { + TRAP( err, iClipHandler->SetSeekPointL( aPosition ) ); + if ( !err ) + { + iInitialTime = KMaxTUint; + iBuffer->ResetBuffer(); + } + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtpFileSource::TypeToStream +// ----------------------------------------------------------------------------- +// +TBool CCRRtpFileSource::TypeToStream( + const MRtpFileWriteObserver::TRtpType& aType, + MCRPacketSource::TCRPacketStreamId& aStream ) + { + switch ( aType ) + { + case MRtpFileWriteObserver::ERtpAudio: + aStream = MCRPacketSource::EAudioStream; + break; + + case MRtpFileWriteObserver::ERtcpAudio: + aStream = MCRPacketSource::EAudioControlStream; + break; + + case MRtpFileWriteObserver::ERtpVideo: + aStream = MCRPacketSource::EVideoStream; + break; + + case MRtpFileWriteObserver::ERtcpVideo: + aStream = MCRPacketSource::EVideoControlStream; + break; + + case MRtpFileWriteObserver::ERtpSubTitle: + aStream = MCRPacketSource::ESubTitleStream; + break; + + case MRtpFileWriteObserver::ERtcpSubTitle: + aStream = MCRPacketSource::ESubTitleControlStream; + break; + + case MRtpFileWriteObserver::ERtpClipPause: + LOG( "CCRRtpFileSource::TypeToStream(), ERtpClipPause" ); + iClipPauseSent = ETrue; + aStream = MCRPacketSource::EDisContinousStream; + break; + + case MRtpFileWriteObserver::ERtpClipEnd: + LOG( "CCRRtpFileSource::TypeToStream(), ERtpClipEnd" ); + aStream = MCRPacketSource::EStreamEndTag; + break; + + default: + LOG1( "CCRRtpFileSource::TypeToStream(), Default case, aType: %d", + aType ); + return EFalse; + } + + return ETrue; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRtpRecordSink.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRtpRecordSink.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,623 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that takes packet from buffer and does not put them* +*/ + + + + +// INCLUDES +#include "CCRRtpRecordSink.h" +#include "CCRPacketBuffer.h" +#include "CCRStreamingSession.h" +#include "MCRConnectionObserver.h" +#include +#include +#include +#include "CRtpTsConverter.h" +#include "CRtpPacket.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KDefaultBitRate( 256 + 64 ); // 320 kbps +const TInt KDefGroupSize( 70 * 1024 ); // 70k +const TInt KMaxGroupSize( 140 * 1024 ); // 140k +const TInt KMaxGrouplength( 3000 ); // 3 s +const TInt KGroupHeaderSize( KGroupHeaderBytes + KPacketsCountBytes ); +const TInt KGroupLenghtAccuracy( 20 ); // 20ms + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// + +CCRRtpRecordSink* CCRRtpRecordSink::NewL( + const SCRRecordParams& aRecordParams, + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession, + MCRConnectionObserver* aObserver, + CRtpClipHandler*& aClipHandler ) + { + CCRRtpRecordSink* self = new( ELeave ) + CCRRtpRecordSink( aSinkId, aOwningSession, aObserver, aClipHandler ); + CleanupStack::PushL( self ); + self->ConstructL( aRecordParams ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::CCRRtpRecordSink +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtpRecordSink::CCRRtpRecordSink( + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession, + MCRConnectionObserver* aObserver, + CRtpClipHandler*& aClipHandler ) + : CCRPacketSinkBase( aOwningSession, aSinkId ), + iObserver( aObserver ), + iClipHandler( aClipHandler ), + iGroupPointer( NULL, 0 ), + iGroupSize( KGroupHeaderSize ), + iPacketsCount( 0 ), + iWantedGroup( KMaxTInt ), + iOldestTs( KMaxTUint ), + iLatestAudio( NULL, 0 ), + iSaveMode( MRtpFileWriteObserver::ESaveNormal ), + iGroupMode( MRtpFileWriteObserver::ESaveIdle ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::ConstructL +// 2nd phase. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::ConstructL( const SCRRecordParams& aRecordParams ) + { + LOG( "CCRRtpRecordSink::ConstructL()" ); + + // Params + iRecParams.iClipPath = aRecordParams.iFileName; + iRecParams.iSdpData.Set( aRecordParams.iSdpData ); + iRecParams.iService.Set( aRecordParams.iServiceName ); + iRecParams.iProgram.Set( aRecordParams.iProgramName ); + iRecParams.iPostRule = aRecordParams.iPostRule; + iRecParams.iParental = aRecordParams.iParental; + iRecParams.iEndTime = aRecordParams.iEndTime; + + if ( aRecordParams.iFormat == ECRRecordTimeShift ) + { + iRecParams.iStartTime = 0; + iRecParams.iEndTime = KDvrMaximumTimeShift * 1e6; + iSaveMode = MRtpFileWriteObserver::ESaveTimeShift; + } + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + LOG1( "CCRRtpRecordSink::ConstructL(), iClipPath: %S", &iRecParams.iClipPath ); + TName buf( KNullDesC ); iRecParams.iStartTime.FormatL( buf, KTimeDateFormat ); + LOG1( "CCRRtpRecordSink::ConstructL(), iStartTime: %S", &buf ); + iRecParams.iEndTime.FormatL( buf, KTimeDateFormat ); + LOG1( "CCRRtpRecordSink::ConstructL(), iEndTime: %S", &buf ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + // Clip handler and group buffer + User::LeaveIfNull( iClipHandler ); + iGroupBuffer = HBufC8::NewL( 0 ); + iGroupPointer.Set( iGroupBuffer->Des() ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::~CCRRtpRecordSink +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtpRecordSink::~CCRRtpRecordSink() + { + LOG( "CCRRtpRecordSink::~CCRRtpRecordSink()" ); + + if ( iClipHandler ) + { + iClipHandler->StopRecording( KErrCancel ); + } + + delete iGroupBuffer; + delete iAudioConv; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::SetSdpL +// Sets SDP, parses it and initiates XPS. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::SetSdpL( const TDesC8& aSdp ) + { + TInt initiated( iRecParams.iSdpData.Length() ); + LOG2( "CCRRtpRecordSink::SetSdpL(), aSdp len: %d, initiated: %d", + aSdp.Length(), initiated ); + if ( !initiated && iClipHandler ) + { + iRecParams.iSdpData.Set( aSdp ); + iClipHandler->RegisterWriteObserver( this ); + iClipHandler->StartRecordingL( iRecParams, iSaveMode ); + + // SDP parser + CDvrSdpParser* sdpParser = CDvrSdpParser::NewLC(); + sdpParser->TryParseL( aSdp ); + + // Bit rates + TUint total( sdpParser->VideoBitrate() + sdpParser->AudioBitrate() ); + TReal angle( TReal( total ) / KDefaultBitRate ); + iWantedGroup = TInt( angle * KDefGroupSize ); + LOG1( "SetSdpL::SetSdpL(), iWantedGroup: %d", iWantedGroup ); + iGroupBuffer = iGroupBuffer->ReAllocL( iWantedGroup + KGroupHeaderSize ); + iGroupPointer.Set( iGroupBuffer->Des() ); + + // TS converter + delete iAudioConv; iAudioConv = NULL; + iAudioConv = CRtpTsConverter::NewL( sdpParser->AudioTimerGranularity() ); + LOG1( "CCRRtpRecordSink::SetSdpL(), AudioTimerGranularity: %d", + sdpParser->AudioTimerGranularity() ); + CleanupStack::PopAndDestroy( sdpParser ); + + // Recording can start + iGroupMode = MRtpFileWriteObserver::ESaveNormal; + iObserver->ConnectionStatusChange( iOwningSession.SourceChecksum(), + MCRConnectionObserver::ECRRecordingStarted, KErrNone ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::NewPacketAvailable +// From CCRPacketSinkBase. New packet(s) to a group. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::NewPacketAvailable() + { + // Keep group buffer untouch during clip writing + if ( iBuffer && iClipHandler && !iClipHandler->WritingActive() ) + { + if ( iGroupMode == MRtpFileWriteObserver::ESaveNormal ) + { + // New packets to a group + AddToGroup(); + + // Group size big enougth to write to clip? + if ( iGroupSize >= iWantedGroup ) + { + SaveGroup( iGroupMode ); + } + + // Keep buffer size reasonable + iBuffer->HandleBufferSize(); + } + else + { + if ( iGroupMode != MRtpFileWriteObserver::ESaveIdle ) + { + AddToGroup(); + + // Handle user pause + if ( iGroupMode == MRtpFileWriteObserver::ESavePause ) + { + AddPausePacket(); + } + + SaveGroup( iGroupMode ); + iGroupMode = MRtpFileWriteObserver::ESaveIdle; + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::BufferResetting +// From CCRPacketSinkBase. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::BufferResetDone() + { + AddPausePacket(); + if ( iClipHandler && !iClipHandler->WritingActive() ) + { + SaveGroup( MRtpFileWriteObserver::ESavePause ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::Pause +// ----------------------------------------------------------------------------- +// +TInt CCRRtpRecordSink::Pause() + { + LOG1( "CCRRtpRecordSink::Pause(), iGroupMode: %d", iGroupMode ); + + TInt err( KErrCompletion ); + if ( iClipHandler ) + { + if ( iSaveMode == MRtpFileWriteObserver::ESaveNormal ) + { + // Normal pause + err = KErrNone; + iGroupMode = MRtpFileWriteObserver::ESavePause; + } + else + { + // Time shift pause + TRAP( err, iClipHandler->TimeShiftPauseL() ); + } + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::Restore +// ----------------------------------------------------------------------------- +// +TInt CCRRtpRecordSink::Restore() + { + LOG1( "CCRRtpRecordSink::Restore(), iGroupMode: %d", iGroupMode ); + + iGroupMode = MRtpFileWriteObserver::ESaveNormal; + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::Stop +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::Stop() + { + LOG1( "CCRRtpRecordSink::Stop(), iGroupMode: %d", iGroupMode ); + + iGroupMode = MRtpFileWriteObserver::ESaveEnd; + if ( iClipHandler && !iClipHandler->WritingActive() ) + { + iWantedGroup = KMaxTInt; + SaveGroup( iGroupMode ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::GroupSaved +// From MRtpFileWriteObserver. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::GroupSaved() + { + ResetGroupVariables(); + if ( iGroupMode != MRtpFileWriteObserver::ESaveNormal ) + { + SaveGroup( iGroupMode ); + iGroupMode = MRtpFileWriteObserver::ESaveIdle; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::WriteStatus +// From MRtpFileWriteObserver. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::WriteStatus( const TInt aStatus ) + { + LOG1( "CCRRtpRecordSink::WriteStatus(), aStatus: %d", aStatus ); + + ForceStopRecording( aStatus ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::AddToGroup +// Initialises time stamp converter for audio stream and adds packets to a group. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::AddToGroup() + { + const TInt packets( iBuffer->PacketsCount( iSinkId ) ); + for ( TInt i( packets ); i > KErrNotFound; i-- ) + { + // Packet + TPtr8 packet( NULL, 0 ); + MCRPacketSource::TCRPacketStreamId streamId( + MCRPacketSource::EStreamIdCount ); + const TInt book( iBuffer->GetStream( iSinkId, streamId ) ); + iBuffer->GetPacket( book, packet ); + + // TS converter + if ( streamId == MCRPacketSource::EAudioControlStream && + iAudioConv && !iAudioConv->Initiated() ) + { + iAudioConv->Init( packet ); + } + + // Type valid + MRtpFileWriteObserver::TRtpType type( MRtpFileWriteObserver::ERtpNone ); + if ( packet.Length() && StreamToType( streamId, type ) ) + { + TRAPD( err, AddPacketToGroupL( packet, type ) ); + if ( err ) + { + LOG1( "CCRRtpRecordSink::AddToGroup(), AddPacketToGroupL leaved: %d", err ); + ForceStopRecording( err ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::AddPacketToGroupL +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::AddPacketToGroupL( + const TDesC8& aPacket, + const MRtpFileWriteObserver::TRtpType& aType ) + { + const TUint total( KPacketSizeBytesLen + + KPacketTypeBytesLen + aPacket.Length() ); + iGroupSize += total; + if ( iGroupSize > iGroupPointer.MaxLength() ) + { + iGroupBuffer = iGroupBuffer->ReAllocL( iGroupSize ); + iGroupPointer.Set( iGroupBuffer->Des() ); + LOG1( "CCRRtpRecordSink::AddPacketToGroupL(), New iGroupSize: %d", iGroupSize ); + } + + // Packet length (PTL), type and data + TBuf8 header; + CRtpUtil::MakeBytesL( total, header ); + header.Append( KCharSpace ); + header[KPacketTypeBytePoint] = ( TUint8 )( aType ); + iGroupPointer.Append( header ); + iGroupPointer.Append( aPacket ); + iPacketsCount++; + +#ifdef CR_ALL_LOGS + const TUint8* pointer( &aPacket[2] ); + TInt seq( BigEndian::Get16( pointer ) ); + LOG3( "CCRRtpRecordSink::AddPacketToGroupL(), type: %d, packet: %d, seq: %d", + aType, aPacket.Length(), seq ); + //RFileLogger::WriteFormat( _L( "livetv" ), _L( "record.log" ), EFileLoggingModeAppend, + // _L( "AddPacketToGroupL(), type: %d, packet: %d, seq: %d" ), aType, aPacket.Length(), seq ); + +#endif // CR_ALL_LOGS + + // Variables for TS delta + if ( aType == MRtpFileWriteObserver::ERtpAudio && + iAudioConv && iAudioConv->Initiated() ) + { + if ( iOldestTs == KMaxTUint ) + { + iOldestTs = TsFromPacketL( aPacket ); + } + else + { + iLatestAudio.Set( iGroupPointer.Right( aPacket.Length() ) ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::SaveGroup +// Saves RTP packets group to a clip. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::SaveGroup( MRtpFileWriteObserver::TRtpSaveAction aAction ) + { + TRAPD( err, SaveGroupL( aAction ) ); + if ( err ) + { + ForceStopRecording( err ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::SaveGroup +// Saves RTP packets group to a clip. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::SaveGroupL( MRtpFileWriteObserver::TRtpSaveAction aAction ) + { + // TS delta + TBool forceSave( aAction != MRtpFileWriteObserver::ESaveNormal ); + TInt length( TReal( iGroupSize ) / iWantedGroup * KNormalRecGroupLength ); + if ( iOldestTs != KMaxTUint ) + { + length = TsFromPacketL( iLatestAudio ) - iOldestTs; + } + if ( length >= ( KNormalRecGroupLength - KGroupLenghtAccuracy ) ) + { + forceSave = ETrue; + if ( length <= ( KNormalRecGroupLength + KGroupLenghtAccuracy ) ) + { + iWantedGroup = ( iWantedGroup + iGroupSize ) / 2; + } + else + { + TReal angle( TReal( iGroupSize ) / length ); + TInt wanted( TReal( KNormalRecGroupLength ) * angle ); + if ( wanted > ( KDefGroupSize / 2 ) && wanted < KMaxGroupSize ) + { + iWantedGroup = ( iWantedGroup + wanted ) / 2; + } + } + } + + // Group ok to save? + if ( forceSave || iGroupSize > KMaxGroupSize ) + { + // Group packets count (PTC) + HBufC8* bytes = CRtpUtil::MakeBytesLC( iPacketsCount ); + iGroupPointer.Insert( 0, bytes->Des() ); + CleanupStack::PopAndDestroy( bytes ); + + // Make sure that nasty length not end to the clip in case TS overflow + length = ( length <= KMaxGrouplength )? length: KMaxGrouplength; + + // Save to clip + TInt err( KErrNotReady ); + if ( iClipHandler ) + { + TRAP( err, iClipHandler->SaveNextGroupL( iGroupPointer, + length, aAction ) ); + } + if ( err ) + { + LOG1( "CCRRtpRecordSink::SaveGroup(), SaveNextGroupL Leaved: %d", err ); + ForceStopRecording( err ); + } + + LOG3( "CCRRtpRecordSink::SaveGroup(), iPacketsCount: %d, length: %u, iWantedGroup: %d", + iPacketsCount, length, iWantedGroup ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::StreamToType +// ----------------------------------------------------------------------------- +// +TBool CCRRtpRecordSink::StreamToType( + const MCRPacketSource::TCRPacketStreamId& aStream, + MRtpFileWriteObserver::TRtpType& aType ) + { + switch ( aStream ) + { + case MCRPacketSource::EAudioStream: + aType = MRtpFileWriteObserver::ERtpAudio; + break; + + case MCRPacketSource::EAudioControlStream: + aType = MRtpFileWriteObserver::ERtcpAudio; + break; + + case MCRPacketSource::EVideoStream: + aType = MRtpFileWriteObserver::ERtpVideo; + break; + + case MCRPacketSource::EVideoControlStream: + aType = MRtpFileWriteObserver::ERtcpVideo; + break; + + case MCRPacketSource::ESubTitleStream: + aType = MRtpFileWriteObserver::ERtpSubTitle; + break; + + case MCRPacketSource::ESubTitleControlStream: + aType = MRtpFileWriteObserver::ERtcpSubTitle; + break; + + case MCRPacketSource::EDisContinousStream: + LOG( "CCRRtpRecordSink::StreamToType(), ERtpClipPause" ); + aType = MRtpFileWriteObserver::ERtpClipPause; + break; + + case MCRPacketSource::EStreamEndTag: + LOG( "CCRRtpRecordSink::StreamToType(), ERtpClipEnd" ); + aType = MRtpFileWriteObserver::ERtpClipEnd; + break; + + default: + return EFalse; + } + + return ETrue; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::TsFromPacketL +// ----------------------------------------------------------------------------- +// +TUint CCRRtpRecordSink::TsFromPacketL( const TDesC8& aPacket ) + { + CRtpPacket* rtpPacket = CRtpPacket::NewLC(); + TUint ts( KMaxTUint ); + if ( !rtpPacket->ParseRtp( aPacket ) ) + { + ts = iAudioConv->ConvertTs( rtpPacket->iRtpRecvHeader.iTimestamp, ETrue ); + } + + CleanupStack::PopAndDestroy( rtpPacket ); + return ts; + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::AddPausePacket +// Wrapper for AddPausePacketL(). +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::AddPausePacket() + { + LOG( "CCRRtpRecordSink::AddPausePacket()"); + + TRAPD( err, AddPausePacketL() ); + if ( err ) + { + ForceStopRecording( err ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::AddPausePacketL +// Adds pause packet to the group. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::AddPausePacketL() + { + HBufC8* data = CRtpUtil::MakeBytesLC( KMaxTUint ); + AddPacketToGroupL( data->Des(), MRtpFileWriteObserver::ERtpClipPause ); + CleanupStack::PopAndDestroy( data ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::ForceStopRecording +// Stops recording on clip handler and destroys the sink. +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::ForceStopRecording( const TInt& aStatus ) + { + LOG2( "CCRRtpRecordSink::ForceStopRecording(), iGroupMode: %d, aStatus: %d", + iGroupMode, aStatus ); + iGroupMode = MRtpFileWriteObserver::ESaveIdle; + + if ( iClipHandler ) + { + iClipHandler->StopRecording( aStatus ); + } + + iObserver->ConnectionStatusChange( iOwningSession.SourceChecksum(), + MCRConnectionObserver::ECRRecordingEnded, aStatus ); + iOwningSession.SinkStops( Id() ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpRecordSink::ResetGroupVariables +// +// ----------------------------------------------------------------------------- +// +void CCRRtpRecordSink::ResetGroupVariables() + { + iGroupSize = KGroupHeaderSize; // Room for group header and packets count + iPacketsCount = 0; + iGroupPointer.Zero(); + iOldestTs = KMaxTUint; + iLatestAudio.Set( NULL, 0 ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRtpTcpStream.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRtpTcpStream.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Single media stream for RTP/TCP streamer* +*/ + + + + +// INCLUDE FILES +#include "CCRRtpTcpStream.h" +#include "CCRRtpTcpObserver.h" +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KReceiverReportLength( 12 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStream::CCRRtpTcpStream +// ----------------------------------------------------------------------------- +// +CCRRtpTcpStream::CCRRtpTcpStream( MCRRtpTcpObserver& aObserver ) + : iObserver(aObserver) + { + iSSRC = Math::Random(); + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStream::NewL +// ----------------------------------------------------------------------------- +// +CCRRtpTcpStream* CCRRtpTcpStream::NewL( MCRRtpTcpObserver& aObserver ) + { + CCRRtpTcpStream* self = new( ELeave ) CCRRtpTcpStream( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStream::ConstructL +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStream::ConstructL() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStream::~CCRRtpTcpStream +// ----------------------------------------------------------------------------- +// +CCRRtpTcpStream::~CCRRtpTcpStream() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStream::ForwardPacketAvailable +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStream::PacketAvailable( TInt aChannel ) + { + // Nothing to to do for RTP, just ignore + if ( !( aChannel % 2 ) ) + { + return; + } + + // Very simple Receiver Report generation: + // - RC=0, no SSRC report blocks -> no statistics keeping + // - one RR for every SR received -> no timing, back-off, etc + TBuf8 chunk( KNullDesC8 ); + chunk.SetLength( KReceiverReportLength ); + + // RTSP header + chunk[0] = ( TUint8 )( 0x24 ); // magic '$' for embedded binary in RTSP + chunk[1] = ( TUint8 )( aChannel ); // enbedded RTSP channel + // Embedded packet length, fixed + BigEndian::Put16( ( TUint8* )chunk.Ptr() + 2, 8 ); + + // RR + chunk[4] = 0x80; // v=2, p=0, rc=0 + chunk[5] = 201; // PT= RR= 201 + // Length=1 ( in 32bits, -1 ) + BigEndian::Put16( ( TUint8* )chunk.Ptr() + 6, 1 ); + BigEndian::Put32( ( TUint8* )chunk.Ptr() + 8, iSSRC ); + + iObserver.ForwardRtpTcpChunck( chunk ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRtpTcpStreamer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRtpTcpStreamer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,418 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP/TCP streamer for RTSP source.* +*/ + + + + +// INCLUDE FILES +#include "CCRRtpTcpStreamer.h" +#include "CCRRtpTcpObserver.h" +#include "CCRRtpTcpStream.h" +#include "CRRTSPCommon.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KCRRtpTcpHeaderLength( 4 ); +const TInt KCRRtpTcpStartMark( 0x24 ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::NewL +// ----------------------------------------------------------------------------- +CCRRtpTcpStreamer* CCRRtpTcpStreamer::NewL( MCRRtpTcpObserver& aObserver ) + { + CCRRtpTcpStreamer* self = new( ELeave ) CCRRtpTcpStreamer( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::CCRRtpTcpStreamer +// ----------------------------------------------------------------------------- +// +CCRRtpTcpStreamer::CCRRtpTcpStreamer( MCRRtpTcpObserver& aObserver ) + : iObserver( aObserver ), + iMoreExpected( KErrNotFound ), + iIpData( NULL ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::ConstructL +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStreamer::ConstructL() + { + // Construct streams + for ( TInt i( 0 ); i < KCRRtpTcpStreamCount; i++ ) + { + iStreams[i] = CCRRtpTcpStream::NewL( iObserver ); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::~CCRRtpTcpStreamer +// ----------------------------------------------------------------------------- +CCRRtpTcpStreamer::~CCRRtpTcpStreamer() + { + // Buffers + if ( iIpData ) + { + delete iIpData; iIpData = NULL; + } + if ( iRtspData ) + { + delete iRtspData; iRtspData = NULL; + } + + // Delete streams + for ( TInt i( 0 ); i < KCRRtpTcpStreamCount; i++ ) + { + if ( iStreams[i] ) + { + delete iStreams[i]; iStreams[i] = NULL; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::DataAvailable +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStreamer::DataAvailable( + const TDesC8& aIpData, + const TBool& aInterleaved ) + { + TPtrC8 data( aIpData ); + if ( iMoreExpected > KErrNotFound && iIpData != NULL ) + { + // More data expected + if ( HandleMoreExpected( data ) ) + { + return; // Need more + } + } + + // Can't be existing IP data at this point + delete iIpData; iIpData = NULL; + iMoreExpected = KErrNotFound; + + // Find out next packet + do + { + // Search for $ (0x24) sign + TBool tcp( EFalse ); + for ( TInt i( 0 ); aInterleaved && tcp == EFalse && + i < data.Length() && i < KCRRtpTcpHeaderLength; i++ ) + { + if ( data[i] == KCRRtpTcpStartMark ) + { + tcp = ETrue; + data.Set( data.Mid( i ) ); + + // Received less than full interleved header (4 bytes) + if ( data.Length() < KCRRtpTcpHeaderLength ) + { + iMoreExpected = KCRRtpTcpHeaderLength - data.Length(); + iIpData = data.Alloc(); + LOG1( "CCRRtpTcpStreamer::DataAvailable(), No interleave header, len: %d", data.Length() ); + return; // Need more + } + } + } + + if ( tcp ) + { + // TCP packet + if ( HandleTcpPacket( data ) ) + { + return; // Need more + } + } + else + { + // RTSP response + if ( HandleRtspResponse( data, aInterleaved ) ) + { + return; // Need more + } + + delete iRtspData; iRtspData = NULL; + } + } + while ( data.Length() > 0 ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::HandleMoreExpected +// ----------------------------------------------------------------------------- +// +TBool CCRRtpTcpStreamer::HandleMoreExpected( TPtrC8& aData ) + { + TInt len( aData.Length() ); + int used( len ); + if ( len >= iMoreExpected || iMoreExpected == KMaxTInt ) + { + if ( iMoreExpected >= KCRRtpTcpHeaderLength || + iIpData->Des()[0] != KCRRtpTcpStartMark || + iIpData->Length() >= KCRRtpTcpHeaderLength ) + { + // KMaxTInt is indication of unknow length in RTSP response + if ( iMoreExpected < KMaxTInt ) + { + used = iMoreExpected; + iMoreExpected = KErrNotFound; + } + else + { + // Combine datas and try find out RTSP response + delete iRtspData; iRtspData = NULL; + iRtspData = HBufC8::New( iIpData->Length() + len ); + TPtr8 ptr( iRtspData->Des() ); + ptr.Copy( iIpData->Des() ); + ptr.Append( aData ); + aData.Set( iRtspData->Des() ); + return EFalse; // Continue + } + } + else + { + // Fill interleave header + iIpData = iIpData->ReAlloc( iIpData->Length() + iMoreExpected ); + TPtr8 ptr( iIpData->Des() ); + ptr.Append( aData.Mid( 0, iMoreExpected ) ); + aData.Set( aData.Mid( iMoreExpected ) ); + len = aData.Length(); + used = len; + // Find real wanted packet length + iMoreExpected = ( TInt )BigEndian::Get16( ptr.Ptr() + 2 ); + if ( len == 0 ) + { + return ETrue; // Need more + } + if ( len >= iMoreExpected ) + { + used = iMoreExpected; + iMoreExpected = KErrNotFound; + } + } + } + + // Add new data to iIpData + iIpData = iIpData->ReAlloc( iIpData->Length() + used ); + TPtr8 ptr( iIpData->Des() ); + ptr.Append( aData.Mid( 0, used ) ); + aData.Set( aData.Mid( used ) ); + if ( iMoreExpected == KErrNotFound ) + { + ForwardPacket( ptr ); + if ( used == len ) + { + delete iIpData; iIpData = NULL; + return ETrue; // All handled + } + } + else + { + iMoreExpected -= used; + return ETrue; // Need more + } + + return EFalse; // Continue + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::HandleTcpPacket +// ----------------------------------------------------------------------------- +// +TBool CCRRtpTcpStreamer::HandleTcpPacket( TPtrC8& aData ) + { + const TInt length( KCRRtpTcpHeaderLength + + ( TInt )BigEndian::Get16( aData.Ptr() + 2 ) ); + if ( aData.Length() >= length ) + { + MakePacket( aData, length ); + } + else + { + // Need more data + iMoreExpected = length - aData.Length(); + iIpData = aData.Alloc(); + return ETrue; // Need more + } + + return EFalse; // Continue + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::HandleRtspResponse +// ----------------------------------------------------------------------------- +// +TBool CCRRtpTcpStreamer::HandleRtspResponse( + TPtrC8& aData, + const TBool& aInterleaved ) + { + TInt point( aData.FindC( KCRRTSPReplyHeader ) ); + if ( point > KErrNotFound ) + { + aData.Set( aData.Mid( point ) ); + + // Search for double CRLF combination + TInt crlf2( aData.FindC( KCR2NewLines ) ); + if ( crlf2 > KErrNotFound ) + { + crlf2 += KCR2NewLines().Length(); + } + + // Content length + point = aData.FindC( KCRRTSPContentLength() ); + if ( point > KErrNotFound && crlf2 > KErrNotFound ) + { + point += KCRRTSPContentLength().Length(); + TInt contentLen( KErrNotFound ); + TLex8 contentLenLex( aData.Mid( point, 5 ) ); + if ( contentLenLex.Val( contentLen ) < KErrNone ) + { + LOG1( "CCRRtpTcpStreamer::HandleRtspResponse(), Content length parse failed, Dumped %d bytes !", aData.Length() ); + return ETrue; + } + + LOG1( "CCRRtspCommon::HandleRtspResponse(), contentLen %d", contentLen ); + // Verify that enought data in IP packet + if ( aData.Length() >= ( crlf2 + contentLen ) ) + { + MakePacket( aData, crlf2 + contentLen ); + } + else + { + // Need more + iIpData = aData.Alloc(); + iMoreExpected = crlf2 + contentLen - aData.Length(); + return ETrue; + } + } + else + { + // Content length not defined, RTSP command should end to double CRLF + if ( crlf2 > KErrNotFound ) + { + MakePacket( aData, crlf2 ); + } + else + { + LOG( "CCRRtpTcpStreamer::HandleRtspResponse(), No double CRLF.." ); + + // Look for single CRLF + point = aData.FindC( KCRNewLine ); + if ( point > KErrNotFound ) + { + // If not interleaved, all data belongs to RTSP response + if ( !aInterleaved ) + { + if ( aData.Mid( aData.Length() - KCR2NewLines().Length() ). + FindF( KCRNewLine ) > KErrNotFound ) + { + ForwardPacket( aData ); + return ETrue; + } + + // Not complete but total length unknown + LOG( "CCRRtpTcpStreamer::HandleRtspResponse(), Need more without known length.." ); + iIpData = aData.Alloc(); + iMoreExpected = KMaxTInt; + return ETrue; + } + + // Only one CRLF after RTSP response, find last + point += KCRNewLine().Length(); + for ( TInt i( point ); i < aData.Length(); ) + { + TInt next( aData.Mid( point ).FindC( KCRNewLine ) ); + if ( next > KErrNotFound ) + { + point += ( next + KCRNewLine().Length() ); + i = point; + } + else + { + i = aData.Length(); + } + } + + LOG1( "CCRRtpTcpStreamer::HandleRtspResponse(), Last CRLF at index: %d", point ); + MakePacket( aData, point ); + } + else + { + // Not any CRLF, can not be RTSP response + LOG1( "CCRRtpTcpStreamer::HandleRtspResponse(), No CRLF, Dumped %d bytes !", aData.Length() ); + return ETrue; + } + } + } + } + else + { + LOG1( "CCRRtpTcpStreamer::HandleRtspResponse(), Not RTSP message, Dumped %d bytes !", aData.Length() ); + return ETrue; + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::MakePacket +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStreamer::MakePacket( TPtrC8& aData, const TInt aLength ) + { + ForwardPacket( aData.Mid( 0, aLength ) ); + aData.Set( aData.Mid( aLength ) ); + } + +// ----------------------------------------------------------------------------- +// CCRRtpTcpStreamer::ForwardPacket +// ----------------------------------------------------------------------------- +// +void CCRRtpTcpStreamer::ForwardPacket( const TDesC8& aPacket ) + { + if ( aPacket[0] == KCRRtpTcpStartMark ) + { + // 1. Forward (actually return or signal reception of) packet to user + const TInt channel( ( TInt )aPacket[1] ); + iObserver.RtpTcpPacketAvailable( + channel, aPacket.Mid( KCRRtpTcpHeaderLength ) ); + + // 2. Map channel to internal stream, ignore non audio or video + const TInt streamId( channel / 2 ); + if ( streamId >= 0 && streamId < KCRRtpTcpStreamCount ) + { + iStreams[streamId]->PacketAvailable( channel ); + } + } + else + { + // RTSP + iObserver.RtspMsgAvailable( aPacket ); + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRRtspSink.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRRtspSink.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,922 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that instructs rtsp client about getting rtp* +*/ + + + + +// INCLUDE FILES +#include "CCRRtspSink.h" +#include "CCRPacketBuffer.h" +#include "CRRTSPCommon.h" +#include "CCRConnection.h" +#include "CCRStreamingSession.h" +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KCCRRtspSinkDefaultServerPort( 20042 ); + +_LIT( KCCRRtspSink, "Rtsp sink" ); +_LIT ( KCRLocalIPAddr, "127.0.0.1" ); +_LIT8( KBaseUrl, "rtsp://127.0.0.1/" ); +_LIT8( KVis0, "v=0\r\n" ); +_LIT8( KSdpOLine, "o=- 1 2 IN IP4 127.0.0.1\r\n" ); +_LIT8( KSdpSLine, "s=cre\r\n"); +_LIT8( KSdpCLine, "c=IN IP4 0.0.0.0\r\n"); +_LIT8( KSdpTLine, "t=0 0\r\n"); +_LIT8( KSdpBLine, "b=AS:"); +_LIT8( KSdpAudioMLine, "m=audio 0 RTP/AVP %d\r\n" ); +_LIT8( KSdpAudioAControlLine, + "a=control:rtsp://127.0.0.1/default.3gp/AudioControlAddress\r\n" ); +_LIT8( KSdpvideoMLine, "m=video 0 RTP/AVP %d\r\n" ); +_LIT8( KSdpvideoAControlLine, + "a=control:rtsp://127.0.0.1/default.3gp/VideoControlAddress\r\n" ); +_LIT8( KDescribeReply, + "RTSP/1.0 200 OK\r\nCseq: %d\r\nContent-length: %d\r\n" + "Content-Type: application/sdp\r\n\r\n%S" ); +_LIT8( KSetupReply, + "RTSP/1.0 200 OKr\nCseq: %dr\nSession: 42\r\n" + "Transport: RTP/AVP;unicast;mode=play;client_port=%d-%d;" + "server_port=%d-%d\r\n\r\n" ); +_LIT8( KControlAddr,"VideoControlAddress" ); +_LIT8( KPlayReply, + "RTSP/1.0 200 OK\r\n" "Cseq: %d\r\n" + "RTP-Info: url=rtsp://127.0.0.1/default.3gp/VideoControlAddress" + ";seq=%u;rtptime=%u,url=rtsp://127.0.0.1/default.3gp/AudioControlAddress;" + "seq=%u;rtptime=%u\r\n" + "Session: 42\r\n" ); +_LIT8( KPlayReplyAudioOnly, + "RTSP/1.0 200 OK\r\n" "Cseq: %d\r\n" + "RTP-Info: url=rtsp://127.0.0.1/default.3gp/AudioControlAddress;" + "seq=%u;rtptime=%u\r\n" + "Session: 42\r\n" ); +_LIT8( KPlayReplyVideoOnly, + "RTSP/1.0 200 OK\r\n" "Cseq: %d\r\n" + "RTP-Info: url=rtsp://127.0.0.1/default.3gp/VideoControlAddress" + ";seq=%u;rtptime=%u\r\n" + "Session: 42\r\n" ); + +_LIT8( KPauseReply, "RTSP/1.0 %d OK\r\nCseq: %d\r\nSession: 42\r\n\r\n" ); +_LIT8( KTearDownReply, "RTSP/1.0 200 OK\r\nCseq: %d\r\nSession: 42\r\n\r\n" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRRtspSink::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRRtspSink* CCRRtspSink::NewL( + CCRConnection& aConnection, + RSocketServ& aSockServer, + CCRStreamingSession::TCRSinkId aSinkId, + const TInt& aLoopbackPort, + CCRStreamingSession& aOwningSession ) + { + CCRRtspSink* self = new( ELeave ) + CCRRtspSink( aConnection, aSockServer, aSinkId, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL( aLoopbackPort ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::CCRRtspSink +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRRtspSink::CCRRtspSink( + CCRConnection& aConnection, + RSocketServ& aSockServer, + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ) + : CCRPacketSinkBase( aOwningSession, aSinkId ), + iConnection( aConnection ), + iSockServer( aSockServer ), + iStage( ERTSPInit ), + iSetupReceived( 0 ), + iAudioSeq( KMaxTUint32 ), + iAudioTS( KMaxTUint32 ), + iVideoSeq( KMaxTUint32 ), + iVideoTS( KMaxTUint32 ), + iLowerRange( KRealZero ), + iUpperRange( KRealMinusOne ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ConstructL +// 2nd phase. +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ConstructL( const TInt& aLoopbackPort ) + { + iReceivedData = HBufC8::NewL( 0 ); + iRopResponse = HBufC8::NewL( 0 ); + iSockArr[EROPControl] = CCRSock::NewL( + *this, EROPControl, iConnection.Connection(), iSockServer, ETrue, ETrue ); + TInt err( iSockArr[EROPControl]->ListenPort( aLoopbackPort ) ); + LOG2( "CCRRtspSink::ConstructL(), aLoopbackPort: %d, err: %d", aLoopbackPort, err ); + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::~CCRRtspSink +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRRtspSink::~CCRRtspSink() + { + LOG( "CCRRtspSink::~CCRRtspSink()" ); + + for ( TInt i( 0 ); i < EROPMaxSockets; i++ ) + { + delete iSockArr[i]; iSockArr[i] = NULL; + } + for ( TInt i( 0 ); i < CCRRtspCommand::ERTSPCommandNOCOMMAND; i++ ) + { + delete iCommands[i]; iCommands[i] = NULL; + } + + delete iSdpForRop; + delete iSdpParser; + delete iRopResponse; + delete iReceivedData; + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ProduceSDPForRopL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ProduceSDPForRopL() + { + if ( !iSdpParser ) + { + User::Leave( KErrNotReady ); + } + + delete iSdpForRop; iSdpForRop = NULL; + iSdpForRop = HBufC8::NewL( KMaxName ); + + iSdpForRop->Des().Zero(); + AppendL( iSdpForRop, KVis0 ); + AppendL( iSdpForRop, KSdpOLine ); + AppendL( iSdpForRop, KSdpSLine ); + AppendL( iSdpForRop, KSdpCLine ); + AppendL( iSdpForRop, KSdpTLine ); + if ( ( iSdpParser->AudioBitrate() + iSdpParser->VideoBitrate() ) > 0 ) + { + AppendL( iSdpForRop, KSdpBLine ); + AppendNumL( iSdpForRop, iSdpParser->AudioBitrate() + + iSdpParser->VideoBitrate() ); + AppendL( iSdpForRop, KCRNewLine ); + } + + RArray &sessionAttributes = iSdpParser->SessionAttributes(); + for ( TInt i( 0 ); i < sessionAttributes.Count(); i++ ) + { + AppendL( iSdpForRop, sessionAttributes[i] ); + AppendL( iSdpForRop, KCRNewLine ); + } + + // Check whether audio exist. + if ( iSdpParser->AudioControlAddr().Length() ) + { + AppendFormatL( iSdpForRop, KSdpAudioMLine, iSdpParser->MediaIdentifierAudio() ); + if ( iSdpParser->AudioBitrate() > 0 ) + { + AppendL( iSdpForRop, KSdpBLine ); + AppendNumL( iSdpForRop, iSdpParser->AudioBitrate() ); + AppendL( iSdpForRop, KCRNewLine ); + } + + AppendL( iSdpForRop, KSdpAudioAControlLine ); + + RArray &audioAttributes = iSdpParser->AudioAttributes(); + for ( TInt i( 0 ); i < audioAttributes.Count(); i++ ) + { + AppendL( iSdpForRop, audioAttributes[i] ); + AppendL( iSdpForRop, KCRNewLine ); + } + } + + // Check whether Video exist. + if ( iSdpParser->VideoControlAddr().Length() ) + { + AppendFormatL( iSdpForRop, KSdpvideoMLine, iSdpParser->MediaIdentifierVideo() ); + if ( iSdpParser->VideoBitrate() > 0 ) + { + AppendL( iSdpForRop, KSdpBLine ); + AppendNumL( iSdpForRop, iSdpParser->VideoBitrate() ); + AppendL( iSdpForRop, KCRNewLine ); + } + + AppendL( iSdpForRop, KSdpvideoAControlLine ); + + RArray &videoAttributes = iSdpParser->VideoAttributes(); + for ( TInt i( 0 ); i < videoAttributes.Count(); i++ ) + { + AppendL( iSdpForRop, videoAttributes[i] ); + AppendL( iSdpForRop, KCRNewLine ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SetSdpL +// as a side-effect causes parsing of the sdp +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::SetSdpL( const TDesC8& aSdp ) + { + LOG1( "CCRRtspSink::SetSdpL(), aSdp len: %d", aSdp.Length() ); + + // Create SDP parser + delete iSdpParser; iSdpParser = NULL; + iSdpParser = CDvrSdpParser::NewL(); + iSdpParser->TryParseL( aSdp, KBaseUrl ); + ProduceSDPForRopL(); + + if ( iStage == ERTSPDescSent ) + { + ReplyToDescribeL(); + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::NewPacketAvailable +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::NewPacketAvailable() + { + if ( iBuffer ) + { + // Stream of next packet + MCRPacketSource::TCRPacketStreamId stream( + MCRPacketSource::EStreamIdCount ); + const TInt bookKeeping( iBuffer->GetStream( iSinkId, stream ) ); + + // Packets in buffer. + if ( stream != MCRPacketSource::EStreamIdCount ) + { + TCRROPSockId socket( SocketFromStream( stream ) ); + + // Is previous packet send ready. + + if ( iSockArr[socket] && !iSockArr[socket]->IsActive() ) + { + // Get packet + TPtr8 packet( NULL, 0 ); + iBuffer->GetPacket( bookKeeping, packet ); + + // Now we have the packet, send it to rop: + iSockArr[socket]->SendData( packet ); + + if ( iStage == ERTSPPlaySent ) + { + iStage = ERTSPPlaying; + } + + } + else + { + iPacketPendingInBuffer = ETrue; + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SetSeqAndTS +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::SetSeqAndTS( + TUint& aAudioSeq, + TUint& aAudioTS, + TUint& aVideoSeq, + TUint& aVideoTS ) + { + LOG1( "CRE ropsink SetSeqAndTS aseq=%u ", aAudioSeq ); + + iAudioSeq = aAudioSeq; + iAudioTS = aAudioTS; + iVideoSeq = aVideoSeq; + iVideoTS = aVideoTS; + iSeqAndTSSet = ETrue; + + if ( iStage == ERTSPReadyToPlay ) + { + TRAPD( err,ReplyToPlayL() ); + if ( err != KErrNone ) + { + LOG1( "CRE ropsink ReplyToPlayL L=%d", err ); + iOwningSession.SinkStops( Id() ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SetRange +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::SetRange( TReal aLower, TReal aUpper ) + { + LOG2( "CRE CCRRtspSink SetRange (%f - %f)", aLower, aUpper ); + iLowerRange = aLower; + iUpperRange = aUpper; + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::StatusChanged +// This is used currently for getting to know if we're in playing state or not +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::StatusChanged( MCRPacketSource::TCRPacketSourceState aNewState ) + { + LOG2( "CCRRtspSink::StatusChanged(), iStage: %d, aNewState: %d", iStage, aNewState ); + + if ( aNewState == MCRPacketSource::ERtpStateSetupRepply ) + { + if ( iStage == ERTSPDelayedSetup && iRopResponse->Length() > 0 ) + { + SendControlData(); + } + + iSetupReceived++; // SETUP repply received + } + else if ( aNewState == MCRPacketSource::ERtpStatePlaying ) + { + if ( iStage == ERTSPPlaySent || iStage == ERTSPReadyToPlay ) + { + iStage = ERTSPPlaying; + } + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::DataReceived +// +// This is called when data is received from socket. +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::DataReceived( TInt aSockId, const TDesC8 &aData ) + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + // Debug output follows + if ( aSockId == EROPControl ) + { + LOG2( "CCRRtspSink::DataReceived(), aSockId: %d, len: %d", + aSockId, aData.Length() ); + TName d( KNullDesC ); + for ( TInt i( 0 ); i < aData.Length(); i++ ) + { + TChar c( aData[i] ); + d.Append( c ); + if ( ( i > 0 ) && ( i % 80 ) == 0 ) + { + LOG1( ">%S<", &d ); + d.Zero(); + } + } + + LOG1( ">%S<", &d ); + } +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + switch ( aSockId ) + { + case EROPControl: // RTSP is spoken in this sock + { + TRAPD( err, HandleReceivedEROPControlL( aData ) ); + if ( KErrNone != err ) + { + LOG1( "ROPSink ProcessRtspCommandL leave %d", err ); + iOwningSession.SinkStops( Id() ); + } + } + break; + + case EROPVideoSend1: + case EROPVideoSend2: + case EROPAudioSend1: + case EROPAudioSend2: + { + // Those packets that rop sends to us we do not need actions + } + break; + + default: + { + LOG1( "default: Unknown aSockId: %d", aSockId ); + } + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::HandleReceivedEROPControlL +// +// This is called after received data from EROPControl socket. +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::HandleReceivedEROPControlL( const TDesC8& aData ) + { + AppendL( iReceivedData, aData ); + ProcessRtspCommandL(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SockStatusChange +// +// When socket status changes to something +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::SockStatusChange( + TInt aSockId, + CCRSock::TCRSockStatus aStatus, + TInt aError ) + { + if ( aStatus == CCRSock::EFailed ) + { + LOG3( "CCRRtspSink::SockStatusChange, id: %d, failure: %d, aError: %d", + aSockId, ( TInt )aStatus, aError ); + // here do DoCleanup() + iOwningSession.SinkStops( Id() ); + } + + if ( aSockId != EROPControl ) + { + // Delete used packet from buffer if the socket was udp packet socket + iBuffer->HandleBufferSize(); + + // Is there more packets to send. + if ( iPacketPendingInBuffer ) + { + NewPacketAvailable(); + iPacketPendingInBuffer = + ( iBuffer->PacketsCount( iSinkId ) > KErrNotFound ); + } + } + else + { + LOG3( "CCRRtspSink::SockStatusChange(), aSockId: %d, aStatus: %d, aError: %d", + aSockId, ( TInt )aStatus, aError ); + } + +#if !defined LIVE_TV_FILE_TRACE && !defined LIVE_TV_RDEBUG_TRACE + ( void )aError; +#endif + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ProcessRtspCommandL +// +// Causes parsing of command +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ProcessRtspCommandL() + { + LOG1( "CCRRtspSink::ProcessRtspCommandL(), iStage: %d", iStage ); + + CCRRtspCommand *command = CCRRtspCommand::NewL(); + CleanupStack::PushL( command ); + command->TryParseL( *iReceivedData ); + delete iCommands[command->Command()]; + iCommands[command->Command()] = command; + CleanupStack::Pop( command ); // it is now safely in instance variable + ProduceRtspReplyL( command->Command() ); + iReceivedData->Des().Zero(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ProduceRtspReplyL +// +// Causes sending of reply to rop +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ProduceRtspReplyL( CCRRtspCommand::TCommand aLastCommand ) + { + LOG2( "CCRRtspSink::ProduceRtspReplyL(), iStage: %d, aLastCommand: %d", + iStage, aLastCommand ); + + switch ( aLastCommand ) + { + case CCRRtspCommand::ERTSPCommandOPTIONS: + ReplyToOptionsL(); + break; + + case CCRRtspCommand::ERTSPCommandDESCRIBE: + if ( iSdpForRop ) + { + ReplyToDescribeL(); + } + + iStage = ERTSPDescSent; + break; + + case CCRRtspCommand::ERTSPCommandSETUP: + ReplyToSetupL(); + break; + + case CCRRtspCommand::ERTSPCommandPLAY: + if ( iSeqAndTSSet ) + { + // we've either audio or video seq set, we can proceed with play: + ReplyToPlayL(); + iStage = ERTSPPlaySent; + } + else + { + TReal startPos( KRealZero ); + TReal endPos( KRealZero ); + iCommands[CCRRtspCommand::ERTSPCommandPLAY]->GetRange( startPos, endPos ); + iOwningSession.PlayCommand( startPos, endPos ); + iStage = ERTSPReadyToPlay; + } + iSetupReceived = 0; + break; + + case CCRRtspCommand::ERTSPCommandPAUSE: + ReplyToPauseL( iStage != ERTSPPlaying ? KErrNotReady : iOwningSession.PauseCommand() ); + iSeqAndTSSet = EFalse; + break; + + case CCRRtspCommand::ERTSPCommandTEARDOWN: + iOwningSession.StopCommand(); + ReplyToTearDownL(); + break; + + default: + // None + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToOptionsL +// +// Causes sending of reply to rop for options +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToOptionsL() + { + LOG( "CCRRtspSink::ReplyToOptionsL()" ); + + iRopResponse->Des().Zero(); + AppendFormatL( iRopResponse, KCROptionsReply, + iCommands[CCRRtspCommand::ERTSPCommandOPTIONS]->CSeq() ); + SendControlData(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToDescribeL +// +// Causes sending of reply to rop for describe +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToDescribeL() + { + LOG( "CCRRtspSink::ReplyToDescribeL()" ); + + User::LeaveIfNull( iSdpForRop ); + iRopResponse->Des().Zero(); + AppendFormatL( iRopResponse, KDescribeReply, + iCommands[CCRRtspCommand::ERTSPCommandDESCRIBE]->CSeq(), + iSdpForRop->Des().Length(), &*iSdpForRop ); + SendControlData(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToSetupL +// +// Causes sending of reply to rop for setup, either audio or video +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToSetupL() + { + LOG( "CCRRtspSink::ReplyToSetupL()" ); + if ( !iSdpParser ) + { + User::Leave( KErrNotReady ); + } + + TPtrC8 url( NULL, 0 ); + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->URL( url ); + if ( url.Find( KControlAddr) != KErrNotFound ) + { + // ROP is setting up video + TInt videoPort( + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->ClientPort() ); + LOG1( "CCRRtspSink::ReplyToSetupL video port %d", videoPort ); + iStage = ERTSPSetupVideoSent; + + // Setup sockets: + iSockArr[EROPVideoSend1] = CCRSock::NewL( *this, EROPVideoSend1, + iConnection.Connection(), iSockServer, EFalse, ETrue ); + User::LeaveIfError( iSockArr[EROPVideoSend1]->ConnectSock( + KCRLocalIPAddr, videoPort, + KCCRRtspSinkDefaultServerPort ) ); + + iSockArr[EROPVideoSend2] = CCRSock::NewL( *this, EROPVideoSend2, + iConnection.Connection(), iSockServer, EFalse, ETrue ); + User::LeaveIfError( iSockArr[EROPVideoSend2]->ConnectSock( + KCRLocalIPAddr, videoPort + 1, + KCCRRtspSinkDefaultServerPort + 1 ) ); + } + else + { + // ROP is setting up audio + TInt audioPort( + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->ClientPort() ); + LOG1( "CCRRtspSink::ReplyToSetupL audio port: %d", audioPort ); + iStage = ERTSPSetupAudioSent; + + // Setup sockets: + iSockArr[EROPAudioSend1] = CCRSock::NewL( *this, EROPAudioSend1, + iConnection.Connection(), iSockServer, EFalse, ETrue ); + User::LeaveIfError( iSockArr[EROPAudioSend1]->ConnectSock( + KCRLocalIPAddr, audioPort, + KCCRRtspSinkDefaultServerPort + 2 ) ); + + iSockArr[EROPAudioSend2] = CCRSock::NewL( *this, EROPAudioSend2, + iConnection.Connection(), iSockServer, EFalse, ETrue ); + User::LeaveIfError( iSockArr[EROPAudioSend2]->ConnectSock( + KCRLocalIPAddr, audioPort + 1, + KCCRRtspSinkDefaultServerPort + 3 ) ); + } + + iRopResponse->Des().Zero(); + AppendFormatL( iRopResponse, KSetupReply, + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->CSeq(), + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->ClientPort(), + iCommands[CCRRtspCommand::ERTSPCommandSETUP]->ClientPort() + 1, + ( iStage == ERTSPSetupVideoSent )? KCCRRtspSinkDefaultServerPort: + KCCRRtspSinkDefaultServerPort + 2, + ( iStage == ERTSPSetupVideoSent )? KCCRRtspSinkDefaultServerPort + 1: + KCCRRtspSinkDefaultServerPort + 3 ); + + // If last setup, delay player response. Otherwise Helix will get prepare completed + // and sends automatically PLAY command which ruins the state machine + if ( iSetupReceived < 2 ) + { + CDvrSdpParser::TDvrPacketProvidings content( iSdpParser->SupportedContent() ); + if ( iStage == ERTSPSetupVideoSent ) + { + if ( ( iSetupReceived == 0 && content == CDvrSdpParser::EDvrVideoOnly ) || + ( iSetupReceived <= 1 && content == CDvrSdpParser::EDvrBothAudioAndVideo ) ) + { + iStage = ERTSPDelayedSetup; + LOG( "CCRRtspSink::ReplyToSetupL(), Video SETUP repply delayed.." ); + } + } + else + { + if ( ( iSetupReceived == 0 && content == CDvrSdpParser::EDvrAudioOnly ) || + ( iSetupReceived <= 1 && content == CDvrSdpParser::EDvrBothAudioAndVideo ) ) + { + iStage = ERTSPDelayedSetup; + LOG( "CCRRtspSink::ReplyToSetupL(), Audio SETUP repply delayed.." ); + } + } + } + + // Repply now or later + if ( iStage != ERTSPDelayedSetup ) + { + SendControlData(); + } + } + + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToPlayL +// +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToPlayL() + { + LOG( "CCRRtspSink::ReplyToPlayL()" ); + + iRopResponse->Des().Zero(); + if ( iSdpParser->AudioControlAddr().Length() && + iSdpParser->VideoControlAddr().Length() ) + { + AppendFormatL( iRopResponse, KPlayReply, + iCommands[CCRRtspCommand::ERTSPCommandPLAY]->CSeq(), + iVideoSeq, iVideoTS, iAudioSeq, iAudioTS ); + } + else if ( iSdpParser->AudioControlAddr().Length() && + !iSdpParser->VideoControlAddr().Length() ) + { + AppendFormatL( iRopResponse, KPlayReplyAudioOnly, + iCommands[CCRRtspCommand::ERTSPCommandPLAY]->CSeq(), + iAudioSeq, iAudioTS ); + } + else if ( !iSdpParser->AudioControlAddr().Length() && + iSdpParser->VideoControlAddr().Length() ) + { + AppendFormatL( iRopResponse, KPlayReplyVideoOnly, + iCommands[CCRRtspCommand::ERTSPCommandPLAY]->CSeq(), + iVideoSeq, iVideoTS ); + } + else + { // no audio, no video. + iOwningSession.SinkStops( Id() ); + return; + } + + if ( !( iLowerRange == KRealZero && iUpperRange == KRealMinusOne ) ) + { + TBuf8 buf( KCRRangeHeader ); + TRealFormat format( 10, 3 ); + format.iTriLen = 0; + buf.AppendNum( iLowerRange, format ); + buf.Append( '-' ); + buf.AppendNum( iUpperRange, format ); + buf.Append( KCRNewLine ); + AppendFormatL( iRopResponse, buf ); + } + + AppendL( iRopResponse, KCRNewLine ); + SendControlData(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToPlayL +// +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToPauseL( TInt aErrorCode ) + { + LOG1( "CCRRtspSink::ReplyToPauseL(), aErrorCode: %d", aErrorCode ); + + iRopResponse->Des().Zero(); + + switch ( aErrorCode ) + { + case KErrNone: + AppendFormatL( iRopResponse, KPauseReply, + CCRRtspResponse::ERTSPRespOK, + iCommands[CCRRtspCommand::ERTSPCommandPAUSE]->CSeq() ); + iStage = ERTSPPauseSent; + break; + + case KErrNotReady: + AppendFormatL( iRopResponse, KPauseReply, + CCRRtspResponse::ERTSPRespMethodNotValidInThisState, + iCommands[CCRRtspCommand::ERTSPCommandPAUSE]->CSeq() ); + break; + + default: + AppendFormatL( iRopResponse, KPauseReply, + CCRRtspResponse::ERTSPRespMethodNotAllowed, + iCommands[CCRRtspCommand::ERTSPCommandPAUSE]->CSeq() ); + break; + } + + SendControlData(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::ReplyToTearDownL +// +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::ReplyToTearDownL() + { + LOG( "CCRRtspSink::ReplyToTearDownL()" ); + + iRopResponse->Des().Zero(); + AppendFormatL( iRopResponse, KTearDownReply, + iCommands[CCRRtspCommand::ERTSPCommandTEARDOWN]->CSeq() ); + SendControlData(); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SocketFromStream +// +// ----------------------------------------------------------------------------- +// +CCRRtspSink::TCRROPSockId CCRRtspSink::SocketFromStream( + MCRPacketSource::TCRPacketStreamId aStreamId ) + { + switch ( aStreamId ) + { + case MCRPacketSource::EAudioStream: + return EROPAudioSend1; + + case MCRPacketSource::EAudioControlStream: + return EROPAudioSend2; + + case MCRPacketSource::EVideoStream: + return EROPVideoSend1; + + case MCRPacketSource::EVideoControlStream: + return EROPVideoSend2; + + default: + __ASSERT_ALWAYS( 1!=2, User::Panic( KCCRRtspSink, KErrArgument ) ); + break; + } + + return EROPMaxSockets; // this is never reached + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::AppendL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::AppendL( HBufC8*& aBuffer, const TDesC8& aStr ) + { + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + aStr.Length() ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + aStr.Length() + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.Append( aStr ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::AppendNumL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::AppendNumL( HBufC8*& aBuffer, const TInt aNum ) + { + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + KMaxInfoName ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + KMaxInfoName + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.AppendNum( aNum ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::AppendFormatL +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::AppendFormatL( + HBufC8*& aBuffer, + TRefByValue aFmt, ... ) + { + VA_LIST list; + VA_START( list, aFmt ); + HBufC8* buf = HBufC8::NewLC( KMaxDataSize ); + buf->Des().FormatList( aFmt, list ); + VA_END( list ); + + TPtr8 ptr( aBuffer->Des() ); + if ( ( ptr.Length() + buf->Length() ) >= ptr.MaxLength() ) + { + const TInt newLength( ptr.Length() + buf->Length() + KMaxName ); + aBuffer = aBuffer->ReAllocL( newLength ); + ptr.Set( aBuffer->Des() ); + } + + ptr.Append( *buf ); + CleanupStack::PopAndDestroy( buf ); + } + +// ----------------------------------------------------------------------------- +// CCRRtspSink::SendControlData +// +// ----------------------------------------------------------------------------- +// +void CCRRtspSink::SendControlData() + { + iSockArr[EROPControl]->SendData( *iRopResponse ); + iRopResponse->Des().Zero(); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRServer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRServer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,392 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of CR servers server class* +*/ + + + + +// INCLUDE FILES +#include "CCRServer.h" +#include "CCRSession.h" +#include "CCREngine.h" +#include // Constants exported from client library +#include +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// Platform security. Custom check is applied to all IPCs. +static const int KRangeCount( 1 ); + +static const TInt SecurityRanges[KRangeCount] = + { + 0, // Range is from 0 to KMaxTInt + }; + +static const TUint8 SecurityRangesPolicy[KRangeCount] = + { + CPolicyServer::ECustomCheck + }; + +static const CPolicyServer::TPolicy Policy = + { + CPolicyServer::EAlwaysPass, + KRangeCount, + SecurityRanges, + SecurityRangesPolicy, + NULL, + }; + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRServer::NewLC() +// +// ----------------------------------------------------------------------------- +// +CCRServer* CCRServer::NewLC( ) + { + CCRServer* self = new( ELeave ) CCRServer; + CleanupStack::PushL( self ); + self->ConstructL( ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRServer::CCRServer() +// C++ constructor +// ----------------------------------------------------------------------------- +// +CCRServer::CCRServer() + : CPolicyServer( EPriorityRealTimeServer, Policy, ESharableSessions ), + iSessionCount( 0 ) + { + __DECLARE_NAME( _S( "CCRServer" ) ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::ConstructL() +// second-phase constructor; create the object container index. +// ----------------------------------------------------------------------------- +// +void CCRServer::ConstructL( ) + { + LOG( "CCRServer::ConstructL()" ); + + iContainerIx = CObjectConIx::NewL(); + iObjectCon = iContainerIx->CreateL(); + + StartL( KCRServerNameExe ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::~CCRServer() +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRServer::~CCRServer() + { + LOG( "CCRServer::~CCRServer()" ); + + DeleteRtpEngine(); + } + +// ----------------------------------------------------------------------------- +// CCRServer::ThreadFunction() +// The active scheduler is installed and started here. +// ----------------------------------------------------------------------------- +// +TInt CCRServer::ThreadFunction( ) + { + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + if ( !cleanupStack ) + { + PanicServer( KErrNoMemory ); + } + + TRAPD( err, ThreadFunctionL( ) ); + if ( err ) + { + PanicServer( KErrServerTerminated ); + } + + delete cleanupStack; + cleanupStack = NULL; + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRServer::ThreadFunctionL() +// +// ----------------------------------------------------------------------------- +// +void CCRServer::ThreadFunctionL( ) + { + LOG( "CCRServer::ThreadFunctionL() - In" ); + + // Construct active scheduler + CActiveScheduler* activeScheduler = new ( ELeave ) CActiveScheduler; + CleanupStack::PushL( activeScheduler ); // |-> 1 + + // Install active scheduler. + // We don't need to check whether an active scheduler is already installed + // as this is a new thread, so there won't be one + CActiveScheduler::Install( activeScheduler ); + + // Construct our server, pushed cleanup stack and leaved there + CCRServer* server = CCRServer::NewLC( ); // |-> 2 + + // Signal server is up + RProcess::Rendezvous( KErrNone ); + + // Start handling requests + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy( server ); // 2<-| + CleanupStack::PopAndDestroy( activeScheduler ); // 1<-| + + LOG( "CCRServer::ThreadFunctionL() - Out" ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::SignalClientL +// Signal the client that server is running. +// ----------------------------------------------------------------------------- +void CCRServer::SignalClientL() + { + RSemaphore semaphore; + User::LeaveIfError( semaphore.OpenGlobal( KCRServerSemaphoreName ) ); + semaphore.Signal(); + semaphore.Close(); + } + +// ----------------------------------------------------------------------------- +// CCRServer::PanicServer +// Utility - panic the server +// ----------------------------------------------------------------------------- +void CCRServer::PanicServer( TInt aPanic ) + { + LOG1( "CCRServer::PanicServer(), aPanic: %d", aPanic ); + + User::Panic( KCRServerNameExe, aPanic ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::GetEngineObjectL() +// +// ----------------------------------------------------------------------------- +// +CCREngine* CCRServer::GetEngineObjectL() + { + if ( iObjectCon->Count() == 0 ) + { + // Create CR engine + iEngine = CCREngine::NewL( ); + + // Add our engine to container + iObjectCon->AddL( iEngine ); + } + else + { + // default implementation return KErrNone. + if ( KErrNone != iEngine->Open() ) + { + User::Leave( KErrGeneral ); + } + } + + // We have only one object in our container + return iEngine; + } + +// ----------------------------------------------------------------------------- +// CCRServer::Inc() +// +// ----------------------------------------------------------------------------- +// +void CCRServer::Inc() + { + iSessionCount++; + LOG1( "CCRServer::Inc(), New iSessionCount: %d", iSessionCount ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::Dec() +// +// ----------------------------------------------------------------------------- +// +void CCRServer::Dec() + { + iSessionCount--; + LOG1( "CCRServer::Dec(), New iSessionCount: %d", iSessionCount ); + + if ( iSessionCount <= 0 ) + { + StopServer(); + } + } + +// ----------------------------------------------------------------------------- +// CCRServer::NewSessionL() +// +// ----------------------------------------------------------------------------- +// +CSession2* CCRServer::NewSessionL( + const TVersion& aVersion, + const RMessage2& /*aMessage*/ ) const + { + // Check version is ok + TVersion v( KCRServMajorVersionNumber, + KCRServMinorVersionNumber, + KCRServBuildVersionNumber ); + + if ( !User::QueryVersionSupported( v, aVersion ) ) + { + User::Leave( KErrNotSupported ); + } + + // Make new session + return CCRSession::NewL( ( CCRServer* ) this ); + } + +// ----------------------------------------------------------------------------- +// CCRServer::StopServer +// Stops the server thread if no sessions active. +// ----------------------------------------------------------------------------- +// +void CCRServer::StopServer() + { + LOG( "CCRServer::StopServer()" ); + + CActiveScheduler::Stop(); + } + +// ----------------------------------------------------------------------------- +// CCRServer::DeleteRtpEngine +// Stops active scheduler and deletes object container and other objects. +// ----------------------------------------------------------------------------- +// +void CCRServer::DeleteRtpEngine() + { + LOG1( "CCRServer::DeleteRtpEngine(), iContainerIx: %d", iContainerIx ); + + if ( iContainerIx ) + { + iContainerIx->Remove( iObjectCon ); + delete iContainerIx; iContainerIx = NULL; + } + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// StartThread() +// Start the server thread. This is called from the client. +// ----------------------------------------------------------------------------- +// +TInt CCRServer::StartThread() + { +#ifdef _DEBUG + __UHEAP_MARK; +#endif + + LOG( "CCRServer::StartThread() - In" ); + // Check server not already started + TFindServer findCountServer( KCRServerNameExe ); + TFullName name; + if ( findCountServer.Next( name ) == KErrNone ) + { + // Found server already + TRAP_IGNORE( CCRServer::SignalClientL() ); + return KErrAlreadyExists; + } + + ThreadFunction( ); + + LOG( "CCRServer::StartThread() - Out" ); + +#ifdef _DEBUG + __UHEAP_MARKEND; +#endif + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// E32Main() +// Server startup +// Returns: KErrNone +// ----------------------------------------------------------------------------- +// +GLDEF_C TInt E32Main() + { + return CCRServer::StartThread(); + } + +// -------------------------------------------------------------------------- +// CCRServer::CustomSecurityCheckL() +// -------------------------------------------------------------------------- +// +CPolicyServer::TCustomResult CCRServer::CustomSecurityCheckL( + const RMessage2& aMsg, + TInt& /*aAction*/, + TSecurityInfo& /*aMissing*/ ) + { + + TCustomResult retVal ( EFail ); + + // Check the messagge function range + if ( ( aMsg.Function() > ECRServBase && + aMsg.Function() < ECRServLastEnum ) || + ( aMsg.Function() > ECRLiveTvBase && + aMsg.Function() < ECRLiveTvLastEnum ) ) + { + // Check if the client has required capabilities + // From .mmp-file following are CAP_APPLICATION capabilities + if( ! aMsg.HasCapability(ECapabilityNetworkServices ) || + ! aMsg.HasCapability(ECapabilityLocalServices ) || + ! aMsg.HasCapability(ECapabilityLocation ) || + ! aMsg.HasCapability(ECapabilityReadUserData ) || + ! aMsg.HasCapability(ECapabilityWriteUserData ) || + ! aMsg.HasCapability(ECapabilityReadDeviceData ) || + ! aMsg.HasCapability(ECapabilityWriteDeviceData ) || + ! aMsg.HasCapability(ECapabilitySwEvent ) ) + { + LOG1( + "CCRServer::CustomSecurityCheckL() No capability for message %d!!!", + aMsg.Function() ); + } + else + { + LOG1( + "CCRServer::CustomSecurityCheckL() Message %d inside range and capabilities ok", + aMsg.Function() ); + retVal = EPass; + } + } + else + { + LOG1( + "CCRServer::CustomSecurityCheckL() Message %d outside known range!!!", + aMsg.Function() ); + } + + return retVal; + + } +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRSession.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RBF server's CCRSession class* +*/ + + + + +// INCLUDE FILES +#include "CCRSession.h" +#include "CCRServer.h" +#include "CCREngine.h" +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRSession::CCRSession() +// C++ constructor +// ----------------------------------------------------------------------------- +// +CCRSession::CCRSession() : CSession2(), iResourceCount( 0 ) + { + __DECLARE_NAME( _S( "CCRSession" ) ); + } + +// ----------------------------------------------------------------------------- +// CCRSession::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRSession* CCRSession::NewL( CCRServer* aServer ) + { + CCRSession* self = new( ELeave ) CCRSession(); + CleanupStack::PushL( self ); + self->ConstructL( aServer ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRSession::ConstructL() +// second-phase C++ constructor +// ----------------------------------------------------------------------------- +// +void CCRSession::ConstructL( CCRServer* aServer ) + { + LOG( "CCRSession::ConstructL" ); + + aServer->Inc(); + // Create new object index + iObjects = CObjectIx::NewL(); + } + +// ----------------------------------------------------------------------------- +// CCRSession::~CCRSession() +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRSession::~CCRSession() + { + LOG( "CCRSession::~CCRSession" ); + + // Deletes objects + delete iObjects; + } + +// ----------------------------------------------------------------------------- +// CCRSession::ServiceL() +// ----------------------------------------------------------------------------- +// +void CCRSession::ServiceL( const RMessage2& aMessage ) + { + switch ( aMessage.Function() ) + { + case ECRServCreateSubSession: + case ECRServCloseSubSession: + case ECRServCloseSession: + { + LOG1( "CCRSession::ServiceL(), aMessage: %d", aMessage.Function() ); + TRAPD( err, DispatchMessageL( aMessage ) ); + aMessage.Complete( err ); + } + break; + + default: + { + // Ok, but must be subsession relative + CCREngine* engine = ( CCREngine* )iObjects->At( aMessage.Int3() ); + if ( engine == NULL ) + { + LOG( "CCRSession::ServiceL(), Null engine !" ); + aMessage.Complete( KErrBadHandle ); + PanicClient( KErrBadHandle ); + } + else + { + // this is the normal route, + // all engine commands go this way + engine->GeneralServiceL( aMessage ); + } + } + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRSession::DispatchMessageL() +// ----------------------------------------------------------------------------- +// +void CCRSession::DispatchMessageL( const RMessage2& aMessage ) + { + // Check for session-relative requests + switch ( aMessage.Function() ) + { + case ECRServCreateSubSession: + NewObjectL( aMessage ); + break; + + case ECRServCloseSubSession: + DeleteObject( aMessage.Int3() ); + break; + + case ECRServCloseSession: + Server()->Dec(); + break; + + default: + // None + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRSession::NewObjectL() +// +// ----------------------------------------------------------------------------- +// +void CCRSession::NewObjectL( const RMessage2& aMessage ) + { + LOG( "CCRSession::NewObjectL() in" ); + + CObject* obj = Server()->GetEngineObjectL(); + TInt handle( iObjects->AddL( obj ) ); + LOG1( "CCRSession::NewObjectL(), handle: %d", handle ); + + // Write the handle to client + TPckg handlePckg( handle ); + TRAPD( err, aMessage.WriteL( 3, handlePckg ) ); + if ( err ) + { + PanicClient( KErrBadDescriptor ); + return; + } + + // Notch up another resource + iResourceCount++; + LOG1( "CCRSession::NewObjectL() out, iResourceCount: %d", iResourceCount ); + } + +// ----------------------------------------------------------------------------- +// CCRSession::DeleteObject() +// ----------------------------------------------------------------------------- +// +void CCRSession::DeleteObject( TUint aHandle ) + { + LOG1( "CCRSession::DeleteObject() in, aHandle: %u", aHandle ); + + // Panic if bad handle + CCREngine* engine = ( CCREngine* )iObjects->At( aHandle ); + if ( engine == NULL ) + { + PanicClient( KErrNotFound ); + } + + // Deletes engine + iResourceCount--; + iObjects->Remove( aHandle ); + + LOG1( "CCRSession::DeleteObject() out, iResourceCount: %d", iResourceCount ); + } + +// ----------------------------------------------------------------------------- +// CCRSession::CountResources() +// +// ----------------------------------------------------------------------------- +// +TInt CCRSession::CountResources() + { + return iResourceCount; + } + +// ----------------------------------------------------------------------------- +// CCRSession::PanicClient() +// ----------------------------------------------------------------------------- +// +void CCRSession::PanicClient( TInt aPanic ) const + { + _LIT( KTxtSessionPanic, "RbfSession" ); + User::Panic( KTxtSessionPanic, aPanic ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRSock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRSock.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,913 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Handles tcp/udp socket* +*/ + + + + +// INCLUDE FILES +#include "CCRSock.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +_LIT( KCRSockLocalhost, "127.0.0.1" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRSock::CCRSock +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRSock::CCRSock( + MCRSockObserver& aObserver, + TInt aSockId, + RConnection& aConnection, + RSocketServ& aSockServer, + TBool aProtoTCP, + TBool aIssueRead ) + : CActive( CActive::EPriorityStandard ), + iSockServer( aSockServer ), + iSockStatus( CCRSock::EInitNeeded ), + iObserver( aObserver ), + iSockId( aSockId ), + iProtoTCP( aProtoTCP ), + iIssueRead( aIssueRead ), + iReceivedData( NULL, 0 ), + iSentData( NULL, 0 ), + iConnection( aConnection ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRSock::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRSock* CCRSock::NewL( + MCRSockObserver& aObserver, + TInt aSockId, + RConnection& aConnection, + RSocketServ& aSockServer, + TBool aProtoTCP, + TBool aIssueRead ) + { + CCRSock* self = new( ELeave ) CCRSock( aObserver, aSockId, aConnection, + aSockServer, aProtoTCP, aIssueRead ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRSock::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRSock::ConstructL() + { + LOG( "CCRSock::ConstructL() in" ); + + iReceivedDataBuf = HBufC8::NewL( KMaxDataSize ); + iReceivedData.Set( iReceivedDataBuf->Des() ); + iSentDataBuf = HBufC8::NewL( KMaxDataSize ); + iSentData.Set( iSentDataBuf->Des() ); + + // Add self to active scheduler + CActiveScheduler::Add( this ); + if ( iIssueRead ) + { + iReader = CCRSockReader::NewL( *this, iConnection, iSockServer ); + } + + iToAddr.SetPort( 0 ); + + LOG( "CCRSock::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::~CCRSock +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRSock::~CCRSock() + { + LOG( "CCRSock::~CCRSock()" ); + + CleanUp(); + delete iReader; + delete iSentDataBuf; + delete iReceivedDataBuf; + } + + +// ----------------------------------------------------------------------------- +// CCRSock::RunL +// "Brain" +// ----------------------------------------------------------------------------- +// +void CCRSock::RunL() + { + TInt err( KErrNone ); + + if ( iStatus == KErrEof && iWasListening ) + { + iSocket.Close(); + err = iSocket.Open( iSockServer ); + if ( err == KErrNone ) + { + LOG1( "CCRSock::RunL(), reopening sock: %d for listen", iSockId ); + iIsiSocketOpen = ETrue; + iListenSocket.Accept( iSocket, iStatus ); + iSockStatus = CCRSock::EListening; + SetActive(); + } + else + { + LOG2( "CCRSock::RunL(), iSocket.Open FAILED id: %d err: %d", + iSockId, err ); + } + } + else + { + switch ( iSockStatus ) + { + case EResolving: // in connection, this is usually 1st time to come to RunL + if ( iStatus == KErrNone ) + { // host name found + iHostAddress().iAddr.SetPort( iPort ); + iSocket.Close(); + err = iSocket.Open( iSockServer, + KAfInet, + iProtoTCP ? KSockStream : KSockDatagram, + iProtoTCP ? KProtocolInetTcp : KProtocolInetUdp, + iConnection ) ; + if ( err ) + { + iSockStatus = CCRSock::EFailed; + iObserver.SockStatusChange( iSockId, iSockStatus, err ); + iResolver.Close(); + LOG2( "CCRSock::RunL(), iSockId: %d, err: %d", iSockId, err ); + } + else + { + iIsiSocketOpen = ETrue; + if ( iLocalPort > 0 ) + { + TInetAddr bindAddr( KInetAddrAny, iLocalPort ); + err = iSocket.Bind( bindAddr ); + if ( err != KErrNone ) + { + LOG2( "CCRSock::ConnectSock(), Bind FAILED, Id: %d, err %d", iSockId, err ); + } + } + + LOG2( "CCRSock::RunL(), iSockId: %d, port: %d", + iSockId, iHostAddress().iAddr.Port() ); + iSocket.Connect( iHostAddress().iAddr, iStatus ); + iToAddr = iHostAddress().iAddr; + err = iSocket.SetOpt( KSOBlockingIO, KSOLSocket); + if ( err != KErrNone ) + { + LOG1( "CCRSock::RunL(), iSocket.SetOpt FAILED: %d", err ); + } + iSockStatus = CCRSock::EConnecting; + iObserver.SockStatusChange( iSockId, iSockStatus, err ); + SetActive(); + iResolver.Close(); + } + } + else + { // resolving not ok + iSockStatus = CCRSock::EFailed; + iObserver.SockStatusChange( iSockId, iSockStatus, iStatus.Int() ); + iResolver.Close(); + } + break; + + case EConnecting: + if ( iStatus == KErrNone ) // success + { + iSockStatus = CCRSock::EIdle; + // next action is up to user, don't do SetActive here. + LOG1( "CCRSock::RunL(), iSockId: %d", iSockId ); + + if ( iIssueRead && iReader && ( !iReader->IsActive() ) ) + { + iReader->IssueRead(); + } + } + else + { + iSockStatus = CCRSock::EFailed; + iObserver.SockStatusChange( iSockId, iSockStatus, iStatus.Int() ); + CleanUp(); /* close everything */ + } + iObserver.SockStatusChange( iSockId, iSockStatus, iStatus.Int() ); + break; + + case ESending: + // send has been finished,somehow: + if ( iStatus == KErrNone ) // success + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + sendBytes += iSentDataLen(); + sendCount ++; + if ( ( sendCount % 50 ) == 0 ) + { + LOG3( "CCRSock::RunL(), sendCount: %d, sendBytes: %d, iSockId: %d", + sendCount, sendBytes, iSockId ); + } +#endif + iSockStatus = CCRSock::EIdle; + // next action is up to user, don't do SetActive here. + } + else + { + iSockStatus = CCRSock::EFailed; + CleanUp(); /* close everything */ + } + iObserver.SockStatusChange( iSockId, iSockStatus, iStatus.Int() ); + break; + + case EListening: + if ( iStatus == KErrNone ) // success, da zocket is open + { + iSockStatus = CCRSock::EIdle; + if ( iIssueRead && iReader && ( !iReader->IsActive() ) ) + { + iReader->IssueRead(); + } + } + else + { + iSockStatus = CCRSock::EFailed; + CleanUp(); /* close everything */ + } + iObserver.SockStatusChange( iSockId, iSockStatus, iStatus.Int() ); + break; + + default: + __ASSERT_DEBUG( 1==2, User::Panic( _L("CRRTP"), KErrArgument) ); + break; /* this should not happend? */ + } + } + } + +// ----------------------------------------------------------------------------- +// CCRSock::DoCancel +// Cancels pending actions +// ----------------------------------------------------------------------------- +// +void CCRSock::DoCancel() + { + LOG( "CCRSock::DoCancel() in" ); + if ( iIsiSocketOpen ) + { + iSocket.CancelAll(); + } + if ( iIsiListenSocketOpen ) + { + iListenSocket.CancelAll(); + } + + LOG( "CCRSock::DoCancel() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::CopySendData +// Handles send buffer size. +// ----------------------------------------------------------------------------- +// +void CCRSock::CopySendData( const TDesC8& aData ) + { + if ( aData.Length() > iSentData.MaxLength() ) + { + // Alloc more than 8k + delete iSentDataBuf; iSentDataBuf = NULL; + iSentDataBuf = HBufC8::New( aData.Length() ); + iSentData.Set( iSentDataBuf->Des() ); + } + else + { + if ( iSentData.MaxLength() > KMaxDataSize && + aData.Length() <= KMaxDataSize ) + { + // Back to 8k if not more needed + delete iSentDataBuf; iSentDataBuf = NULL; + iSentDataBuf = HBufC8::New( KMaxDataSize ); + iSentData.Set( iSentDataBuf->Des() ); + } + } + + iSentData.Copy( aData ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::CleanUp +// Performs cleanup +// ----------------------------------------------------------------------------- +// +void CCRSock::CleanUp() + { + LOG( "CCRSock::CleanUp() in" ); + Cancel(); + + iResolver.Close(); + iSocket.Close(); + iListenSocket.Close(); + iSockStatus = CCRSock::EInitNeeded; + + iIsiSocketOpen = EFalse; + iIsiListenSocketOpen = EFalse; + LOG( "CCRSock::CleanUp() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::RunError +// Q: Is anything wrong +// A: Thanks for asking. About everything. +// ----------------------------------------------------------------------------- +// +TInt CCRSock::RunError( TInt aError ) + { + LOG1( "CCRSock::RunError(), aError: %d", aError ); + ( void )aError; // Prevent compiler warning + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRSock::ConnectSock +// Initiates connection to remote addr. +// ----------------------------------------------------------------------------- +// +TInt CCRSock::ConnectSock( + const TDesC& aAddr, + TUint aPort, + TInt aLocalPort ) + { + LOG( "CCRSock::ConnectSock()" ); + + TInt retval( KErrNone ); + if ( IsActive() ) + { + retval = KErrInUse; + } + else + { + iWasListening = EFalse; + iPort = aPort; + iLocalPort = aLocalPort; + if ( aAddr.Compare( KCRSockLocalhost() ) != 0 ) + { + iResolver.Close(); + if ( (retval = iResolver.Open( iSockServer, KAfInet, + KProtocolInetTcp, iConnection) ) == KErrNone ) + { + iResolver.GetByName( aAddr, iHostAddress, iStatus ); + iSockStatus = CCRSock::EResolving; + SetActive(); + } + else + { + LOG2( "CCRSock::ConnectSock(), Resolver.Open id: %d, err: %d", + iSockId, retval ); + iSockStatus = CCRSock::EFailed; + } + } + else + { // localhost, no need to resolve + iHostAddress().iAddr.SetPort( iPort ); + iSocket.Close(); + retval = iSocket.Open( iSockServer, + KAfInet, + iProtoTCP ? KSockStream : KSockDatagram, + iProtoTCP ? KProtocolInetTcp : KProtocolInetUdp, + iConnection ) ; + if ( retval ) + { + LOG2( "CCRSock::ConnectSock(), Socket.Open id: %d, err: %d", + iSockId, retval ); + iSockStatus = CCRSock::EFailed; + } + else + { + iIsiSocketOpen = ETrue; + iSockStatus = CCRSock::EConnecting; + if ( aLocalPort > 0 ) + { + TInetAddr bindAddr( KInetAddrAny, aLocalPort ); + TInt err( iSocket.Bind( bindAddr ) ); + if ( err != KErrNone ) + { + LOG2( "CCRSock::ConnectSock(), Bind FAILED iSockId: %d, err: %d", + iSockId, err ); + } + } + iToAddr = TInetAddr( KInetAddrLoop, aPort ); + LOG2( "CCRSock::ConnectSock(), iSockId %d port %d", + iSockId, aPort ); + iSocket.Connect( iToAddr, iStatus ); + SetActive(); + if ( iProtoTCP ) + { + retval = iSocket.SetOpt( KSOBlockingIO, KSOLSocket ); + } + iObserver.SockStatusChange( iSockId, iSockStatus, retval ); + } + } + } + + LOG1( "CCRSock::ConnectSock(), retVal: %d", retval ); + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRSock::ConnectSock +// Initiates connection to remote addr without resolving. +// ----------------------------------------------------------------------------- +// +TInt CCRSock::ConnectSock( + const TSockAddr& aAddr, + TInt aLocalPort ) + { + LOG( "CCRSock::ConnectSock(), no dns" ); + + TInt retval( KErrNone ); + if ( IsActive() ) + { + retval = KErrInUse; + } + else + { + iWasListening = EFalse; + iPort = aAddr.Port(); + iLocalPort = aLocalPort; + iHostAddress().iAddr = aAddr; + iSocket.Close(); + retval = iSocket.Open( iSockServer, + KAfInet, + iProtoTCP ? KSockStream : KSockDatagram, + iProtoTCP ? KProtocolInetTcp : KProtocolInetUdp, + iConnection ) ; + if ( retval ) + { + LOG2( "CCRSock::ConnectSock(), Socket.Open id: %d, err: %d", + iSockId, retval ); + iSockStatus = CCRSock::EFailed; + } + else + { + iIsiSocketOpen = ETrue; + iSockStatus = CCRSock::EConnecting; + if ( aLocalPort > 0 ) + { + TInetAddr bindAddr( KInetAddrAny, aLocalPort ); + TInt err( iSocket.Bind( bindAddr ) ); + if ( err != KErrNone ) + { + LOG2( "CCRSock::ConnectSock(), Bind FAILED id: %d err: %d", + iSockId, err ); + } + } + iToAddr = aAddr; + LOG2( "CCRSock::ConnectSock(), id: %d, port: %d", iSockId, iPort ); + iSocket.Connect( iToAddr, iStatus ); + SetActive(); + if ( iProtoTCP ) + { + retval = iSocket.SetOpt( KSOBlockingIO, KSOLSocket ); + } + iObserver.SockStatusChange( iSockId, iSockStatus, retval ); + } + } + + LOG1( "CCRSock::ConnectSock(), retVal: %d", retval ); + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRSock::ListenPort +// Starts listening to port. Synchronous. +// ----------------------------------------------------------------------------- +// +TInt CCRSock::ListenPort( TUint aPort ) + { + LOG1( "CCRSock::ListenPort(), aPort: %d", aPort ); + + TInt retval( KErrNone ); + if ( IsActive() ) + { + return KErrInUse; + } + if ( iSockStatus != CCRSock::EInitNeeded ) + { + return KErrNotReady; + } + + iHostAddress().iAddr.SetPort( iPort ); + iWasListening = ETrue; + if ( iProtoTCP ) + { + iListenSocket.Close(); + if ( ( retval = iListenSocket.Open( iSockServer, KAfInet, + KSockStream, KProtocolInetTcp, iConnection ) ) == KErrNone ) + { + iIsiListenSocketOpen = ETrue; + TInetAddr listenAddr( KInetAddrAny, aPort ); + LOG2( "CCRSock::ListenPort(), id: %d, port: %d", iSockId,(TInt)aPort); + retval = iListenSocket.Bind( listenAddr ); + if ( retval == KErrNone ) + { + retval = iListenSocket.Listen( 5 ); + if ( retval == KErrNone ) + { + iSocket.Close(); + retval = iSocket.Open( iSockServer ); + if ( retval == KErrNone ) + { + iIsiSocketOpen = ETrue; + iListenSocket.Accept( iSocket, iStatus ); + iSockStatus = CCRSock::EListening; + SetActive(); + } + else + { + LOG1( "CCRSock::ListenPort(), iSocket.Open FAILED retval: %d", retval ); + } + } + else + { + LOG1( "CCRSock::ListenPort(), iListenSock.Listen FAILED retval: %d", retval ); + } + } + else + { + LOG2( "CCRSock::ListenPort() iListenSocket.Bind FAILED Id: %d, retval: %d", iSockId, retval); + } + } + else + { + LOG2( "ListenSocket.Open id: %d, err: %d", iSockId, retval ); + } + } + else + { + // for UDP things are different: just open, bind + iSocket.Close(); + if ( ( retval = iSocket.Open( iSockServer, + KAfInet, + KSockDatagram, + KProtocolInetUdp, + iConnection ) ) != KErrNone ) + { + iSockStatus = CCRSock::EFailed; + LOG2( "CCRSock::ListenPort(), UDPSocket.Open id: %d, err: %d", iSockId, retval ); + } + else + { + TInetAddr listenAddr( KInetAddrAny, aPort ); + retval = iSocket.Bind( listenAddr ); + if ( retval == KErrNone ) + { + LOG2( "CCRSock::ListenPort(), udp: %d ok, id: %d", aPort,iSockId ); + iSockStatus = CCRSock::EIdle; + iIsiSocketOpen = ETrue; + } + else + { + LOG2( "CCRSock::ListenPort(), UDPSocket.Bind FAILED id: %d, retval: %d", iSockId, retval ); + iSockStatus = CCRSock::EFailed; + } + if ( iIssueRead && iReader && ( !iReader->IsActive() ) ) + { + iReader->IssueRead(); + } + } + } + + LOG1( "CCRSock::ListenPort(), retval: %d", retval ); + return retval; + } + +// ----------------------------------------------------------------------------- +// CCRSock::JoinGroup +// Joins a multicast group. Synchronous. +// ----------------------------------------------------------------------------- +// +TInt CCRSock::JoinGroup( const TInetAddr& aGroupAddr ) + { + LOG( "CCRSock::JoinGroup()" ); + + TPckgBuf request; + request().iAddr = aGroupAddr.Ip6Address(); + request().iInterface = 0; + return iSocket.SetOpt( KSoIp6JoinGroup, KSolInetIp, request ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::SendData +// Initiates async data sending +// ----------------------------------------------------------------------------- +// +void CCRSock::SendData( const TDesC8& aDataThatIsSentOverSocket ) + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + if ( iProtoTCP && aDataThatIsSentOverSocket.Length() && + aDataThatIsSentOverSocket[0] != ( TUint8 )( '$' ) ) + { + LOG2("CCRSock::SendData(), id: %d, len: %d", + iSockId, aDataThatIsSentOverSocket.Length() ); + TChar c; + TName d; + for ( TInt i( 0 ); i < aDataThatIsSentOverSocket.Length(); i++ ) + { + c = aDataThatIsSentOverSocket[i]; + d.Append( c ); + if ( ( i > 0 ) && ( i % 80 ) == 0 ) + { + LOG1( ">%S<", &d ); + d.Zero(); + } + } + + LOG1( ">%S<", &d ); + } +#endif + + // Data to socket + if ( !IsActive() ) + { + CopySendData( aDataThatIsSentOverSocket ); + if ( iProtoTCP ) + { + iSocket.Write( iSentData, iStatus ); + iSockStatus = CCRSock::ESending; + SetActive(); + } + else + { + if ( iToAddr.Port() != 0 ) + { + iSocket.SendTo( iSentData, iToAddr, 0, iStatus, iSentDataLen ); + iSockStatus = CCRSock::ESending; + SetActive(); + } + else + { + LOG1( "CCRSock::SendData(), Discarding send, id: %d" ,iSockId ); + } + } + } + else + { + LOG2( "CCRSock::SendData(), id: %d, Already active, Dumped packet, len: %d" , + iSockId, aDataThatIsSentOverSocket.Length() ); + } + } + +// ----------------------------------------------------------------------------- +// CCRSock::SockStatus +// returns status +// ----------------------------------------------------------------------------- +// +CCRSock::TCRSockStatus CCRSock::SockStatus() const + { + return iSockStatus; + } + +// ----------------------------------------------------------------------------- +// CCRSock::ConnectedAddr +// returns endpoint addr of this sock +// ----------------------------------------------------------------------------- +// +TInetAddr CCRSock::ConnectedAddr( void ) + { + TInetAddr addr; + iSocket.RemoteName( addr ); + return addr; + } + +// ----------------------------------------------------------------------------- +// CCRSock::LocalAddr +// returns local addr of this sock +// ----------------------------------------------------------------------------- +// +TInetAddr CCRSock::LocalAddr( void ) + { + TInetAddr addr; + iSocket.LocalName( addr ); + return addr; + } + +// ----------------------------------------------------------------------------- +// CCRSock::SetToAddr +// sets "to" addr of this sock +// ----------------------------------------------------------------------------- +// +void CCRSock::SetToAddr( const TInetAddr &aAddr ) + { + LOG( "CCRSock::SetToAddr() in" ); + iToAddr = aAddr; + +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + TName an_addr; + iToAddr.Output( an_addr ); + LOG3( "CCRSock::SetToAddr(), id: %d, addr: %S, port: %d", iSockId, &an_addr, aAddr.Port() ); +#endif + + } + +// ----------------------------------------------------------------------------- +// CCRSock::Socket +// ----------------------------------------------------------------------------- +RSocket& CCRSock::Socket() + { + return iSocket; + } + +// ----------------------------------------------------------------------------- +// ----------- here begins implementation of "SockReader" helper class---------- +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// + +// ----------------------------------------------------------------------------- +// CCRSockReader::NewL +// Construction startpoint +// ----------------------------------------------------------------------------- +// +CCRSockReader* CCRSockReader::NewL( + CCRSock& aSock, + RConnection& aConnection, RSocketServ& aSockServer ) + { + CCRSockReader* self = new ( ELeave ) CCRSockReader( + aSock, aConnection, aSockServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } +// ----------------------------------------------------------------------------- +// CCRSockReader::CCRSockReader +// Default constructor +// ----------------------------------------------------------------------------- +// +CCRSockReader::CCRSockReader( + CCRSock& aSock, RConnection& aConnection, + RSocketServ& aSockServer ) + : CActive( EPriorityStandard ), + iSock( aSock ), + iConnection( aConnection ), + iSockServer( aSockServer ) + { + } +// ----------------------------------------------------------------------------- +// CCRSockReader::ConstructL +// Actual constructor +// ----------------------------------------------------------------------------- +// +void CCRSockReader::ConstructL() + { + LOG( "CCRSockReader::ConstructL()" ); + + // Add self to active scheduler + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CCRSock::~CCRSockReader +// Destructor +// ----------------------------------------------------------------------------- +// +CCRSockReader::~CCRSockReader() + { + LOG( "CCRSockReader::~CCRSockReader()" ); + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CCRSockReader::RunL +// Work-horse +// ----------------------------------------------------------------------------- +// +void CCRSockReader::RunL() + { +#if defined ( LIVE_TV_FILE_TRACE ) || defined ( LIVE_TV_RDEBUG_TRACE ) + if ( iSock.iProtoTCP && iStatus.Int() != KErrNone ) + { + LOG2( "CCRSockReader::RunL(), id: %d, status: %d", iSock.iSockId, iStatus.Int() ); + } +#endif + + switch ( iStatus.Int() ) + { + case KErrNone: + { +#if defined( LIVE_TV_FILE_TRACE ) || defined( LIVE_TV_RDEBUG_TRACE ) + if ( !iSock.iProtoTCP ) + { + recvBytes += iSock.iReceivedData.Length(); + recvCount ++; + if ( ( recvCount % 50 ) == 0 ) + { + LOG3( "CCRSockReader::RunL(), recvCount: %d, recvBytes: %d, id: %d", + recvCount, recvBytes, iSock.iSockId ); + TName an_addr; + iSock.iFromAddr.Output( an_addr ); + TInt a_byte2 = iSock.iReceivedData[2]; + TInt a_byte3 = iSock.iReceivedData[3]; + LOG3( "CCRSockReader::RunL(), Addr %S, port: %d, last seq: %d", + &an_addr, iSock.iFromAddr.Port(), ( a_byte2 * 255 ) + a_byte3 ); + } + } +#endif // LIVE_TV_FILE_TRACE || LIVE_TV_RDEBUG_TRACE + + iSock.iObserver.DataReceived( iSock.iSockId, iSock.iReceivedData ); + IssueRead(); + } + break; + + default: // error cases + { + LOG2( "CCRSockReader::RunL(), id: %d, status: %d", iSock.iSockId, iStatus.Int() ); + iSock.iSockStatus = CCRSock::EFailed; + iSock.iObserver.SockStatusChange( + iSock.iSockId, iSock.iSockStatus, iStatus.Int() ); + } + break; + } + } + +// ----------------------------------------------------------------------------- +// CCRSockReader::IssueRead +// Asks for more data +// ----------------------------------------------------------------------------- +// +void CCRSockReader::IssueRead() + { + if ( IsActive() ) + { + LOG( "CCRSockReader::IssueRead(), IsActive! return" ); + return; + } + + iSock.iReceivedData.Zero(); + if ( iSock.iProtoTCP ) + { + iSock.iSocket.RecvOneOrMore( iSock.iReceivedData, 0, iStatus, + iSock.iReceivedDataLen ); + } + else + { + iSock.iSocket.RecvFrom( iSock.iReceivedData, iSock.iFromAddr, 0, iStatus ); + } + + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CCRSockReader::DoCancel +// Cancels outstanding operations +// ----------------------------------------------------------------------------- +// +void CCRSockReader::DoCancel() + { + LOG( "CCRSockReader::DoCancel()" ); + // CCRSock::DoCancel() has already called CancelAll to socket so no need to do it here + } +// ----------------------------------------------------------------------------- +// CCRSockReader::RunError +// If anything goes wrong +// ----------------------------------------------------------------------------- +// +TInt CCRSockReader::RunError( TInt aError ) + { + LOG1( "CCRSockReader::RunError(), aError: %d, return KErrNone", aError ); + ( void )aError; // Prevent compiler warning + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// ----------- here ends implementation of "SockReader" helper class---------- +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRStreamingSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRStreamingSession.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,865 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for streaming session. Owns a source, number of buffers* +*/ + + + + +// INCLUDES +#include "VideoServiceUtilsConf.hrh" +#include "CCRStreamingSession.h" +#include "CCRRtspSink.h" +#include "CCRNullSink.h" +#include "CCRPacketBuffer.h" +#include +#include "CCRRtspPacketSource.h" +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +#include "CCRXpsSink.h" +#include "CCRRtpRecordSink.h" +#include "CCRRtpFileSource.h" +#include "CCRNullSource.h" +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT +#include "MCRStreamObserver.h" +#include "CCRPacketSinkBase.h" +#include "CCRConnection.h" +#include "CCRengine.h" +#include "videoserviceutilsLogger.h" + +// CONSTANTS +const TInt KMaxRtspPackets( 400 ); +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +const TInt KMaxRtpPackets( 500 ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::NewL +// +// ----------------------------------------------------------------------------- +// +CCRStreamingSession* CCRStreamingSession::NewL( + RSocketServ& aSockServer, + CCRConnection* aConnection, + CCREngine& aEngine ) + { + CCRStreamingSession* self = new( ELeave ) CCRStreamingSession( + aSockServer, aConnection, aEngine ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::CCRStreamingSession +// +// ----------------------------------------------------------------------------- +// +CCRStreamingSession::CCRStreamingSession( + RSocketServ& aSockServer, + CCRConnection* aConnection, + CCREngine& aEngine ) + : iSockServer( aSockServer ), + iConnection( aConnection ), + iEngine( aEngine ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::ConstructL +// +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::ConstructL() + { + LOG( "CCRStreamingSession::ConstructL()" ); + + // Note, quite high priority + iCleanUp = new ( ELeave ) CAsyncCallBack( CActive::EPriorityStandard ); + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::~CCREStreamingSession +// +// ----------------------------------------------------------------------------- +// +CCRStreamingSession::~CCRStreamingSession() + { + LOG( "CCRStreamingSession::~CCRStreamingSession()" ); + + delete iCleanUp; + iSinks.ResetAndDestroy(); + iSinksToDelete.Reset(); + delete iSource; + delete iBuffer; + iConnection = NULL; + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::OpenSourceL +// Opens RTSP streaming source. +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::OpenSourceL( + const SCRRtspParams& aParams, + const TDesC& aSessionDefinition ) + { + LOG( "CCRStreamingSession::OpenSourceL(), RTSP Url" ) + + if ( !iSource && iConnection ) + { + iSourceChecksum = SourceDefinition( aSessionDefinition ); + iSource = CCRRtspPacketSource::NewL( + aParams, *iConnection, iSockServer, *this, *this ); + iSource->RegisterConnectionObs( &iEngine ); + } + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::OpenSourceL +// Opens RTP clip streaming source. +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::OpenSourceL( + const SCRRtpPlayParams& aParams, + CRtpClipHandler*& aClipHandler, + const TDesC& aSessionDefinition ) + { + LOG( "CCRStreamingSession::OpenSourceL(), RTP clip" ) + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + if ( !iSource ) + { + iSourceChecksum = SourceDefinition( aSessionDefinition ); + iBuffer = CCRPacketBuffer::NewL( KMaxRtpPackets ); + iSource = CCRRtpFileSource::NewL( aParams, aClipHandler, *this, *this ); + iSource->SetBuffer( iBuffer ); + } + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aParams; + ( void )aClipHandler; + ( void )aSessionDefinition; + User::Leave( KErrNotSupported ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::OpenSourceL +// Opens RTP clip streaming source. +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::OpenSourceL( + const RFile& aRtpHandle, + CRtpClipHandler*& aClipHandler, + const TDesC& aSessionDefinition ) + { + LOG( "CCRStreamingSession::OpenSourceL(), RTP handle" ) + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + if ( !iSource ) + { + iSourceChecksum = SourceDefinition( aSessionDefinition ); + iBuffer = CCRPacketBuffer::NewL( KMaxRtpPackets ); + iSource = CCRRtpFileSource::NewL( aRtpHandle, aClipHandler, *this, *this ); + iSource->SetBuffer( iBuffer ); + } + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aRtpHandle; + ( void )aClipHandler; + ( void )aSessionDefinition; + User::Leave( KErrNotSupported ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::OpenSourceL +// Opens DVB-H live streaming source. +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::OpenSourceL( + const SCRLiveParams& /*aLiveParams*/, + const TDesC& /*aSessionDefinition*/ ) + { + LOG( "CCRStreamingSession::OpenSourceL(), DVB-H live" ) + + User::Leave( KErrNotSupported ); + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::OpenSourceL +// Opens RTP clip as a live streaming source. +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::OpenSourceL( const TDesC& aSessionDefinition ) + { + LOG( "CCRStreamingSession::OpenSourceL(), Null" ) + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + if ( !iSource ) + { + iSourceChecksum = SourceDefinition( aSessionDefinition ); + iBuffer = CCRPacketBuffer::NewL( KMaxRtpPackets ); + iSource = CCRNullSource::NewL( aSessionDefinition, *this, *this ); + iSource->SetBuffer( iBuffer ); + } + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aSessionDefinition; + User::Leave( KErrNotSupported ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::SourceDefinition +// +// ----------------------------------------------------------------------------- +// +TUint CCRStreamingSession::SourceDefinition( const TDesC& aName ) + { + TUint checkSum( 0 ); + for ( TInt i( aName.Length() - 1 ); i >= 0; i-- ) + { + checkSum += aName[i]; + } + + // And for rtsp packet source do use different id + // if udp is blocked and we're using tcp then. + if ( iSource && iSource->Id() == ECRRtspSourceId && + iConnection && + iConnection->GetHeuristic ( CCRConnection::EUdpStreamingBlocked ) ) + { + checkSum++; + } + + return checkSum; + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::SourceChecksum +// +// ----------------------------------------------------------------------------- +// +TUint CCRStreamingSession::SourceChecksum() + { + return iSourceChecksum; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::CreateAndSetBufferL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::CreateAndSetBufferL() + { + if ( iSource && iBuffer == NULL ) + { + iBuffer = CCRPacketBuffer::NewL( KMaxRtspPackets ); + iSource->SetBuffer( iBuffer ); + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::CreateRtspSinkL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::CreateRtspSinkL( const TInt& aLoopbackPort ) + { + LOG( "CCRStreamingSession::CreateRtspSinkL()" ) + + if ( iConnection ) + { + // Only one RTSP sink at the time + DeleteSink( ECRRtspSinkId ); + + // New sink + CCRRtspSink* sink = CCRRtspSink::NewL( + *iConnection, iSockServer, ECRRtspSinkId, aLoopbackPort, *this ); + CleanupStack::PushL( sink ); + User::LeaveIfError( iSinks.Append( sink ) ); + CleanupStack::Pop( sink ); + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::CreateXpsSinkL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::CreateXpsSinkL() + { + LOG( "CCRStreamingSession::CreateXpsSinkL()" ) + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + + CCRXpsSink* sink = CCRXpsSink::NewL( ECRXpsSinkId, *this ); + CleanupStack::PushL( sink ); + User::LeaveIfError( iSinks.Append( sink ) ); + CleanupStack::Pop( sink ); +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + User::Leave( KErrNotSupported ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::Create3gpRecordSinkL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::Create3gpRecordSinkL( + const SCRRecordParams& /*aRecordParams*/ ) + { + LOG( "CCRStreamingSession::Create3gpRecordSinkL()" ) + + User::Leave( KErrNotSupported ); + /* + CCR3gpRecordSink* sink = CCR3gpRecordSink::NewL( ECR3gpRecSinkId, *this ); + CleanupStack::PushL( sink ); + User::LeaveIfError( iSinks.Append( sink ) ); + CleanupStack::Pop( sink ); + */ + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::CreateRtpRecordSinkL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::CreateRtpRecordSinkL( + const SCRRecordParams& aRecordParams, + CRtpClipHandler*& aClipHandler ) + { + LOG( "CCRStreamingSession::CreateRtpRecordSinkL()" ) + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT + // Create record sink + CCRRtpRecordSink* sink = CCRRtpRecordSink::NewL( + aRecordParams, ECRRtpRecSinkId, *this, &iEngine, aClipHandler ); + CleanupStack::PushL( sink ); + User::LeaveIfError( iSinks.Append( sink ) ); + CleanupStack::Pop( sink ); + +#else // RD_IPTV_FEA_RTP_CLIP_SUPPORT + ( void )aRecordParams; + ( void )aClipHandler; + User::Leave( KErrNotSupported ); +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::PostActionL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::PostActionL() + { + User::LeaveIfNull( iSource ); + iSource->PostActionL(); + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::PlayCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::PlayCommand( + const TReal& aStartPos, + const TReal& aEndPos ) + { + if ( iSource ) + { + return iSource->Play( aStartPos, aEndPos ); + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::PauseCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::PauseCommand() + { + if ( iSource ) + { + return iSource->Pause(); + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::StopCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::StopCommand() + { + if ( iSource && iSinks.Count() >= 1 ) + { + return iSource->Stop(); + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SetPosition +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::SetPosition( const TInt64 aPosition ) + { + if ( iSource ) + { + return iSource->SetPosition( aPosition ); + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::GetPosition +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::GetPosition( TInt64& aPosition, TInt64& aDuration ) + { + if ( iSource ) + { + return iSource->GetPosition( aPosition, aDuration ); + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::PauseCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::PauseCommand( const TCRSinkId& aSinkId ) + { + // Pauses current sink action + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( aSinkId == iSinks[i]->Id() ) + { + return iSinks[i]->Pause(); + } + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::RestoreCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::RestoreCommand( const TCRSinkId& aSinkId ) + { + // Pauses current sink action + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( aSinkId == iSinks[i]->Id() ) + { + return iSinks[i]->Restore(); + } + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::StopCommand +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::StopCommand( const TCRSinkId& aSinkId ) + { + // Stop current sink action + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( aSinkId == iSinks[i]->Id() ) + { + iSinks[i]->Stop(); + return KErrNone; + } + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::TransferSink +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::TransferSink( + const TCRSinkId& aSinkId, + CCRStreamingSession& aTargetSession ) + { + LOG1( "CCRStreamingSession::TransferSink(), aSinkId: %d", aSinkId ); + + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( iSinks[i]->Id() == aSinkId ) + { + TInt err( aTargetSession.AddNewSink( iSinks[i] ) ); + if ( !err ) + { + iBuffer->RemoveSink( iSinks[i] ); + iSinks.Remove( i ); + } + + return err; + } + } + + return KErrCompletion; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::AddNewSink +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::AddNewSink( CCRPacketSinkBase* aSink ) + { + LOG1( "CCRStreamingSession::AddNewSink(), aSink->Id: %d", aSink->Id() ); + + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( aSink->Id() == iSinks[i]->Id() ) + { + LOG( "CCRStreamingSession::AddNewSink(), Sink already exist !" ); + return KErrInUse; + } + } + + // Add new sink + TInt err( iSinks.Append( aSink ) ); + if ( !err ) + { + err = iBuffer->AddSink( iSinks[iSinks.Count() - 1] ); + } + + return err; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::ClipHandlerUsed +// +//----------------------------------------------------------------------------- +// +TBool CCRStreamingSession::ClipHandlerUsed() + { + // Used in source + if ( iSource && iSource->Id() == ECRRtpSourceId ) + { + return ETrue; + } + + // Used in any Sink + for ( TInt i( iSinks.Count() - 1 ); i >= 0; i-- ) + { + if ( iSinks[i]->Id() == ECRRtpRecSinkId ) + { + return ETrue; + } + } + + return EFalse; + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::CreateNullSinkL +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::CreateNullSinkL() + { + CCRNullSink* sink = CCRNullSink::NewL( ECRNullSinkId, *this ); + sink->RegisterConnectionObs( &iEngine ); + CleanupStack::PushL( sink ); + User::LeaveIfError( iSinks.Append( sink ) ); + CleanupStack::Pop( sink ); + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::InitializeSinks +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::InitializeSinks() + { + if ( iSource && iBuffer ) + { + TPtrC8 sdp( NULL, 0 ); + TInt err( iSource->GetSdp( sdp ) ); + if ( err ) + { + LOG1( "CCRStreamingSession::InitializeSinks(), GetSdp() Failed: %d", err ); + SourceStop(); + } + else + { + for ( TInt i( 0 ); i < iSinks.Count(); i++ ) + { + TRAP( err, iSinks[i]->SetSdpL( sdp ) ); + if ( err ) + { + LOG1( "CCRStreamingSession::InitializeSinks(), SetSdpL() Failed: %d", err ); + SinkStops( iSinks[i]->Id() ); + return; + } + + iSinks[i]->SetBuffer( iBuffer ); + err = iBuffer->AddSink( iSinks[i] ); + if ( err ) + { + LOG1( "CCRStreamingSession::InitializeSinks(), AddSink() Failed: %d", err ); + SourceStop(); + return; + } + } + + iEngine.ConnectionStatusChange( + SourceChecksum(), MCRConnectionObserver::ECRSdpAvailable, KErrNone ); + } + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SetSeqAndTs() +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::SetSeqAndTs() + { + if ( iSource ) + { + TUint audioSeq( 0 ); + TUint audioTS( 0 ); + TUint videoSeq( 0 ); + TUint videoTS( 0 ); + TReal lowerRange( KRealZero ); + TReal upperRange( KRealMinusOne ); + + iSource->GetRange( lowerRange,upperRange ); + iSource->SeqAndTS( audioSeq, audioTS, videoSeq, videoTS ); + + for ( TInt j( 0 ); j < iSinks.Count(); j++ ) + { + if ( !( lowerRange == KRealZero && upperRange == KRealMinusOne ) ) + { + iSinks[j]->SetRange( lowerRange,upperRange ); + } + + iSinks[j]->SetSeqAndTS( audioSeq, audioTS, videoSeq, videoTS ); + } + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SinkStops() +// So, a sink wants to quit. we can't just delete it here as return. Statement +// would then take us to deleted instance: put up a cleanup CAsyncCallBack and +// return. +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::SinkStops( const TCRSinkId& aSinkId ) + { + LOG1( "CCRStreamingSession::SinkStops(), aSinkId: %d", aSinkId ); + + // InsertInSignedKeyOrderL checks for duplicate, if there is already + // entry for that sink, the array will remain unchanged + TRAPD( err, iSinksToDelete.InsertInSignedKeyOrderL( aSinkId ) ); + if ( err ) + { + LOG1( "CCRStreamingSession::SinkStops(), InsertInSignedKeyOrderL leaved %d", err ); + } + + // If not already active and sinks to delete? + if ( !iCleanUp->IsActive() && iSinksToDelete.Count() ) + { + TCallBack cb( SinkStopCallBack, this ); + iCleanUp->Set( cb ); + iCleanUp->CallBack(); + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SourceRestore() +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::SourceRestore() + { + if ( iSource ) + { + iSource->Restore(); + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SourceStop() +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::SourceStop() + { + // Session is useless without a source so ask engine to clean it all up + iEngine.SessionStop( this ); + } + +// ----------------------------------------------------------------------------- +// CCRStreamingSession::StatusChanged +// +// ----------------------------------------------------------------------------- +// +void CCRStreamingSession::StatusChanged( + MCRPacketSource::TCRPacketSourceState aStatus ) + { + LOG1( "CCRStreamingSession::StatusChanged(), aStatus: %d", aStatus ); + + switch ( aStatus ) + { + case MCRPacketSource::ERtpStateIdle: + break; + + case MCRPacketSource::ERtpStateSdpAvailable: + TRAPD( err, CreateAndSetBufferL() ); + if ( err ) + { + LOG1( "CCRStreamingSession::StatusChanged(), CreateAndSetBuffers leaved: %d", err ); + } + + InitializeSinks(); + break; + + case MCRPacketSource::ERtpStateSeqAndTSAvailable: + SetSeqAndTs(); + break; + + case MCRPacketSource::ERtpStateSetupRepply: + case MCRPacketSource::ERtpStatePlaying: + { + for ( TInt j( iSinks.Count() - 1 ); j >= 0; j-- ) + { + iSinks[j]->StatusChanged( aStatus ) ; + } + } + break; + + case MCRPacketSource::ERtpStateClosing: + SourceStop(); + break; + + default: + // None. + break; + } + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::SinkStopCallBack() +// +//----------------------------------------------------------------------------- +// +TInt CCRStreamingSession::SinkStopCallBack( TAny* aThis ) + { + CCRStreamingSession* self = static_cast( aThis ); + LOG1( "CCRStreamingSession::SinkStopCallBack(), iSinksToDelete count: %d", + self->iSinksToDelete.Count() ); + self->DoSinkStop(); + return self->iSinksToDelete.Count(); + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::DoSinkStop() +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::DoSinkStop( void ) + { + LOG( "CCRStreamingSession::DoSinkStop() in" ); + + for ( TInt i( iSinksToDelete.Count() - 1 ); i >= 0; i-- ) + { + for ( TInt j( iSinks.Count() - 1 ); j >= 0; j-- ) + { + if ( iSinks[j]->Id() == iSinksToDelete[i] ) + { + TInt remainingSinks( 0 ); + if ( iBuffer ) + { + // If we never got sdp, we never had a buffer + remainingSinks = iBuffer->RemoveSink( iSinks[j] ); + } + + if ( remainingSinks < 1 ) + { + // No sinks remaing for our buffers, I'm feeling useless + if ( iSource ) + { + iSource->Stop(); + } + } + + delete iSinks[j]; + iSinks[j] = NULL; + iSinks.Remove( j ); + } + } + } + + iSinksToDelete.Reset(); + LOG( "CCRStreamingSession::DoSinkStop() out" ); + } + +//----------------------------------------------------------------------------- +// CCRStreamingSession::DeleteSink +// +//----------------------------------------------------------------------------- +// +void CCRStreamingSession::DeleteSink( const TCRSinkId& aSinkId ) + { + for ( TInt i( iSinks.Count() - 1 ); i >= 0 ; i-- ) + { + if ( iSinks[i]->Id() == aSinkId ) + { + // Remove sink from buffer + if ( iBuffer ) + { + iBuffer->RemoveSink( iSinks[i] ); + } + + // Delete sink + delete iSinks[i]; + iSinks[i] = NULL; + iSinks.Remove( i ); + LOG2( "CCRStreamingSession::DeleteSink(), deleted index: %d, aSinkId: %d", i, aSinkId ); + } + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRTimer.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrapper for CTimer* +*/ + + + + +// INCLUDE FILES +#include "CCRTimer.h" +#include "MCRTimerObserver.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRTimer::NewL() +// ----------------------------------------------------------------------------- +// +CCRTimer* CCRTimer::NewL( const TInt aPriority, MCRTimerObserver& aTimerObserver ) + { + CCRTimer* self = CCRTimer::NewLC( aPriority, aTimerObserver ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRTimer::NewLC() +// ----------------------------------------------------------------------------- +// +CCRTimer* CCRTimer::NewLC( const TInt aPriority, MCRTimerObserver& aTimerObserver ) + { + CCRTimer* self = new (ELeave) CCRTimer( aPriority, aTimerObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRTimer::CCRTimer() +// ----------------------------------------------------------------------------- +// +CCRTimer::CCRTimer( const TInt aPriority, MCRTimerObserver& aTimerObserver ) + : CTimer( aPriority ), iObserver( aTimerObserver ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRTimer::ConstructL() +// ----------------------------------------------------------------------------- +// +void CCRTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CCRTimer::~CCRTimer() +// ----------------------------------------------------------------------------- +// +CCRTimer::~CCRTimer() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CCRTimer::RunL() +// Timer request has completed, so notify the timer's owner. +// ----------------------------------------------------------------------------- +// +void CCRTimer::RunL() + { + if ( iStatus == KErrNone ) + { + iObserver.TimerExpired( this ); + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngine/src/CCRXpsSink.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngine/src/CCRXpsSink.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,858 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class that takes packet from the buffer and forward them thrue* +*/ + + + + +// INCLUDES +#include "CCRXpsSink.h" +#include "CCRPacketBuffer.h" +#include "CCRStreamingSession.h" +#include +#include "CCRTimer.h" +#include "CRtpPacket.h" +#include "CRtpTsConverter.h" +#include + +// CONSTANTS +_LIT( KCRXpsServerName, "IpVideoXps" ); +_LIT8( KAttributeDefRange, "a=range:npt=0-86400.0" ); +#ifdef VIA_FEA_IPTV_USE_IPDC +_LIT8( KMtvAvc, "X-MTV-AVC" ); +_LIT8( KHxAvc1, "X-HX-AVC1" ); +#endif // VIA_FEA_IPTV_USE_IPDC +const TInt KRangeIdentifierLen( 8 ); +const TInt KXpsBufferedPackets( 300 ); // about 3s +const TInt KXpsOverflowDelay( 300 * 1000 ); // 300ms + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRXpsSink::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRXpsSink* CCRXpsSink::NewL( + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ) + { + CCRXpsSink* self = new( ELeave ) + CCRXpsSink( aSinkId, aOwningSession ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::CCRXpsSink +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRXpsSink::CCRXpsSink( + CCRStreamingSession::TCRSinkId aSinkId, + CCRStreamingSession& aOwningSession ) + : CCRPacketSinkBase( aOwningSession, aSinkId ), + iWaitPlayer( KErrNotFound ), + iRequested( KErrNotFound ), + iXpsResetOk( EFalse ), + iAudioStreamId( KErrNotFound ), + iVideoStreamId( KErrNotFound ), + iTitleStreamId( KErrNotFound ) + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::ConstructL +// 2nd phase. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::ConstructL() + { + LOG( "CCRXpsSink::ConstructL() in" ); + + iRtpPacket = CRtpPacket::NewL(); + iPacketSink = CXPSPacketSink::New(); + LOG1( "CCRXpsSink::ConstructL(), iPacketSink: %d", iPacketSink ); + User::LeaveIfNull( iPacketSink ); + TInt err( iPacketSink->Init( KCRXpsServerName, this ) ); + if ( err ) + { + LOG1( "CCRXpsSink::ConstructL(), iPacketSink->Init() err: %d", err ); + User::Leave( err ); + } + + LOG( "CCRXpsSink::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::~CCRXpsSink +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRXpsSink::~CCRXpsSink() + { + LOG( "CCRXpsSink::~CCRXpsSink()" ); + + // Delete variables + StopTimer(); + delete iPacketSink; + delete iAudioConv; + delete iVideoConv; + delete iTitleConv; + delete iRtpPacket; + +#ifdef VIA_FEA_IPTV_USE_IPDC + delete iVideoDepacketizer; +#endif // VIA_FEA_IPTV_USE_IPDC + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SetSdpL +// Sets SDP, parses it and initiates XPS. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::SetSdpL( const TDesC8& aSdp ) + { + LOG1( "CCRXpsSink::SetSdpL(), SDP len: %d", aSdp.Length() ); + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + LOG( "CCRXpsSink::SetSdpL(), SDP content:" ); + TName d( KNullDesC ); + for ( TInt i( 0 ); i < aSdp.Length(); i++ ) + { + TChar c = aSdp[i]; + d.Append( c ); + if ( ( i > 0 ) && ( i % 80 ) == 0 ) + { + LOG1( ">%S<", &d ); + d.Zero(); + } + } + + LOG1( ">%S<", &d ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + if ( iWaitPlayer != KErrNotFound ) + { + LOG( "CCRXpsSink::SetSdpL(), SDP already set !" ); + return; + } + + // SDP parser + CDvrSdpParser* sdpParser = CDvrSdpParser::NewLC(); + sdpParser->TryParseL( aSdp ); + + // TS converter + delete iAudioConv; iAudioConv = NULL; + iAudioConv = CRtpTsConverter::NewL( sdpParser->AudioTimerGranularity() ); + LOG1( "CCRXpsSink::SetSdpL(), AudioTimerGranularity: %d", + sdpParser->AudioTimerGranularity() ); + + delete iVideoConv; iVideoConv = NULL; + iVideoConv = CRtpTsConverter::NewL( sdpParser->VideoTimerGranularity() ); + LOG1( "CCRXpsSink::SetSdpL(), VideoTimerGranularity: %d", + sdpParser->VideoTimerGranularity() ); + + delete iTitleConv; iTitleConv = NULL; + + // Streams count + TInt streams( 0 ); + const CDvrSdpParser::TDvrPacketProvidings providings( + sdpParser->SupportedContent() ); + if ( providings == CDvrSdpParser::EDvrAudioOnly || + providings == CDvrSdpParser::EDvrVideoOnly ) + { + streams = 1; + } + if ( providings == CDvrSdpParser::EDvrBothAudioAndVideo ) + { + streams = 2; + } + + // Stream ids + iAudioStreamId = sdpParser->AudioStreamId(); + iVideoStreamId = sdpParser->VideoStreamId(); + LOG2( "CCRXpsSink::SetSdpL(), iAudioStreamId: %d, iVideoStreamId: %d", + iAudioStreamId, iVideoStreamId ); + // Verify/update range + if ( aSdp.FindC( + KAttributeDefRange().Left( KRangeIdentifierLen ) ) == KErrNotFound ) + { + LOG( "CCRXpsSink::SetSdpL(), setting default range" ); + iRangeKnown = EFalse; + sdpParser->NewLineL( KErrNotFound, KAttributeDefRange ); + } + else + { + LOG( "CCRXpsSink::SetSdpL() sdp already did contain range, not changed" ); + iRangeKnown = ETrue; + } + + // Get SDP data + TPtrC8 sdp( NULL, 0 ); + User::LeaveIfError( sdpParser->GetSdp( sdp ) ); + HBufC8* tmpSdpData = NULL; + + // See if recorded from ISMA crypted content +#ifdef VIA_FEA_IPTV_USE_IPDC + TInt mimePos( sdp.Find( KMtvAvc ) ); + if ( mimePos != KErrNotFound || sdp.Find( KHxAvc1 ) != KErrNotFound ) + { + LOG( "CCRXpsSink::SetSdpL(), Playback of ISMA clip.." ); + delete iVideoDepacketizer; iVideoDepacketizer = NULL; + iVideoDepacketizer = CH264Mpeg4GenrToFileformat::New(); + User::LeaveIfNull( iVideoDepacketizer ); + HBufC8* fmtp = FindFmtpLC( sdp ); + TInt err( iVideoDepacketizer->Init( *fmtp ) ); + CleanupStack::PopAndDestroy( fmtp ); + if ( err ) + { + delete iVideoDepacketizer; iVideoDepacketizer = NULL; + LOG1( "CCRXpsSink::SetSdpL(), Depacketizer Init() failed: %d", err ); + } + else + { + // Change MIME type from X-MTV-AVC to X-HX-AVC1 for playback + // KMtvAvc mime prevents Helix crash in non DVB-H phones + if ( mimePos != KErrNotFound ) + { + tmpSdpData = HBufC8::NewLC( sdp.Length() - + KMtvAvc().Length() + KHxAvc1().Length() ); + TPtr8 ptr( tmpSdpData->Des() ); + ptr.Copy( sdp.Left( mimePos ) ); + ptr.Append( KHxAvc1 ); + ptr.Append( sdp.Mid( mimePos + KMtvAvc().Length() ) ); + sdp.Set( ptr ); + } + } + } +#endif // VIA_FEA_IPTV_USE_IPDC + + // Pass SDP to XPS + LOG( "CCRXpsSink::SetSdpL(), iPacketSink->SetSessionDescription.." ); + User::LeaveIfError( iPacketSink->SetSessionDescription( sdp, streams ) ); + if ( tmpSdpData != NULL ) + { + CleanupStack::PopAndDestroy( tmpSdpData ); + } + + // Config streams + for ( TInt i( 0 ); i < streams; i++ ) + { + LOG2( "CCRXpsSink::SetSdpL(), iPacketSink->ConfigStream: %d, KXpsBufferedPackets: %d", + i, KXpsBufferedPackets ); + User::LeaveIfError( iPacketSink->ConfigStream( i, KXpsBufferedPackets ) ); + } + + CleanupStack::PopAndDestroy( sdpParser ); + iWaitPlayer = KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::NewPacketAvailable +// From CCRPacketSinkBase. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::NewPacketAvailable() + { + // Kill flow timer + StopTimer(); + + // Ok to enqueue? + if ( iBuffer ) + { + if ( iWaitPlayer == KErrNone ) + { + // Enqueue packet + if ( SendPacket() ) + { + // Keep buffer size reasonable + iBuffer->HandleBufferSize(); + } + + if ( iBuffer->ContinousStream() ) + { + // Make sure all will be sent from the buffer in continous stream case + if ( iBuffer->PacketsCount( iSinkId ) > KErrNotFound ) + { + StartTimer( 0 ); + } + } + else + { + // Group done, need request more + if ( !iBuffer->MoreComing() ) + { + StartTimer( 0 ); + } + } + } + else + { + iBuffer->HandleBufferSize(); + // Make sure that process never end + if ( !iBuffer->ContinousStream() ) + { + StartTimer( KXpsOverflowDelay ); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::BufferResetting +// From CCRPacketSinkBase. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::BufferResetDone() + { + StopTimer(); + iWaitPlayer = KErrNone; + iRequested = KErrNotFound; + + // XPS reset possible? + if ( iXpsResetOk ) + { + LOG( "CCRXpsSink::BufferResetDone(), Resets XPS.." ); + iPacketSink->Reset(); + iXpsResetOk = EFalse; + } + + // Uninit TS converters + LOG( "CCRXpsSink::BufferResetDone(), Uninitiates TS converters.." ); + if ( iAudioConv ) + { + iAudioConv->UnInitiate(); + } + if ( iVideoConv ) + { + iVideoConv->UnInitiate(); + } + if ( iTitleConv ) + { + iTitleConv->UnInitiate(); + } + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + iLogXps = 0; +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::TimerExpired +// From MCRTimerObserver. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::TimerExpired( CCRTimer* /*aTimer*/ ) + { + RestoreSink(); + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::RestorePacketSupply +// From CCRPacketSinkBase. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::RestorePacketSupply( TUint aStreamId ) + { +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + if ( iLogXps < 5 ) + { + iLogXps++; + LOG2( "CCRXpsSink::RestorePacketSupply(), aStreamId: %d, iWaitPlayer: %d", + aStreamId, iWaitPlayer ); + } +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + if ( iWaitPlayer != TInt( ETrue ) ) + { + if ( iBuffer->ContinousStream() ) + { + iRequested = aStreamId; + iWaitPlayer = KErrNone; + RestoreSink(); + } + else + { + iWaitPlayer = KErrNone; + StartTimer( KXpsOverflowDelay ); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::RestoreSink +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::RestoreSink() + { + if ( iBuffer ) + { + // See if more waits in packet buffer + if ( iBuffer->PacketsCount( iSinkId ) > KErrNotFound ) + { + NewPacketAvailable(); + } + else + { + StopTimer(); + // This is only for non continous stream, like .rtp clip + iOwningSession.SourceRestore(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SendPacket +// Initialises time stamp converter for audio and video stream and passes RTP +// packets with adjusted time stamp to XPS interface. All packets before +// converter has beeen initialized are dumbed. +// ----------------------------------------------------------------------------- +// +TBool CCRXpsSink::SendPacket() + { + TBool packetSent( ETrue ); + MCRPacketSource::TCRPacketStreamId bufferId( MCRPacketSource::EStreamIdCount ); + const TInt book( iBuffer->GetStream( iSinkId, bufferId ) ); + TPtr8 packet( NULL, 0 ); + + // Packet type related action + TInt err( KErrNone ); + switch ( bufferId ) + { + case MCRPacketSource::EAudioStream: + if ( iAudioConv->Initiated() ) + { + iBuffer->GetPacket( book, packet ); + if ( iRequested == KErrNotFound || iRequested == iAudioStreamId ) + { + iRequested = KErrNotFound; + err = SendAudioPacket( packet ); + } + else + { + LOG( "CCRXpsSink::SendPacket(), Audio packet DROPPED after XPS overflow !" ) + } + } + else + { + packetSent = EFalse; + SearchForControlStreamPackets(); + } + break; + + case MCRPacketSource::EAudioControlStream: + { + iBuffer->GetPacket( book, packet ); + if ( !iAudioConv->Initiated() ) + { + iAudioConv->Init( packet ); + LOG1( "CCRXpsSink::SendPacket(), Audio TS initiated, status: %d", + iAudioConv->Initiated() ) + } + } + break; + + case MCRPacketSource::EVideoStream: + if ( iVideoConv->Initiated() ) + { + iBuffer->GetPacket( book, packet ); + if ( iRequested == KErrNotFound || iRequested == iVideoStreamId ) + { + iRequested = KErrNotFound; + err = SendVideoPacket( packet ); + } + else + { + LOG( "CCRXpsSink::SendPacket(), Video packet DROPPED after XPS overflow !" ) + } + } + else + { + packetSent = EFalse; + SearchForControlStreamPackets(); + } + break; + + case MCRPacketSource::EVideoControlStream: + { + iBuffer->GetPacket( book, packet ); + if ( !iVideoConv->Initiated() ) + { + iVideoConv->Init( packet ); + LOG1( "CCRXpsSink::SendPacket(), Video TS initiated, status: %d", + iVideoConv->Initiated() ) + } + } + break; + + case MCRPacketSource::ESubTitleStream: + if ( iTitleConv->Initiated() ) + { + iBuffer->GetPacket( book, packet ); + err = SendTitlePacket( packet ); + } + else + { + packetSent = EFalse; + SearchForControlStreamPackets(); + } + break; + + case MCRPacketSource::ESubTitleControlStream: + { + iBuffer->GetPacket( book, packet ); + if ( !iTitleConv->Initiated() ) + { + iTitleConv->Init( packet ); + LOG1( "CCRXpsSink::SendPacket(), Title TS initiated, status: %d", + iTitleConv->Initiated() ) + } + } + break; + + case MCRPacketSource::EDisContinousStream: + { + LOG( "CCRXpsSink::SendPacket(), EDiscontinousStream" ); + // Just wait player's "MvloLoadingStartedL" event, + // PlayCommand( -1.0, -1.0 ) will then handle pause packet + iWaitPlayer = ETrue; + // Used packet out from the buffer + iBuffer->GetPacket( book, packet ); + } + break; + + case MCRPacketSource::EStreamEndTag: + LOG1( "CCRXpsSink::SendPacket(), EStreamEndTag, iRangeKnown: %d", iRangeKnown ); + if ( iRangeKnown ) + { + if ( iAudioStreamId > KErrNotFound ) + { + iPacketSink->StreamEnd( iAudioStreamId ); + } + if ( iVideoStreamId > KErrNotFound ) + { + iPacketSink->StreamEnd( iVideoStreamId ); + } + } + //else + // { + // Just wait player's "MvloLoadingStartedL" event, + // Play ends with PlayCommand( -1.0, -1.0 ) in .rtp clip case and/or + // VIA will stop the play if play position goes beond the clip's lenght + // } + + // Used packet out from the buffer + iBuffer->GetPacket( book, packet ); + break; + + default: + LOG1( "CCRXpsSink::SendPacket(), Bad bufferId: %d", bufferId ); + // Used packet out from the buffer + iBuffer->GetPacket( book, packet ); + break; + } + + // Stop sink if error? + if ( err ) + { + LOG2( "CCRXpsSink::SendPacket(), error: %d, bufferId: %d", err, bufferId ); + LOG2( "CCRXpsSink::SendPacket(), iAudioStreamId: %d, iVideoStreamId: %d", + iAudioStreamId, iVideoStreamId ); + iOwningSession.SinkStops( Id() ); + } + + return packetSent; + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SendAudioPacket +// Adjust RTP timestamp and enqueue the packet. +// ----------------------------------------------------------------------------- +// +TInt CCRXpsSink::SendAudioPacket( const TDesC8& aPacket ) + { + // Parse packet + TInt err( iRtpPacket->ParseRtp( aPacket ) ); + if ( err ) + { + LOG1( "CCRXpsSink::SendAudioPacket(), Parsing error: %d", err ); + return err; + } + + // Adjust time stamp + iRtpPacket->SetTimeStamp( + iAudioConv->ConvertTs( iRtpPacket->iRtpRecvHeader.iTimestamp ) ); + + // Send to player + return EnqueuePacket( iAudioStreamId ); + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SendVideoPacket +// Adjust RTP timestamp and enqueue the packet. +// ----------------------------------------------------------------------------- +// +TInt CCRXpsSink::SendVideoPacket( const TDesC8& aPacket ) + { + TPtrC8 packet( aPacket ); + +#ifdef VIA_FEA_IPTV_USE_IPDC + // Do ISMA Depacketizer + if ( iVideoDepacketizer != NULL ) + { + TInt result( iVideoDepacketizer->PushPacket( packet ) ); + if ( result != KErrCompletion ) // KErrCompletion means Ok + { + return KErrNone; + } + + // Next packet should be available + TInt err( iVideoDepacketizer->NextFrame( packet ) ); + if ( err ) + { + LOG1( "CCRXpsSink::SendVideoPacket(), NextFrame error: %d", err ); + return err; + } + } +#endif // VIA_FEA_IPTV_USE_IPDC + + // Parse packet + TInt err( iRtpPacket->ParseRtp( packet ) ); + if ( err ) + { + LOG1( "CCRXpsSink::SendVideoPacket(), Parsing error: %d", err ); + return err; + } + + // Adjust time stamp + iRtpPacket->SetTimeStamp( + iVideoConv->ConvertTs( iRtpPacket->iRtpRecvHeader.iTimestamp ) ); + + // Send to player + return EnqueuePacket( iVideoStreamId ); + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SendTitlePacket +// Adjust RTP timestamp and enqueue the packet. +// ----------------------------------------------------------------------------- +// +TInt CCRXpsSink::SendTitlePacket( const TDesC8& /*aPacket*/ ) + { + // Title implementation unknown + return KErrNotSupported; + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::EnqueuePacket +// Sends packet to the player. +// ----------------------------------------------------------------------------- +// +TInt CCRXpsSink::EnqueuePacket( const TUint aStreamId ) + { + TInt err( iPacketSink->Enqueue( + aStreamId, iRtpPacket->iRtpRecvHeader, iRtpPacket->iPayload ) ); + +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + if ( err && ( iLogXps < 5 || err != KErrOverflow ) ) + { + LOG3( "CCRXpsSink::EnqueuePacket(), aStreamId: %d, err: %d, payload len: %d", + aStreamId, err, iRtpPacket->iPayload.Length() ); + } +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + + if ( err == KErrOverflow ) + { + iWaitPlayer = err; + return KErrNone; + } + + // XPS reset can not be done before first packet is enqued + iXpsResetOk = ETrue; + return err; + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::SearchForControlStreamPackets +// Checks buffer for control stream packets. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::SearchForControlStreamPackets() + { + // Check if RTCP packet already in buffer + if ( CheckBufferForControlStreamPackets() ) + { + iBuffer->AdjustBuffer(); + } + else + { + // Get more packets if group not contains any RTCP packet(s) + if ( !iBuffer->ContinousStream() && !iBuffer->MoreComing() ) + { + iBuffer->AdjustBuffer(); + iOwningSession.SourceRestore(); + } + } + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::CheckBufferForControlStreamPackets +// Checks buffer for control stream packets. +// ----------------------------------------------------------------------------- +// +TBool CCRXpsSink::CheckBufferForControlStreamPackets() + { + TBool audioOk( iAudioConv->Initiated() || iAudioStreamId == KErrNotFound ); + TBool videoOk( iVideoConv->Initiated() || iVideoStreamId == KErrNotFound ); + + // Loop packets, oldest first + for ( TInt offset( iBuffer->PacketsCount( iSinkId ) - 1 ); + ( !audioOk || !videoOk ) && offset >= 0; offset-- ) + { + MCRPacketSource::TCRPacketStreamId streamId( MCRPacketSource::EStreamIdCount ); + const TInt book( iBuffer->GetStream( iSinkId, offset, streamId ) ); + TPtr8 packet( NULL, 0 ); + + switch ( streamId ) + { + case MCRPacketSource::EAudioControlStream: + if ( !iAudioConv->Initiated() ) + { + audioOk = ETrue; + iBuffer->PeekPacket( book, packet, offset ); + iAudioConv->Init( packet ); + LOG1( "CCRXpsSink::CheckBufferForControlStreamPackets(), Audio TS initiated, status: %d", + iAudioConv->Initiated() ) + } + break; + + case MCRPacketSource::EVideoControlStream: + if ( !iVideoConv->Initiated() ) + { + videoOk = ETrue; + iBuffer->PeekPacket( book, packet, offset ); + iVideoConv->Init( packet ); + LOG1( "CCRXpsSink::CheckBufferForControlStreamPackets(), Video TS initiated, status: %d", + iVideoConv->Initiated() ) + } + break; + + case MCRPacketSource::ESubTitleControlStream: + if ( !iTitleConv->Initiated() ) + { + iBuffer->PeekPacket( book, packet, offset ); + iTitleConv->Init( packet ); + LOG1( "CCRXpsSink::CheckBufferForControlStreamPackets(), Title TS initiated, status: %d", + iTitleConv->Initiated() ) + } + break; + + default: + break; + } + } + + return ( audioOk && videoOk ); + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::StartTimer +// Starts packet flow timer. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::StartTimer( const TInt& aInterval ) + { + StopTimer(); + TRAPD( err, iFlowTimer = CCRTimer::NewL( + CActive::EPriorityLow, *this ) ); + if ( !err ) + { + iFlowTimer->After( aInterval ); + } + else + { + LOG1( "CCRXpsSink::StartTimer(), Flowtimer err: %d", err ); + iOwningSession.SinkStops( Id() ); + } + } + +// ----------------------------------------------------------------------------- +// CCRXpsSink::StopTimer +// Starts packet flow timer. +// ----------------------------------------------------------------------------- +// +void CCRXpsSink::StopTimer() + { + delete iFlowTimer; iFlowTimer = NULL; + } + +#ifdef VIA_FEA_IPTV_USE_IPDC +// ----------------------------------------------------------------------------- +// CCRXpsSink::FindFmtpL +// Finds the fmtp string. +// ----------------------------------------------------------------------------- +// +HBufC8* CCRXpsSink::FindFmtpLC( const TDesC8& aSdpData ) + { + LOG( "CCRXpsSink::FindFmtpLC() in" ); + _LIT8( KCRStr, "\r" ); + _LIT8( KLFStr, "\n" ); + _LIT8( KHxAVCfmtp, "a=hxavcfmtp:" ); + + // Get the video fmtp string + HBufC8* fmtp = NULL; + TInt pos = aSdpData.Find( KHxAVCfmtp ); + if ( pos > KErrNotFound ) + { + // Extract the right most from the fist char after KHxAVCfmtp + TPtrC8 rightPtr( aSdpData.Mid( pos + KHxAVCfmtp().Length() ) ); + + // We need the first line of rightPtr + TInt posLFStr( rightPtr.Find( KLFStr ) ); + TInt posCRStr( rightPtr.Find( KCRStr ) ); + if ( posLFStr > 0 && posCRStr > 0 ) + { + fmtp = rightPtr.Left( Min( posLFStr, posCRStr ) ).AllocLC(); + } + else if ( posLFStr > 0 ) + { + fmtp = rightPtr.Left( posLFStr ).AllocLC(); + } + else if ( posCRStr > 0 ) + { + fmtp = rightPtr.Left( posCRStr ).AllocLC(); + } + else + { + fmtp = rightPtr.AllocLC(); + } + } + + User::LeaveIfNull( fmtp ); +#if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE ) + HBufC* buf = HBufC::NewL( fmtp->Length() ); + TPtr ptr( buf->Des() ); ptr.Copy( *fmtp ); + LOG1( "CCRXpsSink::FindFmtpLC() out, Fmtp: %S", &ptr ); +#endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE + return fmtp; + } + +#endif // VIA_FEA_IPTV_USE_IPDC + + // End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/EABI/CommonRecordingEngineClientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/EABI/CommonRecordingEngineClientU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +EXPORTS + _ZN9CCRDvrApi11GetPositionEjRxS0_ @ 1 NONAME + _ZN9CCRDvrApi11PlayCommandEjdd @ 2 NONAME + _ZN9CCRDvrApi11PlayRtpFileERjRK16SCRRtpPlayParams @ 3 NONAME + _ZN9CCRDvrApi11PlayRtpFileERjRK5RFile @ 4 NONAME + _ZN9CCRDvrApi11PlayRtspUrlERjRK13SCRRtspParams @ 5 NONAME + _ZN9CCRDvrApi11SetPositionEjx @ 6 NONAME + _ZN9CCRDvrApi11StopCommandEj @ 7 NONAME + _ZN9CCRDvrApi12CancelSetIapEv @ 8 NONAME + _ZN9CCRDvrApi12CloseSessionEj @ 9 NONAME + _ZN9CCRDvrApi12PauseCommandEj @ 10 NONAME + _ZN9CCRDvrApi13StopTimeShiftEjj @ 11 NONAME + _ZN9CCRDvrApi14PlayDvbhStreamERjRK13SCRLiveParams @ 12 NONAME + _ZN9CCRDvrApi14PlayNullSourceERj @ 13 NONAME + _ZN9CCRDvrApi14StartTimeShiftERjj @ 14 NONAME + _ZN9CCRDvrApi16RecordDvbhStreamERjRK13SCRLiveParamsRK15SCRRecordParams @ 15 NONAME + _ZN9CCRDvrApi16RecordRtspStreamERjRK13SCRRtspParamsRK15SCRRecordParams @ 16 NONAME + _ZN9CCRDvrApi16StopRecordStreamEj @ 17 NONAME + _ZN9CCRDvrApi17ChangeDvbhServiceERjRK13SCRLiveParams @ 18 NONAME + _ZN9CCRDvrApi17PauseRecordStreamEjRKi @ 19 NONAME + _ZN9CCRDvrApi19RecordCurrentStreamEjRK15SCRRecordParams @ 20 NONAME + _ZN9CCRDvrApi21PlayRtspUrlToNullSinkERjRK13SCRRtspParams @ 21 NONAME + _ZN9CCRDvrApi4NewLEP17MCREngineObserver @ 22 NONAME + _ZN9CCRDvrApi4NewLEv @ 23 NONAME + _ZN9CCRDvrApi6SetIapERKj @ 24 NONAME + _ZN9CCRDvrApiD0Ev @ 25 NONAME + _ZN9CCRDvrApiD1Ev @ 26 NONAME + _ZN9CCRDvrApiD2Ev @ 27 NONAME + _ZTI9CCRDvrApi @ 28 NONAME ; ## + _ZTV9CCRDvrApi @ 29 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/bwins/CommonRecordingEngineClientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/bwins/CommonRecordingEngineClientU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,27 @@ +EXPORTS + ??1CCRDvrApi@@UAE@XZ @ 1 NONAME ; CCRDvrApi::~CCRDvrApi(void) + ?CancelSetIap@CCRDvrApi@@QAEHXZ @ 2 NONAME ; int CCRDvrApi::CancelSetIap(void) + ?ChangeDvbhService@CCRDvrApi@@QAEHAAIABUSCRLiveParams@@@Z @ 3 NONAME ; int CCRDvrApi::ChangeDvbhService(unsigned int &, struct SCRLiveParams const &) + ?CloseSession@CCRDvrApi@@QAEHI@Z @ 4 NONAME ; int CCRDvrApi::CloseSession(unsigned int) + ?GetPosition@CCRDvrApi@@QAEHIAA_J0@Z @ 5 NONAME ; int CCRDvrApi::GetPosition(unsigned int, long long &, long long &) + ?NewL@CCRDvrApi@@SAPAV1@PAVMCREngineObserver@@@Z @ 6 NONAME ; class CCRDvrApi * CCRDvrApi::NewL(class MCREngineObserver *) + ?NewL@CCRDvrApi@@SAPAV1@XZ @ 7 NONAME ; class CCRDvrApi * CCRDvrApi::NewL(void) + ?PauseCommand@CCRDvrApi@@QAEHI@Z @ 8 NONAME ; int CCRDvrApi::PauseCommand(unsigned int) + ?PauseRecordStream@CCRDvrApi@@QAEHIABH@Z @ 9 NONAME ; int CCRDvrApi::PauseRecordStream(unsigned int, int const &) + ?PlayCommand@CCRDvrApi@@QAEHINN@Z @ 10 NONAME ; int CCRDvrApi::PlayCommand(unsigned int, double, double) + ?PlayDvbhStream@CCRDvrApi@@QAEHAAIABUSCRLiveParams@@@Z @ 11 NONAME ; int CCRDvrApi::PlayDvbhStream(unsigned int &, struct SCRLiveParams const &) + ?PlayNullSource@CCRDvrApi@@QAEHAAI@Z @ 12 NONAME ; int CCRDvrApi::PlayNullSource(unsigned int &) + ?PlayRtpFile@CCRDvrApi@@QAEHAAIABUSCRRtpPlayParams@@@Z @ 13 NONAME ; int CCRDvrApi::PlayRtpFile(unsigned int &, struct SCRRtpPlayParams const &) + ?PlayRtpFile@CCRDvrApi@@QAEHAAIABVRFile@@@Z @ 14 NONAME ; int CCRDvrApi::PlayRtpFile(unsigned int &, class RFile const &) + ?PlayRtspUrl@CCRDvrApi@@QAEHAAIABUSCRRtspParams@@@Z @ 15 NONAME ; int CCRDvrApi::PlayRtspUrl(unsigned int &, struct SCRRtspParams const &) + ?PlayRtspUrlToNullSink@CCRDvrApi@@QAEHAAIABUSCRRtspParams@@@Z @ 16 NONAME ; int CCRDvrApi::PlayRtspUrlToNullSink(unsigned int &, struct SCRRtspParams const &) + ?RecordCurrentStream@CCRDvrApi@@QAEHIABUSCRRecordParams@@@Z @ 17 NONAME ; int CCRDvrApi::RecordCurrentStream(unsigned int, struct SCRRecordParams const &) + ?RecordDvbhStream@CCRDvrApi@@QAEHAAIABUSCRLiveParams@@ABUSCRRecordParams@@@Z @ 18 NONAME ; int CCRDvrApi::RecordDvbhStream(unsigned int &, struct SCRLiveParams const &, struct SCRRecordParams const &) + ?RecordRtspStream@CCRDvrApi@@QAEHAAIABUSCRRtspParams@@ABUSCRRecordParams@@@Z @ 19 NONAME ; int CCRDvrApi::RecordRtspStream(unsigned int &, struct SCRRtspParams const &, struct SCRRecordParams const &) + ?SetIap@CCRDvrApi@@QAEHABI@Z @ 20 NONAME ; int CCRDvrApi::SetIap(unsigned int const &) + ?SetPosition@CCRDvrApi@@QAEHI_J@Z @ 21 NONAME ; int CCRDvrApi::SetPosition(unsigned int, long long) + ?StartTimeShift@CCRDvrApi@@QAEHAAII@Z @ 22 NONAME ; int CCRDvrApi::StartTimeShift(unsigned int &, unsigned int) + ?StopCommand@CCRDvrApi@@QAEHI@Z @ 23 NONAME ; int CCRDvrApi::StopCommand(unsigned int) + ?StopRecordStream@CCRDvrApi@@QAEHI@Z @ 24 NONAME ; int CCRDvrApi::StopRecordStream(unsigned int) + ?StopTimeShift@CCRDvrApi@@QAEHII@Z @ 25 NONAME ; int CCRDvrApi::StopTimeShift(unsigned int, unsigned int) + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/group/CommonRecordingEngineClient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/group/CommonRecordingEngineClient.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Symbian style build specification for* +*/ + + + +#include "../inc/CRClientConsts.hrh" +#include + +//OPTION ARMCC --asm --interleave +ALWAYS_BUILD_AS_ARM + +TARGET CommonRecordingEngineClient.dll +TARGETTYPE dll +UID 0x1000008d KCRClientUid + +CAPABILITY CAP_GENERAL_DLL + +SOURCEPATH ../src +SOURCE CCRDvrApi.cpp +SOURCE RCRClient.cpp +SOURCE RCRService.cpp +SOURCE RCRServiceBase.cpp +SOURCE CCRApiBase.cpp +SOURCE CCRMsgQueueObserver.cpp +SOURCE CCRServerHandleSingleton.cpp + +USERINCLUDE . +USERINCLUDE ../inc +USERINCLUDE ../../CommonRecordingEngine/inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib // Common +LIBRARY efsrv.lib // File server +LIBRARY FLogger.lib // Debug logger + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common recording engine client library build info file* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/commonrecordingengineclient.iby CORE_MW_LAYER_IBY_EXPORT_PATH(commonrecordingengineclient.iby) + +PRJ_MMPFILES +CommonRecordingEngineClient.mmp + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/CCRMsgQueueObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/CCRMsgQueueObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common recording engine message queue observer* +*/ + + + + +#ifndef CCRMSGQUEUEOBSERVER_H +#define CCRMSGQUEUEOBSERVER_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class MCREngineObserver; + +// CLASS DECLARATION + +/** +* Common recording engine message queue observer. +* Uses Symbian OS class RMsgQueue. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( CCRMsgQueueObserver ) : public CActive + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCRMsgQueueObserver* NewL( ); + + /** + * Virtual destructor. + */ + virtual ~CCRMsgQueueObserver(); + +public: // New methods + + /** + * Method that adds a view to message queue's observer list. + * @since Series 60 3.0 + * @param aObserver is the object that will be notified + * @return none. + */ + void AddMsgQueueObserverL( MCREngineObserver* aObserver ); + + /** + * Sets session id to listen to. + * @since Series 60 3.0 + * @param aSessionId session id + * @return none. + */ + void SetSessionId( TInt aSessionId ); + +private: // Constructors + + /** + * C++ default constructor. + */ + CCRMsgQueueObserver( ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +private: // Methods from base classes + + /** + * From CActive. + * Handles an active object’s request completion event. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void RunL(); + + /** + * From CActive. + * Called when outstanding request is cancelled. + * This function is called as part of the active object’s Cancel(). + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DoCancel(); + + /** + * From CActive. + * Handles a leave occurring in the request completion event handler RunL(). + * @since Series 60 3.0 + * @param aError Error code. + * @return none. + */ + TInt RunError( TInt aError ); + +private: // Data + + /** + * Actual message queue. Or handle to kernel-side object. + */ + RMsgQueue iQueue; + + /** + * This is data-area for the message received from kernel side. + */ + SCRQueueEntry iReceivedMessage; + + /** + * Observers are views. + */ + RPointerArray iObservers; + + /** + * Session id to listen to + */ + TInt iSessionId; + + }; + +#endif // CCRMSGQUEUEOBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/CCRServerHandleSingleton.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/CCRServerHandleSingleton.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,125 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Singleton to hold server session* +*/ + + + + +#ifndef CCRSERVERHADLESINGLETON_H +#define CCRSERVERHADLESINGLETON_H + +// INCLUDES +#include "RCRService.h" +#include "RCRClient.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRAPIBase; + +// CLASS DECLARATION + +/** +* Singleton class to store client handles. Instance of this class is kept +* in TLS and a reference count is maintained. This is to ensure that if a +* process creates multiple CCRDvrApi instances, they will all share the +* same session to CommonRecordingEngine. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( CCRServerHandleSingleton ) : public CBase + { + + /** + * CCRApiBase and CCRDvrApi are the only classes + * that should have access to this class. + */ + friend class CCRApiBase; + friend class CCRDvrApi; + +private: // Constructors and destructors + + /** + * Private constructor to prevent direct instantiation. InstanceL must be used. + */ + CCRServerHandleSingleton(); + + /** + * Second phase of 2-phased construction + */ + void ConstructL(); + + /** + * Private destructor to prevent direct deletion. Release must be used. + */ + ~CCRServerHandleSingleton(); + +private: // New methods + + /** + * Returns the singleton instance. If it does not yet exist, it is created. + * If it does, a reference count is incremented + * @since Series 60 3.0 + * @param none. + * @return Instance to singleton class. + */ + static CCRServerHandleSingleton* InstanceL(); + + /** + * Releases the singleton instance. If reference count reaches zero, the + * instance is destroyed and client connection closed. + */ + static void Release(); + + /** + * Returns a reference to the service handle + * @since Series 60 3.0 + * @param none. + * @return Reference to RCRService + */ + inline RCRService& Service() { return iService; } + +private: // Data + + /** + * Amount of references to this instance. + * Instance will be deleted when this reaches zero. + */ + TInt iReferenceCount; + + /** + * Handle to Recording Engine client. + */ + RCRClient iClient; + + /** + * Handle to Recording Engine services. + */ + RCRService iService; + + }; + +#endif // CCRSERVERHADLESINGLETON_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/CRClientConsts.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/CRClientConsts.hrh Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common constant definitions* +*/ + + + + + +#ifndef __CRCLIENTCONSTS_H +#define __CRCLIENTCONSTS_H + +#define KCRClientUid 0x1028242E + +#endif // __CRCLIENTCONSTS_H + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/RCRClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/RCRClient.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for RC Client class* +*/ + + + + +#ifndef RCRCLIENT_H +#define RCRCLIENT_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* This is the client-side interface through which communication +* with the server is channelled. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( RCRClient ) : public RSessionBase + { + +public: // Constructors and destructor + + /** + * C++ default constructor. + * @param none. + * @return none. + */ + RCRClient(); + +public: // New methods + + /** + * Connects to the server. + * @since Series 60 3.0 + * @param none. + * @return KErrNone if successful, + * otherwise another of the system-wide error code. + */ + TInt Connect(); + + /** + * Closes the session. + * @since Series 60 3.0 + * @param none. + * @return None + */ + void Close(); + + /** + * Version. + * @since Series 60 3.0 + * @param none. + * @return version number. + */ + TVersion Version() const; + + }; + +#endif // RCRCLIENT_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/RCRService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/RCRService.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,301 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for RC Client's Service class* +*/ + + + + +#ifndef RCRSERVICE_H +#define RCRSERVICE_H + +// INCLUDES +#include "RCRServiceBase.h" +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class RCRClient; + +// CLASS DECLARATION + +/** +* This is the actual client API that passes commands +* to server side. CCRDvrApi and other classes visible +* to client application are merely wrappers to this +* class. If CCRDvrApi has method foo, it will just +* call method foo if this class here and this will in +* turn say something like return SendReceive( ECRDoFooInServer, args ); +* This needs to have implementations of all the engine +* methods of all client classes. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( RCRService ) : public RCRServiceBase + { + +public: // Constructors and destructor + + /** + * Constructor. + */ + RCRService(); + +public: // New methods + + /** + * Tells receiving engine which IAP to use. + * @since Series 60 3.0 + * @param aIapId is the internet access point id. + * @return none. + */ + TInt SetIap( const TSubConnectionUniqueId& aIapId ); + + /** + * Tells receiving engine to cancel IAP selection. + * @since Series 60 3.0 + */ + TInt CancelSetIap(); + + /** + * Prepares live IPTV PTSP stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspParams parameter set for rtsp. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayRtspUrl( TUint& aSessionChk, + const SCRRtspParams& aRtspParams ); + + /** + * Prepares DVB-H live stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams parameter set for DVB-H. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayDvbhStream( TUint& aSessionChk, + const SCRLiveParams& aLiveParams ); + + /** + * Changes DVB-H live stream service. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams parameter set for DVB-H. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt ChangeDvbhService( TUint& aSessionChk, + const SCRLiveParams& aLiveParams ); + + /** + * Prepares clip RTP stream from a name. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtpFile parameter set for rtsp. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayRtpFile( TUint& aSessionChk, + const SCRRtpPlayParams& aRtpFile ); + + /** + * Prepares clip RTP stream from a file handle. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtpHandle a open file handle for RTP file. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayRtpFile( TUint& aSessionChk, + const RFile& aRtpHandle ); + + /** + * Starts currently active stream recording. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRecordParams a parameters for recording. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt RecordCurrentStream( const TUint aSessionChk, + const SCRRecordParams& aRecordParams ); + + /** + * Starts recording for RTSP live stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspUrl is set of parameters required for rtsp. + * @param aRecordParams a parameters for recording. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt RecordRtspStream( TUint& aSessionChk, + const SCRRtspParams& aRtspUrl, + const SCRRecordParams& aRecordParams ); + + /** + * Starts DVB-H recording. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams is set of parameters required for DVB-H. + * @param aRecordParams a parameters for recording. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt RecordDvbhStream( TUint& aSessionChk, + const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ); + + /** + * Pauses/Resumes recording. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aStart a start or end pausing. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PauseRecordStream( const TUint aSessionChk, + const TBool& aStart ); + + /** + * Stops recording. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt StopRecordStream( const TUint aSessionChk ); + + /** + * Starts time shift mode. + * @since Series 60 3.0 + * @param aTimeShiftChk a session definition checksum. + * @param aSessionChk a session definition of existing session. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt StartTimeShift( TUint& aTimeShiftChk, + const TUint aSessionChk ); + + /** + * Stops time shift mode. + * @since Series 60 3.0 + * @param aTimeShiftChk a session definition checksum. + * @param aCurrentChk a session definition of existing session. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt StopTimeShift( const TUint aTimeShiftChk, + const TUint aCurrentChk ); + + /** + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayCommand( const TUint aSessionChk, + const TReal& aStartPos, + const TReal& aEndPos ); + + /** + * Method for ordering "pause" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PauseCommand( const TUint aSessionChk ); + + /** + * Method for ordering "stop" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt StopCommand( const TUint aSessionChk ); + + /** + * Setter for play position of packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aPosition a postion of RTP playback. + * @param aDuration a duration of RTP clip. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt SetPosition( const TUint aSessionChk, + const TInt64 aPosition ); + + /** + * Getter for play position of packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aPosition a postion of RTP playback. + * @param aDuration a duration of RTP clip. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt GetPosition( const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ); + + /** + * Method for ordering closing a source and all sinks. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + TInt CloseSession( const TUint aSessionChk ); + + /** + * Prepares rtp file playing as a live source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayNullSource( TUint& aSessionChk ); + + /** + * Prepares live IPTV PTSP stream to null sink. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspParams a active live parameters. + * @return KErrNone if successful, + * otherwise another of the system-wide error codes. + */ + TInt PlayRtspUrlToNullSink( TUint& aSessionChk, + const SCRRtspParams& aRtspParams ); + }; + +#endif // RCRSERVICE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/inc/RCRServiceBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/inc/RCRServiceBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for CR Client's ServiceBase class.* +*/ + + + + +#ifndef RCRSERVICEBASE_H +#define RCRSERVICEBASE_H + +// INCLUDES +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class RCRClient; + +// CLASS DECLARATION + +/** +* Base class for services. This represents a client-side sub-session +* and has a corresponding sub-session object on the server-side. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( RCRServiceBase ) : public RSubSessionBase + { + +public: // Constructors and destructors + + /** + * C++ default constructor. + */ + RCRServiceBase::RCRServiceBase( ); + + /** + * Open server. + * @since Series 60 3.0 + * @param aClient a reference to the client. + * @return KErrNone if successful, otherwise one of the system-wide error codes. + */ + TInt Open( RCRClient& aClient ); + + /** + * Close server. + * @since Series 60 3.0 + * @param none. + * @return None + */ + void Close(); + + /** + * Uses user panic to panic client. + * @since Series 60 3.0 + * @param aFault Panic reason. + * @return None. + */ + void PanicClient( TInt aFault ); + + /** + * Getter for sessionhandle. + * @since Series 60 3.0 + * @param none. + * @return None. + */ + inline RCRClient& SessionHandle() { return *iClient; } + +private: // Data + + /** + * Pointer to client. Not owned. + */ + RCRClient* iClient; + + }; + +#endif // RCRSERVICEBASE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/rom/commonrecordingengineclient.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/rom/commonrecordingengineclient.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __COMMONRECORDINGENGINECLIENT_IBY__ +#define __COMMONRECORDINGENGINECLIENT_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\CommonRecordingEngineClient.dll SHARED_LIB_DIR\CommonRecordingEngineClient.dll + +#endif // __COMMONRECORDINGENGINECLIENT_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/CCRAPIBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/CCRAPIBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of IptvRTP client's API* +*/ + + + + +// INCLUDE FILES +#include +#include "CCRServerHandleSingleton.h" + +// CONSTANTS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRApiBase::CCRApiBase +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRApiBase::CCRApiBase() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRApiBase::BaseConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRApiBase::BaseConstructL() + { + iSingleton = CCRServerHandleSingleton::InstanceL(); + } + +// ----------------------------------------------------------------------------- +// CCRApiBase::~CCRApiBase +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRApiBase::~CCRApiBase() + { + CCRServerHandleSingleton::Release(); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/CCRDvrApi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/CCRDvrApi.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,398 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of IptvRTP client's API* +*/ + + + + +// INCLUDE FILES +#include +#include "RCRService.h" +#include "RCRClient.h" +#include +#include "CCRMsgQueueObserver.h" +#include "CCRServerHandleSingleton.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRDvrApi::NewL +// Static two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CCRDvrApi* CCRDvrApi::NewL( MCREngineObserver *aObserver ) + { + CCRDvrApi* self = new( ELeave ) CCRDvrApi(); + CleanupStack::PushL( self ); + self->ConstructL( aObserver ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::NewL +// Static two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CCRDvrApi* CCRDvrApi::NewL() + { + CCRDvrApi* self = new( ELeave ) CCRDvrApi(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::CCRDvrApi +// ----------------------------------------------------------------------------- +// +CCRDvrApi::CCRDvrApi() + { + // None + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRDvrApi::ConstructL( MCREngineObserver *aObserver ) + { + CCRApiBase::BaseConstructL(); + iQueueObserver = CCRMsgQueueObserver::NewL(); + iQueueObserver->SetSessionId( 0 ); + iQueueObserver->AddMsgQueueObserverL( aObserver ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRDvrApi::ConstructL() + { + CCRApiBase::BaseConstructL(); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::~CCRDvrApi +// ----------------------------------------------------------------------------- +// +EXPORT_C CCRDvrApi::~CCRDvrApi() + { + // note what happens in CCRAPIBase, the iClient et al. + // might get deleted there. + delete iQueueObserver; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::SetIap +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::SetIap( const TSubConnectionUniqueId& aIapId ) + { + return iSingleton->Service().SetIap( aIapId ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::CancelSetIap +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::CancelSetIap() + { + return iSingleton->Service().CancelSetIap(); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayRtspUrl +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayRtspUrl( + TUint& aSessionChk, + const SCRRtspParams& aRtspUrl ) + { + iQueueObserver->SetSessionId( 0 ); + TInt err( iSingleton->Service().PlayRtspUrl( aSessionChk, aRtspUrl ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayDvbhStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayDvbhStream( + TUint& aSessionChk, + const SCRLiveParams& aDvbhLive ) + { + iQueueObserver->SetSessionId( 0 ); + TInt err( iSingleton->Service().PlayDvbhStream( aSessionChk, aDvbhLive ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::ChangeDvbhService +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::ChangeDvbhService( + TUint& aSessionChk, + const SCRLiveParams& aDvbhLive ) + { + TInt err( iSingleton->Service().ChangeDvbhService( aSessionChk, aDvbhLive ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayRtpFile +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayRtpFile( + TUint& aSessionChk, + const SCRRtpPlayParams& aRtpFile ) + { + iQueueObserver->SetSessionId( 0 ); + TInt err( iSingleton->Service().PlayRtpFile( aSessionChk, aRtpFile ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayRtpFile +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayRtpFile( + TUint& aSessionChk, + const RFile& aRtpHandle ) + { + iQueueObserver->SetSessionId( 0 ); + TInt err( iSingleton->Service().PlayRtpFile( aSessionChk, aRtpHandle ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::RecordCurrentStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::RecordCurrentStream( + const TUint aSessionChk, + const SCRRecordParams& aRecordParams ) + { + return iSingleton->Service().RecordCurrentStream( aSessionChk, aRecordParams ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::RecordRtspStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::RecordRtspStream( + TUint& aSessionChk, + const SCRRtspParams& aRtspUrl, + const SCRRecordParams& aRecordParams ) + { + return iSingleton->Service().RecordRtspStream( + aSessionChk, aRtspUrl, aRecordParams ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::RecordDvbhStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::RecordDvbhStream( + TUint& aSessionChk, + const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ) + { + return iSingleton->Service().RecordDvbhStream( + aSessionChk, aLiveParams, aRecordParams ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PauseRecordStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PauseRecordStream( + const TUint aSessionChk, + const TBool& aStart ) + { + return iSingleton->Service().PauseRecordStream( aSessionChk, aStart ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::StopRecordStream +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::StopRecordStream( const TUint aSessionChk ) + { + return iSingleton->Service().StopRecordStream( aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::StartTimeShift +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::StartTimeShift( + TUint& aTimeShiftChk, + const TUint aSessionChk ) + { + return iSingleton->Service().StartTimeShift( aTimeShiftChk, aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::StopTimeShift +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::StopTimeShift( + const TUint aTimeShiftChk, + const TUint aCurrentChk ) + { + return iSingleton->Service().StopTimeShift( aTimeShiftChk, aCurrentChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayCommand +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayCommand( + const TUint aSessionChk, + const TReal aStartPos, + const TReal aEndPos ) + { + return iSingleton->Service().PlayCommand( aSessionChk, aStartPos, aEndPos ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PauseCommand +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PauseCommand( const TUint aSessionChk ) + { + return iSingleton->Service().PauseCommand( aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::StopCommand +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::StopCommand( const TUint aSessionChk ) + { + return iSingleton->Service().StopCommand( aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::SetPosition +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::SetPosition( + const TUint aSessionChk, + const TInt64 aPosition ) + { + return iSingleton->Service().SetPosition( aSessionChk, aPosition ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::GetPosition +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::GetPosition( + const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ) + { + return iSingleton->Service().GetPosition( aSessionChk, aPosition, aDuration ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::CloseSession +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::CloseSession( const TUint aSessionChk ) + { + return iSingleton->Service().CloseSession( aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayNullSource +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayNullSource( TUint& aSessionChk ) + { + return iSingleton->Service().PlayNullSource( aSessionChk ); + } + +// ----------------------------------------------------------------------------- +// CCRDvrApi::PlayRtspUrlToNullSink +// +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CCRDvrApi::PlayRtspUrlToNullSink( + TUint& aSessionChk, + const SCRRtspParams& aRtspUrl ) + { + iQueueObserver->SetSessionId( 0 ); + TInt err( iSingleton->Service().PlayRtspUrlToNullSink( aSessionChk, aRtspUrl ) ); + if ( !err ) + { + iQueueObserver->SetSessionId( aSessionChk ); + } + return err; + } + +// End of File + + diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/CCRMsgQueueObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/CCRMsgQueueObserver.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Offers interface to RMsgQueue in civilized manner.* +*/ + + + + +// INCLUDE FILES +#include "CCRMsgQueueObserver.h" +#include +#include +#include "videoserviceutilsLogger.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CCRMsgQueueObserver* CCRMsgQueueObserver::NewL() + { + CCRMsgQueueObserver* self = new( ELeave ) CCRMsgQueueObserver(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::CCRMsgQueueObserver() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCRMsgQueueObserver::CCRMsgQueueObserver() : CActive( EPriorityAbsoluteHigh ) + { + // Note! CActive's priority must be absolute high for ensure that + // the messages are arrived in right order to VIA. + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CCRMsgQueueObserver::ConstructL() + { + LOG( "CCRMsgQueueObserver::ConstructL() in" ); + + RProcess process; + TInt handleId( process.Handle() ); + TBuf queueName; + queueName.Format(KCRMsgQueueName, handleId); + queueName.Trim(); + TInt err( iQueue.CreateGlobal( queueName, + sizeof( SCRQueueEntry ) ) ); + LOG2( "CCRMsgQueueObserver createglobal %S = %d", &queueName, err ); + err = iQueue.OpenGlobal( queueName ) ; + LOG1( "CCRMsgQueueObserver openglobal = %d", err ); + User::LeaveIfError( err ); + iQueue.NotifyDataAvailable( iStatus ); + LOG1( "CCRMsgQueueObserver queue message size is %d", iQueue.MessageSize() ); + SetActive(); + + LOG( "CCRMsgQueueObserver::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::~CCRMsgQueueObserver() +// Destructor. +// ----------------------------------------------------------------------------- +// +CCRMsgQueueObserver::~CCRMsgQueueObserver() + { + LOG( "CCRMsgQueueObserver::~CCRMsgQueueObserver() in" ); + + Cancel(); + iQueue.Close(); + iObservers.Reset(); + iObservers.Close(); + + LOG( "CCRMsgQueueObserver::~CCRMsgQueueObserver() out" ); + } + + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::RunL() +// From CActive +// ----------------------------------------------------------------------------- +// +void CCRMsgQueueObserver::RunL() + { + LOG1( "CCRMsgQueueObserver::RunL() in, iStatus: %d", iStatus.Int() ); + + if ( iStatus.Int() == KErrNone ) + { + TInt i( 0 ); + if ( iQueue.Receive( iReceivedMessage ) == KErrNone ) + { + if ( !iReceivedMessage.iSessionId || // or our id has not been set yet + iReceivedMessage.iSessionId == iSessionId ) // if the id matches + { + switch ( iReceivedMessage.iMsg ) + { + case ECRMsgQueueAuthenticationNeeded: + LOG( "CCRMsgQueueObserver EAuthenticationFailed" ); + SCRObserverMsg authNotify; + authNotify.iMsg = ECRAuthenticationNeeded; + authNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( authNotify ) ); + } + + break; + + case ECRMsgQueueAttachCompleted: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueAttachCompleted" ); + SCRObserverMsg iapNotify; + iapNotify.iMsg = ECRAttachCompleted; + iapNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( iapNotify ) ); + } + } + break; + + case ECRMsgQueueConnectionError: + { + LOG1( "CCRMsgQueueObserver ECRMsgQueueConnectionError, iReceivedMessage.iErr: %d", + iReceivedMessage.iErr ); + SCRObserverMsg iapNotify; + iapNotify.iMsg = ECRConnectionError; + iapNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( iapNotify ) ); + } + } + break; + + case ECRMsgQueueNotEnoughBandwidth: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueNotEnoughBandwidth" ); + SCRObserverMsg iapNotify; + iapNotify.iMsg = ECRNotEnoughBandwidth; + iapNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( iapNotify ) ); + } + } + break; + + case ECRMsgQueueSwitchingToTcp: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueSwitchingToTcp" ); + SCRObserverMsg iapNotify; + iapNotify.iMsg = ECRSwitchingToTcp; + iapNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( iapNotify ) ); + } + } + break; + + case ECRMsgQueueNormalEndOfStream: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueNormalEndOfStream" ); + SCRObserverMsg iapNotify; + iapNotify.iMsg = ECRNormalEndOfStream; + iapNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( iapNotify ) ); + } + } + break; + + case ECRMsgQueueStreamIsLiveStream: + { + LOG( "CCRMsgQueueObserver ECRMsgStreamIsLiveStream" ); + SCRObserverMsg liveStreamNotify; + liveStreamNotify.iMsg = ECRStreamIsLiveStream; + liveStreamNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( liveStreamNotify ) ); + } + } + break; + + case ECRMsgQueueStreamIsRealMedia: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueStreamIsRealMedia" ); + SCRObserverMsg realStreamNotify; + realStreamNotify.iMsg = ECRRealNetworksStream; + realStreamNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( realStreamNotify ) ); + } + } + break; + + case ECRMsgQueueTestSinkData: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueTestSinkData" ); + SCRObserverMsg testSinkDataNotify; + testSinkDataNotify.iMsg = ECRTestSinkData; + testSinkDataNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( testSinkDataNotify ) ); + } + } + break; + + case ECRMsgQueueSdpAvailable: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueSdpAvailable" ); + SCRObserverMsg sdpAvailableNotify; + sdpAvailableNotify.iMsg = ECRSdpAvailable; + sdpAvailableNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( sdpAvailableNotify ) ); + } + } + break; + + case ECRMsgQueueReadyToSeek: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueReadyToSeek" ); + SCRObserverMsg readyToSeekNotify; + readyToSeekNotify.iMsg = ECRReadyToSeek; + readyToSeekNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( readyToSeekNotify ) ); + } + } + break; + + case ECRMsgQueueRecordingStarted: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueRecordingStarted" ); + SCRObserverMsg realStreamNotify; + realStreamNotify.iMsg = ECRRecordingStarted; + realStreamNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( realStreamNotify ) ); + } + } + break; + + case ECRMsgQueueRecordingPaused: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueRecordingState" ); + SCRObserverMsg realStreamNotify; + realStreamNotify.iMsg = ECRRecordingPaused; + realStreamNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( realStreamNotify ) ); + } + } + break; + + case ECRMsgQueueRecordingEnded: + { + LOG( "CCRMsgQueueObserver ECRMsgQueueRecordingState" ); + SCRObserverMsg realStreamNotify; + realStreamNotify.iMsg = ECRRecordingEnded; + realStreamNotify.iErr = iReceivedMessage.iErr; + for ( i = 0; i < iObservers.Count(); i ++ ) + { + TRAP_IGNORE( iObservers[i]->NotifyL( realStreamNotify ) ); + } + } + break; + + default: + { + LOG1( "Unknown message: %d", iReceivedMessage.iMsg ); + } + break; + } + } + else // message belongs to different session + { + LOG2( "Ignoring message: msg.sessionId=%d, iSessionId=%d", + iReceivedMessage.iSessionId, iSessionId ); + } + } + } + + iQueue.NotifyDataAvailable( iStatus ); + SetActive(); + LOG( "CCRMsgQueueObserver::RunL() out" ); + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::RunError() +// From CActive +// ----------------------------------------------------------------------------- +// +TInt CCRMsgQueueObserver::RunError( TInt aError ) + { + LOG1( "CCRMsgQueueObserver::RunError(), aError: %d", aError ); + return aError; + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::DoCancel() +// From CActive +// ----------------------------------------------------------------------------- +// +void CCRMsgQueueObserver::DoCancel() + { + LOG( "CCRMsgQueueObserver::DoCancel()" ); + iQueue.CancelDataAvailable(); + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::AddMsgQueueObserverL() +// Addes object to observer array +// ----------------------------------------------------------------------------- +// +void CCRMsgQueueObserver::AddMsgQueueObserverL( MCREngineObserver* aObserver ) + { + User::LeaveIfError( iObservers.Append( aObserver ) ); + } + +// ----------------------------------------------------------------------------- +// CCRMsgQueueObserver::SetSessionId() +// Sets session id to listen to +// ----------------------------------------------------------------------------- +// +void CCRMsgQueueObserver::SetSessionId( TInt aSessionId ) + { + iSessionId = aSessionId; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/CCRServerHandleSingleton.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/CCRServerHandleSingleton.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Singleton to hold server session* +*/ + + + + +// INCLUDE FILES +#include "CCRServerHandleSingleton.h" + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CCRServerHandleSingleton::CCRServerHandleSingleton() : iReferenceCount( 1 ) + { + // None + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +CCRServerHandleSingleton::~CCRServerHandleSingleton() + { + iService.Close(); + iClient.Close(); + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void CCRServerHandleSingleton::ConstructL() + { + User::LeaveIfError( iClient.Connect() ); + User::LeaveIfError( iService.Open( iClient ) ); + } + +// ----------------------------------------------------------------------------- +// Returns the singleton instance. +// ----------------------------------------------------------------------------- +// +CCRServerHandleSingleton* CCRServerHandleSingleton::InstanceL() + { + CCRServerHandleSingleton* self = NULL; + + TAny* tlsPtr = Dll::Tls(); + if ( tlsPtr == NULL ) + { + self = new( ELeave ) CCRServerHandleSingleton; + CleanupStack::PushL( self ); + self->ConstructL(); + User::LeaveIfError( Dll::SetTls( self ) ); + CleanupStack::Pop( self ); + } + else + { + self = static_cast( tlsPtr ); + ++self->iReferenceCount; + } + + return self; + } + +// ----------------------------------------------------------------------------- +// Releases the singleton instance. +// ----------------------------------------------------------------------------- +// +void CCRServerHandleSingleton::Release() + { + TAny* tlsPtr = Dll::Tls(); + __ASSERT_DEBUG( tlsPtr != NULL, User::Panic( _L( "CCRApiBase" ), KErrNotFound ) ); + + if ( tlsPtr != NULL ) + { + CCRServerHandleSingleton* self = static_cast( tlsPtr ); + if ( --self->iReferenceCount == 0 ) + { + delete self; + Dll::FreeTls(); + } + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/RCRClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/RCRClient.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of CR client's Server* +*/ + + + + +// INCLUDE FILES +#include "RCRClient.h" +#include +#include +#include + +// CONSTANTS +const TUint KDefaultMessageSlots( 4 ); +const TUint KNumberOfServerStartupAttempts( 2 ); + +// LOCAL FUNCTION PROTOTYPES +static TInt StartServer(); +static TInt CreateServerProcess(); + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// StartServer +// Returns: Error code +// ----------------------------------------------------------------------------- +// +static TInt StartServer() + { + TFindServer findServer( KCRServerNameExe ); + TFullName name( KNullDesC ); + + // Server already running? + TInt result( findServer.Next( name ) ); + if ( !result ) + { + return KErrNone; + } + + // Process + result = CreateServerProcess(); + + return result; + } + +// ----------------------------------------------------------------------------- +// CreateServerProcess +// +// ----------------------------------------------------------------------------- +// +static TInt CreateServerProcess() + { + RProcess server; + TInt err( server.Create( KCRServerNameExe , _L( "" ) ) ); + if ( err ) + { + return err; + } + + // Makes the server eligible for execution. + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + + server.Resume(); + + User::WaitForRequest(reqStatus); + + if( reqStatus.Int() != KErrNone ) + { + server.Close(); + } + + return reqStatus.Int(); + } + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RCRClient::RCRClient +// +// ----------------------------------------------------------------------------- +// +RCRClient::RCRClient() : RSessionBase() + { + // None + } + +// ----------------------------------------------------------------------------- +// RCRClient::Connect +// +// ----------------------------------------------------------------------------- +// +TInt RCRClient::Connect() + { + TInt ret( KErrNotFound ); + TInt retry( KNumberOfServerStartupAttempts ); + do + { + // Start + ret = StartServer(); + if ( ret != KErrNone && ret != KErrAlreadyExists ) + { + return ret; + } + + // Subsession + ret = CreateSession( KCRServerNameExe, Version(), KDefaultMessageSlots ); + if ( ret != KErrNotFound && ret != KErrServerTerminated ) + { + return ret; + } + + retry--; + } + while( retry >= 0 ); + + return ret; + } + +// ----------------------------------------------------------------------------- +// RCRClient::Close +// +// ----------------------------------------------------------------------------- +// +void RCRClient::Close() + { + TIpcArgs args( TIpcArgs::ENothing ); + SendReceive( ECRServCloseSession, args ); + RHandleBase::Close(); + } + +// ----------------------------------------------------------------------------- +// RCRClient::Version +// +// ----------------------------------------------------------------------------- +// +TVersion RCRClient::Version( void ) const + { + return( TVersion( KCRServMajorVersionNumber, + KCRServMinorVersionNumber, + KCRServBuildVersionNumber ) ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/RCRService.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/RCRService.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,518 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RC client's Service* +*/ + + + + +// INCLUDE FILES +#include "RCRService.h" +#include +#include + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RCRService::RCRService +// +// ----------------------------------------------------------------------------- +// +RCRService::RCRService() : RCRServiceBase() + { + // None + } + +// ----------------------------------------------------------------------------- +// RCRService::SetIap +// LiveTV specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::SetIap( const TSubConnectionUniqueId& aIapId ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + SCRRtspIapParams msg; + RProcess process; + TInt handleId( process.Handle() ); + msg.iQueueName.Format( KCRMsgQueueName, handleId ); + msg.iQueueName.Trim(); + msg.iConnectionId = aIapId; + + TPckgBuf pckg( msg ); + TIpcArgs args( &pckg ); + return SendReceive( ECRSetIap, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::CancelSetIap +// LiveTV specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::CancelSetIap() + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TIpcArgs args; + return SendReceive( ECRCancelSetIap, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayRtspUrl +// LiveTV specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayRtspUrl( + TUint& aSessionChk, + const SCRRtspParams& aRtspParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aRtspParams ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRPlayRtspUrl, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayDvbhStream +// DVB-H specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayDvbhStream( + TUint& aSessionChk, + const SCRLiveParams& aLiveParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aLiveParams ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRPlayDvbhLive, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::ChangeDvbhService +// DVB-H specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::ChangeDvbhService( + TUint& aSessionChk, + const SCRLiveParams& aLiveParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aLiveParams ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRChangeService, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayRtpFile +// DVB-H specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayRtpFile( + TUint& aSessionChk, + const SCRRtpPlayParams& aRtpFile ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aRtpFile ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRPlayRtpFile, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayRtpFile +// DVB-H specific. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayRtpFile( + TUint& aSessionChk, + const RFile& aRtpHandle ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg( 0 ); + TIpcArgs args( &pckg ); + aRtpHandle.TransferToServer( args, 1, 2 ); + TInt err( SendReceive( ECRPlayRtpHandle, args ) ); + aSessionChk = pckg(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::RecordCurrentStream +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::RecordCurrentStream( + const TUint aSessionChk, + const SCRRecordParams& aRecordParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aRecordParams ); + TIpcArgs args( &pckg0, &pckg1 ); + return SendReceive( ECRRecordCurrentStream, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::RecordRtspStream +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::RecordRtspStream( + TUint& aSessionChk, + const SCRRtspParams& aRtspUrl, + const SCRRecordParams& aRecordParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aRtspUrl ); + TPckgBuf pckg2( aRecordParams ); + TIpcArgs args( &pckg0, &pckg1, &pckg2 ); + TInt err( SendReceive( ECRRecordRtspStream, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::RecordDvbhStream +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::RecordDvbhStream( + TUint& aSessionChk, + const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aLiveParams ); + TPckgBuf pckg2( aRecordParams ); + TIpcArgs args( &pckg0, &pckg1, &pckg2 ); + TInt err( SendReceive( ECRRecordDvbhStream, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PauseRecordStream +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PauseRecordStream( const TUint aSessionChk, const TBool& aStart ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aStart ); + TIpcArgs args( &pckg0, &pckg1 ); + return SendReceive( ECRPauseRecordStream, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::StopRecordStream +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::StopRecordStream( const TUint aSessionChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TIpcArgs args( &pckg0 ); + return SendReceive( ECRStopRecordStream, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::StartTimeShift +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::StartTimeShift( + TUint& aTimeShiftChk, + const TUint aCurrentChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aCurrentChk ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRStartTimeShift, args ) ); + aTimeShiftChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::StopTimeShift +// UI command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::StopTimeShift( + const TUint aTimeShiftChk, + const TUint aCurrentChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aTimeShiftChk ); + TPckgBuf pckg1( aCurrentChk ); + TIpcArgs args( &pckg0, &pckg1 ); + return SendReceive( ECRStopTimeShift, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayCommand +// Player command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayCommand( + const TUint aSessionChk, + const TReal& aStartPos, + const TReal& aEndPos ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aStartPos ); + TPckgBuf pckg2( aEndPos ); + TIpcArgs args( &pckg0, &pckg1, &pckg2 ); + return SendReceive( ECRPlayCommand, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PauseCommand +// Player command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PauseCommand( const TUint aSessionChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TIpcArgs args( &pckg0 ); + return SendReceive( ECRPauseCommand, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::StopCommand +// Player command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::StopCommand( const TUint aSessionChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TIpcArgs args( &pckg0 ); + return SendReceive( ECRStopCommand, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::SetPosition +// Sets position of packet source. +// ----------------------------------------------------------------------------- +// +TInt RCRService::SetPosition( + const TUint aSessionChk, + const TInt64 aPosition ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aPosition ); + + TIpcArgs args( &pckg0, &pckg1 ); + return SendReceive( ECRSetPosition, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::GetPosition +// Gets position of packet source. +// ----------------------------------------------------------------------------- +// +TInt RCRService::GetPosition( + const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TPckgBuf pckg1( aPosition ); + TPckgBuf pckg2( 0 ); + + TIpcArgs args( &pckg0, &pckg1, &pckg2 ); + TInt err( SendReceive( ECRGetPosition, args ) ); + aPosition = pckg1(); + aDuration = pckg2(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::CloseSession +// Player command. +// ----------------------------------------------------------------------------- +// +TInt RCRService::CloseSession( const TUint aSessionChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( aSessionChk ); + TIpcArgs args( &pckg0 ); + return SendReceive( ECRCloseSession, args ); + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayNullSource +// Debug purposes. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayNullSource( TUint& aSessionChk ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TIpcArgs args( &pckg0 ); + TInt err( SendReceive( ECRPlayNullSource, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// ----------------------------------------------------------------------------- +// RCRService::PlayRtspUrlToNullSink +// Debug purposes. +// ----------------------------------------------------------------------------- +// +TInt RCRService::PlayRtspUrlToNullSink( + TUint& aSessionChk, + const SCRRtspParams& aRtspParams ) + { + __ASSERT_ALWAYS( &( SessionHandle() ), PanicClient( KErrBadHandle ) ); + if ( SubSessionHandle() ) + { + TPckgBuf pckg0( 0 ); + TPckgBuf pckg1( aRtspParams ); + TIpcArgs args( &pckg0, &pckg1 ); + TInt err( SendReceive( ECRPlayRtspUrlToNullSink, args ) ); + aSessionChk = pckg0(); + return err; + } + + return KErrServerTerminated; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/CommonRecordingEngineClient/src/RCRServiceBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/CommonRecordingEngineClient/src/RCRServiceBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RC client's ServiceBase* +*/ + + + + +// INCLUDE FILES +#include "RCRServiceBase.h" +#include "RCRClient.h" +#include + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RCRServiceBase::RCRServiceBase +// +// ----------------------------------------------------------------------------- +// +RCRServiceBase::RCRServiceBase() + : RSubSessionBase(), + iClient( NULL ) + { + // None + } + +// ----------------------------------------------------------------------------- +// RCRServiceBase::Open +// +// ----------------------------------------------------------------------------- +// +TInt RCRServiceBase::Open( RCRClient& aClient ) + { + __ASSERT_ALWAYS( aClient.Handle(), PanicClient( KErrBadHandle ) ); + iClient = &aClient; + TIpcArgs args( TIpcArgs::ENothing ); + return CreateSubSession( aClient, ECRServCreateSubSession, args ); + } + +// ----------------------------------------------------------------------------- +// RCRServiceBase::Close +// +// ----------------------------------------------------------------------------- +// +void RCRServiceBase::Close() + { + RSubSessionBase::CloseSubSession( ECRServCloseSubSession ); + } + +// ----------------------------------------------------------------------------- +// RCRServiceBase::PanicClient +// +// ----------------------------------------------------------------------------- +// +void RCRServiceBase::PanicClient( TInt aFault ) + { + _LIT( KCRClientFault, "CRApi Client Fault" ); + User::Panic( KCRClientFault, aFault ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 dvrengine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dvrengine/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for RTP engine.* +*/ + + + + +#include +#include "../CommonRecordingEngine/inc/VideoServiceUtilsConf.hrh" + +#ifdef RD_IPTV_FEA_RTP_CLIP_SUPPORT +#include "../CommonRecordingEngine/DvrRtpUtils/group/bld.inf" +#include "../CommonRecordingEngine/DvrRtpClipHandler/group/bld.inf" +#include "../CommonRecordingEngine/DvrRtpClipRecognizer/group/bld.inf" +#endif // RD_IPTV_FEA_RTP_CLIP_SUPPORT + +#include "../CommonRecordingEngine/group/bld.inf" +#include "../CommonRecordingEngineClient/Group/bld.inf" + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +#include "../videoutils_plat/group/bld.inf" +#include "../videoscheduler/group/bld.inf" +#include "../videoconnutility/group/bld.inf" + + +PRJ_EXPORTS + +PRJ_MMPFILES + + +PRJ_TESTMMPFILES +#include "../tsrc/group/bld.inf" diff -r 826cea16efd9 -r 13a33d82ad98 group/cleaner.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/cleaner.bat Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of the License "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: Cleaner script that tries to really clean everything +rem from the environment. +rem + +@echo off +perl -S cleaner.pl %1 %2 %3 diff -r 826cea16efd9 -r 13a33d82ad98 group/cleaner.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/cleaner.mk Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @perl -S cleaner.pl clean + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : do_nothing + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : do_nothing + +FINAL : do_nothing diff -r 826cea16efd9 -r 13a33d82ad98 group/cleaner.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/cleaner.pl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,266 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Cleaner script to perform more thorough cleanup than abld reallyclean# + +use strict; +use constant DEBUG => 0; + +my $iCleanup_file = "cleanup.txt"; +my @iErrors = (); +my $iTag_platform = "__PLATFORM__"; +my $iTag_target = "__TARGET__"; +my @iPlatforms = ( "winscw", "armv5" ); +my @iTargets = ( "udeb", "urel" ); +my $iSlowClean = 0; +my $iTest = 0; + +# ---------------------------------------------------------------------------- +# Main +# ---------------------------------------------------------------------------- + +my $iCommand = shift @ARGV || ""; + +if ( $iCommand eq "clean" ) { + + print "Running cleanup...\n"; + clean(); + +} elsif ( $iCommand eq "slowclean" ) { + + $iSlowClean = 1; + clean(); + +} elsif ( $iCommand eq "test" ) { + + print "Running test...\n"; + $iTest = 1; + clean(); + +} elsif ( $iCommand eq "init" ) { + + init_environment(); + +} elsif ( $iCommand eq "generate" ) { + + generate(); + +} else { + print "Usage: $0 \n"; + print "Commands:\n"; + print " init Initializes the build environment by calling 'bldmake bldfiles' and 'abld makefile'.\n"; + print " This needs to be run only if the environment has not been built yet and 'abld build -what' fails.\n"; + print " generate Generates a configuration file of releasables to be cleaned.\n"; + print " clean Cleans the build quickly by deleting all matching files from the configuration file.\n"; + print " slowclean Slower and more thorough clean that deletes all similar files in addition to the ones normal clean deletes.\n"; + print " Example: Cleanup list contains file 'binary.dll'. Slowclean will also delete files named\n"; + print " 'binary.dll.foo' and 'binary.dll.bar'\n"; + print " test Runs a test to see what files would be deleted on a real cleanup run.\n"; + print " Shows only files that would not be deleted by 'abld reallyclean'.\n"; + exit 0; +} + +# Print possible errors +print join "\n", @iErrors; + +exit 0; + +# ---------------------------------------------------------------------------- +# Subroutines +# ---------------------------------------------------------------------------- + + +# ---------------------------------------------------------------------------- +# Initializes the environment to be able to call 'abld build -what' +# ---------------------------------------------------------------------------- +# +sub init_environment { + # Initialize the environment in order to get "abld build -what" to run properly + print "Initializing build environment...\n"; + + print "Calling 'bldmake bldfiles'\n"; + system "bldmake bldfiles"; + + print "Calling 'abld export'\n"; + system "abld export"; + + print "Calling 'abld makefile winscw'\n"; + system "abld makefile winscw"; + + print "Calling 'abld makefile armv5'\n"; + system "abld makefile armv5"; + + print "Done.\n"; +} + + +# ---------------------------------------------------------------------------- +# Generates the cleanup list by calling 'abld build -what' and parsing it +# ---------------------------------------------------------------------------- +# +sub generate { + print "Attempting to generate the cleanup list...\n"; + + # Get the list of releasables from the build tools + open my $in, "abld build -what 2>&1 |" or die "Cannot open pipe! $!"; + + my %parsed; + while ( <$in> ) { + if ( /No such file or directory/ ) { + push @iErrors, "Unable to generate cleanup list. The environment is not ready. Run 'init' before running 'generate'"; + last; + } + + $_ = lc $_; + next unless /^\\epoc32/; + + s/release\\(?:winscw|armv5)\\(?:udeb|urel)/release\\$iTag_platform\\$iTag_target/i; + + # Cenrep file. Add the corresponding .cre file to the cleanup list + if ( /(.+?winscw\\c\\private\\10202be9\\)(.{8})\.txt/ ) { + $parsed{ $1 . "persists\\" . $2 . ".cre\n" }++; + } + + $parsed{ $_ }++; + } + + close $in; + + if ( @iErrors > 0 ) { + return; + } + + open my $out, ">$iCleanup_file" or die "Cannot open file $iCleanup_file! $!"; + print $out join "", sort keys %parsed; + close $out; +} + + +# ---------------------------------------------------------------------------- +# Cleans up the environment by deleting all files found from the cleanup list +# Cleaning is done by finding all files that match the string in the list in +# so all similarly named files are also deleted. (CodeWarrior temporary files etc ) +# ---------------------------------------------------------------------------- +# +sub clean { + + if ( !-e $iCleanup_file ) { + push @iErrors, "Cleanup file $iCleanup_file not found! Run 'generate' to generate it."; + return; + } + + open my $in, "$iCleanup_file" or die "Cannot open cleanup file $iCleanup_file! $!"; + my @releasables = <$in>; + close $in; + + my $total = scalar @releasables; + print "$total rules found from cleanup list...\n"; + + my @deleted = (); + my $progress = 0; + foreach ( @releasables ) { + $progress++; + + next if $_ eq ""; + + # Found __PLATFORM__ tag. Substitute it with all known platforms and add them back to the array + if ( /$iTag_platform/ ) { + foreach my $platform ( @iPlatforms ) { + my $new_releasable = $_; + $new_releasable =~ s/$iTag_platform/$platform/; + debug( "Adding releasable: $new_releasable" ); + push @releasables, $new_releasable; + $total++; # Adjust the total amount of files to be deleted + } + + # Move on to the next round + next; + } + + # Found __TARGET__ tag. Substitute it with all known targets and add them back to the array + if ( /$iTag_target/ ) { + foreach my $target ( @iTargets ) { + my $new_releasable = $_; + $new_releasable =~ s/$iTag_target/$target/; + debug( "Adding releasable: $new_releasable" ); + push @releasables, $new_releasable; + $total++; # Adjust the total amount of files to be deleted + } + + # Move on to the next round + next; + } + + # At this point there is nothing to substitute. Find all files matching the releasable name and delete them + chomp; # Get rid of newline at the end + + my $releasable = lc $_; + my @files_found; + if ( $iSlowClean == 1 ) { + @files_found = glob "$_*"; + } else { + push @files_found, $releasable; + } + foreach my $file ( @files_found ) { + next unless $file =~ /^\\epoc32/; # Some kind of safeguard, just in case + + if ( $iTest == 1 ) { + + # If the file is not one of the releasables, it would not be deleted by reallyclean + # So add it to the list of files that would only be deleted by this script + + $file = lc $file; + if ( $file ne $releasable || $file =~ /\.cre$/ ) { + push @deleted, $file; + } + + } else { + + my $err = 0; + unlink $file or ( $err = -1 ); + if ( $err ne -1 ) { + push @deleted, $file; + } + } + } + + # Report progress + my $percent = ( $progress / $total ) * 100; + printf "\r ( %d / %d ) % .1f %%", $progress, $total, $percent; + } + + if ( @deleted > 0 ) { + print "\n\nSummary:\n"; + foreach my $deleted ( sort @deleted ) { + if ( $iTest ) { + print "Would be deleted: $deleted\n"; + } else { + print "Deleted: $deleted\n"; + } + } + } else { + print "\n\nNothing to be done.\n"; + } +} + + +# ---------------------------------------------------------------------------- +# Debug output. Prints a string if the debug flag is defined +# ---------------------------------------------------------------------------- +# +sub debug { + my $msg = shift; + if ( DEBUG ) { + print $msg; + } +} \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 group/cleanup.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/cleanup.txt Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,71 @@ +\epoc32\data\102750d5.rsc +\epoc32\include\domain\middleware\ipvideo\ccrapibase.h +\epoc32\include\domain\middleware\ipvideo\ccrdvrapi.h +\epoc32\include\domain\middleware\ipvideo\ccsescheduledprogram.h +\epoc32\include\domain\middleware\ipvideo\ccseschedulerapi.h +\epoc32\include\domain\middleware\ipvideo\ccseschedulerpluginif.h +\epoc32\include\domain\middleware\ipvideo\ccseschedulerpluginif.inl +\epoc32\include\domain\middleware\ipvideo\cdvrsdpparser.h +\epoc32\include\domain\middleware\ipvideo\crtpcliphandler.h +\epoc32\include\domain\middleware\ipvideo\crtpcliphandler.inl +\epoc32\include\domain\middleware\ipvideo\crtpclipmanager.h +\epoc32\include\domain\middleware\ipvideo\crtpfilebase.h +\epoc32\include\domain\middleware\ipvideo\crtpfilebase.inl +\epoc32\include\domain\middleware\ipvideo\crtpmetaheader.h +\epoc32\include\domain\middleware\ipvideo\crtputil.h +\epoc32\include\domain\middleware\ipvideo\crtypedefs.h +\epoc32\include\domain\middleware\ipvideo\cseengineuids.h +\epoc32\include\domain\middleware\ipvideo\cseschedulerclientservercommon.h +\epoc32\include\domain\middleware\ipvideo\mcrengineobserver.h +\epoc32\include\domain\middleware\ipvideo\mcsepluginobserver.h +\epoc32\include\domain\middleware\ipvideo\mcsescheduleobserver.h +\epoc32\include\domain\middleware\ipvideo\mrtpcliprepairobserver.h +\epoc32\include\domain\middleware\ipvideo\mrtpfileobserver.h +\epoc32\include\domain\middleware\ipvideo\mrtpfilereadobserver.h +\epoc32\include\domain\middleware\ipvideo\mrtpfilewriteobserver.h +\epoc32\include\domain\middleware\ipvideo\rcseschedulerclient.h +\epoc32\include\domain\middleware\ipvideo\rcseschedulerservice.h +\epoc32\include\domain\middleware\ipvideo\rcseschedulerservicebase.h +\epoc32\include\domain\middleware\ipvideo\tvcxconnutilnotifierparams.h +\epoc32\include\domain\middleware\ipvideo\vcxconnectionutility.h +\epoc32\include\domain\middleware\ipvideo\vcxconnutilengineobserver.h +\epoc32\include\domain\middleware\vcxmyvideosdefs.h +\epoc32\include\domain\middleware\vcxmyvideosuids.h +\epoc32\include\domain\middleware\videoplayeruid.hrh +\epoc32\localisation\102750d5\rsc\102750d5.rpp +\epoc32\localisation\group\102750d5.info +\epoc32\release\__PLATFORM__\__TARGET__\102750d5.rsc +\epoc32\release\__PLATFORM__\__TARGET__\commonrecordingengine.exe +\epoc32\release\__PLATFORM__\__TARGET__\commonrecordingengine.exe.map +\epoc32\release\__PLATFORM__\__TARGET__\commonrecordingengineclient.dll +\epoc32\release\__PLATFORM__\__TARGET__\commonrecordingengineclient.dll.map +\epoc32\release\__PLATFORM__\__TARGET__\commonrecordingengineclient.lib +\epoc32\release\__PLATFORM__\__TARGET__\cseschedulerclient.dll +\epoc32\release\__PLATFORM__\__TARGET__\cseschedulerclient.dll.map +\epoc32\release\__PLATFORM__\__TARGET__\cseschedulerclient.lib +\epoc32\release\__PLATFORM__\__TARGET__\cseschedulerserver.exe +\epoc32\release\__PLATFORM__\__TARGET__\cseschedulerserver.exe.map +\epoc32\release\__PLATFORM__\__TARGET__\dvrsdpparser.dll +\epoc32\release\__PLATFORM__\__TARGET__\dvrsdpparser.dll.map +\epoc32\release\__PLATFORM__\__TARGET__\dvrsdpparser.lib +\epoc32\release\__PLATFORM__\__TARGET__\vcxconnectionutility.dll +\epoc32\release\__PLATFORM__\__TARGET__\vcxconnectionutility.dll.map +\epoc32\release\__PLATFORM__\__TARGET__\vcxconnectionutility.lib +\epoc32\release\__PLATFORM__\__TARGET__\vcxconnutilpsworker.exe +\epoc32\release\__PLATFORM__\__TARGET__\vcxconnutilpsworker.exe.map +\epoc32\release\armv5\lib\commonrecordingengineclient.dso +\epoc32\release\armv5\lib\commonrecordingengineclient.lib +\epoc32\release\armv5\lib\commonrecordingengineclient{000a0000}.dso +\epoc32\release\armv5\lib\commonrecordingengineclient{000a0000}.lib +\epoc32\release\armv5\lib\cseschedulerclient.dso +\epoc32\release\armv5\lib\cseschedulerclient.lib +\epoc32\release\armv5\lib\cseschedulerclient{000a0000}.dso +\epoc32\release\armv5\lib\cseschedulerclient{000a0000}.lib +\epoc32\release\armv5\lib\dvrsdpparser.dso +\epoc32\release\armv5\lib\dvrsdpparser.lib +\epoc32\release\armv5\lib\dvrsdpparser{000a0000}.dso +\epoc32\release\armv5\lib\dvrsdpparser{000a0000}.lib +\epoc32\release\armv5\lib\vcxconnectionutility.dso +\epoc32\release\armv5\lib\vcxconnectionutility.lib +\epoc32\release\armv5\lib\vcxconnectionutility{000a0000}.dso +\epoc32\release\armv5\lib\vcxconnectionutility{000a0000}.lib diff -r 826cea16efd9 -r 13a33d82ad98 layers.sysdef.xml --- a/layers.sysdef.xml Tue Aug 31 16:13:59 2010 +0300 +++ b/layers.sysdef.xml Wed Sep 01 12:20:37 2010 +0100 @@ -1,17 +1,23 @@ - ]> - + - + + + + + + + diff -r 826cea16efd9 -r 13a33d82ad98 tsrc/conf/ats_apitests.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/conf/ats_apitests.txt Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,10 @@ +;Run \vado\videoplayer\tsrc\testing\tools\genATSdrop.pl from +;the tsrc folder to create ATS3 drop. +DEVICE INSERT_DEVICE +EMAIL INSERT_EMAIL +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +SIS \VideoApp_Domain\videoplayer\videoplayerapp\mpxvideoplayer\sis\VideoPlayer.sisx +INC ..\..\videoutils_plat\videoconnutility_api\tsrc\conf\atsconf.txt +INC ..\..\videoutils_plat\videoscheduler_api\tsrc\conf\atsconf.txt diff -r 826cea16efd9 -r 13a33d82ad98 tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsrc/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for Generic test modules under videoutils* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES +#include "../../videoutils_plat/videoconnutility_api/tsrc/group/bld.inf" +#include "../../videoutils_plat/videoscheduler_api/tsrc/group/bld.inf" diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/bwins/vcxconnectionutilityu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/bwins/vcxconnectionutilityu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,9 @@ +EXPORTS + ?DecreaseReferenceCount@CVcxConnectionUtility@@QAEXXZ @ 1 NONAME ; void CVcxConnectionUtility::DecreaseReferenceCount(void) + ?DisconnectL@CVcxConnectionUtility@@QAEXXZ @ 2 NONAME ; void CVcxConnectionUtility::DisconnectL(void) + ?GetIap@CVcxConnectionUtility@@QAEHAAKH@Z @ 3 NONAME ; int CVcxConnectionUtility::GetIap(unsigned long &, int) + ?InstanceL@CVcxConnectionUtility@@SAPAV1@XZ @ 4 NONAME ; class CVcxConnectionUtility * CVcxConnectionUtility::InstanceL(void) + ?RegisterObserverL@CVcxConnectionUtility@@QAEXPAVMConnUtilEngineObserver@@@Z @ 5 NONAME ; void CVcxConnectionUtility::RegisterObserverL(class MConnUtilEngineObserver *) + ?RemoveObserver@CVcxConnectionUtility@@QAEXPAVMConnUtilEngineObserver@@@Z @ 6 NONAME ; void CVcxConnectionUtility::RemoveObserver(class MConnUtilEngineObserver *) + ?WapIdFromIapIdL@CVcxConnectionUtility@@QAEKK@Z @ 7 NONAME ; unsigned long CVcxConnectionUtility::WapIdFromIapIdL(unsigned long) + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/eabi/vcxconnectionutility_tb92u.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/eabi/vcxconnectionutility_tb92u.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,8 @@ +EXPORTS + _ZN21CVcxConnectionUtility11DisconnectLEv @ 1 NONAME + _ZN21CVcxConnectionUtility14RemoveObserverEP23MConnUtilEngineObserver @ 2 NONAME + _ZN21CVcxConnectionUtility17RegisterObserverLEP23MConnUtilEngineObserver @ 3 NONAME + _ZN21CVcxConnectionUtility22DecreaseReferenceCountEv @ 4 NONAME + _ZN21CVcxConnectionUtility6GetIapERmi @ 5 NONAME + _ZN21CVcxConnectionUtility9InstanceLEv @ 6 NONAME + _ZN21CVcxConnectionUtility15WapIdFromIapIdLEm @ 7 NONAME diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/eabi/vcxconnectionutilityu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/eabi/vcxconnectionutilityu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,17 @@ +EXPORTS + _ZN21CVcxConnectionUtility11DisconnectLEv @ 1 NONAME + _ZN21CVcxConnectionUtility14RemoveObserverEP23MConnUtilEngineObserver @ 2 NONAME + _ZN21CVcxConnectionUtility17RegisterObserverLEP23MConnUtilEngineObserver @ 3 NONAME + _ZN21CVcxConnectionUtility22DecreaseReferenceCountEv @ 4 NONAME + _ZN21CVcxConnectionUtility6GetIapERmi @ 5 NONAME + _ZN21CVcxConnectionUtility9InstanceLEv @ 6 NONAME + _ZTIN4Meta11TMetaVarLenI5RBuf8EE @ 7 NONAME ; ## + _ZTIN4Meta11TMetaVarLenI6RBuf16EE @ 8 NONAME ; ## + _ZTIN4Meta12TMetaVarLen8I5RBuf8EE @ 9 NONAME ; ## + _ZTIN4Meta13TMetaVarLen16I6RBuf16EE @ 10 NONAME ; ## + _ZTVN4Meta11TMetaVarLenI5RBuf8EE @ 11 NONAME ; ## + _ZTVN4Meta11TMetaVarLenI6RBuf16EE @ 12 NONAME ; ## + _ZTVN4Meta12TMetaVarLen8I5RBuf8EE @ 13 NONAME ; ## + _ZTVN4Meta13TMetaVarLen16I6RBuf16EE @ 14 NONAME ; ## + _ZN21CVcxConnectionUtility15WapIdFromIapIdLEm @ 15 NONAME + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include + + +PRJ_PLATFORMS + +WINSCW ARMV5 + + +PRJ_EXPORTS +../rom/videoconnutility.iby CORE_MW_LAYER_IBY_EXPORT_PATH(videoconnutility.iby) + +PRJ_MMPFILES + +vcxconnectionutility.mmp + +PRJ_TESTMMPFILES + + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/group/vcxconnectionutility.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/group/vcxconnectionutility.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is a project specification file for Video Center Conn Utility* +*/ + + + + +#include +#include + + +TARGET vcxconnectionutility.dll +TARGETTYPE dll +UID 0x1000008d 0x20016BA1 + +#if defined (SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY) && defined (ARMCC) + DEFFILE vcxconnectionutility_tb92.def +#else + DEFFILE vcxconnectionutility.def +#endif + + +CAPABILITY CAP_GENERAL_DLL + +SOURCEPATH ../src + +SOURCE vcxconnutilengine.cpp +SOURCE vcxconnutilpubsub.cpp +SOURCE vcxconnutilimpl.cpp +SOURCE vcxconnectionutility.cpp +SOURCE vcxconnutilsubscriber.cpp +SOURCE vcxconnutilwaitsch.cpp + +USERINCLUDE . +USERINCLUDE ../inc +USERINCLUDE ../../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY commdb.lib +LIBRARY commsdat.lib +LIBRARY euser.lib +LIBRARY cmmanager.lib +LIBRARY esock.lib +LIBRARY connmon.lib +LIBRARY netmeta.lib +LIBRARY flogger.lib +LIBRARY extendedconnpref.lib diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilengine.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,358 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: class to handle networking functions in vcxconnectionutility* +*/ + + + + +#ifndef __CVCX_CONUTILENGINE_H__ +#define __CVCX_CONUTILENGINE_H__ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "vcxconnectionutility.hrh" + +class CActiveCommsMobilityApiExt; +class MConnUtilExtEngineObserver; + + +// CLASS DECLARATION +/** +* Class defines functionality for handling networking functions in +* vcxconnectionutility. +* These are: +* 1. connection creation and disconnecting +* 2. handling and notifying of events from apllication level roaming (ALR) +* 3. handling and notifying of other interesting events from the network: +* - link layer closing and connection deletion +* - iap list changing +* +* Class uses MConnUtilEngineObserver interface to inform CVcxConnUtilImpl +* -class about the events. +*/ + +NONSHARABLE_CLASS ( CVcxConnUtilEngine ) : public CActive, + public MMobilityProtocolResp, + public MConnectionMonitorObserver + { + public: // construction / destruction + + /** + * Construction. + * + * @param MConnUtilExtEngineObserver + * @return The newly constructed CVcxConnUtilEngine + */ + static CVcxConnUtilEngine* NewL( MConnUtilExtEngineObserver* aObserver ); + + /** + * Construction. Object left to cleanupstack + * + * @param MConnUtilExtEngineObserver + * @return The newly constructed CVcxConnUtilEngine + */ + static CVcxConnUtilEngine* NewLC( MConnUtilExtEngineObserver* aObserver ); + + /** + * destructor + */ + virtual ~CVcxConnUtilEngine(); + + private: + + /** + * C++ constructor + */ + CVcxConnUtilEngine(); + + /** + * Private 2nd phase construction. + */ + void ConstructL(); + + private: // From CActive + + /** + * From CActive. Connection startup is done asynchronously after + * connection cretaion ends, the status value of the connection is + * updated whether connection succeed or not + */ + void RunL(); + + /** + * From CActive. Cancels coonnection creation. + */ + void DoCancel(); + + private: // From MMobilityProtocolResp + + /** + * From MMobilityProtocolResp. We have better carrier available for + * the active connection. + * + * @param aOldAPInfo current IAP information + * @param aNewAPInfo suggested new IAP information + * @param aIsUpgrade ETrue indicates IAP is to be upgraded + * @param aIsSeamless ETrue indicates that new connection is seamless + * (new IAP requires dialog for connection) + */ + void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, + TAccessPointInfo aNewAPInfo, + TBool aIsUpgrade, + TBool aIsSeamless ); + + /** + * From MMobilityProtocolResp. We have a new carrier available for + * the active connection. + * + * @param aNewAPInfo IAP information from the new available connection + * @param aIsSeamless ETrue indicates that new connection is seamless + * (new IAP requires dialog for connection) + */ + void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ); + + /** + * From MMobilityProtocolResp. + * + * @param aError + */ + void Error( TInt aError ); + + private: // from MConnectionMonitorObserver + + /** + * @see MConnectionMonitorObserver + */ + void EventL( const CConnMonEventBase &aConnMonEvent ); + + public: // new methods + + typedef RArray RDestinationArray; + + /** + * Starts a connection via SNAP + * + * @param aPref connection information to be used connection startup + * @return KErrNone always is async connection and if sync connection + * startup succeed or one of the system wide error codes + */ + TInt StartToConnect( TConnPref& aPref, TBool aConnAsync = ETrue ); + + /** + * Disconnects active connection and closes RConnection + */ + void Disconnect(); + + /** + * Method is used to get the name of the destination that matches + * given id and to make sure, that destination really have connection + * methods to use. + * + * @param aDestinationID destination (SNAP) if from where to fetch infromation + * + * @return TBool true, if connection is ok to start + */ + TBool PrepareConnectionDetailsL( TInt aDestinationID ); + + /** + * Method reads platform's connection settings, and returns a destination id. + * If aPurpose is setted as ESnapPurposeUnknown, default id is returned, + * otherwise purpose is used to get correct id + * + * @param aPurpose if ESnapPurposeUnknown, get default, in all other cases + * try to fetch id based on the purpose + * + * @return TUint32 destination id + */ + TUint32 GetCmmDestinationIdL( CMManager::TSnapPurpose aPurpose = + CMManager::ESnapPurposeUnknown ); + + /** + * Method checks if there is an active connection for + * the given iap + * + * @param aIapId iap id to check + * + * @return TBool ETrue if connection exists + * + */ + TBool IsIapConnected( TUint32 aIapId ); + + /** + * Method fills started connection's information: IAP id (iIapId) and IAP name + * This is needed in case of "always ask" to get the information client requires. + * + */ + void FillActiveConnectionDetailsL(); + + /** + * clears iapid, snapid and their names + * + */ + void ResetConnectionInfo(); + + /** + * Returns currently fetched iap id + * + * @return TUint32 + */ + TUint32 IapId() const; + + /** + * Returns currently fetched iap id + * + * @return TInt + */ + TInt DestinationId() const; + + /** + * Returns currently fetched snap name + * + * @return TUint32 + */ + TPtrC DestinationName() const; + + /** + * Returns current connection status + * + * @return TPSVCConnectionStatus + */ + TVCxConnectionStatus ConnectionStatus() const; + + /** + * Explicitly sets internal connection status. + * + * @param TPSVCConnectionStatus + */ + void SetConnectionStatus( TVCxConnectionStatus aStatus ); + + /** + * Method can be called to create mobility object + * for getting roaming events from the network. + * + * @return TInt KErrnone if object created or already exists. Otherwise a + * system level error. + */ + TInt CreateMobility(); + + /** + * Returns "query connection" status. + */ + TBool QueryConn(); + + /** + * Set "query connection" status. + * + * @param aQueryConn Value for connection query flag. + */ + void SetQueryConn( TBool aQueryConn ); + + + private: + + /** + * Internal helper method trying to fetch destination + * information for the current IAP. + * + */ + void FillDestinationInfoL(); + + private: + + /** + * Socket Server + */ + RSocketServ iSocketServer; + + /** + * Connection + */ + RConnection iConnection; + + /** + * Connection monitor + */ + RConnectionMonitor iConnectionMonitor; + + /** + * Current connection state + */ + TVCxConnectionStatus iConnectionState; + + /** + * Connection Manager Extensions + */ + RCmManagerExt iCmManagerExt; + + /** + * Destination id. + */ + TInt iDestinationId; + + /** + * IAP ID. + */ + TUint32 iIapId; + + /** + * Destination (snap) Name. + */ + HBufC* iDestinationName; + + /** + * current connection id + */ + TUint iCurrentConnectionId; + + /** + * Mobility object to fetch carrier change events + */ + CActiveCommsMobilityApiExt* iMobility; + + /** + * array of all available destination ids + */ + RDestinationArray iDestinationArray; + + /** + * observer to notify about changes in the network + */ + MConnUtilExtEngineObserver* iObserver; + + /** + * Value to pass connection result error code from the + * async connection creation + */ + TInt iConnectingResult; + + /** + * If is set to ETrue, connection selection dialog will be displayed. + * Used when tried SNAP contained invalid IAP. + */ + TBool iQueryConn; + + }; + +#endif // __CVCX_CONUTILENGINE_H__ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilextengineobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilextengineobserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: extended engine observer interface for video connection utility internal use* +*/ + + + + +#ifndef __VCXCONNUTILEXTENGINEOBSERVER_H_ +#define __VCXCONNUTILEXTENGINEOBSERVER_H_ + +#include +/** +* Interface is being used inside vcxconnectionutility to notify +* IAP changes and request for waits +*/ + +class MConnUtilExtEngineObserver : public MConnUtilEngineObserver + + { + public: + + /** + * Method is called, when observable request observer to + * put it's current active object to wait until EndWait + * for same wait id is called + * + * @param aWaitId wait id + */ + virtual void WaitL( TUint32 aWaitId ) = 0; + + /** + * Method is called, when observable request observer to + * end wait for given id + * + * @param aWaitId wait id + */ + virtual void EndWait( TUint32 aWaitId ) = 0; + + /** + * Method is called, when observable needs to know wether + * this instance is the master instance + * + * @return TBool ETrue is master, EFalse not a master + */ + virtual TBool IsMaster() = 0; + + }; + + +#endif /*VCXCONNUTILEXTENGINEOBSERVER_H_*/ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilimpl.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,373 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation Class to handle connection creation.* +*/ + + + + +#ifndef __VCX_CONNUTILIMPL_H_ +#define __VCX_CONNUTILIMPL_H_ + +// INCLUDES +#include +#include + +#include + +#include "vcxconnutilpubsubobserver.h" +#include "vcxconnutilextengineobserver.h" + +// FORWARD DECLARATIONS +class CRepository; +class CVcxConnUtilEngine; +class CVcxConnUtilPubSub; +class CVcxConnectionUtility; +class CVcxConnUtilWaitSch; + + +// CLASS DECLARATION + +/** +* This class defines operations for handling the networking notifications +* from the engine class, notifications from the PS and provides a functionality +* for those. +* +*/ +NONSHARABLE_CLASS( CVcxConnUtilImpl) : public CBase, + public MConnUtilPubsubObserver, + public MConnUtilExtEngineObserver + { + + public: // Constructors and destructor + + /** + * Construction. + * + * @param CVcxConnectionUtility* pointer to main interface class for + * for showing dialogs + * @return The newly constructed CVcxConnUtilEngine + */ + static CVcxConnUtilImpl* NewL( CVcxConnectionUtility* aUiInterface ); + + /** + * Construction. Object left to cleanupstack + * + * @param CVcxConnectionUtility* pointer to main interface class for + * for showing dialogs + * @return The newly constructed CVcxConnUtilEngine + */ + static CVcxConnUtilImpl* NewLC( CVcxConnectionUtility* aUiInterface ); + + /** + * Destructor. + */ + virtual ~CVcxConnUtilImpl(); + + private: + + /** + * constructor. + * + * @param CVcxConnectionUtility* pointer to main interface class for + * for showing dialogs + */ + CVcxConnUtilImpl( CVcxConnectionUtility* aUiInterface ); + + /** + * default constructor definition. + * + */ + CVcxConnUtilImpl( ); + + /** + * Private 2nd phase construction. + */ + void ConstructL(); + + public: // New functions + + + /** + * Returns open IAP, If connection is not opened it will be created + * + * @param aIapId On return, IAP ID. + * @param aSilent If ETrue, tries to open connection silently (without dialogs) + * + * @return KErrNone or one of the system wide error codes. + */ + TInt GetIap( TUint32& aIapId, TBool aSilent ); + + /** + * Closes open connection. + */ + void DisconnectL(); + + /** + * Registers observer + * + * @param MConnUtilEngineObserver + */ + void RegisterObserverL( MConnUtilEngineObserver* aObserver ); + + /** + * Removes observer from the array of observers + * + * @param MConnUtilEngineObserver + */ + void RemoveObserver( MConnUtilEngineObserver* aObserver ); + + /** + * Returns current connection status + * + * @return TVCxConnectionStatus + */ + TVCxConnectionStatus EngineConnectionStatus(); + + /** + * Gets WAP id from IAP id. Leaves with KErrNotFound if no record with given + * IAP id is found. + * + * @return WAP id matching the given IAP id. + */ + TUint32 WapIdFromIapIdL( TUint32 aIapId ); + + private: // from MConUtilPubsubObserver + + /** + * Notification about pubsub key (integer) value change + * + * @param aKey PS key informing the change + * @param aValue a new value + */ + void ValueChangedL(const TUint32& aKey, const TInt& aValue); + + private: // from MConnUtilExtEngineObserver + + /** + * Engine has gotten mobility event about preferred IAP. Utility must requets permission + * from it's clients before connection changing can be done. + * + * @return TBool ETrue if roaming can be allowed from the applicatin. + */ + TBool RequestIsRoamingAllowedL(); + + /** + * Notification about IAP change due roaming. If this instance + * is master, it should change the IAP to Pubsub + * + */ + void IapChangedL(); + + /** + * Method calls video connection utility's wait scheduler to + * put current active object to wait with given id. + * + * @param aWaitId id for the wait + */ + void WaitL( TUint32 aWaitId ); + + /** + * Method calls video connection utility's wait scheduler to + * end wait for given id + * + * @param aWaitId id for the wait + */ + void EndWait( TUint32 aWaitId ); + + /** + * Method return ETrue, if this instance is master + * + * @return TBool ETrue if is master, EFalse if not master + */ + TBool IsMaster(); + + private: // New functions + + /** + * Method reads Video center's connection related settings + * from the cenrep. Method also tries to reinit details inside + * conn util engine, if it fails, "always ask" is saved to VC settings + * + * @return KErrNone or one of the system wide error codes. Method can also leave. + */ + TInt PrepareConnSettings(); + + /** + * Setups the connection creation prefs for "always ask" situation, and calls engine + * to start connection or calls DoCreateConnectionL for other cases. + * + * @param aSilent If ETrue, tries to open connection silently (without dialogs) + * + * @return KErrNone or one of the system wide error codes. Method can also leave. + */ + TInt CreateConnection( TBool aSilent ); + + /** + * Setups and tries to open connection via SNAP. + * + * @param aSilent If ETrue, tries to open connection silently (without dialogs) + * @param aSnapId snap (destination) id to use in connection + * @param aMasterConnect If true, mobility object needs to be created for receiving events + * from network. + * + * @return KErrNone or one of the system wide error codes. Method can also leave. + */ + TInt DoCreateConnection( TBool aSilent, TInt32 aSnapId, TBool aMasterConnect ); + + /** + * After connection staring is finished by the engine, this method is to be called. + * Method first checks is connection is ne for this inctance and if it is, + * utility's internal connection information is setted up. Method also + * calls CheckAndChangeSlaveToMaster to setup this inctance to be master if + * one does not yet exist. If this inctance is to be master, connection info + * is updated to PS as well. + * + * + * @return KErrNone if connection data filled ok and we are connected. + */ + TInt HandleFinalizeConnection(); + + /** + * Displays a wait note + * + * @param aConnectionName name of connection to show on the dialog + */ + void DisplayWaitNote( const TDesC& aConnectionName = KNullDesC ); + + /** + * closes a wait note + * + */ + void CloseWaitNote(); + + /** + * Method queries all observers and requests roaming status from them. + * If all observers accept or there is not observers, PS key EVCxPSNbRoamAccepted + * is increased by one. After method ends, PS key EVCxPSNbrRoamResp is increased by + * one to notify that one response is ready. + * + * @return TBool ETrue if roaming is allowed + */ + TBool DoRequestClientRoamingL(); + + /** + * Method saves iap id and name, snap id and name and connection state + * to pubsub. + * + */ + void SaveConnectionToPubSubL(); + + /** + * Method handles changing of slave to master when existing + * master is diconnecting. If change has occured, reinits + * the connection to be used via snap instead of IAP + * + */ + void HandleMasterChangeL(); + + /** + * Method handles the actual change of this instance to be + * master if there is not yet any. + * + * Changing is protected by semaphore, so only one existing + * slave instance can check and possible change it's status + * at the time. + * + * Note that KErrNone does not indicate succesfull status + * chenge. Caller should also check if iMaster -value has changed. + * + * @return TInt KErrNone or one of the system wide error codes, + */ + TInt CheckAndChangeSlaveToMaster(); + + /** + * Method changes slave instance connection status + * based on given value. + * + * @param aNewStatus new status from master + * + */ + void HandleSlaveConnectionStatusL( const TInt& aNewStatus ); + + /** + * Method checks whether there are enough responses for the roaming + * request. If there is sets roaming acceptance status to PS. + * + * @param aNbrOfResps number of responces received so far + * + */ + void HandleRoamingReponsesL( const TInt& aNbrOfResps ); + + /** + * Method notifies observers about IAP changed event + * + */ + void NotifyObserversIAPChanged(); + + private: // Data + + + /** + * Interface for UI related functions for connecting utility: + * Showing and hiding connection -dialog + */ + CVcxConnectionUtility* iUIInterface; + + /** + * Connection utility engine. Handles connection creation, disconnecting and + * connection meta data + */ + CVcxConnUtilEngine* iEngine; + + /** + * pubsub engine, listens pubsub keys + * and notify chenges + */ + CVcxConnUtilPubSub* iPubsub; + + /** + * Wait handler for managing all CactiveSchedulerWaits + * used by video connection utility + */ + CVcxConnUtilWaitSch* iWaitHandler; + + /** + * Array of external network observers. + */ + RArray iObservers; + + /** + * Is this instance the master + */ + TBool iMaster; + + /** + * Semaphore to prevent concurrency in master / slave switch + */ + RSemaphore iSemaSwitchRole; + + /** + * Semaphore to prevent concurrency connection creation + */ + RSemaphore iSemaCreateConn; + + /** + * Used curing connection creation to tell active objects + * that current connection is new. + */ + TBool iNewConnection; + }; +#endif // __VCX_CONNUTILIMPL_H_ +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilpubsub.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilpubsub.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,254 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pubsub handler class for vcxconnectionutility* +*/ + + + + +#ifndef __CVCX_CONUTILPUBSUB_H__ +#define __CVCX_CONUTILPUBSUB_H__ + +#include +#include +#include + + +class CVcxConnUtilSubscriber; +class MConnUtilPubsubObserver; + +/** +* This class defines operations for handling the pub sub keys and their values. +* +*/ +NONSHARABLE_CLASS( CVcxConnUtilPubSub ) : public CBase + { + public: // construction / destruction + + /** + * Construction. + * + * @return The newly constructed CVcxConnUtilPubSub + */ + static CVcxConnUtilPubSub* NewL( MConnUtilPubsubObserver *aObserver ); + + /** + * Construction. Object left to cleanupstack + * + * @return The newly constructed CVcxConnUtilPubSub + */ + static CVcxConnUtilPubSub* NewLC( MConnUtilPubsubObserver *aObserver ); + + /** + * destructor + */ + virtual ~CVcxConnUtilPubSub(); + + private: + + /** + * C++ constructor + */ + CVcxConnUtilPubSub(); + + /** + * Private 2nd phase construction. + * + * During instantiation, the availibility of the PS keys is being checked. In case + * keys does not exists, they are being created by starting an external executable, + * vcxconnutilpsworker, whose UID is being used as the unique category of the PS keys. + * This kind of solution is needed to make sure, that category is always unique and + * the UID of the category is always known beforehand in vcxconnectionutility library + * + * @param aObserver observer to be passed subscribers + */ + void ConstructL( MConnUtilPubsubObserver *aObserver ); + + + public: // new functions + + /** + * Increases a "counter" pub sub value by one. + * If given key is not concidered as a counter, + * nothing is done + * + * @param aKey PS key whose value to increase + */ + void IncCounterPubSubL( TUint32 aKey ); + + /** + * Decreases a "counter" pub sub value by one + * If given key is not concidered as a counter, + * nothing is done + * + * @param aKey PS key whose value to decrease + */ + void DecCounterPubSubL( TUint32 aKey ); + + /** + * Saves given value to the defined PS key. + * + * @param aKey PS to where to save the value + * @param aValue Value to save + * + * @return TInt KErrNone is succees, KerrNotFound if provided key is + * not in the scope of connection util or another + * system level error code + * + */ + TInt SetValue( TUint32 aKey, TInt aValue ); + + /** + * Get value from defined PS key. + * + * @param aKey PS from where to fetch value + * @param aValue + * + * @return TInt KErrNone is succees, KerrNotFound if provided key is + * not in the scope of connection util or another + * system level error code + * + */ + TInt GetValue( TUint32 aKey, TInt& aValue ); + + /** + * Start subscribers. If using deafult value, starts all. + * Otherwise just starts the one defined as aKey + * + * @param aKey key value of subscriber to start + */ + void StartSubscibers( TUint32 aKey = 0 ); + + /** + * Cancels subscribers. If using deafult value, cancels all. + * Otherwise just cancels the one defined as aKey + * + * @param aKey key value of subscriber to cancel + * + */ + void CancelValueSubscribers( TUint32 aKey = 0 ); + + private: + + /** + * Method starts a vcxconnutilpsworker -process + * to create PS keys for connectionutility and + * waits for the process to finish before returning. + * + * If another process has already started worker, method + * waits for it to finish. + * + * Method leaves if existing semaphore cannot be opened or + * creating of process fails. + * + */ + void DefinePropertiesL(); + + /** + * Internal helper method to get a pointer to RProperty + * defined by the aKey -value. + * In case aKey refers to a property that does not exists, + * a null pointer is returned + * + * @param aKey a key value for property wanted + * + * @return RProperty* pointer to property or NULL in case + * property is not found + */ + RProperty* GetProperty( TUint32 aKey ); + + /** + * Internal helper method to get a pointer to Subscriber + * defined by the aKey -value. + * In case aKey refers to a Subscriber that does not exists, + * a null pointer is returned + * + * @param aKey a key value for subscriber wanted + * + * @return CVcxConnUtilSubscriber* pointer to Subscriber or NULL in case + * property is not found + */ + CVcxConnUtilSubscriber* GetSubscriber( TUint32 aKey ); + + /** + * Internal helper method to handle actual incrementation or + * decrementation (based on the calfactor) of the PS key concidered + * to be a counter value in connectionutility's context. + * + * @leave if PS Get or Set fails + * + * @param aKey a key value for subscriber wanted + * + * @param aCalcFactor a value to be added to the PS key value + */ + void DoPSCounterIncrementL( TUint32 aKey, TInt aCalcFactor ); + + private: + + /** + * P&S Current IAP's Id + */ + RProperty iPropertyCurrentIAPId; + + /** + * P&S Current Destination's Id + */ + RProperty iPropertyCurrentSNAPId; + + /** + * P&S telling how many instances are using connection + */ + RProperty iPropertyNbrOfInst; + + /** + * P&S telling how many instances + * have accepted roaming + */ + RProperty iPropertyAccepted; + + /** + * P&S telling Connection state property. + * Object contains PS property for connection state -key and + * subcribe -listener for that value changes + */ + CVcxConnUtilSubscriber* iConnectionStatePS; + + /** + * P&S telling if we currently have master instance or not + * Object contains PS property for masterexist -key and + * subcribe -listener for that value changes + */ + CVcxConnUtilSubscriber* iMasterExistPS; + + /** + * P&S telling the roaming request status from + * the instances + */ + CVcxConnUtilSubscriber* iRoamingReqStatusPS; + + /** + * P&S telling the amount of connection users responded + * roaming request + */ + CVcxConnUtilSubscriber* iNbrInstanceResp; + + /** + * Semaphore to protect critical counter -PS + * increment and decrement operations. + */ + RSemaphore iSemaCounter; + + }; + +#endif // __CVCX_CONUTILPUBSUB_H__ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilpubsubobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilpubsubobserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: interface to notify about PS key changes in vcxconnectionutility* +*/ + + + + +#ifndef _M_CVCX_CONUTILOBS_H__ +#define _M_CVCX_CONUTILOBS_H__ + +#include +#include + +/** +* Interface is being used inside vcxconnectionutility to notify +* the implementation class about changes of values in the PS keys. +*/ + +class MConnUtilPubsubObserver + + { + public: + + /** + * Method to be called when PS key value changes + * + * @param aKey key id + * @param aValue new value + */ + virtual void ValueChangedL(const TUint32& aKey, const TInt& aValue) = 0; + + }; + +#endif // _M_CVCX_CONUTILOBS_H__ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilsubscriber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilsubscriber.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle subscribtions from PS* +*/ + + + + +#ifndef __VCX_CONNUTILSUBSCRI_H +#define __VCX_CONNUTILSUBSCRI_H + +#include +#include + +class MConnUtilPubsubObserver; + +/** +* This class defines operations listening modifications for the +* property defined. +* Notifies changes throught MConnUtilPubsubObserver interface. +* +*/ +NONSHARABLE_CLASS ( CVcxConnUtilSubscriber ) : public CActive + { + + public: // constuct / destruct + + /** + * Construction. + * + * @param aUid category for the property + * @param aKey key id for the property + * @param aType type of the key (at the moment only int is supported) + * @param aObserver pointer to observer to who to notify about changes + * + * @return The newly constructed CVcxConnUtilPubSub + */ + static CVcxConnUtilSubscriber* NewL( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MConnUtilPubsubObserver* aObserver ); + + /** + * Destructor. + * + */ + virtual ~CVcxConnUtilSubscriber(); + + /** + * Returns a reference to property this + * subscriber listens to. + * + * @return RProperty + */ + RProperty& Property(); + + /** + * Start subscribing if not already started + */ + void Start(); + + + private: // constuct + + /** + * Constructor + * + */ + CVcxConnUtilSubscriber( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MConnUtilPubsubObserver* aObserver ); + + /** + * Symbian 2nd phase construction + * + */ + void ConstructL(); + + private: // from CActive + + /** + * From CActive. Calles when value subscribed to changes + * + */ + void RunL(); + + /** + * From CActive. Cancels subscribtion + * + */ + void DoCancel(); + + private: + + /** + * ETrue if object is initialized and subscribtion starts + */ + TBool iInitialized; + + /** + * Property to subscribe + */ + RProperty iProperty; + + /** + * Category uid for the property + */ + const TUid iUid; + + /** + * Key id for the property + */ + const TUint32 iKey; + + /** + * type of the property + */ + RProperty::TType iKeyType; + + /** + * Observer + */ + MConnUtilPubsubObserver* iObserver; + }; + +#endif // __VCX_CONNUTILSUBSCRI_H diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/inc/vcxconnutilwaitsch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/inc/vcxconnutilwaitsch.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CCVcxConnUtilWaitSch class declaration file* +*/ + + + + +#ifndef __CVCXCONNUTILWAITSCH_H +#define __CVCXCONNUTILWAITSCH_H + +// INCLUDES +#include +#include +#include + + +class CVcxConnUtilWait; +class CActiveSchedulerWait; + +// CLASS DECLARATION + +/** + * CVcxConnUtilWaitSch is used to manage CActiveSchedulerWait objects + * within videoconnutility. + * Basically, when client calls wait, a new CActiveSchedulerWait is created + * and being put to list. Different types for waits are managed by different + * wait -wrapper object, which type is defined as a private class for this class. + * + * Currently videoconnutility puts active objects to wait in following situations: + * + * (1) When there is connection creation ongoing and other active objects try to + * create connection: only the one active object that is creating connection is runnig, + * other a-objects waits as long as connection is ready + * + * (2) Master waiting for roaming status from slave instances: Master's roaming active object is + * waiting for roaming response status change. + * + * (3) Connection creation during roaming: All active objects requesting connection during roaming + * are put to wait for the roaming to finish, so that correct iap id can be returned. + * + * (4) Disconnecting during roaming. Master's disconnecting a-object(s) is put to wait for + * roaming to finish + * + * Waiting is released by the client by calling EndWait. CVcxConnUtilWaitSch basicallly + * stops wait for every wait object, put those whose type is not the one provided + * by the parameter of EndWait are being put back to wait. This solution is needed, to + * prevent deadlocks: we might have different kind of waits at the same time, but not all + * are to be released at the same time, but because of the nature of the ActiveScheduler, + * all wait objects are needed to release once, before anyone can proceed. + * + * + */ +NONSHARABLE_CLASS( CVcxConnUtilWaitSch ) : public CBase + { + public: // Constructors and destructor + + /** + * Destructor. + */ + ~CVcxConnUtilWaitSch(); + + /** + * Two-phased constructor. + */ + static CVcxConnUtilWaitSch* NewL(); + + /** + * Two-phased constructor. + */ + static CVcxConnUtilWaitSch* NewLC(); + + private: + + /** + * Constructor for performing 1st stage construction + */ + CVcxConnUtilWaitSch(); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + + public: + + /** + * Method creates a new CVcxConnUtilWait object in case + * one with provided type does not already exist, then + * creates a CActiveSchedulerWait object for the current + * active object and puts it to wait by calling + * CActiveSchedulerWait::Start. After call returns (wait has + * released) checks if CVcxConnUtilWait's iCanStop is ETrue. + * In case it is not, the object is being put back to wait. + * + * After wait object is really released, it is being deallocated. + * + * Method leaves with systemwide error code, in case object + * creation or saving to array fails. + * + * @param aWaitId wait type id for this wait + */ + void WaitL( TUint32 aWaitId ); + + + /** + * Method loops all CVcxConnUtilWait objects and sets their + * iCanStop to ETrue, in case aWaitId is same as CVcxConnUtilWait's + * iType. + * All CActiveSchedulerWait's for each CVcxConnUtilWait is being + * released by calling CActiveSchedulerWait::AsyncStop. + * + * @param aWaitId wait type id for this wait + */ + void EndWait( TUint32 aWaitId ); + + + private: + + /** + * Internal helper method for getting corresponding + * CVcxConnUtilWait object based in the aID. + * + * In case aID -type object is not found from the + * iWaits -array, it is being created and appended to array. + * + * @param aID wait type id for this wait + */ + CVcxConnUtilWait* GetWaitL( TUint32 aID ); + + /** + * Internal helper method for PrepareWaitObjectL for + * getting next not started Active scheduler wait + * object for given CVcxConnUtilWait. + * + * If there is no existing not started object or given + * CVcxConnUtilWait is NULL a new CActiveSchedulerWait + * object is created and appended to the aWait object's + * waitarray. + * + * + * @param aWait wait wait object from where to search + */ + CActiveSchedulerWait* GetActiveSWaitL( CVcxConnUtilWait* aWait ); + + private: + /** + * Array containing all CVcxConnUtilWait objects maintained + * by this object + */ + RPointerArray< CVcxConnUtilWait > iWaits; + + }; + +#endif // __CVCXCONNUTILWAITSCH_H diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/rom/videoconnutility.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/rom/videoconnutility.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __VIDEOCONNUTILITY_IBY__ +#define __VIDEOCONNUTILITY_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\vcxconnectionutility.dll SHARED_LIB_DIR\vcxconnectionutility.dll + +#endif // __VIDEOCONNUTILITY_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnectionutility.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnectionutility.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,272 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle connection creation.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include + +#include +#include +#include "vcxconnectionutility.hrh" +#include "vcxconnutilimpl.h" + +// CONSTANTS +const TInt KVCxConnUtilAppUid = 0x20016BA1; + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::InstanceL() +// ----------------------------------------------------------------------------- +// +EXPORT_C CVcxConnectionUtility* CVcxConnectionUtility::InstanceL() + { + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::InstanceL() in"); + + CVcxConnectionUtility* self = NULL; + TAny* instance = UserSvr::DllTls( KVCxConnUtilAppUid ); + + if ( !instance ) + { + self = new( ELeave ) CVcxConnectionUtility; + CleanupStack::PushL( self ); + self->ConstructL(); + User::LeaveIfError( UserSvr::DllSetTls( KVCxConnUtilAppUid, self ) ); + CleanupStack::Pop( self ); + } + else + { + self = reinterpret_cast( instance ); + } + self->iReferenceCount++; + + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::InstanceL() out"); + + return self; + + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::DecreaseReferenceCount() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVcxConnectionUtility::DecreaseReferenceCount() + { + TAny* singleton = UserSvr::DllTls( KVCxConnUtilAppUid ); + + if ( singleton == this ) + { + iReferenceCount--; + if( iReferenceCount == 0 ) + { + UserSvr::DllFreeTls( KVCxConnUtilAppUid ); + delete this; + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVcxConnectionUtility::ConstructL() + { + MPX_DEBUG1("vcxconnutil ## CVcxNsConnectionUtility::ConstructL() in"); + + iUtilImpl = CVcxConnUtilImpl::NewL( this ); + + MPX_DEBUG1("vcxconnutil ## CVcxNsConnectionUtility::ConstructL() out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::CVcxNsConnectionUtility() +// ----------------------------------------------------------------------------- +// +CVcxConnectionUtility::CVcxConnectionUtility( ) : +CActive( EPriorityStandard ) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::~CVcxConnectionUtility() +// ----------------------------------------------------------------------------- +// +CVcxConnectionUtility::~CVcxConnectionUtility() + { + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::~CConnectionManager in"); + CloseWaitNote(); + + delete iUtilImpl; + iNotifier.Close(); + + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::~CConnectionManager out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::RegisterObserverL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVcxConnectionUtility::RegisterObserverL( MConnUtilEngineObserver* aObserver ) + { + iUtilImpl->RegisterObserverL( aObserver ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::RemoveObserver +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVcxConnectionUtility::RemoveObserver( MConnUtilEngineObserver* aObserver ) + { + iUtilImpl->RemoveObserver( aObserver ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::GetIap +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVcxConnectionUtility::GetIap( TUint32& aIapId, TBool aSilent ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::GetIap in "); + TInt err( KErrNone ); + + err = iUtilImpl->GetIap( aIapId, aSilent ); + + MPX_DEBUG2("vcxconnutil ## CVcxConnectionUtility::GetIap out error: %d ", err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::WapIdFromIapIdL +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint32 CVcxConnectionUtility::WapIdFromIapIdL( TUint32 aIapId ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::WapIdFromIapIdL in "); + TUint32 wapId = iUtilImpl->WapIdFromIapIdL( aIapId ); + MPX_DEBUG1("vcxconnutil ## CVcxConnectionUtility::WapIdFromIapIdL out "); + return wapId; + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::Disconnect() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVcxConnectionUtility::DisconnectL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnectionUtility::Disconnect in"); + if( iReferenceCount <= 1 ) + { + iUtilImpl->DisconnectL(); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnectionUtility::Disconnect out"); + } + + +void CVcxConnectionUtility::RunL() + { + TInt err = iStatus.Int(); + if ( iStatus.Int() == KErrCancel && + iUtilImpl->EngineConnectionStatus() == EVCxConnecting ) + { + // This implifies that user has cancelled connecting dialog, + // if currently connecting, disconnect + TRAP_IGNORE( iUtilImpl->DisconnectL() ); + } + } + + +void CVcxConnectionUtility::DoCancel() + { + // complete request if we're active. + // othervise app blocks + if( IsActive() ) + { + TRequestStatus* s = &iStatus; + User::RequestComplete( s, KErrNone ); + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::DisplayWaitNote() +// ----------------------------------------------------------------------------- +// +void CVcxConnectionUtility::DisplayWaitNote(const TDesC& aConnectionName) + { + if( !IsActive() ) + { + TVcxNotifierParams value; + value.iEvent = TVcxNotifierParams::EConnecting; + + value.iMsg = aConnectionName; + + TPckg param( value ); + + TPckgBuf resultPckg; // Output parameters + + // get connection to the notify server + iNotifier.Close(); + + if( iNotifier.Connect() == KErrNone ) + { + iStatus = KRequestPending; + iNotifier.StartNotifierAndGetResponse( iStatus, KVcxNotifierImplUid, + param, resultPckg ); + SetActive(); + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnectionUtility::CloseWaitNote() +// ----------------------------------------------------------------------------- +// +void CVcxConnectionUtility::CloseWaitNote() + { + + if( IsActive() ) + { + Cancel(); + } + + TVcxNotifierParams value; + value.iEvent = TVcxNotifierParams::EConnected; + value.iMsg.Zero(); + + TPckg param( value ); + + TPckgBuf resultPckg; + + iNotifier.Close(); + + if( iNotifier.Connect() == KErrNone ) + { + + TRequestStatus stat; + iNotifier.StartNotifierAndGetResponse( stat, KVcxNotifierImplUid, param, resultPckg ); + + User::WaitForRequest( stat ); + + iNotifier.Close(); + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnutilengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnutilengine.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,759 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include +#include +#include +#include + +#include "vcxconnutilextengineobserver.h" +#include "vcxconnutilengine.h" + +// CONSTANTS +_LIT( KCommDBIapId, "IAP\\Id" ); + + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::NewL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilEngine* CVcxConnUtilEngine::NewL( MConnUtilExtEngineObserver* aObserver ) + { + CVcxConnUtilEngine* self = CVcxConnUtilEngine::NewLC( aObserver ); + CleanupStack::Pop( self ); // self; + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::NewLC() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilEngine* CVcxConnUtilEngine::NewLC( MConnUtilExtEngineObserver* aObserver ) + { + CVcxConnUtilEngine* self = new (ELeave) CVcxConnUtilEngine(); + CleanupStack::PushL( self ); + self->iObserver = aObserver; + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::CVcxNsConnUtilEngine() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilEngine::CVcxConnUtilEngine( ) : + CActive( EPriorityStandard ), + iConnectionState( EVCxNotConnected ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::ConstructL() + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilEngine::ConstructL() in"); + + iCmManagerExt.OpenL(); + + User::LeaveIfError( iSocketServer.Connect() ); + + User::LeaveIfError( iConnectionMonitor.ConnectL() ); + + User::LeaveIfError( iConnectionMonitor.NotifyEventL( *this ) ); + + // get all destination ids + iCmManagerExt.AllDestinationsL( iDestinationArray ); + + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::ConstructL() out" ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::~CVcxNsConnUtilEngine() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilEngine::~CVcxConnUtilEngine() + { + + if( iMobility ) + { + // make sure observers are not being called + // after receiving Error() from Cancel() + iConnectionState = EVCxDisconnecting; + iMobility->Cancel(); + delete iMobility; + } + + if( IsActive() ) + { + Cancel(); + } + + iConnection.Close(); + + iSocketServer.Close(); + + iCmManagerExt.Close(); + + iConnectionMonitor.Close(); + + delete iDestinationName; + + iDestinationArray.Close(); + + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::StartToConnect() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilEngine::StartToConnect( TConnPref& aPref, TBool aConnAsync ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::StartToConnect with TConnSnapPref in" ); + + TInt err( KErrNone ); + if( EVCxConnected == iConnectionState || + EVCxConnecting == iConnectionState ) + { + return err; + } + iConnectionState = EVCxConnecting; + err = iConnection.Open( iSocketServer ); + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::StartToConnect connection opened" ); + if( err != KErrNone ) + { + return err; + } + + if( !IsActive() ) + { + if( aConnAsync ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::StartToConnect connecting async" ); + + iConnection.Start( aPref, iStatus ); + SetActive(); + TRAP( err, iObserver->WaitL( EVCxPSConnectionStatus ) ); + if( err == KErrNone ) + { + // save possible error code from async + // connection creation + err = iConnectingResult; + } + else if( err == KLeaveExit ) + { + // app is closing, active scheduler is about to be closed. + // cancel connection waiting. + if( IsActive() ) + { + Cancel(); + } + } + } + else + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::StartToConnect connecting sync" ); + err = iConnection.Start(); + if( err == KErrNone ) + { + iConnectionState = EVCxConnected; + } + } + } + + if( iConnectionState != EVCxConnected ) + { + iIapId = 0; + } + + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilEngine::StartToConnect with TConnSnapPref err: %d out", err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::CreateMobility() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilEngine::CreateMobility() + { + TInt err( KErrNone ); + if( iMobility ) + { + iMobility->Cancel(); + delete iMobility; + iMobility = 0; + } + if( !iMobility ) + { + TRAP( err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ) ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::Disconnect() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::Disconnect() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::Disconnect in"); + if( iConnectionState != EVCxNotConnected ) + { + MPX_DEBUG1( "CVcxConnUtilEngine::Disconnect closing connection"); + iConnectionState = EVCxDisconnecting; + if( iMobility ) + { + iMobility->Cancel(); + delete iMobility; + iMobility = NULL; + } + + iConnection.Close(); + iConnectionState = EVCxNotConnected; + + } + if( IsActive() ) + { + Cancel(); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::Disconnect out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::PreferredCarrierAvailable() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo , + TAccessPointInfo aNewAPInfo, + TBool /*aIsUpgrade*/, + TBool aIsSeamless ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::PreferredCarrierAvailable in"); + MPX_DEBUG2( "PreferredCarrierAvailable oldiap: %d", aOldAPInfo.AccessPoint() ); + MPX_DEBUG2( "PreferredCarrierAvailable newiap: %d", aNewAPInfo.AccessPoint() ); + MPX_DEBUG2( "PreferredCarrierAvailable seamless: %d", aIsSeamless ); + + + if ( !aIsSeamless && + aOldAPInfo.AccessPoint() > 0 && + aOldAPInfo.AccessPoint() != aNewAPInfo.AccessPoint() ) + { + if( iConnectionState == EVCxRoamingAccepted ) + { + // in this case we have a roaming ongoing at the + // but we have not yet received NewCarrierActive + // so networking has found yet better usable iap. + // since everyone have allready accepted roaming we + // can migrate it right away + MPX_DEBUG1( "CVcxConnUtilEngine::PreferredCarrierAvailable migrated due EVCxRoamingAccepted state" ); + iMobility->MigrateToPreferredCarrier(); + } + else if( iConnectionState != EVCxRoamingRequest ) + { + TBool allowRoam( EFalse ); + iConnectionState = EVCxRoamingRequest; + + TRAPD( err, allowRoam = iObserver->RequestIsRoamingAllowedL() ); + + // there is a possibility, that client has disconnected during request + // in that case, do nothing + if( iConnectionState == EVCxNotConnected ) + { + return; + } + + if( err == KErrNone && allowRoam ) + { + + MPX_DEBUG1( "CVcxConnUtilEngine::PreferredCarrierAvailable migrated" ); + + iMobility->MigrateToPreferredCarrier(); + iConnectionState = EVCxRoamingAccepted; + } + else + { + MPX_DEBUG1( "CVcxConnUtilEngine::PreferredCarrierAvailable ignored" ); + iMobility->IgnorePreferredCarrier(); + iConnectionState = EVCxConnected; + // reset IAP / SNAP info to the pubsub + TRAPD( err, iObserver->IapChangedL() ); + if( err != KErrNone ) + { + // internal error, let's try to resolve connection + iConnectionState = EVCxError; + TRAP( err, iObserver->IapChangedL() ); + } + } + } + else + { + MPX_DEBUG1( "CVcxConnUtilEngine::PreferredCarrierAvailable Allready roaming" ); + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::PreferredCarrierAvailable out" ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::NewCarrierActive() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::NewCarrierActive in"); + + if ( aIsSeamless ) + { + // It is Seamless. E.g. Mobile IP enabled. + MPX_DEBUG1( "CVcxConnUtilEngine::NewCarrierActive seamless"); + iConnectionState = EVCxConnected; + } + else + { + MPX_DEBUG1( "CVcxConnUtilEngine::NewCarrierActive accepting new carrier"); + + // We accept the new IAP / SNAP. + iMobility->NewCarrierAccepted(); + iConnectionState = EVCxConnected; + // change new IAP / SNAP info to the pubsub + TRAPD( err, iObserver->IapChangedL() ); + if( err != KErrNone ) + { + // internal error, let's try to resolve connection + iMobility->NewCarrierRejected(); + iConnectionState = EVCxError; + TRAP( err, iObserver->IapChangedL() ); + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::NewCarrierActive out" ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::EventL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::EventL( const CConnMonEventBase &aConnMonEvent ) + { + TInt eventType = aConnMonEvent.EventType(); + + TInt connectionId = aConnMonEvent.ConnectionId(); + + // for other events: + // if not master instance or event does not concern + // current connection or we are not connected, do not + // need to handle events + if( !iObserver->IsMaster() || + connectionId != iCurrentConnectionId || + iConnectionState != EVCxConnected ) + { + return; + } + + switch(eventType) + { + case EConnMonConnectionStatusChange: + { + const CConnMonConnectionStatusChange* event = + static_cast( &aConnMonEvent ); + + if( event->ConnectionStatus() == KLinkLayerClosed ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::EventL: KLinkLayerClosed "); + iObserver->IapChangedL(); + } + } + break; + case EConnMonDeleteConnection: + { + iObserver->IapChangedL(); + } + break; + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::Error() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::Error( TInt aError ) + { + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilEngine::Error %d in", aError ); + if( aError != KErrNone ) + { + // Error method is also called, when we call Cancel -method for iMobility + // during disconnecting or during deallocation. Those are not concidered + // as "errors" in the connection utility, so they do not require any + // further handling + if( iConnectionState != EVCxDisconnecting ) + { + iConnectionState = EVCxError; + TRAP_IGNORE( iObserver->IapChangedL() ); + } + + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::Error out" ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::GetCmmDestinationIdL() +// ----------------------------------------------------------------------------- +// +TUint32 CVcxConnUtilEngine::GetCmmDestinationIdL( CMManager::TSnapPurpose aPurpose ) + { + TUint32 destinationId( 0 ); + // get default destination id + TCmDefConnValue defConnection; + iCmManagerExt.ReadDefConnL( defConnection ); + + // if default is setted to be destination, get it's ID + if( defConnection.iType == ECmDefConnDestination && + aPurpose == CMManager::ESnapPurposeUnknown ) + { + destinationId = defConnection.iId; + } + else if( defConnection.iType == ECmDefConnConnectionMethod || + aPurpose != CMManager::ESnapPurposeUnknown ) + { + // default connection is connection method, + // search for the destination of it + RArray destinations; + CleanupClosePushL( destinations ); + iCmManagerExt.AllDestinationsL(destinations); + + RCmDestinationExt destination; + RCmConnectionMethodExt connectionMethod; + TInt exists( KErrNotFound ); + TInt count = destinations.Count(); + for( TInt i = 0; i < count && exists != KErrNone; i++ ) + { + destination = iCmManagerExt.DestinationL( destinations[ i ] ); + CleanupClosePushL( destination ); + + // look for default destination id + if( aPurpose == CMManager::ESnapPurposeUnknown ) + { + // check if connection method belongs to destination + TRAP( exists, + connectionMethod = destination.ConnectionMethodByIDL( + defConnection.iId ) ); + if( exists == KErrNone ) + { + connectionMethod.Close(); + // correct destination found + destinationId = destination.Id(); + } + } + // look for destination id based on purpose + else + { + if( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == + aPurpose ) + { + // found, save destination id and end search + destinationId = destination.Id(); + exists = KErrNone; + } + } + CleanupStack::PopAndDestroy( &destination ); + } + CleanupStack::PopAndDestroy( &destinations ); + } + return destinationId; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::PrepareConnectionDetailsL() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilEngine::PrepareConnectionDetailsL( TInt aDestinationID ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::PrepareConnectionDetailsL in"); + TBool connectionOk( EFalse ); + + ResetConnectionInfo(); + + if( aDestinationID ) + { + + MPX_DEBUG2( "CVcxConnUtilEngine::PrepareConnectionDetailsL destinationID: %d", aDestinationID); + iDestinationId = aDestinationID; + RCmDestinationExt destination = iCmManagerExt.DestinationL( aDestinationID ); + CleanupClosePushL(destination); + + iDestinationName = destination.NameLC(); + CleanupStack::Pop( iDestinationName ); + + MPX_DEBUG2( "CVcxConnUtilEngine::PrepareConnectionDetailsL destination name: %S", iDestinationName); + + TInt cmCount = destination.ConnectionMethodCount(); + MPX_DEBUG2( "CVcxConnUtilEngine::PrepareConnectionDetailsL method count: %d", cmCount); + if( cmCount ) + { + connectionOk = ETrue; + } + CleanupStack::PopAndDestroy( &destination ); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::PrepareConnectionDetailsL out"); + return connectionOk; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::IsIapConnected() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilEngine::IsIapConnected( TUint32 aIapId ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::IsIapConnected in"); + TBool connected( EFalse ); + TRAPD( err, connected = + iCmManagerExt.GetConnectionMethodInfoBoolL( aIapId, CMManager::ECmConnected ) ) + + if( err != KErrNone ) + { + connected = EFalse; + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::IsIapConnected out"); + return connected; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::FillActiveConnectionDetailsL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::FillActiveConnectionDetailsL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::FillActiveConnectionDetailsL in"); + // fill in connection information from the latest connection + TRequestStatus status; + TUint connectionCount(0); + iConnectionMonitor.GetConnectionCount(connectionCount, status); + User::WaitForRequest( status ); + User::LeaveIfError(status.Int()); + + if (connectionCount) + { + // fill in IAP Id + iConnection.GetIntSetting( KCommDBIapId, iIapId ); + MPX_DEBUG2( "CVcxConnUtilEngine::FillActiveConnectionDetailsL iap id: %d", iIapId ); + + // get current connection id + TBool found( EFalse ); + TUint subConnCount( 0 ); + for ( TInt i ( 1 ); i <= connectionCount && !found; i ++ ) + { + TUint connectionId; + User::LeaveIfError( iConnectionMonitor.GetConnectionInfo( i, + connectionId, + subConnCount ) ); + TUint iapIdToCheck; + iConnectionMonitor.GetUintAttribute( + connectionId, 0, KIAPId, iapIdToCheck, status ); + // Note: Codescanner generates here pointless warning. We need to get data synchronously. + User::WaitForRequest ( status ); + User::LeaveIfError( status.Int() ); + + if ( iapIdToCheck == iIapId ) + { + // found + iCurrentConnectionId = connectionId; + found = ETrue; + } + } + + if( !iDestinationId ) + { + // try to fill destination info if not yet gotten + FillDestinationInfoL(); + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::FillActiveConnectionDetailsL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::IapId() +// ----------------------------------------------------------------------------- +// +TUint32 CVcxConnUtilEngine::IapId() const + { + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilEngine::IapId %d", iIapId ); + + return iIapId; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::DestinationId() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilEngine::DestinationId() const + { + return iDestinationId; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::ConnectionStatus() +// ----------------------------------------------------------------------------- +// +TVCxConnectionStatus CVcxConnUtilEngine::ConnectionStatus() const + { + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilEngine::ConnectionStatus %d", iConnectionState ); + return iConnectionState; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::SetConnectionStatus() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::SetConnectionStatus( TVCxConnectionStatus aStatus ) + { + iConnectionState = aStatus; + } + + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::DestinationName() +// ----------------------------------------------------------------------------- +// +TPtrC CVcxConnUtilEngine::DestinationName() const + { + if ( iDestinationName ) + { + return iDestinationName->Des(); + } + return TPtrC(); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::ResetConnectionInfo() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::ResetConnectionInfo() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::ResetConnectionInfo in"); + iIapId = 0; + delete iDestinationName; + iDestinationName = 0; + iDestinationId = 0; + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::ResetConnectionInfo out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::FillDestinationInfoL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::FillDestinationInfoL( ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::FillDestinationInfoL in"); + TInt count = iDestinationArray.Count(); + delete iDestinationName; + iDestinationName = 0; + iDestinationId = 0; + + TBool found( EFalse ); + for( TUint destIndex = 0; destIndex < count && !found; ++destIndex ) + { + RCmDestinationExt destination = + iCmManagerExt.DestinationL( iDestinationArray[ destIndex ] ); + + CleanupClosePushL( destination ); + TInt cmCount = destination.ConnectionMethodCount(); + + for ( TUint methIndex = 0; methIndex < cmCount && !found; ++methIndex ) + { + RCmConnectionMethodExt connectionMethod = destination.ConnectionMethodL( methIndex ); + CleanupClosePushL( connectionMethod ); + if( iIapId == connectionMethod.GetIntAttributeL( CMManager::ECmIapId ) ) + { + // found, save data + iDestinationId = iDestinationArray[ destIndex ]; + MPX_DEBUG2( "CVcxConnUtilEngine::FillDestinationInfoL destination found: %d", iDestinationId ); + iDestinationName = destination.NameLC(); + CleanupStack::Pop( iDestinationName ); + found = ETrue; + MPX_DEBUG2( "CVcxConnUtilEngine::FillDestinationInfoL snap name: %S", iDestinationName ); + } + CleanupStack::PopAndDestroy( &connectionMethod ); + } + CleanupStack::PopAndDestroy( &destination ); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilEngine::FillDestinationInfoL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::DoCancel() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::DoCancel() + { + + if( iConnectionState == EVCxConnecting ) + { + MPX_FUNC( "CVcxConnUtilEngine::DoCancel disconnect"); + Disconnect(); + } + iConnectingResult = KErrCancel; + iObserver->EndWait( EVCxPSConnectionStatus ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::RunL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::RunL() + { + if ( iStatus.Int() != KErrNone ) + { + iConnectingResult = iStatus.Int(); + iConnectionState = EVCxNotConnected; + } + else + { + iConnectingResult = KErrNone; + if( iConnectionState == EVCxConnecting ) + { + iConnectionState = EVCxConnected; + } + } + iObserver->EndWait( EVCxPSConnectionStatus ); + + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::QueryConn() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilEngine::QueryConn() + { + return iQueryConn; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilEngine::SetQueryConn() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilEngine::SetQueryConn( TBool aQueryConn ) + { + iQueryConn = aQueryConn; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnutilimpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnutilimpl.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1155 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle connection creation.* +*/ + + + + +// INCLUDE FILES +#include +#include +#include // CMDBSession +#include // CCDWAPIPBearerRecord +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "vcxconnectionutility.hrh" +#include "vcxconnutilimpl.h" +#include "vcxconnutilengine.h" +#include "vcxconnutilpubsub.h" +#include "vcxconnutilwaitsch.h" + +// CONSTANTS +_LIT( KConnUtilRoleSema, "__ConnUtillMasterSlaveRoleSwitchSema__ "); +_LIT( KConnUtilConnectionSema, "__ConnUtillConnectionCreateSema__ "); + +const TInt KIptvCenRepAPModeAlwaysAsk = 0; +const TInt KConUtilSemaStartupValue = 1; +const TInt KNbrOfNotFoundConnTries = 30; + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::NewL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilImpl* CVcxConnUtilImpl::NewL( CVcxConnectionUtility* aUiInterface ) + { + CVcxConnUtilImpl* self = CVcxConnUtilImpl::NewLC( aUiInterface ); + CleanupStack::Pop( self ); // self; + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::NewLC() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilImpl* CVcxConnUtilImpl::NewLC( CVcxConnectionUtility* aUiInterface ) + { + CVcxConnUtilImpl* self = new (ELeave) CVcxConnUtilImpl( aUiInterface ); + CleanupStack::PushL( self ); + self->ConstructL( ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::ConstructL( ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::ConstructL() in"); + + iWaitHandler = CVcxConnUtilWaitSch::NewL(); + + iObservers.Reset(); + + TInt err( KErrNone ); + err = iSemaSwitchRole.CreateGlobal( KConnUtilRoleSema, KConUtilSemaStartupValue ); + if( err == KErrAlreadyExists ) + { + // semafore exists already, open it + err = iSemaSwitchRole.OpenGlobal( KConnUtilRoleSema ); + } + User::LeaveIfError( err ); + + err = iSemaCreateConn.CreateGlobal( KConnUtilConnectionSema, KConUtilSemaStartupValue ); + if( err == KErrAlreadyExists ) + { + // semafore exists already, open it + err = iSemaCreateConn.OpenGlobal( KConnUtilConnectionSema ); + } + User::LeaveIfError( err ); + + iEngine = CVcxConnUtilEngine::NewL( this ); + + iPubsub = CVcxConnUtilPubSub::NewL( this ); + + // check and set pubsub -values + TInt activeIap( 0 ); + User::LeaveIfError( iPubsub->GetValue( EVCxPSIapId, activeIap ) ); + if( activeIap != 0 ) + { + // check if there really is connection, if not reinit values + if( !iEngine->IsIapConnected( activeIap ) ) + { + // no connection, data integrity has been corrupted at some point + activeIap = 0; + } + } + if( activeIap == 0 ) + { + MPX_DEBUG1("CVcxConnUtilImpl::ConstructL() no connection yet, initing values"); + User::LeaveIfError( iPubsub->SetValue( EVCxPSMasterExists, 0 ) ); + + User::LeaveIfError( iPubsub->SetValue( EVCxPSIapId, 0 ) ); + + User::LeaveIfError( iPubsub->SetValue( EVCxPSSnapId, 0 ) ); + + User::LeaveIfError( iPubsub->SetValue( + EVCxPSConnectionStatus, EVCxNotConnected ) ); + + User::LeaveIfError( iPubsub->SetValue( EVCxPSNbrConnInstances, 0 ) ); + } + + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::ConstructL() out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::CVcxNsConnectionUtility() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilImpl::CVcxConnUtilImpl( CVcxConnectionUtility* aUiInterface ) : +iUIInterface( aUiInterface ) + { + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::~CVcxConnectionUtility() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilImpl::~CVcxConnUtilImpl() + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::~CVcxConnUtilImpl in"); + + iObservers.Close(); + + if( iEngine && iPubsub ) + { + TRAP_IGNORE( DisconnectL() ); + } + + delete iWaitHandler; + + iSemaSwitchRole.Close(); + iSemaCreateConn.Close(); + + delete iPubsub; + delete iEngine; + + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::~CVcxConnUtilImpl out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::RegisterObserverL +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::RegisterObserverL( MConnUtilEngineObserver* aObserver ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::RegisterObserverL in"); + iObservers.AppendL( aObserver ); + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::RegisterObserverL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::RemoveObserver +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::RemoveObserver( MConnUtilEngineObserver* aObserver ) + { + MPX_DEBUG1("Cvcxconnutil ## VcxConnUtilImpl::RemoveObserver in"); + TInt i; + for ( i = 0; i < iObservers.Count(); i++ ) + { + if ( aObserver == iObservers[i] ) + { + iObservers.Remove( i ); + iObservers.Compress(); + break; + } + } + MPX_DEBUG1("Cvcxconnutil ## VcxConnUtilImpl::RemoveObserver out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::EngineConnectionStatus +// ----------------------------------------------------------------------------- +// +TVCxConnectionStatus CVcxConnUtilImpl::EngineConnectionStatus() + { + return iEngine->ConnectionStatus(); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::GetIap +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::GetIap( TUint32& aIapId, TBool aSilent ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::GetIap in "); + aIapId = 0; + TInt err( KErrNone ); + // assume always new connection + iNewConnection = ETrue; + + switch ( iEngine->ConnectionStatus() ) + { + case EVCxNotConnected: + case EVCxDisconnecting: + iSemaCreateConn.Wait(); + err = KErrNotFound; + // KErrNotFound from connection creation indicates that we have + // some destination with unusable iap(s) in it for we cannot connect to + // in that case, destination id to db is setted as "always ask" and connection + // creation will be tried again for 30 times + for(TInt i = 0; i < KNbrOfNotFoundConnTries && err == KErrNotFound; ++i) + { + err = CreateConnection( aSilent ); + MPX_DEBUG2("vcxconnutil ## CVcxConnUtilImpl::GetIap - CreateConnection returned %d ", err ); + } + iSemaCreateConn.Signal(); + break; + case EVCxConnecting: + { + // this instance is connecting, meaning engine is waiting for + // networking to create connection, we need to wait for the engine + // to finish it's waiting + TRAP( err, WaitL( EVCxPSConnectionStatus ) ); + if( iEngine->ConnectionStatus() != EVCxConnected ) + { + // if main active object didn't managed to create connection, + // return error. This active object does not know the actual + // error so return KErrGeneral + err = KErrGeneral; + } + else + { + err = HandleFinalizeConnection(); + } + } + break; + case EVCxRoamingAccepted: // pass throught + case EVCxRoamingRequest: // pass throught + TRAP( err, WaitL( EVCxPSConnectionStatus ) ); + default: + iNewConnection = EFalse; + break; + } + + if( err == KErrNone ) + { + // get iap id if any. If this is the first connection for this + // instance, iap id will be fetched later on + aIapId = iEngine->IapId(); + } + + MPX_DEBUG2("vcxconnutil ## CVcxConnUtilImpl::GetIap out error: %d ", err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::WapIdFromIapIdL +// ----------------------------------------------------------------------------- +// +TUint32 CVcxConnUtilImpl::WapIdFromIapIdL( TUint32 aIapId ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::WapIdFromIapIdL() in "); + MPX_DEBUG2("vcxconnutil ## CVcxConnUtilImpl::WapIdFromIapIdL() IAP id = %d", aIapId); + CMDBSession* db = CMDBSession::NewL( CMDBSession::LatestVersion() ); + CleanupStack::PushL( db ); + + // WapIpBearer table contains the mapping between wap and iap id's. + CCDWAPIPBearerRecord* wapBearerRecord = + static_cast( CCDRecordBase::RecordFactoryL( KCDTIdWAPIPBearerRecord ) ); + + CleanupStack::PushL( wapBearerRecord ); + + wapBearerRecord->iWAPIAP = aIapId; + + TBool found = wapBearerRecord->FindL( *db ); + + if ( !found ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::WapIdFromIapIdL() Record was not found. Leaving with KErrNotFound."); + User::Leave(KErrNotFound); + } + + TUint32 wap = static_cast( wapBearerRecord->iWAPAccessPointId ); + + CleanupStack::PopAndDestroy( wapBearerRecord ); + CleanupStack::PopAndDestroy( db ); + + MPX_DEBUG2("vcxconnutil ## CVcxConnUtilImpl::WapIdFromIapIdL() Matching WAP id = %d", wap); + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilImpl::WapIdFromIapIdL() out "); + return wap; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::PrepareConnSettings() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::PrepareConnSettings() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::PrepareConnSettings in"); + TInt err( KErrNone ); + TInt vcDestinationID( 0 ); + + if ( !iEngine->QueryConn() ) + { + TRAP( err, vcDestinationID = + iEngine->GetCmmDestinationIdL( CMManager::ESnapPurposeUnknown ) ); + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilImpl::PrepareConnSettings - destination id %d", vcDestinationID); + } + + TBool detailsGotten( EFalse ); + TRAP( err, detailsGotten = iEngine->PrepareConnectionDetailsL( vcDestinationID ) ); + if( err == KErrNone && !detailsGotten ) + { + // not able to resolve connection details, proceed with always ask + iEngine->ResetConnectionInfo(); + } + + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::PrepareConnSettings out"); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::CreateConnection() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::CreateConnection( TBool aSilent ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL in"); + + TInt err( KErrNone ); + + TInt connStatusPS( EVCxNotConnected ); + + err = PrepareConnSettings(); + if( err != KErrNone ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL error getting connsettings out"); + return err; + } + + err = iPubsub->GetValue( EVCxPSConnectionStatus, connStatusPS ); + if( err != KErrNone ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL error getting PS conn status out"); + return err; + } + + // if there is already an active connection created by some other + // instance, use that one + TInt snapId( 0 ); + TBool masterConnect( EFalse ); + + if( connStatusPS == EVCxConnected || connStatusPS == EVCxRoamingRequest ) + { + err = iPubsub->GetValue( EVCxPSSnapId, snapId ); + if( err != KErrNone ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL error getting PS snap id, out"); + return err; + } + if( snapId == 0 ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL not usable snap is in PS"); + // current snap is undefined, set snap id KErrNotFound for + // DoCreateConnection to use active iap instead of snap id + snapId = KErrNotFound; + } + } + else + { + masterConnect = ETrue; + snapId = iEngine->DestinationId(); + } + + err = DoCreateConnection( aSilent, snapId, masterConnect ); + if( err == KErrNotFound && masterConnect ) + { + // KErrNotFound from connection creation indicates that we have + // some destination with unusable iap(s) in it. Enable connection query. + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL - set connection query"); + iEngine->SetQueryConn( ETrue ); + } + if( err == KErrNone ) + { + err = HandleFinalizeConnection(); + } + + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilImpl::CreateConnectionL out (%d)", err); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::DoCreateConnection() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::DoCreateConnection( TBool /*aSilent*/, TInt32 aSnapId, TBool aMasterConnect ) + { + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilImpl::DoCreateConnectionL in (snapId=%d)", aSnapId); + + TInt err( KErrNone ); + + if ( aSnapId == KIptvCenRepAPModeAlwaysAsk ) + { + //In always ask mode we show always ask dialog + TCommDbConnPref connPref; + connPref.SetDialogPreference( ECommDbDialogPrefPrompt ); + err = iEngine->StartToConnect( connPref ); + MPX_DEBUG2( "CVcxConnUtilImpl::DoCreateConnectionL connection start always ask err %d", err); + } + else if ( aSnapId > KIptvCenRepAPModeAlwaysAsk ) + { + TConnSnapPref prefs; + prefs.SetSnap( aSnapId ); + err = iEngine->StartToConnect( prefs, aMasterConnect ); + MPX_DEBUG2( "CVcxConnUtilImpl::DoCreateConnectionL connection start err %d", err); + } + else + { + TInt iapPS( 0 ); + err = iPubsub->GetValue( EVCxPSIapId, iapPS ); + if( err == KErrNone ) + { + if( iapPS ) + { + TCommDbConnPref connPref; + connPref.SetIapId( iapPS ); + connPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + err = iEngine->StartToConnect( connPref, EFalse ); + MPX_DEBUG2( "CVcxConnUtilImpl::DoCreateConnectionL connection via iap start err %d", err); + } + else + { + err = KErrNotFound; + } + } + } + if( err == KErrNone && aMasterConnect ) + { + err = iEngine->CreateMobility(); + } + MPX_DEBUG2( "vcxconnutil ## CVcxConnUtilImpl::DoCreateConnectionL out (%d)", err); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::HandleFinalizeConnection() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::HandleFinalizeConnection() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleFinalizeConnection in"); + if( !iNewConnection ) + { + // if connection is not new for this instance + // no finalizing required + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleFinalizeConnection no new connection, out"); + return KErrNone; + } + if( iEngine->ConnectionStatus() != EVCxConnected ) + { + // connection not ok, no point to proceed, return error + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleFinalizeConnection not connected, out"); + return KErrGeneral; + } + + iNewConnection = EFalse; + TRAPD( err, iEngine->FillActiveConnectionDetailsL() ); + + if( err == KErrNone ) + { + TRAP( err, iPubsub->IncCounterPubSubL( EVCxPSNbrConnInstances ) ); + if( err == KErrNone ) + { + // master role check and switch if necessary + if( !iMaster ) + { + err = CheckAndChangeSlaveToMaster(); + } + } + if( err == KErrNone && iMaster ) + { + TRAP( err, SaveConnectionToPubSubL() ); + } + if( err == KErrNone ) + { + // start getting events from pubsub + iPubsub->StartSubscibers(); + } + } + if( err != KErrNone ) + { + // some operation above failed, internal error + // try to disconnect and return error + TRAPD( errDisc, DisconnectL() ); + // return latest error if disconnecting fails + if( errDisc != KErrNone ) + { + err = errDisc; + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleFinalizeConnection out"); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::DisconnectConnection() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::DisconnectL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::Disconnect in"); + TVCxConnectionStatus connStatus = iEngine->ConnectionStatus(); + + // if this is a master, and it is roaming we need to wait + // for roaming to finish + if( iMaster ) + { + // because EVCxRoamingAccepted is never saved as + // connection status to PS, + // it is safe to wait PS value key change here + if( connStatus == EVCxRoamingRequest || + connStatus == EVCxRoamingAccepted ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::Disconnect master waiting roaming to finish"); + WaitL( EVCxPSConnectionStatus ); + MPX_DEBUG1( "CVcxConnUtilImpl::Disconnect master waiting finished"); + connStatus = iEngine->ConnectionStatus(); + } + } + else + { + // if slave is about to disconnect + // and it's internal state is roaming + // we know that it has been responded to + // roaming request. Decrease value here + if( connStatus == EVCxRoamingRequest || + connStatus == EVCxRoamingAccepted || + connStatus == EVCxPendingClientRequest ) + { + if( connStatus == EVCxRoamingAccepted ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::Disconnect slave removes it's acceptance"); + iPubsub->DecCounterPubSubL( EVCxPSNbRoamAccepted ); + } + MPX_DEBUG1( "CVcxConnUtilImpl::Disconnect slave removes it's response"); + iPubsub->DecCounterPubSubL( EVCxPSNbrRoamResp ); + } + } + + // disconnecting, no longer interested in pubsub events + iPubsub->CancelValueSubscribers(); + + if( connStatus == EVCxNotConnected ) + { + return; + } + + TInt nbrOfConnUsers( 0 ); + User::LeaveIfError( iPubsub->GetValue( EVCxPSNbrConnInstances, nbrOfConnUsers ) ); + + if( nbrOfConnUsers > 0 ) + { + iPubsub->DecCounterPubSubL( EVCxPSNbrConnInstances ); + } + iPubsub->GetValue( EVCxPSNbrConnInstances, nbrOfConnUsers ); + // we're leaving and there are no other instances using connection + if( nbrOfConnUsers == 0 ) + { + // no more connection users, reset PS -values + User::LeaveIfError( iPubsub->SetValue( EVCxPSIapId, 0 ) ); + + User::LeaveIfError( iPubsub->SetValue( EVCxPSSnapId, 0 ) ); + + User::LeaveIfError( iPubsub->SetValue( + EVCxPSConnectionStatus, EVCxNotConnected ) ); + + User::LeaveIfError( iPubsub->SetValue( + EVCxPSRoamingRequestStatus, EVCxRoamingNotInit ) ); + } + iEngine->Disconnect(); + + // cannot be master anymore if not using connection + if( iMaster ) + { + iMaster = EFalse; + User::LeaveIfError( iPubsub->SetValue( EVCxPSMasterExists, 0 ) ); + } + + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::Disconnect out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::SaveConnectionToPubSubL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::SaveConnectionToPubSubL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::SaveConnectionToPubSubL in"); + // publish connection properties + // IAP id: + User::LeaveIfError( iPubsub->SetValue( EVCxPSIapId, iEngine->IapId() ) ); + + // Snap ID: + User::LeaveIfError( iPubsub->SetValue( EVCxPSSnapId, iEngine->DestinationId() ) ); + + // connection State + User::LeaveIfError( iPubsub->SetValue( + EVCxPSConnectionStatus, iEngine->ConnectionStatus() ) ); + + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::SaveConnectionToPubSubL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::RequestIsRoamingAllowedL() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilImpl::RequestIsRoamingAllowedL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::RequestIsRoamingAllowedL in"); + TBool okToRoam( ETrue ); + + // if this instance is master, need to wait for slaves to request their status before proceeding + if( iMaster ) + { + // init pubsubs for roaming request status checking + User::LeaveIfError( iPubsub->SetValue( EVCxPSNbrRoamResp, 0 ) ); + User::LeaveIfError( iPubsub->SetValue( EVCxPSNbRoamAccepted, 0 ) ); + + // query own state + okToRoam = DoRequestClientRoamingL(); + // client might have disconnected + if( iEngine->ConnectionStatus() == EVCxNotConnected ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::RequestIsRoamingAllowedL master disconnected, out"); + return EFalse; + } + + User::LeaveIfError( iPubsub->SetValue( EVCxPSConnectionStatus, EVCxRoamingRequest ) ); + TInt nbrOfConnUsers(0); + User::LeaveIfError( iPubsub->GetValue( EVCxPSNbrConnInstances, nbrOfConnUsers ) ); + if( okToRoam && nbrOfConnUsers > 1 ) + { + + // if we have slaves also using connection, + // we need to wait for them to request roaming statuses + // from their clients also. In this case, the status is being + // checked via pubsub EVCxPSRoamingRequestStatus to which master + // updates after enought resposes are received + MPX_DEBUG1( "CVcxConnUtilImpl::RequestIsRoamingAllowedL master waiting"); + TRAPD( err, WaitL( EVCxPSRoamingRequestStatus ) ); + if( err != KErrNone ) + { + MPX_DEBUG2( "CVcxConnUtilImpl::RequestIsRoamingAllowedL master wait leaved %d", err ); + } + MPX_DEBUG1( "CVcxConnUtilImpl::RequestIsRoamingAllowedL master released"); + + TInt roamingStatus( EVCxRoamingNotInit ); + User::LeaveIfError( iPubsub->GetValue( EVCxPSRoamingRequestStatus, roamingStatus ) ); + if( EVCxRoamingAllowed != roamingStatus ) + { + okToRoam = EFalse; + } + } + } + // reset roaming PS value + User::LeaveIfError( iPubsub->SetValue( EVCxPSRoamingRequestStatus, EVCxRoamingNotInit ) ); + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::RequestIsRoamingAllowedL out"); + return okToRoam; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::DoRequestClientRoamingL() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilImpl::DoRequestClientRoamingL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::DoRequestClientRoamingL in" ); + + TBool okToRoam( ETrue ); + TInt err( KErrNone ); + + TVCxConnectionStatus oldState = iEngine->ConnectionStatus(); + iEngine->SetConnectionStatus( EVCxPendingClientRequest ); + for ( TInt i = 0; i < iObservers.Count() && okToRoam; i++ ) + { + TRAP( err, okToRoam = iObservers[i]->RequestIsRoamingAllowedL() ); + if( err != KErrNone || !okToRoam ) + { + okToRoam = EFalse; + break; + } + } + if( iEngine->ConnectionStatus() != EVCxNotConnected ) + { + // operation path back to connection utility, reset state, in case + // client has not diconnected during callback + iEngine->SetConnectionStatus( oldState ); + + if( okToRoam && err == KErrNone ) + { + // roaming ok for this instance, increase nbr of accepted + iPubsub->IncCounterPubSubL( EVCxPSNbRoamAccepted ); + MPX_DEBUG1( "CVcxConnUtilImpl::DoRequestClientRoamingL accepted increased" ); + } + } + + // increase nbr of responses + iPubsub->IncCounterPubSubL( EVCxPSNbrRoamResp ); + + MPX_DEBUG2( "CVcxConnUtilImpl::DoRequestClientRoamingL allowed %d out", okToRoam ); + + return okToRoam; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::IapChanged() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::IapChangedL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::IapChanged in"); + if( !iMaster ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::IapChanged not master out"); + return; + } + TInt err( KErrNone ); + + // current information + TUint32 oldIap = iEngine->IapId(); + TVCxConnectionStatus engineStatus = iEngine->ConnectionStatus(); + + // resolve connection information from the network middleware + iEngine->ResetConnectionInfo(); + if( engineStatus != EVCxNotConnected && + engineStatus != EVCxError ) + { + iEngine->FillActiveConnectionDetailsL(); + } + + // if there is no active connection or gotten iap id is invalid + TUint32 iapID = iEngine->IapId(); + if( iapID == 0 || !( iEngine->IsIapConnected( iapID ) ) ) + { + if( engineStatus != EVCxError ) + { + engineStatus = EVCxNotConnected; + } + // signal status before disconnect -call to make sure + // slaves react in case master's disconnecting fails + MPX_DEBUG2( "IapChanged not connected notify %d ", engineStatus ); + iPubsub->SetValue( EVCxPSConnectionStatus, engineStatus ); + + MPX_DEBUG1( "CVcxConnUtilImpl::IapChanged no active iap, diconnect"); + TRAP( err, DisconnectL() ); + if( err != KErrNone ) + { + MPX_DEBUG2( "CVcxConnUtilImpl::IapChanged no active iap, diconnect leaves %d", err ); + } + } + else + { + MPX_DEBUG1( "CVcxConnUtilImpl::IapChanged iap connected"); + engineStatus = EVCxConnected; + iEngine->SetConnectionStatus( EVCxConnected ); + // refresh PS connection state + SaveConnectionToPubSubL(); + } + + // notify clients about iap change + if( engineStatus != EVCxError && ( oldIap != iapID || !iapID ) ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::IapChanged notify observers"); + NotifyObserversIAPChanged(); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::IapChanged out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::WaitL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::WaitL( TUint32 aWaitId ) + { + iWaitHandler->WaitL( aWaitId ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::EndWait() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::EndWait( TUint32 aWaitId ) + { + iWaitHandler->EndWait( aWaitId ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::IsMaster() +// ----------------------------------------------------------------------------- +// +TBool CVcxConnUtilImpl::IsMaster() + { + return iMaster; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::ValueChangedL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::ValueChangedL( const TUint32& aKey, const TInt& aValue ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::ValueChangedL (TInt) in"); + EndWait( aKey ); + // pubsub key value changed, check and update + // functionality as required. + switch( aKey ) + { + case EVCxPSMasterExists: + { + HandleMasterChangeL(); + break; + } + case EVCxPSConnectionStatus: + { + HandleSlaveConnectionStatusL( aValue ); + break; + } + case EVCxPSNbrRoamResp: + { + HandleRoamingReponsesL( aValue ); + } + break; + case EVCxPSRoamingRequestStatus: + // NOP + break; + default: + User::Leave( KErrNotFound ); + break; + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::ValueChangedL (TInt) out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::HandleMasterChangeL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::HandleMasterChangeL() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleMasterChangeL in"); + // if this instance is not connected, don't bother + // to change. Not connected instance cannot be master + if( iMaster ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleMasterChangeL master, out"); + return; + } + + if( iEngine->ConnectionStatus() != EVCxConnected ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleMasterChangeL not connected, out"); + return; + } + + User::LeaveIfError( CheckAndChangeSlaveToMaster() ); + + if( iMaster ) + { + // at this point we need to reinit ex-slave's connection to use + // destination (snap) instead of IAP for the ex-slave to be able + // to get mobility events. + // if original connection was via IAP due "always ask", do nothing + if( iEngine->DestinationId() ) + { + // this instance has become master, so it needs to init the mobility object + if( iEngine->CreateMobility() != KErrNone ) + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleMasterChangeL master reinit connection not ok"); + DisconnectL(); + } + else + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleMasterChangeL master reinit connection ok"); + iEngine->FillActiveConnectionDetailsL(); + SaveConnectionToPubSubL(); + } + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleMasterChangeL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::CheckAndChangeSlaveToMaster() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilImpl::CheckAndChangeSlaveToMaster() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CheckAndChangeSlaveToMaster in"); + TInt err( KErrNone ); + TInt status( 0 ); + + /////// + // entering critical section + iSemaSwitchRole.Wait(); + err = iPubsub->GetValue( EVCxPSMasterExists, status ); + // if master already exists, do nothing + if( !status && err == KErrNone) + { + MPX_DEBUG1( "CVcxConnUtilImpl::CheckAndChangeSlaveToMaster changing master"); + iMaster = ETrue; + err = iPubsub->SetValue( EVCxPSMasterExists, iMaster ); + } + iSemaSwitchRole.Signal(); + // Leaving critical section + /////// + + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CheckAndChangeSlaveToMaster out"); + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::HandleSlaveConnectionStatusL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::HandleSlaveConnectionStatusL( const TInt& aNewStatus ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleSlaveConnectionStatus in"); + // if master, do nothing + if( iMaster ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleSlaveConnectionStatus master out"); + return; + } + // resolve given connection, this structure is needed + // to prevent errors in type check + TVCxConnectionStatus gottenStatus( EVCxNotConnected ); + switch( aNewStatus ) + { + case EVCxNotConnected: + gottenStatus = EVCxNotConnected; + break; + case EVCxConnecting: + gottenStatus = EVCxConnecting; + break; + case EVCxConnected: + gottenStatus = EVCxConnected; + break; + case EVCxDisconnecting: + gottenStatus = EVCxDisconnecting; + break; + case EVCxRoamingRequest: + gottenStatus = EVCxRoamingRequest; + break; + case EVCxRoamingAccepted: + gottenStatus = EVCxRoamingAccepted; + break; + case EVCxError: + gottenStatus = EVCxError; + break; + default: + User::Leave( KErrGeneral ); + break; + } + TVCxConnectionStatus currentStatus = iEngine->ConnectionStatus(); + + MPX_DEBUG2( "HandleSlaveConnectionStatus gotten %d", gottenStatus ); + MPX_DEBUG2( "HandleSlaveConnectionStatus current %d", currentStatus ); + + if( gottenStatus == EVCxRoamingRequest && currentStatus == EVCxConnected ) + { + // if master is requesting roaming, query all external clients + // whether we can roam or not + MPX_DEBUG1( "CVcxConnUtilImpl::HandleSlaveConnectionStatus slave check Roaming"); + if ( DoRequestClientRoamingL() ) + { + gottenStatus = EVCxRoamingAccepted; + } + // client might have disconnected during roaming. In that case do not change status + if( iEngine->ConnectionStatus() != EVCxNotConnected ) + { + // set connection status explicitly to tell slave we're roaming + iEngine->SetConnectionStatus( gottenStatus ); + } + } + + else if( ( currentStatus == EVCxRoamingRequest || + currentStatus == EVCxRoamingAccepted || + currentStatus == EVCxConnected ) && + gottenStatus == EVCxConnected ) + { + // if current status was roaming or + // master has notified new connection and state + // has changed to connected, meaning + // master has succesfully reinitialized preferred connection + // slave needs to try to reinit connection via new iap if + // new iap differs from current + + TInt valueFromPS( 0 ); + User::LeaveIfError( iPubsub->GetValue( EVCxPSIapId, valueFromPS ) ); + MPX_DEBUG2( "HandleSlaveConnectionStatus slave iap %d", iEngine->IapId() ); + MPX_DEBUG2( "HandleSlaveConnectionStatus slave PS iap %d", valueFromPS ); + if( valueFromPS != iEngine->IapId() ) + { + User::LeaveIfError( iPubsub->GetValue( EVCxPSSnapId, valueFromPS ) ); + iEngine->Disconnect(); + if( DoCreateConnection( ETrue, valueFromPS, EFalse ) == KErrNone ) + { + // refresh connection details + iEngine->FillActiveConnectionDetailsL(); + MPX_DEBUG1( "CVcxConnUtilImpl::HandleSlaveConnectionStatus slave restarted ok" ); + } + else + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleSlaveConnectionStatus slave restarting not ok" ); + DisconnectL(); + gottenStatus = EVCxNotConnected; + } + NotifyObserversIAPChanged(); + } + iEngine->SetConnectionStatus( gottenStatus ); + } + else + { + if( gottenStatus == EVCxNotConnected || + gottenStatus == EVCxError ) + { + // master has notified disconnecting or error for some reason + DisconnectL(); + // notify normal disconnect to observers + if( gottenStatus == EVCxNotConnected ) + { + NotifyObserversIAPChanged(); + } + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleSlaveConnectionStatus out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::ValueChangedL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::HandleRoamingReponsesL( const TInt& aNbrOfResps ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleRoamingReponsesL in"); + if( !iMaster ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleRoamingReponsesL slave out"); + return; + } + if( iEngine->ConnectionStatus() != EVCxRoamingRequest ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleRoamingReponsesL not roaming"); + return; + } + // check if all have been responded and if all agreed on roaming + TInt nbrOfConUsers( 0 ); + TInt nbrOfAgeed( 0 ); + TInt nbrofResponses( aNbrOfResps ); + + User::LeaveIfError( iPubsub->GetValue( EVCxPSNbrConnInstances, nbrOfConUsers ) ); + User::LeaveIfError( iPubsub->GetValue( EVCxPSNbRoamAccepted, nbrOfAgeed ) ); + + if( nbrOfConUsers == nbrofResponses ) + { + if( nbrofResponses == nbrOfAgeed ) + { + // every instance has responded and all agrees roaming, + // change state for master's main thread to proceed + MPX_DEBUG1( "CVcxConnUtilImpl::HandleRoamingReponsesL EVCxRoamingAllowed"); + + User::LeaveIfError( iPubsub->SetValue( + EVCxPSRoamingRequestStatus, EVCxRoamingAllowed ) ); + } + else + { + MPX_DEBUG1( "CVcxConnUtilImpl::HandleRoamingReponsesL EVCxRoamingNotInit"); + User::LeaveIfError( iPubsub->SetValue( + EVCxPSRoamingRequestStatus, EVCxRoamingNotInit ) ); + } + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::HandleRoamingReponsesL out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::NotifyObserversIAPChanged() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::NotifyObserversIAPChanged() + { + for ( TInt i = 0; i < iObservers.Count(); i++ ) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::NotifyObserversIAPChanged notifying observer"); + TRAPD( err, iObservers[i]->IapChangedL() ); + if( err != KErrNone ) + { + MPX_DEBUG2( "vcxconnutil ## NotifyObserversIAPChanged::IapChanged observer leaved %d", err); + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::DisplayWaitNote() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::DisplayWaitNote(const TDesC& aConnectionName) + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::DisplayWaitNote in"); + if( iUIInterface ) + { + iUIInterface->DisplayWaitNote( aConnectionName ); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::DisplayWaitNote out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilImpl::CloseWaitNote() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilImpl::CloseWaitNote() + { + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CloseWaitNote in"); + if( iUIInterface ) + { + iUIInterface->CloseWaitNote(); + } + MPX_DEBUG1( "vcxconnutil ## CVcxConnUtilImpl::CloseWaitNote out"); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnutilpubsub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnutilpubsub.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,391 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +#include "vcxconnutilcommon.h" +#include "vcxconnectionutility.hrh" +#include "vcxconnutilpubsub.h" +#include "vcxconnutilsubscriber.h" +#include "vcxconnutilpubsubobserver.h" + +// CONSTANTS +_LIT( KConnUtilCounterSema, "__VcxConnUtillCounterSema__ "); +const TInt KSemaStartupValue = 1; + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::NewL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilPubSub* CVcxConnUtilPubSub::NewL( MConnUtilPubsubObserver *aObserver ) + { + CVcxConnUtilPubSub* self = CVcxConnUtilPubSub::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::NewLC() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilPubSub* CVcxConnUtilPubSub::NewLC( MConnUtilPubsubObserver *aObserver ) + { + CVcxConnUtilPubSub* self = new (ELeave) CVcxConnUtilPubSub( ); + CleanupStack::PushL( self ); + self->ConstructL( aObserver ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::CVcxNsConnUtilEngine() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilPubSub::CVcxConnUtilPubSub( ) + { + // NOP + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::ConstructL( MConnUtilPubsubObserver *aObserver ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilPubSub::ConstructL() in"); + + TInt status( KErrNone ); + // semafore for protecting P&S -counter value writing + status = iSemaCounter.CreateGlobal( KConnUtilCounterSema, KSemaStartupValue ); + if( status == KErrAlreadyExists ) + { + // if semafore exists already, just open handle to existing + status = iSemaCounter.OpenGlobal( KConnUtilCounterSema ); + } + User::LeaveIfError( status ); + + User::LeaveIfError( + iPropertyCurrentIAPId.Attach( KVcxConnUtilPScategory, + EVCxPSIapId ) ); + + User::LeaveIfError( + iPropertyCurrentSNAPId.Attach( KVcxConnUtilPScategory, + EVCxPSSnapId ) ); + + User::LeaveIfError( + iPropertyNbrOfInst.Attach( KVcxConnUtilPScategory, + EVCxPSNbrConnInstances ) ); + + User::LeaveIfError( + iPropertyAccepted.Attach( KVcxConnUtilPScategory, + EVCxPSNbRoamAccepted ) ); + + iConnectionStatePS = + CVcxConnUtilSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSConnectionStatus, + RProperty::EInt, aObserver ); + + iMasterExistPS = + CVcxConnUtilSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSMasterExists, + RProperty::EInt, aObserver ); + + iRoamingReqStatusPS = + CVcxConnUtilSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSRoamingRequestStatus, + RProperty::EInt, aObserver ); + + iNbrInstanceResp = + CVcxConnUtilSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSNbrRoamResp, + RProperty::EInt, aObserver ); + + if( GetValue( EVCxPSIapId, status ) == KErrNotFound ) + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilPubSub::ConstructL() no properties"); + + // define properties + DefinePropertiesL(); + } + + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilPubSub::ConstructL() out"); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::~CVcxConnUtilPubSub() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilPubSub::~CVcxConnUtilPubSub() + { + iSemaCounter.Close(); + + iPropertyCurrentIAPId.Close(); + iPropertyCurrentSNAPId.Close(); + iPropertyNbrOfInst.Close(); + iPropertyAccepted.Close(); + + delete iConnectionStatePS; + delete iMasterExistPS; + delete iRoamingReqStatusPS; + delete iNbrInstanceResp; + + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::DefinePropertiesL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::DefinePropertiesL() + { + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilPubSub::DefinePropertiesL() in"); + TInt result( KErrNone ); + RSemaphore semaphore; + result = semaphore.CreateGlobal( KVcxConnUtilPSSema, 0 ); + if( result != KErrNone && result != KErrAlreadyExists ) + { + // kernel cannot create semaphore, or there is no existing + User::LeaveIfError( result ); + } + if( result == KErrAlreadyExists ) + { + // semaphore exist. Some other process is already defining PS + // open semaphore and wait for it to finish + User::LeaveIfError( semaphore.OpenGlobal( KVcxConnUtilPSSema ) ); + semaphore.Wait(); + // check if PS keys do exists + TInt value( 0 ); + if( GetValue( EVCxPSIapId, value ) == KErrNotFound ) + { + // other proces has failed to define PS, + // this process will try it + result = KErrNone; + } + } + if( result == KErrNone ) + { + const TUidType createPSUid( KNullUid, KNullUid, KVcxConnUtilPScategory ); + + RProcess createPS; + result = createPS.Create( KVcxConnUtilPSWorkerName(), KNullDesC(), createPSUid ); + if( result == KErrNone ) + { + createPS.Resume(); + createPS.Close(); + semaphore.Wait(); + // init default values for keys, whose default differs from 0 + SetValue( EVCxPSRoamingRequestStatus, EVCxRoamingNotInit ); + SetValue( EVCxPSConnectionStatus, EVCxNotConnected ); + } + } + // need to signal here for other possible + // processes to proceed + semaphore.Signal(); + semaphore.Close(); + if( result != KErrNone && result != KErrAlreadyExists ) + { + // all other erros cause leave: worker process creation fails, or + // kernel refuses to open existing semphore (== platform problem) + User::LeaveIfError( result ); + } + MPX_DEBUG1("vcxconnutil ## CVcxConnUtilPubSub::DefinePropertiesL() out"); + } + + +RProperty* CVcxConnUtilPubSub::GetProperty( TUint32 aKey ) + { + switch( aKey ) + { + case EVCxPSConnectionStatus: + return &( iConnectionStatePS->Property() ); + + case EVCxPSIapId: + return &iPropertyCurrentIAPId; + + case EVCxPSSnapId: + return &iPropertyCurrentSNAPId; + + case EVCxPSMasterExists: + return &( iMasterExistPS->Property() ); + + case EVCxPSNbrConnInstances: + return &iPropertyNbrOfInst; + + case EVCxPSRoamingRequestStatus: + return &( iRoamingReqStatusPS->Property() ); + + case EVCxPSNbrRoamResp: + return &( iNbrInstanceResp->Property() ); + + case EVCxPSNbRoamAccepted: + return &iPropertyAccepted; + + default: + break; + } + return 0; + } + +CVcxConnUtilSubscriber* CVcxConnUtilPubSub::GetSubscriber( TUint32 aKey ) + { + switch( aKey ) + { + case EVCxPSConnectionStatus: + return iConnectionStatePS; + + case EVCxPSMasterExists: + return iMasterExistPS; + + case EVCxPSRoamingRequestStatus: + return iRoamingReqStatusPS; + + case EVCxPSNbrRoamResp: + return iNbrInstanceResp; + + default: + break; + } + return 0; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::IncCounterPubSubL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::IncCounterPubSubL( TUint32 aKey ) + { + const TInt KIncValue( 1 ); + DoPSCounterIncrementL( aKey, KIncValue ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::DecNbrOfConnUsersPubSub() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::DecCounterPubSubL( TUint32 aKey ) + { + const TInt KDecValue( -1 ); + DoPSCounterIncrementL( aKey, KDecValue ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::DoPSCounterIncrementL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::DoPSCounterIncrementL( TUint32 aKey, TInt aCalcFactor ) + { + if( aKey == EVCxPSNbrConnInstances || + aKey == EVCxPSNbrRoamResp || + aKey == EVCxPSNbRoamAccepted ) + { + RProperty* property = GetProperty( aKey ); + if( property ) + { + TInt value( 0 ); + TInt err( KErrNone ); + // entering critical section + iSemaCounter.Wait(); + err = property->Get( value ); + if( err == KErrNone ) + { + value += aCalcFactor; + err = property->Set( value ); + } + // leaving critical section + iSemaCounter.Signal(); + User::LeaveIfError( err ); + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::SetValue() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilPubSub::SetValue( TUint32 aKey, TInt aValue ) + { + TInt err( KErrNone ); + RProperty* property = GetProperty( aKey ); + if( property ) + { + err = property->Set( aValue ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::GetValue() +// ----------------------------------------------------------------------------- +// +TInt CVcxConnUtilPubSub::GetValue( TUint32 aKey, TInt& aValue ) + { + TInt err( KErrNone ); + RProperty* property = GetProperty( aKey ); + if( property ) + { + err = property->Get( aValue ); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::CancelValueSubscribers() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::StartSubscibers( TUint32 aKey ) + { + if( !aKey ) + { + iConnectionStatePS->Start(); + iMasterExistPS->Start(); + iRoamingReqStatusPS->Start(); + iNbrInstanceResp->Start(); + } + else + { + CVcxConnUtilSubscriber* subscriber = GetSubscriber( aKey ); + if( subscriber ) + { + subscriber->Start(); + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilPubSub::CancelValueSubscribers() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilPubSub::CancelValueSubscribers( TUint32 aKey ) + { + if( !aKey ) + { + iConnectionStatePS->Cancel(); + iMasterExistPS->Cancel(); + iRoamingReqStatusPS->Cancel(); + iNbrInstanceResp->Cancel(); + } + else + { + CVcxConnUtilSubscriber* subscriber = GetSubscriber( aKey ); + if( subscriber ) + { + subscriber->Cancel(); + } + } + } +// end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnutilsubscriber.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnutilsubscriber.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle subscribtions from PS* +*/ + + + +#include "vcxconnutilsubscriber.h" +#include "vcxconnutilpubsubobserver.h" + + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::CVcxConnUtilSubscriber() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilSubscriber::CVcxConnUtilSubscriber( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MConnUtilPubsubObserver* aObserver ) : + CActive( EPriorityStandard ), + iUid( aUid ), + iKey( aKey ), + iKeyType(aType), + iObserver( aObserver ) + { + // NOP + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::NewL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilSubscriber* CVcxConnUtilSubscriber::NewL( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MConnUtilPubsubObserver* aObserver ) + { + CVcxConnUtilSubscriber* self = + new( ELeave ) CVcxConnUtilSubscriber( aUid, aKey, aType, aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilSubscriber::ConstructL() + { + iInitialized = EFalse; + User::LeaveIfError( iProperty.Attach( iUid, iKey ) ); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::~CVcxConnUtilSubscriber() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilSubscriber::~CVcxConnUtilSubscriber() + { + if( IsActive() ) + { + Cancel(); + } + iProperty.Close(); + + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::Property() +// ----------------------------------------------------------------------------- +// +RProperty& CVcxConnUtilSubscriber::Property() + { + return iProperty; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::Start() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilSubscriber::Start() + { + if( !IsActive() ) + { + iProperty.Subscribe( iStatus ); + SetActive(); + iInitialized = ETrue; + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::DoCancel() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilSubscriber::DoCancel() + { + if( IsActive() ) + { + iProperty.Cancel(); + } + iInitialized = EFalse; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilSubscriber::RunL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilSubscriber::RunL() + { + // resubscribe before processing new + // value to prevent missing updates + iProperty.Subscribe( iStatus ); + SetActive(); + + if( iInitialized ) + { + if(iKeyType == RProperty::EInt ) + { + TInt intValue; + // int type changed + if( iProperty.Get( intValue ) == KErrNone && iObserver ) + { + TRAP_IGNORE( iObserver->ValueChangedL( iKey, intValue ) ); + } + } + } + iInitialized = ETrue; + } +// end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutility/src/vcxconnutilwaitsch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutility/src/vcxconnutilwaitsch.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CCVcxConnUtilWaitSch class definition file* +*/ + + + + + +#include "vcxconnutilwaitsch.h" + + + /** + * CVcxConnUtilWait is used to wrap CActiveScheduler objects to be used + * as "wait-type" context within videoconnutility. + * Each CVcxConnUtilWait object has a wait type -id for whose + * object maintans an array of CActiveScheduler objects' wait state. + */ +NONSHARABLE_CLASS( CVcxConnUtilWait ) : public CBase + { + public: + + /** + * Destructor. + */ + ~CVcxConnUtilWait() + { + iWaitArray.ResetAndDestroy(); + }; + + /** + * Default constructor + */ + CVcxConnUtilWait( ) {}; + + /** + * Wait type id + */ + TUint32 iType; + + /** + * Flag to indicate wether CActiveScheduler maintained + * by this object can really be released. In case flag is + * false, CActiveScheduler -objects need to be put to wait + * again right after their release. + */ + TBool iCanStop; + + /** + * Array containing CActiveScheduler maintained + * by this object + */ + RPointerArray < CActiveSchedulerWait > iWaitArray; + }; + + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::CVcxConnUtilWaitSch() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilWaitSch::CVcxConnUtilWaitSch() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::~CVcxConnUtilWaitSch() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilWaitSch::~CVcxConnUtilWaitSch() + { + iWaits.ResetAndDestroy(); + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::NewLC() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilWaitSch* CVcxConnUtilWaitSch::NewLC() + { + CVcxConnUtilWaitSch* self = new (ELeave)CVcxConnUtilWaitSch(); + CleanupStack::PushL(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::NewL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilWaitSch* CVcxConnUtilWaitSch::NewL() + { + CVcxConnUtilWaitSch* self = CVcxConnUtilWaitSch::NewLC(); + CleanupStack::Pop( self ); // self; + return self; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::WaitL() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilWaitSch::WaitL( TUint32 aWaitId ) + { + CVcxConnUtilWait* wait = GetWaitL( aWaitId ); + CActiveSchedulerWait* activeWait = GetActiveSWaitL( wait ); + + while( !wait->iCanStop ) + { + activeWait->Start(); + } + + TInt index = wait->iWaitArray.FindL( activeWait ); + if( index != KErrNotFound ) + { + wait->iWaitArray.Remove( index ); + } + delete activeWait; + + if( !wait->iWaitArray.Count() ) + { + index = iWaits.FindL( wait ); + if( index != KErrNotFound ) + { + iWaits.Remove( index ); + } + delete wait; + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::EndWait() +// ----------------------------------------------------------------------------- +// +void CVcxConnUtilWaitSch::EndWait( TUint32 aWaitId ) + { + TInt waitCount( 0 ); + TInt asWaitCount( 0 ); + + waitCount = iWaits.Count(); + + for( TInt i( 0 ); i < waitCount; ++i ) + { + iWaits[ i ]->iCanStop = ( aWaitId == iWaits[ i ]->iType ); + + asWaitCount = iWaits[ i ]->iWaitArray.Count(); + + for( TInt j( 0 ); j < asWaitCount; ++j ) + { + if( iWaits[ i ]->iWaitArray[ j ]->IsStarted() ) + { + iWaits[ i ]->iWaitArray[ j ]->AsyncStop(); + } + } + } + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::GetWaitL() +// ----------------------------------------------------------------------------- +// +CVcxConnUtilWait* CVcxConnUtilWaitSch::GetWaitL( TUint32 aID ) + { + CVcxConnUtilWait* wait( 0 ); + TInt count( 0 ); + count = iWaits.Count(); + + for( TInt i( 0 ); i < count; ++i ) + { + if( iWaits[ i ]->iType == aID ) + { + wait = iWaits[ i ]; + break; + } + } + if( !wait ) + { + wait = new (ELeave) CVcxConnUtilWait(); + CleanupStack::PushL( wait ); + wait->iType = aID; + iWaits.AppendL( wait ); + CleanupStack::Pop( wait ); + } + return wait; + } + +// ----------------------------------------------------------------------------- +// CVcxConnUtilWaitSch::GetActiveSWaitL() +// ----------------------------------------------------------------------------- +// +CActiveSchedulerWait* CVcxConnUtilWaitSch::GetActiveSWaitL( CVcxConnUtilWait* aWait ) + { + CActiveSchedulerWait* item( 0 ); + if( aWait ) + { + TInt count( aWait->iWaitArray.Count() ); + for( TInt i( 0 ); i < count; i++ ) + { + if( !( aWait->iWaitArray[i]->IsStarted() ) ) + { + item = aWait->iWaitArray[i]; + break; + } + } + } + if( !item ) + { + item = new ( ELeave) CActiveSchedulerWait; + CleanupStack::PushL( item ); + aWait->iWaitArray.AppendL( item ); + CleanupStack::Pop( item ); + } + return item; + } +// End of file + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutilpsworker/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutilpsworker/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../rom/videoconnutilpsworker.iby CORE_MW_LAYER_IBY_EXPORT_PATH(videoconnutilpsworker.iby) + +PRJ_MMPFILES +vcxconnutilpsworker.mmp diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutilpsworker/group/vcxconnutilpsworker.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutilpsworker/group/vcxconnutilpsworker.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is a project specification file for PS worker fo connectionutility* +*/ + + + +#include +#include + +TARGET vcxconnutilpsworker.exe +TARGETTYPE exe +UID 0 0x2001B2AB + +USERINCLUDE ../../inc + +MW_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE vcxconnutilpsworker.cpp + +LIBRARY euser.lib + + + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutilpsworker/rom/videoconnutilpsworker.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutilpsworker/rom/videoconnutilpsworker.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __VIDEOCONNUTILPSWORKER_IBY__ +#define __VIDEOCONNUTILPSWORKER_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\vcxconnutilpsworker.exe PROGRAMS_DIR\vcxconnutilpsworker.exe + +#endif // __VIDEOCONNUTILPSWORKER_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/connutilpsworker/src/vcxconnutilpsworker.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/connutilpsworker/src/vcxconnutilpsworker.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: executable for defining PS keys used by the connectionutility* +*/ + + + + +#include +#include +#include + +#include "vcxconnutilcommon.h" +#include "vcxconnectionutility.hrh" + + +// --------------------------------------------------------------------------- +// E32Main() +// Provides the globale entry point function for the platform to start process +// --------------------------------------------------------------------------- +// +GLDEF_C TInt E32Main() + { + // Create cleanup stack + __UHEAP_MARK; + + // define properties + RProperty::Define( KVcxConnUtilPScategory, EVCxPSConnectionStatus, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSIapId, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSSnapId, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSMasterExists, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSNbrConnInstances, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSRoamingRequestStatus, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSNbRoamAccepted, RProperty::EInt ); + + RProperty::Define( KVcxConnUtilPScategory, EVCxPSNbrRoamResp, RProperty::EInt ); + + RSemaphore semaphore; + if( semaphore.OpenGlobal( KVcxConnUtilPSSema ) == KErrNone ) + { + // Semaphore opened ok, so someone really needing PS keys exists. + // signal it to notify PS keys are defined + semaphore.Signal(); + semaphore.Close(); + } + __UHEAP_MARKEND; + return KErrNone; + } +// end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +#include "../connutilpsworker/group/bld.inf" +#include "../connutility/group/bld.inf" + +PRJ_PLATFORMS + +WINSCW ARMV5 + +PRJ_EXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + + diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/inc/vcxconnectionutility.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/inc/vcxconnectionutility.hrh Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: vcxconnectionutility definitions and enums* +*/ + + + +#ifndef __VCX_CONNECTIOUTILITY_HRH__ +#define __VCX_CONNECTIOUTILITY_HRH__ + +/** + * P&S key id enums: + * + * EVCxPSConnectionStatus - Master saves current connection status here. Possible values are: + * - EVCxNotConnected: there is no active connection in the connectionutility scope + * - EVCxConnected: connection exists and is active + * - EVCxRoamingRequest: connectiontuility is in roaming mode + * + * EVCxPSIapId - Current active iap id + * + * EVCxPSSnapId - Current active Destination id + * + * EVCxPSMasterExists - This value is used to notify slaves wether master exists or not. + * When active master disconnects it changes this value to 0. Slaves notify + * this and first slave which gets the notifications changes itself to be new master + * + * EVCxPSNbrConnInstances- Number of processes that use connectionutility and have active connection. + * + * EVCxPSRoamingRequestStatus - Value is used internally by the master when it waits slaves to request + * roaming state. + * Possible values are: + * - EVCxRoamingNotInit: when master has requested roaming from it's own clients it sets this value. + * Same value is resetted if roaming is not allowed + * - EVCxRoamingAllowed: When master's and all slaves' clients have been accepted roaming this value is + * setted to notify that roaming is allowed + * + * EVCxPSNbrRoamResp - Number of responses received from different connectionutility processes. + * + * EVCxPSNbRoamAccepted - Number of accepted responses from the roaming request from different + * connectionutility processes. + */ +enum TVCxPSConUtilKeyId + { + EVCxPSConnectionStatus = 0x00000001, // TVCxConnectionStatus + EVCxPSIapId, // TInt + EVCxPSSnapId, // TInt + EVCxPSMasterExists, // TInt + EVCxPSNbrConnInstances, // TInt + EVCxPSRoamingRequestStatus, // TVCxPSConUtilRoamingRequest + EVCxPSNbrRoamResp, // TInt + EVCxPSNbRoamAccepted // TInt + }; + +/** + * enums for roaming state to be used in + * EVCxPSRoamingRequestStatus when EVCxPSConnectionStatus + * is EVCxRoamingRequest + */ +enum TVCxPSConUtilRoamingRequest + { + EVCxRoamingNotInit = 50, + EVCxRoamingAllowed + }; + +/** + * connection utility's connection state enums + * EVCxNotConnected + * current instance is not connected to network and does not maintain any active connection. + * + * EVCxConnecting + * current instance is waiting for networkingmiddleware to initialize connection + * + * EVCxConnected + * current instance is connected and it maintains active connection + * + * EVCxDisconnecting + * current instance is disconnecting + * + * EVCxRoamingRequest + * current master instance is requesting it's client's about roaming. + * If instance is slave, this state notifies that slave does not accept roaming. + * + * EVCxPendingClientRequest + * Operation path is in the client side during roaming. + * + * EVCxRoamingAccepted + * Slave: current instance's client's are all accepted roaming. + * Master: every local client and all slaves have been accepted roaming. + * + * EVCxError + * unresolved error received from the networking middleware. In this case clients are notified by the IapChanged in which + * case client can try to resolve connection by recalling GetIap, or disconnecting connection + * + */ +enum TVCxConnectionStatus + { + EVCxNotConnected = 10, + EVCxConnecting, + EVCxConnected, + EVCxDisconnecting, + EVCxRoamingRequest, + EVCxPendingClientRequest, + EVCxRoamingAccepted, + EVCxError + }; + +#endif // __VCX_CONNECTIOUTILITY_HRH__ +// end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoconnutility/inc/vcxconnutilcommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoconnutility/inc/vcxconnutilcommon.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: containd common constants used in the scope of vcxconnectionutility* +*/ + + + + +#ifndef __VCX_CONNUTILCOMMON_H +#define __VCX_CONNUTILCOMMON_H + +/** + * use UID of the PS worker as a category of the + * PS keys used by connectionutility + */ +const TUid KVcxConnUtilPScategory = { 0x2001B2AB }; + +/** + * name of the "PS -worker" executable + */ +_LIT( KVcxConnUtilPSWorkerName, "vcxconnutilpsworker" ); + +/** + * name of the semaphore used by the PS worker to signal + * PS keys are ready + */ +_LIT( KVcxConnUtilPSSema, "__vcxxonnutilsemaphore__" ); + +#endif // __VCX_CONNUTILCOMMON_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/BWINS/CseSchedulerClientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/BWINS/CseSchedulerClientU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,38 @@ +EXPORTS + ??0CCseScheduledProgram@@IAE@XZ @ 1 NONAME ; CCseScheduledProgram::CCseScheduledProgram(void) + ??1CCseScheduledProgram@@UAE@XZ @ 2 NONAME ; CCseScheduledProgram::~CCseScheduledProgram(void) + ??1CCseSchedulerApi@@UAE@XZ @ 3 NONAME ; CCseSchedulerApi::~CCseSchedulerApi(void) + ?AddSchedule@CCseSchedulerApi@@QBEHAAVCCseScheduledProgram@@@Z @ 4 NONAME ; int CCseSchedulerApi::AddSchedule(class CCseScheduledProgram &) const + ?AppUid@CCseScheduledProgram@@QBEJXZ @ 5 NONAME ; long CCseScheduledProgram::AppUid(void) const + ?ApplicationData@CCseScheduledProgram@@QAE?AVTPtrC8@@XZ @ 6 NONAME ; class TPtrC8 CCseScheduledProgram::ApplicationData(void) + ?DbIdentifier@CCseScheduledProgram@@QBEKXZ @ 7 NONAME ; unsigned long CCseScheduledProgram::DbIdentifier(void) const + ?DebugDump@CCseScheduledProgram@@QBEXXZ @ 8 NONAME ; void CCseScheduledProgram::DebugDump(void) const + ?EndTime@CCseScheduledProgram@@QAEAAVTTime@@XZ @ 9 NONAME ; class TTime & CCseScheduledProgram::EndTime(void) + ?ExternalizeL@CCseScheduledProgram@@QAEXAAVRWriteStream@@@Z @ 10 NONAME ; void CCseScheduledProgram::ExternalizeL(class RWriteStream &) + ?ExternalizeLength@CCseScheduledProgram@@QAEHXZ @ 11 NONAME ; int CCseScheduledProgram::ExternalizeLength(void) + ?GetOverlappingSchedules@CCseSchedulerApi@@QAEHAAVCCseScheduledProgram@@AAV?$RPointerArray@VCCseScheduledProgram@@@@@Z @ 12 NONAME ; int CCseSchedulerApi::GetOverlappingSchedules(class CCseScheduledProgram &, class RPointerArray &) + ?GetSchedule@CCseSchedulerApi@@QBEHKPAVCCseScheduledProgram@@@Z @ 13 NONAME ; int CCseSchedulerApi::GetSchedule(unsigned long, class CCseScheduledProgram *) const + ?GetSchedulesByAppUid@CCseSchedulerApi@@QBEHJAAV?$RPointerArray@VCCseScheduledProgram@@@@@Z @ 14 NONAME ; int CCseSchedulerApi::GetSchedulesByAppUid(long, class RPointerArray &) const + ?GetSchedulesByPluginUid@CCseSchedulerApi@@QBEHJAAV?$RPointerArray@VCCseScheduledProgram@@@@@Z @ 15 NONAME ; int CCseSchedulerApi::GetSchedulesByPluginUid(long, class RPointerArray &) const + ?GetSchedulesByTime@CCseSchedulerApi@@QBEHABVTTime@@0AAV?$RPointerArray@VCCseScheduledProgram@@@@@Z @ 16 NONAME ; int CCseSchedulerApi::GetSchedulesByTime(class TTime const &, class TTime const &, class RPointerArray &) const + ?GetSchedulesByType@CCseSchedulerApi@@QBEHJAAV?$RPointerArray@VCCseScheduledProgram@@@@@Z @ 17 NONAME ; int CCseSchedulerApi::GetSchedulesByType(long, class RPointerArray &) const + ?InternalizeL@CCseScheduledProgram@@QAEXAAVRReadStream@@@Z @ 18 NONAME ; void CCseScheduledProgram::InternalizeL(class RReadStream &) + ?Name@CCseScheduledProgram@@QBE?AVTPtrC8@@XZ @ 19 NONAME ; class TPtrC8 CCseScheduledProgram::Name(void) const + ?NewL@CCseScheduledProgram@@SAPAV1@AAV1@@Z @ 20 NONAME ; class CCseScheduledProgram * CCseScheduledProgram::NewL(class CCseScheduledProgram &) + ?NewL@CCseScheduledProgram@@SAPAV1@XZ @ 21 NONAME ; class CCseScheduledProgram * CCseScheduledProgram::NewL(void) + ?NewL@CCseSchedulerApi@@SAPAV1@XZ @ 22 NONAME ; class CCseSchedulerApi * CCseSchedulerApi::NewL(void) + ?PluginType@CCseScheduledProgram@@QBEJXZ @ 23 NONAME ; long CCseScheduledProgram::PluginType(void) const + ?PluginUid@CCseScheduledProgram@@QBEJXZ @ 24 NONAME ; long CCseScheduledProgram::PluginUid(void) const + ?RemoveSchedule@CCseSchedulerApi@@QBEHK@Z @ 25 NONAME ; int CCseSchedulerApi::RemoveSchedule(unsigned long) const + ?ScheduleType@CCseScheduledProgram@@QBEJXZ @ 26 NONAME ; long CCseScheduledProgram::ScheduleType(void) const + ?SetAppUid@CCseScheduledProgram@@QAEXJ@Z @ 27 NONAME ; void CCseScheduledProgram::SetAppUid(long) + ?SetApplicationDataL@CCseScheduledProgram@@QAEXABVTDesC8@@@Z @ 28 NONAME ; void CCseScheduledProgram::SetApplicationDataL(class TDesC8 const &) + ?SetDbIdentifier@CCseScheduledProgram@@QAEXK@Z @ 29 NONAME ; void CCseScheduledProgram::SetDbIdentifier(unsigned long) + ?SetEndTime@CCseScheduledProgram@@QAEXABVTTime@@@Z @ 30 NONAME ; void CCseScheduledProgram::SetEndTime(class TTime const &) + ?SetName@CCseScheduledProgram@@QAEXABVTDesC8@@@Z @ 31 NONAME ; void CCseScheduledProgram::SetName(class TDesC8 const &) + ?SetPluginType@CCseScheduledProgram@@QAEXJ@Z @ 32 NONAME ; void CCseScheduledProgram::SetPluginType(long) + ?SetPluginUid@CCseScheduledProgram@@QAEXJ@Z @ 33 NONAME ; void CCseScheduledProgram::SetPluginUid(long) + ?SetScheduleType@CCseScheduledProgram@@QAEXJ@Z @ 34 NONAME ; void CCseScheduledProgram::SetScheduleType(long) + ?SetStartTime@CCseScheduledProgram@@QAEXABVTTime@@@Z @ 35 NONAME ; void CCseScheduledProgram::SetStartTime(class TTime const &) + ?StartTime@CCseScheduledProgram@@QAEAAVTTime@@XZ @ 36 NONAME ; class TTime & CCseScheduledProgram::StartTime(void) + diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/EABI/CseSchedulerClientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/EABI/CseSchedulerClientU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,53 @@ +EXPORTS + _ZN16CCseSchedulerApi23GetOverlappingSchedulesER20CCseScheduledProgramR13RPointerArrayIS0_E @ 1 NONAME + _ZN16CCseSchedulerApi4NewLEv @ 2 NONAME + _ZN16CCseSchedulerApiD0Ev @ 3 NONAME + _ZN16CCseSchedulerApiD1Ev @ 4 NONAME + _ZN16CCseSchedulerApiD2Ev @ 5 NONAME + _ZN20CCseScheduledProgram10SetEndTimeERK5TTime @ 6 NONAME + _ZN20CCseScheduledProgram12ExternalizeLER12RWriteStream @ 7 NONAME + _ZN20CCseScheduledProgram12InternalizeLER11RReadStream @ 8 NONAME + _ZN20CCseScheduledProgram12SetPluginUidEl @ 9 NONAME + _ZN20CCseScheduledProgram12SetStartTimeERK5TTime @ 10 NONAME + _ZN20CCseScheduledProgram13SetPluginTypeEl @ 11 NONAME + _ZN20CCseScheduledProgram15ApplicationDataEv @ 12 NONAME + _ZN20CCseScheduledProgram15SetDbIdentifierEm @ 13 NONAME + _ZN20CCseScheduledProgram15SetScheduleTypeEl @ 14 NONAME + _ZN20CCseScheduledProgram17ExternalizeLengthEv @ 15 NONAME + _ZN20CCseScheduledProgram19SetApplicationDataLERK6TDesC8 @ 16 NONAME + _ZN20CCseScheduledProgram4NewLERS_ @ 17 NONAME + _ZN20CCseScheduledProgram4NewLEv @ 18 NONAME + _ZN20CCseScheduledProgram7EndTimeEv @ 19 NONAME + _ZN20CCseScheduledProgram7SetNameERK6TDesC8 @ 20 NONAME + _ZN20CCseScheduledProgram9SetAppUidEl @ 21 NONAME + _ZN20CCseScheduledProgram9StartTimeEv @ 22 NONAME + _ZN20CCseScheduledProgramC1Ev @ 23 NONAME + _ZN20CCseScheduledProgramC2Ev @ 24 NONAME + _ZN20CCseScheduledProgramD0Ev @ 25 NONAME + _ZN20CCseScheduledProgramD1Ev @ 26 NONAME + _ZN20CCseScheduledProgramD2Ev @ 27 NONAME + _ZNK16CCseSchedulerApi11AddScheduleER20CCseScheduledProgram @ 28 NONAME + _ZNK16CCseSchedulerApi11GetScheduleEmP20CCseScheduledProgram @ 29 NONAME + _ZNK16CCseSchedulerApi14RemoveScheduleEm @ 30 NONAME + _ZNK16CCseSchedulerApi18GetSchedulesByTimeERK5TTimeS2_R13RPointerArrayI20CCseScheduledProgramE @ 31 NONAME + _ZNK16CCseSchedulerApi18GetSchedulesByTypeElR13RPointerArrayI20CCseScheduledProgramE @ 32 NONAME + _ZNK16CCseSchedulerApi20GetSchedulesByAppUidElR13RPointerArrayI20CCseScheduledProgramE @ 33 NONAME + _ZNK16CCseSchedulerApi23GetSchedulesByPluginUidElR13RPointerArrayI20CCseScheduledProgramE @ 34 NONAME + _ZNK20CCseScheduledProgram10PluginTypeEv @ 35 NONAME + _ZNK20CCseScheduledProgram12DbIdentifierEv @ 36 NONAME + _ZNK20CCseScheduledProgram12ScheduleTypeEv @ 37 NONAME + _ZNK20CCseScheduledProgram4NameEv @ 38 NONAME + _ZNK20CCseScheduledProgram6AppUidEv @ 39 NONAME + _ZNK20CCseScheduledProgram9DebugDumpEv @ 40 NONAME + _ZNK20CCseScheduledProgram9PluginUidEv @ 41 NONAME + _ZTI16CCseSchedulerApi @ 42 NONAME ; ## + _ZTI19RCseSchedulerClient @ 43 NONAME ; ## + _ZTI20CCseScheduledProgram @ 44 NONAME ; ## + _ZTI20RCseSchedulerService @ 45 NONAME ; ## + _ZTI24RCseSchedulerServiceBase @ 46 NONAME ; ## + _ZTV16CCseSchedulerApi @ 47 NONAME ; ## + _ZTV19RCseSchedulerClient @ 48 NONAME ; ## + _ZTV20CCseScheduledProgram @ 49 NONAME ; ## + _ZTV20RCseSchedulerService @ 50 NONAME ; ## + _ZTV24RCseSchedulerServiceBase @ 51 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/group/CseSchedulerClient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/group/CseSchedulerClient.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is a project specification file for Common Scheduling Engine / client* +*/ + + + + +#include +#include + +//OPTION ARMCC --asm --interleave +ALWAYS_BUILD_AS_ARM + +TARGET cseschedulerclient.dll +TARGETTYPE dll +UID 0x1000008d 0x10281F1F + +CAPABILITY CAP_ECOM_PLUGIN DRM + +// ECom Dll recognition UID followed by the unique UID for this dll + +SOURCEPATH ../src +SOURCE CCseSchedulerAPI.cpp +SOURCE RCseSchedulerClient.cpp +SOURCE RCseSchedulerService.cpp +SOURCE RCseSchedulerServiceBase.cpp +SOURCE CCseScheduledProgram.cpp + + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +MW_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../data + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY flogger.lib +LIBRARY estor.lib + +LANGUAGE_IDS diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/videoschedulerclient.iby CORE_MW_LAYER_IBY_EXPORT_PATH(videoschedulerclient.iby) +PRJ_MMPFILES +CseSchedulerClient.mmp diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/rom/videoschedulerclient.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/rom/videoschedulerclient.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __VIDEOSCHEDULERCLIENT_IBY__ +#define __VIDEOSCHEDULERCLIENT_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\CseSchedulerClient.dll SHARED_LIB_DIR\CseSchedulerClient.dll + +#endif // __VIDEOSCHEDULERCLIENT_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/src/CCseScheduledProgram.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/src/CCseScheduledProgram.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,552 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class contains data for scheduled programs.* +*/ + + + + +// INCLUDES +#include // Header file for this class +#include "CseDebug.h" // Debug macros + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// --------------------------------------------------------------------------- +// CCseScheduledProgram::CCseScheduledProgram() +// +// --------------------------------------------------------------------------- +EXPORT_C CCseScheduledProgram::CCseScheduledProgram() : + iStartTime( 0 ), + iEndTime( 0 ), + iAppUid( 0 ), + iPluginUid( 0 ), + iDbIdentifier( 0 ), + iScheduleType ( ECseOther ), + iPluginType( ECseUniPlugin ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::CCseScheduledProgram"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::NewL"); + + CCseScheduledProgram* self = new ( ELeave ) CCseScheduledProgram(); + CleanupStack::PushL( self ); + self->ConstructL(); + self->SetName( aProg.Name() ); + self->SetStartTime( aProg.StartTime() ); + self->SetEndTime( aProg.EndTime() ); + self->SetAppUid( aProg.AppUid() ); + self->SetPluginUid( aProg.PluginUid() ); + self->SetDbIdentifier( aProg.DbIdentifier() ); + self->SetApplicationDataL( aProg.ApplicationData() ); + self->SetScheduleType( aProg.ScheduleType() ); + self->SetPluginType( aProg.PluginType() ); + CleanupStack::Pop( self ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::NewL"); + + CCseScheduledProgram* self = new ( ELeave ) CCseScheduledProgram(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::ConstructL"); + iAppData = HBufC8::NewL( 0 ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::~CCseScheduledProgram"); + delete iAppData; + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::SetScheduleType"); + iScheduleType = aScheduleType; + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::SetApplicationData"); + delete iAppData; + iAppData = NULL; + iAppData = aAppData.AllocL(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::ApplicationData"); + return *iAppData; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::InternalizeL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::InternalizeL( RReadStream& aStream ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::InternalizeL"); + TUint32 lower( 0 ); + TUint32 upper( 0 ); + TInt32 buffLen( 0 ); + + // Name + buffLen = aStream.ReadInt32L(); + aStream.ReadL( iName, buffLen ); + + // Start time + lower = aStream.ReadUint32L(); + upper = aStream.ReadUint32L(); + TInt64 time( 0 ); + time = (TInt64) lower; + TInt64 longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + iStartTime = time; + + // End time + lower = aStream.ReadUint32L(); + upper = aStream.ReadUint32L(); + time = (TInt64) lower; + longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + iEndTime = time; + + // Application UID + iAppUid = aStream.ReadInt32L(); + + // Notifier plug-in UID + iPluginUid = aStream.ReadInt32L(); + + // Db identifier + iDbIdentifier = aStream.ReadUint32L(); + + // Schedule type + iScheduleType = aStream.ReadInt32L(); + + // Plugin type + iPluginType = aStream.ReadInt32L(); + + // Application data length + buffLen = aStream.ReadInt32L(); + + // Application data + delete iAppData; + iAppData = NULL; + iAppData = HBufC8::NewL( buffLen ); + TPtr8 ptr( iAppData->Des() ); + aStream.ReadL( ptr, buffLen ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::ExternalizeL"); + TInt64 temp( 0 ); + TUint32 lower( 0 ); + TUint32 upper( 0 ); + TInt32 buffLen( 0 ); + + // Name + buffLen = iName.Length(); + aStream.WriteInt32L( buffLen ); + aStream.WriteL( iName ); + // Start time + temp = iStartTime.Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + aStream.WriteUint32L( lower ); + aStream.WriteUint32L( upper ); + + // End time + temp = iEndTime.Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + aStream.WriteUint32L( lower ); + aStream.WriteUint32L( upper ); + + // Application UID + aStream.WriteInt32L( iAppUid ); + + // Notifier plug-in UID + aStream.WriteInt32L( iPluginUid ); + + // DbIdentifier + aStream.WriteUint32L( iDbIdentifier ); + + // Schedule type + aStream.WriteInt32L( iScheduleType ); + + // Schedule type + aStream.WriteInt32L( iPluginType ); + + // Application data length + buffLen = iAppData->Length(); + aStream.WriteInt32L( buffLen ); + + // Application data + aStream.WriteL( *iAppData ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::ExternalizeLength"); + TInt retValue( 0 ); + retValue = sizeof( iStartTime ) + +sizeof( iEndTime ) + +sizeof( iAppUid ) + +sizeof( iPluginUid ) + +sizeof( iDbIdentifier ) + +sizeof( iScheduleType ) + +sizeof( iPluginType ) + +sizeof( TInt32 ) // Application data length + +sizeof( TInt32 ) // Name length + +iName.Size( ) // Name + +iAppData->Size( ); // Application data size + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduledProgram::SetPluginType"); + iPluginType = aPluginType; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetName +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetName( const TDesC8& aName ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetName"); + iName = aName; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetDbIdentifier +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetDbIdentifier( const TUint32 aDbIdentifier ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetDbIdentifier"); + iDbIdentifier = aDbIdentifier; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetStartTime +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetStartTime( const TTime& aStartTime ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetStartTime"); + iStartTime = aStartTime; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetEndTime +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetEndTime( const TTime& aEndTime ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetEndTime"); + iEndTime = aEndTime; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetAppUid +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetAppUid( const TInt32 aAppUid ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetAppUid"); + iAppUid = aAppUid; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::SetPluginUid +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::SetPluginUid( const TInt32 aPluginUid ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetPluginUid"); + iPluginUid = aPluginUid; + } + + +// Getters for the instance data +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::GetPluginType +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt32 CCseScheduledProgram::PluginType() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::PluginType"); + return iPluginType; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::Name +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC8 CCseScheduledProgram::Name() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::Name"); + return iName; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::DbIdentifier +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint32 CCseScheduledProgram::DbIdentifier() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::DbIdentifier"); + return iDbIdentifier; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::StartTime +// ----------------------------------------------------------------------------- +// +EXPORT_C TTime& CCseScheduledProgram::StartTime() + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::SetDbIdentifier"); + return iStartTime; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::EndTime +// ----------------------------------------------------------------------------- +// +EXPORT_C TTime& CCseScheduledProgram::EndTime() + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::EndTime"); + return iEndTime; + } + + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::ScheduleType +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt32 CCseScheduledProgram::ScheduleType() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::ScheduleType"); + return iScheduleType; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::AppUid +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt32 CCseScheduledProgram::AppUid() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::Appuid"); + return iAppUid; + } + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::PluginUid +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt32 CCseScheduledProgram::PluginUid() const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::PluginUid"); + return iPluginUid; + } + + +// ----------------------------------------------------------------------------- +// CCseScheduledProgram::DebugDump +// ----------------------------------------------------------------------------- +// +EXPORT_C void CCseScheduledProgram::DebugDump() const + { +#ifdef _DEBUG + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduledProgram::DebugDump"); + + // Write schedule name + // Change 8-bit buffer to 16-bit. + HBufC* writeBuff = NULL; + TRAPD( err, writeBuff = HBufC::NewL( iName.Length() ) ); + if(err == KErrNone) + { + TPtr writePtr = writeBuff->Des(); + writePtr.Copy( iName ); + CSELOGSTRING2_HIGH_LEVEL("Schedule name: %S", writeBuff); + } + else + { + CSELOGSTRING2_HIGH_LEVEL("Schedule name: %S", &iName); + } + + // Start time + TBuf<100> startTimeBuf; + _LIT( KDateTimeFormat,"%1%*D/%2%*M/%3%*Y %H:%T:%S" ); + TRAP( err, iStartTime.FormatL( startTimeBuf, KDateTimeFormat ) ); + if ( KErrNone == err ) + { + CSELOGSTRING2_HIGH_LEVEL("Schedule start time: %S", &startTimeBuf); + } + + // End time + TBuf<100> endTimeBuf; + TRAP( err, iEndTime.FormatL( endTimeBuf, KDateTimeFormat ) ); + if ( KErrNone == err ) + { + CSELOGSTRING2_HIGH_LEVEL("Schedule end time: %S", &endTimeBuf); + } + + // Application UID + CSELOGSTRING2_HIGH_LEVEL("Schedule application uid: 0x%x", (unsigned)iAppUid); + + // Plugin UID + CSELOGSTRING2_HIGH_LEVEL("Schedule plugin uid: 0x%x", (unsigned)iPluginUid); + + // Application data + // Write only length of data + CSELOGSTRING2_HIGH_LEVEL("Schedule application data length: %d", iAppData->Length() ); + + // DB identifier + CSELOGSTRING2_HIGH_LEVEL("Schedule DB identifier: %x", iDbIdentifier); + + // Schedule type + switch(iScheduleType) + { + case ECseReminder: + CSELOGSTRING_HIGH_LEVEL("Schedule type: ECseReminder"); + break; + + case ECseRecording: + CSELOGSTRING_HIGH_LEVEL("Schedule type: ECseRecording"); + break; + + case ECseProgramGuideUpdate: + CSELOGSTRING_HIGH_LEVEL("Schedule type: ECseProgramGuideUpdate"); + break; + + case ECseScheduleDownload: + CSELOGSTRING_HIGH_LEVEL("Schedule type: ECseScheduleDownload"); + break; + + case ECseOther: + CSELOGSTRING_HIGH_LEVEL("Schedule type: ECseOther"); + break; + + default: + break; + } + delete writeBuff; + writeBuff = NULL; + + CSELOGSTRING_HIGH_LEVEL("<< // Header file for this class +#include // Represent one schedule in database +#include // Common defines for client and server +#include // Client common methods (server start up etc) +#include "CseDebug.h" // Debug macros +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ============================ MEMBER FUNCTIONS =============================== +// FUNCTION PROTOTYPES + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// CCseSchedulerApi::CCseSchedulerApi +// +// ----------------------------------------------------------------------------- +// +CCseSchedulerApi::CCseSchedulerApi() + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::CCseSchedulerApi"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::NewL"); + CCseSchedulerApi* self = new ( ELeave ) CCseSchedulerApi(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::ConstructL"); + User::LeaveIfError( iClient.Connect() ); + User::LeaveIfError( iService.Open( iClient ) ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::~CCseSchedulerApi"); + iService.Close(); + iClient.Close(); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::AddSchedule"); + TRAPD( err, iService.AddScheduleL( aData ) ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::RemoveSchedule"); + TRAPD( err, iService.RemoveScheduleL( aDbIdentifier ) ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerApi::GetSchedule"); + TRAPD( err, iService.GetScheduleL( aDbIdentifier, aProg ) ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::GetSchedulesByAppUid"); + TRAPD( err, iService.GetSchedulesL( aAppUid, aArray ) ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::GetSchedulesByPluginUid"); + TRAPD( err, iService.GetSchedulesByPluginUidL( aPluginUid, aArray ) ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::GetSchedulesByType"); + TRAPD( err, iService.GetSchedulesByTypeL( aType, aArray ) ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::GetSchedulesByTime"); + TRAPD( err, iService.GetSchedulesByTimeL( aBeginning, aEnd, aArray ) ); + CSELOGSTRING_HIGH_LEVEL("<<& aResultArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerApi::GetOverlappingSchedules"); + TRAPD( err, iService.GetOverlappingSchedulesL( aProgram, aResultArray ) ); + CSELOGSTRING_HIGH_LEVEL("<< // Header for this class +#include "CseDebug.h" // Debug macros +#include // Common defines for client and server +#include +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +const TUint KSchedulingDefaultMessageSlots( 4 ); +const TUint KSchedulingNumberOfServerStartupAttempts( 2 ); + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// LOCAL FUNCTION PROTOTYPES +static TInt StartServer(); +static TInt CreateServerProcess(); + +// FORWARD DECLARATIONS +// None + +// ============================= LOCAL FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// StartServer +// Returns: Error code +// ----------------------------------------------------------------------------- +// +static TInt StartServer() + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::StartServer"); + TFindServer findServer( KCseSchedulerServerName ); + TFullName name; + + // Server already running? + if ( !findServer.Next( name ) ) + { + return KErrNone; + } + + TInt result( CreateServerProcess() ); + + CSELOGSTRING2_HIGH_LEVEL("<<>>RCseSchedulerClient::CreateServerProcess"); + RProcess server; + TInt result( server.Create( KCseSchedulerServerFileName , _L( "" ) ) ); + + if ( result ) + { + return result; + } + + // Makes the server eligible for execution. + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + + server.Resume(); + + User::WaitForRequest(reqStatus); + + if( reqStatus.Int() != KErrNone ) + { + server.Close(); + } + + CSELOGSTRING2_HIGH_LEVEL("<<>>RCseSchedulerClient::RCseSchedulerClient"); + // None + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerClient::~RCseSchedulerClient"); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerClient::Connect"); + TInt ret( KErrNotFound ); + TInt retry( KSchedulingNumberOfServerStartupAttempts ); + do + { + // Start + ret = StartServer(); + if ( ret!=KErrNone && ret!=KErrAlreadyExists ) + { + return ret; + } + + // Subsession + ret = CreateSession( KCseSchedulerServerName, Version(), KSchedulingDefaultMessageSlots ); + if ( ret != KErrNotFound && ret != KErrServerTerminated ) + { + return ret; + } + + retry--; + } + while( retry >= 0 ); + + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerClient::Close"); + + TIpcArgs args( TIpcArgs::ENothing ); + SendReceive( ECseServCloseSession, args ); + + RHandleBase::Close(); + + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerClient::Version"); + + return( TVersion( KCseServMajorVersionNumber, + KCseServMinorVersionNumber, + KCseServBuildVersionNumber ) ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerClient/src/RCseSchedulerService.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerClient/src/RCseSchedulerService.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,659 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Scheduler engine client's Service* +*/ + + + + + +// INCLUDE FILES +#include // Header fo this class +#include // Represent one schedule in database +#include "CseDebug.h" // Debug macros +#include // Client common methods (server start up etc) +#include + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None. + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// RCseSchedulerService::RCseSchedulerService +// +// ----------------------------------------------------------------------------- +// +RCseSchedulerService::RCseSchedulerService() : RCseSchedulerServiceBase() + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::RCseSchedulerService"); + // None + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerService::~RCseSchedulerService"); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerService::AddScheduleL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + // First we to "externalize" (put CCseScheduledProgram-class content to array) + // information from given scheduled program. + HBufC8* msg = HBufC8::NewLC( aData.ExternalizeLength() ); + HBufC8* id = HBufC8::NewLC( 4 ); + TPtr8 ptr( msg->Des() ); + TPtr8 idPtr( id->Des() ); + + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( ptr ); + aData.ExternalizeL( writeStream ); + CleanupStack::PopAndDestroy( &writeStream ); + + TIpcArgs args( &ptr, &idPtr ); + + // Send array to server side. + User::LeaveIfError( SendReceive( ECseAddSchedule, args ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idPtr ); + aData.SetDbIdentifier( readStream.ReadUint32L() ); + CleanupStack::PopAndDestroy( &readStream ); + + CleanupStack::PopAndDestroy( id ); + CleanupStack::PopAndDestroy( msg ); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerService::RemoveScheduleL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Put integer value to stream + HBufC8* msg = HBufC8::NewL( 4 ); + CleanupStack::PushL( msg ); + TPtr8 ptr( msg->Des() ); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( ptr ); + writeStream.WriteUint32L( aDbIdentifier ); + CleanupStack::PopAndDestroy( &writeStream ); + + TIpcArgs args( &ptr ); + + // Send stream to server side + User::LeaveIfError( SendReceive( ECseRemoveSchedule, args ) ); + CleanupStack::PopAndDestroy( msg ); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerService::GetScheduleL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + if ( !aProg ) + { + User::Leave( KErrArgument ); + } + // Buffer for DbIdentifier + HBufC8* msgDbId = HBufC8::NewLC( 4 ); + TPtr8 dbIdPtr( msgDbId->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuff = HBufC8::NewLC( 4 ); + TPtr8 lengthPtr( lengthBuff->Des() ); + TInt length( 0 ); + + // Initialize DbIdentifier + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( dbIdPtr ); + writeStream.WriteUint32L( aDbIdentifier ); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &dbIdPtr, &lengthPtr ); + + // Ask for message length + User::LeaveIfError( SendReceive( ECseGetScheduleLength, args ) ); + + // Read length from the message + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthPtr ); + length = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Now ask for the scheduled program information + HBufC8* programBuffer = HBufC8::NewLC( length ); + TPtr8 programPtr( programBuffer->Des() ); + + TIpcArgs progArgs( &dbIdPtr, &programPtr ); + User::LeaveIfError( SendReceive( ECseGetSchedule, progArgs ) ); + + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( programPtr ); + aProg->InternalizeL( readStr ); + CleanupStack::PopAndDestroy( &readStr ); + + CleanupStack::PopAndDestroy( programBuffer ); + CleanupStack::PopAndDestroy( lengthBuff ); + CleanupStack::PopAndDestroy( msgDbId ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchdulesL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Buffer for app UID + HBufC8* msgAppUid = HBufC8::NewLC( 4 ); + TPtr8 appUidPtr( msgAppUid->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuff = HBufC8::NewLC( 4 ); + TPtr8 lengthPtr( lengthBuff->Des() ); + TInt length( 0 ); + + // Write App Uid + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( appUidPtr ); + writeStream.WriteInt32L( aAppUid ); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &appUidPtr, &lengthPtr ); + + // Ask for message length + User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByAppUid, args ) ); + + // Read length from the message + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthPtr ); + length = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Now ask for the scheduled program information + HBufC8* programBuffer = HBufC8::NewLC( length ); + TPtr8 programPtr( programBuffer->Des() ); + + TIpcArgs progArgs( &appUidPtr, &programPtr ); + User::LeaveIfError( SendReceive( ECseGetSchedulesByAppUid, progArgs ) ); + + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( programPtr ); + + // read number of items in stream + TInt itemCount ( 0 ); + itemCount = readStr.ReadInt32L(); + + // read all items from stream to array + for ( TInt i = 0; i < itemCount; i++ ) + { + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + prog->InternalizeL( readStr ); + aArray.AppendL( prog ); + CleanupStack::Pop( prog ); + } + + readStr.Close(); + + CleanupStack::PopAndDestroy( &readStr ); + CleanupStack::PopAndDestroy( programBuffer ); + CleanupStack::PopAndDestroy( lengthBuff ); + CleanupStack::PopAndDestroy( msgAppUid ); + CSELOGSTRING_HIGH_LEVEL("<<& aResultArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetOverlappingSchedulesL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Buffer for schedule data + HBufC8* schedData = HBufC8::NewLC( sizeof( TInt32 ) + // type + sizeof( TInt64 ) + // start time + sizeof( TInt64 ) ); // end time + TPtr8 schedDataPtr( schedData->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuf = HBufC8::NewLC( sizeof( TInt32 ) ); + TPtr8 lengthBufPtr( lengthBuf->Des() ); + TUint32 length( 0 ); + + // Schedule type + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( schedDataPtr ); + writeStream.WriteInt32L( aProgram.ScheduleType() ); + + // Start time + TInt64 temp( 0 ); + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Change TTime to stream format. + temp = aProgram.StartTime().Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + writeStream.WriteUint32L( lower ); + writeStream.WriteUint32L( upper ); + + // End time + temp = aProgram.EndTime().Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + writeStream.WriteUint32L( lower ); + writeStream.WriteUint32L( upper ); + + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &schedDataPtr, &lengthBufPtr ); + + // Ask for db id + User::LeaveIfError( SendReceive( ECseGetOverlappingSchedulesLength, args ) ); + + // Read length + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthBufPtr ); + length = readStream.ReadUint32L(); + CleanupStack::PopAndDestroy( &readStream ); + + if ( length > 0 ) + { + HBufC8* schedulesBuf = HBufC8::NewLC( length + + sizeof( TInt32 ) ); // item count as TInt32 + TPtr8 schedulesPtr( schedulesBuf->Des() ); + + TIpcArgs schedArgs( &schedDataPtr, &schedulesPtr ); + + User::LeaveIfError( SendReceive( ECseGetOverlappingSchedules, schedArgs ) ); + + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( schedulesPtr ); + // read item count + TInt32 count( readStr.ReadInt32L() ); + + // read all items from stream to array + for ( TInt i = 0; i < count; i++ ) + { + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + prog->InternalizeL( readStr ); + aResultArray.AppendL( prog ); + CleanupStack::Pop( prog ); + } + + readStr.Close(); + CleanupStack::PopAndDestroy( &readStr ); + CleanupStack::PopAndDestroy( schedulesBuf ); + } + + CleanupStack::PopAndDestroy( lengthBuf ); + CleanupStack::PopAndDestroy( schedData ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByPluginUidL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Buffer for app UID + HBufC8* msgPluginUid = HBufC8::NewLC( 4 ); + TPtr8 pluginUidPtr( msgPluginUid->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuff = HBufC8::NewLC( 4 ); + TPtr8 lengthPtr( lengthBuff->Des() ); + TInt length( 0 ); + + // Write App Uid + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( pluginUidPtr ); + writeStream.WriteInt32L( aPluginUid ); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &pluginUidPtr, &lengthPtr ); + + // Ask for message length + User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByPluginUid, args ) ); + + // Read length from the message + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthPtr ); + length = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Now ask for the scheduled program information + HBufC8* programBuffer = HBufC8::NewLC( length ); + TPtr8 programPtr( programBuffer->Des() ); + + TIpcArgs progArgs( &pluginUidPtr, &programPtr ); + User::LeaveIfError( SendReceive( ECseGetSchedulesByPluginUid, progArgs ) ); + + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( programPtr ); + + // read number of items in stream + TInt itemCount ( 0 ); + itemCount = readStr.ReadInt32L(); + + // read all items from stream to array + for ( TInt i = 0; i < itemCount; i++ ) + { + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + prog->InternalizeL( readStr ); + aArray.AppendL( prog ); + CleanupStack::Pop( prog ); + } + + readStr.Close(); + + CleanupStack::PopAndDestroy( &readStr ); + CleanupStack::PopAndDestroy( programBuffer ); + CleanupStack::PopAndDestroy( lengthBuff ); + CleanupStack::PopAndDestroy( msgPluginUid ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByTypeL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Buffer for app UID + HBufC8* msgScheduleType = HBufC8::NewLC( 4 ); + TPtr8 typePtr( msgScheduleType->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuff = HBufC8::NewLC( 4 ); + TPtr8 lengthPtr( lengthBuff->Des() ); + TInt length( 0 ); + + // Write App Uid + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( typePtr ); + writeStream.WriteInt32L( aType ); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &typePtr, &lengthPtr ); + + // Ask for message length + User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByType, args ) ); + + // Read length from the message + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthPtr ); + length = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Now ask for the scheduled program information + HBufC8* programBuffer = HBufC8::NewLC( length ); + TPtr8 programPtr( programBuffer->Des() ); + + TIpcArgs progArgs( &typePtr, &programPtr ); + User::LeaveIfError( SendReceive( ECseGetSchedulesByType, progArgs ) ); + + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( programPtr ); + + // read number of items in stream + TInt itemCount ( 0 ); + itemCount = readStr.ReadInt32L(); + + // read all items from stream to array + for ( TInt i = 0; i < itemCount; i++ ) + { + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + prog->InternalizeL( readStr ); + aArray.AppendL( prog ); + CleanupStack::Pop( prog ); + } + + readStr.Close(); + + CleanupStack::PopAndDestroy( &readStr ); + CleanupStack::PopAndDestroy( programBuffer ); + CleanupStack::PopAndDestroy( lengthBuff ); + CleanupStack::PopAndDestroy( msgScheduleType ); + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) const + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByTimeL"); + if ( !SubSessionHandle() ) + { + User::Leave( ECseNoSubsessionHandle ); + } + + // Buffer for schedule data + HBufC8* timeframe = HBufC8::NewLC( sizeof( TInt64 ) + // start time + sizeof( TInt64 ) ); // end time + + TPtr8 timeframePtr( timeframe->Des() ); + + // Buffer for incoming message length + HBufC8* lengthBuf = HBufC8::NewLC( sizeof( TInt32 ) ); + TPtr8 lengthBufPtr( lengthBuf->Des() ); + TUint32 length( 0 ); + + // Schedule type + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( timeframePtr ); + + // Start time + TInt64 temp( 0 ); + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Change TTime to stream format. + temp = aBeginning.Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + writeStream.WriteUint32L( lower ); + writeStream.WriteUint32L( upper ); + + // End time + temp = aEnd.Int64(); + lower = (0x00000000FFFFFFFFULL) & temp; + upper = (0x00000000FFFFFFFFULL) & (temp >> 32); + writeStream.WriteUint32L( lower ); + writeStream.WriteUint32L( upper ); + + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + // Set args for IPC + TIpcArgs args( &timeframePtr, &lengthBufPtr ); + + // Ask for db id + User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByTimeframe, args ) ); + + // Read length + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( lengthBufPtr ); + length = readStream.ReadUint32L(); + CleanupStack::PopAndDestroy( &readStream ); + + if ( length > 0 ) + { + HBufC8* schedulesBuf = HBufC8::NewLC( length + + sizeof( TInt32 ) ); // item count as TInt32 + TPtr8 schedulesPtr( schedulesBuf->Des() ); + + TIpcArgs schedArgs( &timeframePtr, &schedulesPtr ); + + User::LeaveIfError( SendReceive( ECseGetSchedulesByTimeframe, schedArgs ) ); + + RDesReadStream readStr; + CleanupClosePushL( readStr ); + readStr.Open( schedulesPtr ); + // read item count + TInt32 count( readStr.ReadInt32L() ); + + // read all items from stream to array + for ( TInt i = 0; i < count; i++ ) + { + // Internalize (change stream to CCseScheduledProgram-class) stream that we got. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + prog->InternalizeL( readStr ); + aArray.AppendL( prog ); + CleanupStack::Pop( prog ); + } + + readStr.Close(); + CleanupStack::PopAndDestroy( &readStr ); + CleanupStack::PopAndDestroy( schedulesBuf ); + } + + CleanupStack::PopAndDestroy( lengthBuf ); + CleanupStack::PopAndDestroy( timeframe ); + CSELOGSTRING_HIGH_LEVEL("<< // Client common methods (open, close etc) +#include // Client common methods (server start up etc) +#include "CseDebug.h" // Debug macros +#include // Common defines for client and server + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None. + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +// None. + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// RCseSchedulerServiceBase::RCseSchedulerServiceBase +// +// ----------------------------------------------------------------------------- +// +RCseSchedulerServiceBase::RCseSchedulerServiceBase() + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerServiceBase::RCseSchedulerServiceBase"); + CSELOGSTRING_HIGH_LEVEL("<<>>~RCseSchedulerServiceBase::~RCseSchedulerServiceBase"); + CSELOGSTRING_HIGH_LEVEL("<<<~RCseSchedulerServiceBase::~RCseSchedulerServiceBase"); + } + +// ----------------------------------------------------------------------------- +// RCseSchedulerServiceBase::Open +// +// ----------------------------------------------------------------------------- +// +TInt RCseSchedulerServiceBase::Open( RCseSchedulerClient& aClient ) + { + CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerServiceBase::Open"); + __ASSERT_ALWAYS( aClient.Handle(), PanicClient( KErrBadHandle ) ); + iClient = &aClient; + + TIpcArgs args( TIpcArgs::ENothing ); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerServiceBase::Close"); + RSubSessionBase::CloseSubSession( ECseServCloseSubSession ); + CSELOGSTRING_HIGH_LEVEL("<<>>RCseSchedulerServiceBase::PanicClient"); + _LIT( KCseRTPClientFault, "CseRTPApi Client Fault" ); + User::Panic( KCseRTPClientFault, aFault ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/data/102750D5.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/data/102750D5.rss Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +RESOURCE STARTUP_ITEM_INFO CseSchedulerServer +{ + executable_name = "!:\\sys\\bin\\CseSchedulerServer.exe"; + recovery = EStartupItemExPolicyNone; +} diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/group/ScheduleServer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/group/ScheduleServer.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Project definition file* +*/ + + + + +#include +#include + +//OPTION ARMCC --asm --interleave +ALWAYS_BUILD_AS_ARM + +TARGET cseschedulerserver.exe +#if !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__) +EPOCSTACKSIZE 0x10000 +#else +EPOCSTACKSIZE 0x5000 +#endif // !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__) + +targettype exe +UID 0x1000008c 0x102750D6 +VENDORID VID_DEFAULT +SECUREID 0x102750D6 +CAPABILITY CAP_SERVER -DRM -AllFiles + +SOURCEPATH ../src +SOURCE CCseSchedulerServer.cpp +SOURCE CCseScheduleDB.cpp +SOURCE CCseSchedulerTimer.cpp +SOURCE CCseSchedulerServerSession.cpp +SOURCE CCseSchedulerServerEngine.cpp +SOURCE CCseSchedulerPluginControllerBase.cpp +SOURCE CCseSchedulerUniPluginController.cpp +SOURCE CCseSchedulerMultiPluginController.cpp +SOURCE CCseSchedulerPluginStarter.cpp +SOURCE CCseSchedulerLandLord.cpp +SOURCE CCseSchedulerThreadPacket.cpp +SOURCE CCseSemaphoreController.cpp +SOURCEPATH ../data + +START RESOURCE 102750D5.rss +END // RESOURCE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY flogger.lib +LIBRARY edbms.lib +LIBRARY ws32.lib +LIBRARY apgrfx.lib +LIBRARY apparc.lib +LIBRARY estor.lib +LIBRARY cseschedulerclient.lib +LIBRARY ecom.lib diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../rom/videoschedulerserver.iby CORE_MW_LAYER_IBY_EXPORT_PATH(videoschedulerserver.iby) +PRJ_MMPFILES +ScheduleServer.mmp diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseScheduleDB.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseScheduleDB.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,447 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: header file for CCseScheduleDB class* +*/ + + + +#ifndef _CCSESCHEDULEDB_H +#define _CCSESCHEDULEDB_H + +#include +#include // RDbStoreDatabase +#include // RFs +#include +#include + +// CONSTANTS +const int KCseCustomSqlLength = 256; +const int KCseDbCompactTimeout = 30000000; + +// Constant for filename definition +_LIT( KCseScheduleDBName, "CseSchedules.db" ); +// Database table +_LIT( KCseDatabaseTable, "CseDatabase" ); +_LIT( KCseDatabaseVersionCol, "DbVersion" ); +_LIT( KCseDatabaseReserved1Col, "DbReserved1" ); +_LIT( KCseDatabaseReserved2Col, "DbReserved2" ); + +// Program table +_LIT( KCseScheduleTable, "ScheduleEvent" ); +_LIT( KCseScheduleDbKeyCol, "Key" ); +_LIT( KCseScheduleNameCol, "Name" ); +_LIT( KCseScheduleStartTimeCol, "StartTime" ); +_LIT( KCseScheduleEndTimeCol, "EndTime" ); +_LIT( KCseScheduleApplicationUIDCol, "ApplicationUID" ); +_LIT( KCseSchedulePlugInUIDCol, "PlugInUID" ); +_LIT( KCseScheduleTypeCol, "Type" ); +_LIT( KCseScheduleApplicationSpecificCol, "ApplicationSpecificData" ); +_LIT( KCseScheduleRunCountCol, "ScheduleRunCount" ); +_LIT( KCseScheduleStateCol, "ScheduleState" ); +_LIT( KCseSchedulePluginTypeCol, "PluginType" ); +_LIT( KCseScheduleReserved1Col, "ScheduleReserved1" ); +_LIT( KCseScheduleReserved2Col, "ScheduleReserved2" ); + +class CCseScheduledProgram; + +/** +* Version of CleanupXxxxPushL() that can be used to 'ResetAndDestroy' +* the supplied object if the clean-up stack unwinds. +*/ +template +class CleanupResetAndDestroy + { + public: + inline static void PushL( T& aRef ); + private: + static void ResetAndDestroy( TAny *aPtr ); + }; + +template + inline void CleanupResetAndDestroyPushL( T& aRef ); + +template +inline void CleanupResetAndDestroy::PushL( T& aRef ) + { + CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); + } + +template +void CleanupResetAndDestroy::ResetAndDestroy( TAny *aPtr ) + { + ( static_cast( aPtr ) )->ResetAndDestroy(); + } + +template +inline void CleanupResetAndDestroyPushL( T& aRef ) + { + CleanupResetAndDestroy::PushL( aRef ); + } + + +/** +* Schedule database. +*/ +class CCseScheduleDB : public CBase, + public MBackupObserver +{ + public: // Constructors and destructors + virtual ~CCseScheduleDB(); + + /** + * Two-phased constructor. + */ + IMPORT_C static CCseScheduleDB* NewL(); + + /** + * Enum for schedule state + */ + enum TCseScheduleState + { + ECseWaiting = 0, + ECseRunning + }; + + /** + * Enum for database access + */ + enum TCseDatabaseAccess + { + ECseDbOpen = 0, + ECseDbLocked + }; + + public: // Methods from MBackupObserver + void ChangeFileLockL(const TDesC &aFileName, TFileLockFlags aFlags); + + public: // New methods + /** + * Adds given schedule to database. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aData schedule to be added to database. + * @return None + */ + void AddScheduleL( CCseScheduledProgram& aData ); + + /** + * Removes schedule from database. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aData schedule to be removed from database. + * @return None + */ + void RemoveScheduleL( const TUint32 aDbIdentifier ); + + /** + * Finds start time of the schedule that is happening next from the database. + * Method will leave with KErrLocked -error code if Backup/Restore is going on. + * @return Start time of the next schedule. + */ + TTime GetNextScheduleTimeL(); + + /** + * Fills parameter array with schedules that have same starting time as + * paramter time. Method will leave with KErrLocked -error code if + * Backup/Restore is going on. + * @param aSchdeduleTime Start time of the schedules fetched. + * @param aNextScheduleArray Array containing schedules after call + * is completed. + * @return None + */ + void FillScheduleArrayByTimeL( const TTime& aScheduleTime, + RPointerArray& aNextScheduleArray ); + + /** + * Gets the given schedule from database. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aDbIdentifier Database identifier of the schedule fetched. + * @param aSchedule Pointer where schedule is stored when call + * is completed. + * @return None + */ + void GetScheduleByDbIdentifierL( const TUint32 aDbIdentifier, + CCseScheduledProgram* aSchedule ); + + /** + * Get application specific schedules from db. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aAppUid Application UID. + * @param aScheduleArray Array where to put scheduled events. + * @return None + */ + void GetApplicationSchedulesL( const TInt32 aAppUid, + RPointerArray& aArray ); + + /** + * Get overlapping schedules. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aType Schedule type (one from + * CCseScheduledProgram::TCseScheduleType) + * @param aStartTime Start time + * @param aEndTime End Time + * @param aResultArray On return, contains pointers to overlapping schedules + * empty if none found. + * @return None. + */ + void GetOverlappingSchedulesL( const TInt32 aType, + const TTime& aStartTime, + const TTime& aEndTime, + RPointerArray& aResultArray ); + + /** + * Increases runcount of given schedule in DB. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aDbIdentifier Database identifier of the schedule thats + * runcount is to be incremented + */ + void IncreaseRunCountL( const TUint32 aDbIdentifier ); + + /** + * Gets the runcount of give schedule. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aDbIdentifier DbIdentifier of the schedule whos runcount is fetched. + * @return Run count of the schedule. + */ + TInt32 GetRunCountL( const TUint32 aDbIdentifier ); + + /** + * Gets the state of give schedule. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aDbIdentifier DbIdentifier of the schedule whos state is fetched. + * @return Schedule state (one of the CCseScheduledDB::TCseScheduleState) + */ + TInt32 GetScheduleStateL( const TUint32 aDbIdentifier ); + + /** + * Sets the state of give schedule. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aDbIdentifier DbIdentifier of the schedule whos state is fetched. + * @param aState State to be set. + * @return None + */ + void SetScheduleStateL( const TUint32 aDbIdentifier, + const TInt32 aState ); + + /** + * Gets the startup schedules from the DB. When phone is set on, we try to run all + * schdeulus that were on run when the phone was set off (run count is bigger than 0). + * Method will leave with KErrLocked -error code if Backup/Restore is going on. + * @param aResultArray Array where schedules that were on run are stored. + * @return None + */ + void StartupSchedulesL( RPointerArray& aResultArray ); + + /** + * Get plugin specific schedules from db. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aPluginUid Application UID. + * @param aScheduleArray Array where to put scheduled events. + * @return None + */ + void GetSchedulesByPluginL( const TInt32 aPluginUid, + RPointerArray& aArray ); + + /** + * Get plugin specific schedules of specific type from db. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aType Schedule type + * @param aScheduleArray Array where to put scheduled events. + * @return None + */ + void GetSchedulesByTypeL( const TInt32 aType, + RPointerArray& aArray ); + + /** + * Get schedules in given timeframe. Method will leave with + * KErrLocked -error code if Backup/Restore is going on. + * @param aBeginning Start time of timeframe + * @param aEnd End Time of timeframe + * @param aResultArray On return, contains pointers to overlapping schedules + * empty if none found. + * @return None. + */ + void GetSchedulesByTimeframeL( const TTime& aStartTime, + const TTime& aEndTime, + RPointerArray& aResultArray ); + + /** + * Gets all the uid's of different plugins that are in DB. + * KErrLocked -error code if Backup/Restore is going on. + * @param aPlugins On return, contains all the different plugin uid's in + * db. Empty if none found. + */ + void GetPluginsL( RArray& aPlugins ); + + /** + * Get the next happening time of schedule from database based on plugin uid. + * KErrLocked -error code if Backup/Restore is going on. + * @param aPluginUid Plugin uid in which to base the search + * @return Next start time of the schedule of given plugin Uid. + */ + TTime GetNextScheduleTimeByPluginL( TInt32 aPluginUid ); + + /** + * Gets all the schedules that are going to happen at the given time based on plugin uid. + * KErrLocked -error code if Backup/Restore is going on. + * @param aScheduleTime Start time in which to base the search + * @param aPluginUid Plugin uid in which to base the search + * @param aNextScheduleArray On return, contains pointers to schedules. + */ + void GetSchedulesByTimeAndPluginL( + const TTime& aScheduleTime, + TInt32 aPluginUid, + RPointerArray& aNextScheduleArray ); + + + private: + /** + * C++ default constructor. + */ + CCseScheduleDB(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Methods + /** + * Checks the db version from db. If it is older than current one, destroy it + * and create new one. + * @return None + */ + void CheckDbVersionL(); + + /** + * Open DB or create new database if DB file is not found. + * @return None + */ + void OpenOrCreateDbL(); + + /** + * Create schedule table. + * @param aDatabase where to create schedule table. + * @return None + */ + void CreateScheduleTableL( RDbStoreDatabase& aDatabase ) const; + + /** + * Create database table. + * @param aDatabase where to create database table. + * @return None + */ + void CreateDatabaseTableL( RDbStoreDatabase& aDatabase ); + + /** + * Gets the database version number + * @param None + * @return None + */ + TInt GetDbVersionL( ); + + /** + * Set hardcoded database version to database. Used after creating new database. + * @param None + * @return None + */ + void SetDatabaseVersionL(); + + /** + * Removes existing database. + * @return None + */ + void RemoveDbL(); + + /** + * Static call back for CPeriodic. + * @param aThis Pointer to CCseScheduleDB so that we can + * direct call back to class. + * @return Always TFalse + */ + static TInt CompactCallback( TAny* aThis ); + + /** + * We want to compact database 30 seconds after last database operation. + * this resets 30 sec counter. + * @return None + */ + void ResetCompactTimer( ); + + /** + * Compacts database. + * @return None + */ + void CompactDb(); + + /** + * Closed Db file and sets iDbAccess to ECseDbLocked. + * @return None + */ + void CloseDbFile(); + + /** + * Closed Db file and sets iDbAccess to ECseDbOpen. + * @return None + */ + void OpenDbFileL(); + + /** + * Leaves with KErrLocked if iDbAccess is ECseDbLocked. + * @return None + */ + void LeaveIfDbLockedL() const; + + private: // Data + /** + * File server session is connected in construction and closed in + * destruction + */ + RFs iFsSession; + + /** + * File name of the database which to handle + */ + TFileName iDbFile; + + /** + * For database operations + */ + RDbStoreDatabase iScheduleDb; + + /** + * For creating and opening services database file. Own. + */ + CFileStore* iScheduleFileStore; + + /** + * Timer used in compacting database. Own. + */ + CPeriodic* iCompactTimer; + + /** + * SQL string for SQL calls + */ + TBuf iSqlSchedule; + + /** + * Status is database accessible + */ + TCseDatabaseAccess iDbAccess; + + /** + * Wrapper to get notification if backup/restore is + * about to happen. Own. + */ + CBaBackupSessionWrapper* iBackupWrapper; +}; +#endif _CCSESCHEDULEDB_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerLandLord.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerLandLord.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header file for CCseSchedulerThreadCrossroads-class.* +*/ + + + + +#ifndef _CCSESCHEDULERLANDLORD_H +#define _CCSESCHEDULERLANDLORD_H + +// INCLUDES +#include +#include "MCseSemaphoreSignalObserver.h" + +// CONSTANTS +#define KThreadNameSize 19 + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class MCseScheduleObserver; +class RThread; +class CCseScheduledProgram; +class CCseSchedulerThreadPacket; +class CCseSemaphoreController; +class CActiveSchedulerWait; + +/** +* LandLord controlling shared data that is given to thread. After plugin thread is started, +* nothing should be accessed before thread has died. +* +* Also observes thread when it dies. +*/ +class CCseSchedulerLandLord : public CActive, + public MCseSemaphoreSignalObserver + +{ + public: // Constructors and destructors + /** + * Destructor. + */ + virtual ~CCseSchedulerLandLord(); + + /** + * Two-phased constructor. + * @param aObserver A pointer back to plugin controller. + */ + static CCseSchedulerLandLord* NewL( MCseScheduleObserver* aObserver ); + + private: // Constructors and destructors + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aObserver A pointer back to plugin controller. + */ + CCseSchedulerLandLord( MCseScheduleObserver* aObserver ); + + public: + /** + * Set schedule to LandLord. + * @param aData CCseScheduledProgram to be set. + */ + void SetScheduleL( CCseScheduledProgram& aData ); + + /** + * Returns ThreadPacket of the LandLord + * @return pointer to ThreadPacket + */ + CCseSchedulerThreadPacket* ThreadPacket( ); + + /** + * Run plugin. Creates thread where the CCseSchedulerPluginStarter is run + * and sets itself observing when thread dies. + */ + void RunPluginL( ); + + /** + * Clears landlord. Uses semaphore to signal plugin thread that thread needs + * to be taken down. + * Synchronous. + */ + void ClearL(); + + /** + * Returns ETrue if LandLord is working (plugin is running). + */ + TBool IsWorking(); + + private: // CActive + /** + * RunL + * @return None + */ + void RunL(); + + /** + * RunError + * @return + */ + TInt RunError( TInt aError ); + + /** + * DoCancel + * @return None + */ + void DoCancel(); + + private: // from MCseSemaphoreSignalObserver + void SemaphoreSignalled( ); + + private: // New methods + /** + * Generates unique thread name to internal iThreadName-buffer. + */ + void GenerateThreadNameL(); + + /** + * Generates semaphores to signal thread shutdown and when shutdown + * is completed. + */ + void GenerateSemaphoresL( ); + + /** + * Starts or stops active wait. Used when thread needs to be taken down. + */ + void ActiveWait( TBool aStart ); + + private: // Data + /** + * Pointer back to plugin controller. Own. + */ + MCseScheduleObserver* iObserver; + + /** + * ThreadPacket. Contains data to be given plugin thread when run. Own. + */ + CCseSchedulerThreadPacket* iThreadPacket; + + /** + * Thread where plugin is run. + */ + RThread iThread; + + /** + * Unique thread name. Own. + */ + HBufC* iThreadName; + + /** + * ETrue if thread is running, EFalse if not. + */ + TBool iThreadRunning; + + /** + * Semaphore signalled when plugin is wanted to take down. + */ + RSemaphore iPluginShutdownSemaphore; + + /** + * Semaphore signalled when plugin has been taken down. + */ + RSemaphore iPluginShutdownCompleteSemaphore; + + /** + * ActiveSchedulerWait. Own. + */ + CActiveSchedulerWait* iActiveSchedulerWait; + + /** + * Checks once a while if plugin shutdown has been completed. + * Own. + */ + CCseSemaphoreController* iShutdownCompleteMonitor; + + /** + * ETrue if shutdown has been signalled to CCSeSchedulerPluginStarter. + * EFalse if not. + */ + TBool iTakedownRequested; +}; + +#endif //_CCSESCHEDULERLANDLORD_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerMultiPluginController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerMultiPluginController.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header for MultiPluginController-class* +*/ + + + + +#ifndef __CCSESCHEDULERMULTIPLUGINCONTROLLER_H +#define __CCSESCHEDULERMULTIPLUGINCONTROLLER_H + +// INCLUDES +#include "CCseSchedulerPluginControllerBase.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +class CCseSchedulerPluginStarter; +class CCseSchedulerLandLord; + +/** +* Controller for plugins that can be several in run at same time +*/ +class CCseSchedulerMultiPluginController : public CCseSchedulerPluginControllerBase + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * @params aEngine reference to engine + * @params aPluginUid plugin uid of the plugin this plugin controller is made for + * @return CCseSchedulerPluginControllerBase pointer to CCseSchedulerPluginControllerBase class + */ + static CCseSchedulerMultiPluginController* NewL( CCseSchedulerServerEngine& aEngine, TInt32 aPluginUid ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerMultiPluginController(); + + public: // from CCseSchedulerPluginControllerBase + void ClearControllerL(); + + TBool IsControllerActive(); + + void RunPluginsL() ; + + void DoCleanUp() ; + + void ScheduleCompletedL( const TUint32 aDbIdentifier, TInt aCompletitionCode ); + + private: // Constructors and destructor + /** + * C++ default constructor. + */ + CCseSchedulerMultiPluginController( CCseSchedulerServerEngine& aEngine, TInt32 aPluginUid ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // New methods + /** + * Handles succesfully completed schedules. + * @param aDbIdentifier DbIdentifier of schedule just completed + */ + void ScheduleCompletedSuccesfullyL( const TUint32 aDbIdentifier ); + + /** + * Handles failed schedules. + * @param aDbIdentifier DbIdentifier of schedule just completed + * @param aCompletitionCode Error code of the completed schedule. + */ + void HandleScheduleErrorL( const TUint32 aDbIdentifier, + TUint32 aCompletitionCode ); + private: // Data + + /** + * LandLords. Owns data that is given to new thread and acts as observer to thread. + * Own. + */ + RPointerArray iLandLords; + }; + +#endif // __CCSESCHEDULERMULTIPLUGINCONTROLLER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerPluginControllerBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerPluginControllerBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,185 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header for PluginControllerBase-class* +*/ + + + + +#ifndef __CCSESCHEDULERPLUGINCONTROLLERBASE_H +#define __CCSESCHEDULERPLUGINCONTROLLERBASE_H + +// INCLUDES +#include +#include +#include +#include "MCseSchedulerTimerObserver.h" +#include "MCsePluginControllerObserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +class CCseScheduledProgram; +class CCseSchedulerTimer; +class CCseSchedulerServerEngine; + +/** +* Base class for plugin controllers. Handles all plugin related stuff except scheduling logic. +*/ +class CCseSchedulerPluginControllerBase : public CBase, + public MCseScheduleObserver, + public MCseSchedulerTimerObserver + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * @params aEngine reference to engine + * @params aPluginUid plugin uid of the plugin this plugin controller is made for + * @return CCseSchedulerPluginControllerBase pointer to CCseSchedulerPluginControllerBase class + */ + static CCseSchedulerPluginControllerBase* NewL( MCsePluginControllerObserver& aEngine, TInt32 aPluginUid ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerPluginControllerBase(); + + protected: + /** + * C++ default constructor. + */ + CCseSchedulerPluginControllerBase( MCsePluginControllerObserver& aEngine, TInt32 aPluginUid ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + public: // from MCseScheduleObserver-class + /** + * Plugins uses this method to inform common scheduler engine that + * schedule is handled. + * @param aDbIdentifier DbIdentifier of scheduled program that just + * has been processed. + */ + virtual void ScheduleCompletedL( const TUint32 aDbIdentifier, TInt aCompletitionCode ); + + public: // from MCseSchedulerTimerObserver-class + /** + * Plugins uses this method to inform common scheduler engine that + * schedule is handled. + * @param aDbIdentifier DbIdentifier of scheduled program that just + * has been processed. + */ + virtual void TimerErrorL( const TInt32 aError ); + + /** + * Timer is up, run the Plugins!!! + */ + virtual void RunPluginsL( ); + + public: // New methods + + /** + * Sets plugin to be cleared after callstack break. + * @param aToBeCleared ETrue if controller needs to be cleared. + */ + void SetToBeCleared( TBool aToBeCleared ); + + /** + * Clears controller: clears (takes down all threads running for the plugin) + * all landlords. + */ + virtual void ClearControllerL(); + + /** + * Cleans the controller from LandLord(s) that aren't needed anymore. + */ + virtual void DoCleanUp( ); + + /** + * Sets schedules to controller. More precise information is found from Uni and Multi + * controller classes. + * @params aScheduleArrat Array of schedules to be set into controller. All given + * schedules should have same start time. + */ + virtual void SetSchedulesL( RPointerArray& aScheduleArray ); + + /** + * Gets plugin id. This Uid of the plugin going to be run when time is right. Can be + * used, for example, to find right kind of controller to a schedule. + * @return plugin Uid of the plugin used to run the schedule. + */ + TInt32 PluginUid( ); + + /** + * Checks if the plugin is obsolete (There are no more schedules to be run). + * @return ETrue if obsolete, EFalse if not. + */ + TBool IsObsolete() const; + + /** + * Checks if the plugin is set to be cleared. + * @return ETrue if set, EFalse if not. + */ + TBool IsToBeCleared(); + + /** + * Checks if there are active plugins in controller. + * @return ETrue if active plugins found, EFalse otherwise + */ + virtual TBool IsControllerActive(); + + protected: //data + /** + * Array containing schedules to be run. Own. + */ + RPointerArray iScheduleArray; + + /** + * Timer class. Own. + */ + CCseSchedulerTimer* iTimer; + + /** + * Reference to engine + */ + MCsePluginControllerObserver& iEngine; + + /** + * Uid of the plugin contrelled by this controller. + */ + TInt32 iPluginUid; + + /** + * Boolean indicating if this plugin controller is to cleared + * (plugin running is deleted). + */ + TBool iToBeCleared; + }; + +#endif // __CCSESCHEDULERPLUGINCONTROLLERBASE_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerPluginStarter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerPluginStarter.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header for PluginStarter-class* +*/ + + + +#ifndef __CCSESCHEDULERPLUGINSTARTER_H +#define __CCSESCHEDULERPLUGINSTARTER_H + +// INCLUDES +#include +#include +#include "MCseSemaphoreSignalObserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +class CCseSchedulerThreadPacket; +class CCseSchedulerPluginIF; +class CCseSchedulerLandLord; +class CCseSemaphoreController; + +/** +* Handles running and shutting down one plugin. Runs in seperate thread than rest of the SchedulerEngine +*/ +class CCseSchedulerPluginStarter : public CBase, + public MCseSemaphoreSignalObserver, + public MCsePluginObserver + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * @param aThreadPacket Thread packet containing all the needed information to plugin + * to be run. + * @return CCseSchedulerPluginStarter pointer to CCseSchedulerPluginStarter class + */ + static CCseSchedulerPluginStarter* NewL( CCseSchedulerThreadPacket* aThreadPacket ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerPluginStarter(); + + public: // from MCsePluginObserver-class + void PluginCompleted( TInt aCompletitionValue ); + + public: // from MCseSemaphoreSignalObserver-class + void SemaphoreSignalled( ); + + public: // New methods + /** + * Creates plugin and runs schedule in it. + * @param aParam Any pointer that actually holds CCseThreadPacket + * @return KErrNone if succesful, otherwise common Symbian error codes. + */ + static TInt StartThread( TAny* aParam ); + + private: // Constructors and destructor + /** + * C++ default constructor. + */ + CCseSchedulerPluginStarter( CCseSchedulerThreadPacket* aThreadPacket ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // New methods + /** + * Called from actual StartThread. Creates CCseSchedulerPluginStarter. + * @param aParam Any pointer that actually holds CCseThreadPacket + */ + static void DoStartThreadL( TAny* aParam ); + + /** + * Creates plugin based on schedule and runs schedule in it. + */ + void RunPluginL( ); + + /** + * Plugin complete callback used with CIdle. Used to break call stack. + * @param aPtr Pointer back to CCseSchedulerPluginStarter-class + * @return Always EFalse. + */ + static TInt PluginCompleteCallback( TAny* aPtr ); + + /** + * Plugin complete callback handler. Stops active scheduler, sets completition value + * and runs down the plugin. + * @return Always EFalse + */ + TInt HandlePluginCompleteCallback(); + + private: // Data + /** + * Thread packet. Includes all needed information for plugin and the completiotion value. + * Own. + */ + CCseSchedulerThreadPacket* iThreadPacket; + + /** + * Plugin in run. Own. + */ + CCseSchedulerPluginIF* iPlugin; + + /** + * CIdle, used to break call stack when plugin completes. Own. + */ + CIdle* iCompletitionBreaker; + + /** + * Bool flagging if plugin is wanted to be shot down + */ + TBool iPluginRdyToTakedown; + + /** + * Semaphore monitor. Check once a while if shutdown semaphore is signalled. + */ + CCseSemaphoreController* iSemaphoreMonitor; + }; + +#endif // __CCSESCHEDULERPLUGINSTARTER_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerServer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header for Scheduler Server class* +*/ + + + + +#ifndef __CCSESCHEDULERSERVER_H +#define __CCSESCHEDULERSERVER_H + +// INCLUDES +#include +#include "CseSchedulerServer.pan" // Panic codes + +// CONSTANTS +#define KCseSchedulerMinHeapSize 2*KMinHeapSize +#define KCseSchedulerMaxHeapSize 0x1F0000 + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CCseSchedulerServerEngine; + +// CLASS DECLARATION +/** +* Server class +* +* @lib CseSchedulerServer.exe +*/ +class CCseSchedulerServer : public CPolicyServer + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CCseSchedulerServer* NewLC( ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerServer(); + + public: // New functions + + /** + * Thread function, creates cleanup stack for the thread. + * @return KErrNone + */ + static TInt ThreadFunction( ); + + /** + * Thread function, the active scheduler is installed and started. + * @return None. + */ + static void ThreadFunctionL( ); + + /** + * Panics server. + * @param aPanic panic code. + * @return None. + */ + static void PanicServer( TCseSchedulerServPanic aPanic ); + + /** + * Starts the server thread. + * @return None. + */ + static TInt StartThread(); + + /** + * Dec + * @return None. + */ + void Dec(); + + /** + * Inc + * @return None. + */ + void Inc(); + + /** + * Create new Session. + * @param aVersion server version number. + * @return CSharableSession pointer to new created session. + */ + CSession2* NewSessionL( const TVersion &aVersion, + const RMessage2& aMessage ) const; + + /** + * Gets engine object. + * @return CCseSchedulerServerEngine pointer. + */ + CCseSchedulerServerEngine* GetEngineObjectL(); + + /** + * Makes check if server is still needed (has schedules on run or active + * client), if not calls ActiveScheduler::Stop resulting server shutdown. + */ + void StopServer(); + + protected: // Functions from base classes + + /** + * From CPolicyServer, called by framework to perform + * custom security check for any client messages. + * + * @param aMsg Message. + * @param aAction Action. + * @param aMissing Security info. + * @return Result of security check. + */ + TCustomResult CustomSecurityCheckL( const RMessage2 &aMsg, TInt &aAction, TSecurityInfo &aMissing ); + + /** + * Starter callback used with CIdle. Used to break call stack. + * @param aPtr Pointer back to CCseSchedulerUserInformer-class + * @return Always EFalse. + */ + static TInt StarterCallback( TAny* aPtr ); + + /** + * Starter callback handler. Checks if server is actually needed (there + * is client or schedules to be run). If engine is not needed, signals + * server to be deleted. + * @return Always EFalse + */ + TInt HandleStarterCallback(); + + + private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCseSchedulerServer(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( ); + + private: // New functions + + /** + * Deletes scheduler engine. + * @return None. + */ + void DeleteSchedulerEngine(); + + + private: // Data + /** + * Object container index. Own. + */ + CObjectConIx* iContainerIx; + + /** + * Object container. Own. + */ + CObjectCon* iObjectCon; + + /** + * Number of sessions + */ + TInt iSessionCount; + + /** + * Engine object. Own. + */ + CCseSchedulerServerEngine* iSchedulerEngine; + + /** + * CIdle, used to break call stack when scheduler is started. Own. + */ + CPeriodic* iStarterBreaker; + }; + +#endif // __CCSESCHEDULERSERVER_H + +// End of File \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerServerEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerServerEngine.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,328 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Scheduler Server's Engine class* +*/ + + + + +#ifndef __CCSESCHEDULERSERVERENGINE_H +#define __CCSESCHEDULERSERVERENGINE_H + +// INCLUDES +#include // Observer so that CCseSchedulerTimer can inform engine. +#include "MCsePluginControllerObserver.h" // Observer so that CCseSchedulerTimer can inform engine. +#include "CseSchedulerServer.pan" // Panic codes + + +// CONSTANTS +// Usually we have only one scheduled event at a time so we set granularity to 1, but +// in some rare cases we migth have more so we have to use array. +const int KCseScheduleGranularity = 1; + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CCseScheduleDB; +class CCseSchedulerTimer; +class CCseScheduledProgram; +class CCseSchedulerServerSession; +class CCseSchedulerServer; +class CCseSchedulerPluginControllerBase; + + +// CLASS DECLARATION +// None + +/** +* Server's "brain". Controls all subsession messages to current object for +* futher prosessing. Manages message list thru the reguest handler. Reads from +* the client address space and writes back to client address space. Controls +* sub objet request(s). +*/ +class CCseSchedulerServerEngine : public CObject, + public MCsePluginControllerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param Reference to scheduler server + * @return CCseSchedulerEngine pointer to CCseSchedulerEngine class + */ + static CCseSchedulerServerEngine* NewL( CCseSchedulerServer& aServer ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerServerEngine(); + + public: // From MCsePluginControllerObserver + + void ScheduleCompletedSuccesfullyL( const TUint32 aDbIdentifier ); + + void ScheduleCompletedWithErrorL( const TUint32 aDbIdentifier, TUint32 aCompletionCode ); + + void IncreaseScheduleRunCountL( const TUint32 aDbIdentifier ); + + TBool IsAllowedToRun( TUint32 aDbIdentifier ); + + void ScheduleNotValid( const TUint32 aDbIdentifier ); + + void RequestReschedule( ); + + void ClearingDone(); + + public: // New methods + /** + * Plugin complete callback used with CIdle. Used to break call stack. + * @param aPtr Pointer back to CCseSchedulerUserInformer-class + * @return Always EFalse. + */ + static TInt CompletitionCallback( TAny* aPtr ); + + /** + * Schedule complete callback handler. Removes schedule from "on run list", + * informs engine that schedule has comlete and checks if the plugin where + * schedule was run still needed. + * @return Always EFalse + */ + TInt HandleCompletitionCallback(); + + /** + * Cleaner callback used with CIdle. Used to break call stack. + * @param aPtr Pointer back to CCseSchedulerUserInformer-class + * @return Always EFalse. + */ + static TInt CleanerCallback( TAny* aPtr ); + + /** + * Cleaner callback handler. Goes through all plugin contollers and clears them + * (shutdowns all threads running plugins). + * @return Always EFalse + */ + TInt HandleCleanerCallback(); + + public: // From CObject + /** + * Overwrites CObjects Close. Sets the AccesCount to zero. + * @return None + */ + void Close(); + + public: // New functions + + /** + * Does the general message handling. + * @param aMessage contains data from the client. + * @return None. + */ + void GeneralServiceL( const RMessage2& aMessage ); + + /** + * Service cancellation. + * @param aMessage contains data from the client. + * @return None. + */ + void CancelService( const RMessage2& aMessage ); + + /** + * Checks if scheduler is active atm (schedules in run or waitint) + * @return ETrue if active and EFalse if not. + */ + TBool IsSchedulerActive() const; + + /** + * Reschedules engine (get new "next schedule" from database and + * resets timer). + * @return None. + */ + void RescheduleL(); + + /** + * Reschedules engine (get new "next schedule" from database and + * resets timer). + * @return None. + */ + void RescheduleByPluginL( TInt32 aPluginUid ); + + private: // Constructors and destructor + + /** + * C++ default constructor. + * @param Reference to scheduler server. + */ + CCseSchedulerServerEngine( CCseSchedulerServer& aServer ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + + private: // New functions + /** + * Panic the client on server side. + * @param aPanic Our panic code. + * @param aMessage A message from client + * @return None. + */ + void PanicClient( TCseSchedulerServPanic aPanic, + const RMessage2& aMessage ) const; + + /** + * Adds schedule to database + * @param aMessage A message from client + * @return None. + */ + void AddScheduleL( const RMessage2& aMessage ); + + /** + * Removes schedule from database + * @param aMessage A message from client + * @return None. + */ + void RemoveScheduleL( const RMessage2& aMessage ); + + /** + * Gets all schedules from database + * @param aMessage A message from client + * @return None. + */ + void GetSchedulesL( const RMessage2& aMessage ); + + /** + * Adds schedule to database + * @param aMessage A message from client + * @return None. + */ + void GetScheduleL( const RMessage2& aMessage ); + + /** + * Gets externalize length of one specific schedule + * @param aMessage A message from client + * @return None. + */ + void GetScheduleLengthL( const RMessage2& aMessage ); + + /** + * Gets schedules based on application UID. + * @param aMessage A message from client + * @return None. + */ + void GetSchedulesByAppUidL( const RMessage2& aMessage ); + + /** + * Gets externalize length of the schedules of one application UID + * @param aMessage A message from client + * @return None. + */ + void GetScheduleArrayLengthByAppUidL( const RMessage2& aMessage ); + + /** + * Gets externalize length of the overlapping schedules + * @param aMessage A message from client + * @return None. + */ + void GetOverlappingSchedulesLengthL( const RMessage2& aMessage ); + + /** + * Gets overlapping schedules of given timeframe + * @param aMessage A message from client + * @return None. + */ + void GetOverlappingSchedulesL( const RMessage2& aMessage ); + + /** + * Gets startup schedules from database (schedules that were on run when + * phone was shut down) + * @return None. + */ + void EngineSchedulesStartup(); + + /** + * Gets externalize length of the schedules of one plugin UID + * @param aMessage A message from client + * @return None. + */ + void GetScheduleArrayLengthByPluginUidL( const RMessage2& aMessage ); + + /** + * Gets schedules based on plugin UID. + * @param aMessage A message from client + * @return None. + */ + void GetSchedulesByPluginUidL( const RMessage2& aMessage ); + + /** + * Gets externalize length of the schedules of one type. + * @param aMessage A message from client + * @return None. + */ + void GetScheduleArrayLengthByTypeL( const RMessage2& aMessage ); + + /** + * Gets schedules based on schedule type. + * @param aMessage A message from client + * @return None. + */ + void GetSchedulesByTypeL( const RMessage2& aMessage ); + + /** + * Gets externalize length of the schedules of specific timeframe. + * @param aMessage A message from client + * @return None. + */ + void GetScheduleArrayLengthByTimeframeL( const RMessage2& aMessage ); + + /** + * Gets schedules between given timeframe. + * @param aMessage A message from client + * @return None. + */ + void GetSchedulesByTimeframeL( const RMessage2& aMessage ); + + private: // Data + /** + * DB class. Own. + */ + CCseScheduleDB* iDb; + + /** + * Array holding all plugin controllers. + */ + RPointerArray iPluginControllerArray; + + /** + * CIdle, used to break call stack when schedule completes. Own. + */ + CIdle* iCompletitionBreaker; + + /** + * Reference to scheduler server + */ + CCseSchedulerServer& iServer; + }; + +#endif // __CCSESCHEDULERSERVERENGINE_H + +// End of file + diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerServerSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerServerSession.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Scheduler Server's Session class* +*/ + + + + +#ifndef __CCSESCHEDULERSERVERSESSION_H +#define __CCSESCHEDULERSERVERSESSION_H + +// INCLUDES +#include +#include "CseSchedulerServer.pan" // Panic codes + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +class CCseSchedulerEngine; +class CCseSchedulerServer; + +// CLASS DECLARATION + +/** +* CCseSchedulerSession +* +* @lib +*/ +class CCseSchedulerServerSession : public CSession2 + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + * @Param aClient reference client thread + * @Param aServer pointer to Server + * @return CCseSchedulerSession pointer to CCseSchedulerSession class + */ + static CCseSchedulerServerSession* NewL( CCseSchedulerServer* aServer ); + + + /** + * Destructor. + */ + virtual ~CCseSchedulerServerSession(); + + public: // New functions + + /** + * Server + * @return a pointer to server + */ + CCseSchedulerServer* Server(); + + /** + * Service + * @param aMessage contains data from the client. + * @return None + */ + void ServiceL( const RMessage2& aMessage ); + + private: // New functions + + /** + * Dispatch message + * @param aMessage contains data from the client. + * @return None + */ + void DispatchMessageL( const RMessage2& aMessage ); + + /** + * New Object + * @param aMessage contains data from the client. + * @return None + */ + void NewObjectL( const RMessage2& aMessage ); + + /** + * Deletes object, can't fail - can panic client + * @param aHandle handle + * @return None + */ + void DeleteObject( TUint aHandle ); + + /** + * Counts resources + * @return Number of resources + */ + TInt CountResources(); + + /** + * Panics client + * @param aPanic panic code + * @return None + */ + void PanicClient( TCseSchedulerServPanic aPanic ) const; + + private: // Constructors and destructor + + /** + * C++ default constructor. + * @Param aClient reference client thread + */ + CCseSchedulerServerSession(); + + /** + * Symbian 2nd phase constructor. + * @Param aServer pointer to Server + */ + void ConstructL( CCseSchedulerServer* aServer ); + + private: // Data + + /** + * Object index for this session. Own. + */ + CObjectIx* iObjects; + + /** + * Total number of resources allocated + */ + TInt iResourceCount; + + }; + +#endif // __CCSESCHEDULERSERVERSESSION_H + diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerThreadPacket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerThreadPacket.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header file for CCseSchedulerThreadPacket-class.* +*/ + + + +#ifndef _CCSESCHEDULERTHREADPACKET_H +#define _CCSESCHEDULERTHREADPACKET_H + +// INCLUDES +#include + +// CONSTANTS +// None +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CCseScheduledProgram; + +/** +* Class holding CCseScheduledProgram and ThreadResultCode. This is given to +* separate plugin thread and should not be accessed before thread dies. +*/ +class CCseSchedulerThreadPacket : public CBase +{ + public: // Constructors and destructors + /** + * Destructor. + */ + virtual ~CCseSchedulerThreadPacket(); + + /** + * Two-phased constructor. + * @param aObserver A pointer back to server engine through observer + */ + static CCseSchedulerThreadPacket* NewL( ); + + private: // Constructors and destructors + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aObserver A pointer back to server engine through observer. + */ + CCseSchedulerThreadPacket( ); + + public: // New methods + /** + * Sets schedule to thread packet. Overwrites existing one. + * @param aData Scheduled program to be set + */ + void SetScheduleL( CCseScheduledProgram& aData ); + + /** + * Gets schedule from thread packet. + * @return Pointer to scheduled program. + */ + CCseScheduledProgram* Schedule( ); + + /** + * Sets threads result code. Should be set before thread completes. + * Defaults to KErrGeneral. + * @param aResultCode New result code. Overwrites existing one. + */ + void SetResultCode( TInt32 aResultCode); + + /** + * Gets threads result code. + * @return Threads result code. Defaulted to KErrGeneral if not set. + */ + TInt32 ResultCode( ); + + /** + * Sets semaphore used to signal plugin shutdown request. + * @param aSemaphore Semaphore used to signal shutdown + */ + void SetShutdownSemaphore( RSemaphore& aSemaphore ); + + /** + * Sets semaphore used to signal when plugin shutdown has completed. + * @param aSemaphore Semaphore used to signal shutdown + */ + void SetShutdownCompleteSemaphore( RSemaphore& aSemaphore ); + + /** + * Gets semaphore used to signal plugin shutdown request. + * @return RSemaphore Semaphore used to signal plugin shutdown request. + */ + RSemaphore& ShutdownSemaphore(); + + /** + * Gets semaphore used to signal when plugin shutdown has completed. + * @return RSemaphore Semaphore used to signal when plugin shutdown has completed. + */ + RSemaphore& ShutdownCompleteSemaphore(); + + private: // Data + /** + * Scheduled program to be run in the plugin thread. Own. + */ + CCseScheduledProgram* iSchedule; + + /** + * Plugin completition code after the thread dies. + */ + TInt32 iResultCode; + + /** + * Semaphore signalled when plugin shutdown is wanted while plugin is running. + */ + RSemaphore iShutdownSemaphore; + + /** + * Semaphore signalled when plugin shutdown is completed. + */ + RSemaphore iShutdownCompleteSemaphore; +}; + +#endif //_CCSESCHEDULERTHREADPACKET_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerTimer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header file for CCSeSchdulerTimer-class.* +*/ + + + + +#ifndef _CCSESCHEDULERTIMER_H +#define _CCSESCHEDULERTIMER_H + +// INCLUDES +#include + +// CONSTANTS +// None +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class MCseSchedulerTimerObserver; +class CCseSchedulerPluginIF; + +/** +* Timer for determining when schedules should be run. +*/ +class CCseSchedulerTimer : public CTimer +{ + public: // Constructors and destructors + /** + * Destructor. + */ + virtual ~CCseSchedulerTimer(); + + /** + * Two-phased constructor. + * @param aObserver A pointer back to server engine through observer + */ + static CCseSchedulerTimer* NewL( MCseSchedulerTimerObserver* aObserver ); + + public: // New methods + /** + * Sets timer to fire on given time + * @param aTime Time when timer is set to fire + * @return None + */ + void SetTimer( const TTime& aTime ); + + private: // Constructors and destructors + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aObserver A pointer back to server engine through observer. + */ + CCseSchedulerTimer( MCseSchedulerTimerObserver* aObserver ); + + private: // Functions from base classes + /** + * RunL + * @return None + */ + void RunL(); + + /** + * RunError + * @return See CTimer documentation. + */ + TInt RunError( TInt aError ); + + /** + * DoCancel + * @return None + */ + void DoCancel(); + + private: // Data + /** + * Pointer back to scheduler engine. Not own. + */ + MCseSchedulerTimerObserver* iObserver; +}; + +#endif //_CCSESCHEDULERTIMER_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSchedulerUniPluginController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSchedulerUniPluginController.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header for UniPluginController-class* +*/ + + + + +#ifndef __CCSESCHEDULERUNIPLUGINCONTROLLER_H +#define __CCSESCHEDULERUNIPLUGINCONTROLLER_H + +// INCLUDES +#include "CCseSchedulerPluginControllerBase.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +class CCseSchedulerPluginStarter; +class CCseSchedulerLandLord; + +/** +* Controller for plugins that can be only be in run one at the time +*/ +class CCseSchedulerUniPluginController : public CCseSchedulerPluginControllerBase + { + public: // Constructors and destructor + /** + * Two-phased constructor. + * @params aEngine reference to engine + * @params aPluginUid plugin uid of the plugin this plugin controller is made for + * @return CCseSchedulerPluginControllerBase pointer to CCseSchedulerPluginControllerBase class + */ + static CCseSchedulerUniPluginController* NewL( CCseSchedulerServerEngine& aEngine, TInt32 aPluginUid ); + + /** + * Destructor. + */ + virtual ~CCseSchedulerUniPluginController(); + + + public: // from CCseSchedulerPluginControllerBase + + void ClearControllerL(); + + TBool IsControllerActive(); + + void RunPluginsL() ; + + void SetSchedulesL( RPointerArray& aScheduleArray ); + + void ScheduleCompletedL( const TUint32 aDbIdentifier, TInt aCompletitionCode ); + + void TimerErrorL( const TInt32 aError ); + + private: // Constructors and destructor + /** + * C++ default constructor. + */ + CCseSchedulerUniPluginController( CCseSchedulerServerEngine& aEngine, TInt32 aPluginUid ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // New methods + /** + * Handles succesfully completed schedules. + * @param aDbIdentifier DbIdentifier of schedule just completed + */ + void ScheduleCompletedSuccesfullyL( const TUint32 aDbIdentifier ); + + /** + * Handles failed schedules. + * @param aDbIdentifier DbIdentifier of schedule just completed + * @param aCompletitionCode Error code of the completed schedule. + */ + void HandleScheduleErrorL( const TUint32 aDbIdentifier, + TUint32 aCompletitionCode ); + private: // Data + + /** + * LandLord. Owns data that is given to new thread and acts as observer to thread. + * Own. + */ + CCseSchedulerLandLord* iLandLord; + + /** + * Boolean representing if the LandLord is active or not. + */ + TBool iIsLandLordWorking; + }; + +#endif // __CCSESCHEDULERUNIPLUGINCONTROLLER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CCseSemaphoreController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CCseSemaphoreController.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Semaphore controller. Checks once a while if given semaphore is* +*/ + + + + +#ifndef __CCSESEMAPHORECONTROLLER_H +#define __CCSESEMAPHORECONTROLLER_H + +// INCLUDES +#include + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +class RSemaphore; +class MCseSemaphoreSignalObserver; + +/** +* CCseSemaphoreController +* +* @lib +*/ +class CCseSemaphoreController : public CTimer + { + public: // Constructors and destructors + /** + * Destructor. + */ + virtual ~CCseSemaphoreController(); + + /** + * Two-phased constructor. + * @param aSemaphore Semaphore to be followed. + * @param aObserver A pointer back to server engine through observer. + */ + static CCseSemaphoreController* NewL( RSemaphore& aSemaphore, + MCseSemaphoreSignalObserver& aObserver ); + + /** + * Starts checking if semaphore is signalled. Default interval is 5000ms. + */ + void Start( ); + + /** + * Stops checking semaphore. + */ + void Stop( ); + + private: // Constructors and destructors + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * C++ default constructor. + * @param aSemaphore Semaphore to be followed. + * @param aObserver A pointer back to server engine through observer. + */ + CCseSemaphoreController( RSemaphore& aSemaphore, + MCseSemaphoreSignalObserver& aObserver ); + + private: // Functions from base classes + /** + * RunL + * @return None + */ + void RunL(); + + /** + * Sets new interval how often semaphore signal is checked. Doesn't restart + * checking automatically. + * @param aInterval Interval how often semaphore signal is checked in milliseconds. + */ + void SetInterval( TUint aInterval ); + + private: // data + + /** + * Semaphore under observation. + */ + RSemaphore& iSemaphore; + + /** + * Reference to observer. + */ + MCseSemaphoreSignalObserver& iObserver; + + /** + * Interval how often semaphore signal is checked in milliseconds. + * Default is 5000 ms. + */ + TUint iInterval; + }; + + +#endif // __CCSESEMAPHORECONTROLLER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/CseSchedulerServer.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/CseSchedulerServer.pan Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CSESCHEDULERSERVER_PAN__ +#define __CSESCHEDULERSERVER_PAN__ + +/** CseEngineServer panic codes */ +enum TCseSchedulerServPanic + { + ECsePanicBadRequest = 1, + ECsePanicBadDescriptor, + ECreateTrapCleanup, + ECseCreateTrapCleanup, + ECseSrvCreateServer, + ECsePanicBadSubSessionHandle, + ECsePanicCouldNotCreatePrivateDir + }; + +#endif // __CSESCHEDULERSERVER_PAN__ + +// End of File \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/MCsePluginControllerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/MCsePluginControllerObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer to inform common scheduling engine when plugin is* +*/ + + + + +#ifndef __MCSEPLUGINCONTROLLEROBSERVER_H__ +#define __MCSEPLUGINCONTROLLEROBSERVER_H__ + +class CCseSchedulerPluginControllerBase; + +// CLASS DECLARATION +/** +* MCsePluginControllerObserver +* This class offers plugin controller some of the engine's utilities. +*/ +class MCsePluginControllerObserver + { + public: // New functions + /** + * Method to inform succesfully completed schedules. + * @param aDbIdentifier Identifier of the schedule that has + * completed. + */ + virtual void ScheduleCompletedSuccesfullyL( const TUint32 aDbIdentifier ) = 0; + + /** + * Method to inform failed schedules. + * @param aDbIdentifier Identifier of the schedule that has + * completed. + */ + virtual void ScheduleCompletedWithErrorL( const TUint32 aDbIdentifier, + TUint32 aErrorCode ) = 0; + + /** + * Orders engine to increase run count of given shedule. + * @param aDbIdentifier Identifier of the schedule who's run + * needs to be incremented. + */ + virtual void IncreaseScheduleRunCountL( const TUint32 aDbIdentifier ) = 0; + + /** + * Asks from engine if given schedule can be run + * @param aDbIdentifier Identifier of the schedule to be checked. + * @return boolean value representing if schedule can be run or not. + */ + virtual TBool IsAllowedToRun( const TUint32 aDbIdentifier ) = 0; + + /** + * Reports not valid schedule to engine (schedule cannot be run anymore). + * @param aDbIdentifier Reported schedules identifier. + */ + virtual void ScheduleNotValid( const TUint32 aDbIdentifier ) = 0; + + /** + * Requests rescheduling for plugin controllers + */ + virtual void RequestReschedule( ) = 0; + + /** + * Signals when plugin controller clearing is done. + */ + virtual void ClearingDone( ) = 0; + }; + +#endif // __MCSEPLUGINCONTROLLEROBSERVER_H__ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/MCseSchedulerTimerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/MCseSchedulerTimerObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __MCSESCHEDULERTIMEROBSERVER_H__ +#define __MCSESCHEDULERTIMEROBSERVER_H__ + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +/** +* MCseSchedulerTimerObserver +* This class specifies the function to be called when a timeout occurs. +* Used in conjunction with CCseSchedulerTimer class. +*/ +class MCseSchedulerTimerObserver + { + public: // New functions + /** + * Called when time is up and plugins should be run. + * + */ + virtual void RunPluginsL( ) = 0; + + /** + * Informs about time errors (time changes, timer is set towards time already + * in past), + * @parms aError timer error code. Most common are: + * KErrAbort - Phone time has changed + * KErrUnderflow - Time is in the past + * KErrOverFlow - Time is too far in the future + */ + virtual void TimerErrorL( TInt32 aError ) = 0; + }; + +#endif // __MCSESCHEDULERTIMEROBSERVER_H__ + +// End of File \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/inc/MCseSemaphoreSignalObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/inc/MCseSemaphoreSignalObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer to inform plugin starter that it is time shutdown* +*/ + + + + +#ifndef __MCSESEMAPHORESIGNALOBSERVER_H__ +#define __MCSESEMAPHORESIGNALOBSERVER_H__ + +// CLASS DECLARATION +/** +* MCseSemaphoreSignalObserver +* Observer interface to be called once observed semaphore is signalled +*/ +class MCseSemaphoreSignalObserver + { + public: // New functions + /** + * Called when observed semaphore is signalled. + */ + virtual void SemaphoreSignalled( ) = 0; + }; + +#endif // __MCSESEMAPHORESIGNALOBSERVER_H__ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/rom/videoschedulerserver.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/rom/videoschedulerserver.iby Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __VIDEOSCHEDULERSERVER_IBY__ +#define __VIDEOSCHEDULERSERVER_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\CseSchedulerServer.exe PROGRAMS_DIR\CseSchedulerServer.exe + +#endif // __VIDEOSCHEDULERSERVER_IBY__ diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/src/CCseScheduleDB.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/src/CCseScheduleDB.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,2077 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Database where to store scheduled events.* +*/ + + + + +// INCLUDE FILES +#include "CCseScheduleDB.h" // Header file for this class +#include // Represent one schedule in database +#include +#include "CseDebug.h" // Debug macros +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +_LIT( KCseCDiskPrefix, "c:" ); +_LIT( KCseSqlGetAll, "SELECT * FROM ScheduleEvent"); +_LIT( KCseSelectFromDb, "SELECT * FROM " ); +_LIT( KCseWhere, " WHERE " ); +_LIT( KCseEqual, " = " ); +_LIT( KCseOrderBy, " ORDER BY " ); +_LIT( KCseAnd, " AND " ); +_LIT( KCseLess, " < " ); +_LIT( KCseMore, " > " ); + +static TUint KScheduleNameMaxLength = 255; +static TUint KCseDatbaseVersionNumber = 1; + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ============================ MEMBER FUNCTIONS =============================== +// --------------------------------------------------------------------------- +// CCseScheduleDB::CCseScheduleDB() +// +// --------------------------------------------------------------------------- +CCseScheduleDB::CCseScheduleDB() : iDbAccess( ECseDbOpen ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::CCseScheduleDB"); + // Default C++ Constructor + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::~CCseScheduleDB"); + + iScheduleDb.Close(); + delete iScheduleFileStore; + iFsSession.Close(); + + if( iCompactTimer ) + { + iCompactTimer->Cancel(); + delete iCompactTimer; + } + delete iBackupWrapper; + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::NewL"); + CCseScheduleDB* self = new ( ELeave ) CCseScheduleDB(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::ConstructL"); + + User::LeaveIfError( iFsSession.Connect() ); + + iCompactTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + + iBackupWrapper = CBaBackupSessionWrapper::NewL(); + + TRAPD( err, OpenOrCreateDbL() ); + + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( "CCseScheduleDB::ConstructL - Opening or creating the database FAILED: %d", err ); + + if ( err != KErrNoMemory && + err != KErrLocked && + err != KErrDisMounted && + err != KErrDiskFull && + err != KErrNotReady ) + { + // Delete and recreate database file. Cannot recover other way. + CSELOGSTRING_HIGH_LEVEL( "CCseScheduleDB::ConstructL - deleting database" ); + RemoveDbL(); + CSELOGSTRING_HIGH_LEVEL( "CCseScheduleDB::ConstructL - recreating database" ); + TRAPD( err, OpenOrCreateDbL() ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( "CCseScheduleDB::ConstructL couldnt recreate database (%d), leaving", err ); + User::Leave( err ); + } + } + else + { + CSELOGSTRING2_HIGH_LEVEL( "CCseScheduleDB::ConstructL leaving (%d)", err ); + User::Leave( err ); + } + } + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) + { + CSELOGSTRING2_HIGH_LEVEL(">>>CCseScheduleDB::GetApplicationSchedulesL - AppUid: %d", + aAppUid); + + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleApplicationUIDCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aAppUid ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get the SQL table indexes. + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo scheduleTypeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through the tables + while ( view.AtRow() ) + { + // Create new CCseSceduledProgram to be added to array + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + + // Fill created schedule with DB information + view.GetL(); + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + prog->SetScheduleType( view.ColInt32( scheduleTypeIndex ) ); + prog->SetPluginType( view.ColInt32( pluginTypeIndex ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy(); // readStream + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aArray.Append( prog ) ); + CleanupStack::Pop( prog ); + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::OpenOrCreateDbL"); + TBuf path; + + // Get path to CSE's private directory + TInt err( iFsSession.PrivatePath( path ) ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL("iFsSession.PrivatePath() failed: %d", err ); + User::Leave( err ); + } + + iDbFile.Zero(); + iDbFile.Append( KCseCDiskPrefix ); + iDbFile.Append( path ); + if ( BaflUtils::CheckFolder( iFsSession, iDbFile ) != KErrNone ) + { + err = iFsSession.CreatePrivatePath( EDriveC ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( "CreatePrivatePath failed! %d", err ); + User::Leave( err ); + } + } + + iDbFile.Append( KCseScheduleDBName() ); + + // If file doesn't exist create it + if ( !BaflUtils::FileExists( iFsSession, iDbFile ) ) + { + CSELOGSTRING_HIGH_LEVEL("CCseScheduleDB::OpenOrCreateDbL Create New"); + iScheduleDb.Close(); + + if( iScheduleFileStore ) + { + delete iScheduleFileStore; + iScheduleFileStore = NULL; + } + + iScheduleFileStore = CPermanentFileStore::ReplaceL( iFsSession, + iDbFile, + EFileRead|EFileWrite ); + // Set file store type + iScheduleFileStore->SetTypeL( iScheduleFileStore->Layout() ); + // Create stream object + TStreamId id = iScheduleDb.CreateL( iScheduleFileStore ); + // Keep database id as root of store + iScheduleFileStore->SetRootL( id ); + // Complete creation by commiting + iScheduleFileStore->CommitL(); + + CreateDatabaseTableL( iScheduleDb ); + CreateScheduleTableL( iScheduleDb ); + SetDatabaseVersionL( ); + } + // Or if it exists then just open it. + else + { + iScheduleDb.Close(); + delete iScheduleFileStore; + iScheduleFileStore = NULL; + iScheduleFileStore = CPermanentFileStore::OpenL( iFsSession, iDbFile, + EFileRead|EFileWrite ); + iScheduleFileStore->SetTypeL( iScheduleFileStore->Layout() ); + iScheduleDb.OpenL( iScheduleFileStore, iScheduleFileStore->Root() ); + CheckDbVersionL(); + User::LeaveIfError( iScheduleDb.Compact() ); + } + + if ( !iBackupWrapper ) + { + iBackupWrapper = CBaBackupSessionWrapper::NewL(); + } + + iBackupWrapper->RegisterFileL( iDbFile, *this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::CheckDbVersionL"); + + TInt dbVersion( 0 ); + + TRAPD( leave, dbVersion = GetDbVersionL() ); + + if ( dbVersion != KCseDatbaseVersionNumber || leave != KErrNone ) + { + CSELOGSTRING3_HIGH_LEVEL( + "CCseScheduleDB::CheckDbVersionL Not ok, version: %d, error: %d", + dbVersion, leave ); + + // Destroy the old one + iScheduleDb.Close(); + delete iScheduleFileStore; + iScheduleFileStore = NULL; + + // Create new one + iScheduleFileStore = CPermanentFileStore::ReplaceL( iFsSession, + iDbFile, + EFileRead|EFileWrite ); + + // Set file store type + iScheduleFileStore->SetTypeL( iScheduleFileStore->Layout() ); + // Create stream object + TStreamId id = iScheduleDb.CreateL( iScheduleFileStore ); + // Keep database id as root of store + iScheduleFileStore->SetRootL( id ); + // Complete creation by commiting + iScheduleFileStore->CommitL(); + + CreateDatabaseTableL( iScheduleDb ); + CreateScheduleTableL( iScheduleDb ); + SetDatabaseVersionL( ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetDbVersionL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + TInt dbVersion(0); + + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseDatabaseTable ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + TDbColNo versionIndex = colSetOrder->ColNo( KCseDatabaseVersionCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + if ( view.AtRow() ) + { + view.GetL(); + dbVersion = view.ColInt32( versionIndex ); + } + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING2_HIGH_LEVEL( + "<<>>CCseScheduleDB::CreateScheduleTableL"); + + // Create columns for the database. + TDbCol keyCol( KCseScheduleDbKeyCol, EDbColUint32 ); + keyCol.iAttributes = TDbCol::EAutoIncrement; + + TDbCol nameCol( KCseScheduleNameCol, EDbColText8, KScheduleNameMaxLength ); + TDbCol startTimeCol( KCseScheduleStartTimeCol, EDbColDateTime ); + TDbCol endTimeCol( KCseScheduleEndTimeCol, EDbColDateTime ); + TDbCol applicationUidCol( KCseScheduleApplicationUIDCol, EDbColInt32 ); + TDbCol plugInUidCol( KCseSchedulePlugInUIDCol, EDbColInt32 ); + TDbCol typeCol( KCseScheduleTypeCol, EDbColInt32 ); + TDbCol applicationSpecificCol( KCseScheduleApplicationSpecificCol, EDbColLongBinary ); + TDbCol runCountCol( KCseScheduleRunCountCol, EDbColInt32 ); + TDbCol stateCol( KCseScheduleStateCol, EDbColInt32 ); + TDbCol pluginTypeCol( KCseSchedulePluginTypeCol, EDbColInt32 ); + TDbCol reserved1Col( KCseScheduleReserved1Col, EDbColInt32 ); + TDbCol reserved2Col( KCseScheduleReserved2Col, EDbColInt32 ); + + // Create column set and add defined columns in to the set + CDbColSet* scheduleColSet = CDbColSet::NewLC(); + scheduleColSet->AddL( keyCol ); + scheduleColSet->AddL( nameCol ); + scheduleColSet->AddL( startTimeCol ); + scheduleColSet->AddL( endTimeCol ); + scheduleColSet->AddL( applicationUidCol ); + scheduleColSet->AddL( plugInUidCol ); + scheduleColSet->AddL( typeCol ); + scheduleColSet->AddL( applicationSpecificCol ); + scheduleColSet->AddL( runCountCol ); + scheduleColSet->AddL( stateCol ); + scheduleColSet->AddL( pluginTypeCol ); + scheduleColSet->AddL( reserved1Col ); + scheduleColSet->AddL( reserved2Col ); + + // Create new table to the database with created columnset + User::LeaveIfError( aDatabase.CreateTable( KCseScheduleTable, + *scheduleColSet ) ); + + CleanupStack::PopAndDestroy( scheduleColSet ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::CreateDatabaseTableL"); + + // Create columns for the database. + TDbCol versionCol( KCseDatabaseVersionCol, EDbColInt32 ); + TDbCol reserved1Col( KCseDatabaseReserved1Col, EDbColInt32 ); + TDbCol reserved2Col( KCseDatabaseReserved2Col, EDbColInt32 ); + + // Create column set and add defined columns in to the set + CDbColSet* databaseColSet = CDbColSet::NewLC(); + databaseColSet->AddL( versionCol ); + databaseColSet->AddL( reserved1Col ); + databaseColSet->AddL( reserved2Col ); + + // Create new table to the database with created columnset + User::LeaveIfError( aDatabase.CreateTable( KCseDatabaseTable, + *databaseColSet ) ); + + CleanupStack::PopAndDestroy( databaseColSet ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::SetDatabaseVersionL"); + + iSqlSchedule.Zero(); + iSqlSchedule.Append( KCseSelectFromDb ); + iSqlSchedule.Append( KCseDatabaseTable ); + + RDbView view; + CleanupClosePushL( view ); + + // Prepare DB for update + User::LeaveIfError(view.Prepare( iScheduleDb, + TDbQuery( iSqlSchedule ), + TDbWindow::EUnlimited, + RDbView::EInsertOnly )); + view.InsertL(); + + // Create colomn set (row) to be added + CDbColSet* databaseColSet = view.ColSetL(); + CleanupStack::PushL( databaseColSet ); + + // Fill row with Schedule information + view.SetColL( databaseColSet->ColNo( KCseDatabaseVersionCol ), + KCseDatbaseVersionNumber ); + CleanupStack::PopAndDestroy( databaseColSet ); + view.PutL(); + CleanupStack::PopAndDestroy( &view ); // closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::AddScheduleL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + iSqlSchedule.Zero(); + iSqlSchedule.Append( KCseSqlGetAll ); + RDbView view; + CleanupClosePushL( view ); + + // Prepare DB for update + User::LeaveIfError(view.Prepare( iScheduleDb, + TDbQuery( iSqlSchedule ), + TDbWindow::EUnlimited, + RDbView::EInsertOnly )); + view.InsertL(); + + // Create colomn set (row) to be added + CDbColSet* scheduleColSet = view.ColSetL(); + CleanupStack::PushL( scheduleColSet ); + + // Fill row with Schedule information + view.SetColL( scheduleColSet->ColNo( KCseScheduleNameCol ), + aData.Name() ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleStartTimeCol ), + aData.StartTime() ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleEndTimeCol ), + aData.EndTime() ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleApplicationUIDCol ), + aData.AppUid() ); + + view.SetColL( scheduleColSet->ColNo( KCseSchedulePlugInUIDCol ), + aData.PluginUid() ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleTypeCol ), + aData.ScheduleType() ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleRunCountCol ), + 0 ); + + view.SetColL( scheduleColSet->ColNo( KCseScheduleStateCol ), + ECseWaiting ); + + view.SetColL( scheduleColSet->ColNo( KCseSchedulePluginTypeCol ), + aData.PluginType() ); + + // Description is long one, it needs to be handled by stream + RDbColWriteStream write; + write.OpenLC( view, scheduleColSet->ColNo( KCseScheduleApplicationSpecificCol ) ); + write.WriteL( aData.ApplicationData() ); + write.CommitL(); + CleanupStack::PopAndDestroy(); // write + + TDbColNo keyColumnNo = scheduleColSet->ColNo( KCseScheduleDbKeyCol ); + CleanupStack::PopAndDestroy( scheduleColSet ); + view.PutL(); + + // Get new program key + aData.SetDbIdentifier( view.ColUint32( keyColumnNo ) ); + + CleanupStack::PopAndDestroy( &view ); // closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::RemoveScheduleL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL string to find given schedule from DB + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + User::LeaveIfError( iScheduleDb.Begin() ); + + // Prepare DB to update + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + view.FirstL(); + + TInt count( 0 ); + + // If schedule found, remove it. + while ( view.AtRow() ) + { + view.DeleteL(); + count++; + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // closes view + User::LeaveIfError( iScheduleDb.Commit() ); + + CSELOGSTRING3_HIGH_LEVEL("---- %d Items for identifier %d removed from DB", count, aDbIdentifier); + if ( count == 0 ) + { + User::Leave( KErrNotFound ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetNextScheduleTimeL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL satring to get schedule occurence(s) that are + // going to happen next from database. + TTime nextScheduleTime( 0 ); + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleStateCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( ECseWaiting ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next schedule + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Schedule found get its start time. + if ( view.AtRow() ) + { + view.GetL(); + nextScheduleTime = view.ColTime( startTimeIndex ); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<& aNextScheduleArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::FillScheduleArrayByTimeL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf<100> startTimeBuf; + + _LIT( KDateTimeFormat,"# %1%*D/%2%*M/%3%*Y %H:%T:%S.%C#" ); + + aScheduleTime.FormatL( startTimeBuf, KDateTimeFormat ); + + // Create SQL string to get all schedules to be happen at given time + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.Append( startTimeBuf ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get column indexes + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through all found schedules. + while ( view.AtRow() ) + { + // Create new schedule to be added to array + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + view.GetL(); + + // Copy information from DB to schedule. + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + prog->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + prog->SetPluginType( CCseScheduledProgram::TCsePluginType( + view.ColInt32( pluginTypeIndex ) ) ); + TInt streamLen( view.ColLength( applicationSpecificIndex ) ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy(); // readStream; + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aNextScheduleArray.Append( prog ) ); + CleanupStack::Pop( prog ); + + // And next schedule... + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetScheduleByDbIdentifierL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + if ( !aSchedule ) + { + return; + } + + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + while ( view.AtRow() ) + { + view.GetL(); + aSchedule->SetDbIdentifier( view.ColUint32( keyIndex ) ); + aSchedule->SetName( view.ColDes8( nameIndex ) ); + aSchedule->SetStartTime( view.ColTime( startTimeIndex ) ); + aSchedule->SetEndTime( view.ColTime( endTimeIndex ) ); + aSchedule->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + aSchedule->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + + aSchedule->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + aSchedule->SetPluginType( CCseScheduledProgram::TCsePluginType( + view.ColInt32( pluginTypeIndex ) ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |->1 + readStream.ReadL(buffPtr, streamLen); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1<-| Popping pointer to Col that we dont have here + TPtrC8 ptr8( appDataBuffer->Des() ); + aSchedule->SetApplicationDataL( *appDataBuffer ); + CleanupStack::PopAndDestroy( appDataBuffer ); + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<& aResultArray + ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetOverlappingSchedulesL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + TBuf<100> startTimeBuf; + _LIT( KDateTimeFormat,"# %1%*D/%2%*M/%3%*Y %H:%T:%S#" ); + aStartTime.FormatL( startTimeBuf, KDateTimeFormat ); + TBuf<100> endTimeBuf; + aEndTime.FormatL( endTimeBuf, KDateTimeFormat ); + + // Create SQL string to find all overlapping schedules from database between given + // timeframe. + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleTypeCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aType ); + sqlStatement.Append( KCseAnd ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + sqlStatement.Append( KCseLess ); + sqlStatement.Append( endTimeBuf ); + sqlStatement.Append( KCseAnd ); + sqlStatement.Append( KCseScheduleEndTimeCol ); + sqlStatement.Append( KCseMore ); + sqlStatement.Append( startTimeBuf ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Move to the first row + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get colon indexes. + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through all found schedules. + while ( view.AtRow() ) + { + // Create new schedule to be added to array. + CCseScheduledProgram* schedule = CCseScheduledProgram::NewL(); + CleanupStack::PushL( schedule ); + view.GetL(); + + // Set schedule information. + schedule->SetDbIdentifier( view.ColUint32( keyIndex ) ); + schedule->SetName( view.ColDes8( nameIndex ) ); + schedule->SetStartTime( view.ColTime( startTimeIndex ) ); + schedule->SetEndTime( view.ColTime( endTimeIndex ) ); + schedule->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + schedule->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + + schedule->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + schedule->SetPluginType( CCseScheduledProgram::TCsePluginType( + view.ColInt32( pluginTypeIndex ) ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; // |->1 + readStream.OpenLC( view, applicationSpecificIndex ); + readStream.ReadL(buffPtr, streamLen); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1<-| Popping pointer to Col that we dont have here + TPtrC8 ptr8( appDataBuffer->Des() ); + schedule->SetApplicationDataL( *appDataBuffer ); + CleanupStack::PopAndDestroy( appDataBuffer ); + if ( schedule->StartTime() < aEndTime && schedule->EndTime() > aStartTime ) + { + aResultArray.AppendL( schedule ); + CleanupStack::Pop( schedule ); + } + else + { + CleanupStack::PopAndDestroy( schedule ); + schedule = NULL; + } + + // Next shcedule... + view.NextL(); + } + CleanupStack::PopAndDestroy( &view ); // Closes view + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::IncreaseRunCountL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL string to find given schedule + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + // Order table based on DB identifier + RDbView readView; + CleanupClosePushL( readView ); + + User::LeaveIfError( readView.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( readView.EvaluateAll() ); + + // Get the next reminder + readView.FirstL(); + + // First we read existint run count + CDbColSet* readColSet = readView.ColSetL(); + CleanupStack::PushL( readColSet ); + TDbColNo runCountCol = readColSet->ColNo( KCseScheduleRunCountCol ); + CleanupStack::PopAndDestroy( readColSet ); + TInt32 runCount( 0 ); + if ( readView.AtRow() ) + { + readView.GetL(); + runCount = readView.ColInt32( runCountCol ); + runCount++; + } + // Close read view + CleanupStack::PopAndDestroy( &readView ); + + // Update run count + if ( runCount > 0 ) + { + // Open write view + RDbView writeView; + CleanupClosePushL( writeView ); + User::LeaveIfError( writeView.Prepare( iScheduleDb, + TDbQuery( sqlStatement ), + TDbWindow::EUnlimited, + RDbView::EUpdatable )); + User::LeaveIfError( writeView.EvaluateAll() ); + + writeView.FirstL(); + CDbColSet* writeColSet = writeView.ColSetL(); + CleanupStack::PushL( writeColSet ); + TDbColNo runCountColNo = writeColSet->ColNo( KCseScheduleRunCountCol ); + CleanupStack::PopAndDestroy( writeColSet ); + + writeView.UpdateL(); + + // If we found (as we should) schedule again we update its value. + if ( writeView.AtRow() ) + { + writeView.SetColL( runCountColNo, runCount ); + } + + writeView.PutL(); + + CleanupStack::PopAndDestroy( &writeView ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetRunCountL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + TInt32 runCount( 0 ); + + // Create SQL string to find given schedule + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + TDbColNo runCountCol = colSetOrder->ColNo( KCseScheduleRunCountCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // If we found schedule get its run count. + if ( view.AtRow() ) + { + view.GetL(); + + runCount = view.ColInt32( runCountCol ); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseScheduleDB::SetScheduleStateL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL string to find given schedule + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + // Open write view + RDbView writeView; + CleanupClosePushL( writeView ); + User::LeaveIfError( writeView.Prepare( iScheduleDb, + TDbQuery( sqlStatement ), + TDbWindow::EUnlimited, + RDbView::EUpdatable )); + User::LeaveIfError( writeView.EvaluateAll() ); + + writeView.FirstL(); + CDbColSet* writeColSet = writeView.ColSetL(); + CleanupStack::PushL( writeColSet ); + TDbColNo stateColNo = writeColSet->ColNo( KCseScheduleStateCol ); + CleanupStack::PopAndDestroy( writeColSet ); + + writeView.UpdateL(); + + // If we found schedule, we change the column value. + if ( writeView.AtRow() ) + { + writeView.SetColL( stateColNo, aState ); + } + + writeView.PutL(); + CleanupStack::PopAndDestroy( &writeView ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetScheduleStateL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL string to find given schedule + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleDbKeyCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aDbIdentifier ); + + // Order table based on DB identifier + RDbView readView; + CleanupClosePushL( readView ); + User::LeaveIfError( readView.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( readView.EvaluateAll() ); + + // Get the reminder + readView.FirstL(); + + CDbColSet* readColSet = readView.ColSetL(); + CleanupStack::PushL( readColSet ); + TDbColNo stateCol = readColSet->ColNo( KCseScheduleStateCol ); + CleanupStack::PopAndDestroy( readColSet ); + TInt32 state( KErrNotFound ); + + // If we found schedule, get the schedule state. + if ( readView.AtRow() ) + { + readView.GetL(); + state = readView.ColInt32( stateCol ); + } + // Close read view + CleanupStack::PopAndDestroy( &readView ); + + CSELOGSTRING_HIGH_LEVEL("<<& aScheduleArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::StartupSchedulesL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL string to find wanted schedules. + // At startup phase we are first interested for + // those schedules that were on run when phone was + // shutdown (eg runcount is bigger than 0). + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleRunCountCol ); + sqlStatement.Append( KCseMore ); + sqlStatement.AppendNum( 0 ); + + // Order table + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the first reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Column indexes + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through the found schedules. + while ( view.AtRow() ) + { + // Create CseScheduledProgram to be added to string. + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + view.GetL(); + + // Set schedule information. + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + + prog->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + prog->SetPluginType( CCseScheduledProgram::TCsePluginType( + view.ColInt32( pluginTypeIndex ) ) ); + + TInt streamLen( view.ColLength( applicationSpecificIndex ) ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |->1 + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1<-| Popping pointer to Col that we dont have here + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aScheduleArray.Append( prog ) ); + CleanupStack::Pop( prog ); + + // Next shcedule + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::ResetCompactTimer"); + + // If iCompatTimer is not running start it. + if( !iCompactTimer ) + { + TRAPD(err, iCompactTimer = CPeriodic::NewL( CActive::EPriorityStandard )); + + if(err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL("CCseScheduleDB::ResetCompactTimer - Can't create iCompactTimer: %d", err); + } + } + + // If iCompactTimer is running cancel it and start over again. + if( iCompactTimer ) + { + iCompactTimer->Cancel(); + + iCompactTimer->Start( KCseDbCompactTimeout, + KCseDbCompactTimeout, + TCallBack( CompactCallback, this ) ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::CompactCallback"); + + // Direct call to class method. + static_cast( aThis )->CompactDb(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::CompactDb"); + // Compact database + + if( iDbAccess != ECseDbLocked ) + { + TInt err( iScheduleDb.Compact() ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL("iScheduleDb.Compact() failed: %d", err); + } + } + + // Cancel timer if it is running + if ( iCompactTimer ) + { + iCompactTimer->Cancel(); + delete iCompactTimer; + iCompactTimer = NULL; + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::ChangeFileLockL" ); + + switch ( aFlags ) + { + case MBackupObserver::EReleaseLockReadOnly: + case MBackupObserver::EReleaseLockNoAccess: + { + // Backup and restore starting, close the db + CloseDbFile(); + + // Cancel timer if it is running + if ( iCompactTimer ) + { + iCompactTimer->Cancel(); + delete iCompactTimer; + iCompactTimer = NULL; + } + } + break; + + default: + { + OpenDbFileL(); + } + break; + } + + CSELOGSTRING_HIGH_LEVEL( "<<>>CCseScheduleDB::CloseDbFile"); + + iDbAccess = ECseDbLocked; + iScheduleDb.Close(); + delete iScheduleFileStore; + iScheduleFileStore = NULL; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::OpenDbFileL"); + + iScheduleDb.Close(); + if( iScheduleFileStore ) + { + delete iScheduleFileStore; + iScheduleFileStore = NULL; + } + iScheduleFileStore = CPermanentFileStore::OpenL( iFsSession, iDbFile, + EFileRead|EFileWrite ); + iScheduleFileStore->SetTypeL( iScheduleFileStore->Layout() ); + iScheduleDb.OpenL( iScheduleFileStore, iScheduleFileStore->Root() ); + User::LeaveIfError( iScheduleDb.Compact() ); + + iDbAccess = ECseDbOpen; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::LeaveIfDbLocked"); + + if(iDbAccess == ECseDbLocked) + { + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) + { + + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetSchedulesByPluginL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseSchedulePlugInUIDCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aPluginUid ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get the SQL table indexes. + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo scheduleTypeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through the tables + while ( view.AtRow() ) + { + // Create new CCseSceduledProgram to be added to array + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + + // Fill created schedule with DB information + view.GetL(); + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + prog->SetScheduleType( view.ColInt32( scheduleTypeIndex ) ); + prog->SetPluginType( view.ColInt32( pluginTypeIndex ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |->1 + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1<-| Popping pointer to Col that we dont have here + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aArray.Append( prog ) ); + CleanupStack::Pop( prog ); + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<& aArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetSchedulesByPluginL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleTypeCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aType ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get the SQL table indexes. + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo scheduleTypeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through the tables + while ( view.AtRow() ) + { + // Create new CCseSceduledProgram to be added to array + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + + // Fill created schedule with DB information + view.GetL(); + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + prog->SetScheduleType( view.ColInt32( scheduleTypeIndex ) ); + prog->SetPluginType( view.ColInt32( pluginTypeIndex ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |-> 1 + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1 <-| Popping pointer to Col that we dont have here + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aArray.Append( prog ) ); + CleanupStack::Pop( prog ); + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<& aResultArray + ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetSchedulesByTimeframeL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + TBuf<100> startTimeBuf; + _LIT( KDateTimeFormat,"# %1%*D/%2%*M/%3%*Y %H:%T:%S#" ); + aBeginning.FormatL( startTimeBuf, KDateTimeFormat ); + TBuf<100> endTimeBuf; + aEnd.FormatL( endTimeBuf, KDateTimeFormat ); + + // Create SQL string to find all overlapping schedules from database between given + // timeframe. + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + sqlStatement.Append( KCseLess ); + sqlStatement.Append( endTimeBuf ); + sqlStatement.Append( KCseAnd ); + sqlStatement.Append( KCseScheduleEndTimeCol ); + sqlStatement.Append( KCseMore ); + sqlStatement.Append( startTimeBuf ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Move to the first row + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get colon indexes. + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through all found schedules. + while ( view.AtRow() ) + { + // Create new schedule to be added to array. + CCseScheduledProgram* schedule = CCseScheduledProgram::NewL(); + CleanupStack::PushL( schedule ); + view.GetL(); + + // Set schedule information. + schedule->SetDbIdentifier( view.ColUint32( keyIndex ) ); + schedule->SetName( view.ColDes8( nameIndex ) ); + schedule->SetStartTime( view.ColTime( startTimeIndex ) ); + schedule->SetEndTime( view.ColTime( endTimeIndex ) ); + schedule->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + schedule->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + + schedule->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + schedule->SetPluginType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( pluginTypeIndex ) ) ); + + TInt streamLen( 0 ); + streamLen = view.ColLength( applicationSpecificIndex ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |-> 1 + readStream.ReadL(buffPtr, streamLen); + readStream.Release(); + CleanupStack::PopAndDestroy( ); // 1 <-| Popping pointer to Col that we dont have here + TPtrC8 ptr8( appDataBuffer->Des() ); + schedule->SetApplicationDataL( *appDataBuffer ); + CleanupStack::PopAndDestroy( appDataBuffer ); + + aResultArray.AppendL( schedule ); + CleanupStack::Pop( schedule ); + + // Next shcedule... + view.NextL(); + } + CleanupStack::PopAndDestroy( &view ); // Closes view + CSELOGSTRING_HIGH_LEVEL("<<& aPlugins ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetPluginsL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseSchedulePlugInUIDCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get the SQL table indexes. + TDbColNo pluginUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + TInt32 currentPluginUid( 0 ); + TInt32 newPluginUid( 0 ); + + // Loop through the tables + while ( view.AtRow() ) + { + view.GetL(); + + // Get plugin Uid from row + newPluginUid = view.ColInt32( pluginUidIndex ); + + // If it is different that the current plugin uid add it to + // array and set new "current" uid. + if( newPluginUid != currentPluginUid ) + { + // Query results are sorted by plugin uid + // so if uid changes we can add it to array + // without fearing that we will have + // duplicates. + aPlugins.Append( newPluginUid ); + currentPluginUid = newPluginUid; + } + + view.NextL(); + } + + view.Close(); + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseScheduleDB::GetNextScheduleTimeByPluginL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Create SQL satring to get schedule occurence(s) that are + // going to happen next from database. + TTime nextScheduleTime( 0 ); + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleStateCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( ECseWaiting ); + sqlStatement.Append( KCseAnd ); + sqlStatement.Append( KCseSchedulePlugInUIDCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aPluginUid ); + sqlStatement.Append( KCseOrderBy ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next schedule + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Schedule found get its start time. + if ( view.AtRow() ) + { + view.GetL(); + nextScheduleTime = view.ColTime( startTimeIndex ); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<<& aNextScheduleArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseScheduleDB::GetSchedulesByTimeAndPluginL"); + LeaveIfDbLockedL(); + ResetCompactTimer(); + + // Gets program occurence(s) that are going to happen next + // from database + TBuf<100> startTimeBuf; + + _LIT( KDateTimeFormat,"# %1%*D/%2%*M/%3%*Y %H:%T:%S.%C#" ); + + aScheduleTime.FormatL( startTimeBuf, KDateTimeFormat ); + + // Create SQL string to get all schedules to be happen at given time + TBuf sqlStatement; + sqlStatement.Append( KCseSelectFromDb ); + sqlStatement.Append( KCseScheduleTable ); + sqlStatement.Append( KCseWhere ); + sqlStatement.Append( KCseScheduleStartTimeCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.Append( startTimeBuf ); + sqlStatement.Append( KCseAnd ); + sqlStatement.Append( KCseSchedulePlugInUIDCol ); + sqlStatement.Append( KCseEqual ); + sqlStatement.AppendNum( aPluginUid ); + + // Order table based on start time + RDbView view; + CleanupClosePushL( view ); + User::LeaveIfError( view.Prepare( iScheduleDb, + TDbQuery( sqlStatement ) ) ); + User::LeaveIfError( view.EvaluateAll() ); + + // Get the next reminder + view.FirstL(); + + CDbColSet* colSetOrder = view.ColSetL(); + CleanupStack::PushL( colSetOrder ); + + // Get column indexes + TDbColNo keyIndex = colSetOrder->ColNo( KCseScheduleDbKeyCol ); + TDbColNo nameIndex = colSetOrder->ColNo( KCseScheduleNameCol ); + TDbColNo startTimeIndex = colSetOrder->ColNo( KCseScheduleStartTimeCol ); + TDbColNo endTimeIndex = colSetOrder->ColNo( KCseScheduleEndTimeCol ); + TDbColNo applicationUidIdIndex = colSetOrder->ColNo( KCseScheduleApplicationUIDCol ); + TDbColNo plugInUidIndex = colSetOrder->ColNo( KCseSchedulePlugInUIDCol ); + TDbColNo typeIndex = colSetOrder->ColNo( KCseScheduleTypeCol ); + TDbColNo applicationSpecificIndex = colSetOrder->ColNo( KCseScheduleApplicationSpecificCol ); + TDbColNo pluginTypeIndex = colSetOrder->ColNo( KCseSchedulePluginTypeCol ); + + CleanupStack::PopAndDestroy( colSetOrder ); + + // Loop through all found schedules. + while ( view.AtRow() ) + { + // Create new schedule to be added to array + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + view.GetL(); + + // Copy information from DB to schedule. + prog->SetDbIdentifier( view.ColUint32( keyIndex ) ); + prog->SetName( view.ColDes8( nameIndex ) ); + prog->SetStartTime( view.ColTime( startTimeIndex ) ); + prog->SetEndTime( view.ColTime( endTimeIndex ) ); + prog->SetAppUid( view.ColInt32( applicationUidIdIndex ) ); + prog->SetPluginUid( view.ColInt32( plugInUidIndex ) ); + + prog->SetScheduleType( CCseScheduledProgram::TCseScheduleType( + view.ColInt32( typeIndex ) ) ); + prog->SetPluginType( view.ColInt32( pluginTypeIndex ) ); + TInt streamLen( view.ColLength( applicationSpecificIndex ) ); + + HBufC8* appDataBuffer = HBufC8::NewL( streamLen ); + CleanupStack::PushL( appDataBuffer ); + + TPtr8 buffPtr( appDataBuffer->Des() ); + RDbColReadStream readStream; + readStream.OpenLC( view, applicationSpecificIndex ); // |-> 1 + readStream.ReadL( buffPtr, streamLen ); + readStream.Release(); + CleanupStack::PopAndDestroy(); // 1 <-| + + prog->SetApplicationDataL( *appDataBuffer ); + + CleanupStack::PopAndDestroy( appDataBuffer ); + User::LeaveIfError( aNextScheduleArray.Append( prog ) ); + CleanupStack::Pop( prog ); + + // And next schedule... + view.NextL(); + } + + CleanupStack::PopAndDestroy( &view ); // Closes view + + CSELOGSTRING_HIGH_LEVEL("<< +#include "CCseSchedulerThreadPacket.h" +#include // Observer for informing engine +#include +#include "CseDebug.h" // Debug macros +#include "CCseSemaphoreController.h" + +_LIT( KCseUniThreadName, "CseThread" ); +_LIT( KCseLine, "-" ); + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CCseSchedulerTimer::CCseSchedulerTimer() +// +// --------------------------------------------------------------------------- +CCseSchedulerLandLord::CCseSchedulerLandLord( MCseScheduleObserver* aObserver ) : + CActive( CActive::EPriorityStandard ), + iThreadRunning( EFalse ), + iTakedownRequested( EFalse ) + + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerLandLord::CCseSchedulerLandLord"); + + // C++ default constructor + iObserver = aObserver; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::~CCseSchedulerLandLord"); + + Cancel(); + + delete iShutdownCompleteMonitor; + iShutdownCompleteMonitor = NULL; + delete iActiveSchedulerWait; + iActiveSchedulerWait = NULL; + iObserver = NULL; + delete iThreadPacket; + iThreadPacket = NULL; + delete iThreadName; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::NewL"); + + // Symbian C++ constructor + CCseSchedulerLandLord* self = new ( ELeave ) CCseSchedulerLandLord( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::ConstructL"); + + iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; + CActiveScheduler::Add( this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::DoCancel" ); + + if ( iThreadRunning ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerLandLord::DoCancel Canceling thread" ); + + // Signal thread to die away! + iPluginShutdownSemaphore.Signal(); + + iThreadRunning = EFalse; + + // Complete schedule with KErrAbort + TRAP_IGNORE( iObserver->ScheduleCompletedL( + iThreadPacket->Schedule( )->DbIdentifier(), KErrAbort ) ); + } + + CSELOGSTRING_HIGH_LEVEL( "<<>>CCseSchedulerLandLord::RunL"); + + iThreadRunning = EFalse; + + // In case we have not cancelled operation, complete schedule with result code. + // If we have cancelled it, we're not interested about the result as the + // schedule has already been removed from the DB + if( !iTakedownRequested ) + { + iObserver->ScheduleCompletedL( iThreadPacket->Schedule( )->DbIdentifier(), + iThreadPacket->ResultCode( ) ); + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::SetSchedule"); + + delete iThreadPacket; + iThreadPacket = NULL; + iThreadPacket = CCseSchedulerThreadPacket::NewL(); + iThreadPacket->SetScheduleL( aData ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::Schedule"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::RunError"); + // ATM there isn't leaving code in RunL so we just cancel timer if it is active. + Cancel(); + // Return KErrNone to avoid crash. + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerLandLord::GenerateThreadName +// Generates "unique" name for thread +// ----------------------------------------------------------------------------- +// +void CCseSchedulerLandLord::GenerateThreadNameL( ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerLandLord::GenerateThreadName"); + + delete iThreadName; + iThreadName = NULL; + iThreadName = KCseUniThreadName().AllocL(); + iThreadName = iThreadName->ReAllocL( + iThreadName->Size() + // Length of original name. + sizeof( TUint32 ) * 2 + // Space for Plugin Uid and DbIdentifier + 2 ); // Two "-" as a separator between + // Uid and identifier + + // Separator + iThreadName->Des( ).Append( KCseLine ); + + // Plugin uid + iThreadName->Des( ).AppendNum( iThreadPacket->Schedule()->PluginUid() ); + + // Separator + iThreadName->Des( ).Append( KCseLine ); + + // Finally schedule identifier to make thread name unique + iThreadName->Des( ).AppendNum( iThreadPacket->Schedule()->DbIdentifier() ); + + CSELOGSTRING_HIGH_LEVEL("<<SetShutdownSemaphore( iPluginShutdownSemaphore ); + + iPluginShutdownCompleteSemaphore.CreateLocal( 0 ); + iThreadPacket->SetShutdownCompleteSemaphore( iPluginShutdownCompleteSemaphore ); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerLandLord::RunPluginL +// From CActive, called when RunL leaves. +// ----------------------------------------------------------------------------- +// +void CCseSchedulerLandLord::RunPluginL( ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerLandLord::RunPluginL"); + TInt error( KErrNone ); + + // Create semaphores for shutdown signalling + GenerateSemaphoresL(); + + // First we create unique thread name + GenerateThreadNameL( ); + + // Create thread where to run schedule + error = iThread.Create( *iThreadName, + CCseSchedulerPluginStarter::StartThread, + KDefaultStackSize, + NULL, // uses caller thread's heap + iThreadPacket, // Schedule + EOwnerThread ); + + if( error == KErrNone ) + { + // Creation succesfull, start running it and logon on it. + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerLandLord::RunPluginL - Thread creation succesfull"); + iThread.Resume(); + iThread.Logon( iStatus ); + SetActive(); + iThreadRunning = ETrue; + } + else + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerLandLord::RunPluginL - Thread creation FAILED: %d", + error); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::ActiveWait()"); + if (aStart) + { + if(!iActiveSchedulerWait->IsStarted()) + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerLandLord::ActiveWait - Wait start"); + iActiveSchedulerWait->Start(); + } + } + else + { + if(iActiveSchedulerWait->IsStarted()) + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerLandLord::ActiveWait - Wait stop"); + iActiveSchedulerWait->AsyncStop(); + } + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::ShutdownPlugin()"); + + ActiveWait( EFalse ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::ClearL"); + + if( iThreadRunning ) + { + // Flag the takedown. We're cancelling the operation, so we have + // no interest about result code as the schedule has already + // been removed from the DB. + iTakedownRequested = ETrue; + + // Signal thread to die away! + iPluginShutdownSemaphore.Signal(); + + if( !iShutdownCompleteMonitor ) + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerLandLord::ClearL - New semaphore monitor" ); + iShutdownCompleteMonitor = CCseSemaphoreController::NewL( iPluginShutdownCompleteSemaphore, *this ); + } + + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerLandLord::ClearL - StartMonitor" ); + iShutdownCompleteMonitor->Start(); + + ActiveWait( ETrue ); + + iThreadRunning = EFalse; + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerLandLord::IsWorking()"); + + CSELOGSTRING2_HIGH_LEVEL("<< +#include "CCseSchedulerTimer.h" +#include "CCseSchedulerServerEngine.h" +#include "CCseSchedulerThreadPacket.h" + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerPluginControllerBase::CCseSchedulerMultiPluginController +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCseSchedulerMultiPluginController::CCseSchedulerMultiPluginController( + CCseSchedulerServerEngine& aEngine, + TInt32 aPluginUid ) : + CCseSchedulerPluginControllerBase( aEngine, aPluginUid ) + + { + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerMultiPluginController::CCseSchedulerMultiPluginController"); + + CSELOGSTRING_HIGH_LEVEL( + "<<>>CCseSchedulerMultiPluginController::NewL"); + + CCseSchedulerMultiPluginController* self = + new( ELeave ) CCseSchedulerMultiPluginController( aEngine, aPluginUid ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::ConstructL"); + + CCseSchedulerPluginControllerBase::ConstructL(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::~CCseSchedulerMultiPluginController"); + + iLandLords.ResetAndDestroy( ); + iLandLords.Close(); + + CSELOGSTRING_HIGH_LEVEL( + "<<>>CCseSchedulerMultiPluginController::RunPluginsL"); + TBool scheduleAlreadyRunning( EFalse ); + + if(iScheduleArray.Count() >0 ) + { + // Kick those schedules running that aren't already running + for( TInt i = 0; i < iScheduleArray.Count(); i++) + { + for ( TInt ii = 0; ii < iLandLords.Count(); ii++ ) + { + if( iScheduleArray[i]->DbIdentifier() == + iLandLords[ii]->ThreadPacket()->Schedule()->DbIdentifier() ) + { + scheduleAlreadyRunning = ETrue; + } + } + if( !scheduleAlreadyRunning ) + { + if( iEngine.IsAllowedToRun( iScheduleArray[i]->DbIdentifier() ) ) + { + // Create new LandLord for each schedule to be run + CCseSchedulerLandLord* landLord = CCseSchedulerLandLord::NewL( this ); + + CleanupStack::PushL( landLord ); + + // Set schedule for LandLord + landLord->SetScheduleL( *iScheduleArray[i] ); + + // Increase run count + iEngine.IncreaseScheduleRunCountL( iScheduleArray[0]->DbIdentifier() ); + + // Order the LandLord to run plugin + landLord->RunPluginL(); + + CleanupStack::Pop( landLord ); + + // Add created landLord to array. Destroyed later when landLord + // is not needed anymore. + iLandLords.AppendL( landLord ); + + CleanupStack::Pop( landLord ); + } + else + { + // Schedule cannot be run anymore due to security reasons + // Signal engine to remove schedule from DB + iEngine.ScheduleNotValid( iScheduleArray[i]->DbIdentifier() ); + + // Remove schedule own list + delete iScheduleArray[i]; + iScheduleArray.Remove( i ); + i--; + } + } + } + if( iLandLords.Count() == 0 ) + { + // We've gone through all our schedules and still no LandLords. + // We need to request new schedules. + iEngine.RequestReschedule(); + } + } + else + { + // No schedules...!?!? REEEEESCHEDULE!!! + iEngine.RequestReschedule(); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::ScheduleCompletedL"); + + if ( aCompletitionCode == KErrNone ) + { + ScheduleCompletedSuccesfullyL( aDbIdentifier ); + } + else + { + HandleScheduleErrorL( aDbIdentifier, aCompletitionCode ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::ScheduleCompletedSuccesfullyL"); + + // Remove schedule from list + for ( TInt i = 0; i < iScheduleArray.Count(); i ++) + { + if( iScheduleArray[i]->DbIdentifier() == aDbIdentifier ) + { + delete iScheduleArray[i]; + iScheduleArray.Remove( i ); + } + } + + // Notify engine about completition. + iEngine.ScheduleCompletedSuccesfullyL( aDbIdentifier ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::HandleScheduleError"); + + // Here we could try to handle plugin errors. Problem is that scheduler doesn't + // know anything about schedule it is running and so there cannot be tailored + // error handling for each plugin. In the end, we just complete schedule + // to engine with error code (ends up removing schedule from DB). + + // Remove schedule from list + for ( TInt i = 0; i < iScheduleArray.Count(); i ++) + { + if( iScheduleArray[i]->DbIdentifier() == aDbIdentifier ) + { + delete iScheduleArray[i]; + iScheduleArray.Remove( i ); + break; + } + } + + iEngine.ScheduleCompletedWithErrorL( aDbIdentifier, aCompletitionCode ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::DoCleanUp"); + TBool scheduleFound( EFalse ); + + // Check all LandLords. If we found that there is no schedules related to + // one we destroy it. + for (TInt i = iLandLords.Count(); i > 0; i--) + { + for ( TInt ii = 0; ii < iScheduleArray.Count(); ii++ ) + { + // Compare LandLords DbIdentifier with the ones in schedules + if( iLandLords[i-1]->ThreadPacket()->Schedule()->DbIdentifier() == + iScheduleArray[ii]->DbIdentifier() ) + { + scheduleFound = ETrue; + break; + } + } + // Remove LandLord if there is no schedule for it. + if( !scheduleFound ) + { + delete iLandLords[i-1]; + iLandLords.Remove(i-1); + } + scheduleFound = EFalse; + } + + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerMultiPluginController::ClearControllerL"); + for( TInt i = 0 ; i < iLandLords.Count() ; i++ ) + { + iLandLords[i]->ClearL(); + } + CSELOGSTRING_HIGH_LEVEL("<<IsWorking() ) + { + retVal = ETrue ; + break; + } + } + return retVal; + } + +// End of file. diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/src/CCseSchedulerPluginControllerBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/src/CCseSchedulerPluginControllerBase.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,328 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for plugin controllers* +*/ + + + + + +// INCLUDE FILES +#include "CCseSchedulerPluginControllerBase.h" +#include "CseDebug.h" // Debug macros +#include +#include "CCseSchedulerTimer.h" +#include "CCseSchedulerServerEngine.h" + + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerPluginControllerBase::CCseSchedulerPluginControllerBase +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCseSchedulerPluginControllerBase::CCseSchedulerPluginControllerBase( MCsePluginControllerObserver& aEngine, + TInt32 aPluginUid ) : + iEngine( aEngine ), + iPluginUid( aPluginUid ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginControllerBase::CCseSchedulerPluginControllerBase"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::NewL"); + + CCseSchedulerPluginControllerBase* self = new( ELeave ) CCseSchedulerPluginControllerBase( aEngine, aPluginUid ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::ConstructL"); + + iTimer = CCseSchedulerTimer::NewL( this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::~CCseSchedulerPluginControllerBase"); + + delete iTimer; + iScheduleArray.ResetAndDestroy(); + + CSELOGSTRING_HIGH_LEVEL("<<& aScheduleArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginControllerBase::SetSchedules"); + + // The aScheduleArray parameter contains schedules which are either before + // or at the same time as the existing ones in the iScheduleArray. + // Just destroy the old ones and replace with new ones. + // Also cancel the timer because the schedule to run may be different + + iScheduleArray.ResetAndDestroy(); + iTimer->Cancel(); + + // Go through all given schedules and copy them our array + for( TInt i = 0; i < aScheduleArray.Count(); i++) + { + CCseScheduledProgram* schedule = + CCseScheduledProgram::NewL(*aScheduleArray[i] ); + CleanupStack::PushL( schedule ); + + iScheduleArray.AppendL( schedule ); + + CleanupStack::Pop( schedule ); + } + + // If we have schedules, set the timer + if (iScheduleArray.Count() > 0) + { + // All the schedules have same time + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginControllerBase::SetSchedules"); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerPluginControllerBase::GetPluginUid +// +// ----------------------------------------------------------------------------- +// +TInt32 CCseSchedulerPluginControllerBase::PluginUid( ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginControllerBase::PluginUid"); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::RunPluginsL"); + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerPluginControllerBase::RunPluginsL - Base class, do nothing"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::IsObsolete"); + + TBool ret( EFalse ); + + // If we have no schedules in array we declare ourselves as "obsolete". + if( iScheduleArray.Count() == 0 ) + { + ret = ETrue; + } + + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::ScheduleCompleted"); + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerUniPluginController::ScheduledEventCompleted - WTF LEIK BSAE KLASS"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginControllerBase::TimerErrorL"); + + if ( aError == KErrAbort ) + { + // System time changed. Make sanity check and start timer again. + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerPluginControllerBase::TimerErrorL, system time has changed"); + if ( iScheduleArray.Count() > 0 ) + { + TTime now; + now.UniversalTime(); + // Time still in the future + if ( now < iScheduleArray[0]->StartTime() ) + { + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + else + { + RunPluginsL(); + } + } + return; + } + + if ( aError == KErrUnderflow ) + { + // Scheduled time is in the past, pass it to notifier. It should decide what to do + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerPluginControllerBase::TimerErrorL, scheduled time is in the past"); + RunPluginsL(); + return; + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::DoCleanUp"); + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerUniPluginController::DoCleanUp - Base class"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::SetToBeCleared"); + + iToBeCleared = aToBeCleared; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::ClearControllerL"); + + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerUniPluginController::ClearControllerL - Baseclass, nothing here"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::IsToBeCleared"); + + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::IsControllerActive"); + + CSELOGSTRING2_HIGH_LEVEL("<< // Represent one schedule in database +#include +#include "CCseSchedulerThreadPacket.h" +#include "CCseSemaphoreController.h" + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerPluginStarter::CCseSchedulerPluginStarter +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCseSchedulerPluginStarter::CCseSchedulerPluginStarter ( CCseSchedulerThreadPacket* aThreadPacket ) : + iThreadPacket( aThreadPacket ), + iPluginRdyToTakedown( EFalse ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginStarter::CCseSchedulerPluginStarter"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::NewL"); + + CCseSchedulerPluginStarter* self = new( ELeave ) CCseSchedulerPluginStarter( aThreadPacket ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::ConstructL"); + + iCompletitionBreaker = CIdle::NewL( CActive::EPriorityLow ); + // Start completition breaker. This time we do not inform about completition of + // plugin but we break call chain and start running plugin from RunL + iCompletitionBreaker->Start(TCallBack( PluginCompleteCallback, this )); + + iSemaphoreMonitor = CCseSemaphoreController::NewL( iThreadPacket->ShutdownSemaphore(), + *this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::~CCseSchedulerPluginStarter"); + + delete iCompletitionBreaker; + delete iPlugin; + iPlugin = NULL; + REComSession::FinalClose(); + + delete iSemaphoreMonitor; + iSemaphoreMonitor = NULL; + + // We DO NOT destroy thread packet, we just null the pointer. + // Information is still needed on other side after thread dies + iThreadPacket = NULL; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::RunPlugin"); + + TInt err( KErrNone ); + + //create cleanupstack + CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack + if (!cleanup) + { + err = KErrNoMemory; + } + if (!err) + { + TRAP(err, DoStartThreadL( aParam )); + } + delete cleanup; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::DoStartThreadL"); + + CCseSchedulerThreadPacket* threadPacket = static_cast(aParam); + + CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler; + + // If schedule doesn't exist there is really nothing we can do + if( scheduler ) + { + CleanupStack::PushL( scheduler ); // |->1 + CActiveScheduler::Install( scheduler ); + + // Create the starter + CCseSchedulerPluginStarter* starter = CCseSchedulerPluginStarter::NewL( threadPacket ); + CleanupStack::PushL(starter); // |->2 + + // Ready to run + CActiveScheduler::Start(); + + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerPluginStarter::DoStartThreadL - Out from CActiveScheduler::Start!"); + + // Cleanup the server and scheduler + CleanupStack::PopAndDestroy( starter ); // 2<-| + CleanupStack::PopAndDestroy( scheduler ); // 1<-| + + threadPacket->ShutdownCompleteSemaphore().Signal(); + } + else + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerPluginStarter::DoStartThreadL - No schedule available, GTFO"); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::RunPluginL"); + + // Create plugin + TUid pluginUid = TUid::Uid( iThreadPacket->Schedule()->PluginUid() ); + + iPlugin = CCseSchedulerPluginIF::NewL( pluginUid ); + + iPlugin->RunTaskL( *iThreadPacket->Schedule(), this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::PluginCompleted - Code: %d", aCompletitionCode); + + // Start taking down The Thread + // Start Completition breaker if not already active to break call chain. + // Set plugin completition value + iThreadPacket->SetResultCode( aCompletitionCode ); + + iPluginRdyToTakedown = ETrue; + + if( !iCompletitionBreaker->IsActive() ) + { + iCompletitionBreaker->Start(TCallBack( PluginCompleteCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerPluginStarter::PluginCompleted:Breaker already running!"); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>PluginCompleteCallback::ScheduleCompleteCallback"); + CSELOGSTRING_HIGH_LEVEL("<<( aPtr )->HandlePluginCompleteCallback(); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerUserInformer::HandlePluginCompleteCallback +// ----------------------------------------------------------------------------- +// +TInt CCseSchedulerPluginStarter::HandlePluginCompleteCallback() + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerPluginStarter::HandleScheduleCompleteCallback "); + + if( iPluginRdyToTakedown ) + { + // First clear flag + iPluginRdyToTakedown = EFalse; + // Takedown thread + CActiveScheduler::Stop(); + } + else + { + // First start monitor + iSemaphoreMonitor->Start(); + // Plugin ready to be run + TRAPD( err, RunPluginL() ); + if ( err != KErrNone ) + { + // Run plugin leaved for some reason. Set error code and get outta here! + iThreadPacket->SetResultCode( err ); + iPluginRdyToTakedown = ETrue; + iCompletitionBreaker->Start(TCallBack( PluginCompleteCallback, this )); + } + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerPluginStarter::SemaphoreSignalled"); + + delete iPlugin; + iPlugin = NULL; + + CActiveScheduler::Stop(); + + CSELOGSTRING_HIGH_LEVEL("<< // Common defines for client and server +#include "CseSchedulerServer.pan" // Server panic codes +#include "CseDebug.h" // Debug macros +#include +#include +#include +#include + + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// Platform security. Custom check is applied to all IPCs. +static const int KRangeCount( 1 ); + +static const TInt SecurityRanges[KRangeCount] = + { + 0, // Range is from 0 to KMaxTInt + }; + +static const TUint8 SecurityRangesPolicy[KRangeCount] = + { + CPolicyServer::ECustomCheck + }; + +static const CPolicyServer::TPolicy Policy = + { + CPolicyServer::EAlwaysPass, + KRangeCount, + SecurityRanges, + SecurityRangesPolicy, + NULL, + }; + + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +const TInt KDbStartTimeout = 2000000; + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerServer::CCseSchedulerServer() +// C++ constructor +// ----------------------------------------------------------------------------- +// +CCseSchedulerServer::CCseSchedulerServer() + : CPolicyServer( EPriorityRealTimeServer, Policy, ESharableSessions ), + iContainerIx( NULL ), + iObjectCon( NULL ), + iSessionCount( 0 ), + iSchedulerEngine( NULL ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerServer::CCseSchedulerServer"); + __DECLARE_NAME( _S( "CCseSchedulerServer" ) ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::NewLC"); + + CCseSchedulerServer* self = new ( ELeave ) CCseSchedulerServer; + CleanupStack::PushL( self ); + + self->ConstructL( ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::ConstructL"); + iContainerIx = CObjectConIx::NewL(); + iObjectCon = iContainerIx->CreateL(); + StartL( KCseSchedulerServerName ); + GetEngineObjectL(); + iStarterBreaker = CPeriodic::NewL( CActive::EPriorityStandard ); + + // break call chain + if( !iStarterBreaker->IsActive() ) + { + // Give client 2 secs to make server session before we check + // if server is needed or not. + iStarterBreaker->Start( KDbStartTimeout, + KDbStartTimeout, + TCallBack( StarterCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServer::ConstructL - Breaker already active"); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::~CCseSchedulerServer"); + DeleteSchedulerEngine(); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::ThreadFunction"); + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + if ( !cleanupStack ) + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerServer::ThreadFunction - Could not create cleanupstack: %d"); + return KErrNone; + } + + TRAPD( err, ThreadFunctionL( ) ); + if ( err ) + { + CSELOGSTRING2_HIGH_LEVEL("CCseSchedulerServer::ThreadFunction - Main thread leaved: %d", err ); + } + + delete cleanupStack; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::ThreadFunctionL"); + + // Construct active scheduler + CActiveScheduler* activeScheduler = new ( ELeave ) CActiveScheduler; + CleanupStack::PushL( activeScheduler ); // |-> 1 + + // Install active scheduler. + // We don't need to check whether an active scheduler is already installed + // as this is a new thread, so there won't be one + CActiveScheduler::Install( activeScheduler ); + + // Construct our server, pushed cleanup stack and leaved there + CCseSchedulerServer* server = CCseSchedulerServer::NewLC( ); // |-> 2 + + // Signal server is up + RProcess::Rendezvous( KErrNone ); + + // Start handling requests + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy( server ); // 2<-| + CleanupStack::PopAndDestroy( activeScheduler ); // 1<-| + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::PanicServer"); + _LIT( KSchedulerServer, "SchedulerServer" ); + User::Panic( KSchedulerServer, aPanic ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::GetEngineObjectL"); + + if ( iObjectCon->Count() == 0 ) + { + // Create scheduler engine + iSchedulerEngine = CCseSchedulerServerEngine::NewL( *this ); + + // Add our engine to container + iObjectCon->AddL( iSchedulerEngine ); + } + else + { + // default implementation return KErrNone. + if ( KErrNone != iSchedulerEngine->Open() ) + { + User::Leave( KErrGeneral ); + } + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::Inc"); + if ( iSessionCount!=KErrNotFound ) + { + iSessionCount++; + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::Dec"); + iSessionCount--; + + if ( iSessionCount<=0 ) + { + StopServer(); + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::DeleteSchedulerEngine"); + + if ( iContainerIx ) + { + if( iObjectCon->Count() > 0 ) + { + iSchedulerEngine->Close(); + } + + iContainerIx->Remove( iObjectCon ); + delete iContainerIx; + iContainerIx = NULL; + iSchedulerEngine = NULL; + } + + if( iStarterBreaker && iStarterBreaker->IsActive() ) + { + iStarterBreaker->Cancel(); + } + delete iStarterBreaker; + iStarterBreaker = NULL; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::NewSessionL"); + + // Check version is ok + TVersion v( KCseServMajorVersionNumber, + KCseServMinorVersionNumber, + KCseServBuildVersionNumber ); + + if ( !User::QueryVersionSupported( v, aVersion ) ) + { + User::Leave( KErrNotSupported ); + } + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::StopServer"); + TBool schedulerActive( iSchedulerEngine->IsSchedulerActive() ); + CSELOGSTRING2_HIGH_LEVEL("CCseSchedulerServer::StopServer - Session count: %d", iSessionCount); + if ( (iSessionCount<=0) && (schedulerActive == EFalse)) + { + CSELOGSTRING_HIGH_LEVEL("CCseSchedulerServer::StopServer - Call ActiveScheduler::Stop()"); + CActiveScheduler::Stop(); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::StartThread"); +#if _DEBUG + __UHEAP_MARK; +#endif + + // Check server not already started + TFindServer findCountServer( KCseSchedulerServerName ); + TFullName name; + if ( findCountServer.Next( name ) == KErrNone ) + { + // Found server already + RProcess::Rendezvous( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::CustomSecurityCheckL"); + TCustomResult retVal ( EFail ); + + // Check the messagge function range + if ( aMsg.Function() > ECseRequestBase && + aMsg.Function() < ECseRequestLast ) + { + + // Check if the client has required capabilities + // From .mmp-file capablity NetworkControl + if( // From .mmp-file following are CAP_SERVER capabilities + ! aMsg.HasCapability(ECapabilityNetworkServices ) || + ! aMsg.HasCapability(ECapabilityLocalServices ) || + ! aMsg.HasCapability(ECapabilityLocation ) || + ! aMsg.HasCapability(ECapabilityReadUserData ) || + ! aMsg.HasCapability(ECapabilityWriteUserData ) || + ! aMsg.HasCapability(ECapabilityReadDeviceData ) || + ! aMsg.HasCapability(ECapabilityWriteDeviceData ) || + ! aMsg.HasCapability(ECapabilityUserEnvironment ) || + ! aMsg.HasCapability(ECapabilitySwEvent ) ) + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerServer::CustomSecurityCheckL() No capability for message %d!!!", + aMsg.Function() ); + } + else + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerServer::CustomSecurityCheckL() Message %d inside range and capabilities ok", + aMsg.Function() ); + retVal = EPass; + } + } + else + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerServer::CustomSecurityCheckL() Message %d outside known range!!!", + aMsg.Function() ); + } + + if( retVal == EPass ) + { + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::StarterCallback"); + TBool retVal( EFalse); + retVal = static_cast( aPtr )->HandleStarterCallback(); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServer::HandleStarterCallback "); + + // We dont want to use periodic anymore, so we cancel it. We just wanted to + // make call here 2 secs after server has been created. + iStarterBreaker->Cancel(); + + // Check if server can be stopped. + iSchedulerEngine->RequestReschedule(); + + CSELOGSTRING_HIGH_LEVEL("<< +#include +#include +#include "CCseSchedulerServerEngine.h" // Common methods for server +#include // Common defines for client and server +#include // Represent one schedule in database +#include "CseDebug.h" // Debug macros +#include "CCseScheduleDB.h" // Schedule database +#include "CCseSchedulerTimer.h" // Schedule timer for determining schedule times +#include // Scheduler plugin interface +#include "CCseSchedulerUniPluginController.h" +#include "CCseSchedulerMultiPluginController.h" +#include "CCseSchedulerServer.h" + + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// CloseEngine +// CB method used if ConstructL leaves. Just calls Close to initiate proper +// shutdown sequence +// ----------------------------------------------------------------------------- +// +void CloseEngine( TAny* aPtr ) + { + static_cast( aPtr )->Close(); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerServerEngine::CCseSchedulerServerEngine +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCseSchedulerServerEngine::CCseSchedulerServerEngine( CCseSchedulerServer& aServer ) : + iServer( aServer ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerServerEngine::CCseSchedulerServerEngine"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::NewL"); + + CCseSchedulerServerEngine* self = new( ELeave ) CCseSchedulerServerEngine( aServer ); + CleanupStack::PushL( TCleanupItem( CloseEngine, self ) ); + self->ConstructL(); + CleanupStack::Pop( ); // CleanupItem + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::ConstructL"); + + iDb = CCseScheduleDB::NewL(); + iCompletitionBreaker = CIdle::NewL( CActive::EPriorityLow ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::~CCseSchedulerServerEngine"); + + delete iDb; + + iPluginControllerArray.ResetAndDestroy(); + iPluginControllerArray.Close(); + delete iCompletitionBreaker; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GeneralService"); + + switch( aMessage.Function() ) + { + case ECseAddSchedule: + { + AddScheduleL( aMessage ); + break; + } + case ECseRemoveSchedule: + { + RemoveScheduleL( aMessage ); + break; + } + case ECseGetSchedules: + { + GetSchedulesL( aMessage ); + break; + } + case ECseGetSchedule: + { + GetScheduleL( aMessage ); + break; + } + case ECseGetScheduleLength: + { + GetScheduleLengthL( aMessage ); + break; + } + case ECseGetSchedulesByAppUid: + { + GetSchedulesByAppUidL( aMessage ); + break; + } + case ECseGetScheduleArrayLengthByAppUid: + { + GetScheduleArrayLengthByAppUidL( aMessage ); + break; + } + case ECseGetOverlappingSchedulesLength: + { + GetOverlappingSchedulesLengthL( aMessage ); + break; + } + case ECseGetOverlappingSchedules: + { + GetOverlappingSchedulesL( aMessage ); + break; + } + case ECseGetScheduleArrayLengthByPluginUid: + { + GetScheduleArrayLengthByPluginUidL( aMessage ); + break; + } + case ECseGetSchedulesByPluginUid: + { + GetSchedulesByPluginUidL( aMessage ); + break; + } + case ECseGetScheduleArrayLengthByType: + { + GetScheduleArrayLengthByTypeL( aMessage ); + break; + } + case ECseGetSchedulesByType: + { + GetSchedulesByTypeL( aMessage ); + break; + } + case ECseGetScheduleArrayLengthByTimeframe: + { + GetScheduleArrayLengthByTimeframeL( aMessage ); + break; + } + case ECseGetSchedulesByTimeframe: + { + GetSchedulesByTimeframeL( aMessage ); + break; + } + + default: + { + aMessage.Complete( KErrNotSupported ); + break; + } + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::PanicClient"); + + // Panic the client on server side + _LIT( KTxtClientFault, "CseSchedulerServer" ); + aMessage.Panic( KTxtClientFault, aPanic ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::AddScheduleL"); + TInt ret( KErrNone ); + TBuf8<4> id; + + // Initialize buffers... + CCseScheduledProgram* schedule = CCseScheduledProgram::NewL(); + CleanupStack::PushL( schedule ); + HBufC8* msg = HBufC8::NewL( aMessage.GetDesLengthL( 0 ) ); + CleanupStack::PushL( msg ); + TPtr8 ptr( msg->Des() ); + + // Read schedule as a stream format to buffer + aMessage.ReadL( 0, ptr, 0 ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( ptr ); + + // Change stream formatted schedule to "CseScheduledProgram"-format + schedule->InternalizeL( readStream ); + + CleanupStack::PopAndDestroy( &readStream ); + + // Add it to DB + iDb->AddScheduleL( *schedule ); + + // Make the completition value + id.FillZ(); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( id ); + writeStream.WriteUint32L( schedule->DbIdentifier() ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + aMessage.WriteL( 1, id, 0 ); + + RescheduleByPluginL( schedule->PluginUid() ); + + CleanupStack::PopAndDestroy( msg ); + CleanupStack::PopAndDestroy( schedule ); + + aMessage.Complete( ret ); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::RemoveScheduleL"); + + TUint32 dbIdentifier( 0 ); + TBuf8<4> idBuff; + TInt32 pluginUid( 0 ); + + idBuff.FillZ(); + + // Read db identifier from aMessager + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + dbIdentifier = readStream.ReadUint32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Remove schedule + // First check the plugin UID of removed schedule + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + iDb->GetScheduleByDbIdentifierL( dbIdentifier, prog ); + pluginUid = prog->PluginUid( ); + // Now remove it from DB + iDb->RemoveScheduleL( dbIdentifier ); + RescheduleByPluginL( pluginUid ); + + // Use completition callback to remove those controllers that aren't needed anymore + if( !iCompletitionBreaker->IsActive() ) + { + iCompletitionBreaker->Start(TCallBack( CompletitionCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::ScheduleCompletedSuccesfully - Breaker already active"); + } + + CleanupStack::PopAndDestroy( prog ); + aMessage.Complete( KErrNone ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleL"); + TUint32 dbIdentifier( 0 ); + TBuf8<4> idBuff; + + idBuff.FillZ(); + + // Read db identifier from aMessage + TInt err( aMessage.Read( 0, idBuff ) ); + + if ( err == KErrNone ) + { + // Create new db identifier to be passed to client + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + dbIdentifier = readStream.ReadUint32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedule + iDb->GetScheduleByDbIdentifierL( dbIdentifier, prog ); + + TInt length( prog->ExternalizeLength() ); + + // Externalize schedule to stream format + HBufC8* retBuff = HBufC8::NewL( length ); + CleanupStack::PushL( retBuff ); + TPtr8 retPtr( retBuff->Des() ); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retPtr ); + prog->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retPtr ) ); + CleanupStack::PopAndDestroy( retBuff ); + CleanupStack::PopAndDestroy( prog ); + } + + aMessage.Complete( err ); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleLengthL"); + TUint32 dbIdentifier( 0 ); + TBuf8<4> idBuff; + TBuf8<4> lenBuff; + TInt length( 0 ); + CCseScheduledProgram* schedule = CCseScheduledProgram::NewL(); + CleanupStack::PushL( schedule ); + idBuff.FillZ(); + + // Read db identifier from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + dbIdentifier = readStream.ReadUint32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedule + iDb->GetScheduleByDbIdentifierL( dbIdentifier, schedule ); + + // Get schedule length + length = schedule->ExternalizeLength(); + + lenBuff.FillZ(); + + // Write length in stream so we can pass it to client + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( lenBuff ); + writeStream.WriteInt32L( length ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, lenBuff ) ); + + CleanupStack::PopAndDestroy( schedule ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleArrayLengthByAppUidL"); + TInt32 appUid( 0 ); + TBuf8<4> idBuff; + TBuf8<4> lenBuff; + TInt length( 0 ); + idBuff.FillZ(); + + // Read application uid from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + appUid = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + iDb->GetApplicationSchedulesL( appUid, progArray ); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length = length + progArray[i]->ExternalizeLength(); + } + CleanupStack::PopAndDestroy( &progArray ); // closes progArray + + lenBuff.FillZ(); + + // Change length value to stream so that we can send it back to client. + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( lenBuff ); + writeStream.WriteInt32L( length ); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, lenBuff ) ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetSchedulesByAppUidL"); + TInt32 appUid( 0 ); + TBuf8<4> idBuff; + idBuff.FillZ(); + TInt32 numberOfElems( 0 ); + TInt length( 0 ); + + // Read application UID from aMessage + TInt err( aMessage.Read( 0, idBuff ) ); + + if ( err == KErrNone ) + { + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + appUid = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + iDb->GetApplicationSchedulesL( appUid, progArray ); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length += progArray[i]->ExternalizeLength(); + } + + // Allocate write stream + HBufC8* retBuff = HBufC8::NewL( length ); + CleanupStack::PushL( retBuff ); + TPtr8 retPtr( retBuff->Des() ); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retPtr ); + + // Fill stream + // Write number elems + numberOfElems = progArray.Count(); + writeStream.WriteInt32L( numberOfElems ); + // Add elems one by one + for ( TInt i = 0; i < progArray.Count(); i++ ) + { + progArray[i]->ExternalizeL( writeStream ); + } + writeStream.CommitL(); + + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retPtr ) ); + + CleanupStack::PopAndDestroy( retBuff ); + CleanupStack::PopAndDestroy( &progArray ); + } + + aMessage.Complete( err ); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetSchedulesL"); + aMessage.Complete( KErrNotSupported ); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerServerEngine::GetOverlappingSchedulesLengthL +// +// ----------------------------------------------------------------------------- +// +void CCseSchedulerServerEngine::GetOverlappingSchedulesLengthL( + const RMessage2& aMessage ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerServerEngine::GetOverlappingSchedulesLengthL"); + TInt32 scheduleType( 0 ); + TBuf8<20> idBuff; + TBuf8 retBuf; // contains length + + TUint32 length( 0 ); + + idBuff.FillZ(); + + // Read schedule type from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + scheduleType = readStream.ReadInt32L(); + + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Read start time from the aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + TInt64 time( 0 ); + time = (TInt64) lower; + TInt64 longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 startTime = time; + + // Read end time from the aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + time = (TInt64) lower; + longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 endTime = time; + + CleanupStack::PopAndDestroy( &readStream ); + + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + + // Get overlapping schedules + iDb->GetOverlappingSchedulesL( scheduleType, startTime, endTime, schedules ); + + // Count length one by one + for ( TInt i = 0; i < schedules.Count(); i++ ) + { + length += schedules[i]->ExternalizeLength(); + } + + CleanupStack::PopAndDestroy( &schedules ); + + retBuf.FillZ(); + + + // Write length to stream so we can pass it to client + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retBuf ); + writeStream.WriteInt32L( length ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retBuf ) ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetOverlappingSchedulesL"); + TInt32 scheduleType( 0 ); + TBuf8<20> idBuff; + + idBuff.FillZ(); + + // Read schedule type from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + scheduleType = readStream.ReadInt32L(); + + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Read start time from aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + TInt64 time( 0 ); + time = (TInt64) lower; + TInt64 longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 startTime = time; + + //Read end time from aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + time = (TInt64) lower; + longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 endTime = time; + + CleanupStack::PopAndDestroy( &readStream ); + + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + + // Get overlapping schedules from database + iDb->GetOverlappingSchedulesL( scheduleType, startTime, endTime, schedules ); + + TUint32 length( 0 ); + + length += sizeof( TInt32 ); // item count added to buffer first + + // Length of the schedules needed for transfer stream + for ( TInt i = 0; i < schedules.Count(); i++ ) + { + length += schedules[i]->ExternalizeLength(); + } + + HBufC8* retBuf = HBufC8::NewLC( length ); + TPtr8 retBufPtr( retBuf->Des() ); + + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retBufPtr ); + // write item count to buffer + writeStream.WriteInt32L( schedules.Count() ); + + // write all items to buffer + for ( TInt j = 0; j < schedules.Count(); j++ ) + { + schedules[j]->ExternalizeL( writeStream ); + } + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retBufPtr ) ); + + CleanupStack::PopAndDestroy( retBuf ); + CleanupStack::PopAndDestroy( &schedules ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::Reschedule"); + + RArray uidArray; + + iDb->GetPluginsL( uidArray ); + + if( uidArray.Count() > 0 ) + { + for(TInt i = 0; i < uidArray.Count(); i++) + { + TTime runTime( iDb->GetNextScheduleTimeByPluginL( uidArray[i] ) ); + + // Search for existing plugin controller for this schedule + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + iDb->GetSchedulesByTimeAndPluginL( runTime, uidArray[i], schedules ); + + if( schedules.Count() > 0 ) + { + TBool controllerFound( EFalse ); + + // Plugin controller might existCheck if the plugin controller already exists. + for( TInt ii = 0; ii < iPluginControllerArray.Count(); ii++ ) + { + if( schedules[0]->PluginUid() == iPluginControllerArray[ii]->PluginUid() ) + { + iPluginControllerArray[ii]->SetSchedulesL( schedules ); + controllerFound = ETrue; + break; + } + } + + // It didn't so we create new one + if( controllerFound == EFalse ) + { + if( schedules[0]->PluginType() == CCseScheduledProgram::ECseUniPlugin ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::Reschedule: Create new uniplugin controller"); + // Create new PluginController + iPluginControllerArray.AppendL( CCseSchedulerUniPluginController::NewL( *this, schedules[0]->PluginUid() ) ); + // Add schedules to just created controller + iPluginControllerArray[iPluginControllerArray.Count()-1]->SetSchedulesL(schedules); + } + else if ( schedules[0]->PluginType() == CCseScheduledProgram::ECseMultiPlugin ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::Reschedule: Create new multiplugin controller"); + // Create new PluginController + iPluginControllerArray.AppendL( CCseSchedulerMultiPluginController::NewL( *this, schedules[0]->PluginUid() ) ); + // Add schedules to just created controller + iPluginControllerArray[iPluginControllerArray.Count()-1]->SetSchedulesL(schedules); + } + else + { + // WTF?!?! + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::Reschedule: Plugin something completely different"); + } + } + } + // Delete schedule array. + CleanupStack::PopAndDestroy( &schedules ); + } + } + + uidArray.Reset(); + uidArray.Close(); + + // Stop server if we dont have any clients and there is no more + // reason for us to live (no schedules active). + iServer.StopServer(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::IsSchedulerActive"); + + TBool ret(EFalse); + + if( iPluginControllerArray.Count() > 0 ) + { + ret = ETrue; + } + + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::Close"); + + while( AccessCount() >= 1 ) + { + Dec(); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleArrayLengthByPluginUidL"); + TInt32 pluginUid( 0 ); + TBuf8<4> idBuff; + TBuf8<4> lenBuff; + TInt length( 0 ); + idBuff.FillZ(); + + // Read application uid from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + pluginUid = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + iDb->GetSchedulesByPluginL( pluginUid, progArray); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length = length + progArray[i]->ExternalizeLength(); + } + CleanupStack::PopAndDestroy( &progArray ); // closes progArray + + lenBuff.FillZ(); + + // Change length value to stream so that we can send it back to client. + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( lenBuff ); + writeStream.WriteInt32L( length ); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, lenBuff ) ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetSchedulesByPluginUidL"); + TInt32 pluginUid( 0 ); + TBuf8<4> idBuff; + idBuff.FillZ(); + TInt32 numberOfElems( 0 ); + TInt length( 0 ); + + // Read application UID from aMessage + TInt err( aMessage.Read( 0, idBuff ) ); + + if ( err == KErrNone ) + { + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + pluginUid = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + iDb->GetSchedulesByPluginL( pluginUid, progArray ); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length += progArray[i]->ExternalizeLength(); + } + + // Allocate write stream + HBufC8* retBuff = HBufC8::NewL( length ); + CleanupStack::PushL( retBuff ); + TPtr8 retPtr( retBuff->Des() ); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retPtr ); + + // Fill stream + // Write number elems + numberOfElems = progArray.Count(); + writeStream.WriteInt32L( numberOfElems ); + // Add elems one by one + for ( TInt i = 0; i < progArray.Count(); i++ ) + { + progArray[i]->ExternalizeL( writeStream ); + } + writeStream.CommitL(); + + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retPtr ) ); + + CleanupStack::PopAndDestroy( retBuff ); + CleanupStack::PopAndDestroy( &progArray ); + } + + aMessage.Complete( err ); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleArrayLengthByTypeL"); + TInt32 type( 0 ); + TBuf8<4> idBuff; + TBuf8<4> lenBuff; + TInt length( 0 ); + idBuff.FillZ(); + + // Read application uid from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + type = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + iDb->GetSchedulesByTypeL( type, progArray); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length = length + progArray[i]->ExternalizeLength(); + } + CleanupStack::PopAndDestroy( &progArray ); // closes progArray + + lenBuff.FillZ(); + + // Change length value to stream so that we can send it back to client. + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( lenBuff ); + writeStream.WriteInt32L( length ); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, lenBuff ) ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetSchedulesByTypeL"); + TInt32 type( 0 ); + TBuf8<4> idBuff; + idBuff.FillZ(); + TInt32 numberOfElems( 0 ); + TInt length( 0 ); + + // Read application UID from aMessage + TInt err( aMessage.Read( 0, idBuff ) ); + + if ( err == KErrNone ) + { + RPointerArray progArray; + CleanupResetAndDestroyPushL( progArray ); + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + type = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + // Get schedules from database + iDb->GetSchedulesByTypeL( type, progArray ); + + // Calculate total length + // Number of items in array + length = length + 4; // Size of TInt32 + // Data from array + for ( TInt i = 0 ; i < progArray.Count(); i++ ) + { + length += progArray[i]->ExternalizeLength(); + } + + // Allocate write stream + HBufC8* retBuff = HBufC8::NewL( length ); + CleanupStack::PushL( retBuff ); + TPtr8 retPtr( retBuff->Des() ); + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retPtr ); + + // Fill stream + // Write number elems + numberOfElems = progArray.Count(); + writeStream.WriteInt32L( numberOfElems ); + // Add elems one by one + for ( TInt i = 0; i < progArray.Count(); i++ ) + { + progArray[i]->ExternalizeL( writeStream ); + } + writeStream.CommitL(); + + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retPtr ) ); + + CleanupStack::PopAndDestroy( retBuff ); + CleanupStack::PopAndDestroy( &progArray ); + } + + aMessage.Complete( err ); + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetScheduleArrayLengthByTimeframeL"); + TBuf8<20> idBuff; + TBuf8 retBuf; // contains length + + TUint32 length( 0 ); + + idBuff.FillZ(); + + // Read schedule type from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Read start time from the aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + TInt64 time( 0 ); + time = (TInt64) lower; + TInt64 longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 beginning = time; + + // Read end time from the aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + time = (TInt64) lower; + longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 end = time; + + CleanupStack::PopAndDestroy( &readStream ); + + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + + // Get overlapping schedules + iDb->GetSchedulesByTimeframeL( beginning, end, schedules ); + + // Count length one by one + for ( TInt i = 0; i < schedules.Count(); i++ ) + { + length += schedules[i]->ExternalizeLength(); + } + + CleanupStack::PopAndDestroy( &schedules ); + + retBuf.FillZ(); + + + // Write length to stream so we can pass it to client + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retBuf ); + writeStream.WriteInt32L( length ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retBuf ) ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::GetSchedulesByTimeframeL"); + TBuf8<20> idBuff; + + idBuff.FillZ(); + + // Read schedule type from aMessage + User::LeaveIfError( aMessage.Read( 0, idBuff ) ); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( idBuff ); + + TUint32 lower( 0 ); + TUint32 upper( 0 ); + + // Read start time from aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + TInt64 time( 0 ); + time = (TInt64) lower; + TInt64 longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 beginning = time; + + //Read end time from aMessage + lower = readStream.ReadUint32L(); + upper = readStream.ReadUint32L(); + time = (TInt64) lower; + longUpper = (TInt64) upper; + longUpper = longUpper << 32; + longUpper &= (0xFFFFFFFF00000000ULL); + time |= longUpper; + TInt64 end = time; + + CleanupStack::PopAndDestroy( &readStream ); + + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + + // Get overlapping schedules from database + iDb->GetSchedulesByTimeframeL( beginning, end, schedules ); + + TUint32 length( 0 ); + + length += sizeof( TInt32 ); // item count added to buffer first + + // Length of the schedules needed for transfer stream + for ( TInt i = 0; i < schedules.Count(); i++ ) + { + length += schedules[i]->ExternalizeLength(); + } + + HBufC8* retBuf = HBufC8::NewLC( length ); + TPtr8 retBufPtr( retBuf->Des() ); + + RDesWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( retBufPtr ); + // write item count to buffer + writeStream.WriteInt32L( schedules.Count() ); + + // write all items to buffer + for ( TInt j = 0; j < schedules.Count(); j++ ) + { + schedules[j]->ExternalizeL( writeStream ); + } + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + User::LeaveIfError( aMessage.Write( 1, retBufPtr ) ); + + CleanupStack::PopAndDestroy( retBuf ); + CleanupStack::PopAndDestroy( &schedules ); + + aMessage.Complete( KErrNone ); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::ScheduleCompletedSuccesfully: aDbIdentifier: %d", + aDbIdentifier); + + TInt32 pluginUid( 0 ); + + // First get the plugin UID of removed schedule + CCseScheduledProgram* prog = CCseScheduledProgram::NewL() ; + CleanupStack::PushL( prog ); + iDb->GetScheduleByDbIdentifierL( aDbIdentifier, prog ); + pluginUid = prog->PluginUid( ); + CleanupStack::PopAndDestroy( prog ); + + // Remove completed schedule from DB + TRAPD( err, iDb->RemoveScheduleL( aDbIdentifier ) ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerServerEngine::ScheduleCompletedSuccesfully - iDb->RemoveScheduleL() LEAVED: %d", + err); + } + + // Reschedule completed plugin + if( pluginUid != 0 ) + { + // We have plugin Uid, reschedule that controller + RescheduleByPluginL( pluginUid ); + } + else + { + // No plugin uid found, reschedule all. + RescheduleL(); + } + + if( !iCompletitionBreaker->IsActive() ) + { + iCompletitionBreaker->Start(TCallBack( CompletitionCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::ScheduleCompletedSuccesfully - Breaker already active"); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::ScheduleCompletedWithError: aDbIdentifier: %d, aError %d", + aDbIdentifier, + aErrorCode); + TInt32 pluginUid( 0 ); + + // First get the plugin UID of removed schedule + CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); + CleanupStack::PushL( prog ); + iDb->GetScheduleByDbIdentifierL( aDbIdentifier, prog ); + pluginUid = prog->PluginUid( ); + CleanupStack::PopAndDestroy( prog ); + + // Something strange happened while executing schedule. Remove it from database. + TRAPD( err, iDb->RemoveScheduleL( aDbIdentifier ) ); + if ( err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( + ">>>CCseSchedulerServerEngine::ScheduleCompletedWithError: iDb->RemoveScheduleL Leaved: %d", + err); + } + + // Reschedule completed plugin + if( pluginUid == 0 ) + { + // We have plugin Uid, reschedule that controller + RescheduleByPluginL( pluginUid ); + } + else + { + // No plugin uid found, reschedule all. + RescheduleL(); + } + +#if CSE_LOGGING_METHOD == 0 + ( void )aErrorCode; +#endif + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::IncreaseScheduleRunCountL: aDbIdentifier: %d", + aDbIdentifier ); + + TRAPD( err, iDb->IncreaseRunCountL( aDbIdentifier ) ); + + if (err != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL( + "CCseSchedulerServerEngine::IncreaseScheduleRunCount - IncreaseRunCount failed: %d. Removing from DB", err); + + // IncreaseRunCount leaved. It is crucial for us that IncreaseRunCount passes. + // We use it to prevent scheduling engine to run certain malicious software. + iDb->RemoveScheduleL( aDbIdentifier ); + } + + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::IsAllowedToRun: aDbIdentifier: %d", + aDbIdentifier ); + + TBool ret( EFalse ); + TInt32 runCount( 0 ); + + TRAPD( err, runCount = iDb->GetRunCountL( aDbIdentifier ) ); + + if ( err == KErrNone && runCount < 3 ) + { + // Set true if check went ok and there is only less than three tries to run schedule + ret = ETrue; + } + + CSELOGSTRING2_HIGH_LEVEL( + "<<>>CCseSchedulerServerEngine::ScheduleNotValid: aDbIdentifier: %d", + aDbIdentifier ); + + TRAP_IGNORE( iDb->RemoveScheduleL( aDbIdentifier ) ); + + CSELOGSTRING_HIGH_LEVEL( + "<<>>CCseSchedulerServerEngine::CompletitionCallback"); + CSELOGSTRING_HIGH_LEVEL("<<( aPtr )->HandleCompletitionCallback(); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerServerEngine::HandleCompletitionCallback +// ----------------------------------------------------------------------------- +// +TInt CCseSchedulerServerEngine::HandleCompletitionCallback() + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerServerEngine::HandleCompletitionCallback "); + + // Reschedule has been made to relevant plugin controllers. + // Go through controllers and remove obsolote ones + for( TInt i = 0; i < iPluginControllerArray.Count(); i++ ) + { + // Do cleanup on controller + iPluginControllerArray[i]->DoCleanUp( ); + + if( iPluginControllerArray[i]->IsObsolete() ) + { + // Delete it and remove from controller array + delete iPluginControllerArray[i]; + iPluginControllerArray.Remove(i); + } + } + + iServer.StopServer(); + + CSELOGSTRING_HIGH_LEVEL("<<>>RequestReschedule::HandleCompletitionCallback "); + + TRAP_IGNORE( RescheduleL() ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::RescheduleByPluginL - Plugin Uid: %d", aPluginUid); + + TTime runTime( iDb->GetNextScheduleTimeByPluginL( aPluginUid ) ); + TBool controllerFound( EFalse ); + + // Search for existing plugin controller for this schedule + RPointerArray schedules; + CleanupResetAndDestroyPushL( schedules ); + iDb->GetSchedulesByTimeAndPluginL( runTime, aPluginUid, schedules ); + + // Search plugin controller that needs rescheduling + for( TInt i = 0; i < iPluginControllerArray.Count(); i++ ) + { + if( aPluginUid == iPluginControllerArray[i]->PluginUid() ) + { + if( schedules.Count() > 0 ) + { + iPluginControllerArray[i]->SetSchedulesL( schedules ); + } + else + { + // Remove controller if controller found but + // there are no schedules for it + + // Check if controller can be removed right away or should it be done + // after callstack breaker + if( iPluginControllerArray[i]->IsControllerActive() ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::RescheduleByPluginL - Plugin found but no schedules, set controller to be removed"); + iPluginControllerArray[i]->SetToBeCleared( ETrue ); + iCompletitionBreaker->Start(TCallBack( CleanerCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::RescheduleByPluginL - Plugin found but no schedules, remove controller"); + delete iPluginControllerArray[i]; + iPluginControllerArray.Remove( i ); + } + } + + controllerFound = ETrue; + break; + } + } + + if( controllerFound == EFalse ) + { + // Create new controller if schedules found + if( schedules.Count() > 0 ) + { + if( schedules[0]->PluginType() == CCseScheduledProgram::ECseUniPlugin ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::RescheduleByPluginL: Create new uniplugin controller"); + // Create new PluginController + iPluginControllerArray.AppendL( CCseSchedulerUniPluginController::NewL( *this, schedules[0]->PluginUid() ) ); + // Add schedules to just created controller + iPluginControllerArray[iPluginControllerArray.Count()-1]->SetSchedulesL(schedules); + } + else if ( schedules[0]->PluginType() == CCseScheduledProgram::ECseMultiPlugin ) + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::RescheduleByPluginL: Create new multiplugin controller"); + // Create new PluginController + iPluginControllerArray.AppendL( CCseSchedulerMultiPluginController::NewL( *this, schedules[0]->PluginUid() ) ); + // Add schedules to just created controller + iPluginControllerArray[iPluginControllerArray.Count()-1]->SetSchedulesL(schedules); + } + else + { + // WTF?!?! + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::RescheduleByPluginL: Plugin something completely different"); + } + } + } + + // Delete schedule array. + CleanupStack::PopAndDestroy( &schedules ); + + // Stop server if we dont have any clients and there is no more + // reason for us to live (no schedules active). + iServer.StopServer(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::ClearingDone"); + + // Use completition callback to remove those controllers that aren't needed anymore + if( !iCompletitionBreaker->IsActive() ) + { + iCompletitionBreaker->Start(TCallBack( CompletitionCallback, this )); + } + else + { + CSELOGSTRING_HIGH_LEVEL( + "CCseSchedulerServerEngine::ClearingDone - Breaker already active"); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::CleanerCallback"); + static_cast( aPtr )->HandleCleanerCallback(); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerEngine::HandleCleanerCallback "); + + // go through plugins and clear + for( TInt i = iPluginControllerArray.Count(); i > 0 ; i--) + { + if( iPluginControllerArray[i-1]->IsToBeCleared() ) + { + // If ClearControllerL -call leaves it means that we couldn't signal + // plugin to take himself down. In such cases we leak memory, but we + // still need to keep going so we do not screw all the rest schedules. + TRAP_IGNORE( iPluginControllerArray[i-1]->ClearControllerL()); + delete iPluginControllerArray[i-1]; + iPluginControllerArray.Remove(i-1); + } + } + + iServer.StopServer(); + + CSELOGSTRING_HIGH_LEVEL("<< // Common defines for client and server +#include "CseDebug.h" // Debug macros + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerSession::CCseSchedulerSession() +// C++ constructor +// ----------------------------------------------------------------------------- +// + +CCseSchedulerServerSession::CCseSchedulerServerSession() : CSession2(), + iResourceCount( 0 ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerServerSession::CCseSchedulerServerSession"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::NewL"); + + CCseSchedulerServerSession* self = new ( ELeave ) CCseSchedulerServerSession(); + CleanupStack::PushL( self ); + self->ConstructL( aServer ); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::ConstructL"); + + if ( aServer ) + { + aServer->Inc(); + } + + // Create new object index + iObjects = CObjectIx::NewL(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::~CCseSchedulerServerSession"); + + delete iObjects; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::ServiceL"); + + switch ( aMessage.Function() ) + { + case ECseServCreateSubSession: + case ECseServCloseSubSession: + case ECseServCloseSession: + { + // "Common messages" + TRAPD( err, DispatchMessageL( aMessage ) ); + aMessage.Complete( err ); + } + break; + + default: + { + // Ok, but must be subsession relative + CCseSchedulerServerEngine* engine = + (CCseSchedulerServerEngine*)iObjects->At( aMessage.Int3() ); + if ( !engine ) + { + aMessage.Complete( KErrBadHandle ); + PanicClient( ECsePanicBadSubSessionHandle ); + } + else + { + // this is the normal route, + // all engine commands go this way + TRAPD( error, engine->GeneralServiceL( aMessage ) ); + if ( error != KErrNone ) + { + CSELOGSTRING2_HIGH_LEVEL("CCseSchedulerServerSession::ServiceL - engine->GeneralServiceL() LEAVED: %d", error); + aMessage.Complete( error ); + } + } + } + break; + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::DispatchMessageL"); + + // Check for session-relative requests + switch ( aMessage.Function() ) + { + case ECseServCreateSubSession: + NewObjectL( aMessage ); + break; + + case ECseServCloseSubSession: + DeleteObject( aMessage.Int3() ); + break; + + case ECseServCloseSession: + Server()->Dec(); + break; + + default: + break; + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::NewObjectL"); + + CObject* obj = Server()->GetEngineObjectL(); + TInt handle( iObjects->AddL( obj ) ); + // Write the handle to client + TPckg handlePckg( handle ); + TRAPD( err, aMessage.WriteL( 3, handlePckg ) ); + + if ( err ) + { + PanicClient( ECsePanicBadRequest ); + return; + } + + // Notch up another resource + iResourceCount++; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::DeleteObject"); + + // Panic if bad handle + CCseSchedulerServerEngine* engine = ( CCseSchedulerServerEngine* )iObjects->At( aHandle ); + if ( !engine ) + { + PanicClient( ECsePanicBadSubSessionHandle ); + } + + iResourceCount--; + // Deletes engine + iObjects->Remove( aHandle ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::CountResources"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::PanicClient"); + + _LIT( KTxtSessionPanic, "SchedulerSession" ); + CSELOGSTRING2_HIGH_LEVEL("CCseSchedulerServerSession::PanicClient - panic code: %d", aPanic); + User::Panic( KTxtSessionPanic, aPanic ); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerSession::PanicClient() +// +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CCseSchedulerServer* CCseSchedulerServerSession::Server() + { + return reinterpret_cast< CCseSchedulerServer* > ( + const_cast< CServer2* > ( CSession2::Server( ) ) ); + } +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/src/CCseSchedulerThreadPacket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/src/CCseSchedulerThreadPacket.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Timer for the notifier* +*/ + + + + +// INCLUDE FILES +#include "CCseSchedulerThreadPacket.h" +#include // Represent one schedule in database +#include +#include "CseDebug.h" // Debug macros + + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + + + +// ============================ MEMBER FUNCTIONS =============================== +// --------------------------------------------------------------------------- +// CCseSchedulerThreadPacket::CCseSchedulerThreadPacket() +// +// --------------------------------------------------------------------------- +CCseSchedulerThreadPacket::CCseSchedulerThreadPacket( ) : + iResultCode( KErrGeneral ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerThreadPacket::CCseSchedulerThreadPacket"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::~CCseSchedulerThreadPacket"); + + delete iSchedule; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::NewL"); + + // Symbian C++ constructor + CCseSchedulerThreadPacket* self = new ( ELeave ) CCseSchedulerThreadPacket(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::ConstructL"); + + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::SetSchedule"); + + delete iSchedule; + iSchedule = NULL; + iSchedule = CCseScheduledProgram::NewL( aData ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::SetResultCode"); + + iResultCode = aResultCode; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::Schedule"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::ResultCode"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::ShutdownSemaphore"); + CSELOGSTRING_HIGH_LEVEL("<<>>ShutdownCompleteSemaphore::ShutdownCompleteSemaphore"); + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerThreadPacket::SetShutdownSemaphore"); + iShutdownSemaphore = aSemaphore; + CSELOGSTRING_HIGH_LEVEL("<<>>ShutdownCompleteSemaphore::SetShutdownCompleteSemaphore"); + iShutdownCompleteSemaphore = aSemaphore; + CSELOGSTRING_HIGH_LEVEL("<< +#include +#include +#include "CseDebug.h" // Debug macros + + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + + + +// ============================ MEMBER FUNCTIONS =============================== +// --------------------------------------------------------------------------- +// CCseSchedulerTimer::CCseSchedulerTimer() +// +// --------------------------------------------------------------------------- +CCseSchedulerTimer::CCseSchedulerTimer( MCseSchedulerTimerObserver* aObserver ) : CTimer( CActive::EPriorityStandard ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerTimer::CCseSchedulerTimer"); + + // C++ default constructor + iObserver = aObserver; + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::~CCseSchedulerTimer"); + Cancel(); + iObserver = NULL; + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::NewL"); + + // Symbian C++ constructor + CCseSchedulerTimer* self = new ( ELeave ) CCseSchedulerTimer(aObserver); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::ConstructL"); + + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::SetTimer"); + + // Just cancel existing and start new one + Cancel(); + AtUTC( aTime ); + +#ifdef _DEBUG + TBuf<100> startTimeBuf; + _LIT( KDateTimeFormat,"CCseSchedulerTimer::SetTimer (UTC): %1%*D/%2%*M/%3%*Y %H:%T:%S.%C#" ); + TRAP_IGNORE( aTime.FormatL( startTimeBuf, KDateTimeFormat ) ); + CSELOGTEXT_HIGH_LEVEL( startTimeBuf ); +#endif // _DEBUG + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::DoCancel"); + + CTimer::DoCancel(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerTimer::RunL, iStatus: %d", iStatus.Int()); + + // Timer has fired. If everything went fine just kick the observer + if ( iStatus.Int() == KErrNone ) + { + iObserver->RunPluginsL(); + } + else + { + // Something went propably wrong, let the observer error handler decide what. + iObserver->TimerErrorL( iStatus.Int() ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerServerSession::RunError: aError = %d", aError ); + // ATM there isn't leaving code in RunL so we just cancel timer if it is active. + Cancel(); + +#if CSE_LOGGING_METHOD == 0 + ( void )aError; +#endif + + // Return KErrNone to avoid crash. + return KErrNone; + } + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/SchedulerServer/src/CCseSchedulerUniPluginController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/SchedulerServer/src/CCseSchedulerUniPluginController.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,395 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for uni plugin controllers* +*/ + + + + + +// INCLUDE FILES +#include "CCseSchedulerUniPluginController.h" +#include "CseDebug.h" // Debug macros +#include "CCseSchedulerPluginStarter.h" +#include "CCseSchedulerLandLord.h" +#include +#include "CCseSchedulerTimer.h" +#include "CCseSchedulerServerEngine.h" + +// EXTERNAL DATA STRUCTURES +// None. + +// EXTERNAL FUNCTION PROTOTYPES +// None. + +// CONSTANTS +// None + +// MACROS +// None. + +// LOCAL CONSTANTS AND MACROS +// None. + +// MODULE DATA STRUCTURES +// None. + +// LOCAL FUNCTION PROTOTYPES +// None. + + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CCseSchedulerUniPluginController::CCseSchedulerUniPluginController +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CCseSchedulerUniPluginController::CCseSchedulerUniPluginController ( + CCseSchedulerServerEngine& aEngine, + TInt32 aPluginUid ) : + CCseSchedulerPluginControllerBase( aEngine, aPluginUid ), + iLandLord( NULL ), + iIsLandLordWorking( EFalse ) + { + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerUniPluginController::CCseSchedulerUniPluginController"); + + CSELOGSTRING_HIGH_LEVEL( + "<<>>CCseSchedulerUniPluginController::NewL"); + + CCseSchedulerUniPluginController* self = + new( ELeave ) CCseSchedulerUniPluginController( aEngine, aPluginUid ); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::ConstructL"); + + CCseSchedulerPluginControllerBase::ConstructL(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::~CCseSchedulerUniPluginController"); + delete iLandLord; + iLandLord = NULL; + CSELOGSTRING_HIGH_LEVEL( + "<<>>CCseSchedulerUniPluginController::RunPluginsL"); + + // Is there something to be run?!? + if(iScheduleArray.Count() >0 ) + { + // Check if there is security reasons for this schedule why this + // schedule shouldn't be run + if( iEngine.IsAllowedToRun( iScheduleArray[0]->DbIdentifier() ) ) + { + // Check if LandLord is still working. If he is, we just fall through + // because schedule will be kicked when current plugin completes + if( iIsLandLordWorking == EFalse ) + { + // When we come here in UniPluginController it means that there isn't any + // threads running on LandLord side. Scrap the old if it exists and create new one. + if ( iLandLord ) + { + delete iLandLord; + iLandLord = NULL; + } + + iLandLord = CCseSchedulerLandLord::NewL( this ); + + iLandLord->SetScheduleL( *iScheduleArray[0] ); + + iEngine.IncreaseScheduleRunCountL( iScheduleArray[0]->DbIdentifier() ); + + iIsLandLordWorking = ETrue; + + iLandLord->RunPluginL(); + } + } + else + { + // Schedule cannot be run anymore due to security reasons + // Signal engine to remove schedule from DB + iEngine.ScheduleNotValid( iScheduleArray[0]->DbIdentifier() ); + + // Remove schedule own list + delete iScheduleArray[0]; + iScheduleArray.Remove( 0 ); + + // Call ourselves again. + RunPluginsL(); + } + } + else + { + // No schedules...!?!? REEEEESCHEDULE!!! + iEngine.RequestReschedule(); + } + + CSELOGSTRING_HIGH_LEVEL("<<& aScheduleArray ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerUniPluginController::SetSchedules"); + + // The aScheduleArray parameter contains schedules which are either before + // or at the same time as the existing ones in the iScheduleArray. + // Just destroy the old ones and replace with new ones. + // Also cancel the timer because the schedule to run may be different + + iScheduleArray.ResetAndDestroy(); + iTimer->Cancel(); + + // Go through all given schedules and copy them our array + for( TInt i = 0; i < aScheduleArray.Count(); i++) + { + CCseScheduledProgram* schedule = + CCseScheduledProgram::NewL(*aScheduleArray[i] ); + CleanupStack::PushL( schedule ); + + iScheduleArray.AppendL( schedule ); + + CleanupStack::Pop( schedule ); + } + + // If we have schedules, set the timer + if (iScheduleArray.Count() > 0 && !iIsLandLordWorking) + { + // All the schedules have same time + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerUniPluginController::SetSchedules"); + } + +// ----------------------------------------------------------------------------- +// CCseSchedulerUniPluginController::ScheduledEventCompleted +// +// ----------------------------------------------------------------------------- +// +void CCseSchedulerUniPluginController::ScheduleCompletedL( const TUint32 aDbIdentifier, + TInt aCompletitionCode ) + { + CSELOGSTRING_HIGH_LEVEL(">>>CCseSchedulerUniPluginController::ScheduleCompletedL"); + + if ( aCompletitionCode == KErrNone ) + { + ScheduleCompletedSuccesfullyL( aDbIdentifier ); + } + else + { + HandleScheduleErrorL( aDbIdentifier, aCompletitionCode ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::ScheduleCompletedSuccesfullyL"); + + // Remove completed schedule from list + for ( TInt i = iScheduleArray.Count(); i > 0; i--) + { + if( iScheduleArray[i-1]->DbIdentifier() == aDbIdentifier ) + { + delete iScheduleArray[i-1]; + iScheduleArray.Remove( i-1 ); + } + } + + // After all this LandLord has finished everything. He may rest now + iIsLandLordWorking = EFalse; + + // Notify engine about completition. + iEngine.ScheduleCompletedSuccesfullyL( aDbIdentifier ); + + // If there is still schedule(s), set timer for it + if( iScheduleArray.Count() > 0 ) + { + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::HandleScheduleErrorL"); + + // Remove completed schedule from list + for ( TInt i = iScheduleArray.Count(); i > 0; i--) + { + if( iScheduleArray[i-1]->DbIdentifier() == aDbIdentifier ) + { + delete iScheduleArray[i-1]; + iScheduleArray.Remove( i-1 ); + } + } + + // After all this LandLord has finished everything. He may rest now + iIsLandLordWorking = EFalse; + + // Here we could try to handle plugin errors. Problem is that scheduler doesn't + // know anything about schedule it is running and so there cannot be tailored + // error handling for each plugin. In the end, we just complete schedule + // to engine with error code (ends up removing schedule from DB). + iEngine.ScheduleCompletedWithErrorL( aDbIdentifier, aCompletitionCode ); + + // If there is still schedule(s), set timer for it + if( iScheduleArray.Count() > 0 ) + { + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::TimerErrorL"); + + if ( aError == KErrAbort ) + { + // System time changed. Make sanity check and start timer again. + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerUniPluginController::TimerErrorL, system time has changed"); + if ( iScheduleArray.Count() > 0 ) + { + TTime now; + now.UniversalTime(); + // Time still in the future + if ( now < iScheduleArray[0]->StartTime() ) + { + iTimer->SetTimer( iScheduleArray[0]->StartTime() ); + } + else + { + // If schedule is in the past let the "normal" route decide when + // it is he's her time to be run + RunPluginsL(); + } + } + return; + } + + if ( aError == KErrUnderflow ) + { + // Scheduled time is in the past, pass it to notifier. It should decide what to do + CSELOGSTRING_HIGH_LEVEL( + ">>>CCseSchedulerServerEngine::TimerErrorL, scheduled time is in the past"); + RunPluginsL(); + return; + } + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::ClearControllerL"); + + iLandLord->ClearL(); + + iScheduleArray.ResetAndDestroy(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSchedulerUniPluginController::IsControllerActive"); + + CSELOGSTRING2_HIGH_LEVEL("<<>>CCseSemaphoreController::CCseSemaphoreController"); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSemaphoreController::~CCseSemaphoreController"); + + Cancel(); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSemaphoreController::NewL"); + + // Symbian C++ constructor + CCseSemaphoreController* self = new ( ELeave ) CCseSemaphoreController( aSemaphore, + aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CSELOGSTRING_HIGH_LEVEL("<<>>CCseSemaphoreController::ConstructL"); + + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + + CSELOGSTRING_HIGH_LEVEL("<< + +#include "../SchedulerClient/group/bld.inf" +#include "../SchedulerServer/group/bld.inf" + +PRJ_EXPORTS + +PRJ_MMPFILES + diff -r 826cea16efd9 -r 13a33d82ad98 videoscheduler/inc/CseDebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoscheduler/inc/CseDebug.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,321 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef CSEDEBUG_H +#define CSEDEBUG_H + +#include + + + +// Define logging level here + +// Minimum log output +#define CSE_HIGH_LEVEL_TRACES + +#define CSE_MIDDLE_LEVEL_TRACES + +// Maximum log output +#define CSE_LOW_LEVEL_TRACES + + + + +/* +----------------------------------------------------------------------------- + + LOGGING MACROs + + USE THESE MACROS IN YOUR CODE + + Usage: + + Example: CSELOGSTRING_HIGH_LEVEL ("Test"); + Example: CSELOGSTRING2_HIGH_LEVEL ("Test %d", aValue); + Example: CSELOGSTRING3_HIGH_LEVEL ("Test %d %d", aValue1, aValue2); + Example: CSELOGSTRING4_HIGH_LEVEL ("Test %d %d %d", aValue1, aValue2, aValue3); + + Example: CSE_LOG_STR_DESC_HIGH_LEVEL (own_desc); + Example: CSE_LOG_STR_DESC2_HIGH_LEVEL (own_desc, aValue)); + Example: CSE_LOG_STR_DESC3_HIGH_LEVEL (own_desc, aValue, aValue2); + Example: CSE_LOG_STR_DESC4_HIGH_LEVEL (own_desc, aValue, aValue2, aValue3); + +----------------------------------------------------------------------------- +*/ + + + +#ifdef CSE_HIGH_LEVEL_TRACES + +#define CSELOGTEXT_HIGH_LEVEL(AAAA) CSE_LOGTEXT(AAAA) +#define CSELOGSTRING_HIGH_LEVEL(AAAA) CSE_LOGSTRING(AAAA) +#define CSELOGSTRING2_HIGH_LEVEL(AAAA,BBBB) CSE_LOGSTRING2(AAAA,BBBB) +#define CSELOGSTRING3_HIGH_LEVEL(AAAA,BBBB,CCCC) CSE_LOGSTRING3(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOGSTRING4(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_HIGH_LEVEL(AAAA) CSE_LOG_STR_DESC(AAAA) +#define CSE_LOG_STR_DESC2_HIGH_LEVEL(AAAA,BBBB) CSE_LOG_STR_DESC2(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_HIGH_LEVEL(AAAA,BBBB,CCCC) CSE_LOG_STR_DESC3(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) + +#else + +#define CSELOGTEXT_HIGH_LEVEL(AAAA) +#define CSELOGSTRING_HIGH_LEVEL(AAAA) +#define CSELOGSTRING2_HIGH_LEVEL(AAAA,BBBB) +#define CSELOGSTRING3_HIGH_LEVEL(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_HIGH_LEVEL(AAAA) +#define CSE_LOG_STR_DESC2_HIGH_LEVEL(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_HIGH_LEVEL(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_HIGH_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#endif + + +#ifdef CSE_MIDDLE_LEVEL_TRACES +#define CSELOGSTRING_MIDDLE_LEVEL(AAAA) CSE_LOGSTRING(AAAA) +#define CSELOGSTRING2_MIDDLE_LEVEL(AAAA,BBBB) CSE_LOGSTRING2(AAAA,BBBB) +#define CSELOGSTRING3_MIDDLE_LEVEL(AAAA,BBBB,CCCC) CSE_LOGSTRING3(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOGSTRING4(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_MIDDLE_LEVEL(AAAA) CSE_LOG_STR_DESC(AAAA) +#define CSE_LOG_STR_DESC2_MIDDLE_LEVEL(AAAA,BBBB) CSE_LOG_STR_DESC2(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_MIDDLE_LEVEL(AAAA,BBBB,CCCC) CSE_LOG_STR_DESC3(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) + +#else + +#define CSELOGSTRING_MIDDLE_LEVEL(AAAA) +#define CSELOGSTRING2_MIDDLE_LEVEL(AAAA,BBBB) +#define CSELOGSTRING3_MIDDLE_LEVEL(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_MIDDLE_LEVEL(AAAA) +#define CSE_LOG_STR_DESC2_MIDDLE_LEVEL(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_MIDDLE_LEVEL(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_MIDDLE_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#endif + + +#ifdef CSE_LOW_LEVEL_TRACES + +#define CSELOGTEXT_LOW_LEVEL(AAAA) CSE_LOGTEXT(AAAA) +#define CSELOGSTRING_LOW_LEVEL(AAAA) CSE_LOGSTRING(AAAA) +#define CSELOGSTRING2_LOW_LEVEL(AAAA,BBBB) CSE_LOGSTRING2(AAAA,BBBB) +#define CSELOGSTRING3_LOW_LEVEL(AAAA,BBBB,CCCC) CSE_LOGSTRING3(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOGSTRING4(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_LOW_LEVEL(AAAA) CSE_LOG_STR_DESC(AAAA) +#define CSE_LOG_STR_DESC2_LOW_LEVEL(AAAA,BBBB) CSE_LOG_STR_DESC2(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_LOW_LEVEL(AAAA,BBBB,CCCC) CSE_LOG_STR_DESC3(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD) CSE_LOG_STR_DESC4(AAAA,BBBB,CCCC,DDDD) + +#else + +#define CSELOGTEXT_LOW_LEVEL(AAAA) +#define CSELOGSTRING_LOW_LEVEL(AAAA) +#define CSELOGSTRING2_LOW_LEVEL(AAAA,BBBB) +#define CSELOGSTRING3_LOW_LEVEL(AAAA,BBBB,CCCC) +#define CSELOGSTRING4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#define CSE_LOG_STR_DESC_LOW_LEVEL(AAAA) +#define CSE_LOG_STR_DESC2_LOW_LEVEL(AAAA,BBBB) +#define CSE_LOG_STR_DESC3_LOW_LEVEL(AAAA,BBBB,CCCC) +#define CSE_LOG_STR_DESC4_LOW_LEVEL(AAAA,BBBB,CCCC,DDDD) + +#endif + + + +/* +----------------------------------------------------------------------------- + + LOG SELECTION + +----------------------------------------------------------------------------- +*/ + +// 0 = No logging, +// 1 = Flogger, +// 2 = RDebug + + +#ifndef _DEBUG + +// UREL BUILD: +#define CSE_LOGGING_METHOD 0 // No logging in UREL builds + +#else // urel + + + +#ifdef __WINSCW__ + +// WINSCW BUILD: +#define CSE_LOGGING_METHOD 2 // RDebug is default with emulator + +#else + +// ARMV5 BUILD: +#define CSE_LOGGING_METHOD 1 // Flogger is default with target device + +#endif + + + +#endif // _DEBUG + + + + +/* +----------------------------------------------------------------------------- + + LOG SETTINGS + +----------------------------------------------------------------------------- +*/ + +#if CSE_LOGGING_METHOD == 1 // Flogger + +#include +_LIT(KCSELogFolder,"CSE"); +_LIT(KCSELogFile,"CSELOG.TXT"); + +#elif CSE_LOGGING_METHOD == 2 // RDebug + +#include + +#endif + + + + + +#if CSE_LOGGING_METHOD == 1 // Flogger + + +#define CSE_LOGTEXT(AAA) RFileLogger::Write(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend, AAA) + +#define CSE_LOG_STR_DESC(AAA) RFileLogger::Write(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend, AAA) +#define CSE_LOG_STR_DESC2(AAA,BBB) do { RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(AAA()),BBB); } while (0) +#define CSE_LOG_STR_DESC3(AAA,BBB,CCC) do { RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(AAA()),BBB,CCC); } while (0) +#define CSE_LOG_STR_DESC4(AAA,BBB,CCC,DDD) do { RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(AAA()),BBB,CCC,DDD); } while (0) + +#define CSE_LOGSTRING(AAA) do { _LIT(tempCSELogDes,AAA); RFileLogger::Write(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,tempCSELogDes()); } while (0) +#define CSE_LOGSTRING2(AAA,BBB) do { _LIT(tempCSELogDes,AAA); RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(tempCSELogDes()),BBB); } while (0) +#define CSE_LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempCSELogDes,AAA); RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(tempCSELogDes()),BBB,CCC); } while (0) +#define CSE_LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempCSELogDes,AAA); RFileLogger::WriteFormat(KCSELogFolder(),KCSELogFile(),EFileLoggingModeAppend,TRefByValue(tempCSELogDes()),BBB,CCC,DDD); } while (0) + +// Time stamp +_LIT(KCseLogTimeFormatString, "CSE TIMESTAMP: %H:%T:%S:%*C3"); +#define CSE_LOGSTRING_TIMESTAMP { \ + TTime logTime; \ + logTime.HomeTime(); \ + TBuf<256> logBuffer; \ + logTime.FormatL(logBuffer, KCseLogTimeFormatString); \ + RFileLogger::Write(KCSELogFolder(), KCSELogFile(), EFileLoggingModeAppend, logBuffer); \ + } + +// Memory stamp +_LIT(KCseLogMemoryStampString, "CSE MEMORYSTAMP: %d KB"); +#define CSE_LOGSTRING_MEMORYSTAMP { \ + User::CompressAllHeaps(); \ + TMemoryInfoV1Buf logMemory; \ + UserHal::MemoryInfo(logMemory); \ + TInt logMemoryInt = (TInt)(logMemory().iFreeRamInBytes); \ + TBuf<256> logMemoryStr; \ + logMemoryStr.Format(KCseLogMemoryStampString, (logMemoryInt / 1024) ); \ + RFileLogger::Write(KCSELogFolder(), KCSELogFile(), EFileLoggingModeAppend, logMemoryStr); \ + } + + +#elif CSE_LOGGING_METHOD == 2 // RDebug + + +#define CSE_LOGTEXT(AAA) RDebug::Print(AAA) + +#define CSE_LOG_STR_DESC(AAA) RDebug::Print(AAA) +#define CSE_LOG_STR_DESC2(AAA,BBB) do { RDebug::Print(AAA, BBB); } while (0) +#define CSE_LOG_STR_DESC3(AAA,BBB,CCC) do { RDebug::Print(AAA, BBB, CCC); } while (0) +#define CSE_LOG_STR_DESC4(AAA,BBB,CCC,DDD) do { RDebug::Print(AAA, BBB, CCC, DDD); } while (0) + +#define CSE_LOGSTRING(AAA) do { _LIT(tempCSELogDes,AAA); RDebug::Print(tempCSELogDes); } while (0) +#define CSE_LOGSTRING2(AAA,BBB) do { _LIT(tempCSELogDes,AAA); RDebug::Print(tempCSELogDes, BBB); } while (0) +#define CSE_LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempCSELogDes,AAA); RDebug::Print(tempCSELogDes, BBB, CCC); } while (0) +#define CSE_LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempCSELogDes,AAA); RDebug::Print(tempCSELogDes, BBB, CCC, DDD); } while (0) + +// Time stamp +_LIT(KCseLogTimeFormatString, "CSE TIMESTAMP: %H:%T:%S:%*C3"); +#define CSE_LOGSTRING_TIMESTAMP { \ + TTime logTime; \ + logTime.HomeTime(); \ + TBuf<256> logBuffer; \ + logTime.FormatL(logBuffer, KCseLogTimeFormatString); \ + RDebug::Print(logBuffer); \ + } + +// Memory stamp +_LIT(KCseLogMemoryStampString, "CSE MEMORYSTAMP: %d KB"); +#define CSE_LOGSTRING_MEMORYSTAMP { \ + User::CompressAllHeaps(); \ + TMemoryInfoV1Buf logMemory; \ + UserHal::MemoryInfo(logMemory); \ + TInt logMemoryInt = (TInt)(logMemory().iFreeRamInBytes); \ + TBuf<256> logMemoryStr; \ + logMemoryStr.Format(KCseLogMemoryStampString, (logMemoryInt / 1024) ); \ + RDebug::Print(logMemoryStr); \ + } + + +#else // TF_LOGGING_METHOD == 0 or invalid + + +#define CSE_LOGSTRING(AAA) +#define CSE_LOGSTRING2(AAA,BBB) +#define CSE_LOGSTRING3(AAA,BBB,CCC) +#define CSE_LOGSTRING4(AAA,BBB,CCC,DDD) + +#define CSE_LOGTEXT(AAA) + +#define CSE_LOG_STR_DESC(AAA) +#define CSE_LOG_STR_DESC2(AAA,BBB) +#define CSE_LOG_STR_DESC3(AAA,BBB,CCC) +#define CSE_LOG_STR_DESC4(AAA,BBB,CCC,DDD) + +#define CSE_LOGSTRING_TIMESTAMP +#define CSE_LOGSTRING_MEMORYSTAMP + + +#endif // TF_LOGGING_METHOD + + + + + + + +#endif // CSEDEBUG_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils.pro --- a/videoutils.pro Tue Aug 31 16:13:59 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -# -# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: Definitions for video type* -# - -TEMPLATE = subdirs -CONFIG += ordered -symbian: { -BLD_INF_RULES.prj_mmpfiles += $$LITERAL_HASH"include \"videoutils_plat/videoplayer_constants_api/group/bld.inf\"" -} diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/dvrengine_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/dvrengine_api.metaxml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,17 @@ + + +DVR Engine API +DVR Engine API is used for RTSP streaming and RTP file playback. +C++ +videoserviceutils + + + + + + + +no +no + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common recording engine domain api* +*/ + + + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +// CommonRecordingEngineClient +../inc/ipvideo/CRTypeDefs.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRTypeDefs.h ) +../inc/ipvideo/CCRDvrApi.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCRDvrApi.h ) +../inc/ipvideo/CCRAPIBase.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCRApiBase.h ) +../inc/ipvideo/MCREngineObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MCREngineObserver.h ) + +// DvrSdpParser +../inc/ipvideo/CDvrSdpParser.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CDvrSdpParser.h ) + +// DvrRtpClipHandler +../inc/ipvideo/CRtpFileBase.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpFileBase.h ) +../inc/ipvideo/CRtpFileBase.inl MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpFileBase.inl ) +../inc/ipvideo/CRtpClipManager.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpClipManager.h ) +../inc/ipvideo/CRtpClipHandler.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpClipHandler.h ) +../inc/ipvideo/CRtpClipHandler.inl MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpClipHandler.inl ) +../inc/ipvideo/MRtpClipRepairObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MRtpClipRepairObserver.h ) +../inc/ipvideo/MRtpFileObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MRtpFileObserver.h ) +../inc/ipvideo/MRtpFileWriteObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MRtpFileWriteObserver.h ) +../inc/ipvideo/MRtpFileReadObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MRtpFileReadObserver.h ) +../inc/ipvideo/CRtpMetaHeader.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpMetaHeader.h ) + +// DvrRtpUtils +../inc/ipvideo/CRtpUtil.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CRtpUtil.h ) + + + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CCRAPIBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CCRAPIBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Common recording engine, common part* +*/ + + + + +#ifndef CCRAPIBASE_H +#define CCRAPIBASE_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRServerHandleSingleton; + +// CLASS DECLARATION + +/** +* General client api base class that all API classes in +* common recording engine API implementations need to inherit. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +NONSHARABLE_CLASS( CCRApiBase ) : public CBase + { + +protected: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCRApiBase(); + + /** + * Destructor. + * @return None. + */ + virtual ~CCRApiBase(); + + /** + * Symbian 2nd phase constructor can leave. + */ + void BaseConstructL(); + +protected: // data + + CCRServerHandleSingleton* iSingleton; + + }; + +#endif // CCRAPIBASE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CCRDvrApi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CCRDvrApi.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,315 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Common recording engine, the part of API* +*/ + + + + +#ifndef CCRDVRAPI_H +#define CCRDVRAPI_H + +// INCLUDES +#include +#include +#include + +// CONSTANTS +const TReal KRealZero( 0.0 ); +const TReal KRealMinusOne( -1.0 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CCRMsgQueueObserver; +class MCREngineObserver; + +// CLASS DECLARATION + +/** +* Ip-LiveTV-specific client api that manages service functionality. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +class CCRDvrApi : public CCRApiBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CCRDvrApi* NewL( MCREngineObserver *aObserver ); + + /** + * Two-phased constructor. + */ + IMPORT_C static CCRDvrApi* NewL(); + + /** + * Destructor. + * @return None. + */ + IMPORT_C virtual ~CCRDvrApi(); + +public: // New methods + + /** + * Tells receiving engine which IAP to use + * @since Series 60 3.0 + * @param aIapId is handle to RConnection that is already open. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt SetIap( const TSubConnectionUniqueId& aIapId ); + + /** + * Tells receiving engine to cancel IAP selection. + * @since Series 60 3.0 + * @param none. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt CancelSetIap(); + + /** + * Prepares RTSP stream for player. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspUrl is set of parameters required for rtsp. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayRtspUrl( TUint& aSessionChk, + const SCRRtspParams& aRtspUrl ); + + /** + * Prepares DVB-H live stream for player. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams is set of parameters required for DVB-H. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayDvbhStream( TUint& aSessionChk, + const SCRLiveParams& aLiveParams ); + + /** + * Changes DVB-H service of live streaming. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams is set of parameters required for DVB-H. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt ChangeDvbhService( TUint& aSessionChk, + const SCRLiveParams& aLiveParams ); + + /** + * Prepares RTP clip stream for player. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtpFile is set of parameters required for rtsp. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayRtpFile( TUint& aSessionChk, + const SCRRtpPlayParams& aRtpFile ); + + /** + * Prepares RTP clip stream for player. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtpHandle a open file handle for RTP file. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayRtpFile( TUint& aSessionChk, + const RFile& aRtpHandle ); + + /** + * Starts recording for currently active stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRecordParams a parameters for recording. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt RecordCurrentStream( const TUint aSessionChk, + const SCRRecordParams& aRecordParams ); + + /** + * Starts recording for RTSP live stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspUrl is set of parameters required for rtsp. + * @param aRecordParams a parameters for recording. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt RecordRtspStream( TUint& aSessionChk, + const SCRRtspParams& aRtspUrl, + const SCRRecordParams& aRecordParams ); + + /** + * Starts recording for DVB-H live stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aLiveParams is set of parameters required for DVB-H. + * @param aRecordParams a parameters for recording. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt RecordDvbhStream( TUint& aSessionChk, + const SCRLiveParams& aLiveParams, + const SCRRecordParams& aRecordParams ); + + /** + * Pauses/Resumes recording of wanted stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aStart a start or end pausing. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PauseRecordStream( const TUint aSessionChk, + const TBool& aStart ); + + /** + * Stops recording of wanted stream. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt StopRecordStream( const TUint aSessionChk ); + + /** + * Starts time shifting for wanted stream. + * @since Series 60 3.0 + * @param aTimeShiftChk a session definition checksum. + * @param aCurrentChk a session definition of existing session. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt StartTimeShift( TUint& aTimeShiftChk, + const TUint aCurrentChk ); + + /** + * Stops time shifting mode. + * @since Series 60 3.0 + * @param aTimeShiftChk a session definition checksum. + * @param aCurrentChk a session definition of existing session. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt StopTimeShift( const TUint aTimeShiftChk, + const TUint aCurrentChk ); + + /** + * Method for ordering "play" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aStartPos is start position in seconds. + * @param aEndPos is end position in seconds. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayCommand( const TUint aSessionChk, + const TReal aStartPos = KRealMinusOne, + const TReal aEndPos = KRealMinusOne ); + + /** + * Method for ordering "pause" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PauseCommand( const TUint aSessionChk ); + + /** + * Method for ordering "stop" for packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt StopCommand( const TUint aSessionChk ); + + /** + * Setter for play position of packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aPosition a postion of RTP playback. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt SetPosition( const TUint aSessionChk, + const TInt64 aPosition ); + + /** + * Getter for play position of packet source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aPosition a postion of RTP playback. + * @param aDuration a duration of RTP clip. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt GetPosition( const TUint aSessionChk, + TInt64& aPosition, + TInt64& aDuration ); + + /** + * Method for ordering closing a source and all sinks. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt CloseSession( const TUint aSessionChk ); + + /** + * Prepares rtp file playing as a live source. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayNullSource( TUint& aSessionChk ); + + /** + * Prepares rtsp stream for null sink. + * @since Series 60 3.0 + * @param aSessionChk a session definition checksum. + * @param aRtspUrl is set of parameters required for rtsp + * @return KErrNone if ok, otherwise system-wide error codes. + */ + IMPORT_C TInt PlayRtspUrlToNullSink( TUint& aSessionChk, + const SCRRtspParams& aRtspUrl ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCRDvrApi(); + + /** + * Symbian 2nd phase constructor can leave. + */ + void ConstructL( MCREngineObserver *aObserver ); + + /** + * Symbian 2nd phase constructor can leave. + */ + void ConstructL(); + +private: // Data + + /** + * Queue observer. + */ + CCRMsgQueueObserver* iQueueObserver; + + }; + +#endif // CCRDVRAPI_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CDvrSdpParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CDvrSdpParser.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,671 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for parsing a SDP.* +*/ + + + + +#ifndef CDVRSDPPARSER_H +#define CDVRSDPPARSER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Class that parses SDP. Not fully but enough to set up a +* rtp stream from rtsp based on information extracted by this class. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CDvrSdpParser : public CBase + { + +public: // Data types + + /** + * Enum for indicating contents of the rtp stream(s). + */ + enum TDvrPacketProvidings + { + EDvrAudioOnly = 0, /**< This packet source feeds only audio stream */ + EDvrVideoOnly, /**< This packet source feeds only video stream */ + EDvrBothAudioAndVideo, /**< This packet source feeds audio and video */ + EDvrNoProgramAtAll, /**< Nothing useful found */ + EDvrSourceCount /**< Final number of different sources */ + }; + + /** + * Defines media point struct. + */ + struct SMediaPoint + { + /* + * Start point of media in SDP. + */ + TInt iStart; + + /* + * Length in bytes of media in SDP. + */ + TInt iLength; + + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CDvrSdpParser pointer to CDvrSdpParser class. + */ + IMPORT_C static CDvrSdpParser* NewL(); + + /** + * Two-phased constructor. + */ + IMPORT_C static CDvrSdpParser* NewLC(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CDvrSdpParser(); + +public: // New functions + + /** + * Method that is used to give SDP to this class. + * "PLAY rtsp://vishnu.wipsl.com/oops/winter_fun.mp4/ RTSP/1.0\r\n..." + * @since Series 60 3.0 + * @param aSDP is the SDP data. + * @param aBaseUrl is the rtsp url used to fetch this sdp. + * If it is not available, a (NULL,0) descriptor needs to be passed. + * It will be used to construct media urls in case where there is no + * absolute media urls in the sdp. + * @return none. + */ + IMPORT_C void TryParseL( const TDesC8 &aSdp , + const TDesC8 &aBaseUrl ); + + /** + * Parses SDP file. + * @since Series 60 3.0 + * @param aSDP is the SDP data. + * @return none. + */ + IMPORT_C void TryParseL( const TDesC8& aSdp ); + + /** + * Method for adding new SDP line. + * @since Series 60 3.0 + * @param aStreamId a section where to add the string. + * KErrNotFound: common part + * 0 (usually) : video + * 1 (usually) : audio + * 2 (usually) : subtitle (not supported yet) + * @param aLine a string to add. + * @rerturn a system wide error code. + */ + IMPORT_C void NewLineL( const TInt aStreamId, + const TDesC8& aLine ); + + /** + * Method for getting SDP data. + * @since Series 60 3.0 + * @param aSdp a pointer to SDP data. + * @rerturn KErrNone if SDP available, otherwise KErrNotFound. + */ + IMPORT_C TInt GetSdp( TPtrC8& aSdp ); + + /** + * Method for asking whether audio and/or video is included. + * @since Series 60 3.0 + * @param none. + * @return indication about stream contents. + */ + IMPORT_C CDvrSdpParser::TDvrPacketProvidings SupportedContent( void ); + + /** + * Method for getting attributes related to session. + * @since Series 60 3.0 + * @param none. + * @rerturn array of strings, may be empty. + */ + IMPORT_C RArray& SessionAttributes( void ); + + /** + * Method for getting attributes related to session. + * @since Series 60 3.0 + * @param none. + * @rerturn array of strings, may be empty. + */ + IMPORT_C RArray& VideoAttributes( void ); + + /** + * Method for getting attributes related to session. + * @since Series 60 3.0 + * @param none. + * @rerturn array of strings, may be empty. + */ + IMPORT_C RArray& AudioAttributes( void ); + + /** + * Method for getting all data streams related to session. + * @since Series 60 3.0 + * @param none. + * @rerturn array of strings, may be empty. + */ + IMPORT_C RArray& DataStreams( void ); + + /** + * Method for getting Ipv6 of the SDP having been parsed. + * @since Series 60 3.0 + * @param none. + * @return ETrue if SDP had Ipv6 address in it. + */ + IMPORT_C TBool IsIpv4Sdp( void ); + + /** + * Method for getting multicastness of the SDP having been parsed. + * @since Series 60 3.0 + * @param none. + * @return ETrue if SDP had multicast characteristics in it. + */ + IMPORT_C TBool IsMultiCastSdp( void ); + + /** + * Method for getting audio control addr e.g. the text from sdp line + * that begins with a=control: and is located in audio media block + * @since Series 60 3.0 + * @param none. + * @return a audio control addr. + */ + IMPORT_C TPtrC8 AudioControlAddr( void ); + + /** + * Method for getting video control addr e.g. the text from sdp line + * that begins with a=control: and is located in video media block + * @since Series 60 3.0 + * @param none. + * @return a video control addr. + */ + IMPORT_C TPtrC8 VideoControlAddr( void ); + + /** + * Method for getting audio ip addr e.g. the text from sdp line + * that begins with c=IN IP... : and is located in audio media block + * @since Series 60 3.0 + * @param none. + * @return video control addr. ownership is NOT transferred. may be NULL. + */ + IMPORT_C TPtrC8 AudioIpAddr( void ); + + /** + * Method for getting video ip addr e.g. the text from sdp line + * that begins with c=IN IP... : and is located in video media block + * @since Series 60 3.0 + * @param none. + * @return video control addr. ownership is NOT transferred. may be NULL. + */ + IMPORT_C TPtrC8 VideoIpAddr( void ); + + /** + * Getter for audio port. + * @since Series 60 3.0 + * @param none. + * @return a audio port number. + */ + IMPORT_C TInt AudioPort( void ); + + /** + * Getter for video port. + * @since Series 60 3.0 + * @param none. + * @return a video port number. + */ + IMPORT_C TInt VideoPort( void ); + + /** + * Getter for audio bitrate. + * @since Series 60 3.0 + * @param none. + * @return a audio bit rate. + */ + IMPORT_C TInt AudioBitrate( void ); + + /** + * Getter for video bitrate. + * @since Series 60 3.0 + * @param none. + * @return a video bit rate. + */ + IMPORT_C TInt VideoBitrate( void ); + + /** + * Getter for audio stream id. + * @since Series 60 3.0 + * @param none. + * @return a audio stream id. + */ + IMPORT_C TInt AudioStreamId( void ); + + /** + * Getter for video stream id. + * @since Series 60 3.0 + * @param none. + * @return a video stream id. + */ + IMPORT_C TInt VideoStreamId( void ); + + /** + * Getter for video timer granularity + * @since Series 60 3.0 + * @param none. + * @return Video stream timestamp granularity as 1/s. + */ + IMPORT_C TUint32 VideoTimerGranularity( void ); + + /** + * Getter for audio timer granularity + * @since Series 60 3.0 + * @param none. + * @return Audio stream timestamp granularity as 1/s. + */ + IMPORT_C TUint32 AudioTimerGranularity( void ); + + /** + * Checker method for SDP representing realnetworks realmedia content + * @since Series 60 3.0 + * @param none. + * @return ETrue if sdp presents realmedia stream. + */ + IMPORT_C TBool IsRealMediaContent( void ); + + /** + * Media identifier for audio. From a=rtpmap:96 H264/90000 + * the number 96. Usually value is 96 for video and + * 97 for audio but might be other + * @since Series 60 3.0 + * @param none. + * @return Media id + */ + IMPORT_C TInt MediaIdentifierAudio( void ); + /** + * Media identifier for video. From a=rtpmap:96 H264/90000 + * the number 96. Usually value is 96 for video and + * 97 for audio but might be other + * @since Series 60 3.0 + * @param none. + * @return Media id. + */ + IMPORT_C TInt MediaIdentifierVideo( void ); + + /** + * Checker method for SDP representing livestream. + * @since Series 60 3.0 + * @param none. + * @return ETrue if sdp presents livestream. + */ + IMPORT_C TBool IsLiveStream( void ); + +protected: // Constructors and destructor + + /** + * C++ default constructor. + */ + CDvrSdpParser(); + + /** + * By default Symbian 2nd phase constructor is private. + * @param a a reference to socket server . + */ + void ConstructL(); + +private: // New methods + + /** + * Finds media(s) from SDP file. + * @since Series 60 3.0 + * @param aSDP is the SDP data. + * @return none. + */ + void FindMediasL( const TDesC8& aSdp ); + + /** + * Finds media(s) from SDP file. + * @since Series 60 3.0 + * @param aPoints a array for media points. + * @return none. + */ + void MakeMediaBuffersL( RArray& aPoints ); + + /** + * Finds session attributes from SDP file. + * @since Series 60 3.0 + * @param aPoints a array for media points. + * @return none. + */ + void FindSessionAttributesL( RArray& aPoints ); + + /** + * Finds media(s) from SDP file. + * @since Series 60 3.0 + * @param aStreamId a section where to add the string. + * @param aLine a string to add. + * @return none. + */ + void InserNewLineL( TInt aStreamId, + const TDesC8& aLine ); + + /** + * Method for finding points of medias in SDP. + * @since Series 60 3.0 + * @param aPoints a array for media points. + * @rerturn none. + */ + void FindMediaPointsL( RArray& aPoints ); + + /** + * Method for finding next media section start in SDP. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @rerturn a next media section start point. + */ + TInt MediaSectionStart( const TDesC8& aPtr ); + + /** + * Append media info from media section to array. + * @since Series 60 3.0 + * @param aMediaPtr a pointer to buffer of media section. + * @param aAddress a IP address of media. + * @return none. + */ + void UpdateMediaInfoL( const TDesC8& aMediaPtr, + HBufC8*& aAddress ); + + /** + * Finds IP addr from a buffer. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where to search. + * @return a IP address if found. + */ + HBufC8* GetIpAddrL( const TDesC8& aPtr ); + + /** + * Getter for clock rate of media. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @return a clock rate value of the media. + */ + TUint GetClockRateL( const TDesC8& aPtr ); + + /** + * Append media info from media section to array. + * @since Series 60 3.0 + * @param aMediaPtr a pointer to buffer of media section. + * @param aControlAddr a control address of media. + * @return none. + */ + void GetControlL( const TDesC8& aMediaPtr, + HBufC8*& aControlAddr ); + + /** + * Method for checking if addr is multicast addr. + * @since Series 60 3.0 + * @param aCLine is c= line from SDP. + * @return none. + */ + void CheckForMulticast( const TDesC8& aLine ); + + /** + * Method that picks up all attribute lines from sdp + * block and stores them in given array + * @since Series 60 3.0 + * @param aSdpSection is section from sdp. In practice m=video section + * or m=audio section or the common section from beginning. + * @aAttributeList is an array where each attribute-line is stored. + */ + void FindAttributesL ( const TDesC8& aSdpSection, + RArray& aAttributeList ); + + /** + * Method that picks up all data stream lines from sdp. + * @since Series 60 3.0 + * @param aSdpSection is section from sdp. In practice m=video section + * or m=audio section or the common section from beginning. + * @aStreamsList is an array where each data stream-line is stored. + * @return none. + */ + void FindDataStreamsL( const TDesC8& aSdpSection, + RArray& aStreamsList ); + + /** + * Reads integer value from a buffer. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @param aKeyword a keyword for line. + * @return a integer value base on keyword. + */ + TInt GetIntL( const TDesC8& aPtr, + const TDesC8& aKeyword ); + + /** + * Reads string value from a buffer. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @param aKeyword a keyword for line. + * @return a buffer base on keyword. + */ + HBufC8* GetStringL( const TDesC8& aPtr, + const TDesC8& aKeyword ); + + /** + * Finds location where keyword data start. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @param aKeyword a keyword for line. + * @return a point in buffer where keyword data start. + */ + TInt FindStart( const TDesC8& aPtr, + const TDesC8& aKeyword ); + + /** + * Finds location where keyword data ends. + * @since Series 60 3.0 + * @param aPtr a pointer to buffer where serch from. + * @param aStart a point where keyword data starts. + * Return a point to line change. + * @param aIgnoreSpace if true, points to the line feed only if. + * @return a point in buffer where keyword data end. + */ + TInt GetLen( const TDesC8& aPtr, + const TInt aStart, + const TBool aIgnoreSpace = EFalse ); + + /** + * Finds smaller non error value integer. + * @since Series 60 3.0 + * @param aValue1 a value 1 for comparison. + * @param aValue2 a value 2 for comparison. + * @return smaller integer if one or both inputs are positive, + otherwise return KErrNotFound. + */ + TInt MinNonError( const TInt aValue1, + const TInt aValue2 ); + + /** + * Convert a string to unsigned integer. + * @since Series 60 3.0 + * @param aString a string to convert. + * @return a integer value base on string. + */ + TUint StrToUint( const TDesC8& aString ); + + /** + * Delete variables. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void DeleteVariables( void ); + +private: // Data + + /** + * Pointer to actual SDP text being parsed. + */ + HBufC8* iSdp; + + /** + * String containing (possible) base url. + */ + HBufC8* iBaseUrl; + + /** + * IP in common section. + */ + HBufC8* iCommonIp; + + /** + * Media section buffer(s) + */ + RArray iMediaBuf; + + /** + * Media attributes for both audio and video. + */ + RArray iSessionAttributes; + + /** + * Media attributes for audio not containing a=control attr. + */ + RArray iAudioAttributes; + + /** + * Media attributes for video not containing a=control attr. + */ + RArray iVideoAttributes; + + /** + * Data streams found from SDP. + */ + RArray iDataStreams; + + /** + * Url that may be used to SETUP iAudioControlAddr RTSP/1.0\r. + */ + HBufC8* iAudioControlAddr; + + /** + * Url that may be used to SETUP iVideoControlAddr RTSP/1.0\r. + */ + HBufC8* iVideoControlAddr; + + /** + * Ip number from audio block from c=IP.. line. + */ + HBufC8* iAudioIpAddr; + + /** + * Ip number from video block from c=IP.. line. + */ + HBufC8* iVideoIpAddr; + + /** + * Audio port or KErrNotFound if not available. + */ + TInt iAudioPort; + + /** + * Video port or KErrNotFound if not available. + */ + TInt iVideoPort; + + /** + * Subtitle port or KErrNotFound if not available. + */ + TInt iTitlePort; + + /** + * Audio bitrate or KErrNotFound if not available. + */ + TInt iAudioBitrate; + + /** + * Video bitrate or KErrNotFound if not available. + */ + TInt iVideoBitrate; + + /** + * Audio strema id. + */ + TInt iAudioStreamId; + + /** + * Video stream id. + */ + TInt iVideoStreamId; + + /** + * How much is one video rtp timer tick in wall clock time + * (usually 1/90000 seconds). + */ + TUint32 iVideoTimerGranularity; + + /** + * How much is one audio rtp timer tick in wall clock time + * (usually 1/ seconds). + */ + TUint32 iAudioTimerGranularity; + + /** + * If the sdp parsed was Ipv4 or not. + */ + TBool iIsIpv4; + + /** + * If the sdp parsed was multicast or not. + */ + TBool iIsMulticast; + + /** + * Media identifier for audio. From a=rtpmap:96 H264/90000 the number 96. + * Usually value 96 is for video and 97 for audio, but might be other. + */ + TInt iMediaIdentifierAudio; + + /** + * Media identifier for video. + */ + TInt iMediaIdentifierVideo; + + }; + +#endif // CDVRSDPPARSER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRTypeDefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRTypeDefs.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common type definitions for both client and server parts* +*/ + + +#ifndef CRTYPEDEFS_H +#define CRTYPEDEFS_H + +// INCLUDES +#include +#include + +// CONSTANTS +_LIT( KCRServerNameExe, "CommonRecordingEngine.exe" ); +_LIT( KCRServerSemaphoreName, "CommonRecServerSemaphore" ); +_LIT( KCRMsgQueueName, "CRMsgQueue%d" ); + +/** Max RTSP Name/password len */ +const TInt KMaxNameLen( 40 ); +/** Max RTSP URI len */ +const TUint KMaxUrlLen( 256 ); + +// The server version. A version must be specified +// when creating a session with the server +const TUint KCRServMajorVersionNumber( 0 ); +const TUint KCRServMinorVersionNumber( 1 ); +const TUint KCRServBuildVersionNumber( 0 ); +const TUint KCRStackSize( 2 * KDefaultStackSize ); +const TUint KCRHeapSize( 0xF0000 ); +const TUint KCRMaxHeapSize( 0x1F0000 ); + +// Queue name length (10 from fixed part and +// 10 from maximum numbers in 32 value +const TUint KCRQueueNameLength( 20 ); + +// MACROS +// None. + +// DATA TYPES +/** +* Different messagetypes going from DVR engine to client lib. +* Note that client lib maps this to yet another enum before +* reporting the event via MCRStreamObserver::NotifyL +*/ +enum TCRQueueMsg + { + ECRMsgQueueAuthenticationNeeded, /**< Needs new username and password for authentication */ + ECRMsgQueueAttachCompleted, /**< Connection Attach completed and connection ready to be used */ + ECRMsgQueueConnectionError, /**< Unable to open connection in RTP engine & CR engine */ + ECRMsgQueueNotEnoughBandwidth, /**< Stream bitrate higher than (estimated) available connection bandwidth */ + ECRMsgQueueSwitchingToTcp, /**< Switching to tcp-streaming; client is supposed to init player */ + ECRMsgQueueNormalEndOfStream, /**< clip ends normally */ + ECRMsgQueueStreamIsLiveStream, /**< indicates that we are streaming clip that cannot be paused */ + ECRMsgQueueStreamIsRealMedia, /**< Clip would have been (unsupported) realnetworks realmedia over rdt */ + ECRMsgQueueTestSinkData, /**< Data from TestSink (former NullSink) to test client */ + ECRMsgQueueSdpAvailable, /**< Used to communicate SDP availability to client */ + ECRMsgQueueReadyToSeek, /**< Used to communicate seeking possibility */ + ECRMsgQueueRecordingStarted, /**< Used to communicate recording state */ + ECRMsgQueueRecordingPaused, /**< Used to communicate recording state */ + ECRMsgQueueRecordingEnded /**< Used to communicate recording state */ + }; + +/** +* Different message types going from TestSink (NullSink) to client lib. +* Embedded in TCRQueueMsg::ECRMsgQueueTestSinkData +*/ +enum TCRTestSinkData + { + ECRTestSinkStateIdle, + ECRTestSinkStateSdpAvailable, + ECRTestSinkStateSeqAndTSAvailable, + ECRTestSinkStatePlaying, + ECRTestSinkStateClosing, + }; + +/** +* Different record formats. +*/ +enum TCRRecordFormat + { + ECRRecordFormatRtp, /**< Nokia's propriatary RTP clip format */ + ECRRecordFormat3gp, /**< Normal 3GPP file format */ + ECRRecordTimeShift /**< Time shifting with Nokia's propriatary format */ + }; + +/** + * This structure is sent over message queue where + * api sits listening + */ +struct SCRQueueEntry + { + TCRQueueMsg iMsg; /**< Identifies the message */ + TInt iErr; /**< Can be used to pass error value related to message */ + TInt iSessionId; /**< Points to session generating the message. 0 points no session, broadcast */ + }; + +/** +* Structure used to communicate the Internet Access Point that +* DVR engine may use +*/ +struct SCRRtspIapParams + { + TInt32 iIap; /**< Internet Access Point ID from COMMS db. Currently not used */ + TUint32 iConnectionId; /**< Handle of opened RConnection. Currently used */ + TBuf iQueueName; /**< Name of RMSgQueue that DVR engine will use to report progress back */ + }; + +/** +* Data structure specifying RTSP address +*/ +struct SCRRtspParams + { + TBuf iUrl ; /**< usually something like rtsp://server.name... */ + TBuf iUserName; /**< RTSP Username. May be blank if server is not going to reply 401 */ + TBuf iPassword; /**< RTSP password. May be blank if server is not going to reply 401 */ + TBuf iQueueName; /**< Name of RMSgQueue that DVR engine will use to report progress back */ + TName iProxyServerAddr ; /**< Possible rtsp proxy server */ + TInt iProxyServerPort ; /**< Rtsp proxy port number */ + }; + +/** +* Defines live stream params. +*/ +struct SCRLiveParams + { + TPtrC8 iSdpData; + }; + +/** +* Defines RTP playback params. +*/ +struct SCRRtpPlayParams + { + TFileName iFileName; + }; + +/** +* Defines recording params. +*/ +struct SCRRecordParams + { + TPtrC iFileName; + TCRRecordFormat iFormat; + TPtrC iServiceName; + TPtrC iProgramName; + TPtrC8 iSdpData; + TInt iPostRule; + TInt iParental; + TTime iEndTime; + }; + +/** +* Opcodes used in message passing between client and server. +*/ +enum TCRServRqst + { + // Server request + ECRServBase = 450, + ECRServConnect, + ECRServCreateSubSession, + ECRServCloseSubSession, + ECRServCloseSession, + ECRServReset, + ECRServCancelAll, + ECRServLastEnum, + // API for LiveTV specific commands + ECRLiveTvBase = 500, + ECRSetIap, + ECRCancelSetIap, + ECRPlayRtspUrl, + ECRPlayDvbhLive, + ECRChangeService, + ECRPlayRtpFile, + ECRPlayRtpHandle, + ECRRecordCurrentStream, + ECRRecordRtspStream, + ECRRecordDvbhStream, + ECRPauseRecordStream, + ECRStopRecordStream, + ECRStartTimeShift, + ECRStopTimeShift, + ECRPlayCommand, + ECRPauseCommand, + ECRStopCommand, + ECRSetPosition, + ECRGetPosition, + ECRCloseSession, + ECRPlayNullSource, + ECRPlayRtspUrlToNullSink, + ECRLiveTvLastEnum + }; + +/** +* Opcodes used in message passing from server. +*/ +enum TCRServResponse + { + ECRStreamPauseHanling = 550, + ECRStreamEndHandling + }; + +#endif // CRTYPEDEFS_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipHandler.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,323 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for RTP file actions.* +*/ + + + + +#ifndef CRTPCLIPHANDLER_H +#define CRTPCLIPHANDLER_H + +// INCLUDES +#include +#include +#include +#include +#include + +// CONSTANTS +const TInt KDvrMaximumTimeShift( 12 * 60 * 60 ); // 12 hours + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpToFile; +class CRtpFromFile; + +// CLASS DECLARATION + +/** +* Handles RTP storing/reading in a clip with a proprietary file format. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpClipHandler : public CBase, + public MRtpFileObserver + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @return CRtpClipHandler pointer to CRtpClipHandler class. + */ + IMPORT_C static CRtpClipHandler* NewL(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CRtpClipHandler(); + +public: // New functions + + /** + * Registers RTP file write observer. + * @since Series 60 3.0 + * @param aObs a pointer to class which handles callback. + * @return none. + */ + IMPORT_C void RegisterWriteObserver( MRtpFileWriteObserver* aObs ); + + /** + * Registers RTP file read observer. + * @since Series 60 3.0 + * @param aObs a pointer to class which handles callback. + * @return none. + */ + IMPORT_C void RegisterReadObserver( MRtpFileReadObserver* aObs ); + + /** + * Starts RTP recording to a file. + * @since Series 60 3.0 + * @param aRecParams a recording info structure. + * @param aAction a save action for clip mode. + * @return none. + */ + IMPORT_C void StartRecordingL( + const MRtpFileWriteObserver::SRtpRecParams& aRecParams, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ); + + /** + * Saves next RTP group to a clip. + * @since Series 60 3.0 + * @param aGroup a RTP group data. + * @param aGroupLength a length of group. + * @param aAction a save action for current group. + * @return none. + */ + IMPORT_C void SaveNextGroupL( + TPtr8& aGroup, + TUint aGroupLength, + const MRtpFileWriteObserver::TRtpSaveAction& aAction ); + + /** + * Getter for writing activity state. + * @since Series 60 3.0 + * @param none. + * @return true if writing ongoing, otherwise false. + */ + IMPORT_C TBool WritingActive( void ) const; + + /** + * Getter for current length of the clip. + * @since Series 60 3.0 + * @param none. + * @return a total length of the clip. + */ + IMPORT_C TUint GetCurrentLength( void ) const; + + /** + * Clip loop mode set for time shift. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C void TimeShiftPauseL(); + + /** + * Default values for rbf record params. + * @since Series 60 3.0 + * @param aParams a recording parameters. + * @param aIndex a index for time shift clip name. + * @return none. + */ + IMPORT_C void DefaultRecParams( MRtpFileWriteObserver::SRtpRecParams& aParams, + const TInt aIndex ); + + /** + * Setter recording end time of the clip. + * @since Series 60 3.0 + * @param aEndTime new end time for the clip. + * @return none. + */ + IMPORT_C void UpdateRecordEndTime( const TTime& aEndTime ); + + /** + * Resumes RTP recording. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C void ResumeRecordingL( void ); + + /** + * Stops RTP recording. + * @since Series 60 3.0 + * @param aError a stop error code. + * @return none. + */ + IMPORT_C void StopRecording( const TInt aError ); + + /** + * Starts RTP playback from a clip. + * @since Series 60 3.0 + * @param aParams a RTP clip play params. + * @param aTimeShift a time shift mode or not. + * @return none. + */ + IMPORT_C void StartPlayBackL( const SCRRtpPlayParams& aParams, + const TBool aTimeShift = EFalse ); + + /** + * Starts RTP playback from a clip. + * @since Series 60 3.0 + * @param aRtpHandle a open file handle for RTP file. + * @return none. + */ + IMPORT_C void StartPlayBackL( const RFile& aFileHandle ); + + /** + * Getter for SDP of the clip. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C HBufC8* GetClipSdpL( void ) const; + + /** + * Reads next RTP group from a clip. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + IMPORT_C void NextClipGroupL( void ); + + /** + * Sets Seek point of the clip. + * @since Series 60 3.0 + * @param aTime a time where to seek in clip. + * @return none. + */ + IMPORT_C void SetSeekPointL( const TUint aTime ); + + /** + * Stops RTP playback. + * @since Series 60 3.0 + * @param aError a stop error code. + * @param aPlayerBuf a buffer length in player. + * @return none. + */ + IMPORT_C void StopPlayBack( const TInt aError, + const TUint aPlayerBuf ); + + /** + * Getter for clip version. + * @since Series 60 3.0 + * @param none. + * @return a internal version of the clip. + */ + inline TInt8 ClipVersion( void ) const; + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CRtpClipHandler(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + +private: // Functions from base classes + + /** + * From MRtpFileObserver. + * Called when RTP group save is ready. + * @since Series 60 3.0 + * @param aAction a save action for last saved group. + * @return None. + */ + void RtpGroupSaved( const TInt aAction ); + + /** + * From MRtpFileObserver. + * Getter for current file reader point. + * @since Series 60 3.0 + * @param aIndex a index of shift seek array. + * @return a read point in file reader. + */ + TInt CurrentFileReadPoint( const TInt aIndex ); + +private: // New methods + + /** + * Swap to next available clip in time shift array if needed. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void SwapClipIfNeededL( void ); + +private: // Data + + /** + * RTP write observer. + */ + MRtpFileWriteObserver* iWriteObs; + + /** + * RTP read observer. + */ + MRtpFileReadObserver* iReadObs; + + /** + * RTP file save. + */ + CRtpToFile* iRtpSave; + + /** + * RTP file read. + */ + CRtpFromFile* iRtpRead; + + /** + * Clip version. + */ + TInt8 iClipVersion; + + /** + * Time shift save clip name index. + */ + TInt iSaveNameIndex; + + /** + * Time shift read clip name index. + */ + TInt iReadNameIndex; + + /** + * Time shift paused state. + */ + TBool iTsPauseState; + + /** + * Time shift seek handling array. + */ + RArray iShiftSeek; + + }; + +#include + +#endif // CRTPCLIPHANDLER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipHandler.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipHandler.inl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the RTP file action inline functions.* +*/ + + + + +// INCLUDE FILES +// None + +// CONSTANTS +// None + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpClipHandler::ClipVersion +// Getter for clip version. +// ----------------------------------------------------------------------------- +// +inline TInt8 CRtpClipHandler::ClipVersion( void ) const + { + return iClipVersion; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpClipManager.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,307 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Finds access objects (SDP file) and ESG related names.* +*/ + + + + +#ifndef CRTPCLIPMANAGER_H +#define CRTPCLIPMANAGER_H + +// INCLUDES +#include +#include +#include +#include +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +class CRtpMetaHeader; +class CRtpClipRepairer; + +// CLASS DECLARATION + +/** +* Handles DVB-H RTP clip related functions. +* +* @lib DvrRtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpClipManager : public CBase + { + +public: // Data types + + /** + * Defines Clip details. + */ + class SRtpClipDetails + { + + public: // Data + + /** + * Service name. + */ + TName iService; + + /** + * Program name. + */ + TName iProgram; + + /** + * Recording start time. + */ + TTime iStartTime; + + /** + * Recording end time. + */ + TTime iEndTime; + + /** + * Recording duration. + */ + TInt iDuration; + + /** + * Recording currently ongoing state. + */ + TBool iRecOngoing; + + /** + * Recording completed status. + */ + TBool iCompleted; + + /** + * Clip protected state. + */ + TBool iProtected; + + /** + * Recording failed status. + */ + TBool iFailed; + + /** + * Clip's quality. + */ + TUint8 iQuality; + + /** + * Clip watched counter. + */ + TInt iPlayCount; + + /* + * Point where last watch were stopped. + */ + TInt iPlaySpot; + + /** + * Post acquisition rule ok with this device. + */ + TBool iPostRuleOk; + + /** + * Parental rate of the clip. + */ + TInt iParental; + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CRtpClipManager* NewL(); + + /** + * Two-phased constructor. + */ + IMPORT_C static CRtpClipManager* NewLC(); + + /** + * Destructor. + * @return None. + */ + IMPORT_C virtual ~CRtpClipManager(); + +public: // New methods + + /** + * Getter for recorded clip details. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @param aDetails a struct for details. + * @return None. + */ + IMPORT_C void GetClipDetailsL( const TDesC& aClipPath, + SRtpClipDetails& aDetails ); + + /** + * Getter for recorded clip details. + * @since Series 60 3.0 + * @param aFile File handle to the clip. + * @param aDetails a struct for details. + * @return None. + */ + IMPORT_C void GetClipDetailsL( RFile& aFile, + SRtpClipDetails& aDetails ); + + /** + * Setter for protected state of the clip. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @param aProtected a protected state. + * @return None. + */ + IMPORT_C void ProtectClipL( const TDesC& aClipPath, + const TBool aProtected ); + + /** + * Asyncronous fix for clip's meta header if possible. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @param aObs a file repairer observer. + * @return None. + */ + IMPORT_C void FixMetaHeaderL( MRtpClipRepairObserver* aObs, + const TDesC& aClipPath ); + + /** + * Syncronous fix for clip's meta header if possible. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @return None. + */ + IMPORT_C void FixMetaHeaderL( const TDesC& aClipPath ); + + /** + * Deletes asyncronous clip fixer. + * @since Series 60 3.0 + * @param aObs a file repairer observer. + * @return None. + */ + IMPORT_C void DeleteRtpRepairer( MRtpClipRepairObserver* aObs ); + + /** + * Verifies post acquisition rule of clip. + * @since Series 60 3.0 + * @param aPostRule a post acquisition rule of clip. + * @param aMetaHeader a pointer to meat header. + * @return KErrNone if rule ok, + * otherwise another of the system-wide error codes. + */ + TInt VerifyPostRuleL( const TUint8 aPostRule, + CRtpMetaHeader* aMetaHeader ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CRtpClipManager(); + + /** + * Symbian 2nd phase constructor can leave. + */ + void ConstructL(); + +private: // New methods + + /** + * Updates details from meta header attributes. + * @since Series 60 3.0 + * @param aAttributes a meta header attributes. + * @param aDetails a struct for details. + * @return None + */ + void GetDetailsL( const CRtpMetaHeader::SAttributes& aAttributes, + SRtpClipDetails& aDetails, + CRtpMetaHeader* aMetaHeader ); + + /** + * Provides root path of clip base on memory setting. + * @since Series 60 3.0 + * @param aClipPath a path of the clip as return value. + * @param aDrive a drive number where to store. + * @return None + */ + void NewClipRootL( TDes& aClipPath, + const TDriveNumber aDrive ); + + /** + * Generates new clip name from service/program names. + * Adds index number to the end if file exist. + * @since Series 60 3.0 + * @param aClipPath a path of the clip. + * @param aProgram a program name of recorded channel. + * @return none. + */ + void NewIndexNameL( TDes& aClipPath, + const TDesC& aProgram ); + + /** + * Adds clip to the repairing queue. + * @since Series 60 3.0 + * @param aClipPath a full path of the clip. + * @return None + */ + void AddClipToRepairQueueL( const TDesC& aClipPath ); + +private: // Data + + /** + * File server. + */ + RFs iFs; + + /** + * File operations. + */ + RFile iFile; + + /** + * Devices IMEI. + */ + HBufC* iImei; + + /** + * RTP clip repairer. + */ + CRtpClipRepairer* iClipRepairer; + + /** + * RTP file repairer queue. + */ + RPointerArray iRepairQueue; + + }; + +#endif // CRTPCLIPMANAGER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpFileBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpFileBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,320 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base methods/variables for RTP file format recording.* +*/ + + + + +#ifndef CRTPFILEBASE_H +#define CRTPFILEBASE_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TInt KCurrentClipVersion( 3 ); +const TInt KMinValidClipVersion( 2 ); +const TInt KSeekHeaderBytes( 3 * KIntegerBytes ); +const TInt KGroupHeaderBytes( 4 * KIntegerBytes ); +const TInt KPacketsCountBytes( 4 ); +const TInt KNormalRecGroupLength( 2000 ); // 2 s +const TUint KSeekArrayInterval( 30000 ); // 30 s + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* RTP format common functionalities. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class CRtpFileBase : public CActive + { + +public: // Data types + + // Time shift seek array + class STimeShiftSeek + { + + public: // Data + + /** + * Group time. + */ + TUint iGroupTime; + + /** + * File seek point. + */ + TInt iSeekpoint; + + /** + * File name index. + */ + TInt iNameIndex; + + }; + + +public: // Constructors and destructor + + /** + * Destructor. + */ + virtual ~CRtpFileBase(); + +protected: // Constructors and destructor + + /** + * C++ default constructor. + */ + CRtpFileBase(); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +protected: // Enumeration + + // Defines RTP file mode + enum TRtpFileMode + { + EModeNone = KErrBadHandle, + EModeNormal = KErrNone, + EModeHandle, + EModeTimeShift + }; + +public: // New functions + + /** + * Deletes time shift files. + * @since Series 60 3.0 + * @param aShiftSeek a reference to time shift seek array. + * @return None. + */ + void DeleteTimeShiftFiles( RArray& aShiftSeek ); + +protected: // New functions + + /** + * Writes RTP seek header to a file. + * @since Series 60 3.0 + * @return None. + */ + void WriteSeekHeaderL(); + + /** + * Reads clip's seek header from a file. + * @since Series 60 3.0 + * @return None. + */ + void ReadSeekHeaderL(); + + /** + * Reads clip's group header from a file. + * @since Series 60 3.0 + * @return None. + */ + void ReadGroupHeaderL(); + + /** + * Updates group header variables from readed data. + * @since Series 60 3.0 + * @param aDataPtr data from which header is updated. + * @return None. + */ + void UpdateGroupHeaderVariablesL( const TDesC8& aDataPtr ); + + /** + * Appends one group to the seek array. + * @since Series 60 3.0 + * @param aTime a TS time of first packet in group. + * @param aPoint a seek point in clip for group. + * @return None. + */ + void AppendSeekArrayL( const TUint aTime, + const TInt aPoint ); + + /** + * Saves seek array to the clip. + * @since Series 60 3.0 + * @return None. + */ + void SaveSeekArrayL(); + + /** + * Reads seek array from the clip. + * @since Series 60 3.0 + * @param aPoint a seek array point in clip. + * @return true if items in seek array, otherwise false. + */ + TBool ReadSeekArrayL( const TInt aPoint ); + + /** + * Resets seek array. + * @since Series 60 3.0 + * @return None. + */ + inline void ResetSeekArray(); + + /** + * Writes variables to log file. + * @since Series 60 3.0 + * @param aMethod a method which called this + */ + void LogVariables( const TDesC& aMethod ); + +private: // Functions from base classes + + /** + * From CActive : Called when request completion event occurs. + * @since Series 60 3.0 + * @return None. + */ + virtual void RunL() = 0; + + /** + * From CActive : Handles a leave occurring in the request + * completion event handler RunL(). + * @since Series 60 3.0 + * @param aError the leave code + * @return status of run error handling + */ + virtual TInt RunError( TInt aError ) = 0; + + /** + * From CActive : Called when request completion event cancelled. + * @since Series 60 3.0 + * @return None. + */ + virtual void DoCancel() = 0; + +protected: // Data types + + // Defines seek struct + class SSeek + { + + public: // Data + + /** + * Enlapsed time. + */ + TUint iTime; + + /** + * Point in clip. + */ + TInt iPoint; + + }; + +protected: // Data + + /** + * Rtp file usage mode. + */ + TRtpFileMode iMode; + + /** + * Current group. + */ + TInt iThisGroup; + + /** + * Packet group counter (Seek header). + */ + TInt iGroupsTotalCount; + + /** + * First seek address (Seek header). + */ + TInt iFirstSeekAddr; + + /** + * Last seek address (Seek header). + */ + TInt iLastSeekAddr; + + /** + * Group total length (Group header). + */ + TInt iGroupTotalLen; + + /** + * Next group point (Group header). + */ + TInt iNextGroupPoint; + + /** + * Previous group point (Group header). + */ + TInt iPrevGroupPoint; + + /** + * Group time (Group header). + */ + TUint iGroupTime; + + /** + * Seek header point. + */ + TInt iSeekHeaderPoint; + + /** + * Current clip path. + */ + HBufC* iCurrentPath; + + /** + * Seek array. + */ + CArrayFix* iSeekArray; + + /** + * File data buffer pointer. + */ + TPtr8 iDataPtr; + + /** + * File server. + */ + RFs iFs; + + /* + * File operations. + */ + RFile iFile; + + }; + +#include + +#endif // CRTPFILEBASE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpFileBase.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpFileBase.inl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of the Common Recording Engine RTP file base* +*/ + + + + +// INCLUDE FILES + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CRtpFileBase::ResetSeekArray +// Resets whole array. +// ----------------------------------------------------------------------------- +// +inline void CRtpFileBase::ResetSeekArray() + { + iSeekArray->Reset(); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpMetaHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpMetaHeader.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,478 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP clip metaheader write/read functionalities.* +*/ + + + + +#ifndef CRTPMETAHEADER_H +#define CRTPMETAHEADER_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TInt KStringLengthBytes( 1 ); +const TInt KMaxMetaHeaderLength( 2048 ); +const TInt KMetaLengthPoint( 0 ); +const TInt KAttributesPoint( KMetaLengthPoint + KIntegerBytes ); // 4 +const TInt KPlayCountPoint( KAttributesPoint + KIntegerBytes ); // 8 +const TInt KPlaySpotPoint( KPlayCountPoint + KIntegerBytes ); // 12 +const TInt KReservedPoint1( KPlaySpotPoint + KIntegerBytes ); // 16 +const TInt KReservedPoint2( KReservedPoint1 + KIntegerBytes ); // 20 +const TInt KReservedPoint3( KReservedPoint2 + KIntegerBytes ); // 24 +const TInt KReservedPoint4( KReservedPoint3 + KIntegerBytes ); // 28 +const TInt KStartTimePoint( KReservedPoint4 + KIntegerBytes ); // 32 +const TInt KEndTimePoint( KStartTimePoint + 2 * KIntegerBytes ); // 40 +const TInt KDurationPoint( KEndTimePoint + 2 * KIntegerBytes ); // 48 +const TInt KSeekArrayPoint( KDurationPoint + KIntegerBytes ); // 52 +const TInt KUserIdPoint( KSeekArrayPoint + KIntegerBytes ); // 56 +const TInt KDeviceInfoPoint( KUserIdPoint + KStringLengthBytes + // 72 + KUserIdLength ); +// Metaheader attributes +const TInt KOngoingFlagShift( 0 ); +const TInt KCompletedFlagShift( 1 ); +const TInt KProtectedFlagShift( 2 ); +const TInt KFailedFlagShift( 3 ); +const TInt KVersionFieldShift( 4 ); +const TInt KQualityFieldShift( 8 ); +const TInt KPostRuleFieldShift( 16 ); +const TInt KParentalFieldShift( 24 ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Meta header handling for RTP file format. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CRtpMetaHeader : public CBase + { + +public: // Enumeration + + // Defines mode + enum TMetaMode + { + EMetaRead = 200, + EMetaWrite, + EMetaUpdate + }; + +public: // Data types + + // Defines clip attributes struct + class SAttributes + { + public: // Data + + /** + * Recording ongoing. + */ + TBool iOngoing; + + /** + * Recording completed. + */ + TBool iCompleted; + + /** + * Clip protected. + */ + TBool iProtected; + + /** + * Recording failed. + */ + TBool iFailed; + + /** + * Clip version. + */ + TUint8 iVersion; + + /** + * Clip quality. + */ + TUint8 iQuality; + + /** + * Clip's post accuisition rule. + */ + TUint8 iPostRule; + + /** + * Parental rate. + */ + TUint8 iParental; + + /** + * Viewed counter. + */ + TInt iPlayCount; + + /** + * Point where vieving stopped. + */ + TInt iPlaySpot; + + }; + +public: // Constructors and destructor + + /** + * Two-phased constructor. + * @param aFile a reference to file operations. + * @param aMode a meta data read or write mode. + */ + static CRtpMetaHeader* NewL( RFile& aFile, + const TMetaMode& aMode ); + + /** + * Two-phased constructor. + * @param aFile a reference to file operations. + * @param aMode a meta data read or write mode. + */ + static CRtpMetaHeader* NewLC( RFile& aFile, + const TMetaMode& aMode ); + + /** + * Destructor. + */ + virtual ~CRtpMetaHeader(); + +public: // New functions + + /** + * Getter for seek header point. + * @since Series 60 3.0 + * @return seek header point. + */ + TInt SeekHeaderPoint(); + + /** + * Writes whole meta header to the clip. + * Note, need use only with node: EMetaWrite. + * @since Series 60 3.0 + * @return None. + */ + void CommitL(); + + /** + * Writes clip's attributes of meta data header to a file. + * @since Series 60 3.0 + * @param aAtt a struct of attributes to write. + * @return None. + */ + void WriteAttributesL( const SAttributes& aAtt ); + + /** + * Writes start date/time to meta data header of the clip. + * @since Series 60 3.0 + * @param aTime a date/time value to write + * @return None. + */ + void WriteStartTimeL( const TTime& aTime ); + + /** + * Writes start date/time to meta data header of the clip. + * @since Series 60 3.0 + * @param aTime a date/time value to write + * @return None. + */ + void WriteEndTimeL( const TTime& aTime ); + + /** + * Writes duration to meta data header of the clip. + * @since Series 60 3.0 + * @param aDuration a duration value to write + * @return None. + */ + void WriteDurationL( const TInt aDuration ); + + /** + * Writes seek array point to meta data header of the clip. + * @since Series 60 3.0 + * @param aPoint a value to write + * @return None. + */ + void WriteSeekArrayPointL( const TInt aPoint ); + + /** + * Writes device info to meta data header of the clip. + * @since Series 60 3.0 + * @param aId a id to write + * @return None. + */ + void WriteUserIdL( const TDesC& aId ); + + /** + * Writes device info to meta data header of the clip. + * @since Series 60 3.0 + * @param aInfo a device info to write + * @return None. + */ + void WriteDeviceInfoL( const TDesC& aInfo ); + + /** + * Writes ESG to meta data header of the clip. + * @since Series 60 3.0 + * @param aService a name of the service + * @param aProgram a name of the program + * @return None. + */ + void WriteEsgDataL( const TDesC& aService, + const TDesC& aProgram ); + + /** + * Writes SRTP data to meta data header of the clip. + * @since Series 60 3.0 + * @param aSrtpData a SRTP data to write. + * @return None. + */ + void WriteSrtpDataL( const TDesC8& aSrtpData ); + + /** + * Writes SDP file data to meta data header of the clip. + * @since Series 60 3.0 + * @param aSdpData a SDP file data. + * @return None. + */ + void WriteSdpDataL( const TDesC8& aSdpData ); + + /** + * Reads clip's attributes of meta data header from a file. + * @since Series 60 3.0 + * @param aAtt a struct of attributes to read. + * @return None. + */ + void ReadAttributesL( SAttributes& aAtt ); + + /** + * Reads start date/time of meta data header from the clip. + * @since Series 60 3.0 + * @param aTime a readed date/time value + * @return None. + */ + void ReadStartTimeL( TTime& aTime ); + + /** + * Reads end date/time of meta data header from the clip. + * @since Series 60 3.0 + * @param aTime a readed date/time value + * @return None. + */ + void ReadEndTimeL( TTime& aTime ); + + /** + * Reads duration in seconds of meta data header from the clip. + * @since Series 60 3.0 + * @param aDuration a readed duration value + * @return None. + */ + void ReadDurationL( TInt& aDuration ); + + /** + * Reads seek array point of meta data header from the clip. + * @since Series 60 3.0 + * @param aPoint a readed seek array point value + * @return None. + */ + void ReadSeekArrayPointL( TInt& aPoint ); + + /** + * Reads user id of meta data header from the clip. + * @since Series 60 3.0 + * @param a buffer for info to read + * @return None. + */ + void ReadUserIdL( TDes& aId ); + + /** + * Reads device info of meta data header from the clip. + * @since Series 60 3.0 + * @param a buffer for info to read + * @return None. + */ + void ReadDeviceInfoL( TDes& aInfo ); + + /** + * Reads ESG of meta data header from the clip. + * @since Series 60 3.0 + * @param a buffer for service name to read + * @param a buffer for program name to read + * @return None. + */ + void ReadEsgDataL( TDes& aService, TDes& aProgram ); + + /** + * Reads SRTP data of meta data header from the clip. + * @since Series 60 3.0 + * @return pointer to readed SRTP data. + */ + HBufC8* ReadSrtpDataL(); + + /** + * Reads SDP file data of meta data header from the clip. + * @since Series 60 3.0 + * @return pointer to readed SDP file data. + */ + HBufC8* ReadSdpDataL(); + +private: // Constructors and destructor + + /** + * C++ default constructor. + * @param aFile a reference to file operations + * @param aMode a meta data read or write mode + */ + CRtpMetaHeader( RFile& aFile, + const TMetaMode& aMode ); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +private: // New functions + + /** + * Writes any string with one byte len info to meta header. + * @since Series 60 3.0 + * @param aPosition a position to write + * @param aData a data to write + * @return None. + */ + void WriteStringDataL( const TInt aPosition, + const TDesC& aData ); + + /** + * Reads any string with one byte len info from meta header. + * @since Series 60 3.0 + * @param aPosition a position from to read + * @param aData a data to read + * @return None. + */ + void ReadStringDataL( const TInt aPosition, + TDes& aData ); + + /** + * Writes time info to meta data header of the clip. + * @since Series 60 3.0 + * @param aPosition a position to append + * @param aTime a time value to write + * @return None. + */ + void AddTimeL( const TInt aPosition, + const TTime& aTime ); + + /** + * Reads time info of meta data header from the clip. + * @since Series 60 3.0 + * @param aPosition a position to read + * @param aTime a readed time value + * @return None. + */ + void GetTimeL( const TInt aPosition, + TTime& aTime ); + + /** + * Adds intehger data to meta buffer. + * @since Series 60 3.0 + * @param aPosition a position to add + * @param aValue a integer value to add + * @return None. + */ + void AddIntegerL( const TInt aPosition, + const TInt aValue ); + + /** + * Adds new data to meta buffer. + * @since Series 60 3.0 + * @param aPosition a position to add + * @param aData a data to append + * @return None. + */ + void AddDataL( const TInt aPosition, + const TDesC8& aData ); + + /** + * Reads 32 bits (TInt) from a file from certain position. + * @since Series 60 3.0 + * @param aPosition a position from to read + * @param aValue a value to update + * @return None. + */ + void ReadTintFromFileL( const TInt& aPosition, + TInt& aValue ); + +private: // Data + + /** + * File operations. + */ + RFile& iFile; + + /** + * Mode. + */ + TMetaMode iMode; + + /** + * File data buffer. + */ + HBufC8* iMetaData; + + /** + * File data buffer pointer. + */ + TPtr8 iDataPtr; + + /** + * ESG data point. + */ + TInt iEsgDataPoint; + + /** + * SRTP data point. + */ + TInt iSrtpDataPoint; + + /** + * SDP file data point. + */ + TInt iSdpDataPoint; + + /** + * Meta total length. + */ + TInt iMetaTotal; + + }; + +#endif // CRTPMETAHEADER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/CRtpUtil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/CRtpUtil.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Convertion methods for RTP file format.* +*/ + + + + +#ifndef CRTPUTIL_H +#define CRTPUTIL_H + +// INCLUDES +#include +#include + +// CONSTANTS +const TInt KSiKilo( 1000 ); +const TInt KIntegerBytes( 4 ); +const TInt KPacketSizeBytePoint( 0 ); +const TInt KPacketSizeBytesLen( 4 ); +const TInt KPacketTypeBytesLen( 1 ); +const TInt KSpecialPacketLength( KPacketSizeBytesLen + KPacketTypeBytesLen + KIntegerBytes ); +const TInt KPacketTypeBytePoint( KPacketSizeBytePoint + KPacketSizeBytesLen ); +const TInt KUserIdLength( RMobilePhone::KIMSISize ); +const TInt KDeviceIdLength( RMobilePhone::KPhoneSerialNumberSize ); + +_LIT8( KRtpClipMimetype, "application/x-nokia-teh-rtp" ); +_LIT( KDvrTimeShiftFile, "c:\\timeshift." ); + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* RTP format common functionalities for Common Recording Engine. +* +* @lib CommonRecordingEngine.lib +* @since Series 60 3.0 +*/ +class CRtpUtil : public CBase + { + +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CRtpUtil* NewL(); + + /** + * Two-phased constructor. + */ + IMPORT_C static CRtpUtil* NewLC(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CRtpUtil(); + +public: // New functions + + /** + * Converts integer to a buffer. + * @since Series 60 3.0 + * @param aValue a value to write. + * @return a buffer where value stored. + */ + IMPORT_C static HBufC8* MakeBytesLC( const TInt& aValue ); + + /** + * Converts integer to a buffer. + * @since Series 60 3.0 + * @param aValue a value to write. + * @param aBuf a buffer where value stored. + * @return none. + */ + IMPORT_C static void MakeBytesL( const TInt& aValue, + TDes8& aBuf ); + + /** + * Converts integer to a buffer. + * @since Series 60 3.0 + * @param aValue a value to write. + * @param aBuf a buffer where value stored. + * @return a system wide error code. + */ + IMPORT_C static TInt MakeBytes( const TInt& aValue, + TDes8& aBuf ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @return an integer converted from bytes. + */ + IMPORT_C static TInt GetValueL( const TDesC8& aBytes ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return none. + */ + IMPORT_C static void GetValueL( const TDesC8& aBytes, + TInt& aValue ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return a system wide error code. + */ + IMPORT_C static TInt GetValue( const TDesC8& aBytes, + TInt& aValue ); + + /** + * Converts bytes to integer. + * @since Series 60 3.0 + * @param aBytes a buffer to convert. + * @param aValue a integer converted from bytes. + * @return a system wide error code. + */ + IMPORT_C static TInt GetValue( const TDesC8& aBytes, + TUint& aValue ); + + /** + * Generates special RTP packet. + * @since Series 60 3.0 + * @param aType a type of RTP packet. + * @return a buffer containing generated RTP packet. + */ + IMPORT_C static HBufC8* SpecialPacketL( const TInt aType ); + + /** + * Getter for RTP clip mime type info. + * @since Series 60 3.0 + * @param aBuf on return contains the mime type. + * @return None. + */ + IMPORT_C static void GetMimeInfo( TDes& aMime ); + + /** + * Getter for RTP clip mime type info. + * @since Series 60 3.0 + * @param aBuf on return contains the mime type. + * @return None. + */ + IMPORT_C static void GetMimeInfo( TDes8& aMime ); + + /** + * Reads IMEI of the phone HW. + * @since Series 60 3.0 + * @param aBuf on return contains the IMEI. + * @return none. + */ + IMPORT_C static void GetImeiL( TDes& aImsi ); + +private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CRtpUtil(); + + /** + * Symbian 2nd phase constructor can leave and is private by default. + */ + void ConstructL(); + +private: // New methods + + /** + * Reads mobile info of the phone. + * @since Series 60 3.0 + * @param none. + * @return none. + */ + void static GetMobilePhoneInfoL( RTelServer& aServer, + RMobilePhone& aPhone ); + + }; + +#endif // CRTPUTIL_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/MCREngineObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/MCREngineObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Engine observer to get event notifications.* +*/ + + +#ifndef MCRENGINEOBSERVER_H +#define MCRENGINEOBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None. + +// DATA TYPES +/** +* Different messages that DVR engine may send via client lib callback +*/ +enum TCRObserverInfo + { + ECRAuthenticationNeeded, /**< CR needs new username and password for authentication */ + ECRAttachCompleted, /**< Connection attach is completed and is ready to be used */ + ECRConnectionError, /**< Unable to open connection in RTP engine & CR engine */ + ECRNotEnoughBandwidth, /**< Stream bitrate higher than (estimated) available connection bandwidth */ + ECRNormalEndOfStream, /**< Used to communicate end of streaming */ + ECRSwitchingToTcp, /**< Switch to tcp, client needs to initiate possible player */ + ECRStreamIsLiveStream, /**< We have a stream that cannot be paused */ + ECRRealNetworksStream, /**< RealMedia stream format, cannot support */ + ECRTestSinkData, /**< Placeholder for TestSink (NullSink) feedback information to test client */ + ECRSdpAvailable, /**< Used to communicate availability of SDP */ + ECRReadyToSeek, /**< Used to communicate seeking posibility */ + ECRRecordingStarted, /**< Used to communicate recording state */ + ECRRecordingPaused, /**< Used to communicate recording state */ + ECRRecordingEnded /**< Used to communicate recording state */ + }; + +/** +* This structure is sent over message queue where +* api sits listening +*/ +struct SCRObserverMsg + { + TCRObserverInfo iMsg; /**< Identifies the message */ + TInt iErr; /**< Can be used to pass error value related to message */ + }; + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* Engine observer to get event notifications. +* +* @lib CommonRecordingEngineClient.lib +* @since Series 60 3.0 +*/ +class MCREngineObserver + { + +public: // New methods + + /** + * Notify call back for statuses. + * @since Series 60 3.0 + * @param aInfo a notify info. + * @return none. + */ + virtual void NotifyL( const SCRObserverMsg& aInfo ) = 0; + + }; + +#endif MCRENGINEOBSERVER_H + +// End of file. diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/MRtpClipRepairObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/MRtpClipRepairObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Call back observer for clip manager.* +*/ + + + + +#ifndef MRTPCLIPREPAIROBSERVER_H +#define MRTPCLIPREPAIROBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None. + +// FORWARD DECLARATIONS +// None. + +// CLASS DECLARATION + +/** +* A RTP clip repair observer. +* +* @lib DvrRtpClipHandler.lib +* @since Series 60 3.0 +*/ +class MRtpClipRepairObserver + { + +public: // New functions + + /** + * Called when clip repairing completes. + * @since Series 60 3.0 + * @param aStatus a status of repairing. + * @return None. + */ + virtual void RtpClipRepaired( const TInt aStatus ) = 0; + + }; + + +#endif // MRTPCLIPREPAIROBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RTP file observer for Common Recording Engine.* +*/ + + + + +#ifndef MRTPFILEOBSERVER_H +#define MRTPFILEOBSERVER_H + +// INCLUDES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* A RTP read observer. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class MRtpFileObserver + { + +public: // New functions + + /** + * Called when RTP group save is ready. + * @since Series 60 3.0 + * @param aAction a save action for last saved group. + * @return None. + */ + virtual void RtpGroupSaved( const TInt aAction ) = 0; + + /** + * Getter for current file reader point. + * @since Series 60 3.0 + * @param aIndex a index of shift seek array. + * @return a read point in file reader. + */ + virtual TInt CurrentFileReadPoint( const TInt aIndex ) = 0; + + }; + +#endif // MRTPFILEOBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileReadObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileReadObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for RTP file actions.* +*/ + + + + +#ifndef MRTPFILEREADOBSERVER_H +#define MRTPFILEREADOBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* RTP file data read observer. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class MRtpFileReadObserver + { + +public: // Data types + + /** + * Defines status indication to client. + */ + enum TRtpReadStatus + { + ERtpTimeShifTEnd = 500 + }; + +public: // New methods + + /** + * Called when RTP packets group readed from a file. + * @since Series 60 3.0 + * @param aConversion a converter for packets bytes. + * @param aGroup a RTP data readed from a file. + * @param aGroupTime a group time in milli seconds. + * @param aLastGroup a indication of last group in clip. + * @return none. + */ + virtual void GroupReadedL( const TDesC8& aGroup, + const TUint aGroupTime, + const TBool aLastGroup ) = 0; + + /** + * Clip handler status of playback. + * @since Series 60 3.0 + * @param aStatus a status of file reading. + * @return none. + */ + virtual void ReadStatus( TInt aStatus ) = 0; + + }; + +#endif // MRTPFILEREADOBSERVER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileWriteObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/dvrengine_api/inc/ipvideo/MRtpFileWriteObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for RTP file actions.* +*/ + + + + +#ifndef MRTPFILEWRITEOBSERVER_H +#define MRTPFILEWRITEOBSERVER_H + +// INCLUDES +#include + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION + +/** +* RTP file data write observer. +* +* @lib RtpClipHandler.lib +* @since Series 60 3.0 +*/ +class MRtpFileWriteObserver + { + +public: // Data types + + /** + * Defines RTP recording params + */ + class SRtpRecParams + { + + public: // Data + + // Clip full path. + TPath iClipPath; + + // SDP data. + TPtrC8 iSdpData; + + // Service name + TPtrC iService; + + // Program name. + TPtrC iProgram; + + // Post accuisition rule. + TInt iPostRule; + + // Parental rate. + TInt iParental; + + // Recording start time in terminal time. + TTime iStartTime; + + // Estimated recording end time in terminal time. + TTime iEndTime; + + }; + + /** + * Defines save action. + */ + enum TRtpSaveAction + { + ESaveIdle = KErrNotFound, + ESaveNormal = KErrNone, + ESaveTimeShift, + ESavePause, + ESaveEnd + }; + + /** + * Defines RTP packet type. + */ + enum TRtpType + { + ERtpNone = KErrNotFound, + ERtpAudio = 10, + ERtcpAudio, + ERtpVideo, + ERtcpVideo, + ERtpClipPause, + ERtpClipEnd, + ERtpSubTitle, + ERtcpSubTitle + }; + +public: // New methods + + /** + * Group saved indication. + * @since Series 60 3.0 + * @return none. + */ + virtual void GroupSaved() = 0; + + /** + * Clip handler status of recording. + * @since Series 60 3.0 + * @param aStatus a status of file writing. + * @return none. + */ + virtual void WriteStatus( const TInt aStatus ) = 0; + + }; + +#endif // MRTPFILEWRITEOBSERVER_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Videoutils build file* +*/ + + +PRJ_PLATFORMS +WINSCW ARMV5 + + +#include "../videoscheduler_api/group/bld.inf" +#include "../videoconnutility_api/group/bld.inf" +#include "../videoplayer_constants_api/group/bld.inf" + +PRJ_EXPORTS + +PRJ_MMPFILES + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../inc/ipvideo/vcxconnectionutility.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/vcxconnectionutility.h ) +../inc/ipvideo/vcxconnutilengineobserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/vcxconnutilengineobserver.h ) +../inc/ipvideo/tvcxconnutilnotifierparams.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/tvcxconnutilnotifierparams.h ) + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/inc/ipvideo/tvcxconnutilnotifierparams.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/inc/ipvideo/tvcxconnutilnotifierparams.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: data structure for passing messages between con utility and* +*/ + + + + + +#ifndef TVCXCONNUTILNOTIFIERPARAMS_ +#define TVCXCONNUTILNOTIFIERPARAMS_ + +// Deprecation warning +#warning This header file has been deprecated. Will be removed in one of the next SDK releases. + +/** + * Max lenght of the string passed via message + */ +const TInt KConnUtilMaxMsgLen = 255; + +/** + * implementation UID for the notifier plugin that + * videoconnutility uses + */ +const TUid KVcxNotifierImplUid = { 0x20016BA5 }; + +/** +* TVcxNotifierParams class. Class is used as message between +* vcxconnectionutility and notifier plugin. Message is to be sent to notifier, +* when connection is being created for showing "connecting.." or similar msg and +* when connection creation is ready. +* +* When connection is to be created, vcxconnectionutility sends message via through +* notifier server where it's passed to the notifier plugin with uid of KVcxNotifierImplUid +* vcxconnectionutility might pass additional message string to be shown in the dialogg +* with iMsg descriptor. +* +* Event can be either: +* - EConnecting (1), when notifier should show dialog asynchronously +* - EConnected (2), when vcxconnectionutility wants plugin to close dialog synchronously +* enums are defined in vcxconnectionutility.hrh +* +* If plugin wants to nofify about closing of dialog before vcxconnectionutility wants it to be closed. +* it should complete async dialog showing with result of KErrCancel. +* +*/ +class TVcxNotifierParams + { + public: + + enum TVcxNotifierEventId + { + EConnecting = 1, + EConnected + }; + + /** + * Event. + */ + TInt iEvent; + + /** + * String message. + */ + TBuf iMsg; + }; + + + +#endif // TVCXCONNUTILNOTIFIERPARAMS_ diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/inc/ipvideo/vcxconnectionutility.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/inc/ipvideo/vcxconnectionutility.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,211 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle connection creation.* +*/ + + +#ifndef __VCX_CONNUTIL_H_ +#define __VCX_CONNUTIL_H_ + +// Deprecation warning +#warning This header file has been deprecated. Will be removed in one of the next SDK releases. + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CVcxConnUtilImpl; +class MConnUtilEngineObserver; + + +// CLASS DECLARATION +/** +* Class is the main interface class for the vcxconnectionutility.dll. +* By using this class, client can fetch iap ID and maintain an active connection +* for that iap. +* Usage: +* @code +* #include +* #include // for receiving events from ALR and iap changes +* +* // Instantiation of connectionutility is done by Instance() +* // every Instance call increments internal reference count by +* // one. When reference count is decremented to 0 deallocation +* // occurs. Client should make sure that it calls as many +* // DecreaseReferenceCount() as it calls InstanceL() +* +* CVcxConnectionUtility* conUtil = CVcxConnectionUtility::InstanceL(); +* +* // in case client is interested in events from ALR or from iap changes, +* // client must implement MConnUtilEngineObserver interface and register +* // as observer. See MConnUtilEngineObserver documentation for details +* conUtil->RegisterObserverL( this ); +* +* // getting the best possible iap is handled by the GetIap +* TInt err( KErrNone ); +* TUint32 iapId( 0 ); +* err = conUtil->GetIap( iapId, EFalse ); +* // in case client does not want the "connecting" dialog // shown, aSilent +* // parameter should be ETrue +* +* // client can try to explicitly disconnect connection, but if there are other references +* // connection is not closed. +* // suggestion is to maintain connection at all time as long as vcxconnectionutility +* // is being used and just react to notifications +* conUtil->Disconnect(); +* +* // when connectionutility is no longer needed, client must call DecreaseReferenceCount() +* // if there are no more references left, memory allocated for the library is deallocated +* // and possible active connection is closed +* // if client has registered as observer, it should deregister first +* conUtil->RemoveObserver(); +* conUtil->DecreaseReferenceCount(); +* conutil = NULL; +* +* @endcode +* +* +* @lib vcxconnectionutility.dll +*/ +NONSHARABLE_CLASS( CVcxConnectionUtility) : public CActive + { + + public: // Constructors and destructor + + /** + * returns instance of the singleton object. This increases + * local reference count by one, so utility members should + * not be called through this. + * + * @return Pointer to CVcxConnectionUtility object. + */ + IMPORT_C static CVcxConnectionUtility* InstanceL(); + + /** + * Remove the reference to this connectionutility instance. + * + * This should be called when client does not need + * utility anymore. + * + * Decreases the reference count by one. When + * all references are removed, the ui engine is destructed. + */ + IMPORT_C void DecreaseReferenceCount(); + + private: + /** + * Destructor. + */ + virtual ~CVcxConnectionUtility(); + + /** + * constructor. + * + */ + CVcxConnectionUtility( ); + + /** + * Private 2nd phase construction. + */ + void ConstructL(); + + /** + * From CActive, handles an active object’s request completion event + */ + void RunL(); + + /** + * From CActive, implements cancellation of an outstanding request. + * This function is called as part of the active object’s Cancel(). + */ + void DoCancel(); + + public: // New functions + + + /** + * Returns open IAP, if connection is not opened it is created + * + * @param aIapId On return, IAP ID. + * @param aSilent If ETrue, tries to open connection silently (without dialogs) + * In the 'Always ask' mode query dialog is always shown. + * + * @return KErrNone or one of the system wide error codes. + */ + IMPORT_C TInt GetIap( TUint32& aIapId, TBool aSilent ); + + /** + * Gets WAP id from IAP id. Leaves with KErrNotFound if no record with given + * IAP id is found. + * + * @param aIapId IAP id to match. + * @return WAP id matching the given IAP id. + */ + IMPORT_C TUint32 WapIdFromIapIdL( TUint32 aIapId ); + + /** + * Closes open connection. + */ + IMPORT_C void DisconnectL(); + + /** + * Registers observer + * + * @param MConnUtilEngineObserver + */ + IMPORT_C void RegisterObserverL( MConnUtilEngineObserver* aObserver ); + + /** + * Removes observer from the array of observers + * + * @param MConnUtilEngineObserver + */ + IMPORT_C void RemoveObserver( MConnUtilEngineObserver* aObserver ); + + /** + * Displays a wait note. Method calls notifier to show + * dialog and sets this active object active. If user cancels + * dialog by pressing cancel, RunL is being called with KErrCancel. + * + * @param aConnectionName name of connection to show on the dialog + */ + void DisplayWaitNote( const TDesC& aConnectionName = KNullDesC ); + + /** + * closes a wait note + * + */ + void CloseWaitNote(); + + + private: // Data + + /** + * Count of references to this object. + */ + TInt iReferenceCount; + + /** + * Utility implementation object + */ + CVcxConnUtilImpl* iUtilImpl; + + /** + * Notifier used for showing connecting dialogs + */ + RNotifier iNotifier; + + }; +#endif // __VCXNS_CONNUTIL_H_ +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/inc/ipvideo/vcxconnutilengineobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/inc/ipvideo/vcxconnutilengineobserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for network event handling* +*/ + + +#ifndef _M_CVCX_CONUTILENGINEOBS_H__ +#define _M_CVCX_CONUTILENGINEOBS_H__ + +// Deprecation warning +#warning This header file has been deprecated. Will be removed in one of the next SDK releases. + + +// CLASS DECLARATION +/** +* Interface for the clients of vcxconnectionutility to receive and react +* for iap changes and roaming. +* It is not required for a client to implement this interface. In that case +* vcxconnectionutility always excepts client to allow roaming. +* +*/ + +class MConnUtilEngineObserver + + { + public: + + /** + * This method is called by the vcxconnectionutility when + * it has received a notification about the availability of + * "better" iaps in the network. This can happen + * when WLAN defined in the corresponding destination becomes + * available or when WLAN carrier is lost and there is a defined + * 3G/gprs iap (or another available WLAN) in the destination + * being used. + * + * Client does not have to accept the changing of the iap. If the client + * returns EFalse notifying it does not want to roam, then the + * iap is not changed. + * + * This however can result in disconnecting, if the old iap is + * no longer available, as happens when WLAN carrier is lost + * + * @return TBool ETrue: roaming accepted, EFalse: Roaming not accepted + * + */ + virtual TBool RequestIsRoamingAllowedL() = 0; + + /** + * This method is called by the vcxconnectionutility when + * there have been some changes in the iap currently using: + * + * Connection lost: this happens when for example WLAN carrier + * is lost and there is no other iap to use or when the corresponding + * connection is closed by some other application. + * + * Iap change by the roaming: if the client has accepted roaming, + * vcxconnectionutility notifies about new iap is ready to use + * + * When client is being called by this method, it can request an + * iap id by calling CVcxConnectionUtility::GetIap- + * + * + */ + virtual void IapChangedL() = 0; + }; + +#endif // _M_CVCX_CONUTILENGINEOBS_H__ diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/Bwins/VCXConnUtilTestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/Bwins/VCXConnUtilTestu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/EABI/VCXConnUtilTestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/EABI/VCXConnUtilTestU.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI26CVCXConnUtilTestSubscriber @ 2 NONAME ; ## + _ZTV26CVCXConnUtilTestSubscriber @ 3 NONAME ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/group/VCXConnUtilTestExe.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/group/VCXConnUtilTestExe.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + +#include + +TARGET VCXConnUtilTestExe.exe +TARGETTYPE exe +//UID 0x1000008c 0x101FB3E1 +UID 0x1000008D 0x101FB3E3 + +CAPABILITY CAP_GENERAL_DLL -DRM -AllFiles + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../VCXTestCommon/inc +USERINCLUDE ../../VCXTestUtilModule/inc +USERINCLUDE ../../../inc/ipvideo + +/// SYSTEMINCLUDE /Epoc32/include/ecom +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE VCXConnUtilTestExe.cpp +SOURCE VCXConnUtilTester.cpp +SOURCE VCXConnUtilTestExeTester.cpp +SOURCE ../../src/VCXConnUtilTestSubscriber.cpp + +LIBRARY cone.lib +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY VCXTestCommon.lib +LIBRARY FLOGGER.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY edbms.lib // rdbstoredatabase +LIBRARY centralrepository.lib +LIBRARY vcxconnectionutility.lib + +LANG SC diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES +VCXConnUtilTestExe.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTestExe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTestExe.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +#ifndef __VCXCONNUTILTESTEXE_H__ +#define __VCXCONNUTILTESTEXE_H__ + +// Include Files + +#include + +// Function Prototypes + +/** + * Test exe needed to run video connection utility in multiple processes. + */ +GLDEF_C TInt E32Main(); + +#endif // __VCXCONNUTILTESTEXE_H__ + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTestExeTester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTestExeTester.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXCONNUTILTESTEXETESTER_H_ +#define VCXCONNUTILTESTEXETESTER_H_ + + +// INCLUDES +#include +#include +#include +#include "VCXConnUtilTestPSObserver.h" + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +class CVCXConnUtilTestSubscriber; +class CVCXConnUtilTester; + +/** +* Observer PS key and when it changes to 1 sends msg to queue to stop the tester exe. +* @since +*/ +class CVCXConnUtilTestExeTester : public CBase, public MVCXConnUtilTestPSObserver + { + public: // Constructors and destructor + /** + * Two-phased constructor. + */ + static CVCXConnUtilTestExeTester * NewL( TUint aProcessId ); + + /** + * Destructor. + */ + virtual ~CVCXConnUtilTestExeTester(); + + public: // New functions + + TBool Running() { return iRunning; }; + + protected: // From base classes + + void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TInt& aValue ); + + void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TDesC& aValue ); + + private: + + /** + * C++ default constructor. + */ + CVCXConnUtilTestExeTester(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL( TUint aProcessId ); + + private: // Data + TBuf<256> iName; + + CVCXConnUtilTester* iTester; + + CVCXConnUtilTestSubscriber* iGlobalShutdownSubcriber; + + CVCXConnUtilTestSubscriber* iCmdSubcriber; + + TBool iRunning; + + TInt iPSKeyBase; + + TInt iAckCount; + }; + +#endif // VCXCONNUTILTESTEXETESTER_H_ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/inc/VCXConnUtilTester.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +#ifndef VCXCONNUTILTESTER_H +#define VCXCONNUTILTESTER_H + +#include +#include "VCXConnUtilTester.h" + +#include "vcxconnutilengineobserver.h" +#include "../../../../../videoconnutility/inc/vcxconnectionutility.hrh" +#include "MIptvTestTimerObserver.h" + +class CIptvTestTimer; +class CIptvTestActiveWait; +class CVcxConnectionUtility; + +/** +* Video connection utility tester class. +*/ +class CVCXConnUtilTester : public CBase, + public MConnUtilEngineObserver, + public MIptvTestTimerObserver + { + public: + + /** + * Two-phased constructor. + */ + static CVCXConnUtilTester* NewL(); + + /** + * C++ default constructor. + */ + CVCXConnUtilTester(); + + /** + * Destructor. + */ + ~CVCXConnUtilTester(); + + public: // Public new functions + + /** + * ConnUtil GetIap + * + * @return an error code. + */ + TInt GetIap( TUint32& aIapId, TBool aSilent, TBool aIsTimed ); + + /** + * ConnUtil WapIdFromIapIdL + */ + TUint32 WapIdFromIapIdL( const TInt32& aIapId ); + + /** + * ConnUtil Disconnect + * + * @return an error code. + */ + TInt Disconnect(); + + private: // Constructors and destructor + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Functions from base classes + /** + * From MConnUtilEngineObserver. + */ + TBool RequestIsRoamingAllowedL(); + + /** + * From MConnUtilEngineObserver. + */ + void IapChangedL(); + + /** + * From MIptvTestTimerObserver Handles timer completion + * @since + * @param aTimerId + * @param aError + */ + void TimerComplete(TInt aTimerId, TInt aError); + + private: // Data + + CVcxConnectionUtility* iConnUtil; + + public: // Data + TBool iIsRoamingAllowed; + + TBool iLeaveAtRoamingRequest; + + TInt iDelaySecondsAtRoamingRequest; + + CIptvTestTimer* iTimer; + + CIptvTestActiveWait* iWait; + + // This will show in function traces. + TBuf<256> iName; + }; + +#endif // VCXCONNUTILTESTER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/src/VCXConnUtilTestExe.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXConnUtilTestExe/src/VCXConnUtilTestExe.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +// Include Files + +#include "VCXConnUtilTestExe.h" +#include +#include +#include "VCXTestLog.h" + +#include "VCXConnUtilTestCommon.h" +#include "CIptvTestActiveWait.h" +#include "CIptvTestTimer.h" +#include "VCXConnUtilTestExeTester.h" +#include "VCXTestTimerWait.h" + +// Constants + +// Global Variables + +// Local Functions + +// Implements just Error() to avoid panic +class CSimpleScheduler : public CActiveScheduler + { + void Error( TInt ) const{} // From CActiveScheduler + }; + +LOCAL_C void MainL() + { + VCXLOGLO1(">>>VCXConnUtilTestExe ## MainL"); + + RProcess process; + + CVCXTestTimerWait* wait = CVCXTestTimerWait::NewL(); + CleanupStack::PushL( wait ); + + // Create stopper class. + CVCXConnUtilTestExeTester* stopper = CVCXConnUtilTestExeTester::NewL( process.Id() ); + CleanupStack::PushL( stopper ); + + // Loop until done. + while( stopper->Running() ) + { + wait->WaitL( 1000000 ); + } + + VCXLOGLO1("VCXConnUtilTestExe ## Loop done!"); + + CleanupStack::PopAndDestroy( stopper ); + CleanupStack::PopAndDestroy( wait ); + + VCXLOGLO1("<< // CleanupResetAndDestroyPushL +#include + +#include "VCXTestCommon.h" +#include "CIptvTestTimer.h" +#include "VCXConnUtilTestCommon.h" +#include "VCXConnUtilTestExeTester.h" +#include "VCXConnUtilTestSubscriber.h" +#include "VCXConnUtilTestPSObserver.h" +#include "VCXConnUtilTester.h" + +#include "VCXTestLog.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestExeTester:: +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVCXConnUtilTestExeTester* CVCXConnUtilTestExeTester::NewL( TUint aProcessId ) + { + VCXLOGLO1(">>>CVCXConnUtilTestExeTester::NewL"); + CVCXConnUtilTestExeTester* self = new (ELeave) CVCXConnUtilTestExeTester(); + CleanupStack::PushL(self); + self->ConstructL( aProcessId ); + CleanupStack::Pop( self ); + VCXLOGLO1("<<>>CVCXConnUtilTestExeTester::~CVCXConnUtilTestExeTester"); + + delete iGlobalShutdownSubcriber; + iGlobalShutdownSubcriber = NULL; + + delete iCmdSubcriber; + iCmdSubcriber = NULL; + + delete iTester; + iTester = NULL; + + // Remove the P&S keys for this process. + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmd + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase); + RProperty::Delete( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase); + + VCXLOGLO1("<<>>CVCXConnUtilTestExeTester::CVCXConnUtilTestExeTester"); + + VCXLOGLO1("<<>>CVCXConnUtilTestExeTester::ConstructL"); + + iTester = CVCXConnUtilTester::NewL(); + + // Define and listen global shutdown key. + + TInt err( KErrNone ); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalShutdownKey, RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExeGlobalShutdownKey: %d, err: %d", + KVCXConnUtilTestExeGlobalShutdownKey, err); + + iGlobalShutdownSubcriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExeGlobalShutdownKey, RProperty::EInt, this ); + iGlobalShutdownSubcriber->Start(); + VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExeGlobalShutdownKey: %d", + KVCXConnUtilTestExeGlobalShutdownKey); + + // Get PS key base. + + TInt testerCount( 0 ); + + User::LeaveIfError( CVCXTestCommon::GetPSProperty( + KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, testerCount ) ); + + testerCount++; + + iPSKeyBase = testerCount * 1000 + aProcessId; + + VCXLOGLO2("CVCXConnUtilTestExeTester:: iPSKeyBase: %d", iPSKeyBase); + + // Define private P&S keys. + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmd: %d, err: %d", + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdIntParam1: %d, err: %d", + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdIntParam2: %d, err: %d", + KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, + RProperty::EText ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyCmdDescParam1: %d, err: %d", + KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseAck: %d, err: %d", + KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseCmd: %d, err: %d", + KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseParam: %d, err: %d", + KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, err); + + err = RProperty::Define( KVCXConnUtilTestPScategory, KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, + RProperty::EInt ); + VCXLOGLO3("CVCXConnUtilTestExeTester:: Define KVCXConnUtilTestExePsKeyResponseError: %d, err: %d", + KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err); + + // Subscribe P&S cmd key. + + iCmdSubcriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, RProperty::EInt, this ); + iCmdSubcriber->Start(); + VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExePsKeyCmd: %d", + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase); + + iRunning = ETrue; + + // And update the tester count to P&S. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( + KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, testerCount ) ); + + VCXLOGLO1("<<", &iName); + } + return; + } + + VCXLOGLO2(">>>CVCXConnUtilTestExeTester::ValueChangedL TInt (%S)", &iName); + + // Store possible parameters. + TInt intParam1(0); + TInt intParam2(0); + TBuf<256> descParam1; + + CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, intParam1 ); + CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, intParam2 ); + CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, descParam1 ); + + // Set response that cmd has been gotten. + + VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting KVCXConnUtilTestExePsKeyResponseAck (%S) ----->", &iName); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, iAckCount++ ); + + // Handle commands. + if( aKey == KVCXConnUtilTestExePsKeyCmd + iPSKeyBase ) + { + switch( aValue ) + { + case EVcxConnUtilCommandShutdown: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandShutdown (%S) ----->", &iName); + iRunning = EFalse; + } + break; + + case EVcxConnUtilCommandSetName: + { + iName.Copy( descParam1 ); + iTester->iName.Copy( descParam1 ); + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetName (%S) ----->", &iName); + } + break; + + case EVcxConnUtilCommandGetIap: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandGetIap (%S) ----->", &iName); + + TUint32 iapId(0); + TBool silent = static_cast( intParam1); + TBool isTimed = static_cast( intParam2 ); + + TInt err = iTester->GetIap( iapId, silent, isTimed ); + + if( err != KErrNone || iapId == 0 ) + { + VCXLOGLO4("CVCXConnUtilTestExeTester:: GetIap error: %d, iap: %d (%S)", err, iapId, &iName); + } + + VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandGetIap (%S) ----->", + &iName); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, iapId ); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err ); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandGetIap ); + + } + break; + + + case EVcxConnUtilCommandGetWapIdForIap: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandGetWapIdForIap (%S) ----->", &iName); + + TInt err( KErrNone ); + + TUint32 wapId( 0 ); + TRAP( err, iTester->WapIdFromIapIdL( intParam1 ) ); + + VCXLOGLO4("CVCXConnUtilTestExeTester:: GetWapIdFromIapIdL returned wapId: %d, err: %d (%S)", wapId, err, &iName); + + VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandGetWapIdForIap (%S) ----->", + &iName); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, wapId ); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err ); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandGetWapIdForIap ); + + } + break; + + case EVcxConnUtilCommandDisconnect: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandDisconnect (%S) ----->", &iName); + + TInt err = iTester->Disconnect(); + + if( err != KErrNone ) + { + VCXLOGLO3("CVCXConnUtilTestExeTester:: disconnect error: %d (%S)", err, &iName); + } + + VCXLOGLO2("CVCXConnUtilTestExeTester:: Setting response for EVcxConnUtilCommandDisconnect (%S) ----->", + &iName); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err ); + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, EVcxConnUtilCommandDisconnect ); + } + break; + + case EVcxConnUtilCommandSetRoamingAllowed: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetRoamingAllowed (%S) ----->", + &iName); + iTester->iIsRoamingAllowed = intParam1; + } + break; + + case EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest (%S) ----->", &iName); + iTester->iLeaveAtRoamingRequest = intParam1; + } + break; + + case EVcxConnUtilCommandSetDelayBeforeRoamingRequest: + { + VCXLOGLO2("CVCXConnUtilTestExeTester:: cmd EVcxConnUtilCommandSetDelayBeforeRoamingRequest (%S) ----->", &iName); + iTester->iDelaySecondsAtRoamingRequest = intParam1; + } + break; + + default: + { + VCXLOGLO3("CVCXConnUtilTestExeTester:: UNKNOWN cmd %d! (%S) ----->", aValue, &iName); + } + break; + } + } + + VCXLOGLO2("<<>>CVCXConnUtilTestExeTester::ValueChangedL TDesC"); + + if( aUid == KVCXConnUtilTestPScategory ) + { + + } + + VCXLOGLO1("<< +#include + +#include "VCXTestLog.h" + +#include "VCXConnUtilTester.h" +#include "vcxconnectionutility.h" +#include "CIptvTestTimer.h" +#include "CIptvTestActiveWait.h" + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTester::NewL +// ----------------------------------------------------------------------------- +// +CVCXConnUtilTester* CVCXConnUtilTester::NewL() + { + VCXLOGLO1(">>>CVCXConnUtilTester::NewL"); + CVCXConnUtilTester* self = new (ELeave) CVCXConnUtilTester(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + VCXLOGLO1("<<>>CVCXConnUtilTester::ConstructL"); + + iIsRoamingAllowed = ETrue; + iLeaveAtRoamingRequest = EFalse; + iDelaySecondsAtRoamingRequest = 0; + + iConnUtil = CVcxConnectionUtility::InstanceL(); + iConnUtil->RegisterObserverL( this ); + + iTimer = CIptvTestTimer::NewL( *this, 0 ); + + iWait = CIptvTestActiveWait::NewL(); + + VCXLOGLO1("<<>>CVCXConnUtilTester::~CVCXConnUtilTester (%S)", &iName); + + if( iConnUtil ) + { + iConnUtil->RemoveObserver( this ); + TRAP_IGNORE( iConnUtil->DisconnectL() ); + iConnUtil->DecreaseReferenceCount(); + } + iConnUtil = NULL; + + if( iTimer ) + { + iTimer->CancelTimer(); + delete iTimer; + iTimer = NULL; + } + + delete iWait; + iWait = NULL; + + VCXLOGLO2("<<>>CVCXConnUtilTester::GetIap (%S)", &iName); + VCXLOGLO2("CVCXConnUtilTester:: isTimed: %d", aIsTimed); + + if( aIsTimed ) + { + // Time GetIap request when next minute starts + TInt seconds( 0 ); + TTime now; + now.HomeTime(); + + TDateTime time = now.DateTime(); + + if( time.Second() >= 55 ) + { + seconds += 10; // Wait extra 10 seconds to make sure any other test module is ready. + } + + seconds += 60 - time.Second(); // Wait to end of minute + + VCXLOGLO3("CVCXConnUtilTester:: waiting %d seconds (%S)", seconds, &iName); + + TUint32 microSeconds( 0 ); + microSeconds = seconds * 1000000; + + microSeconds += 1 - time.MicroSecond(); // And any extra microseconds + + iTimer->After( microSeconds ); + iWait->Start(); + } + + VCXLOGLO2("CVCXConnUtilTester:: making GetIap call (%S) ----->", &iName); + TInt err = iConnUtil->GetIap( aIapId, aSilent ); + VCXLOGLO2("CVCXConnUtilTester:: GetIap returns: %d", err); + VCXLOGLO2("<<>>CVCXConnUtilTester::WapIdFromIapIdL (%S) ----->", &iName); + TUint32 aWapId = iConnUtil->WapIdFromIapIdL( aIapId ); + VCXLOGLO2("CVCXConnUtilTester:: WapIdFromIapIdL returns %d", aWapId); + VCXLOGLO2("<<>>CVCXConnUtilTester::Disconnect (%S) ----->", &iName); + TRAPD( err, iConnUtil->DisconnectL() ); + VCXLOGLO2("CVCXConnUtilTester:: Disconnect returns %d", err); + VCXLOGLO2("<<>>CVCXConnUtilTester::RequestIsRoamingAllowedL (%S) ----->", &iName); + + if( iLeaveAtRoamingRequest ) + { + VCXLOGLO1("CVCXConnUtilTester:: iLeaveAtRoamingRequest set. LEAVING!"); + User::Leave( KErrTotalLossOfPrecision ); + } + + if( iDelaySecondsAtRoamingRequest > 0 ) + { + VCXLOGLO2("CVCXConnUtilTester:: delay: %d", iDelaySecondsAtRoamingRequest ); + iTimer->After( iDelaySecondsAtRoamingRequest * 1000000 ); + iWait->Start(); + } + + VCXLOGLO2("CVCXConnUtilTest:: iIsRoamingAllowed = %d", iIsRoamingAllowed); + + VCXLOGLO2("<<>>CVCXConnUtilTester::IapChangedL (%S)", &iName); + VCXLOGLO2("<<>>CVCXConnUtilTester::TimerComplete, err: %d (%S)", aError, &iName); + iWait->Stop(); + VCXLOGLO2("<< &, class RPointerArray &) + ?ConnectL@CTestUtilConnection@@QAEXXZ @ 40 NONAME ; void CTestUtilConnection::ConnectL(void) + ?ConstructL@CIptvTestActiveWait@@AAEXXZ @ 41 NONAME ; void CIptvTestActiveWait::ConstructL(void) + ?ConstructL@CIptvTestDownloadManager@@AAEXXZ @ 42 NONAME ; void CIptvTestDownloadManager::ConstructL(void) + ?ConstructL@CIptvTestVideoCreator@@AAEXXZ @ 43 NONAME ; void CIptvTestVideoCreator::ConstructL(void) + ?ConstructL@CVCXTestMessageWait@@AAEXXZ @ 44 NONAME ; void CVCXTestMessageWait::ConstructL(void) + ?ConstructL@CVCXTestTimerWait@@AAEXXZ @ 45 NONAME ; void CVCXTestTimerWait::ConstructL(void) + ?CoolDownL@CVCXTestMessageWait@@QAEXH@Z @ 46 NONAME ; void CVCXTestMessageWait::CoolDownL(int) + ?CopyMethodL@CIptvTestUtilALR@@QAEXAAVTDesC16@@00@Z @ 47 NONAME ; void CIptvTestUtilALR::CopyMethodL(class TDesC16 &, class TDesC16 &, class TDesC16 &) + ?CreateBadIapL@CVCXTestCommon@@QAEKAAVTDesC16@@@Z @ 48 NONAME ; unsigned long CVCXTestCommon::CreateBadIapL(class TDesC16 &) + ?CreateDestinationL@CIptvTestUtilALR@@QAEXAAVTDesC16@@@Z @ 49 NONAME ; void CIptvTestUtilALR::CreateDestinationL(class TDesC16 &) + ?CreateVerifyData@CVCXTestCommon@@QAEHAAVTDesC16@@H@Z @ 50 NONAME ; int CVCXTestCommon::CreateVerifyData(class TDesC16 &, int) + ?CreateVerifyDataL@CIptvTestVerifyData@@QAEHAAVTDesC16@@H@Z @ 51 NONAME ; int CIptvTestVerifyData::CreateVerifyDataL(class TDesC16 &, int) + ?CreateVideoFileL@CVCXTestCommon@@QAEXW4TIptvTestVideoType@CIptvTestVideoCreator@@AAVTDesC16@@H@Z @ 52 NONAME ; void CVCXTestCommon::CreateVideoFileL(enum CIptvTestVideoCreator::TIptvTestVideoType, class TDesC16 &, int) + ?CreateVideoFilesL@CVCXTestCommon@@QAEXW4TIptvTestVideoType@CIptvTestVideoCreator@@AAVTDesC16@@HAAV?$RPointerArray@VHBufC16@@@@@Z @ 53 NONAME ; void CVCXTestCommon::CreateVideoFilesL(enum CIptvTestVideoCreator::TIptvTestVideoType, class TDesC16 &, int, class RPointerArray &) + ?CreateVideoL@CIptvTestVideoCreator@@QAEXW4TIptvTestVideoType@1@AAVTDesC16@@H@Z @ 54 NONAME ; void CIptvTestVideoCreator::CreateVideoL(enum CIptvTestVideoCreator::TIptvTestVideoType, class TDesC16 &, int) + ?CreateVideosL@CIptvTestVideoCreator@@QAEXW4TIptvTestVideoType@1@AAVTDesC16@@HAAV?$RPointerArray@VHBufC16@@@@@Z @ 55 NONAME ; void CIptvTestVideoCreator::CreateVideosL(enum CIptvTestVideoCreator::TIptvTestVideoType, class TDesC16 &, int, class RPointerArray &) + ?Deactivate@CIptvTestEvent@@QAEXXZ @ 56 NONAME ; void CIptvTestEvent::Deactivate(void) + ?DeleteDestinationL@CIptvTestUtilALR@@QAEXAAVTDesC16@@@Z @ 57 NONAME ; void CIptvTestUtilALR::DeleteDestinationL(class TDesC16 &) + ?DeleteDummyFilesL@CVCXTestCommon@@QAEXH@Z @ 58 NONAME ; void CVCXTestCommon::DeleteDummyFilesL(int) + ?DeleteMethodL@CIptvTestUtilALR@@QAEXAAVTDesC16@@0@Z @ 59 NONAME ; void CIptvTestUtilALR::DeleteMethodL(class TDesC16 &, class TDesC16 &) + ?DoCancel@CVCXTestPSSubscriber@@EAEXXZ @ 60 NONAME ; void CVCXTestPSSubscriber::DoCancel(void) + ?DownloadL@CIptvTestDownloadManager@@QAEHAAVTDesC16@@000JH@Z @ 61 NONAME ; int CIptvTestDownloadManager::DownloadL(class TDesC16 &, class TDesC16 &, class TDesC16 &, class TDesC16 &, long, int) + ?EnableTimestamps@CIptvTestVerifyData@@QAEXH@Z @ 62 NONAME ; void CIptvTestVerifyData::EnableTimestamps(int) + ?EnableVerifyTimestamps@CVCXTestCommon@@QAEXH@Z @ 63 NONAME ; void CVCXTestCommon::EnableVerifyTimestamps(int) + ?EndWait@CVCXTestPSSubscriber@@QAEXXZ @ 64 NONAME ; void CVCXTestPSSubscriber::EndWait(void) + ?EnsureFileIsNotInUse@CVCXTestCommon@@QAEHABVTPtrC16@@@Z @ 65 NONAME ; int CVCXTestCommon::EnsureFileIsNotInUse(class TPtrC16 const &) + ?EventHappened@CIptvTestEventWaiter@@QAEHPAVCIptvTestEvent@@PAPAV2@@Z @ 66 NONAME ; int CIptvTestEventWaiter::EventHappened(class CIptvTestEvent *, class CIptvTestEvent * *) + ?Get@CVCXTestPSSubscriber@@QAEHAAH@Z @ 67 NONAME ; int CVCXTestPSSubscriber::Get(int &) + ?Get@CVCXTestPSSubscriber@@QAEHAAVTDes16@@@Z @ 68 NONAME ; int CVCXTestPSSubscriber::Get(class TDes16 &) + ?GetDestinationIdL@CIptvTestUtilALR@@QAEHAAVTDesC16@@@Z @ 69 NONAME ; int CIptvTestUtilALR::GetDestinationIdL(class TDesC16 &) + ?GetError@CIptvTestDownloadManager@@QAEXAAVRHttpDownload@@AAJ@Z @ 70 NONAME ; void CIptvTestDownloadManager::GetError(class RHttpDownload &, long &) + ?GetEventCount@CIptvTestEventWaiter@@QAEHXZ @ 71 NONAME ; int CIptvTestEventWaiter::GetEventCount(void) + ?GetFileSize@CVCXTestCommon@@QAEHAAVTDesC16@@AAK@Z @ 72 NONAME ; int CVCXTestCommon::GetFileSize(class TDesC16 &, unsigned long &) + ?GetIapIdByNameL@CVCXTestCommon@@QAEHABVTDesC16@@AAK@Z @ 73 NONAME ; int CVCXTestCommon::GetIapIdByNameL(class TDesC16 const &, unsigned long &) + ?GetIapIdByTypeL@CVCXTestCommon@@QAEHW4TIptvTestIapType@1@AAKH@Z @ 74 NONAME ; int CVCXTestCommon::GetIapIdByTypeL(enum CVCXTestCommon::TIptvTestIapType, unsigned long &, int) + ?GetIapIdL@CVCXTestCommon@@QAEHABVTDesC16@@AAK@Z @ 75 NONAME ; int CVCXTestCommon::GetIapIdL(class TDesC16 const &, unsigned long &) + ?GetIapNameById@CVCXTestCommon@@QAEHAAVTDes16@@K@Z @ 76 NONAME ; int CVCXTestCommon::GetIapNameById(class TDes16 &, unsigned long) + ?GetName@CIptvTestEvent@@QAEXAAVTDes16@@@Z @ 77 NONAME ; void CIptvTestEvent::GetName(class TDes16 &) + ?GetPSProperty@CVCXTestCommon@@SAHVTUid@@IAAH@Z @ 78 NONAME ; int CVCXTestCommon::GetPSProperty(class TUid, unsigned int, int &) + ?GetPSProperty@CVCXTestCommon@@SAHVTUid@@IAAVTDes16@@@Z @ 79 NONAME ; int CVCXTestCommon::GetPSProperty(class TUid, unsigned int, class TDes16 &) + ?GetState@CTestUtilConnection@@QAE?AW4TConnectionState@1@XZ @ 80 NONAME ; enum CTestUtilConnection::TConnectionState CTestUtilConnection::GetState(void) + ?GetVideoFile@CIptvTestVideoCreator@@AAEXAAVTDes16@@W4TIptvTestVideoType@1@ABVTDesC16@@@Z @ 81 NONAME ; void CIptvTestVideoCreator::GetVideoFile(class TDes16 &, enum CIptvTestVideoCreator::TIptvTestVideoType, class TDesC16 const &) + ?HasTimeouted@CIptvTestEvent@@QAEHAAVTTime@@@Z @ 82 NONAME ; int CIptvTestEvent::HasTimeouted(class TTime &) + ?IsConnectionActive@CTestUtilConnectionWaiter@@QAEHK@Z @ 83 NONAME ; int CTestUtilConnectionWaiter::IsConnectionActive(unsigned long) + ?IsWaiting@CIptvTestActiveWait@@QAEHXZ @ 84 NONAME ; int CIptvTestActiveWait::IsWaiting(void) + ?ListDir@CVCXTestCommon@@QAEHABVTDesC16@@H@Z @ 85 NONAME ; int CVCXTestCommon::ListDir(class TDesC16 const &, int) + ?NewL@CIptvTestActiveWait@@SAPAV1@XZ @ 86 NONAME ; class CIptvTestActiveWait * CIptvTestActiveWait::NewL(void) + ?NewL@CIptvTestDownloadManager@@SAPAV1@PAVMTestUtilDownloadObserver@@@Z @ 87 NONAME ; class CIptvTestDownloadManager * CIptvTestDownloadManager::NewL(class MTestUtilDownloadObserver *) + ?NewL@CIptvTestEventWaiter@@SAPAV1@AAVMIptvTestEventWaiterObserver@@@Z @ 88 NONAME ; class CIptvTestEventWaiter * CIptvTestEventWaiter::NewL(class MIptvTestEventWaiterObserver &) + ?NewL@CIptvTestMobilecrashWatcher@@SAPAV1@H@Z @ 89 NONAME ; class CIptvTestMobilecrashWatcher * CIptvTestMobilecrashWatcher::NewL(int) + ?NewL@CIptvTestMobilecrashWatcher@@SAPAV1@XZ @ 90 NONAME ; class CIptvTestMobilecrashWatcher * CIptvTestMobilecrashWatcher::NewL(void) + ?NewL@CIptvTestTimer@@SAPAV1@AAVMIptvTestTimerObserver@@H@Z @ 91 NONAME ; class CIptvTestTimer * CIptvTestTimer::NewL(class MIptvTestTimerObserver &, int) + ?NewL@CIptvTestUtilALR@@SAPAV1@XZ @ 92 NONAME ; class CIptvTestUtilALR * CIptvTestUtilALR::NewL(void) + ?NewL@CIptvTestVerifyData@@SAPAV1@XZ @ 93 NONAME ; class CIptvTestVerifyData * CIptvTestVerifyData::NewL(void) + ?NewL@CIptvTestVideoCreator@@SAPAV1@XZ @ 94 NONAME ; class CIptvTestVideoCreator * CIptvTestVideoCreator::NewL(void) + ?NewL@CTestUtilConnection@@SAPAV1@PAVMTestUtilConnectionObserver@@@Z @ 95 NONAME ; class CTestUtilConnection * CTestUtilConnection::NewL(class MTestUtilConnectionObserver *) + ?NewL@CTestUtilConnectionWaiter@@SAPAV1@PAVMTestUtilConnectionObserver@@@Z @ 96 NONAME ; class CTestUtilConnectionWaiter * CTestUtilConnectionWaiter::NewL(class MTestUtilConnectionObserver *) + ?NewL@CVCXTestCommon@@SAPAV1@XZ @ 97 NONAME ; class CVCXTestCommon * CVCXTestCommon::NewL(void) + ?NewL@CVCXTestMessageWait@@SAPAV1@PAVMVCXTestMessageWaitObserver@@@Z @ 98 NONAME ; class CVCXTestMessageWait * CVCXTestMessageWait::NewL(class MVCXTestMessageWaitObserver *) + ?NewL@CVCXTestPSSubscriber@@SAPAV1@VTUid@@KW4TType@RProperty@@PAVMVCXTestPSObserver@@@Z @ 99 NONAME ; class CVCXTestPSSubscriber * CVCXTestPSSubscriber::NewL(class TUid, unsigned long, enum RProperty::TType, class MVCXTestPSObserver *) + ?NewL@CVCXTestStatsKeeper@@SAPAV1@XZ @ 100 NONAME ; class CVCXTestStatsKeeper * CVCXTestStatsKeeper::NewL(void) + ?NewL@CVCXTestTimerWait@@SAPAV1@XZ @ 101 NONAME ; class CVCXTestTimerWait * CVCXTestTimerWait::NewL(void) + ?NewLC@CIptvTestDownloadManager@@SAPAV1@PAVMTestUtilDownloadObserver@@@Z @ 102 NONAME ; class CIptvTestDownloadManager * CIptvTestDownloadManager::NewLC(class MTestUtilDownloadObserver *) + ?NewLC@CIptvTestUtilALR@@SAPAV1@XZ @ 103 NONAME ; class CIptvTestUtilALR * CIptvTestUtilALR::NewLC(void) + ?NewLC@CTestUtilConnection@@SAPAV1@PAVMTestUtilConnectionObserver@@@Z @ 104 NONAME ; class CTestUtilConnection * CTestUtilConnection::NewLC(class MTestUtilConnectionObserver *) + ?NewLC@CTestUtilConnectionWaiter@@SAPAV1@PAVMTestUtilConnectionObserver@@@Z @ 105 NONAME ; class CTestUtilConnectionWaiter * CTestUtilConnectionWaiter::NewLC(class MTestUtilConnectionObserver *) + ?ParseIntFromString@CVCXTestCommon@@SAHAAHAAVTDesC16@@@Z @ 106 NONAME ; int CVCXTestCommon::ParseIntFromString(int &, class TDesC16 &) + ?PrintIaps@CVCXTestCommon@@QAEXXZ @ 107 NONAME ; void CVCXTestCommon::PrintIaps(void) + ?ReadMobilecrashesL@CIptvTestMobilecrashWatcher@@QAEXAAV?$RPointerArray@VHBufC16@@@@ABVTDesC16@@@Z @ 108 NONAME ; void CIptvTestMobilecrashWatcher::ReadMobilecrashesL(class RPointerArray &, class TDesC16 const &) + ?ReceiveMessage@CVCXTestMessageWait@@QAEXJH@Z @ 109 NONAME ; void CVCXTestMessageWait::ReceiveMessage(long, int) + ?RemoveUsedDestinationCenRepL@CIptvTestUtilALR@@QAEXXZ @ 110 NONAME ; void CIptvTestUtilALR::RemoveUsedDestinationCenRepL(void) + ?Reset@CIptvTestEventWaiter@@QAEHXZ @ 111 NONAME ; int CIptvTestEventWaiter::Reset(void) + ?Reset@CVCXTestMessageWait@@QAEXXZ @ 112 NONAME ; void CVCXTestMessageWait::Reset(void) + ?ResetReceivedMessages@CVCXTestMessageWait@@QAEXXZ @ 113 NONAME ; void CVCXTestMessageWait::ResetReceivedMessages(void) + ?ReturnMobileCrashCount@CIptvTestMobilecrashWatcher@@QAEHXZ @ 114 NONAME ; int CIptvTestMobilecrashWatcher::ReturnMobileCrashCount(void) + ?ReturnNewCrashes@CIptvTestMobilecrashWatcher@@QAEHAAV?$RPointerArray@VHBufC16@@@@@Z @ 115 NONAME ; int CIptvTestMobilecrashWatcher::ReturnNewCrashes(class RPointerArray &) + ?Set@CVCXTestPSSubscriber@@QAEHAAH@Z @ 116 NONAME ; int CVCXTestPSSubscriber::Set(int &) + ?Set@CVCXTestPSSubscriber@@QAEHABVTDesC16@@@Z @ 117 NONAME ; int CVCXTestPSSubscriber::Set(class TDesC16 const &) + ?SetConnectionPreferences@CTestUtilConnection@@QAEXIK@Z @ 118 NONAME ; void CTestUtilConnection::SetConnectionPreferences(unsigned int, unsigned long) + ?SetDriveFreeSpaceL@CVCXTestCommon@@QAEXHI@Z @ 119 NONAME ; void CVCXTestCommon::SetDriveFreeSpaceL(int, unsigned int) + ?SetMethodBoolAttributeL@CIptvTestUtilALR@@QAEXAAVTDesC16@@0HH@Z @ 120 NONAME ; void CIptvTestUtilALR::SetMethodBoolAttributeL(class TDesC16 &, class TDesC16 &, int, int) + ?SetMethodIntAttributeL@CIptvTestUtilALR@@QAEXAAVTDesC16@@0HH@Z @ 121 NONAME ; void CIptvTestUtilALR::SetMethodIntAttributeL(class TDesC16 &, class TDesC16 &, int, int) + ?SetMethodPriorityL@CIptvTestUtilALR@@QAEXAAVTDesC16@@0K@Z @ 122 NONAME ; void CIptvTestUtilALR::SetMethodPriorityL(class TDesC16 &, class TDesC16 &, unsigned long) + ?SetMethodStringAttributeL@CIptvTestUtilALR@@QAEXAAVTDesC16@@0H0@Z @ 123 NONAME ; void CIptvTestUtilALR::SetMethodStringAttributeL(class TDesC16 &, class TDesC16 &, int, class TDesC16 &) + ?SetPSProperty@CVCXTestCommon@@SAHVTUid@@IABVTDesC16@@@Z @ 124 NONAME ; int CVCXTestCommon::SetPSProperty(class TUid, unsigned int, class TDesC16 const &) + ?SetPSProperty@CVCXTestCommon@@SAHVTUid@@IH@Z @ 125 NONAME ; int CVCXTestCommon::SetPSProperty(class TUid, unsigned int, int) + ?SetSystemTime@CVCXTestCommon@@SAHVTTime@@@Z @ 126 NONAME ; int CVCXTestCommon::SetSystemTime(class TTime) + ?SetTimeZone@CVCXTestCommon@@SAHAAVTDesC16@@@Z @ 127 NONAME ; int CVCXTestCommon::SetTimeZone(class TDesC16 &) + ?SetUsedDestinationL@CIptvTestUtilALR@@QAEXAAVTDesC16@@@Z @ 128 NONAME ; void CIptvTestUtilALR::SetUsedDestinationL(class TDesC16 &) + ?Start@CIptvTestActiveWait@@QAEHXZ @ 129 NONAME ; int CIptvTestActiveWait::Start(void) + ?Start@CVCXTestPSSubscriber@@QAEXXZ @ 130 NONAME ; void CVCXTestPSSubscriber::Start(void) + ?StartStatsKeepingL@CVCXTestStatsKeeper@@QAEXABVTDesC16@@0@Z @ 131 NONAME ; void CVCXTestStatsKeeper::StartStatsKeepingL(class TDesC16 const &, class TDesC16 const &) + ?Stop@CIptvTestActiveWait@@QAEHXZ @ 132 NONAME ; int CIptvTestActiveWait::Stop(void) + ?TerminateConnectionL@CTestUtilConnection@@QAEXXZ @ 133 NONAME ; void CTestUtilConnection::TerminateConnectionL(void) + ?TerminateDestinationConnectionsL@CIptvTestUtilALR@@QAEXAAVTDesC16@@@Z @ 134 NONAME ; void CIptvTestUtilALR::TerminateDestinationConnectionsL(class TDesC16 &) + ?VerifyData@CVCXTestCommon@@QAEHAAVTDesC16@@AAW4TVerifyResult@CIptvTestVerifyData@@@Z @ 135 NONAME ; int CVCXTestCommon::VerifyData(class TDesC16 &, enum CIptvTestVerifyData::TVerifyResult &) + ?VerifyDataL@CIptvTestVerifyData@@QAEHAAVTDesC16@@AAW4TVerifyResult@1@@Z @ 136 NONAME ; int CIptvTestVerifyData::VerifyDataL(class TDesC16 &, enum CIptvTestVerifyData::TVerifyResult &) + ?WaitChangeL@CVCXTestPSSubscriber@@QAEXXZ @ 137 NONAME ; void CVCXTestPSSubscriber::WaitChangeL(void) + ?WaitForAllL@CVCXTestMessageWait@@QAEXHH@Z @ 138 NONAME ; void CVCXTestMessageWait::WaitForAllL(int, int) + ?WaitForConnection@CTestUtilConnectionWaiter@@QAEXK@Z @ 139 NONAME ; void CTestUtilConnectionWaiter::WaitForConnection(unsigned long) + ?WaitForMessageL@CVCXTestMessageWait@@QAEXJHH@Z @ 140 NONAME ; void CVCXTestMessageWait::WaitForMessageL(long, int, int) + ?WaitL@CVCXTestTimerWait@@QAEXK@Z @ 141 NONAME ; void CVCXTestTimerWait::WaitL(unsigned long) + ?WaitUntilConnectionIsClosed@CTestUtilConnectionWaiter@@QAEXK@Z @ 142 NONAME ; void CTestUtilConnectionWaiter::WaitUntilConnectionIsClosed(unsigned long) + ?WriteVerifyData@CVCXTestCommon@@QAAHAAVTDesC16@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 143 NONAME ; int CVCXTestCommon::WriteVerifyData(class TDesC16 &, class TRefByValue, ...) + ?WriteVerifyData@CVCXTestCommon@@QAEHAAVTDesC16@@0@Z @ 144 NONAME ; int CVCXTestCommon::WriteVerifyData(class TDesC16 &, class TDesC16 &) + ?WriteVerifyDataL@CIptvTestVerifyData@@QAEHAAVTDesC16@@0@Z @ 145 NONAME ; int CIptvTestVerifyData::WriteVerifyDataL(class TDesC16 &, class TDesC16 &) + ?ListFilesProcessesAndThreadsL@CVCXTestCommon@@SAXAAVRFs@@@Z @ 146 NONAME ; void CVCXTestCommon::ListFilesProcessesAndThreadsL(class RFs &) + ?GetDefaultIap@CIptvTestUtilALR@@QAEKXZ @ 147 NONAME ; unsigned long CIptvTestUtilALR::GetDefaultIap(void) + ?SetDefaultIapCenRep@CIptvTestUtilALR@@QAEHXZ @ 148 NONAME ; int CIptvTestUtilALR::SetDefaultIapCenRep(void) + ?GetDefaultIapCenRep@CIptvTestUtilALR@@QAEKXZ @ 149 NONAME ; unsigned long CIptvTestUtilALR::GetDefaultIapCenRep(void) + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/EABI/VCXTestCommonu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/EABI/VCXTestCommonu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,220 @@ +EXPORTS + _ZN14CIptvTestEvent10DeactivateEv @ 1 NONAME + _ZN14CIptvTestEvent12HasTimeoutedER5TTime @ 2 NONAME + _ZN14CIptvTestEvent7GetNameER6TDes16 @ 3 NONAME + _ZN14CIptvTestEvent8ActivateEv @ 4 NONAME + _ZN14CIptvTestEventC2ERK7TDesC16i @ 5 NONAME + _ZN14CIptvTestEventD0Ev @ 6 NONAME + _ZN14CIptvTestEventD1Ev @ 7 NONAME + _ZN14CIptvTestEventD2Ev @ 8 NONAME + _ZN14CIptvTestTimer11CancelTimerEv @ 9 NONAME + _ZN14CIptvTestTimer4NewLER22MIptvTestTimerObserveri @ 10 NONAME + _ZN14CIptvTestTimer5AfterE27TTimeIntervalMicroSeconds32 @ 11 NONAME + _ZN14CIptvTestTimerD0Ev @ 12 NONAME + _ZN14CIptvTestTimerD1Ev @ 13 NONAME + _ZN14CIptvTestTimerD2Ev @ 14 NONAME + _ZN14CVCXTestCommon10VerifyDataER7TDesC16RN19CIptvTestVerifyData13TVerifyResultE @ 15 NONAME + _ZN14CVCXTestCommon11GetFileSizeER7TDesC16Rm @ 16 NONAME + _ZN14CVCXTestCommon11SetTimeZoneER7TDesC16 @ 17 NONAME + _ZN14CVCXTestCommon13CreateBadIapLER7TDesC16 @ 18 NONAME + _ZN14CVCXTestCommon13GetPSPropertyE4TUidjR6TDes16 @ 19 NONAME + _ZN14CVCXTestCommon13GetPSPropertyE4TUidjRi @ 20 NONAME + _ZN14CVCXTestCommon13SetPSPropertyE4TUidjRK7TDesC16 @ 21 NONAME + _ZN14CVCXTestCommon13SetPSPropertyE4TUidji @ 22 NONAME + _ZN14CVCXTestCommon13SetSystemTimeE5TTime @ 23 NONAME + _ZN14CVCXTestCommon14GetIapNameByIdER6TDes16m @ 24 NONAME + _ZN14CVCXTestCommon15GetIapIdByNameLERK7TDesC16Rm @ 25 NONAME + _ZN14CVCXTestCommon15GetIapIdByTypeLENS_16TIptvTestIapTypeERmi @ 26 NONAME + _ZN14CVCXTestCommon15WriteVerifyDataER7TDesC1611TRefByValueIKS0_Ez @ 27 NONAME + _ZN14CVCXTestCommon15WriteVerifyDataER7TDesC16S1_ @ 28 NONAME + _ZN14CVCXTestCommon16CreateVerifyDataER7TDesC16i @ 29 NONAME + _ZN14CVCXTestCommon16CreateVideoFileLEN21CIptvTestVideoCreator18TIptvTestVideoTypeER7TDesC16i @ 30 NONAME + _ZN14CVCXTestCommon17CreateVideoFilesLEN21CIptvTestVideoCreator18TIptvTestVideoTypeER7TDesC16iR13RPointerArrayI7HBufC16E @ 31 NONAME + _ZN14CVCXTestCommon17DeleteDummyFilesLEi @ 32 NONAME + _ZN14CVCXTestCommon18ParseIntFromStringERiR7TDesC16 @ 33 NONAME + _ZN14CVCXTestCommon18SetDriveFreeSpaceLEij @ 34 NONAME + _ZN14CVCXTestCommon20EnsureFileIsNotInUseERK7TPtrC16 @ 35 NONAME + _ZN14CVCXTestCommon22AdvanceSystemTimeHoursEi @ 36 NONAME + _ZN14CVCXTestCommon22EnableVerifyTimestampsEi @ 37 NONAME + _ZN14CVCXTestCommon24AdvanceSystemTimeMinutesEi @ 38 NONAME + _ZN14CVCXTestCommon24AdvanceSystemTimeSecondsEi @ 39 NONAME + _ZN14CVCXTestCommon29ListFilesProcessesAndThreadsLER3RFs @ 40 NONAME + _ZN14CVCXTestCommon4NewLEv @ 41 NONAME + _ZN14CVCXTestCommon7ListDirERK7TDesC16i @ 42 NONAME + _ZN14CVCXTestCommon9GetIapIdLERK7TDesC16Rm @ 43 NONAME + _ZN14CVCXTestCommon9PrintIapsEv @ 44 NONAME + _ZN16CIptvTestUtilALR11CopyMethodLER7TDesC16S1_S1_ @ 45 NONAME + _ZN16CIptvTestUtilALR13DeleteMethodLER7TDesC16S1_ @ 46 NONAME + _ZN16CIptvTestUtilALR13GetDefaultIapEv @ 47 NONAME + _ZN16CIptvTestUtilALR17GetDestinationIdLER7TDesC16 @ 48 NONAME + _ZN16CIptvTestUtilALR18CreateDestinationLER7TDesC16 @ 49 NONAME + _ZN16CIptvTestUtilALR18DeleteDestinationLER7TDesC16 @ 50 NONAME + _ZN16CIptvTestUtilALR18SetMethodPriorityLER7TDesC16S1_m @ 51 NONAME + _ZN16CIptvTestUtilALR19SetUsedDestinationLER7TDesC16 @ 52 NONAME + _ZN16CIptvTestUtilALR22SetMethodIntAttributeLER7TDesC16S1_ii @ 53 NONAME + _ZN16CIptvTestUtilALR23SetMethodBoolAttributeLER7TDesC16S1_ii @ 54 NONAME + _ZN16CIptvTestUtilALR25SetMethodStringAttributeLER7TDesC16S1_iS1_ @ 55 NONAME + _ZN16CIptvTestUtilALR28RemoveUsedDestinationCenRepLEv @ 56 NONAME + _ZN16CIptvTestUtilALR32TerminateDestinationConnectionsLER7TDesC16 @ 57 NONAME + _ZN16CIptvTestUtilALR4NewLEv @ 58 NONAME + _ZN16CIptvTestUtilALR5NewLCEv @ 59 NONAME + _ZN16CIptvTestUtilALRD0Ev @ 60 NONAME + _ZN16CIptvTestUtilALRD1Ev @ 61 NONAME + _ZN16CIptvTestUtilALRD2Ev @ 62 NONAME + _ZN17CVCXTestTimerWait10ConstructLEv @ 63 NONAME + _ZN17CVCXTestTimerWait4NewLEv @ 64 NONAME + _ZN17CVCXTestTimerWait5WaitLEm @ 65 NONAME + _ZN17CVCXTestTimerWaitD0Ev @ 66 NONAME + _ZN17CVCXTestTimerWaitD1Ev @ 67 NONAME + _ZN17CVCXTestTimerWaitD2Ev @ 68 NONAME + _ZN19CIptvTestActiveWait10ActiveWaitENS_22TIptvTestActiveWaitCmdE @ 69 NONAME + _ZN19CIptvTestActiveWait10ConstructLEv @ 70 NONAME + _ZN19CIptvTestActiveWait4NewLEv @ 71 NONAME + _ZN19CIptvTestActiveWait4StopEv @ 72 NONAME + _ZN19CIptvTestActiveWait5StartEv @ 73 NONAME + _ZN19CIptvTestActiveWait9IsWaitingEv @ 74 NONAME + _ZN19CIptvTestActiveWaitC1Ev @ 75 NONAME + _ZN19CIptvTestActiveWaitC2Ev @ 76 NONAME + _ZN19CIptvTestActiveWaitD0Ev @ 77 NONAME + _ZN19CIptvTestActiveWaitD1Ev @ 78 NONAME + _ZN19CIptvTestActiveWaitD2Ev @ 79 NONAME + _ZN19CIptvTestVerifyData11VerifyDataLER7TDesC16RNS_13TVerifyResultE @ 80 NONAME + _ZN19CIptvTestVerifyData16EnableTimestampsEi @ 81 NONAME + _ZN19CIptvTestVerifyData16WriteVerifyDataLER7TDesC16S1_ @ 82 NONAME + _ZN19CIptvTestVerifyData17CreateVerifyDataLER7TDesC16i @ 83 NONAME + _ZN19CIptvTestVerifyData4NewLEv @ 84 NONAME + _ZN19CIptvTestVerifyDataD0Ev @ 85 NONAME + _ZN19CIptvTestVerifyDataD1Ev @ 86 NONAME + _ZN19CIptvTestVerifyDataD2Ev @ 87 NONAME + _ZN19CTestUtilConnection20TerminateConnectionLEv @ 88 NONAME + _ZN19CTestUtilConnection24SetConnectionPreferencesEjm @ 89 NONAME + _ZN19CTestUtilConnection4NewLEP27MTestUtilConnectionObserver @ 90 NONAME + _ZN19CTestUtilConnection5NewLCEP27MTestUtilConnectionObserver @ 91 NONAME + _ZN19CTestUtilConnection7AttachLEv @ 92 NONAME + _ZN19CTestUtilConnection8ConnectLEv @ 93 NONAME + _ZN19CTestUtilConnectionD0Ev @ 94 NONAME + _ZN19CTestUtilConnectionD1Ev @ 95 NONAME + _ZN19CTestUtilConnectionD2Ev @ 96 NONAME + _ZN19CVCXTestMessageWait10AddMessageEl @ 97 NONAME + _ZN19CVCXTestMessageWait10ConstructLEv @ 98 NONAME + _ZN19CVCXTestMessageWait11WaitForAllLEii @ 99 NONAME + _ZN19CVCXTestMessageWait14ReceiveMessageEli @ 100 NONAME + _ZN19CVCXTestMessageWait15WaitForMessageLElii @ 101 NONAME + _ZN19CVCXTestMessageWait21ResetReceivedMessagesEv @ 102 NONAME + _ZN19CVCXTestMessageWait4NewLEP27MVCXTestMessageWaitObserver @ 103 NONAME + _ZN19CVCXTestMessageWait5ResetEv @ 104 NONAME + _ZN19CVCXTestMessageWait9CoolDownLEi @ 105 NONAME + _ZN19CVCXTestMessageWaitC1EP27MVCXTestMessageWaitObserver @ 106 NONAME + _ZN19CVCXTestMessageWaitC2EP27MVCXTestMessageWaitObserver @ 107 NONAME + _ZN19CVCXTestMessageWaitD0Ev @ 108 NONAME + _ZN19CVCXTestMessageWaitD1Ev @ 109 NONAME + _ZN19CVCXTestMessageWaitD2Ev @ 110 NONAME + _ZN19CVCXTestStatsKeeper10ActionEndLERK7TDesC16i @ 111 NONAME + _ZN19CVCXTestStatsKeeper10ActionEndLEli @ 112 NONAME + _ZN19CVCXTestStatsKeeper12ActionStartLERK7TDesC16S2_i @ 113 NONAME + _ZN19CVCXTestStatsKeeper12ActionStartLElRK7TDesC16 @ 114 NONAME + _ZN19CVCXTestStatsKeeper12ActionTraceLERK7TDesC16 @ 115 NONAME + _ZN19CVCXTestStatsKeeper15ActionProgressLERK7TDesC16S2_ @ 116 NONAME + _ZN19CVCXTestStatsKeeper15ActionProgressLElRK7TDesC16 @ 117 NONAME + _ZN19CVCXTestStatsKeeper18StartStatsKeepingLERK7TDesC16S2_ @ 118 NONAME + _ZN19CVCXTestStatsKeeper4NewLEv @ 119 NONAME + _ZN20CIptvTestEventWaiter13CheckTimeoutsEv @ 120 NONAME + _ZN20CIptvTestEventWaiter13EventHappenedEP14CIptvTestEventPS1_ @ 121 NONAME + _ZN20CIptvTestEventWaiter13GetEventCountEv @ 122 NONAME + _ZN20CIptvTestEventWaiter4NewLER28MIptvTestEventWaiterObserver @ 123 NONAME + _ZN20CIptvTestEventWaiter5ResetEv @ 124 NONAME + _ZN20CIptvTestEventWaiter8AddEventEP14CIptvTestEventi @ 125 NONAME + _ZN20CIptvTestEventWaiterD0Ev @ 126 NONAME + _ZN20CIptvTestEventWaiterD1Ev @ 127 NONAME + _ZN20CIptvTestEventWaiterD2Ev @ 128 NONAME + _ZN20CVCXTestPSSubscriber11WaitChangeLEv @ 129 NONAME + _ZN20CVCXTestPSSubscriber3GetER6TDes16 @ 130 NONAME + _ZN20CVCXTestPSSubscriber3GetERi @ 131 NONAME + _ZN20CVCXTestPSSubscriber3SetERK7TDesC16 @ 132 NONAME + _ZN20CVCXTestPSSubscriber3SetERi @ 133 NONAME + _ZN20CVCXTestPSSubscriber4NewLE4TUidmN9RProperty5TTypeEP18MVCXTestPSObserver @ 134 NONAME + _ZN20CVCXTestPSSubscriber5StartEv @ 135 NONAME + _ZN20CVCXTestPSSubscriber7EndWaitEv @ 136 NONAME + _ZN20CVCXTestPSSubscriber8DoCancelEv @ 137 NONAME + _ZN20CVCXTestPSSubscriberD0Ev @ 138 NONAME + _ZN20CVCXTestPSSubscriberD1Ev @ 139 NONAME + _ZN20CVCXTestPSSubscriberD2Ev @ 140 NONAME + _ZN21CIptvTestVideoCreator10ConstructLEv @ 141 NONAME + _ZN21CIptvTestVideoCreator12CreateVideoLENS_18TIptvTestVideoTypeER7TDesC16i @ 142 NONAME + _ZN21CIptvTestVideoCreator12GetVideoFileER6TDes16NS_18TIptvTestVideoTypeERK7TDesC16 @ 143 NONAME + _ZN21CIptvTestVideoCreator13CreateVideosLENS_18TIptvTestVideoTypeER7TDesC16iR13RPointerArrayI7HBufC16E @ 144 NONAME + _ZN21CIptvTestVideoCreator4NewLEv @ 145 NONAME + _ZN21CIptvTestVideoCreatorC1Ev @ 146 NONAME + _ZN21CIptvTestVideoCreatorC2Ev @ 147 NONAME + _ZN21CIptvTestVideoCreatorD0Ev @ 148 NONAME + _ZN21CIptvTestVideoCreatorD1Ev @ 149 NONAME + _ZN21CIptvTestVideoCreatorD2Ev @ 150 NONAME + _ZN24CIptvTestDownloadManager10ConstructLEv @ 151 NONAME + _ZN24CIptvTestDownloadManager4NewLEP25MTestUtilDownloadObserver @ 152 NONAME + _ZN24CIptvTestDownloadManager5NewLCEP25MTestUtilDownloadObserver @ 153 NONAME + _ZN24CIptvTestDownloadManager8GetErrorER13RHttpDownloadRl @ 154 NONAME + _ZN24CIptvTestDownloadManager9DownloadLER7TDesC16S1_S1_S1_li @ 155 NONAME + _ZN24CIptvTestDownloadManagerD0Ev @ 156 NONAME + _ZN24CIptvTestDownloadManagerD1Ev @ 157 NONAME + _ZN24CIptvTestDownloadManagerD2Ev @ 158 NONAME + _ZN25CTestUtilConnectionWaiter17WaitForConnectionEm @ 159 NONAME + _ZN25CTestUtilConnectionWaiter18IsConnectionActiveEm @ 160 NONAME + _ZN25CTestUtilConnectionWaiter27WaitUntilConnectionIsClosedEm @ 161 NONAME + _ZN25CTestUtilConnectionWaiter4NewLEP27MTestUtilConnectionObserver @ 162 NONAME + _ZN25CTestUtilConnectionWaiter5NewLCEP27MTestUtilConnectionObserver @ 163 NONAME + _ZN25CTestUtilConnectionWaiterC1EP27MTestUtilConnectionObserver @ 164 NONAME + _ZN25CTestUtilConnectionWaiterC2EP27MTestUtilConnectionObserver @ 165 NONAME + _ZN25CTestUtilConnectionWaiterD0Ev @ 166 NONAME + _ZN25CTestUtilConnectionWaiterD1Ev @ 167 NONAME + _ZN25CTestUtilConnectionWaiterD2Ev @ 168 NONAME + _ZN27CIptvTestMobilecrashWatcher16CheckNewCrashesLEv @ 169 NONAME + _ZN27CIptvTestMobilecrashWatcher16ReturnNewCrashesER13RPointerArrayI7HBufC16E @ 170 NONAME + _ZN27CIptvTestMobilecrashWatcher18ReadMobilecrashesLER13RPointerArrayI7HBufC16ERK7TDesC16 @ 171 NONAME + _ZN27CIptvTestMobilecrashWatcher21CompareMobilecrashesLER13RPointerArrayI7HBufC16ES3_ @ 172 NONAME + _ZN27CIptvTestMobilecrashWatcher22ReturnMobileCrashCountEv @ 173 NONAME + _ZN27CIptvTestMobilecrashWatcher4NewLEi @ 174 NONAME + _ZN27CIptvTestMobilecrashWatcher4NewLEv @ 175 NONAME + _ZN27CIptvTestMobilecrashWatcherD0Ev @ 176 NONAME + _ZN27CIptvTestMobilecrashWatcherD1Ev @ 177 NONAME + _ZN27CIptvTestMobilecrashWatcherD2Ev @ 178 NONAME + _ZTI11CVerifyFile @ 179 NONAME + _ZTI14CIptvTestEvent @ 180 NONAME + _ZTI14CIptvTestTimer @ 181 NONAME + _ZTI14CVCXTestCommon @ 182 NONAME + _ZTI16CIptvTestUtilALR @ 183 NONAME + _ZTI17CVCXTestStatsItem @ 184 NONAME + _ZTI17CVCXTestTimerWait @ 185 NONAME + _ZTI19CIptvTestActiveWait @ 186 NONAME + _ZTI19CIptvTestVerifyData @ 187 NONAME + _ZTI19CTestUtilConnection @ 188 NONAME + _ZTI19CVCXTestMessageWait @ 189 NONAME + _ZTI19CVCXTestStatsKeeper @ 190 NONAME + _ZTI20CIptvTestEventWaiter @ 191 NONAME + _ZTI20CVCXTestPSSubscriber @ 192 NONAME + _ZTI21CIptvTestVideoCreator @ 193 NONAME + _ZTI24CIptvTestDownloadManager @ 194 NONAME + _ZTI24CVCXTestStatsItemSummary @ 195 NONAME + _ZTI25CTestUtilConnectionWaiter @ 196 NONAME + _ZTI27CIptvTestMobilecrashWatcher @ 197 NONAME + _ZTV11CVerifyFile @ 198 NONAME + _ZTV14CIptvTestEvent @ 199 NONAME + _ZTV14CIptvTestTimer @ 200 NONAME + _ZTV14CVCXTestCommon @ 201 NONAME + _ZTV16CIptvTestUtilALR @ 202 NONAME + _ZTV17CVCXTestStatsItem @ 203 NONAME + _ZTV17CVCXTestTimerWait @ 204 NONAME + _ZTV19CIptvTestActiveWait @ 205 NONAME + _ZTV19CIptvTestVerifyData @ 206 NONAME + _ZTV19CTestUtilConnection @ 207 NONAME + _ZTV19CVCXTestMessageWait @ 208 NONAME + _ZTV19CVCXTestStatsKeeper @ 209 NONAME + _ZTV20CIptvTestEventWaiter @ 210 NONAME + _ZTV20CVCXTestPSSubscriber @ 211 NONAME + _ZTV21CIptvTestVideoCreator @ 212 NONAME + _ZTV24CIptvTestDownloadManager @ 213 NONAME + _ZTV24CVCXTestStatsItemSummary @ 214 NONAME + _ZTV25CTestUtilConnectionWaiter @ 215 NONAME + _ZTV27CIptvTestMobilecrashWatcher @ 216 NONAME + _ZN16CIptvTestUtilALR19GetDefaultIapCenRepEv @ 217 NONAME + _ZN16CIptvTestUtilALR19SetDefaultIapCenRepEv @ 218 NONAME + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/conf/VCXTestCommon.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/conf/VCXTestCommon.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,4 @@ + +[Test] +title No tests for this module. +[Endtest] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/VCXTestCommon.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/VCXTestCommon.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET VCXTestCommon.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E7 + +#if defined(EKA2) + +CAPABILITY CAP_GENERAL_DLL +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x101FB657 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x102073DB +#endif + +//TARGETPATH ?target_path +DEFFILE VCXTestCommon.def + +SOURCEPATH ../src +SOURCE CIptvTestTimer.cpp +SOURCE CIptvTestVerifyData.cpp +SOURCE CIptvTestMobilecrashWatcher.cpp +SOURCE CIptvTestEventWaiter.cpp +SOURCE CIptvTestEvent.cpp +SOURCE CIptvTestActiveWait.cpp +SOURCE TestUtilConnectionWaiter.cpp +SOURCE IptvTestDownloadManager.cpp +SOURCE IptvTestUtilALR.cpp +SOURCE CIptvTestVideoCreator.cpp +SOURCE TestUtilConnection.cpp +SOURCE VCXTestCommon.cpp +SOURCE VCXTestTimerWait.cpp +SOURCE VCXTestPSSubscriber.cpp +SOURCE VCXTestMessageWait.cpp +SOURCE VCXTestStatsKeeper.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +USERINCLUDE ../inc + +APP_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY FLOGGER.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY commdb.lib +LIBRARY estor.lib // filestore +LIBRARY edbms.lib // rdbstoredatabase +LIBRARY tzclient.lib // RTz +LIBRARY DownloadMgr.lib +LIBRARY esock.lib +LIBRARY cmmanager.lib +LIBRARY centralrepository.lib +LIBRARY ezip.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/VCXTestCommon.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/VCXTestCommon.pkg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,58 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; + +; Languages +&EN + +; Package header +#{"VCXTestCommon"},(0x101F7961),0,0,0 + +; Localised Vendor name +%{"Nokia EN"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files + "\epoc32\release\armv5\udeb\VCXTestCommon.dll" - "!:\Sys\Bin\VCXTestCommon.dll" + "..\conf\VCXTestCommon.cfg" - "c:\TestFramework\VCXTestCommon.cfg" + "..\init\TestFramework.ini" - "c:\TestFramework\TestFramework.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES +VCXTestCommon.mmp + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestActiveWait.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestActiveWait.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CIPTVTESTACTIVEWAIT_H +#define CIPTVTESTACTIVEWAIT_H + +// INCLUDES +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* +* +* +* +* @since +*/ +class CIptvTestActiveWait : public CBase + { + public: // Constructors and destructor + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestActiveWait * NewL(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestActiveWait (); + + + enum TIptvTestActiveWaitCmd + { + EActiveWaitStart, + EActiveWaitStop + }; + + public: // New functions + + /* + * To start and stop CActiveSchedulerWait + */ + + IMPORT_C void ActiveWait( TIptvTestActiveWaitCmd aActiveWaitCmd ); + + /* + * Returns ETrue if CActiveSchedulerWait is running. + */ + IMPORT_C TBool IsWaiting(); + + /* + * Starts active wait. + */ + IMPORT_C TInt Start(); + + /* + * Stops active wait. + */ + IMPORT_C TInt Stop(); + + + protected: // From base classes + + private: + + /** + * C++ default constructor. + */ + CIptvTestActiveWait (); + + /** + * By default Symbian 2nd phase constructor is private. + */ + IMPORT_C void ConstructL(); + + private: // Data + CActiveSchedulerWait* iActiveSchedulerWait; + }; + + +#endif // CIPTVTESTACTIVEWAIT_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestEvent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestEvent.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef CIPTVTESTEVENT_H +#define CIPTVTESTEVENT_H + +// INCLUDES +#include +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CIptvTestEvent; + +// CLASS DECLARATION + +/** +* +* +* +* +* @since +*/ +class CIptvTestEvent : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + //IMPORT_C static CIptvTestEvent* NewL(TInt aTimeoutSeconds); + + /** + * C++ default constructor. + */ + IMPORT_C CIptvTestEvent( const TDesC& aName, TInt aTimeoutSeconds); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestEvent(); + + + public: // New functions + + /** + * Compares if this and aEvent are same. Returns ETrue if so, else EFalse. + */ + IMPORT_C virtual TBool Compare( CIptvTestEvent& aEvent ) = 0; + + /** + * Returns error code if there's error in the event, otherwise KErrNone. + */ + IMPORT_C virtual TInt GetError( ) = 0; + + /** + * Getter for even name. + */ + IMPORT_C void GetName( TDes& aName ); + + /** + * Returns if event has timed out. + */ + IMPORT_C TBool HasTimeouted( TTime& aTimeNow ); + + /* + * Starts timing for this event + */ + IMPORT_C void Activate( ); + + /* + * Stops timing for this event + */ + IMPORT_C void Deactivate( ); + + protected: //from base classes + + private: + + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Data + + TInt iTimeoutSeconds; + TTime iActivationTime; + TBuf<32> iName; + TBool iActive; + }; + + +#endif // CIPTVTESTEVENT_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestEventWaiter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestEventWaiter.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CIPTVTESTEVENTWAITER_H +#define CIPTVTESTEVENTWAITER_H + +// INCLUDES +#include +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class MIptvTestEventWaiterObserver; +class CIptvTestEvent; + +// CLASS DECLARATION + +/** +* +* CIptvTestEventWaiter USAGE: +* +* Implement callbacks from MIptvTestEventWaiterObserver. +* Create your own event class inherited from CIptvTestEvent. +* Create instance. +* +* Add events that are expected to happen with CIptvTestEventWaiter::AddEvent method. +* - Two queues: sequential events and others +* +* When event happen, call CIptvTestEventWaiter::EventHappened(event) +* - This will compare the event to the ones in queues with CIptvTestEvent::Compare() method. +* First tries to find not sequential events and then last sequential event in queue. +* - If event is not found or it's timedout MIptvTestEventWaiterObserver::EventWaiterErrorL is called. +* +* @since +*/ + +class CIptvTestEventWaiter : public CActive + { + public: + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestEventWaiter* NewL(MIptvTestEventWaiterObserver& aObserver); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestEventWaiter(); + + public: // New functions + + /** + * Checks if events have timeouted + */ + IMPORT_C TInt CheckTimeouts(); + + /** + * Will add an event to queue and also check all events if they have timeouted + */ + IMPORT_C TInt AddEvent(CIptvTestEvent* aEvent, TBool aSequential); + + /** + * Will check the event against the events in queue + * If event is found it is returned in aQueuedEvent + * If event is not found the first event in event queue is returned in aQueuedEvent + */ + IMPORT_C TInt EventHappened(CIptvTestEvent* aEvent, CIptvTestEvent** aQueuedEvent); + + /** + * Resets the event waiter system. All events are deleted. + */ + IMPORT_C TInt Reset(); + + /** + * Returns the amount of events left in queues + */ + IMPORT_C TInt GetEventCount(); + + protected: //from base classes + + // from CActive + + /* + * RunL() + * + * Handle request completion events + * + */ + void RunL(); + + /* + * DoCancel() + * + * Cancel any outstanding requests + * + */ + void DoCancel(); + + private: + + /** + * C++ default constructor. + */ + CIptvTestEventWaiter(MIptvTestEventWaiterObserver& aObserver); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Data + + private: + + // Events which should happen sequential + RPointerArray iEventQueue; + + // Events which have no particular order where they happen + RPointerArray iEventDump; + + RPointerArray iPastEvents; + + MIptvTestEventWaiterObserver& iObserver; + + RTimer iTimer; + }; + +#endif // CIPTVTESTEVENTWAITER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestMobilecrashWatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestMobilecrashWatcher.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CIPTVTESTMOBILECRASHWATCHER_H +#define CIPTVTESTMOBILECRASHWATCHER_H + +// INCLUDES +#include +#include // RArray +#include // RFs + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + + +// CLASS DECLARATION + + +/** +* +* +* +* +* @since +*/ +class CIptvTestMobilecrashWatcher : public CBase + { + public: // Constructors and destructor + + + /** + * Two-phased constructor. + * This has iPanicEnabled member set ETrue which will cause panic in destructor if there's new mobilecrashes + */ + IMPORT_C static CIptvTestMobilecrashWatcher* NewL(); + + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestMobilecrashWatcher* NewL(TBool aPanicEnabled); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestMobilecrashWatcher(); + + + public: // New functions + + /** + * Reads all mobilecrashes in c:\data and e:\ directories. + * @since + * @param aCrashes list of mobilecrash files are stored into here + * @return + */ + void ReadMobilecrashesL( RPointerArray& aCrashes, const TDesC& aDrive ); + + /** + * Compares the two arrays of filenames and reports new files in aCrashesNow and causes a panic. + * @since + * @param aCrashesBefore old filelist + * @param aCrashesNow new filelist + * @return ETrue if new mobilecrashes are found, otherwise EFalse + */ + IMPORT_C TBool CompareMobilecrashesL(RPointerArray& aCrashesBefore, RPointerArray& aCrashesNow); + + /** + * Checks for new mobilecrashes. Panics if found. + * @since + * @param + * @return + */ + IMPORT_C void CheckNewCrashesL(); + + /** + * Checks for new mobilecrashes. + * @since + * @param aArray is populated of the new mobilecrashes. + * @return EFalse if new mobilecrashes are not found. ETrue if found. + */ + IMPORT_C TBool ReturnNewCrashes(RPointerArray& aArray); + + /** + * Returns the count of mobilecrashes in c:\\data and e:\\ + * @since + * @param + * @return Count of mobilecrashes in c:\\data and e:\\ + */ + IMPORT_C TInt ReturnMobileCrashCount(); + + protected: //from base classes + + + private: + + /** + * C++ default constructor. + */ + CIptvTestMobilecrashWatcher(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(TBool aPanicEnabled); + + private: // Data + // If ETrue and new mobilecrashes are found then a panic will be thrown in destructor + TBool iPanicEnabled; + + // File system session + RFs iFsSession; + + RPointerArray iCrashesBefore; + + RPointerArray iCrashesNow; + }; + + +#endif // CIPTVTESTMOBILECRASHWATCHER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestTimer.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CIPTVTESTTIMER_H +#define CIPTVTESTTIMER_H + +// INCLUDES +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class MIptvTestTimerObserver; + +// CLASS DECLARATION + +/** +* +* +* +* +* @since +*/ +class CIptvTestTimer : public CActive + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestTimer* NewL(MIptvTestTimerObserver& aObserver, TInt aId); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestTimer(); + + + public: // New functions + IMPORT_C void After(TTimeIntervalMicroSeconds32 aInterval); + IMPORT_C void CancelTimer( ); + + protected: //from base classes + void RunL(); + void DoCancel(); + + private: + + /** + * C++ default constructor. + */ + CIptvTestTimer(MIptvTestTimerObserver& aObserver, TInt aId); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Data + RTimer iTimer; + MIptvTestTimerObserver& iObserver; + TInt iId; + TBool iRestartAfterCancel; + TTimeIntervalMicroSeconds32 iInterval; + }; + + +#endif // CIPTVTESTTIMER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestVerifyData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestVerifyData.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,274 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +/* + +Testmodule needs two new blocks: + EnableVerifying + - Parameters: verify ID, appendmode: 0 = if verify file exists it will be + overwritten, 1 data is written to end of file + - Verify ID can be the Case ID + - Calls IptvTestUtility::CreateVerifyData + - The case can call EnableVerifying block of multiple modules. Verify ID should be same in each call, + just use append mode in other calls but the first. + - If this has not been called then IptvTestUtility::VerifyData and + IptvTestUtility::WriteVerifyData do nothing + + Verify + - Parameters: The verify ID used in the case + - Calls IptvTestUtility::VerifyData(CaseId) for the ID + - Case should call Verify block only once, even EnableVerifying is called for multiple test modules + + After call to EnableVerifying the test module can write data with two different + IptvTestUtility::WriteVerifyData methods. + + VerifyData will fail at the first time it's called. This is because it can't + find already verified file to compare with the one generated during the case run. + The unverified file can be found from E (or C if MMC is not installed) drive + in the folder: \iptvtest\verify\.txt. This file must be verified by + hand and copied to IPTV_engine\internal\data\verify. + + Note: Only logs from HW test runs should be accepted. Emulator and HW might give + different results. + + IPTV_engine\internal\sis\generateverifylist.pl script generates + internal\data\verifyExports.inf file which exports the verified files to + correct locations. internal\sis\pkgExports.txt is also created and the + lines inside must be copied to STIF_IPTV_Engine.pkg. The verified files will + be installed in c:\Testframework\Iptvtest\verify folder on the terminal. + + File & directory summary. + 1. (E/C):\iptvtest\verify\.txt (on hardware) + - Generated during the case run + 2. internal\data\verify + - #1 should be copied here after it has been verified manually for first time. + 3. c:\Testframework\Iptvtest\verify (on hardware) + - Verified files are installed here. Compared to #1 + 4. internal\sis\generateverifylist.pl + - Creates files #5 & #6 + 5. internal\data\verifyExports.inf + - Exports the files in folders: epoc32\winscw\c\testframework\iptvtest\verify + epoc32\data\Z\System\Data\Iptvtest\Verify + 6. \internal\sis\pkgExports.txt + - Pkg lines for the files, copy to STIF_IPTV_Engine.pkg + +Example case: + +[Test] +title ET39000 Data verifying example +create IptvProvisioningTest ProvTest +create IptvServiceManagementApiTest SMTest +SMTest DeleteServicesDb +ProvTest Create +ProvTest EnableVerifying ET39000 // first module and first call will create new data file +ProvTest LocalProvision "c:\TestFramework\testvod_services.xml" +create IptvVodContentApiTest VCTest +VCTest Create SERV_1 +VCTest EnableVerifying ET39000 APPEND // second module will append to the same file +VCTest SelectIap 3G_AP +VCTest UpdateEcg +waittestclass VCTest +VCTest VerifyAllCategoryContent KIptvVodContentCategoryRootId +ProvTest Verify ET39000 // only one module will do the verifying +VCTest Destroy +delete VCTest +ProvTest Destroy +delete ProvTest +SMTest Destroy +delete SMTest +[Endtest] + +*/ + + +#ifndef CIPTVTESTVERIFYDATA_H +#define CIPTVTESTVERIFYDATA_H + +// INCLUDES +#include +#include // RArray +#include // RFs +#include +#include + +// CONSTANTS +const TInt KIptvTestErrVerifyFailed = -1112; +_LIT(KIptvVerifyZipFile, "c:\\testing\\data\\verifyzip\\verify.zip" ); + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS +class CZipFile; + +// CLASS DECLARATION + +class CVerifyFile : public CBase + { + public: + static CVerifyFile* CVerifyFile::NewL(); + + virtual ~CVerifyFile(); + + // data + + TBuf<64> iId; + + /** + * Returns the file name and path where case data is written to be verified + * @since + * @param aFileName pointer to descriptor where file name is written + * @return Error code, KErrNone if no errors, + */ + void GetFileToWrite(TDes& aFileName); + + void CreateNewFile(); + + void WriteData(TDesC& aData); + + void CloseFileHandles(); + + protected: + CVerifyFile(); + void ConstructL(); + + private: + RFs iFs; + HBufC* iFileName; + TBool iFileOpen; + RFileWriteStream iFileStream; + RFile iFile; + + void OpenStream(); + void ResolveFileName(); + }; + + +/** +* +* @since +*/ +class CIptvTestVerifyData : public CBase + { + public: // Constructors and destructor + + enum TVerifyResult + { + EVerifyOk = 0, + EVerifyFailed = -1112, + EVerifiedFileNotFound = -1111, + EFileToVerifyNotFound = -1110, + ESystemError = -1109 + }; + + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestVerifyData* NewL(); + + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestVerifyData(); + + + public: // New functions + + /** + * Initializes the verify file, deletes if the file exists + * @since + * @param aVerifyId An id to identify the file where verify data is written + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt CreateVerifyDataL(TDesC& aVerifyId, TBool aAppend); + + /** + * Writes verify data to a file + * @since + * @param aVerifyId An id to identify the file where verify data is written + * @param aVerifyData Data to write into the file + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt WriteVerifyDataL(TDesC& aVerifyId, TDesC& aVerifyData); + + /** + * Verifies the results, result is written to aVerifyResult + * @since + * @param aVerifyId An id to identify the files which are compared + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt VerifyDataL(TDesC& aVerifyId, TVerifyResult& aVerifyResult); + + /** + * Enables timestamp writing to the file. + * @since + * @param aUseTimestamps + * @return Error code, KErrNone if no errors, + */ + IMPORT_C void EnableTimestamps( TBool aUseTimestamps ); + + protected: //from base classes + + private: + + /** + * C++ default constructor. + */ + CIptvTestVerifyData(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + TInt GetVerifyFileIndex(TInt& aIndex, TDesC& aVerifyId); + + /* + * Reads a file into the buffer. + */ + TInt ReadFileL(RFs& aFs, TDes& aFileName, HBufC8** aBuff, TVerifyResult& aVerifyResult); + + /* + * Extracts a file from zip file. + */ + void ExtractVerifyFileL( TDesC& aVerifyId, const TDesC& aDestFile ); + + /* + * Checks if file exists in zip file. + */ + TBool FileExistsInZip( CZipFile* aZipFile, const TDesC& aFileName ); + + private: // Data + RFs iFs; + + RPointerArray iVerifyFiles; + + CZipFile* iZipFile; + + TBool iUseTimestamps; + + HBufC* iBuffer; + }; + +#endif // CIPTVTESTVERIFYDATA_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestVideoCreator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/CIptvTestVideoCreator.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef CIptvTestVideoCreator_H +#define CIptvTestVideoCreator_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +const int KVcxTestLargeFile3GB = -999; + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* +* +* +* +* @since +*/ +class CIptvTestVideoCreator : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CIptvTestVideoCreator* NewL(); + + /** + * C++ default constructor. + */ + IMPORT_C CIptvTestVideoCreator(); + + /** + * Destructor. + */ + IMPORT_C virtual ~CIptvTestVideoCreator(); + + enum TIptvTestVideoType + { + IptvTestVideo3Gp, // Extension .3GP + IptvTestVideo3Gp2, // Extension .3G2 + IptvTestVideoMp2, // Extension .MP2 + IptvTestVideoMpeg1, // Extension .MPG + IptvTestVideoMpeg2, // Extension .MPG + IptvTestVideoSuperVideoCd, // Extension .MPG + IptvTestVideoMp3, // Extension .MP3 + IptvTestVideoAppleMpeg, // Extension .MP4 + IptvTestVideoMpeg4, // Extension .MP4 + IptvTestVideoMpegAvc, // Extension .MP4 + IptvTestVideoQuicktime, // Extension .MOV + IptvTestVideoRealVideo, // Extension .RM + IptvTestVideoAvi, // Extension .AVI + IptvTestVideoWmv, // Extension .WMV + IptvTestVideoAviAC3 // Extension .AVI + }; + + public: // New functions + + /** + * Creates video to specified location by copying file from e/c:\testing\data according to the video type. + * @param aVideoType a type of video which is created + * @param aFileName path filename where video is created + * @param aSize size of the video. If -1 then size will not be changed, if any other, playback of + * video will probably fail. + */ + IMPORT_C void CreateVideoL( TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aSize ); + + /* + * Creates number of video files to specified location. + */ + IMPORT_C void CreateVideosL( TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aCount, RPointerArray& aFileArray ); + + protected: //from base classes + + private: + + /** + * By default Symbian 2nd phase constructor is private. + */ + IMPORT_C void ConstructL(); + + /** + * Returns the file and path for specied file type. + */ + IMPORT_C void GetVideoFile( TDes& aFileName, CIptvTestVideoCreator::TIptvTestVideoType aVideoType, const TDesC& aDrive ); + + private: // Data + RFs iFs; + CFileMan* iFileMan; + }; + + +#endif // CIptvTestVideoCreator_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/IptvTestDownloadManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/IptvTestDownloadManager.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef IPTVTESTDOWNLOADMANAGER_H +#define IPTVTESTDOWNLOADMANAGER_H + +#include +#include +#include +#include +#include +#include "MTestUtilDownloadObserver.h" +#include "MIptvTestTimerObserver.h" + +// FORWARD DECLARATIONS; +class CIptvTestTimer; + +// CLASS DECLARATION + + +/** +* CTestUtilConnection Controls the internet connection initiation and shutdown +*/ +class CIptvTestDownloadManager : public CBase, MHttpDownloadMgrObserver, public MIptvTestTimerObserver + { + public: + + /* + * NewL() + */ + IMPORT_C static CIptvTestDownloadManager* NewL(MTestUtilDownloadObserver *aObs); + + /* + * NewL() + */ + IMPORT_C static CIptvTestDownloadManager* NewLC(MTestUtilDownloadObserver *aObs); + + /* + * ~CTestUtilConnection() + */ + IMPORT_C virtual ~CIptvTestDownloadManager(); + + + IMPORT_C TInt DownloadL( TDesC& aAddress, TDesC16& aOutFile, TDesC& aUserName, TDesC& aPassword, TInt32 aIapId = 0, TInt aTimeoutSeconds = 300); + + IMPORT_C void GetError(RHttpDownload& aDownload, TInt32& aDownloadError); + + private: + + virtual void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent ); + + virtual void TimerComplete(TInt aTimerId, TInt aError); + + void DeleteDownloadAsync( TInt aError ); + + private: + + void ConstructL(); + + CIptvTestDownloadManager(MTestUtilDownloadObserver *aObs); + + private: + RHttpDownloadMgr iDownloadMgr; + RHttpDownload* iDownload; + + MTestUtilDownloadObserver *iObserver; + + TBool iDownloadRunning; + CIptvTestTimer* iTimer; + + TBool iTimerStartedForDownloadDeletion; + TInt iError; + TBool iDownloadFinishInformed; + }; + + +#endif // IAPCONNECT_V20ENGINE_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/IptvTestUtilALR.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/IptvTestUtilALR.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef IptvTestUtilALR_H +#define IptvTestUtilALR_H + +#include +#include "MTestUtilConnectionObserver.h" + +#include +#include +#include +#include +#include + +// FORWARD DECLARATIONS; +class CIptvTestActiveWait; + +// CONSTANTS + +// Declared in CIptvUtil.h and vcxconnutilimpl.cpp +const TUid VCXTEST_KIptvAlrCenRepUid = { 0x2000B438 }; +const TInt VCXTEST_KIptvCenRepUsedSnapIdKey = 0x1; +const TInt VCXTEST_KIptvCenRepDefaultIapIdKey = 0x2; +const TInt VCXTEST_KIptvCenRepAPModeAlwaysAsk = 0; + +// CLASS DECLARATION + +/** +* CIptvTestUtilALR Controls the internet connection initiation and shutdown +*/ +class CIptvTestUtilALR : public CBase, public MTestUtilConnectionObserver + { +public: + + /* + * NewL() + */ + IMPORT_C static CIptvTestUtilALR* NewL(); + + /* + * NewL() + */ + IMPORT_C static CIptvTestUtilALR* NewLC(); + + /* + * ~CIptvTestUtilALR() + */ + IMPORT_C virtual ~CIptvTestUtilALR(); + +public: // Functions from base classes + + void ConnectionCreated(); + void ConnectionClosed(); + void ConnectionFailed(); + void ConnectionAlreadyExists(); + void ConnectionTimeout(); + +public: // New functions + + /** + * Delete the used destination cenrep value. + */ + IMPORT_C void RemoveUsedDestinationCenRepL(); + + /** + * Set the used destination cenrep value for Video Center & IPTV_Engine. + */ + IMPORT_C void SetUsedDestinationL( TDesC& aDestinationName ); + + /** + * Create new destination (SNAP) + */ + IMPORT_C void CreateDestinationL( TDesC& aDestinationName ); + + /** + * Delete a destination (SNAP) + */ + IMPORT_C void DeleteDestinationL( TDesC& aDestinationName ); + + /** + * Copy existing connection method to defined SNAP. + */ + IMPORT_C void CopyMethodL( TDesC& aMethodName, TDesC& aNewMethodName, TDesC& aNewDestinationName ); + + /** + * Delete a connection method. + */ + IMPORT_C void DeleteMethodL( TDesC& aDestinationName, TDesC& aMethodName ); + + /** + * Set priority for a connection method. + */ + IMPORT_C void SetMethodPriorityL( TDesC& aDestinationName, TDesC& aMethodName, TUint32 aPriority ); + + /** + * Sets specified string attribute for a method. + */ + IMPORT_C void SetMethodStringAttributeL( TDesC& aDestinationName, TDesC& aMethodName, TInt aAttribute, TDesC& aAttributeValue ); + + /** + * Sets specified integer attribute for a method. + */ + IMPORT_C void SetMethodIntAttributeL( TDesC& aDestinationName, TDesC& aMethodName, TInt aAttribute, TInt aAttributeValue ); + + /** + * Sets specified boolean attribute for a method. + */ + IMPORT_C void SetMethodBoolAttributeL( TDesC& aDestinationName, TDesC& aMethodName, TInt aAttribute, TBool aAttributeValue ); + + /** + * Returns id of given destination. + */ + IMPORT_C TInt GetDestinationIdL( TDesC& aDestinationName ); + + /** + * Terminates active connections for the destination's IAPs. + */ + IMPORT_C void TerminateDestinationConnectionsL( TDesC& aDestinationName ); + + /** + * Gets the default access point from connection manager + */ + IMPORT_C TUint32 GetDefaultIap( void ); + + /** + * Gets the default iap, saves it to cenrep + */ + IMPORT_C TInt SetDefaultIapCenRep( void ); + + /** + * Gets the default iap id from cenrep + */ + IMPORT_C TUint32 GetDefaultIapCenRep( void ); + + +private: // New functions + + /** + * Prints destination's IAPs and their priorities to debug output. + */ + void PrintDestinationL( RCmDestinationExt& aDestination ); + + /** + * Compares two connection method names. + * @param aSearchedName name for the method to search for. + * @param aCurrentName name to compare against. + * @param aStrict If false then and aSearchedName is "Internet" there's few alternatives for + * aCurrentName which will match too. + * @return ETrue if match, otherwise EFalse. + */ + TBool MethodMatchesL( const TDesC& aSearchedName, const TDesC& aCurrentName, TBool aStrict ); + +private: + + /* + * CIptvTestUtilALR() + */ + CIptvTestUtilALR(); + + /* + * ConstructL() + */ + void ConstructL(); + +private: // Data + + RCmManagerExt iCmManager; + + // CIptvTestActiveWait + CIptvTestActiveWait* iActiveWait; + + }; + + +#endif // IAPCONNECT_V20ENGINE_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MIptvTestEventWaiterObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MIptvTestEventWaiterObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MIPTVTESTEVENTWAITEROBSERVER_H +#define MIPTVTESTEVENTWAITEROBSERVER_H + +// INCLUDES + +#include + +// FORWARD DECLARATIONS +class CIptvTestEvent; + +// CLASS DECLARATION + +class MIptvTestEventWaiterObserver + { + public: + /** + * Which event caused an error and why + */ + virtual void EventWaiterErrorL(TInt aError, CIptvTestEvent& aEvent) = 0; + + /** + * + */ + virtual void EventWaiterAllEventsValidated() = 0; + + }; + +#endif // MIPTVTESTEVENTWAITEROBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MIptvTestTimerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MIptvTestTimerObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MIPTVTESTTIMEROBSERVER_H +#define MIPTVTESTTIMEROBSERVER_H + +// INCLUDES + +#include + +// FORWARD DECLARATIONS + + +// CLASS DECLARATION + +class MIptvTestTimerObserver + { + public: + virtual void TimerComplete(TInt aTimerId, TInt aError) = 0; + + }; + +#endif // MIPTVTESTTIMEROBSERVER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MTestUtilConnectionObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MTestUtilConnectionObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MIPTVUTILCONNECIONTOBSERVER_H +#define MIPTVUTILCONNECIONTOBSERVER_H + +// INCLUDES + +#include + +// CLASS DECLARATION + +class MTestUtilConnectionObserver + { +public: + + virtual void ConnectionCreated() = 0; + virtual void ConnectionClosed() = 0; + virtual void ConnectionFailed() = 0; + virtual void ConnectionAlreadyExists() = 0; + virtual void ConnectionTimeout() = 0; + }; + +#endif // IPTVUTILCONNECIONTOBSERVER_H + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MTestUtilDownloadObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/MTestUtilDownloadObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MIPTVUTILDOWNLOADOBSERVER_H +#define MIPTVUTILDOWNLOADOBSERVER_H + +// INCLUDES + +#include + +// CLASS DECLARATION + +class MTestUtilDownloadObserver + { +public: + + virtual void DownloadFinished(TInt aError) = 0; + + }; + +#endif // MIPTVUTILDOWNLOADOBSERVER_H + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/TestUtilConnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/TestUtilConnection.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef TESTUTILCONNECTION_H +#define TESTUTILCONNECTION_H + +#include +#include +#include +#include +#include "MTestUtilConnectionObserver.h" + +// FORWARD DECLARATIONS; +//class CCommDbOverrideSettings; + +// CONSTANTS +const TUint32 KUndefinedIAPid = 0x00; +const TUint32 KTimeout = 1000000; + +// CLASS DECLARATION + + +/** +* CTestUtilConnection Controls the internet connection initiation and shutdown +*/ +class CTestUtilConnection : public CActive + { +public: + + enum TConnectionState + { + EIdle = 0, EConnecting, EFailed, EConnected + }; + + /* + * NewL() + */ + IMPORT_C static CTestUtilConnection* NewL(MTestUtilConnectionObserver* aObserver); + + /* + * NewL() + */ + IMPORT_C static CTestUtilConnection* NewLC(MTestUtilConnectionObserver* aObserver); + + /* + * ~CTestUtilConnection() + */ + IMPORT_C virtual ~CTestUtilConnection(); + + /* + * ConnectL() + * + * Creates a connection to IAP. ASYNC. + * + */ + IMPORT_C void ConnectL(); + + /* + * TerminateConnectionL() + * + * Terminate an active connection + * + */ + IMPORT_C void TerminateConnectionL(); + + /* + * SetConnectionPreferences() + * + * Sets connection preferences + * + * Params: + * TUint aBearer Bearer type + * TUint32 aIapId IAP to be connected, default KUndefinedIAPid + * + */ + IMPORT_C void SetConnectionPreferences(TUint aBearer, TUint32 aIapId = KUndefinedIAPid); + + /* + * AttachL() + * + * Attach to active connection. + * + */ + IMPORT_C void AttachL(); + + /* + * GetState() + * + * Get connection state + * + * Params: + * + */ + IMPORT_C TConnectionState GetState(); + +protected: // from CActive + + /* + * RunL() + * + * Handle request completion events + * + */ + void RunL(); + + /* + * DoCancel() + * + * Cancel any outstanding requests + * + */ + void DoCancel(); + + // From MTestUtilConnectionObserver + +private: + + /* + * CTestUtilConnection() + */ + CTestUtilConnection(MTestUtilConnectionObserver* aObserver); + + /* + * ConstructL() + */ + void ConstructL(); + +private: + + TCommDbConnPref iPref; + + // Owns + RConnection iConnect; + RSocketServ iSocketServ; + + TRequestStatus iTimerStatus; + + TConnectionState iConnectionState; + + MTestUtilConnectionObserver* iObserver; + + }; + + +#endif // IAPCONNECT_V20ENGINE_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/TestUtilConnectionWaiter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/TestUtilConnectionWaiter.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef TESTUTILCONNECTIONWAITER_H +#define TESTUTILCONNECTIONWAITER_H + +#include +#include + +#include +#include +#include + + +// FORWARD DECLARATIONS; +//class CCommDbOverrideSettings; +class MTestUtilConnectionObserver; + +// CONSTANTS + +// CLASS DECLARATION + +/** +* CTestUtilConnectionWaiter +*/ +class CTestUtilConnectionWaiter : public CActive + { +public: + + /* + * NewL() + */ + IMPORT_C static CTestUtilConnectionWaiter* NewL(MTestUtilConnectionObserver* aObserver); + + /* + * NewLC() + */ + IMPORT_C static CTestUtilConnectionWaiter* NewLC(MTestUtilConnectionObserver* aObserver); + + /* + * ~CTestUtilConnection() + */ + IMPORT_C virtual ~CTestUtilConnectionWaiter(); + + /* + * WaitForConnection(TUint32 aIapId) + * + * Waits until connection is created. Asynchronous. + * + */ + IMPORT_C void WaitForConnection(TUint32 aIapId); + + /* + * WaitUntilConnectionIsClosed(TUint32 aIapId) + * + * Waits until connection is closed. Asynchronous. + * + */ + IMPORT_C void WaitUntilConnectionIsClosed(TUint32 aIapId); + + /* + * TBool IsConnectionActive() + * + * Checks if connection is active + * + */ + IMPORT_C TBool IsConnectionActive(TUint32 aIapId); + + +protected: // from CActive + + /* + * RunL() + * + * Handle request completion events + * + */ + void RunL(); + + /* + * DoCancel() + * + * Cancel any outstanding requests + * + */ + void DoCancel(); + + // From MTestUtilConnectionObserver + +private: + + /* + * CTestUtilConnectionWaiter() + */ + CTestUtilConnectionWaiter(MTestUtilConnectionObserver* aObserver); + + /* + * ConstructL() + */ + void ConstructL(); + + enum TConnectionWaiterState + { + ENoWaitState, + EWaitingConnection, + EWaitingConnectionClosed + }; + +private: + + MTestUtilConnectionObserver* iObserver; + + TUint32 iIapId; + + RTimer iTimer; + + RSocketServ iServ; + + TInt iCheckCount; + + TConnectionWaiterState iWaitState; + + }; + + +#endif diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestCommon.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,293 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CVCXTestCommon_H +#define CVCXTestCommon_H + +// INCLUDES +#include "CIptvTestVerifyData.h" +#include "MTestUtilConnectionObserver.h" +#include "CIptvTestVideoCreator.h" +#include "VCXTestConstants.h" + +// MACROS +// FORWARD DECLARATIONS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// CLASS DECLARATION + +/** +* This class should have no depencies to any Video Center release! +* Add functionality with depencies to IptvTestUtility. +* +* @since +*/ +class CVCXTestCommon : public CBase, public MTestUtilConnectionObserver + { + public: // Constructors and destructor + + enum TIptvTestIapType + { + EWlanIap, // Any WLAN AP + EGprsIap, // Any GPRS AP + }; + + /** + * Two-phased constructor. + */ + IMPORT_C static CVCXTestCommon* NewL(); + + /** + * Destructor. + */ + virtual ~CVCXTestCommon(); + + public: // New functions + + /** + * Gets size of a file. + * @since + * @param + */ + IMPORT_C TBool GetFileSize(TDesC& aFullPath, TUint32& aFileSize); + + /** + * Searches AP by name. + * First searches if there's IAP matchin for the name. After that following rules are used: + * If name is Internet tries to find first GPRS AP, Internet2 second GPRS AP + * If name is Wlan tries to find first WLAN AP, Wlan2 second WLAN AP + * If AP is not found returns on of the known APs, if one is found. + */ + IMPORT_C TBool GetIapIdL(const TDesC& aIapName, TUint32& aIapId); + + /** + * Searches AP by name. + */ + IMPORT_C TBool GetIapIdByNameL(const TDesC& aIapName, TUint32& aIapId); + + /** + * Searches for AP as defined in TIptvTestIapType. In emulator always returns "Ethernet with Daemon Dynamic IP" + * @since + * @param aType AP type which is wanted + * @param aIapId id of found AP is written here + * @param aOrderNumber return nTh AP of the specified type + * @return KErrNotFound if no AP with the type is found, KErrNone if no errors, + */ + IMPORT_C TInt GetIapIdByTypeL(TIptvTestIapType aType, TUint32& aIapId, TInt aOrderNumber); + + /** + * Returns a name of AP. + */ + IMPORT_C TBool GetIapNameById(TDes& aIapName, TUint32 aIapId); + + /** + * Prints APs in COMMDB into debug output. + */ + IMPORT_C void PrintIaps(); + + /** + * Initializes the verify file, deletes if the file exists + * @since + * @param aVerifyId An id to identify the file where verify data is written + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt CreateVerifyData(TDesC& aVerifyId, TBool aAppend); + + /** + * Writes verify data to a file + * @since + * @param aVerifyId An id to identify the file where verify data is written + * @param aVerifyData Data to write into the file + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt WriteVerifyData(TDesC& aVerifyId, TDesC& aVerifyData); + + /** + * Writes verify data to a file + * @since + * @param aVerifyId An id to identify the file where verify data is written + * @param aVerifyData Data to write into the file + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt WriteVerifyData(TDesC& aVerifyId, TRefByValue aFmt, ... ); + + /** + * + * @since + * @param aVerifyId An id to identify the files which are compared + * @param aVerifyResult Result is written here + * @return Error code, KErrNone if no errors, + */ + IMPORT_C TInt VerifyData(TDesC& aVerifyId, CIptvTestVerifyData::TVerifyResult& aVerifyResult); + + /** + * Enables timestamp writing into the verify file. + * @since + * @param aUseTimestamps + */ + IMPORT_C void EnableVerifyTimestamps( TBool aUseTimestamps ); + + /** + * Converts string to integer. + * @param aInt parsed int is stored here + * @param aString string containing the number + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt ParseIntFromString(TInt& aInt, TDesC& aString); + + /** + * Creates bad iap for testing purposes + * @param aName name of the iap to be created + */ + IMPORT_C TUint32 CreateBadIapL(TDesC& aName); + + /** + * static TInt AdvanceSystemTimeSeconds(); + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt AdvanceSystemTimeSeconds( TInt aCount ); + + /** + * static TInt AdvanceSystemTimeMinutes(); + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt AdvanceSystemTimeMinutes( TInt aCount ); + + /** + * static TInt AdvanceSystemTimeHours(); + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt AdvanceSystemTimeHours( TInt aCount ); + + /** + * static TInt SetSystemTime(); + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt SetSystemTime(TTime aTime); + + /** + * static TInt SetTimeZone(); + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt SetTimeZone(TDesC& aTimeZone); + + /* + * Creates a video file to the system. + */ + IMPORT_C void CreateVideoFileL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aSize ); + + /* + * Creates video files to the system. + */ + IMPORT_C void CreateVideoFilesL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aCount, RPointerArray& aFileArray ); + + /* + * Sets free space for a drive. + */ + IMPORT_C void SetDriveFreeSpaceL( TInt aDriveNumber, TUint aDesiredFreeSpace ); + + /** + * Deletes files created by SetDriveFreeSpaceL. Should be called by any test module which + * has reserved disk space. + */ + IMPORT_C void DeleteDummyFilesL( TInt aDriveNumber ); + + /* + * Returns KErrNone if file is not in use. + */ + IMPORT_C TInt EnsureFileIsNotInUse( const TPtrC& aFileName ); + + /* + * CalculateSpaceToReserveL + */ + void CalculateSpaceToReserveL( RFs &aFs, TInt aDriveNumber, TInt aDesiredSpace, TInt64& aSpaceToReserve ); + + /** + * PrintDriveInfo + */ + void PrintDriveInfo( const TPtrC& aDriveLetter ); + + /** + * ListDir + */ + IMPORT_C TInt ListDir( const TDesC& aDir, TInt aLevel ); + + /** + * Reads integer from P&S. + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt GetPSProperty( const TUid aCategory, const TUint aKey, TInt& aValue ); + + /** + * Writes integer to P&S. + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt SetPSProperty( const TUid aCategory, const TUint aKey, const TInt aValue ); + + /** + * Reads descriptor from P&S. + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt GetPSProperty( const TUid aCategory, const TUint aKey, TDes& aValue ); + + /** + * Writes descriptor to P&S. + * @return KErrNone if succeed, otherwise an error code + */ + IMPORT_C static TInt SetPSProperty( const TUid aCategory, const TUint aKey, const TDesC& aValue ); + + /** + * Prints open files in the file session and which thread / process is keeping the files open. + * @param aFs file session, for example CCoeEnv::Static()->FsSession() as param is good idea. + */ + IMPORT_C static void ListFilesProcessesAndThreadsL( RFs &aFs ); + + public: // From base classes + + void ConnectionCreated() {}; + void ConnectionClosed() {}; + void ConnectionFailed() {}; + void ConnectionAlreadyExists() {}; + void ConnectionTimeout() {}; + + private: + + /** + * C++ default constructor. + */ + CVCXTestCommon(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // Data + CIptvTestVerifyData* iIptvVerifyData; + CIptvTestVideoCreator* iVideoCreator; + RFs iFs; + }; + + +#endif // CVCXTestCommon_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestConstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestConstants.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef VCXTESTCONSTANTS_H +#define VCXTESTCONSTANTS_H + +// CONSTANTS +const TInt KIptvTestErrNotFound = -1111; +const TInt KIptvTestNoSignal = -999666; + +_LIT(KIptvTestBadIapName, "BadIap"); + +#endif // VCXTESTCONSTANTS_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestLog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestLog.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTLOG_H +#define VCXTESTLOG_H + +// INCLUDES +#include +#include + +//#define FILE_LOGGING_IN_UREL_BUILD 1 + +// MACROS +#ifdef _DEBUG + +// SELECT LOG TYPE FROM HERE +// 0 = RDebug +// 1 = file logging +// 2 = no logging +#ifdef __WINSCW__ + #define LOGTYPE 0 +#else + #define LOGTYPE 1 +#endif __WINSCW__ + +#if LOGTYPE == 0 + + #define VCXLOGLO1(s) RDebug::Print(_L(#s)) + #define VCXLOGLO2(s, a) RDebug::Print(_L(#s), a) + #define VCXLOGLO3(s, a, b) RDebug::Print(_L(#s), a, b) + #define VCXLOGLO4(s, a, b, c) RDebug::Print(_L(#s), a, b, c) + #define VCXLOGLO5(s, a, b, c, d) RDebug::Print(_L(#s), a, b, c, d) + +#endif + +#if LOGTYPE == 1 + + #include + + _LIT(KIPTVLogFolder2,"Fusion"); + _LIT(KIPTVLogFile2,"Fusion.txt"); + + #define VCXLOGLO1(AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) + #define VCXLOGLO2(AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB); } while ( EFalse ) + #define VCXLOGLO3(AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) + #define VCXLOGLO4(AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) + #define VCXLOGLO5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) + +#endif + +#if LOGTYPE == 2 + + #define VCXLOGLO1(s) + #define VCXLOGLO2(s, a) + #define VCXLOGLO3(s, a, b) + #define VCXLOGLO4(s, a, b, c) + #define VCXLOGLO5(s, a, b, c, d) + +#endif + +#else // _DEBUG + + #ifdef FILE_LOGGING_IN_UREL_BUILD + + #include + + _LIT(KIPTVLogFolder2,"Fusion"); + _LIT(KIPTVLogFile2,"Fusion.txt"); + + #define VCXLOGLO1(AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) + #define VCXLOGLO2(AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB); } while ( EFalse ) + #define VCXLOGLO3(AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) + #define VCXLOGLO4(AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) + #define VCXLOGLO5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) + + #else // FILE_LOGGING_IN_UREL_BUILD + + #define VCXLOGLO1(s) + #define VCXLOGLO2(s, a) + #define VCXLOGLO3(s, a, b) + #define VCXLOGLO4(s, a, b, c) + #define VCXLOGLO5(s, a, b, c, d) + + #endif // FILE_LOGGING_IN_UREL_BUILD + +#endif // _DEBUG + + +#endif // VCXTESTLOG_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestMessageWait.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestMessageWait.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTMESSAGEWAIT_H_ +#define VCXTESTMESSAGEWAIT_H_ + +// INCLUDES +#include +#include "MIptvTestTimerObserver.h" + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION +class CIptvTestActiveWait; +class CIptvTestTimer; + +/** +* MVCXTestMessageWaitObserver +*/ +class MVCXTestMessageWaitObserver + { + public: + + /** + * Called when message queue empties or there's timeout. + */ + virtual void MessageWaitComplete( TInt aError ) = 0; + + }; + +/** +* CVCXTestMessageWait +*/ +class CVCXTestMessageWait : public CBase, public MIptvTestTimerObserver + { + public: // Constructors and destructor + /** + * Two-phased constructor. + */ + IMPORT_C static CVCXTestMessageWait * NewL( MVCXTestMessageWaitObserver* aObserver ); + + /** + * Destructor. + */ + IMPORT_C virtual ~CVCXTestMessageWait (); + + + public: // New functions + + /** + * Resets already received messages, wait queue and cancels previous receiving. + */ + IMPORT_C void Reset(); + + /** + * Resets only already received messages. + */ + IMPORT_C void ResetReceivedMessages(); + + /** + * Adds message to the wait queue. + */ + IMPORT_C void AddMessage( TInt32 aMsg ); + + /** + * Waits for a message. Calls observer callback when message is received. This will reset + * previously added messages. + */ + IMPORT_C void WaitForMessageL( TInt32 aMsg, TInt aTimeoutSeconds, TBool aDoBlock ); + + /** + * Waits for the added messages. Calls observer callback when messages have been received. + */ + IMPORT_C void WaitForAllL( TInt aTimeoutSeconds, TBool aDoBlock ); + + /** + * Waits until messages have not been received for the specified seconds. + */ + IMPORT_C void CoolDownL( TInt aSeconds ); + + /** + * Checks wait queue for the message. + */ + IMPORT_C void ReceiveMessage( TInt32 aMsg, TInt aError ); + + public: // From base classes. + + void TimerComplete( TInt aTimerId, TInt aError ); + + private: + + /** + * C++ default constructor. + */ + CVCXTestMessageWait( MVCXTestMessageWaitObserver* aObserver ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + IMPORT_C void ConstructL(); + + private: // Data + + MVCXTestMessageWaitObserver* iObserver; + + CIptvTestActiveWait* iActiveWaitBlocking; + + CIptvTestTimer* iTimeoutTimer; + + // Messages which are received while waited messages array is empty. + RArray iReceivedMessages; + + RArray iWaitedMessages; + + TInt iTimeoutSeconds; + + TBool iWaitStarted; + + TBool iCoolingDown; + + TInt iError; + }; + +#endif // VCXTESTMESSAGEWAIT_H_ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestPSObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestPSObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTPSOBSERVER_H +#define VCXTESTPSOBSERVER_H + +#include +#include + +class MVCXTestPSObserver + { +public: + virtual void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TInt& aValue ) = 0; + virtual void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TDesC& aValue ) = 0; + }; + +#endif // VCXTESTPSOBSERVER_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestPSSubscriber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestPSSubscriber.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,174 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTPSSUBSCRIBER_H +#define VCXTESTPSSUBSCRIBER_H + +#include // For CActive, link against: euser.lib +#include // For RTimer, link against: euser.lib + +#include + +class MVCXTestPSObserver; + +class CVCXTestPSSubscriber : public CActive + { + public: + + /** + * Construction. + * + * @param aUid category for the property + * @param aKey key id for the property + * @param aType type of the key (at the moment only int and text are supported) + * @param aObserver pointer to observer to who to notify about changes + * + * @return The newly constructed CVcxConnUtilPubSub + */ + IMPORT_C static CVCXTestPSSubscriber* NewL( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXTestPSObserver* aObserver ); + + /** + * Destructor. + * + */ + IMPORT_C virtual ~CVCXTestPSSubscriber(); + + /** + * Returns a pubsub value from this property + * + *@param &aValue value to fetch + * + *@return TInt KErrNone or some system level error code + */ + IMPORT_C TInt Get( TInt& aValue ); + + /** + * Returns a pubsub value from this property + * + *@param &aValue value tofetch + * + *@return TInt KErrNone or some system level error code + */ + IMPORT_C TInt Get( TDes& aValue ); + + /** + * Sets a pubsub value from this property + * + *@param aValue value to set + * + *@return TInt KErrNone or some system level error code + */ + IMPORT_C TInt Set( TInt& aValue ); + + /** + * Sets a pubsub value from this property + * + *@param aValue value to set + * + *@return TInt KErrNone or some system level error code + */ + IMPORT_C TInt Set( const TDesC& aValue ); + + /** + * Start subscribing if not already started + */ + IMPORT_C void Start(); + + /** + * Activate safe wait object to wait modifications + */ + IMPORT_C void WaitChangeL(); + + /** + * Explicitly ends waiting + */ + IMPORT_C void EndWait(); + + private: // constuct / destruct + + /** + * Constructor + * + */ + CVCXTestPSSubscriber( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXTestPSObserver* aObserver ); + + /** + * Symbian 2nd phase construction + * + */ + void ConstructL(); + + private: // from CActive + + /** + * From CActive. Calles when value subscribed to changes + * + */ + void RunL(); + + /** + * From CActive. Cancels subscribtion + * + */ + void DoCancel(); + + private: + + /** + * ETrue if object is initialized and subscribtion starts + */ + TBool iInitialized; + + /** + * Property to subscribe + */ + RProperty iProperty; + + /** + * Category uid for the property + */ + const TUid iUid; + + /** + * Key id for the property + */ + const TUint32 iKey; + + /** + * type of the property + */ + RProperty::TType iKeyType; + + /** + * Waiter object for data change + */ + CActiveSchedulerWait* iSafeWait; + + /** + * Observer + */ + MVCXTestPSObserver* iObserver; + }; + +#endif // VCXTESTPSSUBSCRIBER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestStatsKeeper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestStatsKeeper.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,236 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTSTATSKEEPER_H +#define VCXTESTSTATSKEEPER_H + +// INCLUDES +#include + +// CONSTANTS + +// MACROS + +// DATA TYPES + +// FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* Class to hold a single statistics item. +*/ +class CVCXTestStatsItem : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CVCXTestStatsItem* NewL(); + + /** + * Destructor. + */ + virtual ~CVCXTestStatsItem(); + + private: + + /** + * C++ default constructor. + */ + CVCXTestStatsItem(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + public: // Data + + TBool iIsActive; + + TInt32 iId; + HBufC* iDescId; + HBufC* iDesc; + TInt iError; + TTime iStartTime; + TTime iEndTime; + + RPointerArray iTraces; + RPointerArray iProgresses; + }; + +/** +* Class to hold summary for statistics. +*/ +class CVCXTestStatsItemSummary : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CVCXTestStatsItemSummary* NewL(); + + /** + * Destructor. + */ + virtual ~CVCXTestStatsItemSummary(); + + private: + + /** + * C++ default constructor. + */ + CVCXTestStatsItemSummary(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + public: // Data + TInt32 iId; + HBufC* iDescId; + HBufC* iDesc; + + TUint iCount; + TUint iFailCount; + + // These are all microseconds. + TInt64 iMinTime; + TInt64 iMaxTime; + TReal iAvgTime; + + TInt64 iTotalTime; + TInt64 iFailTime; + }; + +/** +* Class to keep track of statistics. +*/ +class CVCXTestStatsKeeper : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CVCXTestStatsKeeper* NewL(); + + /** + * Destructor. + */ + virtual ~CVCXTestStatsKeeper (); + + public: // New functions + + /** + * Sets the name and filename for statistics. Report is written when class is desctructed. + */ + IMPORT_C void StartStatsKeepingL( const TDesC& aName, const TDesC& aFileName ); + + /** + * Adds an action to the statistics lists. + */ + IMPORT_C void ActionStartL( TInt32 aId, const TDesC& aDesc ); + + /** + * Adds an action to the statistics lists. + * if param aDescMerge is true then action descsription will contain the descid. + */ + IMPORT_C void ActionStartL( const TDesC& aDescId, const TDesC& aDesc, TBool aDescMerge = EFalse ); + + /** + * Ends an action. + * Leaves with KErrAbort if more than 33% of actions have failed. Test should abort itself in that case. + */ + IMPORT_C void ActionEndL( TInt32 aId, TInt aError ); + + /** + * Ends an action. + * Leaves with KErrAbort if more than 33% of actions have failed. Test should abort itself in that case. + */ + IMPORT_C void ActionEndL( const TDesC& aDescId, TInt aError ); + + /** + * Sets progress information for an action. These are saved in the report. + */ + IMPORT_C void ActionProgressL( TInt32 aId, const TDesC& aProgressDesc ); + + /** + * Sets progress information for an action. These are saved in the report. + */ + IMPORT_C void ActionProgressL( const TDesC& aDescId, const TDesC& aProgressDesc ); + + /** + * Generic trace for different actions. Last 20 of these are saved in the report only if action fails. + */ + IMPORT_C void ActionTraceL( const TDesC& aDesc ); + + private: + + /** + * C++ default constructor. + */ + CVCXTestStatsKeeper(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + private: // New functions. + + CVCXTestStatsItem* GetActiveAction( TInt32 aId ); + + CVCXTestStatsItem* GetActiveAction( const TDesC& aDesc ); + + CVCXTestStatsItem* GetLastActiveAction( TBool aOnlyDescId ); + + TInt FormatDate( const TTime& aDate, TDes& aStr ); + + void GenerateReportL( const TDesC& aFileName, TBool aFullReport ); + + TUint DataSizeL(); + + void CheckFailsL(); + + void GetActionSummariesL( RPointerArray& aSummaries, TBool aFailActiveActions ); + + private: // Data + + TBool iStarted; + + HBufC* iReportName; + + HBufC* iReportFileName; + + RPointerArray iActions; + + RPointerArray iTraces; + + TBool iAbortedBecauseTooManyFails; + }; + +#endif // VCXTESTSTATSKEEPER_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestTimerWait.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestTimerWait.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTIMERWAIT_H +#define VCXTIMERWAIT_H + +// INCLUDES +#include +#include "VCXTestLog.h" +#include "MIptvTestTimerObserver.h" + +// FORWARD DECLARATIONS +class CIptvTestTimer; +class CIptvTestActiveWait; + +// DATA TYPES + +// CLASS DECLARATION + +/** + * Timer waiter class. + */ +class CVCXTestTimerWait : public CBase, public MIptvTestTimerObserver + { + public: + IMPORT_C static CVCXTestTimerWait* NewL(); + + IMPORT_C ~CVCXTestTimerWait(); + + IMPORT_C void WaitL( TUint32 aMicroSeconds ); + + public: + void TimerComplete(TInt aTimerId, TInt aError); + + private: + + IMPORT_C void ConstructL(); + + CVCXTestTimerWait(); + + private: + CIptvTestTimer* iTimer; + CIptvTestActiveWait* iWait; + + }; + +#endif // VCXTIMERWAIT_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/init/TestFramework.ini Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,165 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\Logs\Fusion\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= APPEND # Possible values: OVERWRITE or APPEND +UITestingSupport= Yes +SeparateProcesses= YES +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\VCXTestCommon.cfg +[End_Module] + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= C:\ +#HardwareFormat= TXT # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestActiveWait.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestActiveWait.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +// INCLUDE FILES +#include "CIptvTestActiveWait.h" +#include "VCXTestLog.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CIptvTestActiveWait:: +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestActiveWait* CIptvTestActiveWait::NewL() + { + VCXLOGLO1(">>>CIptvTestActiveWait::NewL"); + CIptvTestActiveWait* self = new (ELeave) CIptvTestActiveWait(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CIptvTestActiveWait::~CIptvTestActiveWait"); + + ActiveWait(EActiveWaitStop); + delete iActiveSchedulerWait; + iActiveSchedulerWait = NULL; + + VCXLOGLO1("<<>>CIptvTestActiveWait::CIptvTestActiveWait"); + + + VCXLOGLO1("<<>>CIptvTestActiveWait::ConstructL"); + + iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; + + VCXLOGLO1("<<>>CIptvTestActiveWait::ActiveWait"); + + VCXLOGLO2("aActiveWaitCmd=%d", aActiveWaitCmd ); + + switch( aActiveWaitCmd ) + { + case EActiveWaitStart: + { + if( !iActiveSchedulerWait->IsStarted() ) + { + iActiveSchedulerWait->Start(); + } + else + { + VCXLOGLO1("ActiveSchedulerWait already started"); + } + } + break; + case EActiveWaitStop: + { + if( iActiveSchedulerWait->IsStarted() ) + { + iActiveSchedulerWait->AsyncStop(); + } + else + { + VCXLOGLO1("ActiveSchedulerWait already stopped"); + } + } + break; + default: + break; + } + + VCXLOGLO1("<<IsStarted(); + } + +// ----------------------------------------------------------------------------- +// CIptvTestActiveWait::Start +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CIptvTestActiveWait::Start( ) + { + TInt err = KErrNotReady; + if( !iActiveSchedulerWait->IsStarted() ) + { + iActiveSchedulerWait->Start(); + err = KErrNone; + } + else + { + VCXLOGLO1("ActiveSchedulerWait already started"); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIptvTestActiveWait::Stop +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CIptvTestActiveWait::Stop( ) + { + TInt err = KErrNotReady; + if( iActiveSchedulerWait->IsStarted() ) + { + iActiveSchedulerWait->AsyncStop(); + err = KErrNone; + } + else + { + VCXLOGLO1("ActiveSchedulerWait already stopped"); + } + return err; + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestEvent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestEvent.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDES +#include "CIptvTestEvent.h" +#include "VCXTestLog.h" + +EXPORT_C CIptvTestEvent::~CIptvTestEvent() + { + } + +EXPORT_C TBool CIptvTestEvent::HasTimeouted(TTime& aTimeNow) + { + if(!iActive) + { + return EFalse; + } + TTimeIntervalSeconds secondsAlive; + aTimeNow.SecondsFrom(iActivationTime, secondsAlive); + + VCXLOGLO3("CIptvTestEvent:: '%S' seconds to timeout: %d", &iName, iTimeoutSeconds - secondsAlive.Int() ); + + if(secondsAlive.Int() >= iTimeoutSeconds) + { + return ETrue; + } + return EFalse; + } + +EXPORT_C CIptvTestEvent::CIptvTestEvent( const TDesC& aName, TInt aTimeoutSeconds) + { + iName = _L("Noname Event"); + iName = aName; + iTimeoutSeconds = aTimeoutSeconds; + iActive = EFalse; + } + +void CIptvTestEvent::ConstructL() + { + } + +EXPORT_C void CIptvTestEvent::GetName(TDes& aName) + { + aName = iName; + } + + +EXPORT_C void CIptvTestEvent::Activate() + { + iActive = ETrue; + iActivationTime.UniversalTime(); + VCXLOGLO2("ACTIVATED %S", &iName); + } + +EXPORT_C void CIptvTestEvent::Deactivate() + { + iActive = EFalse; + VCXLOGLO2("DEACTIVATED %S", &iName); + } + + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestEventWaiter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/CIptvTestEventWaiter.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDES +#include "CIptvTestEventWaiter.h" +#include "MIptvTestEventWaiterObserver.h" +#include "CIptvTestEvent.h" +#include "VCXTestLog.h" + +// ----------------------------------------------------------------------------- +// CIptvTestEventWaiter::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestEventWaiter* CIptvTestEventWaiter::NewL(MIptvTestEventWaiterObserver& aObserver) +{ + VCXLOGLO1(">>>CIptvTestEventWaiter::NewL"); + CIptvTestEventWaiter* self = new (ELeave) CIptvTestEventWaiter(aObserver); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + VCXLOGLO1("<<>>CIptvTestEventWaiter::~CIptvTestEventWaiter"); + if( IsAdded() ) + { + Deque(); // calls also Cancel() + } + + iTimer.Close(); + + Reset(); + VCXLOGLO1("<<>>CIptvTestEventWaiter::CheckTimeouts"); + TTime now; + now.UniversalTime(); + + TInt i; + for(i=0; iHasTimeouted( now ) ) + { + VCXLOGLO1("CIptvTestEventWaiter:: event timedout"); + iObserver.EventWaiterErrorL( KErrTimedOut, *event ); + VCXLOGLO1("<<HasTimeouted( now ) ) + { + VCXLOGLO1("CIptvTestEventWaiter:: event timedout"); + iObserver.EventWaiterErrorL( KErrTimedOut, *event ); + VCXLOGLO1("<<>>CIptvTestEventWaiter::AddEvent"); + + if(aSequential) + { + // First event in queue, activate it + if(iEventQueue.Count() <= 0) + { + aEvent->Activate(); + } + // Add event + iEventQueue.Append( aEvent ); + } + else + { + // All events in dump are active + iEventDump.Append( aEvent ); + aEvent->Activate(); + } + + if( !IsActive() ) + { + iTimer.After(iStatus, 1000000); // once in second + SetActive(); + } + + VCXLOGLO1("<<>>CIptvTestEventWaiter::EventHappened"); + TBool eventFound = EFalse; + + // Check first from the queue. + + VCXLOGLO1("Event queue:"); + + for(TInt i=0; i name; + event->GetName(name); + VCXLOGLO3(" queue %d: %S, %d", i, &name); + } + + //CheckTimeouts(); + + if(iEventQueue.Count() > 0) + { + CIptvTestEvent* event = iEventQueue[0]; + TBuf<32> name; + event->GetName(name); + VCXLOGLO2(" - %S", &name); + + if( !eventFound && event->Compare( *aEvent ) ) + { + iEventQueue.Remove( 0 ); + if(iEventQueue.Count() > 0) + { + iEventQueue[0]->Activate(); + } + iPastEvents.Append( event ); + eventFound = ETrue; + + *aQueuedEvent = event; + + VCXLOGLO1("*Match*"); + } + } + + // Check if the event is in the dump, meaning it can happen any time. + + VCXLOGLO1("Event dump:"); + + if(!eventFound) + { + for(TInt i=0; i name; + event->GetName(name); + VCXLOGLO2(" - %S", &name); + + if( !eventFound && event->Compare( *aEvent ) ) + { + iEventDump.Remove( i ); + iPastEvents.Append( event ); + eventFound = ETrue; + *aQueuedEvent = event; + VCXLOGLO1("*Match*"); + } + } + } + + // Event was found and there's no more events in queues. Message observer that all events are validated. + + if( eventFound && iEventQueue.Count() == 0 && iEventDump.Count() == 0 ) + { + iObserver.EventWaiterAllEventsValidated(); + } + + if( !eventFound ) + { + VCXLOGLO1("CIptvTestEventWaiter:: Event not found from queues."); + + if(iEventQueue.Count() > 0) + { + CIptvTestEvent* event = iEventQueue[0]; + *aQueuedEvent = event; + } + + VCXLOGLO1("<<>>CIptvTestEventWaiter::Reset"); + iEventQueue.ResetAndDestroy(); + iEventDump.ResetAndDestroy(); + iPastEvents.ResetAndDestroy(); + VCXLOGLO1("<<>>CIptvTestEventWaiter::GetEventCount"); + TInt count = 0; + count += iEventQueue.Count(); + count += iEventDump.Count(); + VCXLOGLO2("<<>>CIptvTestEventWaiter::ConstructL"); + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + VCXLOGLO1("<<>>CIptvTestEventWaiter::RunL"); + +// TInt statusCode = iStatus.Int(); + + CheckTimeouts(); + + // Start timer again if waiting for events + + if(iEventQueue.Count() > 0 || iEventDump.Count() > 0) + { + + if( !IsActive() ) + { + iTimer.After(iStatus, 1000000); // once in second + SetActive(); + } + } + + + //VCXLOGLO1("<<>>CIptvTestEventWaiter::DoCancel"); + iTimer.Cancel(); + VCXLOGLO1("<< +#include + +#include "CIptvTestMobilecrashWatcher.h" +#include "VCXTestLog.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +_LIT(KDriveC, "C:\\"); +_LIT(KDriveE, "E:\\"); +_LIT(KDriveF, "F:\\"); + +// ----------------------------------------------------------------------------- +// CIptvTestMobilecrashWatcher:: +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestMobilecrashWatcher* CIptvTestMobilecrashWatcher::NewL() + { + VCXLOGLO1(">>>CIptvTestMobilecrashWatcher::NewL"); + CIptvTestMobilecrashWatcher* self = new (ELeave) CIptvTestMobilecrashWatcher( ); + CleanupStack::PushL(self); + self->ConstructL(ETrue); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::NewL"); + CIptvTestMobilecrashWatcher* self = new (ELeave) CIptvTestMobilecrashWatcher( ); + CleanupStack::PushL(self); + self->ConstructL(aPanicEnabled); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::~CIptvTestMobilecrashWatcher"); + + iCrashesBefore.ResetAndDestroy(); + iCrashesNow.ResetAndDestroy(); + iFsSession.Close(); + + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::CIptvTestMobilecrashWatcher"); + + + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::ConstructL"); + + iPanicEnabled = aPanicEnabled; + iFsSession.Connect(); + + iCrashesBefore.ResetAndDestroy(); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesBefore, KDriveC) ); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesBefore, KDriveE) ); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesBefore, KDriveF) ); + VCXLOGLO1("<<& aCrashes, const TDesC& aDrive ) + { + VCXLOGLO1(">>>CIptvTestMobilecrashWatcher::ReadMobilecrashes"); + + CDir* dirList = NULL; + + TBuf path(aDrive); + + if(aDrive == KDriveC) + { + path.Append(_L("data\\")); + } + + path.Append(_L("*.*")); + + if( !iFsSession.IsValidDrive(EDriveE) ) + { + User::Leave( KErrNotSupported ); + } + + if ( iFsSession.GetDir( path, KEntryAttMatchExclude|KEntryAttDir, ESortByName, dirList ) == KErrNone ) + { + CleanupStack::PushL( dirList ); + + for ( TInt file = 0; file < dirList->Count(); file++ ) + { + HBufC* fileName = HBufC::NewL(KMaxFileName); + CleanupStack::PushL( fileName ); + + fileName->Des().Append(aDrive); + fileName->Des().Append((*dirList)[file].iName); + + if(fileName->Des().FindF( _L("mobilecrash") ) >= 0) + { + CleanupStack::Pop( fileName ); + aCrashes.Append(fileName); + } + else + { + CleanupStack::PopAndDestroy( fileName ); + } + } + CleanupStack::PopAndDestroy( dirList ); + } + + VCXLOGLO1("<<& aCrashesBefore, RPointerArray& aCrashesNow) + { + VCXLOGLO1(">>>CIptvTestMobilecrashWatcher::CompareMobilecrashesL"); + TBool newCrashes = EFalse; + + TInt i = 0; + TInt e = 0; + + VCXLOGLO2("CIptvTestMobilecrashWatcher:: crash files before: %d", aCrashesBefore.Count()); + VCXLOGLO2("CIptvTestMobilecrashWatcher:: crash files now: %d", aCrashesNow.Count()); + + // remove crashesBefore from crashesNow + + // Check is the mobilecrash log in the before array + for(e=0;eDes(); + TPtrC now = aCrashesNow[i]->Des(); + + if(before == now ) + { + HBufC* buf = aCrashesNow[i]; + aCrashesNow.Remove(i); + delete buf; + break; + } + } + } + + if(aCrashesNow.Count() > 0) + { + newCrashes = ETrue; + VCXLOGLO1("CIptvTestMobilecrashWatcher:: New mobilecrashes:"); + for(i=0;iDes(); + VCXLOGLO2("CIptvTestMobilecrashWatcher:: %S", &file); + } + } + + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::CheckNewCrashesL"); + + iCrashesNow.ResetAndDestroy(); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesNow, KDriveC) ); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesNow, KDriveE) ); + TRAP_IGNORE( ReadMobilecrashesL(iCrashesNow, KDriveF) ); + if( CompareMobilecrashesL(iCrashesBefore, iCrashesNow) ) + { + VCXLOGLO1("CIptvTestMobilecrashWatcher:: * ERROR * There's new mobilecrashes, panicing!"); + User::Panic(_L("New mobilecrash log"), KErrGeneral); + } + + VCXLOGLO1("<<& aArray) + { + VCXLOGLO1(">>>CIptvTestMobilecrashWatcher::CheckNewCrashesL"); + + aArray.ResetAndDestroy(); + TRAP_IGNORE( ReadMobilecrashesL(aArray, KDriveC) ); + TRAP_IGNORE( ReadMobilecrashesL(aArray, KDriveE) ); + TRAP_IGNORE( ReadMobilecrashesL(aArray, KDriveF) ); + TBool newCrashes = CompareMobilecrashesL(iCrashesBefore, aArray); + if( newCrashes ) + { + VCXLOGLO1("CIptvTestMobilecrashWatcher:: * ERROR * There's new mobilecrashes!"); + } + + VCXLOGLO1("<<>>CIptvTestMobilecrashWatcher::ReturnMobileCrashCount"); + + RPointerArray array; + + array.ResetAndDestroy(); + TRAP_IGNORE( ReadMobilecrashesL(array, KDriveC) ); + TRAP_IGNORE( ReadMobilecrashesL(array, KDriveE) ); + TRAP_IGNORE( ReadMobilecrashesL(array, KDriveF) ); + TInt count = array.Count(); + array.ResetAndDestroy(); + + VCXLOGLO1("<<>>CIptvTestTimer::NewL"); + CIptvTestTimer* self = new (ELeave) CIptvTestTimer(aObserver, aId); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CIptvTestTimer::~CIptvTestTimer"); + iRestartAfterCancel = EFalse; + Cancel(); + iTimer.Close(); + + if( IsAdded() ) + { + Deque(); // calls also Cancel() + } + + VCXLOGLO1("<<>>CIptvTestTimer::CancelTimer"); + if( IsActive() ) + { + iRestartAfterCancel = EFalse; + Cancel(); + } + VCXLOGLO1("<<>>CIptvTestTimer::CIptvTestTimer"); + CActiveScheduler::Add(this); + VCXLOGLO1("<<>>CIptvTestTimer::ConstructL"); + User::LeaveIfError(iTimer.CreateLocal()); + VCXLOGLO1("<<>>CIptvTestTimer::DoCancel"); + iTimer.Cancel(); + VCXLOGLO1("<< + +#include "CIptvTestVerifyData.h" +#include "VCXTestLog.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +_LIT(KDriveC, "C:\\"); +_LIT(KLineBreak, "\r\n"); + +_LIT(KPathVerifyWrite, "testing\\data\\verifynew\\"); +_LIT(KVerifyExtension, ".txt"); + +// ----------------------------------------------------------------------------- +// CVerifyFile::NewL +// ----------------------------------------------------------------------------- +// +CVerifyFile* CVerifyFile::NewL() + { + CVerifyFile* self = new (ELeave) CVerifyFile(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CVerifyFile::ConstructL +// ----------------------------------------------------------------------------- +// +void CVerifyFile::ConstructL() + { + iFs.Connect(); + iId.Zero(); + } + +// ----------------------------------------------------------------------------- +// CVerifyFile::CVerifyFile +// ----------------------------------------------------------------------------- +// +CVerifyFile::CVerifyFile() + { + + } + +// ----------------------------------------------------------------------------- +// CVerifyFile::~CVerifyFile +// ----------------------------------------------------------------------------- +// +CVerifyFile::~CVerifyFile() + { + delete iFileName; + iFileName = NULL; + CloseFileHandles(); + iFs.Close(); + } + +// ----------------------------------------------------------------------------- +// CVerifyFile::CloseFileHandles +// ----------------------------------------------------------------------------- +// +void CVerifyFile::CloseFileHandles() + { + VCXLOGLO1(">>>CVerifyFile::CloseFileHandles"); + if(iFileOpen) + { + iFile.Close(); + iFileStream.Close(); + } + iFileOpen = EFalse; + VCXLOGLO1("<<>>CVerifyFile::ResolveFileName"); + + iFileName->Des().Zero(); + + iFileName->Des().Append(KDriveC); + + iFileName->Des().Append(KPathVerifyWrite); + + BaflUtils::EnsurePathExistsL(iFs, iFileName->Des()); + + iFileName->Des().Append(iId); + iFileName->Des().Append(KVerifyExtension); + + VCXLOGLO1("<>>CVerifyFile::OpenStream"); + + ResolveFileName(); + + // create the stream + + TInt filePos = 0; + if(BaflUtils::FileExists(iFs, iFileName->Des())) + { + TInt result = iFile.Open(iFs, iFileName->Des(), EFileShareAny | EFileWrite | EFileStreamText); + if(result != KErrNone) + { + TPtrC fileName = iFileName->Des(); + VCXLOGLO2("Could not open file: %S", &fileName); + VCXLOGLO1("<<>>CVerifyFile::CreateNewFile"); + + if(BaflUtils::FileExists(iFs, iFileName->Des() )) + { + iFs.Delete(iFileName->Des()); + } + + if(KErrNone == iFile.Create(iFs, iFileName->Des(), EFileShareAny | EFileWrite | EFileStreamText)) + { + iFile.Close(); + } + + VCXLOGLO1("<<Des().Length() > 0) + { + aFileName = iFileName->Des(); + } + } + +// ----------------------------------------------------------------------------- +// CIptvTestVerifyData:: +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestVerifyData* CIptvTestVerifyData::NewL() + { + VCXLOGLO1(">>>CIptvTestVerifyData::NewL"); + CIptvTestVerifyData* self = new (ELeave) CIptvTestVerifyData( ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CIptvTestVerifyData::~CIptvTestVerifyData"); + + delete iZipFile; + iZipFile = NULL; + + iFs.Close(); + + iVerifyFiles.ResetAndDestroy(); + + delete iBuffer; + iBuffer = NULL; + + VCXLOGLO1("<<iId == aVerifyId) + { + aIndex = i; + } + } + + if(aIndex == -1) + { + return KErrNotFound; + } + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIptvTestVerifyData::CreateVerifyData +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CIptvTestVerifyData::CreateVerifyDataL(TDesC& aVerifyId, TBool aAppend) + { + VCXLOGLO1(">>>CIptvTestVerifyData::CreateVerifyData"); + + if(aVerifyId.Length() <= 0) + { + VCXLOGLO1("No verify Id"); + VCXLOGLO1("<<iId = aVerifyId; + iVerifyFiles.Append(vf); + if(KErrNone != GetVerifyFileIndex(index, aVerifyId)) + { + VCXLOGLO1("CIptvTestVerifyData:: Verify file not found even after creating one."); + VCXLOGLO1("<< fileName; + + if(!aAppend) + { + iVerifyFiles[index]->CreateNewFile(); + } + + iVerifyFiles[index]->GetFileToWrite(fileName); + + VCXLOGLO2("CIptvTestVerifyData:: writePath %S", &fileName); + + VCXLOGLO1("<<>>CIptvTestVerifyData::WriteVerifyData"); + + iBuffer->Des().Zero(); + + if( iUseTimestamps ) + { + _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B"); + TBuf<128> timeString; + TTime time; + time.HomeTime(); + TBuf<128> buff; + time.FormatL( buff, KDateTimeString ); + iBuffer->Des().Append( buff ); + iBuffer->Des().Append( _L(" ") ); + } + + iBuffer->Des().Append( aVerifyData ); + + TInt result = KErrNone; + iVerifyFiles[index]->WriteData( *iBuffer ); + TBuf<12> lineChange(KLineBreak); + iVerifyFiles[index]->WriteData( lineChange ); + +// VCXLOGLO1("<<>>CIptvTestVerifyData::VerifyData"); + + TInt result = KErrNone; + aVerifyResult = EVerifyOk; + + // Connect to file system + TBuf<256> fileNameRead( _L("c:\\testing\\data\\iptvtempverify.txt") ); // File which is extracted from verify.zip + TBuf<256> fileNameWrite; // File which is written during the test + + TRAPD( err, ExtractVerifyFileL( aVerifyId, fileNameRead ) ); + if( err != KErrNone ) + { + VCXLOGLO2("CIptvTestVerifyData:: verify file extract failed: %d", err); + VCXLOGLO1("<<GetFileToWrite(fileNameWrite); + iVerifyFiles[index]->CloseFileHandles(); + + // Check that the files exist + + if(!BaflUtils::FileExists(iFs, fileNameRead)) + { + VCXLOGLO2("File used to verify data not found. %S must be verified by hand and added to the verify.zip.", &fileNameWrite); + VCXLOGLO1("<<Des() ); + + // File from test case + RFile fileFromTest; + TFileText fromTest; + HBufC* lineFromTestBuff = HBufC::NewL( 1024 * 4 ); + CleanupStack::PushL( lineFromTestBuff ); + TPtr lineFromTest( lineFromTestBuff->Des() ); + + result = fileFromInst.Open(iFs, fileNameRead, EFileRead | EFileStreamText); + if(result != KErrNone) + { + VCXLOGLO2("Could not open file 1: %S", &fileNameRead); + CleanupStack::PopAndDestroy( lineFromTestBuff ); + CleanupStack::PopAndDestroy( lineFromInstBuff ); + VCXLOGLO1("<<>>CIptvTestVerifyData::CIptvTestVerifyData"); + + VCXLOGLO1("<<>>CIptvTestVerifyData::ConstructL"); + iVerifyFiles.ResetAndDestroy(); + User::LeaveIfError( iFs.Connect() ); + TRAPD(err, iZipFile = CZipFile::NewL( iFs, KIptvVerifyZipFile ) ); + if( err == KErrNoMemory ) + { + User::Leave( err ); + } + if( err != KErrNone ) + { + VCXLOGLO2("CIptvTestVerifyData:: CZipFile::NewL err: %d", err); + delete iZipFile; + iZipFile = NULL; + } + + iBuffer = HBufC::NewL( 1024 * 5 ); + + VCXLOGLO1("<<>>CIptvTestVerifyData::ReadFile: %S", &aFileName); + + TInt result = KErrNone; + RFile file; + TInt fileSize; + + result = file.Open(aFs, aFileName, EFileRead | EFileStreamText); + if(result != KErrNone) + { + VCXLOGLO2("Could not open file 1: %S", &aFileName); + VCXLOGLO1("<<Des() ); + file.Read(ptr); + + *aBuff = buff; + + CleanupStack::PopAndDestroy(&file); + + VCXLOGLO1("<<>>CIptvTestVerifyData::ExtractVerifyFile"); + + iFs.Delete( aDestFile ); + + if( !iZipFile ) + { + VCXLOGLO1("CIptvTestVerifyData:: iZipFile == NULL! Leaving.."); + User::Leave( KErrNotReady ); + } + + TBuf<256> verifyFileName( aVerifyId ); + verifyFileName.Append( KVerifyExtension ); + VCXLOGLO2("CIptvTestVerifyData:: verifyFileName: %S", &verifyFileName); + VCXLOGLO2("CIptvTestVerifyData:: aDestFile: %S", &aDestFile); + + if( !FileExistsInZip( iZipFile, verifyFileName ) ) + { + VCXLOGLO1("CIptvTestVerifyData:: No such file in zip! Leaving.."); + User::Leave( CIptvTestVerifyData::EVerifiedFileNotFound ); + } + + // Get zip file member from the archive + VCXLOGLO1("CIptvTestVerifyData:: Get zip file member from the archive"); + CZipFileMember* member = iZipFile->CaseInsensitiveMemberL( verifyFileName ); + if( member == NULL ) + { + VCXLOGLO1("CIptvTestVerifyData:: zip member is null. Leaving.."); + User::Leave(KErrGeneral); + } + CleanupStack::PushL( member ); + + // Get read stream for the file + VCXLOGLO1("CIptvTestVerifyData:: Get read stream for the file"); + RZipFileMemberReaderStream* stream; + iZipFile->GetInputStreamL( member, stream ); + CleanupStack::PushL( stream ); + + // Alloc buffer and read the archived file + VCXLOGLO1("CIptvTestVerifyData:: Alloc buffer and read the archived file"); + HBufC8* buffer = HBufC8::NewLC( member->UncompressedSize() ); + TPtr8 bufferPtr( buffer->Des() ); + User::LeaveIfError( stream->Read( bufferPtr, member->UncompressedSize() ) ); + + // Write the file to the filesystem + VCXLOGLO1("CIptvTestVerifyData:: Write the file to the filesystem"); + RFile file; + User::LeaveIfError( file.Replace( iFs, aDestFile, EFileWrite ) ); + CleanupClosePushL( file ); + User::LeaveIfError( file.Write(*buffer) ); + + CleanupStack::PopAndDestroy( &file ); + CleanupStack::PopAndDestroy( buffer ); + CleanupStack::PopAndDestroy( stream ); + CleanupStack::PopAndDestroy( member ); + + VCXLOGLO1("<<>>CIptvTestVerifyData::FileExistsInZip"); + + CZipFileMember* member = NULL; + + VCXLOGLO1("CIptvTestVerifyData:: list of members"); + CZipFileMemberIterator* members = aZipFile->GetMembersL(); + + VCXLOGLO1("CIptvTestVerifyData:: loop all members"); + + while ((member = members->NextL()) != 0) + { + VCXLOGLO3("CIptvTestVerifyData:: member %S, size: %d", &(*member->Name()), member->CompressedSize()); + + if( aFileName == (*member->Name()) ) + { + delete member; + delete members; + VCXLOGLO1("<< +#include + +#include "CIptvTestVideoCreator.h" +#include "VCXTestLog.h" + +// ----------------------------------------------------------------------------- +// NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestVideoCreator* CIptvTestVideoCreator::NewL() + { + CIptvTestVideoCreator* self; + self = new (ELeave) CIptvTestVideoCreator(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CIptvTestVideoCreator +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestVideoCreator::~CIptvTestVideoCreator() + { + delete iFileMan; + iFileMan = NULL; + iFs.Close(); + } + +// ----------------------------------------------------------------------------- +// CIptvTestVideoCreator +// ----------------------------------------------------------------------------- +// +EXPORT_C CIptvTestVideoCreator::CIptvTestVideoCreator() + { + + } + +// ----------------------------------------------------------------------------- +// ConstructL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CIptvTestVideoCreator::ConstructL() + { + User::LeaveIfError( iFs.Connect() ); + iFileMan = CFileMan::NewL( iFs ); + } + +// ----------------------------------------------------------------------------- +// CreateVideoL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CIptvTestVideoCreator::CreateVideoL(CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aSize) + { + VCXLOGLO1(">>>CIptvTestVideoCreator::CreateVideoL"); + + // Resolve source filename + TBuf<256> srcFileName; + + GetVideoFile( srcFileName, aVideoType, _L("C") ); + if( !BaflUtils::FileExists(iFs, srcFileName) ) + { + VCXLOGLO2("CIptvTestVideoCreator:: %S does not exist.", &srcFileName); + GetVideoFile( srcFileName, aVideoType, _L("E") ); + if( !BaflUtils::FileExists(iFs, srcFileName) ) + { + VCXLOGLO2("CIptvTestVideoCreator:: %S does not exist.", &srcFileName); + VCXLOGLO2("CIptvTestVideoCreator:: test video file %S missing! PANIC.", &srcFileName); + User::Panic(_L("Video files missing!"), KErrNotFound); + } + } + + BaflUtils::EnsurePathExistsL( iFs, aFileName.Left( aFileName.LocateReverse('\\') ) ); + + BaflUtils::DeleteFile( iFs, aFileName ); + + VCXLOGLO2("CIptvTestVideoCreator:: aSize = %d", aSize); + + TInt64 wantedSize( 0 ); + + // Check the size + if( aSize == KVcxTestLargeFile3GB ) { + wantedSize = 3000000000; + } + else { + wantedSize = aSize; + } + + //wantedSize = wantedSize == 0 ? wantedSize -1 : wantedSize; + + VCXLOGLO2("CIptvTestVideoCreator:: Wanted file size: %Ld", wantedSize); + + // Read source file into memory, won't work on huge files. + RFile64 srcFile; + VCXLOGLO2("CIptvTestVideoCreator:: Opening %S", &srcFileName); + User::LeaveIfError( srcFile.Open( iFs, srcFileName, EFileRead ) ); + CleanupClosePushL( srcFile ); + + TInt64 srcSize(0); + VCXLOGLO2("CIptvTestVideoCreator:: Getting size of %S", &srcFileName); + User::LeaveIfError( srcFile.Size( srcSize ) ); + + HBufC8* data = HBufC8::NewL( srcSize ); + TPtr8 ptr( data->Des() ); + srcFile.Read( ptr, srcSize ); + CleanupStack::PopAndDestroy( &srcFile ); + + CleanupStack::PushL( data ); + + // Write new file. + RFile64 dstFile; + VCXLOGLO1("CIptvTestVideoCreator:: Replace"); + User::LeaveIfError( dstFile.Replace( iFs, aFileName, EFileWrite ) ); + CleanupClosePushL(dstFile); + + if( wantedSize <= srcSize ) + { + if( wantedSize == -1 ) + { + VCXLOGLO2("CIptvTestVideoCreator:: Writing %Ld", srcSize); + User::LeaveIfError( dstFile.Write( *data, srcSize ) ); + } + else + { + VCXLOGLO2("CIptvTestVideoCreator:: Writing %Ld", wantedSize); + User::LeaveIfError( dstFile.Write( *data, wantedSize ) ); + } + } + else + { + VCXLOGLO2("CIptvTestVideoCreator:: Writing %Ld", srcSize); + User::LeaveIfError( dstFile.Write( *data, srcSize ) ); + + const TInt KIptvTest200Kilos = 1024*200; + HBufC8* buff = HBufC8::NewL( KIptvTest200Kilos ); + buff->Des().SetLength( KIptvTest200Kilos ); + CleanupStack::PushL( buff ); + TInt64 bytesToWrite = wantedSize - srcSize; + while( bytesToWrite > 0 ) + { + if( bytesToWrite >= KIptvTest200Kilos ) + { + bytesToWrite -= KIptvTest200Kilos; + User::LeaveIfError( dstFile.Write( *buff ) ); + } + else + { + User::LeaveIfError( dstFile.Write( *buff, bytesToWrite ) ); + bytesToWrite = 0; + } + } + CleanupStack::PopAndDestroy( buff ); + } + + CleanupStack::PopAndDestroy( &dstFile ); + CleanupStack::PopAndDestroy( data ); + + VCXLOGLO1("<<& aFileArray ) + { + VCXLOGLO1(">>>CIptvTestVideoCreator::CreateVideosL"); + + // Resolve source filename + TBuf<256> srcFileName; + + GetVideoFile( srcFileName, aVideoType, _L("C") ); + + if( !BaflUtils::FileExists(iFs, srcFileName) ) + { + VCXLOGLO2("CIptvTestVideoCreator:: %S does not exist.", &srcFileName); + GetVideoFile( srcFileName, aVideoType, _L("E") ); + if( !BaflUtils::FileExists(iFs, srcFileName) ) + { + VCXLOGLO2("CIptvTestVideoCreator:: %S does not exist.", &srcFileName); + VCXLOGLO2("CIptvTestVideoCreator:: test video file %S missing! PANIC.", &srcFileName); + // Comment next line if you want dummy files to be created. They won't be recognized by MDS. + User::Panic(_L("Video files missing!"), KErrNotFound); + } + } + + TBool fileExists = BaflUtils::FileExists(iFs, srcFileName); + + HBufC* newFileName = HBufC::NewL( 256 ); + CleanupStack::PushL( newFileName ); + + newFileName->Des().Copy( aFileName.Left( aFileName.LocateReverse('\\') ) ); + BaflUtils::EnsurePathExistsL(iFs, *newFileName); + + TInt dotPos = aFileName.LocateReverse('.'); + + for( TInt i = 0; i < aCount; i++ ) + { + newFileName->Des().Copy( aFileName.Left( dotPos ) ); + newFileName->Des().Append( _L("_") ); + newFileName->Des().AppendNum( i ); + newFileName->Des().Append( aFileName.Right( aFileName.Length() - dotPos ) ); + + HBufC* fileForClient = newFileName->Des().AllocL(); + aFileArray.Append( fileForClient ); + + if( fileExists ) + { + User::LeaveIfError( iFileMan->Copy(srcFileName, *newFileName) ); + VCXLOGLO2("CIptvTestVideoCreator:: copy file: '%S'", newFileName); + } + else + { + VCXLOGLO2("CIptvTestVideoCreator:: new fake file: '%S'", newFileName); + RFile file; + CleanupClosePushL(file); + User::LeaveIfError( file.Replace(iFs, *newFileName, EFileWrite) ); + User::LeaveIfError( file.SetSize( 1024*10 ) ); + CleanupStack::PopAndDestroy( &file ); + } + User::After( 100000 ); // Wait tenth of a second. + } + + CleanupStack::PopAndDestroy( newFileName ); + + VCXLOGLO1("<<>>CIptvTestVideoCreator::GetVideoFile"); + aFileName.Copy( aDrive ); + + _LIT(KIptvTestVideoBasePath, ":\\testing\\data\\"); + + aFileName.Append( KIptvTestVideoBasePath ); + + VCXLOGLO2("CIptvTestVideoCreator::GetVideoFile -- using %S", &aFileName); + + switch (aVideoType) + { + case CIptvTestVideoCreator::IptvTestVideo3Gp: + { + aFileName.Append( _L("video_3gp.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideo3Gp2: + { + aFileName.Append( _L("video_3gp2.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMp2: + { + aFileName.Append( _L("video_mp2.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMpeg1: + { + aFileName.Append( _L("video_mpeg1.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMpeg2: + { + aFileName.Append( _L("video_mpeg2.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoSuperVideoCd: + { + aFileName.Append( _L("video_supervideocd.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMp3: + { + aFileName.Append( _L("video_mp3.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoAppleMpeg: + { + aFileName.Append( _L("video_applempeg.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMpeg4: + { + aFileName.Append( _L("video_mpeg4.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoMpegAvc: + { + aFileName.Append( _L("video_mpegavc.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoQuicktime: + { + aFileName.Append( _L("video_quicktime.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoRealVideo: + { + aFileName.Append( _L("video_realvideo.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoAvi: + { + aFileName.Append( _L("video_avi.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoWmv: + { + aFileName.Append( _L("video_wmv.xxx") ); + } + break; + + case CIptvTestVideoCreator::IptvTestVideoAviAC3: + { + aFileName.Append( _L("video_aviac3.xxx") ); + } + break; + default: + User::Panic(_L("IptvMyVideosApiTest: Unknown video type!"), KErrCorrupt); + } + VCXLOGLO1("<< +#include +#include +#include + +#include "IptvTestDownloadManager.h" +#include "VCXTestLog.h" +#include "CIptvTestTimer.h" + +// ========================== MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CTestUtilConnection::NewL() +// +// Constructs CTestUtilConnection object +// --------------------------------------------------------------------------- +// +EXPORT_C CIptvTestDownloadManager* CIptvTestDownloadManager::NewL(MTestUtilDownloadObserver *aObs) + { + VCXLOGLO1(">>>CIptvTestDownloadManager::NewL"); + CIptvTestDownloadManager* self = NewLC(aObs); + CleanupStack::Pop(self); + VCXLOGLO1("<<>>CIptvTestDownloadManager::NewLC"); + CIptvTestDownloadManager* self = new (ELeave) CIptvTestDownloadManager(aObs); + CleanupStack::PushL(self); + self->ConstructL(); + VCXLOGLO1("<<>>CIptvTestDownloadManager::CIptvTestUtilConnection"); + + VCXLOGLO1("<<>>CIptvTestDownloadManager::~CIptvTestDownloadManager"); + + iDownloadMgr.DeleteAll(); + iDownloadMgr.RemoveObserver(*this); + iDownloadMgr.Close(); + + if( iDownload ) + { + iDownload->Delete(); + iDownload = NULL; + } + + if( iTimer ) + { + delete iTimer; + iTimer = NULL; + } + + VCXLOGLO1("<<>>CIptvTestDownloadManager::ConstructL"); + + iDownloadRunning = EFalse; + TUid uid; + uid.iUid = 0x101FB3E3; + iDownloadMgr.ConnectL(uid, *this, ETrue); + + iTimer = CIptvTestTimer::NewL(*this, 0); + + VCXLOGLO1("<<>>CIptvTestDownloadManager::HandleDMgrEventL"); + + TInt32 downloadId; + aDownload.GetIntAttribute(EDlAttrId, downloadId); + + VCXLOGLO3("CIptvTestDownloadManager:: downloadId: %d, aEvent: %d", downloadId, aEvent); + + switch (aEvent.iProgressState) + { + case EHttpContentTypeReceived: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpContentTypeReceived"); + User::LeaveIfError(aDownload.Start()); + break; + case EHttpProgNone: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgNone"); + break; + case EHttpStarted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpStarted"); + break; + case EHttpProgCreatingConnection: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgCreatingConnection"); + break; + case EHttpProgConnectionNeeded: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgConnectionNeeded"); + break; + case EHttpProgConnected: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgConnected"); + break; + case EHttpProgConnectionSuspended: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgConnectionSuspended"); + break; + case EHttpProgDisconnected: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgDisconnected"); + break; + case EHttpProgDownloadStarted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgDownloadStarted"); + break; + case EHttpContentTypeRequested: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpContentTypeRequested"); + break; + case EHttpProgSubmitIssued: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgSubmitIssued"); + break; + case EHttpProgResponseHeaderReceived: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgResponseHeaderReceived"); + break; + case EHttpProgResponseBodyReceived: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgResponseBodyReceived"); + break; + case EHttpProgRedirectedPermanently: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgRedirectedPermanently"); + break; + case EHttpProgRedirectedTemporarily: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgRedirectedTemporarily"); + break; + case EHttpProgDlNameChanged: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgDlNameChanged"); + break; + case EHttpProgContentTypeChanged: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgContentTypeChanged"); + break; + case EHttpProgCodDescriptorDownloaded: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgCodDescriptorDownloaded"); + break; + case EHttpProgCodDownloadStarted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgCodDownloadStarted"); + break; + case EHttpProgCodDescriptorAccepted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgCodDescriptorAccepted"); + break; + case EHttpProgCodLoadEnd: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgCodLoadEnd"); + break; + case EHttpProgSupportedMultiPart: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgSupportedMultiPart"); + break; + case EHttpProgMovingContentFile: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgMovingContentFilep"); + break; + case EHttpProgContentFileMoved: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpProgContentFileMoved"); + break; + default: + VCXLOGLO1("CIptvTestDownloadManager:: Unknown state"); + break; + } + + switch (aEvent.iDownloadState) + { + case EHttpDlCompleted: + { + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlCompleted"); + + DeleteDownloadAsync( KErrNone ); + } + break; + + case EHttpDlFailed: + { + TInt32 err; + GetError( aDownload, err ); + VCXLOGLO2("CIptvTestDownloadManager:: Download failed, err: %d", err); + if( err == KErrNone ) + { + err = KErrGeneral; + } + DeleteDownloadAsync( err ); + } + break; + + case EHttpDlCreated: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlCreated"); + iDownloadRunning = ETrue; + break; + + case EHttpDlInprogress: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlInprogress"); + break; + + case EHttpDlPaused: + { + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlPaused"); + + TInt32 err; + GetError(aDownload, err); + VCXLOGLO2("CIptvTestDownloadManager:: Download is paused, err: %d", err); + if(err == KErrNone) err = KErrGeneral; + + DeleteDownloadAsync( err ); + } + break; + + case EHttpDlMoved: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlMoved"); + break; + + case EHttpDlMediaRemoved: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlMediaRemoved"); + break; + + case EHttpDlMediaInserted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlMediaInserted"); + break; + + case EHttpDlPausable: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlPausable"); + break; + + case EHttpDlNonPausable: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlNonPausable"); + break; + + case EHttpDlDeleted: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlDeleted"); + + if( !iDownloadFinishInformed ) + { + VCXLOGLO1("CIptvTestDownloadManager:: Informing observer."); + iDownloadFinishInformed = ETrue; + iObserver->DownloadFinished( iError ); + iDownloadRunning = EFalse; + } + break; + + case EHttpDlAlreadyRunning: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlAlreadyRunning"); + break; + + case EHttpDlDeleting: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlDeleting"); + if( !iDownloadFinishInformed ) + { + VCXLOGLO1("CIptvTestDownloadManager:: Informing observer."); + iDownloadFinishInformed = ETrue; + iObserver->DownloadFinished( iError ); + iDownloadRunning = EFalse; + } + break; + + case EHttpDlCancelTransaction: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpDlCancelTransaction"); + break; + + default: + VCXLOGLO1("CIptvTestDownloadManager:: Unknown state"); + break; + } + + + VCXLOGLO1("<<>>CIptvTestDownloadManager::DownloadL"); + + TBool result; + + if( iDownload ) + { + VCXLOGLO1("Download already ongoing."); + VCXLOGLO1("<<After(aTimeoutSeconds * 1000000); + + TBuf8<3000> address; + TBuf8<256> username; + TBuf8<256> password; + + address.Copy(aAddress); + username.Copy(aUserName); + password.Copy(aPassword); + + VCXLOGLO3("CIptvTestDownloadManager:: Starting downloading: %S -> %S", &aAddress, &aOutFile); + VCXLOGLO3("CIptvTestDownloadManager:: User: %S, PW %S", &aUserName, &aPassword); + VCXLOGLO2("CIptvTestDownloadManager:: Timeout: %d", aTimeoutSeconds); + + TInt err = KErrNone; + + err = iDownloadMgr.SetIntAttribute( EDlMgrIap, aIapId ); + if ( err != KErrNone ) + { + VCXLOGLO2("CIptvTestDownloadManager:: Could not set AP! err: %d", err); + return err; + } + + RHttpDownload& download = iDownloadMgr.CreateDownloadL( address, result ); + + iDownload = &download; + + err = iDownload->SetStringAttribute( EDlAttrDestFilename, aOutFile); + if(err != KErrNone) + { + VCXLOGLO1("Setting destfilename failed."); + VCXLOGLO1("<<Start(); + if(err != KErrNone) + { + VCXLOGLO1("Starting download failed."); + VCXLOGLO1("<< EIptvDlConnectionFailed"); + if(globalErrorId == KErrServerBusy) + { + VCXLOGLO1("CIptvTestDownloadManager:: server busy -> EIptvDlGeneral"); + aDownloadError = KErrServerBusy; + } + break; + case EHttpAuthenticationFailed: + VCXLOGLO1("CIptvTestDownloadManager:: EHttpAuthenticationFailed -> EIptvDlAuthFailed"); + aDownloadError = EHttpAuthenticationFailed; + break; + case EProxyAuthenticationFailed: + VCXLOGLO1("CIptvTestDownloadManager:: EProxyAuthenticationFailed -> EIptvDlProxyAuthFailed"); + aDownloadError = EProxyAuthenticationFailed; + break; + case EDestFileInUse: + VCXLOGLO1("CIptvTestDownloadManager:: EDestFileInUse -> EIptvDlDestFileInUse"); + aDownloadError = EDestFileInUse; + break; + case EBadUrl: + VCXLOGLO1("CIptvTestDownloadManager:: EBadUrl -> EIptvDlBadUrl"); + aDownloadError = EBadUrl; + break; + case EMMCRemoved: + VCXLOGLO1("CIptvTestDownloadManager:: EMMCRemoved -> EIptvDlMmcRemoved"); + aDownloadError = EMMCRemoved; + break; + case EDiskFull: + VCXLOGLO1("CIptvTestDownloadManager:: EDiskFull -> EIptvDlDiskFull"); + aDownloadError = EDiskFull; + break; + case EObjectNotFound: + VCXLOGLO1("CIptvTestDownloadManager:: EObjectNotFound -> EIptvDlContentNotFound"); + aDownloadError = EObjectNotFound; + break; + + default: + VCXLOGLO1("CIptvTestDownloadManager:: unknown -> EIptvDlGeneral"); + aDownloadError = KErrGeneral; + break; + } + } + +// --------------------------------------------------------- +// CIptvTestDownloadManager::DeleteDownloadAsync +// --------------------------------------------------------- +// +void CIptvTestDownloadManager::DeleteDownloadAsync( TInt aErrorToObserver ) + { + VCXLOGLO1(">>>CIptvTestDownloadManager::DeleteDownloadAsync"); + if( iDownload ) + { + iTimer->After( 1000000 ); // 1 second + iTimerStartedForDownloadDeletion = ETrue; + iError = aErrorToObserver; + } + VCXLOGLO1("<<>>CIptvTestDownloadManager::TimerComplete"); + + VCXLOGLO3("CIptvTestDownloadManager:: aTimerId: %d, aError: %d", aTimerId, aError); + + if( iTimerStartedForDownloadDeletion ) + { + iTimerStartedForDownloadDeletion = EFalse; + VCXLOGLO1("IptvTestDownloadManager:: Deleting the download."); + + if( iDownload ) + { + iDownload->Delete(); + iDownload = NULL; + } + + // Obsever is informed at DL deletion. + } + else + { + iObserver->DownloadFinished(KErrTimedOut); + } + + VCXLOGLO1("<< + +#include "IptvTestUtilALR.h" +#include "VCXTestLog.h" +#include "TestUtilConnection.h" +#include "CIptvTestActiveWait.h" +#include "TestUtilConnectionWaiter.h" +#include "VCXTestConstants.h" +#include + +// ========================== MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::NewL() +// +// Constructs CIptvTestUtilALR object +// --------------------------------------------------------------------------- +// +EXPORT_C CIptvTestUtilALR* CIptvTestUtilALR::NewL() + { + VCXLOGLO1(">>>CIptvIptvTestUtilALR::NewL"); + CIptvTestUtilALR* self = NewLC(); + CleanupStack::Pop(self); + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::NewLC"); + CIptvTestUtilALR* self = new (ELeave) CIptvTestUtilALR(); + CleanupStack::PushL(self); + self->ConstructL(); + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::~CIptvIptvTestUtilALR"); + + iCmManager.Close(); + + delete iActiveWait; + iActiveWait = NULL; + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::ConstructL"); + + iCmManager.OpenL(); + + iActiveWait = CIptvTestActiveWait::NewL(); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::CIptvIptvTestUtilALR"); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::RemoveUsedDestinationCenRep"); + + CRepository* cenRep = CRepository::NewLC( VCXTEST_KIptvAlrCenRepUid ); + User::LeaveIfError( cenRep->Delete( VCXTEST_KIptvCenRepUsedSnapIdKey ) ); + CleanupStack::PopAndDestroy( cenRep ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::SetUsedDestinationL"); + + VCXLOGLO2("CIptvIptvTestUtilALR:: dest name: %S", &aDestinationName); + + TInt destId(0); + + if( aDestinationName.Compare( _L("ALWAYS_ASK") ) != KErrNone ) + { + destId = GetDestinationIdL( aDestinationName ); + } + VCXLOGLO2("CIptvIptvTestUtilALR:: dest id: %d", destId); + + TCmDefConnValue defaultConnection; + defaultConnection.iType = ECmDefConnDestination; + defaultConnection.iId = destId; + iCmManager.WriteDefConnL( defaultConnection ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::CreateDestinationL"); + + VCXLOGLO2("CIptvIptvTestUtilALR:: dest name: %S", &aDestinationName); + + RCmDestinationExt dest; + TRAPD( err, dest = iCmManager.CreateDestinationL( aDestinationName ) ); + VCXLOGLO2("CIptvIptvTestUtilALR::CreateDestinationL: CreateDestinationL returned: %d", err); + User::LeaveIfError( err ); + + CleanupClosePushL( dest ); + TRAP( err, dest.SetHiddenL( EFalse ) ); + VCXLOGLO2("CIptvIptvTestUtilALR::CreateDestinationL: SetHiddenL returned: %d", err); + User::LeaveIfError( err ); + + // This leaves sometimes with KErrLocked, try again in that case few times. + for( TInt retry = 0; retry < 5; retry++ ) + { + TRAP( err, dest.UpdateL() ); + VCXLOGLO2("CIptvIptvTestUtilALR::CreateDestinationL: UpdateL returned: %d", err); + if( err != KErrLocked ) + { + User::LeaveIfError( err ); + break; // All ok. + } + User::After( 1000000 ); + } + + CleanupStack::PopAndDestroy( &dest ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::DeleteDestinationL"); + + VCXLOGLO2("CIptvIptvTestUtilALR:: dest name: '%S'", &aDestinationName); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TRAP_IGNORE( TerminateDestinationConnectionsL( aDestinationName ) ); + + // Delete methods first. + for(TInt e=destination.ConnectionMethodCount()-1; e>=0 ; e--) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: deleting method: %d", e ); + + destination.DeleteConnectionMethodL( method ); + destination.UpdateL(); + CleanupStack::PopAndDestroy( &method ); + } + + VCXLOGLO2( "CIptvIptvTestUtilALR:: deleting destination id: %d", destId ); + destination.DeleteLD(); + + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::CopyMethodL"); + + TBuf<256> srcMethodName( aMethodName ); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: srcMethodName: %S", &srcMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aNewMethodName: %S", &aNewMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aNewDestinationName: %S", &aNewDestinationName ); + + // Find target destination. + TInt targetDestId = GetDestinationIdL( aNewDestinationName ); + RCmDestinationExt targetDestination = iCmManager.DestinationL( targetDestId ); + CleanupClosePushL( targetDestination ); + + // Check if target has destination with the name already. + for(TInt e=0; e destIds(5); + iCmManager.AllDestinationsL( destIds ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: dest Count: %d", destIds.Count() ); + + for(TInt i=0; iLength() + 5); + newName->Des().Append( *sourceMethodName ); + newName->Des().Append( _L("_old") ); + sourceMethod.SetStringAttributeL( CMManager::ECmName, *newName ); + delete newName; + sourceMethod.UpdateL(); + } + + // Set name for new method. + newMethod.SetStringAttributeL( CMManager::ECmName, aNewMethodName ); + // Disable dialog asking permission. + newMethod.SetIntAttributeL( CMManager::ECmSeamlessnessLevel, CMManager::ESeamlessnessShowprogress ); + + VCXLOGLO1( "CIptvIptvTestUtilALR:: new method updated." ); + + targetDestination.AddConnectionMethodL( newMethod ); + targetDestination.UpdateL(); + + VCXLOGLO1( "CIptvIptvTestUtilALR:: method added to target dest." ); + + CleanupStack::PopAndDestroy( &newMethod ); + CleanupStack::PopAndDestroy( sourceMethodName ); + CleanupStack::PopAndDestroy( &sourceMethod ); + CleanupStack::PopAndDestroy( &sourceDestination ); + } + // No iap found, search from uncategorized IAPs. + else + { + RArray cmarray; + TRAPD( err, iCmManager.ConnectionMethodL( cmarray, EFalse, EFalse, EFalse ) ); + if( err != KErrNone ) + { + VCXLOGLO2( "CIptvIptvTestUtilALR:: could not get uncategorized IAPs. err: %d", err ); + cmarray.Reset(); + cmarray.Close(); + } + + VCXLOGLO2( "CIptvIptvTestUtilALR:: uncategorized IAP count: %d", cmarray.Count() ); + + for( TInt e = 0; e < cmarray.Count(); e++ ) + { + RCmConnectionMethodExt sourceMethod = iCmManager.ConnectionMethodL( cmarray[e] ); + CleanupClosePushL( sourceMethod ); + + HBufC* methodName = sourceMethod.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + + TInt iapId = sourceMethod.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + // Check for exact match. + if( MethodMatchesL( srcMethodName, *methodName, ETrue ) ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: exact match."); + foundExact = ETrue; + foundIapIndex = e; + } + + // No exact match found yet, check if its any of the alternative iaps. + if( !foundExact && MethodMatchesL( srcMethodName, *methodName, EFalse ) ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: alt match."); + found = ETrue; + foundIapIndex = e; + } + + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &sourceMethod ); + + // No need to search further. + if( foundExact ) + { + break; + } + } + + // Found IAP from uncategorized dest. + if( found || foundExact ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Creating copy of the method." ); + + RCmConnectionMethodExt sourceMethod = iCmManager.ConnectionMethodL( cmarray[foundIapIndex] ); + CleanupClosePushL( sourceMethod ); + + HBufC* sourceMethodName = sourceMethod.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( sourceMethodName ); + + RCmConnectionMethodExt newMethod = sourceMethod.CreateCopyL(); + VCXLOGLO1( "CIptvIptvTestUtilALR:: New Method ok." ); + CleanupClosePushL( newMethod ); + + // If method names are same rename source method because there can't be two with same name. + if( *sourceMethodName == aNewMethodName ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Method names are same, renaming source method." ); + HBufC* newName = HBufC::NewL( sourceMethodName->Length() + 5); + newName->Des().Append( *sourceMethodName ); + newName->Des().Append( _L("_old") ); + sourceMethod.SetStringAttributeL( CMManager::ECmName, *newName ); + delete newName; + sourceMethod.UpdateL(); + } + + // Set name for new method. + newMethod.SetStringAttributeL( CMManager::ECmName, aNewMethodName ); + // Disable dialog asking permission. + newMethod.SetIntAttributeL( CMManager::ECmSeamlessnessLevel, CMManager::ESeamlessnessShowprogress ); + + targetDestination.AddConnectionMethodL( newMethod ); + targetDestination.UpdateL(); + + CleanupStack::PopAndDestroy( &newMethod ); + CleanupStack::PopAndDestroy( sourceMethodName ); + CleanupStack::PopAndDestroy( &sourceMethod ); + } + + cmarray.Reset(); + cmarray.Close(); + } + + destIds.Reset(); + destIds.Close(); + + PrintDestinationL( targetDestination ); + CleanupStack::PopAndDestroy( &targetDestination ); + + if( !foundExact && !found ) + { + VCXLOGLO2( "CIptvIptvTestUtilALR:: source method %S not found!", &srcMethodName ); +#ifdef __WINSCW__ + VCXLOGLO1( "CIptvIptvTestUtilALR:: EMULATOR BUILD, check that iap is not uncategorized." ); +#endif + User::Leave(KErrNotFound); + } + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::DeleteMethodL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aMethodName: %S", &aMethodName ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TBool found( EFalse ); + + // Find method and delete it. + for(TInt e=0; e< destination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + if( methodName->Compare( aMethodName ) == 0 ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Match. Deleting." ); + found = ETrue; + destination.DeleteConnectionMethodL( method ); + destination.UpdateL(); + } + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + if(!found) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: method not found!"); + User::Leave(KErrNotFound); + } + + PrintDestinationL( destination ); + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::SetMethodPriorityL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aMethodName: %S", &aMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aPriority: %d", aPriority ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TBool found( EFalse ); + + if( aPriority > destination.ConnectionMethodCount() ) + { + VCXLOGLO2( "CIptvIptvTestUtilALR:: Priority must be less than there's methods in the destination, count: %d!", destination.ConnectionMethodCount() ); + User::Leave( KErrCorrupt ); + } + + // No need to set priority here. + if( destination.ConnectionMethodCount() <= 1 ) + { + CleanupStack::PopAndDestroy( &destination ); + VCXLOGLO1("<<Compare( aMethodName ) == 0 ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Match. Setting priority." ); + found = ETrue; + destination.ModifyPriorityL( method, aPriority ); + destination.UpdateL(); + } + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + if(!found) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: method not found!"); + User::Leave(KErrNotFound); + } + + PrintDestinationL( destination ); + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::SetMethodStringAttributeL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aMethodName: %S", &aMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttribute: %d", aAttribute ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttributeValue: %S", &aAttributeValue ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TBool found( EFalse ); + + // Find the method and set attribute + for(TInt e=0; e < destination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + if( MethodMatchesL( aMethodName, *methodName, EFalse ) ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Match. Setting attribute." ); + found = ETrue; + + method.SetStringAttributeL( aAttribute, aAttributeValue ); + method.UpdateL(); + } + + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + if(!found) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: method not found!"); + User::Leave(KErrNotFound); + } + + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::SetMethodIntAttributeL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aMethodName: %S", &aMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttribute: %d", aAttribute ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttributeValue: %d", aAttributeValue ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TBool found( EFalse ); + + // Find the method and set attribute + for(TInt e=0; e < destination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + if( MethodMatchesL( aMethodName, *methodName, EFalse ) ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Match. Setting attribute." ); + found = ETrue; + + method.SetIntAttributeL( aAttribute, aAttributeValue ); + method.UpdateL(); + } + + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + if(!found) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: method not found!"); + User::Leave(KErrNotFound); + } + + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::SetMethodBoolAttributeL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aMethodName: %S", &aMethodName ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttribute: %d", aAttribute ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: aAttributeValue: %d", &aAttributeValue ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + TBool found = EFalse; + + // Find the method and set attribute + for(TInt e=0; e < destination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + if( MethodMatchesL( aMethodName, *methodName, EFalse ) ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: Match. Setting attribute." ); + found = ETrue; + + method.SetBoolAttributeL( aAttribute, aAttributeValue ); + method.UpdateL(); + } + + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + if(!found) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: method not found!"); + User::Leave(KErrNotFound); + } + + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::GetDestinationIdL"); + + VCXLOGLO2("CIptvIptvTestUtilALR:: dest name: '%S'", &aDestinationName); + + RArray destIds(5); + + iCmManager.AllDestinationsL( destIds ); + VCXLOGLO2( "CIptvIptvTestUtilALR:: dest Count: %d", destIds.Count() ); + + TInt foundDestId(0); + + for(TInt i=0; iCompare( aDestinationName ) == 0 ) + { + foundDestId = destIds[i]; + VCXLOGLO2( "CIptvIptvTestUtilALR:: found destination id: %d", destIds[i] ); + CleanupStack::PopAndDestroy( name ); + CleanupStack::PopAndDestroy( &dest ); + break; + } + else + { + CleanupStack::PopAndDestroy( name ); + CleanupStack::PopAndDestroy( &dest ); + } + } + + if( foundDestId == 0 ) + { + VCXLOGLO1( "CIptvIptvTestUtilALR:: destination not found!"); + User::Leave( KErrNotFound ); + } + + destIds.Reset(); + destIds.Close(); + + VCXLOGLO1("<<>>CIptvIptvTestUtilALR::TerminateDestinationConnectionsL"); + + VCXLOGLO2( "CIptvIptvTestUtilALR:: aDestinationName: %S", &aDestinationName ); + + TInt destId = GetDestinationIdL( aDestinationName ); + RCmDestinationExt destination = iCmManager.DestinationL( destId ); + CleanupClosePushL( destination ); + + // Check if there's active connections for the methods + for(TInt e=0; e < destination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = destination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO3( "CIptvIptvTestUtilALR:: method: '%S', id: %d", methodName, iapId ); + + CTestUtilConnectionWaiter* connectionWaiter = CTestUtilConnectionWaiter::NewL( this ); + CleanupStack::PushL( connectionWaiter ); + + // Terminate active connection + if( connectionWaiter->IsConnectionActive( iapId ) ) + { + CTestUtilConnection* connectionUtil = CTestUtilConnection::NewL( this ); + CleanupStack::PushL( connectionUtil ); + connectionUtil->SetConnectionPreferences( KCommDbBearerUnknown, iapId ); + connectionUtil->AttachL(); + + connectionUtil->TerminateConnectionL(); + connectionWaiter->WaitUntilConnectionIsClosed( iapId ); + iActiveWait->Start(); + + CleanupStack::PopAndDestroy( connectionUtil ); + } + CleanupStack::PopAndDestroy( connectionWaiter ); + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + CleanupStack::PopAndDestroy( &destination ); + + VCXLOGLO1("<<>>CIptvTestUtilALR::GetDefaultIap"); + RSocketServ ss; + ss.Connect(); + + RConnection conn; + conn.Open( ss ); + + TCommDbConnPref prefs; + prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + + conn.Start( prefs ); + TUint32 iap( 0 ); + conn.GetIntSetting( _L("IAP\\Id"), iap ); + conn.Close(); + + VCXLOGLO2("<<Set( VCXTEST_KIptvCenRepDefaultIapIdKey, (TInt)iap ) ); + CleanupStack::PopAndDestroy( cenRep ); + } + else + { + err = KErrNotFound; + } + + return err; + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::GetDefaultIap +// --------------------------------------------------------------------------- +// +EXPORT_C TUint32 CIptvTestUtilALR::GetDefaultIapCenRep() + { + TInt iap( 0 ); + + VCXLOGLO1("CIptvTestUtilALR::GetDefaultIapCenRep Create cenrep."); + CRepository* cenRep = CRepository::NewLC( VCXTEST_KIptvAlrCenRepUid ); + VCXLOGLO1("CIptvTestUtilALR::GetDefaultIapCenRep Set cenrep."); + User::LeaveIfError( cenRep->Get( VCXTEST_KIptvCenRepDefaultIapIdKey, iap) ); + CleanupStack::PopAndDestroy( cenRep ); + + TUint32 iapId( iap ); + + return iapId; + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::PrintDestinationL +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::PrintDestinationL( RCmDestinationExt& aDestination ) + { + HBufC* destName = aDestination.NameLC(); + + TPtr destNamePtr = destName->Des(); + VCXLOGLO2( "CIptvIptvTestUtilALR:: Destination: %S", &destNamePtr ); + + for(TInt e=0; e < aDestination.ConnectionMethodCount(); e++) + { + RCmConnectionMethodExt method = aDestination.ConnectionMethodL( e ); + CleanupClosePushL( method ); + + HBufC* methodName = method.GetStringAttributeL( CMManager::ECmName ); + CleanupStack::PushL( methodName ); + + TUint priority = aDestination.PriorityL( method ); + TInt iapId = method.GetIntAttributeL( CMManager::ECmIapId ); + VCXLOGLO4( "CIptvIptvTestUtilALR:: Method: %S, priority: %d, id: %d", methodName, priority, iapId ); + + CleanupStack::PopAndDestroy( methodName ); + CleanupStack::PopAndDestroy( &method ); + } + + CleanupStack::PopAndDestroy( destName ); + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::MethodMatchesL +// --------------------------------------------------------------------------- +// +TBool CIptvTestUtilALR::MethodMatchesL( const TDesC& aSearchedName, const TDesC& aCurrentName, TBool aStrict ) + { +#ifdef __WINSCW__ + if( aSearchedName.Compare( _L("Ethernet with Daemon Dynamic IP") ) == 0 ) + { + return ETrue; + } +#endif + + if( aSearchedName.Compare( aCurrentName ) == 0 ) + { + return ETrue; + } + + if( aStrict) + { + return EFalse; + } + + if( aSearchedName.Compare( _L("Internet") ) == 0 || aSearchedName.Compare( _L("Internet2") ) == 0 ) + { + TBuf<256> temp( aCurrentName ); + temp.LowerCase(); + + _LIT(KIapElisaInternet, "elisa internet"); + _LIT(KIapDnaGPRS, "dna gprs"); + _LIT(KIapSoneraGPRS, "sonera gprs"); + _LIT(KIapRLGPRS, "rl gprs"); + _LIT(KIapInternet, "internet"); + _LIT(KIapProinternet, "prointernet"); + _LIT(KGprsInternet, "gprs internet"); + + if( temp.Compare( KIapElisaInternet ) == KErrNone ) return ETrue; + if( temp.Compare( KIapDnaGPRS ) == KErrNone ) return ETrue; + if( temp.Compare( KIapRLGPRS ) == KErrNone ) return ETrue; + if( temp.Compare( KIapInternet ) == KErrNone ) return ETrue; + if( temp.Compare( KIapProinternet ) == KErrNone ) return ETrue; + if( temp.Compare( KGprsInternet ) == KErrNone ) return ETrue; + if( temp.Compare( KIapSoneraGPRS ) == KErrNone ) return ETrue; + } + + return EFalse; + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::ConnectionCreated +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::ConnectionCreated() + { + iActiveWait->Stop(); + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::ConnectionClosed +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::ConnectionClosed() + { + iActiveWait->Stop(); + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::ConnectionFailed +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::ConnectionFailed() + { + iActiveWait->Stop(); + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::ConnectionAlreadyExists +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::ConnectionAlreadyExists() + { + iActiveWait->Stop(); + } + +// --------------------------------------------------------------------------- +// CIptvTestUtilALR::ConnectionTimeout +// --------------------------------------------------------------------------- +// +void CIptvTestUtilALR::ConnectionTimeout() + { + iActiveWait->Stop(); + } + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/TestUtilConnection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/TestUtilConnection.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES + +#include "TestUtilConnection.h" + +#include "VCXTestLog.h" +#include "MTestUtilConnectionObserver.h" +#include + +// ========================== MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CTestUtilConnection::NewL() +// +// Constructs CTestUtilConnection object +// --------------------------------------------------------------------------- +// +EXPORT_C CTestUtilConnection* CTestUtilConnection::NewL(MTestUtilConnectionObserver* aObserver) + { + VCXLOGLO1(">>>CIptvTestUtilConnection::NewL"); + CTestUtilConnection* self = NewLC(aObserver); + CleanupStack::Pop(self); + VCXLOGLO1("<<>>CIptvTestUtilConnection::NewLC"); + CTestUtilConnection* self = new (ELeave) CTestUtilConnection(aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + VCXLOGLO1("<<>>CIptvTestUtilConnection::CIptvTestUtilConnection"); + SetConnectionPreferences(ECommDbBearerUnknown, 0); + VCXLOGLO1("<<>>CIptvTestUtilConnection::~CIptvTestUtilConnection"); + Cancel(); + + iConnect.Close(); + iSocketServ.Close(); + +// iTimer.Cancel(); +// iTimer.Close(); + + if( IsAdded() ) + { + Deque(); // calls also Cancel() + } + + VCXLOGLO1("<<>>CIptvTestUtilConnection::ConstructL"); + + iSocketServ.Connect(); + iConnect.Open(iSocketServ); + +// User::LeaveIfError(iTimer.CreateLocal()); + + CActiveScheduler::Add(this); + + VCXLOGLO1("<<>>CIptvTestUtilConnection::ConnectL"); + + if(iConnectionState == CTestUtilConnection::EConnected) + { + VCXLOGLO1(">>>CIptvTestUtilConnection:: Already connected"); + return; + } + + if (!IsActive()) + { + iConnect.Start(iPref, iStatus); + iConnectionState = CTestUtilConnection::EConnecting; + + //if the line below panics it's either because you made a request but you haven't + //SetActive the object (pR->iStatus.iFlags&TRequestStatus::EActive==0) or you didn't set the iStatus + //to KRequestPending (pR->iStatus.iFlags&TRequestStatus::ERequestPending==0) +// iTimerStatus = KRequestPending; +// iTimer.After(iTimerStatus, KTimeout); + + SetActive(); + VCXLOGLO1(">>>CIptvTestUtilConnection:: Connecting"); + } + else + { + //globalNote->ShowNoteL(EAknGlobalInformationNote, KTextNotReady); + } + VCXLOGLO1("<<>>CIptvTestUtilConnection::AttachL"); + + if(iConnectionState == CTestUtilConnection::EConnected) + { + VCXLOGLO1(">>>CIptvTestUtilConnection:: Already connected"); + VCXLOGLO1("<< infoPckg(info); + + TInt found = EFalse; + for(TInt i=1;i<=activeConnections;i++) + { + + User::LeaveIfError(iConnect.GetConnectionInfo(i, infoPckg)); + + VCXLOGLO3("CIptvTestUtilConnection:: %d vs %d.", iPref.IapId(), info.iIapId); + + if(info.iIapId == iPref.IapId()) + { + found = ETrue; + break; + } + + } + if(!found) + { + VCXLOGLO1(">>>CIptvTestUtilConnection:: No connection found to that AP."); + VCXLOGLO1("<<>>CIptvTestUtilConnection::RunL"); + + /*if(iTimerStatus.Int() == KErrNone) + { + VCXLOGLO1("CTestUtilConnection:: Connection timeout."); + iObserver->ConnectionTimeout(); + iTimer.Cancel(); + } + */ + TInt statusCode = iStatus.Int(); + + switch (statusCode) + { + case KErrNone: // Connection created succesfully + { + //PrintNoteL(KTextConnectionCreated); + VCXLOGLO1("CTestUtilConnection:: Connection created."); + iConnectionState = CTestUtilConnection::EConnected; +// iTimer.Cancel(); + iObserver->ConnectionCreated(); + break; + } + + case KErrNotFound: // Connection failed + { + //PrintNoteL(KTextGeneralError); + VCXLOGLO1("CTestUtilConnection:: Connection failed."); + iConnectionState = CTestUtilConnection::EFailed; + //iTimer.Cancel(); + iObserver->ConnectionFailed(); + break; + } + + case KErrCancel: // Connection attempt cancelled + { + //PrintNoteL(KTextConnectionCancelled); + VCXLOGLO1("CTestUtilConnection:: Connection attemption canceled."); + iConnectionState = CTestUtilConnection::EFailed; +// iTimer.Cancel(); + iObserver->ConnectionFailed(); + break; + } + + case KErrAlreadyExists: // Connection already exists + { + //PrintNoteL(KTextConnectionExists); + VCXLOGLO1("CTestUtilConnection:: Connection already exists."); + iConnectionState = CTestUtilConnection::EFailed; +// iTimer.Cancel(); + iObserver->ConnectionAlreadyExists(); + break; + } + + default: + { + //TBuf errorText; + // Use text resolver to resolve error text + //errorText = iTextResolver->ResolveError(statusCode); + //PrintErrorL(errorText, statusCode); + VCXLOGLO2("CTestUtilConnection:: Unknown error: %d", statusCode); + iConnectionState = CTestUtilConnection::EFailed; +// iTimer.Cancel(); + iObserver->ConnectionFailed(); + break; + } + } + + VCXLOGLO1("<<>>CIptvTestUtilConnection::DoCancel"); + VCXLOGLO1("<<>>CIptvTestUtilConnection::TermínateConnectionL"); + +/* + if (iProgressNotifier->GetState() == EIAPConnectStateConnected) + { + // Show confirmation dialog first + if (ShowQueryDialogL()) + { + // RConnection::Stop() terminates connection by stopping whole + // network interface even if there are other clients using + // the connection. It is not recommended to use it unless it is + // really meaningful. + User::LeaveIfError(iConnect.Stop()); + + } + } + else + { + PrintNoteL(KTextNotConnected); + } + */ + User::LeaveIfError(iConnect.Stop()); + VCXLOGLO1("<<>>CIptvTestUtilConnection::SetConnectionPreferences"); + iPref.SetDirection(ECommDbConnectionDirectionOutgoing); + iPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); + iPref.SetIapId(aIapId); + iPref.SetBearerSet(aBearer); + iPref.SetDirection(ECommDbConnectionDirectionOutgoing); + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::NewL"); + CTestUtilConnectionWaiter* self = NewLC(aObserver); + CleanupStack::Pop(self); + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::NewLC"); + CTestUtilConnectionWaiter* self = new (ELeave) CTestUtilConnectionWaiter(aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::CTestUtilConnectionWaiter"); + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::~CTestUtilConnectionWaiter"); + + if( IsAdded() ) + { + Deque(); // calls also Cancel() + } + + iServ.Close(); + + iTimer.Close(); + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::ConstructL"); + + // get connection for the iap + + TInt err = iServ.Connect(); + if(err != KErrNone) + { + VCXLOGLO2("Could not connect to socket server, %d.", err); + User::Leave(err); + } + + User::LeaveIfError(iTimer.CreateLocal()); + + CActiveScheduler::Add(this); + + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::WaitForConnection"); + + if (!IsActive()) + { + iWaitState = EWaitingConnection; + + iIapId = aIapId; + iTimer.After(iStatus, KMillion); + SetActive(); + iCheckCount = 0; + + VCXLOGLO2(">>>CTestUtilConnectionWaiter:: Waiting until connection is created for Iap: %d", aIapId); + } + else + { + VCXLOGLO1(">>>CTestUtilConnectionWaiter:: error - already ACTIVE"); + } + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::WaitUntilConnectionIsClosed"); + + if (!IsActive()) + { + iWaitState = EWaitingConnectionClosed; + + iIapId = aIapId; + iTimer.After(iStatus, KMillion); + SetActive(); + iCheckCount = 0; + + VCXLOGLO2(">>>CTestUtilConnectionWaiter:: Waiting until connection closed for Iap: %d", aIapId); + } + else + { + VCXLOGLO1(">>>CTestUtilConnectionWaiter:: error - already ACTIVE"); + } + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::RunL"); + +// TInt statusCode = iStatus.Int(); + + if( iCheckCount++ == 30 ) + { + VCXLOGLO1("CTestUtilConnectionWaiter:: Connection request timed out."); + iObserver->ConnectionTimeout(); + iCheckCount = 0; + Cancel(); + } + else + { + switch(iWaitState) + { + case EWaitingConnection: + { + if(IsConnectionActive(iIapId)) + { + iObserver->ConnectionCreated(); + iWaitState = ENoWaitState; + VCXLOGLO1("Connection is active!"); + } + else + { + SetActive(); + iTimer.After(iStatus, KMillion); + } + } + break; + + case EWaitingConnectionClosed: + { + if(!IsConnectionActive(iIapId)) + { + iObserver->ConnectionClosed(); + iWaitState = ENoWaitState; + VCXLOGLO1("Connection is closed!"); + } + else + { + SetActive(); + iTimer.After(iStatus, KMillion); + } + } + break; + + default: + break; + } + } + + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::DoCancel"); + iTimer.Cancel(); + VCXLOGLO1("<<>>CTestUtilConnectionWaiter::IsConnectionActive"); + + RConnection connection; + + TUint count; + + TInt err = connection.Open(iServ, KAfInet); + + if(err != KErrNone) + { + iServ.Close(); + VCXLOGLO2("CTestUtilConnectionWaiter::Could not connect to open connection: %d.", err); + User::Leave(err); + } + + err = connection.EnumerateConnections(count); + if(err != KErrNone) + { + connection.Close(); + iServ.Close(); + VCXLOGLO2("CTestUtilConnectionWaiter::Could not enum connections, %d.", err); + User::Leave(err); + } + + for(; count; --count) + { + TPckgBuf connInfo; + + if(connection.GetConnectionInfo(count, connInfo) == KErrNone) + { + VCXLOGLO2("CTestUtilConnectionWaiter:: Connection IAP id: %d", connInfo().iIapId); + + if(aIapId == connInfo().iIapId) + { + VCXLOGLO1("CTestUtilConnectionWaiter:: IAP is connected."); + VCXLOGLO1("<< +#include +#include +#include +#include + +#include "VCXTestCommon.h" +#include "IptvTestUtilALR.h" +#include "CIptvTestVerifyData.h" +#include "TestUtilConnectionWaiter.h" +#include "VCXTestLog.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS + +// MACROS + +// LOCAL CONSTANTS AND MACROS +_LIT(KDummyfilePathFormat, "%S:\\data\\temp"); +_LIT(KDummyfileFormat, "%d.dat"); +_LIT(KDoubleBacklash, "\\"); + +// MODULE DATA STRUCTURES + +// LOCAL FUNCTION PROTOTYPES + +// FORWARD DECLARATIONS + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::CVCXTestCommon +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVCXTestCommon::CVCXTestCommon() + { + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CVCXTestCommon::ConstructL() + { + VCXLOGLO1(">>>CVCXTestCommon::ConstructL"); + + User::LeaveIfError( iFs.Connect() ); + + PrintIaps(); + + PrintDriveInfo( _L("C") ); + PrintDriveInfo( _L("E") ); + PrintDriveInfo( _L("D") ); + PrintDriveInfo( _L("F") ); + + //ListDir( _L("C:\\"), 0 ); + //ListDir( _L("E:\\"), 0 ); + + iIptvVerifyData = CIptvTestVerifyData::NewL(); + iVideoCreator = CIptvTestVideoCreator::NewL(); + + VCXLOGLO1("<<>>CVCXTestCommon::~CVCXTestCommon"); + + delete iIptvVerifyData; + iIptvVerifyData = NULL; + + delete iVideoCreator; + iVideoCreator = NULL; + + iFs.Close(); + + VCXLOGLO1("<<>>CVCXTestCommon::NewL"); + CVCXTestCommon* self = new( ELeave ) CVCXTestCommon; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CVCXTestCommon::GetFileSize"); + TBool rv = FALSE; + TEntry entry; + TInt err = KErrNone; + + aFileSize=0; + + err = iFs.Entry( aFullPath, entry ); + + if(KErrNone == err && !entry.IsDir()) + { + aFileSize = entry.iSize; + rv = TRUE; + } + + VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdL"); + + TBool found( EFalse ); + +#ifdef __WINSCW__ + if( aIapName != KIptvTestBadIapName && aIapName != _L("invalidiap") ) + { + _LIT(KEmulatorIap, "Ethernet with Daemon Dynamic IP"); + found = GetIapIdByNameL(KEmulatorIap, aIapId); + VCXLOGLO1("<<GetDefaultIapCenRep(); + CleanupStack::PopAndDestroy( util ); + if( aIapId != 0 ) + { + VCXLOGLO2("CVCXTestCommon::GetIapIdL -- Got default from cenrep: %d", aIapId); + return ETrue; + } + } + + if( aIapName == _L("default") ) + { + VCXLOGLO1("CVCXTestCommon::GetIapIdL -- Getting default iap via ALR util"); + CIptvTestUtilALR* util = CIptvTestUtilALR::NewLC(); + aIapId = util->GetDefaultIap(); + CleanupStack::PopAndDestroy( util ); + if( aIapId != 0 ) + { + VCXLOGLO2("CVCXTestCommon::GetIapIdL -- Got default: %d", aIapId); + return ETrue; + } + } + + VCXLOGLO2("CVCXTestCommon:: Searching IAP: %S", &aIapName); + + found = GetIapIdByNameL(aIapName, aIapId); + + // Iap with exact name found + if( found ) + { + VCXLOGLO1("<< searchFor(aIapName); + searchFor.LowerCase(); + + if(searchFor == _L("invalidiap") ) + { + aIapId = 6000; + VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdByNameL"); + TBool found = EFalse; + aIapId = 0; + + TBuf<128> searchFor(aIapName); + searchFor.LowerCase(); + + // Get IAP names and ids from the database + CCommsDatabase* cdb( NULL ); + TRAPD( err, cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::NewL left: %d, leaving", err); + User::Leave( err ); + } + CleanupStack::PushL( cdb ); + + cdb->ShowHiddenRecords(); + + CCommsDbTableView* view( NULL ); + TRAP( err, view = cdb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); + CleanupStack::PushL( view ); + + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::OpenTableLC left: %d, leaving", err); + User::Leave( err ); + } + + TBuf<40> name; + TUint32 id; + TInt res = view->GotoFirstRecord(); + while( res == KErrNone ) + { + TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); + if( err != KErrNone ) continue; + TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); + if( err != KErrNone ) continue; + + name.LowerCase(); + if(searchFor == name) + { + aIapId = id; + VCXLOGLO3("CVCXTestCommon:: Found IAP: %d, %S", aIapId, &aIapName); + found = ETrue; + break; + } + res = view->GotoNextRecord(); + } + + CleanupStack::PopAndDestroy( view ); + CleanupStack::PopAndDestroy( cdb ); + + VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdByTypeL"); + + aIapId = 0; + TBool found( EFalse ); + + #ifdef __WINSCW__ + found = GetIapIdByNameL( _L("Ethernet with Daemon Dynamic IP"), aIapId ); + VCXLOGLO1("<<ShowHiddenRecords(); + + CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); + + TBuf<40> name; + TUint32 id; + TBuf<255> iapType; + TInt matchCount(0); + + TInt res = view->GotoFirstRecord(); + + while( res == KErrNone ) + { + view->ReadTextL( TPtrC(COMMDB_NAME), name ); + view->ReadUintL( TPtrC(COMMDB_ID), id ); + view->ReadTextL( TPtrC(IAP_SERVICE_TYPE), iapType); + + VCXLOGLO3("CVCXTestCommon:: name: %S, id: %d", &name, id); + VCXLOGLO2("CVCXTestCommon:: type: %S", &iapType); + + if( ( iapType == _L("LANService") && aType == EWlanIap && name != _L("Easy WLAN") ) || + ( iapType == _L("OutgoingGPRS") && aType == EGprsIap ) ) + { + if( matchCount == aOrderNumber ) + { + found = ETrue; + aIapId = id; + break; + } + matchCount++; + } + + res = view->GotoNextRecord(); + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + + VCXLOGLO1("<<ShowHiddenRecords(); + + CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); + + TBuf<40> name; + TUint32 id; + TInt res = view->GotoFirstRecord(); + + while( res == KErrNone ) + { + view->ReadTextL( TPtrC(COMMDB_NAME), name ); + view->ReadUintL( TPtrC(COMMDB_ID), id ); + + res = view->GotoNextRecord(); + //VCXLOGLO3("IAP name, id: %S, %d", &name, id); + if(id == aIapId) + { + found = TRUE; + aIapName.Zero(); + aIapName.Append(name); + break; + } + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + + return found; + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::PrintIaps +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestCommon::PrintIaps() + { + VCXLOGLO1(">>>CVCXTestCommon::PrintIaps"); + // Get IAP names and ids from the database + CCommsDatabase* TheDb( NULL ); + TRAPD( err, TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); + + if( err == KErrNone && TheDb ) + { + CleanupStack::PushL( TheDb ); + + TheDb->ShowHiddenRecords(); + + CCommsDbTableView* view( NULL ); + TRAP( err, view = TheDb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); + CleanupStack::PushL( view ); + + if( err == KErrNone && view ) + { + TBuf<40> name; + TUint32 id; + err = view->GotoFirstRecord(); + while( err == KErrNone ) + { + TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); + if( err != KErrNone ) break; + TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); + if( err != KErrNone ) break; + VCXLOGLO3("CVCXTestCommon:: IAP name, id: %S, %d", &name, id); + + err = view->GotoNextRecord(); + if( err != KErrNone ) break; + } + } + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + } + VCXLOGLO1("<<>>CVCXTestCommon::CreateVerifyData: %S", &aVerifyId); + TInt result = KErrNone; + TRAPD(err, result = iIptvVerifyData->CreateVerifyDataL(aVerifyId, aAppend)); + if(err != KErrNone) + { + VCXLOGLO2("CIptvVerifyData::CreateVerifyDataL caused a leave. %d", err); + result = err; + } + VCXLOGLO1("<<>>CVCXTestCommon::WriteVerifyData"); + TInt result = KErrNone; + TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, aVerifyData)); + if(err != KErrNone) + { + VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); + result = err; + } + //VCXLOGLO1("<< aFmt, ... ) + { + //VCXLOGLO1(">>>CVCXTestCommon::WriteVerifyData(formatted)"); + + VA_LIST argptr; //pointer to argument list + VA_START( argptr, aFmt ); + + HBufC* str; + str = HBufC::NewLC(1024*3); + + //TBuf<512*3> str; + //TBuf<512> format(_L("TESTI: %d, %S")); + + str->Des().FormatList(aFmt, argptr); + + TInt result = KErrNone; + TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, *str)); + + CleanupStack::PopAndDestroy(str); + + if(err != KErrNone) + { + VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); + result = err; + } + + //VCXLOGLO1("<<>>CVCXTestCommon::VerifyData"); + TInt result = KErrNone; + TRAPD(err, result = iIptvVerifyData->VerifyDataL(aVerifyId, aVerifyResult)); + if(err != KErrNone) + { + VCXLOGLO2("CIptvVerifyData::VerifyDataL caused a leave. %d", err); + result = err; + } + VCXLOGLO1("<<>>CVCXTestCommon::EnableVerifyTimestamps"); + iIptvVerifyData->EnableTimestamps( aUseTimestamps ); + VCXLOGLO1("<<>>CVCXTestCommon::ParseIntFromString"); + + TLex lex(aString); + TInt err = lex.Val(aInt); + + VCXLOGLO1("<<>>CVCXTestCommon::CreateBadIapL"); + CCommsDatabase* cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ); + CleanupStack::PushL( cdb ); + + TBuf16<40> name; + name.Copy( aName ); + + TUint32 iapId( 0 ); + TUint32 iapServiceId( 1 ); + TUint32 id( 2 ); + TUint32 iapNetworkId( 3 ); + TUint32 weighting( 4 ); + TUint32 loc( 5 ); + + User::LeaveIfError( cdb->BeginTransaction() ); + + CCommsDbTableView* iapTable = cdb->OpenTableLC( TPtrC( IAP ) ); + + User::LeaveIfError( iapTable->InsertRecord( iapId ) ); + + iapTable->WriteTextL( TPtrC( COMMDB_NAME ), name ); + iapTable->WriteUintL( TPtrC( IAP_SERVICE ), iapServiceId ); + iapTable->WriteTextL( TPtrC( IAP_SERVICE_TYPE ), TPtrC( LAN_SERVICE ) ); + iapTable->WriteTextL( TPtrC( IAP_BEARER_TYPE ), TPtrC( LAN_BEARER ) ); + iapTable->WriteUintL( TPtrC( IAP_BEARER ), id ); + iapTable->WriteUintL( TPtrC( IAP_NETWORK ), iapNetworkId ); + iapTable->WriteUintL( TPtrC( IAP_NETWORK_WEIGHTING ), weighting ); + iapTable->WriteUintL( TPtrC( IAP_LOCATION ), loc ); + + User::LeaveIfError( iapTable->PutRecordChanges( EFalse, EFalse ) ); + + CleanupStack::PopAndDestroy( iapTable ); + + User::LeaveIfError( cdb->CommitTransaction() ); + + CleanupStack::PopAndDestroy( cdb ); + VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeSeconds"); + + TTime now; + now.HomeTime(); + + TTimeIntervalSeconds second(1*aCount); + now += second; + + TInt err = CVCXTestCommon::SetSystemTime(now); + + VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeMinutes"); + + TTime now; + now.HomeTime(); + + TTimeIntervalSeconds minute(1*60*aCount); + now += minute; + + TInt err = CVCXTestCommon::SetSystemTime(now); + + VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeHours"); + + TTime now; + now.HomeTime(); + + TTimeIntervalSeconds hour(1*60*60*aCount); + now += hour; + + TInt err = CVCXTestCommon::SetSystemTime(now); + + VCXLOGLO1("<<>>CVCXTestCommon::SetSystemTime"); + + TTime noDST(aTime); + RTz tz; + TInt err = tz.Connect(); + if(err != KErrNone) + { + VCXLOGLO2("RTz::Connect failed: %d", err); + VCXLOGLO1("<<>>CVCXTestCommon::SetTimeZone"); + + RTz tz; + TInt err = tz.Connect(); + if(err != KErrNone) + { + VCXLOGLO2("RTz::Connect failed: %d", err); + VCXLOGLO1("<< timezone; + timezone.Copy( aTimeZone ); // Conversion + + CTzId* tzId = CTzId::NewL( timezone ); + CleanupStack::PushL(tzId); + + TRAP(err, tz.SetTimeZoneL( *tzId ) ); + CleanupStack::PopAndDestroy(tzId); + CleanupStack::PopAndDestroy(&tz); + + if(err != KErrNone) + { + VCXLOGLO2("RTz::SetTimeZone failed: %d", err); + VCXLOGLO1("<<>>CVCXTestCommon::CreateVideoFileL"); + iVideoCreator->CreateVideoL( aVideoType, aFileName, aSize ); + VCXLOGLO1("<<& aFileArray ) + { + VCXLOGLO1(">>>CVCXTestCommon::CreateVideoFilesL"); + iVideoCreator->CreateVideosL( aVideoType, aFileName, aCount, aFileArray ); + VCXLOGLO1("<<>>CVCXTestCommon::SetDriveFreeSpaceL"); + + const TInt KIptvTest1KB = 1024; + const TInt KIptvTest1MB = KIptvTest1KB*KIptvTest1KB; + +#ifdef __WINSCW__ + if(aDriveNumber == EDriveC) + { + VCXLOGLO1("CVCXTestCommon:: ABORT! No C drive fill in emulator."); + User::Leave( KErrAbort ); + } +#endif + + TChar driveLetter; + User::LeaveIfError( RFs::DriveToChar( aDriveNumber, driveLetter ) ); + + TBuf<255> path; + path.Append( driveLetter ); + path.Append( _L(":\\data\\temp") ); + path.Append( KDoubleBacklash ); + + // First check that if there's free space to fill. + + TInt64 spaceToReserve = 0; + CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); + + if( spaceToReserve == 0 ) + { + VCXLOGLO1("<<0; i-- ) + { + TBuf<256> filePath; + filePath.Zero(); + filePath.Append( path ); + filePath.AppendFormat( KDummyfileFormat, i ); + if( BaflUtils::FileExists( iFs, filePath ) ) + { + VCXLOGLO2("CVCXTestCommon:: Deleting %S.", &filePath); + iFs.Delete( filePath ); + CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); + + // Is there's enough free space now. + if( spaceToReserve > 0 ) + { + break; + } + } + } + + // Recheck free space. + if( spaceToReserve < 0 ) + { + VCXLOGLO1("CVCXTestCommon:: Error! There's already less than wanted space!"); + User::Leave( KErrAbort ); + } + } + + BaflUtils::EnsurePathExistsL(iFs, path); + + // Start creating files of 256 MB size. + TInt64 dummyFileSize = 256 * KIptvTest1MB; + + TInt count = 0; + while( ETrue ) + { + // Check that there's still enough free space for the dummyfile + CalculateSpaceToReserveL( iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve ); + + if( spaceToReserve <= 0 ) + { + VCXLOGLO1("CVCXTestCommon:: Nothing to reserve anymore."); + break; + } + + // Fill all at once if less than 1MB to go. + if( spaceToReserve < KIptvTest1MB ) + { + dummyFileSize = spaceToReserve; + } + + // Not enough space for dummy file, find smaller size. + while( dummyFileSize > spaceToReserve ) + { + dummyFileSize /= 2; + } + + // Find free filename. + TBuf<256> filePath; + do + { + filePath.Zero(); + filePath.Append( path ); + count++; + filePath.AppendFormat(KDummyfileFormat, count); + } + while ( BaflUtils::FileExists( iFs, filePath ) ); + + VCXLOGLO3("Creating %Ld b file to '%S'", dummyFileSize, &filePath); + + // Create the file. + RFile file; + TInt err = file.Replace(iFs, filePath, EFileWrite); + if(err != KErrNone) + { + VCXLOGLO2("file.Replace fail: %d", err); + } + User::LeaveIfError(err); + err = file.SetSize( dummyFileSize ); + if(err != KErrNone) + { + VCXLOGLO2("file.SetSize fail: %d", err); + } + User::LeaveIfError(err); + file.Close(); + + TVolumeInfo volumeInfo; + User::LeaveIfError(iFs.Volume(volumeInfo, aDriveNumber)); + VCXLOGLO2("Free space after: %Ld b", volumeInfo.iFree); + } + + VCXLOGLO1("<<>>CVCXTestCommon::DeleteDummyFilesL"); + + CFileMan* fileMan = CFileMan::NewL(iFs); + CleanupStack::PushL(fileMan); + + TBuf<3> driveLetter; + TChar driveChar; + RFs::DriveToChar( aDriveNumber, driveChar ); + driveLetter.Append(driveChar); + + TBuf<255>path; + + path.Format( KDummyfilePathFormat, &driveLetter ); + path.Append(KDoubleBacklash); + fileMan->RmDir(path); + + CleanupStack::PopAndDestroy(fileMan); + + VCXLOGLO1("<< 0 && iFs.CharToDrive( aDriveLetter[0], driveNumber ) == KErrNone ) + { + TVolumeInfo volumeInfo; + if( iFs.Volume(volumeInfo, driveNumber) == KErrNone ) + { + driveSize = volumeInfo.iSize / 1024 / 1024; + driveFreeSpace = volumeInfo.iFree / 1024 / 1024; + VCXLOGLO2("CVCXTestCommon:: drive: %S", &aDriveLetter ); + VCXLOGLO2("CVCXTestCommon:: - size: %d MB", driveSize); + VCXLOGLO2("CVCXTestCommon:: - free: %d MB", driveFreeSpace); + } + } + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::ListDir +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestCommon::ListDir( const TDesC& aDir, TInt aLevel ) + { + CDir* fileList = NULL; + CDir* dirList = NULL; + + if( aLevel == 0 ) + { + VCXLOGLO2("CVCXTestCommon:: Listing directory %S", &aDir); + } + + TInt err( KErrNone ); + err = iFs.GetDir( aDir, KEntryAttMatchExclusive | KEntryAttDir, ESortByName, dirList ); + if( err == KErrNone ) + { + err = iFs.GetDir( aDir, KEntryAttMatchExclude | KEntryAttDir, ESortByName, fileList ); + } + + CleanupStack::PushL( dirList ); + CleanupStack::PushL( fileList ); + + HBufC* pre = HBufC::NewL( 256 ); + CleanupStack::PushL( pre ); + + for( TInt i=0; iDes().Append( _L(" ") ); + } + + if( err == KErrNone ) + { + HBufC* fileName = HBufC::NewL( 256 ); + CleanupStack::PushL( fileName ); + + if( dirList ) + for ( TInt file = 0; file < dirList->Count(); file++ ) + { + fileName->Des().Zero(); + fileName->Des().Append( aDir ); + fileName->Des().Append( (*dirList)[file].iName ); + VCXLOGLO3("%S (d) %S", pre, fileName); + fileName->Des().Append( _L("\\") ); + fileName->Des().LowerCase(); +#if 0 + ListDir( *fileName, aLevel+1 ); +#else + if( fileName->Des().Find( _L(":\\private\\") ) < 0 && + fileName->Des().Find( _L(":\\resource\\") ) < 0 && + fileName->Des().Find( _L(":\\sys\\") ) < 0 && + fileName->Des().Find( _L(":\\testframework\\") ) < 0 && + fileName->Des().Find( _L(":\\nokia\\") ) < 0 && + fileName->Des().Find( _L(":\\system\\") ) < 0 ) + { + ListDir( fileName->Des(), aLevel+1 ); + } +#endif + } + + TUint32 totalSize(0); + if( fileList ) + for ( TInt file = 0; file < fileList->Count(); file++ ) + { + fileName->Des().Zero(); + fileName->Des().Append( aDir ); + fileName->Des().Append( (*fileList)[file].iName ); + + RFile rf; + if( rf.Open( iFs, *fileName, EFileRead|EFileShareAny ) == KErrNone ) + { + TInt size(0); + if( rf.Size( size ) == KErrNone ) + { + totalSize += size; + VCXLOGLO4("%S (f) %S - %d KB", pre, fileName, size/1024 ); + } + rf.Close(); + } + else + { + VCXLOGLO3("%S (f) %S", pre, fileName); + } + + } + VCXLOGLO3("%S Total size: %d KB", pre, totalSize/1024 ); + CleanupStack::PopAndDestroy( fileName ); + } + + CleanupStack::PopAndDestroy( pre ); + CleanupStack::PopAndDestroy( fileList ); + CleanupStack::PopAndDestroy( dirList ); + + if( aLevel == 0 ) + { + VCXLOGLO1("CVCXTestCommon:: Directory listed."); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::GetPSProperty +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TInt& aValue ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); + TInt err = RProperty::Get( aCategory, aKey, aValue ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Get int returned error: %d.", err); + } + return err; + } + + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::SetPSProperty +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TInt aValue ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); + TInt err = RProperty::Set( aCategory, aKey, aValue ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Set int returned error: %d.", err); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::GetPSProperty +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TDes& aValue ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); + TInt err = RProperty::Get( aCategory, aKey, aValue ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Get desc returned error: %d.", err); + } + return err; + } + + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::SetPSProperty +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TDesC& aValue ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); + TInt err = RProperty::Set( aCategory, aKey, aValue ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXTestCommon:: RProperty::Set desc returned error: %d.", err); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CVCXTestCommon::ListFilesProcessesAndThreadsL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestCommon::ListFilesProcessesAndThreadsL( RFs& aFs ) + { + RArray fileThreadIds; + CleanupClosePushL( fileThreadIds ); + + RPointerArray fileNames; + CleanupResetAndDestroyPushL( fileNames ); + + // Get list of open files. + CFileList* fileList = 0; + TOpenFileScan fileScan( aFs ); + fileScan.NextL( fileList ); + + CleanupStack::PushL( fileList ); + + while( fileList ) + { + for (TInt i = 0; i < fileList->Count(); ++i) + { + fileNames.Append( (*fileList)[i].iName.AllocL() ); + fileThreadIds.Append( fileScan.ThreadId() ); + //VCXLOGLO4("File: %S Size: %d Thread Id: %d", &(*fileList)[i].iName, (*fileList)[i].iSize, fileScan.ThreadId() ); + } + CleanupStack::PopAndDestroy( fileList ); + fileScan.NextL( fileList ); + CleanupStack::PushL( fileList ); + } + + CleanupStack::PopAndDestroy( fileList ); + + // Get list of processes and their threads. + TFindProcess findProcess; + TFullName processName; + + TInt err( KErrNone ); + + // List processes. + while( findProcess.Next( processName ) == KErrNone ) + { + RProcess process; + err = process.Open( processName ); + if( err != KErrNone ) + { + continue; + } + CleanupClosePushL( process ); + + TProcessId pid; + pid = process.Id(); + TInt id = pid.Id(); + VCXLOGLO4("Process: %S, ID: %d (%x)", &processName, id, pid.Id() ); + + TFindThread findThread; + TFullName threadName; + + // List threads that belong to current process. + while( findThread.Next( threadName ) == KErrNone ) + { + RThread thread; + err = thread.Open( threadName ); + if( err == KErrNone ) + { + CleanupClosePushL( thread ); + RProcess threadProcess; + err = thread.Process( threadProcess ) ; + if( err == KErrNone ) + { + CleanupClosePushL( threadProcess ); + if( threadProcess.Id() == process.Id() ) + { + TThreadId tid; + tid = thread.Id(); + id = tid.Id(); + VCXLOGLO4(" - Thread: %S, ID: %d (%x)", &threadName, id, tid.Id() ); + + // And list open files for the thread. + for( TInt i = 0; i < fileThreadIds.Count(); i++ ) + { + if( fileThreadIds[i] == tid.Id() ) + { + VCXLOGLO2(" - %S", fileNames[i] ); + } + } + } + CleanupStack::PopAndDestroy( &threadProcess ); + } + CleanupStack::PopAndDestroy( &thread ); + } + } + + VCXLOGLO1("---"); + CleanupStack::PopAndDestroy( &process ); + } + + CleanupStack::PopAndDestroy( &fileNames ); + CleanupStack::PopAndDestroy( &fileThreadIds ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestMessageWait.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestMessageWait.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,356 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "VCXTestMessageWait.h" +#include "VCXTestLog.h" +#include "CIptvTestActiveWait.h" +#include "CIptvTestTimer.h" + +// EXTERNAL DATA STRUCTURES + +// EXTERNAL FUNCTION PROTOTYPES + +// CONSTANTS +const TInt KTimeoutSecond = 1000000; + +// MACROS + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVCXTestMessageWait:: +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestMessageWait* CVCXTestMessageWait::NewL( MVCXTestMessageWaitObserver* aObserver ) + { + VCXLOGLO1(">>>CVCXTestMessageWait::NewL"); + CVCXTestMessageWait* self = new (ELeave) CVCXTestMessageWait( aObserver ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + VCXLOGLO1("<<>>CVCXTestMessageWait::~CVCXTestMessageWait"); + + iActiveWaitBlocking->Stop(); + delete iActiveWaitBlocking; + iActiveWaitBlocking = NULL; + + if( iTimeoutTimer ) + { + iTimeoutTimer->CancelTimer(); + delete iTimeoutTimer; + iTimeoutTimer = NULL; + } + + iReceivedMessages.Reset(); + iWaitedMessages.Reset(); + + VCXLOGLO1("<<>>CVCXTestMessageWait::CVCXTestMessageWait"); + + VCXLOGLO1("<<>>CVCXTestMessageWait::ConstructL"); + + iActiveWaitBlocking = CIptvTestActiveWait::NewL(); + iTimeoutTimer = CIptvTestTimer::NewL(*this, 0); + + VCXLOGLO1("<<>>CVCXTestMessageWait::Reset"); + iCoolingDown = EFalse; + iWaitStarted = EFalse; + iWaitedMessages.Reset(); + iReceivedMessages.Reset(); + iTimeoutTimer->Cancel(); + iActiveWaitBlocking->Stop(); + VCXLOGLO1("<<>>CVCXTestMessageWait::ResetReceivedMessages"); + iReceivedMessages.Reset(); + VCXLOGLO1("<<>>CVCXTestMessageWait::AddMessage"); + iWaitedMessages.Append( aMsg ); + VCXLOGLO1("<<>>CVCXTestMessageWait::WaitForMessageL"); + + iWaitedMessages.Reset(); + iWaitedMessages.Append( aMsg ); + + iTimeoutSeconds = aTimeoutSeconds; + WaitForAllL( aTimeoutSeconds, aDoBlock ); + + VCXLOGLO1("<<>>CVCXTestMessageWait::WaitForAllL"); + + iWaitStarted = ETrue; + + iTimeoutSeconds = aTimeoutSeconds; + + // Nothing to wait. + if( iWaitedMessages.Count() <= 0 ) + { + VCXLOGLO1("<<= 0; i-- ) + { + for( TInt e = iWaitedMessages.Count()-1; e >= 0; e-- ) + { + if( iReceivedMessages[i] == iWaitedMessages[e] ) + { + iWaitedMessages.Remove( e ); + iReceivedMessages.Remove( i ); + break; + } + } + } + + if( iWaitedMessages.Count() > 0 ) + { + // There's messages to wait. Start timeout timer. + iTimeoutTimer->After( aTimeoutSeconds * KTimeoutSecond ); + + // Client wants blocking call. + if( aDoBlock ) + { + iActiveWaitBlocking->Start(); + User::LeaveIfError( iError ); + } + } + else + { + iWaitStarted = EFalse; + + // Nothing to wait for. + iTimeoutTimer->CancelTimer(); + + // Not blocking, inform client with callback. + if( !aDoBlock ) + { + iObserver->MessageWaitComplete( KErrNone ); + } + } + + VCXLOGLO1("<<>>CVCXTestMessageWait::CoolDownL"); + + Reset(); + + iTimeoutSeconds = aSeconds; + + iCoolingDown = ETrue; + + iTimeoutTimer->After( iTimeoutSeconds * KTimeoutSecond ); + + iActiveWaitBlocking->Start(); + + VCXLOGLO1("<<>>CVCXTestMessageWait::ReceiveMessage"); + + if( aError != KErrNone ) + { + iWaitStarted = EFalse; + if( iActiveWaitBlocking->IsWaiting() ) + { + iError = aError; + iActiveWaitBlocking->Stop(); + } + else + { + iObserver->MessageWaitComplete( aError ); + } + iTimeoutTimer->CancelTimer(); + VCXLOGLO1("<<After( iTimeoutSeconds * KTimeoutSecond ); + VCXLOGLO1("<< 0 ) + { + // Check if message is in wait queue. + for( TInt i = iWaitedMessages.Count()-1; i >= 0; i-- ) + { + if( iWaitedMessages[i] == aMsg ) + { + iWaitedMessages.Remove( i ); + break; + } + } + + if( iWaitedMessages.Count() <= 0 ) + { + iWaitStarted = EFalse; + // Stop wait. + if( iActiveWaitBlocking->IsWaiting() ) + { + iError = KErrNone; + iActiveWaitBlocking->Stop(); + } + // Not waiting, client wants callback. + else + { + iObserver->MessageWaitComplete( KErrNone ); + } + // Stop timer too. + iTimeoutTimer->CancelTimer(); + } + } + + VCXLOGLO1("<<Stop(); + iCoolingDown = EFalse; + } + else + if( iWaitedMessages.Count() > 0 ) + { + iWaitStarted = EFalse; + VCXLOGLO2("CVCXTestMessageWait:: Timeout. Messages left: %d", iWaitedMessages.Count()); + if( iActiveWaitBlocking->IsWaiting() ) + { + iActiveWaitBlocking->Stop(); + iError = KErrTimedOut; + } + else + { + // Client wants callback. + iObserver->MessageWaitComplete( KErrTimedOut ); + } + } + } + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestPSSubscriber.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestPSSubscriber.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,215 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "VCXTestLog.h" +#include "VCXTestPSSubscriber.h" +#include "VCXTestPSObserver.h" + +const TInt KMaxStrLenght( 100 ); + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::CVCXTestPSSubscriber() +// ----------------------------------------------------------------------------- +// +CVCXTestPSSubscriber::CVCXTestPSSubscriber( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXTestPSObserver* aObserver ) : + CActive( EPriorityStandard ), + iUid( aUid ), + iKey( aKey ), + iKeyType(aType), + iObserver( aObserver ) + { + // NOP + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::NewL() +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestPSSubscriber* CVCXTestPSSubscriber::NewL( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXTestPSObserver* aObserver ) + { + CVCXTestPSSubscriber* self = + new( ELeave ) CVCXTestPSSubscriber( aUid, aKey, aType, aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVCXTestPSSubscriber::ConstructL() + { + iInitialized = EFalse; + User::LeaveIfError( iProperty.Attach( iUid, iKey ) ); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::~CVCXTestPSSubscriber() +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestPSSubscriber::~CVCXTestPSSubscriber() + { + if( IsActive() ) + { + Cancel(); + } + iProperty.Close(); + + delete iSafeWait; + iSafeWait = NULL; + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::Get() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestPSSubscriber::Get( TInt& aValue ) + { + return iProperty.Get( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::Get() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestPSSubscriber::Get( TDes& aValue ) + { + return iProperty.Get( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::Set() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestPSSubscriber::Set( TInt& aValue ) + { + return iProperty.Set( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::Set() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CVCXTestPSSubscriber::Set( const TDesC& aValue ) + { + return iProperty.Set( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::Start() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestPSSubscriber::Start() + { + if( !IsActive() ) + { + iProperty.Subscribe( iStatus ); + SetActive(); + iInitialized = ETrue; + } + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::WaitChange() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestPSSubscriber::WaitChangeL() + { + if( !iSafeWait ) + { + iSafeWait = new ( ELeave ) CActiveSchedulerWait; + } + if ( iSafeWait && !iSafeWait->IsStarted() ) + { + iSafeWait->Start(); + } + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::EndWait() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestPSSubscriber::EndWait() + { + if ( iSafeWait && iSafeWait->IsStarted() ) + { + iSafeWait->AsyncStop(); + } + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::DoCancel() +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestPSSubscriber::DoCancel() + { + if( IsActive() ) + { + iProperty.Cancel(); + } + iInitialized = EFalse; + } + +// ----------------------------------------------------------------------------- +// CVCXTestPSSubscriber::RunL() +// ----------------------------------------------------------------------------- +// +void CVCXTestPSSubscriber::RunL() + { + VCXLOGLO1(">>>CVCXTestPSSubscriber::RunL"); + // resubscribe before processing new + // value to prevent missing updates + iProperty.Subscribe( iStatus ); + SetActive(); + + if( iInitialized ) + { + TBuf< KMaxStrLenght > strValue; + TInt intValue; + + if( iKeyType == RProperty::EInt ) + { + // int type changed + if( iProperty.Get( intValue ) == KErrNone && iObserver ) + { + iObserver->ValueChangedL( iUid, iKey, intValue ); + } + } + else if( iKeyType == RProperty::EText ) + { + if( iProperty.Get( strValue ) == KErrNone && iObserver ) + { + iObserver->ValueChangedL( iUid, iKey, strValue ); + } + } + } + EndWait(); + iInitialized = ETrue; + VCXLOGLO1("<< +#include // CleanupResetAndDestroyPushL + +// CONSTANTS +const TUint KMaxTraces = 20; + +// MACROS + +#ifndef __WINSCW__ + +_LIT( KVCXTestLogFolder, "Fusion" ); + +#define VCXTESTSTATS_W1(FILE,AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) +#define VCXTESTSTATS_W2(FILE,AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB); } while ( EFalse ) +#define VCXTESTSTATS_W3(FILE,AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) +#define VCXTESTSTATS_W4(FILE,AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) +#define VCXTESTSTATS_W5(FILE,AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KVCXTestLogFolder,FILE,EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) + +#else + +#define VCXTESTSTATS_W1(FILE,s) RDebug::Print(_L(#s)) +#define VCXTESTSTATS_W2(FILE,s, a) RDebug::Print(_L(#s), a) +#define VCXTESTSTATS_W3(FILE,s, a, b) RDebug::Print(_L(#s), a, b) +#define VCXTESTSTATS_W4(FILE,s, a, b, c) RDebug::Print(_L(#s), a, b, c) +#define VCXTESTSTATS_W5(FILE,s, a, b, c, d) RDebug::Print(_L(#s), a, b, c, d) + +#endif + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItem::NewL +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItem* CVCXTestStatsItem::NewL() + { + CVCXTestStatsItem* self = new (ELeave)CVCXTestStatsItem(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItem::~CVCXTestStatsKeeper +// destructor +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItem::~CVCXTestStatsItem() + { + delete iDesc; + iDesc = NULL; + + delete iDescId; + iDescId = NULL; + + iTraces.ResetAndDestroy(); + iProgresses.ResetAndDestroy(); + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItem::CVCXTestStatsItem() +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItem::CVCXTestStatsItem() + { + + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItem::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVCXTestStatsItem::ConstructL() + { + + } + + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItemSummary::NewL +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItemSummary* CVCXTestStatsItemSummary::NewL() + { + CVCXTestStatsItemSummary* self = new (ELeave)CVCXTestStatsItemSummary(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItemSummary::~CVCXTestStatsKeeper +// destructor +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItemSummary::~CVCXTestStatsItemSummary() + { + delete iDesc; + iDesc = NULL; + + delete iDescId; + iDescId = NULL; + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItemSummary::CVCXTestStatsItemSummary() +// ----------------------------------------------------------------------------- +// +CVCXTestStatsItemSummary::CVCXTestStatsItemSummary() + { + + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsItemSummary::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVCXTestStatsItemSummary::ConstructL() + { + + } + + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::NewL +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestStatsKeeper* CVCXTestStatsKeeper::NewL() + { + CVCXTestStatsKeeper* self = new (ELeave)CVCXTestStatsKeeper(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::~CVCXTestStatsKeeper +// destructor +// ----------------------------------------------------------------------------- +// +CVCXTestStatsKeeper::~CVCXTestStatsKeeper () + { + if( iStarted ) + { + GenerateReportL( _L("FusionStats.txt"), EFalse ); + GenerateReportL( _L("FusionStatsFull.txt"), ETrue ); + } + + delete iReportName; + iReportName = NULL; + + delete iReportFileName; + iReportFileName = NULL; + + iActions.ResetAndDestroy(); + iTraces.ResetAndDestroy(); + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::CVCXTestStatsKeeper +// ----------------------------------------------------------------------------- +// +CVCXTestStatsKeeper::CVCXTestStatsKeeper() + { + + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::ConstructL +// ----------------------------------------------------------------------------- +// +void CVCXTestStatsKeeper::ConstructL() + { + + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::StartStatsKeepingL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestStatsKeeper::StartStatsKeepingL( const TDesC& aName, const TDesC& aFileName ) + { + iStarted = ETrue; + iReportName = aName.AllocL(); + iReportFileName = aFileName.AllocL(); + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::ActionStartL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestStatsKeeper::ActionStartL( TInt32 aId, const TDesC& aDesc ) + { + VCXLOGLO3(">>>CVCXTestStatsKeeper::ActionStartL: %d = %S ------>", aId, &aDesc); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = CVCXTestStatsItem::NewL(); + item->iId = aId; + item->iDesc = aDesc.AllocL(); + item->iStartTime.HomeTime(); + item->iIsActive = ETrue; + + iActions.AppendL( item ); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionStartL %S = %S ------>", &aDescId, &aDesc); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = CVCXTestStatsItem::NewL(); + item->iDescId = aDescId.AllocL(); + if( aDescMerge ) + { + item->iDesc = HBufC::NewL( aDesc.Length() + aDescId.Length() ); + item->iDesc->Des().Append( aDesc ); + item->iDesc->Des().Append( aDescId ); + } + else + { + item->iDesc = aDesc.AllocL(); + } + item->iStartTime.HomeTime(); + item->iIsActive = ETrue; + + iActions.AppendL( item ); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionEndL: %d, err: %d ------>", aId, aError); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = GetActiveAction( aId ); + + if( !item ) + { + VCXLOGLO1("CVCXTestStatsKeeper:: No active action to end!"); + VCXLOGLO1("<<iError = aError; + item->iEndTime.HomeTime(); + + TBuf<64> prgBuff( _L("OK") ); + if( aError != KErrNone ) + { + prgBuff.Format( _L("Failed (%d)"), item->iError); + } + ActionProgressL( aId, prgBuff ); + + item->iIsActive = EFalse; + + if( aError != KErrNone ) + { + for( TInt i = 0; i < iTraces.Count(); i++ ) + { + item->iTraces.AppendL( iTraces[i] ); + } + iTraces.Reset(); + } + + CheckFailsL(); + + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionEndL :%S, err: %d ------>", &aDescId, aError); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = GetActiveAction( aDescId ); + + if( !item ) + { + VCXLOGLO1("CVCXTestStatsKeeper:: No active action to end!"); + VCXLOGLO1("<<iError = aError; + item->iEndTime.HomeTime(); + + TBuf<64> prgBuff( _L("OK") ); + if( aError != KErrNone ) + { + prgBuff.Format( _L("Failed (%d)"), item->iError); + } + ActionProgressL( aDescId, prgBuff ); + + item->iIsActive = EFalse; + + if( aError != KErrNone ) + { + for( TInt i = 0; i < iTraces.Count(); i++ ) + { + item->iTraces.AppendL( iTraces[i] ); + } + iTraces.Reset(); + } + + CheckFailsL(); + + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionProgressL: %d = %S", aId, &aProgressDesc); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = GetActiveAction( aId ); + + if( !item ) + { + User::Leave( KErrNotFound ); + } + + CVCXTestStatsItem* progress = CVCXTestStatsItem::NewL(); + + progress->iStartTime.HomeTime(); + progress->iDesc = aProgressDesc.AllocL(); + + item->iProgresses.AppendL( progress ); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionProgressL: %S = %S", &aDescId, &aProgressDesc); + if( !iStarted ) + { + return; + } + + CVCXTestStatsItem* item = GetActiveAction( aDescId ); + + if( !item ) + { + User::Leave( KErrNotFound ); + } + + CVCXTestStatsItem* progress = CVCXTestStatsItem::NewL(); + + progress->iStartTime.HomeTime(); + progress->iDesc = aProgressDesc.AllocL(); + + item->iProgresses.AppendL( progress ); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::ActionTraceL"); + if( !iStarted ) + { + return; + } + + while( iTraces.Count() > KMaxTraces ) + { + iTraces.Remove( 0 ); + } + + iTraces.AppendL( aDesc.AllocL() ); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::GetActiveAction"); + for( TInt i = 0; i < iActions.Count(); i++ ) + { + if( iActions[i]->iId == aId && iActions[i]->iIsActive ) + { + VCXLOGLO2("CVCXTestStatsKeeper:: Found %S.", iActions[i]->iDesc); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::GetActiveAction (desc)"); + for( TInt i = 0; i < iActions.Count(); i++ ) + { + if( iActions[i]->iDescId && *iActions[i]->iDescId == aDescId && iActions[i]->iIsActive ) + { + VCXLOGLO2("CVCXTestStatsKeeper:: Found %S.", iActions[i]->iDesc); + VCXLOGLO1("<<>>CVCXTestStatsKeeper::GetLastActiveAction"); + for( TInt i = iActions.Count()-1; i >= 0; i-- ) + { + if( iActions[i]->iIsActive ) + { + if( ( aOnlyDescId && iActions[i]->iDesc ) || ( !aOnlyDescId && !iActions[i]->iDesc ) ) + { + continue; + } + VCXLOGLO2("CVCXTestStatsKeeper:: Found: %S.", iActions[i]->iDesc); + VCXLOGLO1("<< startTime; + TBuf<256> endTime; + + CVCXTestStatsItem* item = iActions[i]; + + FormatDate( item->iStartTime, startTime ); + if( !item->iIsActive ) + { + FormatDate( item->iEndTime, endTime ); + } + + TBuf shortened; + if( item->iDesc->Length() > KMaxDescLen ) + { + TPtrC left = item->iDesc->Left( KMaxDescLen/2 ); + TPtrC right = item->iDesc->Right( KMaxDescLen/2 ); + shortened.Format( _L("%S ... %S"), &left, &right ); + } + else + { + shortened.Copy( *item->iDesc ); + } + + TBuf<1024*2> buff; + buff.Format( _L("%- *S %S"), 60, &shortened, &startTime); + VCXTESTSTATS_W2(aFileName, "%S", &buff); + + if( item->iProgresses.Count() > 0 ) + { + for( TInt e = 0; e < item->iProgresses.Count(); e++ ) + { + FormatDate( item->iProgresses[e]->iStartTime, startTime ); + if( item->iProgresses[e]->iDesc->Length() > KMaxDescLen ) + { + TPtrC left = item->iProgresses[e]->iDesc->Left( KMaxDescLen/2-2 ); + TPtrC right = item->iProgresses[e]->iDesc->Right( KMaxDescLen/2-2 ); + shortened.Format( _L("%S .. %S"), &left, &right ); + } + else + { + shortened.Copy( *item->iProgresses[e]->iDesc ); + } + buff.Format( _L(" %- *S %S"), 57, &shortened, &startTime ); + VCXTESTSTATS_W2(aFileName, "%S", &buff); + } + } + + if( item->iTraces.Count() > 0 ) + { + VCXTESTSTATS_W1(aFileName, " Traces:"); + for( TInt e = 0; e < item->iTraces.Count(); e++ ) + { + VCXTESTSTATS_W2(aFileName, " %S", item->iTraces[e]); + } + } + } + } + + RPointerArray summaries; + CleanupResetAndDestroyPushL( summaries ); + GetActionSummariesL( summaries, ETrue ); + + TBuf<256> buff; + + _LIT( KVCXTESTDest, "Desc" ); + _LIT( KVCXTESTFails, "Fails" ); + _LIT( KVCXTESTTotal, "Total" ); + _LIT( KVCXTESTMinTime, "MinTime" ); + _LIT( KVCXTESTMaxTime, "MaxTime" ); + _LIT( KVCXTESTAvgTime, "AvgTime"); + _LIT( KVCXTESTTotalTime, "TotTime"); + + const TInt KDescFieldLen = 32; + + // Header. + buff.Format( _L("%- *S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S %+ 6S"), KDescFieldLen, + &KVCXTESTDest, &KVCXTESTFails, &KVCXTESTTotal, &KVCXTESTMinTime, &KVCXTESTMaxTime, &KVCXTESTAvgTime, &KVCXTESTTotalTime ); + VCXTESTSTATS_W2(aFileName, "%S", &buff); + + // Data. + for( TInt e = 0; e < summaries.Count(); e++ ) + { + TBuf shortened; + if( summaries[e]->iDesc->Length() > KDescFieldLen ) + { + TPtrC left = summaries[e]->iDesc->Left( KDescFieldLen/2-2 ); + TPtrC right = summaries[e]->iDesc->Right( KDescFieldLen/2-2 ); + shortened.Format( _L("%S .. %S"), &left, &right ); + } + else + { + shortened.Copy( *summaries[e]->iDesc ); + } + + const TReal KXXXMillion = 1000000; + TReal minTime = (TReal)summaries[e]->iMinTime / KXXXMillion; + TReal maxTime = (TReal)summaries[e]->iMaxTime / KXXXMillion; + TReal avgTime = (TReal)summaries[e]->iAvgTime / KXXXMillion; + TInt totalTime = (TReal)summaries[e]->iTotalTime / KXXXMillion; + + buff.Format( _L("%- *S %+ 6d %+ 6d %+ 6.2f %+ 6.2f %+ 6.2f %+ 6d"), KDescFieldLen, + &shortened, summaries[e]->iFailCount, summaries[e]->iCount, + minTime, maxTime, avgTime, totalTime ); + VCXTESTSTATS_W2(aFileName, "%S", &buff); + } + + if( iAbortedBecauseTooManyFails ) + { + VCXTESTSTATS_W1(aFileName, "Too many fails, test was aborted!"); + } + + CleanupStack::PopAndDestroy( &summaries ); + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::GetActionSummariesL +// ----------------------------------------------------------------------------- +// +void CVCXTestStatsKeeper::GetActionSummariesL( RPointerArray& aSummaries, TBool aFailActiveActions ) + { + if( aFailActiveActions ) + { + for( TInt i = 0; i < iActions.Count(); i++ ) + { + CVCXTestStatsItem* item = iActions[i]; + if( item->iIsActive ) + { + item->iError = KErrUnknown; + item->iEndTime.HomeTime(); + item->iIsActive = EFalse; + } + } + } + + for( TInt i = 0; i < iActions.Count(); i++ ) + { + CVCXTestStatsItem* item = iActions[i]; + if( item->iIsActive ) + { + continue; + } + + CVCXTestStatsItemSummary* itemSummary( NULL ); + + // Find summary item. + for( TInt e = 0; e < aSummaries.Count(); e++ ) + { + if( item->iDesc && aSummaries[e]->iDesc && *item->iDesc == *aSummaries[e]->iDesc ) + { + itemSummary = aSummaries[e]; + break; + } + } + + // Not found, create new one. + if( !itemSummary ) + { + itemSummary = CVCXTestStatsItemSummary::NewL(); + itemSummary->iId = item->iId; + itemSummary->iTotalTime = 0; + itemSummary->iMaxTime = -1; + itemSummary->iMinTime = -1; + if( item->iDescId ) itemSummary->iDescId = item->iDescId->AllocL(); + itemSummary->iDesc = item->iDesc->AllocL(); + aSummaries.Append( itemSummary ); + } + + // Increase counts. + itemSummary->iCount++; + if( item->iError != KErrNone ) + { + itemSummary->iFailCount++; + } + + // Add item to stats. + TTimeIntervalMicroSeconds runTime( 0 ); + runTime = item->iEndTime.MicroSecondsFrom( item->iStartTime ); + if( runTime.Int64() > 0 ) + { + if( item->iError != KErrNone ) + { + itemSummary->iFailTime += runTime.Int64(); + } + itemSummary->iTotalTime += runTime.Int64(); + TReal run = (TReal)runTime.Int64() / 1000000; + + itemSummary->iMaxTime = + ( runTime.Int64() > itemSummary->iMaxTime || itemSummary->iMaxTime < 0 ) ? runTime.Int64() : itemSummary->iMaxTime; + itemSummary->iMinTime = + ( runTime.Int64() < itemSummary->iMinTime || itemSummary->iMinTime < 0) ? runTime.Int64() : itemSummary->iMinTime; + } + } + + // Calc avg times and check other times. + for( TInt e = 0; e < aSummaries.Count(); e++ ) + { + aSummaries[e]->iAvgTime = (TReal)aSummaries[e]->iTotalTime / (TReal)aSummaries[e]->iCount; + aSummaries[e]->iMinTime = aSummaries[e]->iMinTime < 0 ? 0 : aSummaries[e]->iMinTime; + aSummaries[e]->iMaxTime = aSummaries[e]->iMaxTime < 0 ? 0 : aSummaries[e]->iMaxTime; + } + + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::DataSizeL +// ----------------------------------------------------------------------------- +// +TUint CVCXTestStatsKeeper::DataSizeL() + { + TUint size( 0 ); + + size += iActions.Count() * sizeof( CVCXTestStatsItem ); + + for( TInt i = 0; i < iActions.Count(); i++ ) + { + CVCXTestStatsItem* item = iActions[i]; + if( item->iDescId ) size += item->iDescId->Size(); + size += item->iDesc->Size(); + + size += item->iProgresses.Count() * sizeof( CVCXTestStatsItem ); + + for( TInt e = 0; e < item->iProgresses.Count(); e++ ) + { + size += item->iProgresses[e]->iDesc->Size(); + } + + if( item->iTraces.Count() > 0 ) + { + for( TInt e = 0; e < item->iTraces.Count(); e++ ) + { + size += item->iTraces[e]->Size(); + } + } + } + return size/1024; + } + +// ----------------------------------------------------------------------------- +// CVCXTestStatsKeeper::CheckFailsL +// ----------------------------------------------------------------------------- +// +void CVCXTestStatsKeeper::CheckFailsL() + { + RPointerArray summaries; + CleanupResetAndDestroyPushL( summaries ); + GetActionSummariesL( summaries, EFalse ); + + const TReal KVCXTestStatsKeeperMaxFailPercent = 0.33; + + for( TInt i = 0; i < summaries.Count(); i++ ) + { + // Check fails only when there's some actions done. + if( summaries[i]->iCount > 10 ) + { + // Check if there's too many fails. + TReal failPercent = (TReal)summaries[i]->iFailCount / (TReal)summaries[i]->iCount; + + if( failPercent > KVCXTestStatsKeeperMaxFailPercent ) + { + iAbortedBecauseTooManyFails = ETrue; + VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); + User::Leave( KErrAbort ); + } + + const TInt64 KTest10Minutes = 1000000 * 60 * 10; + + // Check if failing cases take too long to run. + if( summaries[i]->iTotalTime > 0 && summaries[i]->iFailTime > KTest10Minutes ) + { + TReal failTimePercent = (TReal)summaries[i]->iFailTime / (TReal)summaries[i]->iTotalTime; + if( failTimePercent > KVCXTestStatsKeeperMaxFailPercent ) + { + VCXLOGLO1("CVCXTestStatsKeeper:: Too many fails, leaving with KErrAbort"); + iAbortedBecauseTooManyFails = ETrue; + User::Leave( KErrAbort ); + } + } + } + } + CleanupStack::PopAndDestroy( &summaries ); + } + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestTimerWait.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestTimerWait.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDES +#include + +#include "CIptvTestActiveWait.h" +#include "CIptvTestTimer.h" +#include "VCXTestTimerWait.h" + +// ----------------------------------------------------------------------------- +// CTestTimerWait::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestTimerWait* CVCXTestTimerWait::NewL() + { + CVCXTestTimerWait* self = new (ELeave) CVCXTestTimerWait(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXTestTimerWait::CVCXTestTimerWait +// ----------------------------------------------------------------------------- +// +CVCXTestTimerWait::CVCXTestTimerWait() + { + + } + +// ----------------------------------------------------------------------------- +// CVCXTestTimerWait::ConstructL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestTimerWait::ConstructL() + { + iWait = CIptvTestActiveWait::NewL(); + iTimer = CIptvTestTimer::NewL(*this, 0); + } + +// ----------------------------------------------------------------------------- +// CVCXTestTimerWait::~CVCXTestTimerWait +// ----------------------------------------------------------------------------- +// +EXPORT_C CVCXTestTimerWait::~CVCXTestTimerWait() + { + if(iTimer != NULL) + { + iTimer->CancelTimer(); + delete iTimer; + iTimer = NULL; + } + + if( iWait ) + { + iWait->Stop(); + delete iWait; + iWait = NULL; + } + } + +// ----------------------------------------------------------------------------- +// CVCXTestTimerWait::WaitL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CVCXTestTimerWait::WaitL( TUint32 aMicroSeconds ) + { + iTimer->After( aMicroSeconds ); + iWait->Start(); + } + +// ----------------------------------------------------------------------------- +// CVCXTestTimerWait::TimerComplete +// ----------------------------------------------------------------------------- +// +void CVCXTestTimerWait::TimerComplete( TInt /* aTimerId */, TInt /* aError */ ) + { + if( iWait ) iWait->Stop(); + } + +// EOF + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/Bwins/VCXTestUtilModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/Bwins/VCXTestUtilModuleu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &) + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/EABI/VCXTestUtilModuleu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/EABI/VCXTestUtilModuleu.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,34 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZN14CVCXTestCommon10VerifyDataER7TDesC16RN19CIptvTestVerifyData13TVerifyResultE @ 2 NONAME ABSENT + _ZN14CVCXTestCommon11GetFileSizeER7TDesC16Rm @ 3 NONAME ABSENT + _ZN14CVCXTestCommon11SetTimeZoneER7TDesC16 @ 4 NONAME ABSENT + _ZN14CVCXTestCommon13CreateBadIapLER7TDesC16 @ 5 NONAME ABSENT + _ZN14CVCXTestCommon13GetPSPropertyE4TUidjR6TDes16 @ 6 NONAME ABSENT + _ZN14CVCXTestCommon13GetPSPropertyE4TUidjRi @ 7 NONAME ABSENT + _ZN14CVCXTestCommon13SetPSPropertyE4TUidjRK7TDesC16 @ 8 NONAME ABSENT + _ZN14CVCXTestCommon13SetPSPropertyE4TUidji @ 9 NONAME ABSENT + _ZN14CVCXTestCommon13SetSystemTimeE5TTime @ 10 NONAME ABSENT + _ZN14CVCXTestCommon14GetIapNameByIdER6TDes16m @ 11 NONAME ABSENT + _ZN14CVCXTestCommon15GetIapIdByNameLERK7TDesC16Rm @ 12 NONAME ABSENT + _ZN14CVCXTestCommon15GetIapIdByTypeLENS_16TIptvTestIapTypeERmi @ 13 NONAME ABSENT + _ZN14CVCXTestCommon15WriteVerifyDataER7TDesC1611TRefByValueIKS0_Ez @ 14 NONAME ABSENT + _ZN14CVCXTestCommon15WriteVerifyDataER7TDesC16S1_ @ 15 NONAME ABSENT + _ZN14CVCXTestCommon16CreateVerifyDataER7TDesC16i @ 16 NONAME ABSENT + _ZN14CVCXTestCommon16CreateVideoFileLEN21CIptvTestVideoCreator18TIptvTestVideoTypeER7TDesC16i @ 17 NONAME ABSENT + _ZN14CVCXTestCommon17CreateVideoFilesLEN21CIptvTestVideoCreator18TIptvTestVideoTypeER7TDesC16iR13RPointerArrayI7HBufC16E @ 18 NONAME ABSENT + _ZN14CVCXTestCommon17DeleteDummyFilesLEi @ 19 NONAME ABSENT + _ZN14CVCXTestCommon18ParseIntFromStringERiR7TDesC16 @ 20 NONAME ABSENT + _ZN14CVCXTestCommon18SetDriveFreeSpaceLEij @ 21 NONAME ABSENT + _ZN14CVCXTestCommon20EnsureFileIsNotInUseERK7TPtrC16 @ 22 NONAME ABSENT + _ZN14CVCXTestCommon22AdvanceSystemTimeHoursEi @ 23 NONAME ABSENT + _ZN14CVCXTestCommon22EnableVerifyTimestampsEi @ 24 NONAME ABSENT + _ZN14CVCXTestCommon24AdvanceSystemTimeMinutesEi @ 25 NONAME ABSENT + _ZN14CVCXTestCommon24AdvanceSystemTimeSecondsEi @ 26 NONAME ABSENT + _ZN14CVCXTestCommon4NewLEv @ 27 NONAME ABSENT + _ZN14CVCXTestCommon7ListDirERK7TDesC16i @ 28 NONAME ABSENT + _ZN14CVCXTestCommon9GetIapIdLERK7TDesC16Rm @ 29 NONAME ABSENT + _ZN14CVCXTestCommon9PrintIapsEv @ 30 NONAME ABSENT + _ZTI14CVCXTestCommon @ 31 NONAME ABSENT ; ## + _ZTV14CVCXTestCommon @ 32 NONAME ABSENT ; ## + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/conf/VCXTestUtilModule.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/conf/VCXTestUtilModule.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,4 @@ + +[Test] +title No tests for this module. +[Endtest] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/VCXTestUtilModule.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/VCXTestUtilModule.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET VCXTestUtilModule.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +#if defined(EKA2) +CAPABILITY CAP_GENERAL_DLL +VENDORID 0x101FB657 +SECUREID 0x102073DB +#endif + +DEFFILE VCXTestUtilModule.def + +SOURCEPATH ../src +SOURCE IptvTestUtilModule.cpp +SOURCE IptvTestUtilModuleBlocks.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../VCXTestCommon/inc + +APP_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY commdb.lib +LIBRARY bafl.lib +LIBRARY esock.lib +LIBRARY FLOGGER.lib +LIBRARY DownloadMgr.lib +LIBRARY efsrv.lib +LIBRARY tzclient.lib +LIBRARY ezip.lib +LIBRARY VCXTestCommon.lib + +LANG SC + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/VCXTestUtilModule.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/VCXTestUtilModule.pkg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,58 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; + +; Languages +&EN + +; Package header +#{"VCXTestUtilModule"},(0x101F7961),0,0,0 + +; Localised Vendor name +%{"Nokia EN"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files + "\epoc32\release\armv5\udeb\VCXTestUtilModule.dll" - "!:\Sys\Bin\VCXTestUtilModule.dll" + "..\conf\VCXTestUtilModule.cfg" - "c:\TestFramework\VCXTestUtilModule.cfg" + "..\init\TestFramework.ini" - "c:\TestFramework\TestFramework.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +PRJ_PLATFORMS +DEFAULT + + +PRJ_EXPORTS + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES +VCXTestUtilModule.mmp + +// End of File \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/inc/IptvTestUtilModule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/inc/IptvTestUtilModule.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,455 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef IPTVTESTUTILMODULE_H +#define IPTVTESTUTILMODULE_H + +// INCLUDES +#include +#include + +#include +#include +#include + +#include "MTestUtilConnectionObserver.h" +#include "MTestUtilDownloadObserver.h" +#include "MIptvTestTimerObserver.h" + +// CONSTANTS +const TInt KConnectionTimerId = 500; + +// Logging path +_LIT( KIptvTestUtilModuleLogPath, "\\logs\\testframework\\IptvTestUtilModule\\" ); +// Log file +_LIT( KIptvTestUtilModuleLogFile, "IptvTestUtilModule.txt" ); + +// MACROS + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CIptvTestUtilModule; +class CTestUtilConnection; +class CTestUtilConnectionWaiter; +class CIptvTestDownloadManager; +class CIptvTestTimer; +class CIptvTestMobilecrashWatcher; +class CIptvTestUtilALR; +class CVCXTestCommon; +class CZipFile; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CIptvTestUtilModule test class for STIF Test Framework TestScripter. +* This class should have no depencies to Video Center code. +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CIptvTestUtilModule) : public CScriptBase, public MTestUtilConnectionObserver, public MTestUtilDownloadObserver, public MIptvTestTimerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIptvTestUtilModule* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CIptvTestUtilModule(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + void ConnectionCreated(); + void ConnectionClosed(); + void ConnectionFailed(); + void ConnectionAlreadyExists(); + void ConnectionTimeout(); + + void DownloadFinished(TInt aError); + + void TimerComplete(TInt aTimerId, TInt aError); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + private: + + /** + * C++ default constructor. + */ + CIptvTestUtilModule( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Creates MobilecrashesWatcher + * @return Symbian OS error code. + */ + virtual TInt CreateMobilecrashWatcherL( CStifItemParser& aItem ); + + /** + * Checks if there's any new mobilecrashes since the watcher was created. + * @param aItem Script line containing IptvTest Case ID. Required. + * @return KErrNone if there's no new mobilecrash files, else KErrAbort. + */ + virtual TInt CheckMobilecrashesL( CStifItemParser& aItem ); + + /** + * Checks if there's any mobilecrash files. + * @param aItem Script line containing IptvTest Case ID. Required. + * @return KErrNone if there's no mobilecrash files, else KErrAbort. + */ + virtual TInt CheckMobilecrashesZeroToleranceL( CStifItemParser& aItem ); + + /** + * Writes line ">>> Case start: " using Iptv logging methods. + * @param aItem Script line containing IptvTest Case ID. Required. + * @return Symbian OS error code. + */ + virtual TInt IptvLogCaseStart( CStifItemParser& aItem ); + + /** + * Writes line "<<< Case end." using Iptv logging methods. + * @param + * @return Symbian OS error code. + */ + virtual TInt IptvLogCaseEnd( CStifItemParser& aItem ); + + /** + * Writes line using Iptv logging methods. + * @param aItem Text which is written into the log. Not required. + * @return Symbian OS error code. + */ + virtual TInt IptvLogWrite( CStifItemParser& aItem ); + + /** + * Opens a socket to a specified IAP. + * ASYNC. + * @param aItem IAP name. + * @return Symbian OS error code. + */ + virtual TInt ConnectL( CStifItemParser& aItem ); + + /** + * Attached to open connection specified by IAP. + * SYNC. + * @param aItem IAP name. + * @return Symbian OS error code. + */ + virtual TInt AttachL( CStifItemParser& aItem ); + + /** + * Disconnects from the currently open connection. + * SYNC. + * @param none + * @return Symbian OS error code. + */ + virtual TInt DisconnectL( CStifItemParser& aItem ); + + /** + * Terminates the currently open connection, i.e. closes it immediately. + * The connection can be opened by this module or other application. + * SYNC. + * @param none + * @return Symbian OS error code. + */ + virtual TInt TerminateConnectionL( CStifItemParser& aItem ); + + /** + * Starts observing the connection until it's activated, Signals test script. + * @param IAP name + * @return Symbian OS error code. + */ + virtual TInt WaitForConnectionActivityL( CStifItemParser& aItem ); + + /** + * Starts observing the connection until it's closed, Signals test script. + * @param IAP name + * @return Symbian OS error code. + */ + virtual TInt WaitUntilConnectionIsClosed(CStifItemParser& aItem ); + + /** + * Start a download. + */ + virtual TInt DownloadL( CStifItemParser& aItem ); + + /** + * Stop downloads. + */ + virtual TInt StopDownloadsL( CStifItemParser& aItem ); + + /** + * Advance system time for 1 second. + */ + virtual TInt AdvanceSystemTime1Second( CStifItemParser& aItem ); + + /** + * Advance system time for X seconds. + */ + virtual TInt AdvanceSystemTimeSeconds( CStifItemParser& aItem ); + + /** + * Advance system time for X minute. + */ + virtual TInt AdvanceSystemTimeMinutes( CStifItemParser& aItem ); + + /** + * Advance system time for X hour. + */ + virtual TInt AdvanceSystemTimeHours( CStifItemParser& aItem ); + + /** + * Advance system time for specified number of days. + */ + virtual TInt AdvanceSystemTimeDays(CStifItemParser& aItem ); + + /** + * Set the system time. + * Must be in format YYYYMMDD:HHMMSS.MMMMMM (First day / month is 0) + */ + virtual TInt SetSystemTime(CStifItemParser& aItem ); + + /** + * Set the system time within the ongoing day. + * + */ + virtual TInt SetSystemTimeToday(CStifItemParser& aItem ); + + /** + * Set the system timezone. + */ + virtual TInt SetTimeZone(CStifItemParser& aItem ); + + /** + * Sets the default iap id value to cenrep. + */ + virtual TInt SetDefaultIapCenRepL(CStifItemParser& aItem ); + + /** + * Removes the used destination cenrep value. + */ + virtual TInt DeleteUsedDestinationCenRepL( CStifItemParser& aItem ); + + /** + * Set the used destination cenrep value for Video Center & IPTV_Engine. + */ + virtual TInt SetUsedDestinationL( CStifItemParser& aItem ); + + /** + * Create new destination (SNAP) + */ + virtual TInt CreateDestinationL( CStifItemParser& aItem ); + + /** + * Delete a destination (SNAP) + */ + virtual TInt DeleteDestinationL( CStifItemParser& aItem ); + + /** + * Copy existing connection method to defined SNAP. + */ + virtual TInt CopyMethodL( CStifItemParser& aItem ); + + /** + * Delete a connection method. + */ + virtual TInt DeleteMethodL( CStifItemParser& aItem ); + + /** + * Set priority for a connection method. + */ + virtual TInt SetMethodPriorityL( CStifItemParser& aItem ); + + /** + * Delete the destination when classes destructor is run. + */ + virtual TInt DeleteDestinationAfterwardsL( CStifItemParser& aItem ); + + /** + * Sets string attribute for connection method. + */ + virtual TInt SetConnectionMethodStringAttributeL( CStifItemParser& aItem ); + + /** + * Sets integer attribute for connection method. + */ + virtual TInt SetConnectionMethodIntAttributeL( CStifItemParser& aItem ); + + /** + * Sets boolean attribute for connection method. + */ + virtual TInt SetConnectionMethodBoolAttributeL( CStifItemParser& aItem ); + + /** + * CreateFileL + */ + virtual TInt CreateFileL( CStifItemParser& aItem ); + + /** + * DeleteFileL + */ + virtual TInt DeleteFileL( CStifItemParser& aItem ); + + /* + * CreateFolderL + */ + virtual TInt CreateFolderL( CStifItemParser& aItem ); + + /* + * DeleteFolderL + */ + virtual TInt DeleteFolderL( CStifItemParser& aItem ); + + /* + * LockFileL + */ + virtual TInt LockFileL( CStifItemParser& aItem ); + + /* + * UnlockFileL + */ + virtual TInt UnlockFileL( CStifItemParser& aItem ); + + /* + * ExtractFile + */ + virtual TInt ExtractFileL( CStifItemParser& aItem ); + + /* + * FileExistsInZip + */ + virtual TBool FileExistsInZip( CZipFile* aZipFile, const TDesC& aFileName ); + + /** + * Prints IAPs from commdb to debug output. + */ + virtual void PrintIAPs(); + + /** + * Gets IAp by name. + */ + virtual void GetIap(TDesC& aIapName, TUint32& aIapId); + + /** + * Sets free space on drive. + * @param aDriveLetter + * @param aDesiredSpace, bytes + */ + virtual TInt SetDriveFreeSpaceL( CStifItemParser& aItem ); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + CTestUtilConnection* iConnect; + CTestUtilConnectionWaiter* iConnectionWaiter; + TInt iRetryCount; + CIptvTestDownloadManager* iDownload; + CIptvTestTimer* iTimer; + CIptvTestMobilecrashWatcher* iIptvTestMobilecrashWatcher; + HBufC* iObservedServicePath; + RPointerArray iObservedFiles; + RArray iFileModifiedDates; + + RPointerArray iToBeDeletedDestinations; + + CIptvTestUtilALR* iTestUtilALR; + RFs iFs; + RFile iLockedFile; + TBool iFileIsLocked; + + TBool iCaseStarted; + + CVCXTestCommon* iTestCommon; + + TBool iDummyFilesCreated; + }; + +#endif // IPTVTESTUTILMODULE_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/init/TestFramework.ini Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,165 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\Logs\Fusion\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= APPEND # Possible values: OVERWRITE or APPEND +UITestingSupport= Yes +SeparateProcesses= YES +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\VCXTestUtilModule.cfg +[End_Module] + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= C:\ +#HardwareFormat= TXT # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/src/IptvTestUtilModule.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/src/IptvTestUtilModule.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +// INCLUDE FILES +#include +#include "IptvTestUtilModule.h" + +#include + +#include "VCXTestCommon.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::CIptvTestUtilModule +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CIptvTestUtilModule::CIptvTestUtilModule( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::ConstructL() + { + iLog = CStifLogger::NewL( KIptvTestUtilModuleLogPath, + KIptvTestUtilModuleLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + User::LeaveIfError( iFs.Connect() ); + iTestCommon = CVCXTestCommon::NewL(); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveC ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveE ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveF ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveG ) ); + + TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); + + CStifItemParser* nullParser( NULL ); + CreateMobilecrashWatcherL( *nullParser ); + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CIptvTestUtilModule* CIptvTestUtilModule::NewL( + CTestModuleIf& aTestModuleIf ) + { + CIptvTestUtilModule* self = new (ELeave) CIptvTestUtilModule( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// Destructor +CIptvTestUtilModule::~CIptvTestUtilModule() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + delete iTestCommon; + iTestCommon = NULL; + + iFs.Close(); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CIptvTestUtilModule::NewL( aTestModuleIf ); + + } + +// ----------------------------------------------------------------------------- +// E32Dll is a DLL entry point function. +// Returns: KErrNone +// ----------------------------------------------------------------------------- +// +#ifndef EKA2 // Hide Dll entry point to EKA2 +GLDEF_C TInt E32Dll( + TDllReason /*aReason*/) // Reason code + { + return(KErrNone); + + } +#endif // EKA2 + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/src/IptvTestUtilModuleBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/VCXTestUtilModule/src/IptvTestUtilModuleBlocks.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1926 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include + +#include +#include +#include + +#include "VCXTestLog.h" +#include "IptvTestUtilModule.h" +#include "TestUtilConnection.h" +#include "TestUtilConnectionWaiter.h" +#include "IptvTestDownloadManager.h" +#include "VCXTestCommon.h" +#include "CIptvTestMobilecrashWatcher.h" +#include "CIptvTestTimer.h" + +#include "IptvTestUtilALR.h" + +// CONSTANTS +_LIT( KDateTimeString, "%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B" ); + +// MACROS + +// LOCAL CONSTANTS AND MACROS + +// FORWARD DECLARATIONS +class CIptvTestTimer; +class CZipFile; + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::Delete() + { + VCXLOGLO1(">>>CIptvTestUtilModule::Delete"); + if(iConnect) + { + delete iConnect; + iConnect = NULL; + } + + if(iConnectionWaiter) + { + delete iConnectionWaiter; + iConnectionWaiter = NULL; + } + + if(iDownload) + { + delete iDownload; + iDownload = NULL; + } + + if(iTimer) + { + delete iTimer; + iTimer = NULL; + } + + if( iFileIsLocked ) + { + VCXLOGLO1("CIptvTestUtilModule:: Release locked file."); + iLockedFile.Close(); + } + iFileIsLocked = EFalse; + + delete iObservedServicePath; + iObservedServicePath = NULL; + iObservedFiles.ResetAndDestroy(); + //iObservedFiles.Close(); + VCXLOGLO1("CIptvTestUtilModule::Observed array deleted."); + + iFileModifiedDates.Reset(); + iFileModifiedDates.Close(); + VCXLOGLO1("CIptvTestUtilModule::File date array deleted."); + + iFs.Close(); + + TInt i; + for( i = 0; i < iToBeDeletedDestinations.Count(); i++ ) + { + TPtr ptr = iToBeDeletedDestinations[i]->Des(); + iTestUtilALR->DeleteDestinationL( ptr ); + } + + iToBeDeletedDestinations.ResetAndDestroy(); + + if( iTestUtilALR ) + { + delete iTestUtilALR; + iTestUtilALR = NULL; + } + + if( iCaseStarted ) + { + VCXLOGLO1("<<< Case end."); + iCaseStarted = EFalse; + } + + if( iDummyFilesCreated ) + { + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveC ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveE ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveF ) ); + TRAP_IGNORE( iTestCommon->DeleteDummyFilesL( EDriveG ) ); + } + + if(iIptvTestMobilecrashWatcher) + { + CStifItemParser* nullParser( NULL ); + CheckMobilecrashesL( *nullParser ); + + delete iIptvTestMobilecrashWatcher; + iIptvTestMobilecrashWatcher = NULL; + } + + + VCXLOGLO1("<<>>CIptvTestUtilModule::IptvLogCaseStart"); + + _LIT( KIptvTestUtilModule, "IptvTestUtilModule" ); + _LIT( KWhere, "In IptvLogCaseStart" ); + TestModuleIf().Printf( 0, KIptvTestUtilModule, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TPtrC string; + + if( aItem.GetNextString ( string ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::IptvLogCaseStart: Could not read parameter!"); + return KErrGeneral; + } + + VCXLOGLO2(">>> Case start: %S", &string); + + iCaseStarted = ETrue; + + return KErrNone; + //VCXLOGLO1("<<>>CIptvTestUtilModule::IptvLogCaseEnd"); + + _LIT( KIptvTestUtilModule, "IptvTestUtilModule" ); + _LIT( KWhere, "In IptvLogCaseEnd" ); + TestModuleIf().Printf( 0, KIptvTestUtilModule, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + VCXLOGLO1("<<< Case end."); + iCaseStarted = EFalse; + + return KErrNone; + //VCXLOGLO1("<<>>CIptvTestUtilModule::IptvLogWrite"); + + _LIT( KIptvTestUtilModule, "IptvTestUtilModule" ); + _LIT( KWhere, "In IptvLogWrite" ); + TestModuleIf().Printf( 0, KIptvTestUtilModule, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TPtrC string; + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + if( aItem.GetNextString ( string ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::IptvLogWrite: Could not read parameter!"); + return KErrGeneral; + } + + VCXLOGLO2("%S", &string); + + return KErrNone; + //VCXLOGLO1("<<>>CIptvTestUtilModule::ConnectL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In ConnectL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if(iConnect) + { + VCXLOGLO1("CIptvTestUtilModule:: Connection already exists."); + return KErrAlreadyExists; + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt err = KErrNone; + + TPtrC iapName; + + if(KErrNone != aItem.GetNextString(iapName) ) + { + VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name was not specified."); + iLog->Log( _L("** FAIL ** Invalid testcase parameter! Iap name was not specified.") ); + VCXLOGLO1("<< name(iapName); + TUint32 iapId; + if(!iTestCommon->GetIapIdL(name, iapId)) + { + VCXLOGLO2("** FAIL ** Could not find iap with name %S.", &name); + iLog->Log( _L("** FAIL ** Could not find specified iap.") ); + VCXLOGLO1("<<SetConnectionPreferences(KCommDbBearerUnknown, iapId); + iConnect->ConnectL(); + + if(!iTimer) + { + iTimer = CIptvTestTimer::NewL(*this, KConnectionTimerId); + } + iTimer->After(1000000 * 20); + + VCXLOGLO1("<<>>CIptvTestUtilModule::AttachL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AttachL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if(iConnect) + { + VCXLOGLO1("<<Log( _L("** FAIL ** Invalid testcase parameter! Iap name was not specified.") ); + VCXLOGLO1("<< name(iapName); + TUint32 iapId; + if(!iTestCommon->GetIapIdL(name, iapId)) + { + VCXLOGLO2("** FAIL ** Could not find iap with name %S.", &name); + iLog->Log( _L("** FAIL ** Could not find specified iap.") ); + VCXLOGLO1("<<SetConnectionPreferences(KCommDbBearerUnknown, iapId); + iConnect->AttachL(); + + if(!iTimer) + { + iTimer = CIptvTestTimer::NewL(*this, KConnectionTimerId); + } + iTimer->After(1000000 * 20); + + VCXLOGLO1("<<>>CIptvTestUtilModule::DisconnectL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In DisconnectL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = KErrNone; + + if(iTimer) + { + iTimer->CancelTimer(); + } + + delete iConnect; + iConnect = NULL; + + VCXLOGLO1("<<>>CIptvTestUtilModule::TerminateConnectionL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In TerminateConnectionL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = KErrNone; + + if(iConnect) + { + iConnect->TerminateConnectionL(); + + delete iConnect; + iConnect = NULL; + } + + if(iTimer) + { + iTimer->CancelTimer(); + } + + VCXLOGLO1("<<>>CIptvTestUtilModule::DownloadL"); + // Print to UI + _LIT( KIptvTestUtilModule, "IptvTestUtilModule" ); + _LIT( KWhere, "In DownloadL" ); + TestModuleIf().Printf( 0, KIptvTestUtilModule, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = KErrNone; + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC pAddress, pOutFile, pUserName, pPassword, pIapName; + + if( aItem.GetNextString ( pAddress ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::DownloadL: Could not read parameter address!"); + return KErrGeneral; + } + + HBufC* heapBuffer = HBufC::NewL(4000); + TPtr ptr( heapBuffer->Des() ); + ptr.Copy( pAddress ); + + if( aItem.GetNextString ( pOutFile ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::DownloadL: Could not read parameter outputfile!"); + return KErrGeneral; + } + + if( aItem.GetNextString ( pUserName ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::DownloadL: no user name specified!"); + } + + if( aItem.GetNextString ( pPassword ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::DownloadL: no password specified!"); + } + + if( aItem.GetNextString ( pIapName ) != KErrNone ) + { + VCXLOGLO1("CIptvTestUtilModule::DownloadL: no iap specified!"); + } + + VCXLOGLO2("Address: %S", &pAddress); + VCXLOGLO2("OutFile: %S", &pOutFile); + VCXLOGLO2("name: %S", &pUserName); + VCXLOGLO2("Password: %S", &pPassword); + VCXLOGLO2("Iap: %S", &pIapName); + + if(!iDownload) + { + iDownload = CIptvTestDownloadManager::NewL(this); + } + + TUint32 iapId(0); + GetIap(pIapName, iapId); + + err = iDownload->DownloadL(ptr, pOutFile, pUserName, pPassword, iapId); + if(err != KErrNone) + { + VCXLOGLO2("iDownload returned: %d", err); + } + + VCXLOGLO1("<<>>CIptvTestUtilModule::StopDownloads"); + // Print to UI + _LIT( KIptvTestUtilModule, "IptvTestUtilModule" ); + _LIT( KWhere, "In StopDownloadsL" ); + TestModuleIf().Printf( 0, KIptvTestUtilModule, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = KErrNone; + + if(iDownload) + { + delete iDownload; + iDownload = NULL; + } + + VCXLOGLO1("<<CancelTimer(); + } + Signal(); + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::ConnectionClosed +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::ConnectionClosed() + { + VCXLOGLO1("CIptvTestUtilModule:: Connection closed."); + Signal(); + if(iTimer) + { + iTimer->CancelTimer(); + } + + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::ConnectionTimeout +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::ConnectionTimeout() + { + VCXLOGLO1("CIptvTestUtilModule:: Connection timeout!"); + Signal(KErrTimedOut); + if(iTimer) + { + iTimer->CancelTimer(); + } + + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::ConnectionFailed +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::ConnectionFailed() + { + if(--iRetryCount <= 0) + { + Signal(KErrGeneral); + VCXLOGLO1("CIptvTestUtilModule:: Connection failed!"); + } + else + { + VCXLOGLO1("CIptvTestUtilModule:: retrying"); + iConnect->ConnectL(); + } + if(iTimer) + { + iTimer->CancelTimer(); + } + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::ConnectionAlreadyExists +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::ConnectionAlreadyExists() + { + VCXLOGLO1("CIptvTestUtilModule:: Connection already exists."); + if(iTimer) + { + iTimer->CancelTimer(); + } + Signal(); + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::DownloadFinished +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::DownloadFinished(TInt aError) + { + VCXLOGLO1("CIptvTestUtilModule:: Download finished."); + Signal(aError); + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::PrintIAPs +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::PrintIAPs() + { + RArray idArray; + CleanupClosePushL( idArray ); + + CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat(16); + CleanupStack::PushL( nameArray ); + + // Get IAP names and ids from the database + CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); + CleanupStack::PushL( TheDb ); + + TheDb->ShowHiddenRecords(); + + CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); + //Ethernet with Daemon Dynamic IP + TBuf<40> name; + TUint32 id; + TInt res = view->GotoFirstRecord(); + while( res == KErrNone ) + { + view->ReadTextL( TPtrC(COMMDB_NAME), name ); + view->ReadUintL( TPtrC(COMMDB_ID), id ); + + idArray.Insert( id, 0 ); + nameArray->InsertL( 0, name ); + + res = view->GotoNextRecord(); + VCXLOGLO3("IAP name, id: %S, %d", &name, id); + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + + CleanupStack::PopAndDestroy( 2, &idArray ); // nameArray, idArray + } + +// ----------------------------------------------------------------------------- +// CIptvTestUtilModule::GetIap +// ----------------------------------------------------------------------------- +// +void CIptvTestUtilModule::GetIap(TDesC& aIapName, TUint32& aIapId) + { + VCXLOGLO1(">>>CIptvTestUtilModule::GetIap"); + RArray idArray; + CleanupClosePushL( idArray ); + + CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat(16); + CleanupStack::PushL( nameArray ); + + // Get IAP names and ids from the database + CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); + CleanupStack::PushL( TheDb ); + + TheDb->ShowHiddenRecords(); + + CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); + //Ethernet with Daemon Dynamic IP + TBuf<40> name; + TUint32 id; + TInt res = view->GotoFirstRecord(); + while( res == KErrNone ) + { + view->ReadTextL( TPtrC(COMMDB_NAME), name ); + view->ReadUintL( TPtrC(COMMDB_ID), id ); + +#ifdef __WINSCW__ + if(_L("Ethernet with Daemon Dynamic IP") == name) + { + aIapId = id; + VCXLOGLO3("CIptvTestUtilModule:: Found IAP: %d, %S", _L("Ethernet with Daemon Dynamic IP"), &aIapName); + } +#else + if(aIapName == name) + { + aIapId = id; + VCXLOGLO3("CIptvTestUtilModule:: Found IAP: %d, %S", aIapId, &aIapName); + } +#endif + + idArray.Insert( id, 0 ); + nameArray->InsertL( 0, name ); + + res = view->GotoNextRecord(); + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + + CleanupStack::PopAndDestroy( 2, &idArray ); // nameArray, idArray + VCXLOGLO1("<<>>CIptvTestUtilModule::WaitForConnectionActivityL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In WaitForConnectionActivityL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt err = KErrNone; + + TPtrC iapName; + + if( KErrNone != aItem.GetNextString(iapName) ) + { + VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name was not specified."); + iLog->Log( _L("** FAIL ** Invalid testcase parameter! Iap name was not specified.") ); + VCXLOGLO1("<<GetIapIdL( iapName, iapId ) ) + { + VCXLOGLO2("** FAIL ** Could not find iap with name %S.", &iapName); + iLog->Log( _L("** FAIL ** Could not find specified iap.") ); + VCXLOGLO1("<<WaitForConnection(iapId); + + VCXLOGLO1("<<>>CIptvTestUtilModule::WaitUntilConnectionIsClosed"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In WaitForConnectionActivityL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt err = KErrNone; + + TRAP(err, PrintIAPs() ); + + TPtrC iapName; + + if(KErrNone != aItem.GetNextString(iapName) ) + { + VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name was not specified."); + iLog->Log( _L("** FAIL ** Invalid testcase parameter! Iap name was not specified.") ); + VCXLOGLO1("<<GetIapIdL(iapName, iapId)) + { + VCXLOGLO2("** FAIL ** Could not find iap with name %S.", &iapName); + iLog->Log( _L("** FAIL ** Could not find specified iap.") ); + VCXLOGLO1("<<WaitUntilConnectionIsClosed(iapId); + + VCXLOGLO1("<<>>CIptvTestUtilModule::TimerComplete"); + VCXLOGLO2(">>>CIptvTestUtilModule:: aError: %d", aError); + + if(aError == KErrNone && aTimerId == KConnectionTimerId) + { + VCXLOGLO1("* ERROR * Connection timedout!"); + Signal(KErrTimedOut); + } + + VCXLOGLO1("<<>>CIptvTestUtilModule::AdvanceSystemTime1Second"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AdvanceSystemTime1Second" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = CVCXTestCommon::AdvanceSystemTimeSeconds(1); + + VCXLOGLO1("<<>>CIptvTestUtilModule::AdvanceSystemTimeSeconds"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AdvanceSystemTimeSeconds" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt count; + if(aItem.GetNextInt(count) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::AdvanceSystemTimeMinutes"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AdvanceSystemTimeMinutes" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt count; + if(aItem.GetNextInt(count) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::AdvanceSystemTimeHours"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AdvanceSystemTimeHours" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt count; + if(aItem.GetNextInt(count) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::AdvanceSystemTimeDays"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In AdvanceSystemTimeDays" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt daysInt; + if(aItem.GetNextInt(daysInt) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter days missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::SetSystemTime"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetSystemTime" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC dayString; + if(aItem.GetNextString(dayString) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::SetSystemTimeToday"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetSystemTimeToday" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt hour( 0 ); + TInt minute( 0 ); + + aItem.GetNextInt( hour ); + aItem.GetNextInt( minute ); + + TTime time; + TBuf<256> timeString; + time.HomeTime(); + time.FormatL( timeString, KDateTimeString ); + VCXLOGLO2("CIptvTestUtilModule::SetSystemTimeToday -- HomeTime() %S", &timeString); + + TDateTime dateTime( time.DateTime() ); + dateTime = time.DateTime(); + dateTime.SetHour( hour ); + dateTime.SetMinute( minute ); + + time = dateTime; + time.FormatL( timeString, KDateTimeString ); + VCXLOGLO2("CIptvTestUtilModule::SetSystemTimeToday -- System time set to: %S", &timeString); + + /* + time.UniversalTime(); + time.FormatL( timeString, KDateTimeString ); + VCXLOGLO2("CIptvTestUtilModule::SetSystemTimeToday -- Universal time: %S", &timeString); + */ + + TInt err = CVCXTestCommon::SetSystemTime(time); + + VCXLOGLO1("<<>>CIptvTestUtilModule::SetTimeZone"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetTimeZone" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC timeZone; + if(aItem.GetNextString(timeZone) != KErrNone) + { + VCXLOGLO1("* ERROR * Parameter missing."); + VCXLOGLO1("<<>>CIptvTestUtilModule::CreateMobilecrashWatcherL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In CreateMobilecrashWatcherL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if(iIptvTestMobilecrashWatcher) + { + delete iIptvTestMobilecrashWatcher; + iIptvTestMobilecrashWatcher = NULL; + } + + iIptvTestMobilecrashWatcher = CIptvTestMobilecrashWatcher::NewL(EFalse); + + VCXLOGLO1("<<>>CIptvTestUtilModule::CheckMobilecrashesL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In CheckMobilecrashesl" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if(!iIptvTestMobilecrashWatcher) + { + VCXLOGLO1("<< crashes; + if(iIptvTestMobilecrashWatcher->ReturnNewCrashes(crashes)) + { + VCXLOGLO1("<<>>CIptvTestUtilModule::CheckMobilecrashesZeroToleranceL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In CheckMobilecrashesl" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if(!iIptvTestMobilecrashWatcher) + { + iIptvTestMobilecrashWatcher = CIptvTestMobilecrashWatcher::NewL(EFalse); + } + + TInt ret = KErrNone; + if(iIptvTestMobilecrashWatcher->ReturnMobileCrashCount() > 0) + { + ret = KErrAbort; + } + + VCXLOGLO2("<<>>CIptvTestUtilModule::DeleteUsedDestinationCenRepL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In DeleteUsedDestinationCenRepL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNone ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TRAP( ret, iTestUtilALR->RemoveUsedDestinationCenRepL() ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetDefaultIapCenRep"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetDefaultIapCenRep" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNone ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TRAP( ret, iTestUtilALR->SetDefaultIapCenRep() ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetUsedDestinationL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetUsedDestinationL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNone ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + + TRAP( ret, iTestUtilALR->SetUsedDestinationL( destinationName ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::CreateDestinationL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In CreateDestinationL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + + TRAP(ret, iTestUtilALR->CreateDestinationL( destinationName ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::DeleteDestinationL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In DeleteDestinationL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + + TRAP(ret, iTestUtilALR->DeleteDestinationL( destinationName ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::CopyMethodL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In CopyMethodL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC sourceMethodName; + TPtrC targetMethodName; + TPtrC targetDestinationName; + + User::LeaveIfError( aItem.GetNextString( sourceMethodName ) ); + User::LeaveIfError( aItem.GetNextString( targetMethodName ) ); + User::LeaveIfError( aItem.GetNextString( targetDestinationName ) ); + + TRAP(ret, iTestUtilALR->CopyMethodL( sourceMethodName, targetMethodName, targetDestinationName ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::DeleteMethodL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In DeleteMethodL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + TPtrC methodName; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + User::LeaveIfError( aItem.GetNextString( methodName ) ); + + TRAP(ret, iTestUtilALR->DeleteMethodL( destinationName, methodName ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetMethodPriorityL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetMethodPriorityL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + TPtrC methodName; + TInt priority; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + User::LeaveIfError( aItem.GetNextString( methodName ) ); + User::LeaveIfError( aItem.GetNextInt( priority ) ); + + TRAP(ret, iTestUtilALR->SetMethodPriorityL( destinationName, methodName, priority ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::DeleteDestinationAfterwardsL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In DeleteDestinationAfterwardsL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + + iToBeDeletedDestinations.AppendL( destinationName.AllocL() ); + + ret = KErrNone; + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetConnectionMethodStringAttributeL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetConnectionMethodStringAttributeL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + TPtrC methodName; + TInt attribute; + TPtrC value; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + User::LeaveIfError( aItem.GetNextString( methodName ) ); + User::LeaveIfError( aItem.GetNextInt( attribute ) ); + User::LeaveIfError( aItem.GetNextString( value ) ); + + TRAP(ret, iTestUtilALR->SetMethodStringAttributeL( destinationName, methodName, attribute, value ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetConnectionMethodIntAttributeL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetConnectionMethodIntAttributeL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + TPtrC methodName; + TInt attribute; + TInt value; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + User::LeaveIfError( aItem.GetNextString( methodName ) ); + User::LeaveIfError( aItem.GetNextInt( attribute ) ); + User::LeaveIfError( aItem.GetNextInt( value ) ); + + TRAP(ret, iTestUtilALR->SetMethodIntAttributeL( destinationName, methodName, attribute, value ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::SetConnectionMethodBoolAttributeL"); + // Print to UI + _LIT( KIptvTestUtilConnect, "IptvTestUtilModule" ); + _LIT( KWhere, "In SetConnectionMethodBoolAttributeL" ); + TestModuleIf().Printf( 0, KIptvTestUtilConnect, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt ret( KErrNotSupported ); + + if( !iTestUtilALR ) + { + iTestUtilALR = CIptvTestUtilALR::NewL(); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destinationName; + TPtrC methodName; + TInt attribute; + TInt value; + + User::LeaveIfError( aItem.GetNextString( destinationName ) ); + User::LeaveIfError( aItem.GetNextString( methodName ) ); + User::LeaveIfError( aItem.GetNextInt( attribute ) ); + User::LeaveIfError( aItem.GetNextInt( value ) ); + + TRAP(ret, iTestUtilALR->SetMethodBoolAttributeL( destinationName, methodName, attribute, static_cast(value) ) ); + + VCXLOGLO2("<<>>CIptvTestUtilModule::CreateFileL"); + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC fileName; + User::LeaveIfError( aItem.GetNextString( fileName ) ); + + RFile file; + CleanupClosePushL(file); + TInt err = file.Replace(iFs, fileName, EFileWrite); + CleanupStack::PopAndDestroy( &file ); + VCXLOGLO2("<<>>CIptvTestUtilModule::DeleteFileL"); + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC fileName; + User::LeaveIfError( aItem.GetNextString( fileName ) ); + TInt err = iFs.Delete( fileName ); + VCXLOGLO2("<<>>CIptvTestUtilModule::CreateFolderL"); + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path ) ); + BaflUtils::EnsurePathExistsL(iFs, path); + VCXLOGLO1("<<>>CIptvTestUtilModule::DeleteFolderL"); + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path ) ); + CFileMan* fileMan = CFileMan::NewL(iFs); + CleanupStack::PushL(fileMan); + fileMan->RmDir( path ); + CleanupStack::PopAndDestroy( fileMan ); + VCXLOGLO1("<<>>CIptvTestUtilModule::LockFileL"); + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + TPtrC fileName; + User::LeaveIfError( aItem.GetNextString( fileName ) ); + + TInt err( KErrInUse ); + if( !iFileIsLocked ) + { + err = iLockedFile.Open(iFs, fileName, EFileShareExclusive | EFileOpen); + iFileIsLocked = ETrue; + } + VCXLOGLO2("<<>>CIptvTestUtilModule::UnlockFileL"); + if( iFileIsLocked ) + { + iLockedFile.Close(); + } + iFileIsLocked = EFalse; + VCXLOGLO1("<<>>CIptvTestUtilModule::SetDriveFreeSpaceL"); + // Print to UI + _LIT( KWhere, "IptvTestUtilModule" ); + _LIT( KSetCFreeSpace, "In SetDriveFreeSpaceL" ); + TestModuleIf().Printf( 0, KWhere, KSetCFreeSpace ); + // Print to log file + iLog->Log( KSetCFreeSpace ); + + TPtrC driveLetter; + User::LeaveIfError(aItem.GetNextString( driveLetter )); + + VCXLOGLO2("CVCXTestCommon:: drive: %S", &driveLetter); + + TInt driveNumber(0); + User::LeaveIfError( iFs.CharToDrive( driveLetter[0], driveNumber ) ); + + TUint desiredSpace(0); + User::LeaveIfError(aItem.GetNextInt( desiredSpace )); + + VCXLOGLO2("CVCXTestCommon:: desired space: %d", desiredSpace); + + iDummyFilesCreated = ETrue; + + iTestCommon->SetDriveFreeSpaceL( driveNumber, desiredSpace ); + + VCXLOGLO1("<<>>CIptvTestUtilModule::ExtractFile"); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC zipFileName; + User::LeaveIfError(aItem.GetNextString( zipFileName )); + + TPtrC sourceFileName; + User::LeaveIfError(aItem.GetNextString( sourceFileName )); + + TPtrC destFileName; + User::LeaveIfError(aItem.GetNextString( destFileName )); + + iFs.Delete( sourceFileName ); + + CZipFile* zipFile; + TRAPD(err, zipFile = CZipFile::NewL( iFs, zipFileName ) ); + + if( err != KErrNone ) + { + VCXLOGLO2("CIptvTestUtilModule:: error %d", err); + delete zipFile; + return err; + } + + VCXLOGLO2("CIptvTestUtilModule:: zipFileName: %S", &zipFileName); + VCXLOGLO2("CIptvTestUtilModule:: sourceFileName: %S", &sourceFileName); + VCXLOGLO2("CIptvTestUtilModule:: destFileName: %S", &destFileName); + + if( !FileExistsInZip( zipFile, sourceFileName ) ) + { + VCXLOGLO1("CIptvTestUtilModule:: No such file in zip! Leaving.."); + delete zipFile; + User::Leave( KErrNotFound ); + } + + // Get zip file member from the archive + VCXLOGLO1("CIptvTestUtilModule:: Get zip file member from the archive"); + CZipFileMember* member = zipFile->CaseInsensitiveMemberL( sourceFileName ); + if( member == NULL ) + { + VCXLOGLO1("CIptvTestUtilModule:: zip member is null. Leaving.."); + delete zipFile; + User::Leave(KErrGeneral); + } + CleanupStack::PushL( member ); + + // Get read stream for the file + VCXLOGLO1("CIptvTestUtilModule:: Get read stream for the file"); + RZipFileMemberReaderStream* stream; + zipFile->GetInputStreamL( member, stream ); + CleanupStack::PushL( stream ); + + // Alloc buffer and read the archived file + VCXLOGLO1("CIptvTestUtilModule:: Alloc buffer and read the archived file"); + HBufC8* buffer = HBufC8::NewLC( member->UncompressedSize() ); + TPtr8 bufferPtr( buffer->Des() ); + User::LeaveIfError( stream->Read( bufferPtr, member->UncompressedSize() ) ); + + // Write the file to the filesystem + VCXLOGLO1("CIptvTestUtilModule:: Write the file to the filesystem"); + RFile file; + User::LeaveIfError( file.Replace( iFs, destFileName, EFileWrite ) ); + CleanupClosePushL( file ); + User::LeaveIfError( file.Write(*buffer) ); + + delete zipFile; + CleanupStack::PopAndDestroy( &file ); + CleanupStack::PopAndDestroy( buffer ); + CleanupStack::PopAndDestroy( stream ); + CleanupStack::PopAndDestroy( member ); + + VCXLOGLO1("<<>>CIptvTestVerifyData::FileExistsInZip"); + + CZipFileMember* member = NULL; + + VCXLOGLO1("CIptvTestVerifyData:: list of members"); + CZipFileMemberIterator* members = aZipFile->GetMembersL(); + + VCXLOGLO1("CIptvTestVerifyData:: loop all members"); + + while ((member = members->NextL()) != 0) + { + VCXLOGLO3("CIptvTestVerifyData:: member %S, size: %d", &(*member->Name()), member->CompressedSize()); + + if( aFileName == (*member->Name()) ) + { + delete member; + delete members; + VCXLOGLO1("<< Setup and cleanup +create VCXTestUtilModule Util + +Util CopyMethod "Internet" "Internet" "Internet" +// Disable connection dialog for "Internet" destination. +Util SetConnectionMethodIntAttribute "Internet" "Internet" ECmSeamlessnessLevel 2 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 + +delete Util +[Endtest] + +[Test] +title ET31126 Create and destroy +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase + +VCXCONN Create "MASTERPS" + +print created +pause 3000 +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +print pausing +pause 3000 +print OK! + +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31101 Connect to destination with 1 IAP +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31102 Connect to destination with 2 IAPs +create VCXTestUtilModule Util + +// Destination with 2 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP2 0 +Util SetMethodPriority DEST_TEST AP1 1´ + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP2 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31103 Connect to destination with 10 IAPs +create VCXTestUtilModule Util + +// Destination with 10 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util CopyMethod 3G_AP AP3 DEST_TEST +Util CopyMethod 3G_AP AP4 DEST_TEST +Util CopyMethod 3G_AP AP5 DEST_TEST +Util CopyMethod 3G_AP AP6 DEST_TEST +Util CopyMethod 3G_AP AP7 DEST_TEST +Util CopyMethod 3G_AP AP8 DEST_TEST +Util CopyMethod 3G_AP AP9 DEST_TEST +Util CopyMethod 3G_AP AP10 DEST_TEST + +Util SetMethodPriority DEST_TEST AP5 0 +Util SetMethodPriority DEST_TEST AP1 1 +Util SetMethodPriority DEST_TEST AP2 2 +Util SetMethodPriority DEST_TEST AP3 3 +Util SetMethodPriority DEST_TEST AP4 4 +Util SetMethodPriority DEST_TEST AP6 5 +Util SetMethodPriority DEST_TEST AP7 6 +Util SetMethodPriority DEST_TEST AP8 7 +Util SetMethodPriority DEST_TEST AP9 8 +Util SetMethodPriority DEST_TEST AP10 9 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP5 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31108 Connect, disconnect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +pause 3000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31109 Connect, disconnect, connect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +pause 3000 +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31110 Connect, disconnect, disconnect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31111 Disconnect without connection, then connect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN Disconnect +waittestclass VCXCONN + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +pause 3000 +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31112 2nd IAP priority changes during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +pause 1000 +Util SetMethodPriority DEST_TEST AP2 0 + +pause 5000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31113 IAP priority changes during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +pause 1000 +Util SetMethodPriority DEST_TEST AP1 1 + +pause 5000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31114 2nd IAP removed during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +Util DeleteMethod DEST_TEST AP2 + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31115 Another app connected to the dest, connect 1 +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect AP1 +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31116 Another app connected to the dest, connect 2 +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect 3G_AP +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity 3G_AP +waittestclass Util + +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31117 Another app connected to 2nd dest, connect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect 3G_AP +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity 3G_AP +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31118 Connect, another app connects, disconnect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +Util Connect AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails + +pause 4000 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31120 Connect 2nd dest when connected to 1st already +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN GetIap "Internet" +waittestclass VCXCONN + +pause 2000 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31121 Connect 2nd dest, disconnect, connect to 1st +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 +pause 1000 +Util CreateDestination DEST_TEST2 +Util DeleteDestinationAfterwards DEST_TEST2 +Util CopyMethod 3G_AP AP3 DEST_TEST2 +Util SetMethodPriority DEST_TEST2 AP3 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +VCXCONN GetIap DEST_TEST2 +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31122 Connect, disconnect, change IAP prio, repeat +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP2 +waittestclass Util + +Util SetMethodPriority DEST_TEST AP2 0 +Util SetMethodPriority DEST_TEST AP1 1 + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP2 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP2 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31123 Connect, terminate connection 2nd app, connect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +Util Attach AP1 +Util Terminate +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +pause 5000 + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +pause 5000 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31124 Connect, terminate connection 2nd app, disconnect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 +pause 2000 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util +pause 500 + +Util Attach AP1 +pause 500 +Util Terminate +pause 500 +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +pause 500 +VCXCONN Disconnect +waittestclass VCXCONN +pause 500 +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31125 Connect, delete instance +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +delete Util +[Endtest] + +[Test] +title ET31131 WapIdFromIapIdL +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN WapIdFromIapId AP2 +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +[Test] +title ET31132 WapIdFromIapIdL invalid IAP ID +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN WapIdFromIapId "invalidiap" +allownextresult KERRNOTFOUND +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestMasterAndSlave.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestMasterAndSlave.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,504 @@ +#*********************************************************************************** +# +# STIF test script file for testing vcxconnectionutility.dll. +# +#*********************************************************************************** + +[StifSettings] +CapsModifier= IptvTestClientApiCapsMod.exe +[EndStifSettings] + +[Define] +INCLUDE c:\testframework\VCXConnUtilTest.inc +INCLUDE c:\testframework\VCXDrives.inc +INCLUDE c:\testframework\VCXConsts.inc +INCLUDE c:\testframework\VCXErrors.inc +[Enddefine] + +// NotAllowedProperty etc queued + + +#************************************************************************************ + +#------------------------------------------------------------------------------------ +# +# Setup the environment. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31000 Setup and cleanup +create VCXTestUtilModule Util + +Util CopyMethod "Internet" "Internet" "Internet" +// Disable connection dialog for "Internet" destination. +Util SetConnectionMethodIntAttribute "Internet" "Internet" ECmSeamlessnessLevel 2 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 + +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31001 Master only +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +MASTER Disconnect +waittestclass MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +delete MASTER + +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31002 Master and slave - no disconnect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity +SLAVE GetIap DEST_TEST +waittestclass SLAVE +pause 2000 +CONNPS CheckProperty EVCxPSNbrConnInstances 2 +CONNPS CheckProperty EVCxPSMasterExists 1 + +delete SLAVE + +delete MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31003 Master and two slaves - no disconnect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity +SLAVE GetIap DEST_TEST +waittestclass SLAVE + +create VCXConnUtilTest SLAVE2 +SLAVE2 Create "SLAVE2" KVcxConnUtilTestModeConnectivity +SLAVE2 GetIap DEST_TEST +waittestclass SLAVE2 +pause 4000 +CONNPS CheckProperty EVCxPSNbrConnInstances 3 +CONNPS CheckProperty EVCxPSMasterExists 1 + +delete SLAVE2 + +pause 2000 +CONNPS CheckProperty EVCxPSNbrConnInstances 2 +delete SLAVE + +pause 2000 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +delete MASTER +pause 2000 + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31004 Slave disconnect before master +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity +SLAVE GetIap DEST_TEST +waittestclass SLAVE +SLAVE Disconnect +waittestclass SLAVE +pause 2000 + +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 1 +CONNPS CheckProperty EVCxPSMasterExists 1 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +MASTER Disconnect +waittestclass MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +CONNPS CheckProperty EVCxPSConnectionStatus EVCxNotConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 0 +CONNPS CheckProperty EVCxPSMasterExists 0 + +delete SLAVE +delete MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31005 Master disconnect before slave +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +// Create and connect master and slave + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity +SLAVE GetIap DEST_TEST +waittestclass SLAVE + +MASTER Disconnect +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util + +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 1 +CONNPS CheckProperty EVCxPSMasterExists 1 + +SLAVE Disconnect +waittestclass SLAVE +pause 2000 + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +CONNPS CheckProperty EVCxPSConnectionStatus EVCxNotConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 0 +CONNPS CheckProperty EVCxPSMasterExists 0 + +delete SLAVE + +delete MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31006 Master and slave disconnect and connect again +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +// Create and connect master and slave + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity +MASTER GetIap DEST_TEST +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity +SLAVE GetIap DEST_TEST +waittestclass SLAVE + +// Disconnect both +MASTER Disconnect +waittestclass MASTER +pause 2000 +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 1 +CONNPS CheckProperty EVCxPSMasterExists 1 + +SLAVE Disconnect +waittestclass SLAVE +pause 2000 + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxNotConnected +CONNPS CheckProperty EVCxPSNbrConnInstances 0 +CONNPS CheckProperty EVCxPSMasterExists 0 + +// Connect again + +SLAVE GetIap DEST_TEST +waittestclass SLAVE + +Util WaitForConnectionActivity AP1 +waittestclass Util +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 1 + +MASTER GetIap DEST_TEST +waittestclass MASTER +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 2 + +delete SLAVE +delete MASTER + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31007 No master, two instances connect same time. +timeout 120000 // 2 minutes + +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest CONNPS +CONNPS Create "PS" KVcxConnUtilTestModeSubscriber + +create VCXConnUtilTest MASTER +MASTER Create "MASTER" KVcxConnUtilTestModeConnectivity + +create VCXConnUtilTest SLAVE +SLAVE Create "SLAVE" KVcxConnUtilTestModeConnectivity + +// These two GetIap calls are timed to be executed at the same time +MASTER GetIap DEST_TEST 1 +SLAVE GetIap DEST_TEST 1 + +waittestclass SLAVE +waittestclass MASTER + +Util WaitForConnectionActivity AP1 +waittestclass Util + +CONNPS CheckProperty EVCxPSConnectionStatus EVCxConnected +CONNPS CheckProperty EVCxPSMasterExists 1 +CONNPS CheckProperty EVCxPSNbrConnInstances 2 + +delete MASTER + +delete SLAVE + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +CONNPS PrintConnUtilDetails +CONNPS CheckProperty EVCxPSNbrConnInstances 0 + +delete CONNPS +pause 3000 +delete Util +[Endtest] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestSNAP.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestSNAP.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1517 @@ +#*********************************************************************************** +# +# STIF test script file for testing vcxconnectionutility.dll. +# +#*********************************************************************************** + +[StifSettings] +CapsModifier= IptvTestClientApiCapsMod.exe +[EndStifSettings] + +[Define] +INCLUDE c:\testframework\VCXConnUtilTest.inc +INCLUDE c:\testframework\VCXDrives.inc +INCLUDE c:\testframework\VCXConsts.inc +INCLUDE c:\testframework\VCXErrors.inc +[Enddefine] + +#------------------------------------------------------------------------------------ +# +# Setup the environment. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31100 Setup and cleanup +create VCXTestUtilModule Util + +Util CopyMethod "Internet" "Internet" "Internet" +// Disable connection dialog for "Internet" destination. +Util SetConnectionMethodIntAttribute "Internet" "Internet" ECmSeamlessnessLevel 2 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 + +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31126 Create and destroy +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase + +VCXCONN Create "MASTERPS" + +print created +pause 3000 +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +print pausing +pause 3000 +print OK! + +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31101 Connect to destination with 1 IAP +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31102 Connect to destination with 2 IAPs +create VCXTestUtilModule Util + +// Destination with 2 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP2 0 +Util SetMethodPriority DEST_TEST AP1 1´ + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP2 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31103 Connect to destination with 10 IAPs +create VCXTestUtilModule Util + +// Destination with 10 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util CopyMethod 3G_AP AP3 DEST_TEST +Util CopyMethod 3G_AP AP4 DEST_TEST +Util CopyMethod 3G_AP AP5 DEST_TEST +Util CopyMethod 3G_AP AP6 DEST_TEST +Util CopyMethod 3G_AP AP7 DEST_TEST +Util CopyMethod 3G_AP AP8 DEST_TEST +Util CopyMethod 3G_AP AP9 DEST_TEST +Util CopyMethod 3G_AP AP10 DEST_TEST + +Util SetMethodPriority DEST_TEST AP5 0 +Util SetMethodPriority DEST_TEST AP1 1 +Util SetMethodPriority DEST_TEST AP2 2 +Util SetMethodPriority DEST_TEST AP3 3 +Util SetMethodPriority DEST_TEST AP4 4 +Util SetMethodPriority DEST_TEST AP6 5 +Util SetMethodPriority DEST_TEST AP7 6 +Util SetMethodPriority DEST_TEST AP8 7 +Util SetMethodPriority DEST_TEST AP9 8 +Util SetMethodPriority DEST_TEST AP10 9 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP5 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# Note: Disabled, shows IAP query notification. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31104 Connect to destination with no IAP +#create VCXTestUtilModule Util +# +#Destination with no IAPs +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +#allownextresult KERRGENERAL +#VCXCONN GetIap DEST_TEST +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# Note: Disabled, shows IAP query notification. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31106 Connect to destination with working and bad IAPs +#create VCXTestUtilModule Util + +#// Destination with good and bad IAP +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP1 DEST_TEST +#Util CopyMethod BAD_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP1 0 +#Util SetMethodPriority DEST_TEST AP2 1 + +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN + +#Util WaitForConnectionActivity AP1 +#waittestclass Util +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31107 Connect to destination with bad and working IAPs +#create VCXTestUtilModule Util +# +#// Destination with bad and good IAP +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod BAD_AP AP1 DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP1 0 +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#VCXCONN GetIap DEST_TEST +#allowerrorcodes KERRGENERAL +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP2 +#allowerrorcodes KERRTIMEDOUT +#waittestclass Util +# +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31108 Connect, disconnect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +pause 3000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31109 Connect, disconnect, connect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +pause 3000 +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31110 Connect, disconnect, disconnect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31111 Disconnect without connection, then connect +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN Disconnect +waittestclass VCXCONN + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +pause 3000 +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31112 2nd IAP priority changes during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +pause 1000 +Util SetMethodPriority DEST_TEST AP2 0 + +pause 5000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31113 IAP priority changes during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +pause 1000 +Util SetMethodPriority DEST_TEST AP1 1 + +pause 5000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31114 2nd IAP removed during connection +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +Util DeleteMethod DEST_TEST AP2 + +pause 5000 + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31115 Another app connected to the dest, connect 1 +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect AP1 +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31116 Another app connected to the dest, connect 2 +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect 3G_AP +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity 3G_AP +waittestclass Util + +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31117 Another app connected to 2nd dest, connect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +Util Connect 3G_AP +waittestclass Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails + +Util Disconnect +pause 3000 + +Util WaitForConnectionActivity 3G_AP +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31118 Connect, another app connects, disconnect +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +Util Connect AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails + +pause 4000 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31120 Connect 2nd dest when connected to 1st already +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN GetIap "Internet" +waittestclass VCXCONN + +pause 2000 + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31121 Connect 2nd dest, disconnect, connect to 1st +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 +pause 1000 +Util CreateDestination DEST_TEST2 +Util DeleteDestinationAfterwards DEST_TEST2 +Util CopyMethod 3G_AP AP3 DEST_TEST2 +Util SetMethodPriority DEST_TEST2 AP3 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +VCXCONN GetIap DEST_TEST2 +waittestclass VCXCONN +VCXCONN PrintConnUtilDetails +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31122 Connect, disconnect, change IAP prio, repeat +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP2 +waittestclass Util + +Util SetMethodPriority DEST_TEST AP2 0 +Util SetMethodPriority DEST_TEST AP1 1 + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP2 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP2 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31123 Connect, terminate connection 2nd app, connect +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP1 DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP1 0 +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP1 +#waittestclass Util +# +#Util Attach AP1 +#Util Terminate +#Util WaitUntilConnectionIsClosed AP1 +#waittestclass Util +# +#pause 5000 +# +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#pause 5000 +# +#Util WaitForConnectionActivity AP1 +#waittestclass Util +# +#VCXCONN Disconnect +#waittestclass VCXCONN +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31124 Connect, terminate connection 2nd app, disconnect +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP1 DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP1 0 +#Util SetMethodPriority DEST_TEST AP2 1 +#pause 2000 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP1 +#waittestclass Util +#pause 500 +# +#Util Attach AP1 +#pause 500 +#Util Terminate +#pause 500 +#Util WaitUntilConnectionIsClosed AP1 +#waittestclass Util +#pause 500 +#VCXCONN Disconnect +#waittestclass VCXCONN +#pause 500 +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31125 Connect, delete instance +create VCXTestUtilModule Util + +// Destination with 1 working IAP +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +Util WaitForConnectionActivity AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN + +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31127 Roaming - Connect 3G, WLAN becomes available +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxConnected +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxRoamingRequest +#VCXCONN AddWaitedProperty EVCxPSNbRoamAccepted 1 +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxConnected +# +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#Util CopyMethod WLAN_AP AP3 DEST_TEST +#Util SetMethodPriority DEST_TEST AP3 0 +# +#VCXCONN WaitForPropertyQueue +#waittestclass VCXCONN +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#Util WaitForConnectionActivity AP3 +#waittestclass Util +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +#title ET31128 Roaming - Connect WLAN, 3G becomes available +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod WLAN_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#Util CopyMethod 3G_AP AP3 DEST_TEST +#Util SetMethodPriority DEST_TEST AP3 0 +# +#pause 5000 +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +# +#Util WaitUntilConnectionIsClosed AP3 +#waittestclass Util +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31129 Roaming - Connect WLAN, another WLAN becomes available +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod WLAN_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#Util CopyMethod WLAN_AP2 AP3 DEST_TEST +#Util SetMethodPriority DEST_TEST AP3 0 +# +#pause 5000 +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +# +#Util WaitUntilConnectionIsClosed AP3 +#waittestclass Util +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxNotConnected +# +#VCXCONN Disconnect +#waittestclass VCXCONN +# +#VCXCONN WaitForPropertyQueue +#waittestclass VCXCONN +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31130 Roaming not allowed - Connect 3G, WLAN becomes available +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxConnected +#//VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxRoamingRequest +#VCXCONN AddWaitedProperty EVCxPSNbRoamAccepted 0 +#VCXCONN AddWaitedProperty EVCxPSConnectionStatus EVCxConnected +# +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +#VCXCONN SetRoamingAllowed 0 +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#Util CopyMethod WLAN_AP AP3 DEST_TEST +#Util SetMethodPriority DEST_TEST AP3 0 +# +#VCXCONN WaitForPropertyQueue +#waittestclass VCXCONN +# +#Util WaitForConnectionActivity AP2 +#waittestclass Util +# +#Util WaitUntilConnectionIsClosed AP3 +#waittestclass Util +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31131 WapIdFromIapIdL +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN WapIdFromIapId AP2 +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31132 WapIdFromIapIdL invalid IAP ID +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN WapIdFromIapId "invalidiap" +allownextresult KERRNOTFOUND +waittestclass VCXCONN + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31133 Connect, default SNAP changes, connect again +create VCXTestUtilModule Util + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 +pause 1000 + +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 + +Util CreateDestination DEST_TEST2 +Util DeleteDestinationAfterwards DEST_TEST2 +Util CopyMethod 3G_AP AP2 DEST_TEST2 +Util SetMethodPriority DEST_TEST2 AP2 0 + +create VCXConnUtilTest VCXCONN +VCXCONN PrepareCase +VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth + +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +// wait for connection +Util WaitForConnectionActivity AP1 +print Wait for ap1 +waittestclass Util + +// disconnect, wait for disconnect +print Disconnect ap1 +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +// set DEST_TEST2 as default +print default dest_test2 +Util SetUsedDestination DEST_TEST2 + +// attempt to connect to DEST_TEST +print connect dest_test +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN + +// wait for connection on AP2 +print Wait for ap2 +Util WaitForConnectionActivity AP2 +waittestclass Util + +print Disconnect AP2 +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +print OK! +VCXCONN ShutdownTester +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtility class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31134 Default SNAP has no IAPs, connect +#create VCXTestUtilModule Util +# +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST2 +#pause 1000 +# +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +# +#Util CreateDestination DEST_TEST2 +#Util DeleteDestinationAfterwards DEST_TEST2 +#Util CopyMethod 3G_AP AP2 DEST_TEST2 +#Util SetMethodPriority DEST_TEST2 AP2 0 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN PrepareCase +#VCXCONN Create "MASTERPS" KVcxConnUtilTestModeBoth +# +#print connect default +#VCXCONN GetIap DEST_TEST +#allownextresult KERRGENERAL +#waittestclass VCXCONN +# +#print connect dest_test2 +#VCXCONN GetIap DEST_TEST2 +#allownextresult KERRGENERAL +#waittestclass VCXCONN +# +#VCXCONN PrintConnUtilDetails +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +# +#print OK! +#VCXCONN ShutdownTester +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestStates.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXConnUtilTestStates.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,238 @@ +#*********************************************************************************** +# +# STIF test script file for testing vcxconnectionutility.dll. +# +#*********************************************************************************** + +[StifSettings] +CapsModifier= IptvTestClientApiCapsMod.exe +[EndStifSettings] + +[Define] +INCLUDE c:\testframework\VCXConnUtilTest.inc +INCLUDE c:\testframework\VCXDrives.inc +INCLUDE c:\testframework\VCXConsts.inc +INCLUDE c:\testframework\VCXErrors.inc +[Enddefine] + +#------------------------------------------------------------------------------------ +# +# Setup the environment. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31180 Setup and cleanup +create VCXTestUtilModule Util + +Util CopyMethod "Internet" "Internet" "Internet" +// Disable connection dialog for "Internet" destination. +Util SetConnectionMethodIntAttribute "Internet" "Internet" ECmSeamlessnessLevel 2 + +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST2 + +delete VCXCONN +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31181 Initial state +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN Create + +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected + +print OK! +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31182 Connect, state +create VCXTestUtilModule Util + +// Destination with 2 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN Create +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31183 Connect, disconnect, state +create VCXTestUtilModule Util + +// Destination with 2 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN Create +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN Disconnect +waittestclass VCXCONN + +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +Util WaitUntilConnectionIsClosed AP1 + +print OK! +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31184 Disconnect wo connection, state +create VCXTestUtilModule Util + +create VCXConnUtilTest VCXCONN +VCXCONN Create + +VCXCONN Disconnect +waittestclass VCXCONN +Util WaitUntilConnectionIsClosed AP1 +waittestclass Util + +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected + +print OK! +delete VCXCONN +pause 3000 +delete Util +[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +#[Test] +#title ET31186 Connection terminated by another app, state +#create VCXTestUtilModule Util +# +#// Destination with 2 working IAPs +#allowerrorcodes KERRNOTFOUND +#Util DeleteDestination DEST_TEST +#pause 1000 +#Util CreateDestination DEST_TEST +#Util SetUsedDestination DEST_TEST +#Util DeleteDestinationAfterwards DEST_TEST +#Util CopyMethod 3G_AP AP1 DEST_TEST +#Util CopyMethod 3G_AP AP2 DEST_TEST +#Util SetMethodPriority DEST_TEST AP1 0 +#Util SetMethodPriority DEST_TEST AP2 1 +# +#create VCXConnUtilTest VCXCONN +#VCXCONN Create +#VCXCONN GetIap DEST_TEST +#waittestclass VCXCONN +#Util WaitForConnectionActivity AP1 +#waittestclass Util +# +#Util Attach AP1 +#Util Terminate AP1 +#Util WaitUntilConnectionIsClosed AP1 +#waittestclass Util +# +#pause 5000 +#VCXCONN CheckProperty EVCxPSConnectionStatus EVCxNotConnected +# +#print OK! +#delete VCXCONN +#pause 3000 +#delete Util +#[Endtest] + +#------------------------------------------------------------------------------------ +# +# Test CVcxConnUtilEngine class. +# +#------------------------------------------------------------------------------------ +[Test] +title ET31187 Connect, connect again, state +create VCXTestUtilModule Util + +// Destination with 2 working IAPs +allowerrorcodes KERRNOTFOUND +Util DeleteDestination DEST_TEST +pause 1000 +Util CreateDestination DEST_TEST +Util SetUsedDestination DEST_TEST +Util DeleteDestinationAfterwards DEST_TEST +Util CopyMethod 3G_AP AP1 DEST_TEST +Util CopyMethod 3G_AP AP2 DEST_TEST +Util SetMethodPriority DEST_TEST AP1 0 +Util SetMethodPriority DEST_TEST AP2 1 + +create VCXConnUtilTest VCXCONN +VCXCONN Create +VCXCONN GetIap DEST_TEST +waittestclass VCXCONN +Util WaitForConnectionActivity AP1 +waittestclass Util + +VCXCONN GetIap DEST_TEST + +VCXCONN CheckProperty EVCxPSConnectionStatus EVCxConnected + +print OK! +delete VCXCONN +pause 3000 +delete Util +[Endtest] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXConsts.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXConsts.inc Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,16 @@ +TRUE 1 +FALSE 0 +SYNC 0 +ASYNC 1 +FAKE 13579 + +DEFAULT_DEST "Internet" + +3G_AP "Internet" +3G_AP2 "Internet2" +WLAN_AP "Wlan" +WLAN_AP2 "Wlan2" +EMULATOR_AP "Ethernet with Daemon Dynamic IP" +BAD_AP "BadIap" // CIptvTestUtilities::GetIapIdL returns AP that does not work +INVALID_AP "invalidiap" // CIptvTestUtilities::GetIapIdL returns invalid AP ID +DEFAULT_AP "default" // used via CIptvTestUtilALR::GetDefaultIap diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXDrives.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXDrives.inc Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,24 @@ +// +// C is not used by Video Center when phone has F drive, change these accordingly. +// +// If phone has only C and E drives: +// C_DRIVE e +// E_DRIVE f +// +// If phone has F drive: +// C_DRIVE e +// E_DRIVE f +// + +A_DRIVE a +C_DRIVE e +E_DRIVE f +O_DRIVE o +Z_DRIVE z + +ANY_DRIVE "anydrive" + +// Don't change these drives +C_DRIVE_FORCED c +E_DRIVE_FORCED e +F_DRIVE_FORCED f diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/VCXErrors.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/VCXErrors.inc Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,103 @@ +KIptvTestErrNotFound -1111 +KIptvTestErrVerifyFailed -1112 + +KERRNONE 0 +KERRNOTFOUND -1 +KERRGENERAL -2 +KERRCANCEL -3 +KERRNOMEMORY -4 +KERRNOTSUPPORTED -5 +KERRARGUMENT -6 +KERRBADHANDLE -8 +KERROVERFLOW -9 +KERRUNDERFLOW -10 +KERRALREADYEXISTS -11 +KERRINUSE -14 +KERRSERVERBUSY -16 +KERRNOTREADY -18 +KERRUNKNOWN -19 +KERRCORRUPT -20 +KERRLOCKED -22 +KERRDISKFULL -26 +KERRBADNAME -28 +KERRTIMEDOUT -33 +KERRABORT -39 +KERRTOOBIG -40 +KErrCouldNotConnect -34 + + +// EPG manager server side error codes +KIptvErrorGetUpdateInformationLNotFound 123 +KIptvErrorEpgUpdateFailed 133 +KIptvErrorEpgUpdateSuccessed 134 +KIptvVodUpdateNotStarted 137 +KIptvVodUpdateStarted 136 +KIptvErrorVodNoIap 139 +KIptvErrorNoService 140 +KIptvThumbnailCount 141 +KIptvContentUpdateCompleted 146 +KIptvServiceThumbnailDownloaded 143 +KIptvContentThumbnailDownloaded 144 +KIptvRssParserError 145 + +KIptvErrorRssSearchStarted 170 +KIptvErrorRssSearchFailed 171 +KIptvErrorRssSearchSucceed 172 +KIptvErrorRssSearchNoIap 173 + +EIptvDlNoError 0 +EIptvDlOutOfMemory 1 +EIptvDlOutOfMemoryInVodDlPluginCreate 2 +EIptvDlVodDlPluginNotFound 3 +EIptvDlGeneralErrorInVodDlPluginCreate 4 +EIptvDlMessageAlreadyPending 5 +EIptvDlTypeNotSupported 6 +EIptvDlMaxDownloadsExceeded 7 +EIptvDlAlreadyExists 8 +KIptvDlCouldNotGetServiceData 9 +EIptvDlEpgManagerNotReady 10 +EIptvDlCouldNotGetContentFullDetails 11 +EIptvDlFailedToAddNewVideoToMyVideos 12 +EIptvDlCouldNotConnectToS60DlMgr 13 +EIptvDlCouldNotSetIapAttrToS60DlMgr 14 +EIptvDlCouldNotCreateS60Download 15 +EIptvDlCouldNotStartS60Download 16 +EIptvDlConnectionFailed 17 +EIptvDlAuthFailed 18 +EIptvDlProxyAuthFailed 19 +EIptvDlContentNotFound 20 +EIptvDlDiskFull 21 +EIptvDlDestFileInUse 22 +EIptvDlBadUrl 23 +EIptvDlMmcRemoved 24 +EIptvDlGeneral 25 +EIptvDlDisconnected 26 +EIptvDlContentUnchanged 27 + +KIptvSchemaMismatch 301 +KIptvInvalidServiceType 302 +EXmlNoElements -997 +KErrNotFound -1 + +KErrGsmMMServiceOptionTemporaryOutOfOrder -4162 + +// From HttpDownloadMgrCommon.h +EGeneral -30421 +EInternal -30422 +EContentFileIntegrity -30423 +EDiskFull -30424 +EConnectionFailed -30425 +ETransactionFailed -30426 +EMoveFailed -30427 +EDestFileWriteFailed -30428 +EMMCRemoved -30429 +EBadUrl -30430 +EWrongDestFilename -30431 +EDestFileInUse -30432 +EHttpUnhandled -30433 +EHttpAuthenticationFailed -30434 +EProxyAuthenticationFailed -30435 +EObjectNotFound -30436 +EPartialContentModified -30437 +EContentExpired -30438 +EHttpRestartFailed -30450 diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/conf/atsconf.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/conf/atsconf.txt Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,15 @@ +;Run \vado\videoplayer\tsrc\testing\tools\genATSdrop.pl from +;the tsrc folder to create ATS3 drop. +[DROP] +NAME VaDo - videoutils_plat - videoconnutility_api +DEVICE INSERT_DEVICE +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +;SIS \VideoApp_Domain\videoplayer\videoplayerapp\mpxvideoplayer\sis\VideoPlayer.sisx +PKG group\videoconnutility_apitest.pkg +BOOT +INI init\TestFramework.ini 200 +EMAIL INSERT_EMAIL +RUN +[ENDDROP] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/custom/postrun_custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/custom/postrun_custom.xml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,64 @@ + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/custom/prerun_custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/custom/prerun_custom.xml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,54 @@ + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/data/cccccc00.cre Binary file videoutils_plat/videoconnutility_api/tsrc/data/cccccc00.cre has changed diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/group/VCXConnUtilTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/group/VCXConnUtilTest.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include + +TARGET VCXConnUtilTest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY CAP_GENERAL_DLL +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE VCXConnUtilTest.def + +SOURCEPATH ../src +SOURCE VCXConnUtilTest.cpp +SOURCE VCXConnUtilTestBlocks.cpp +SOURCE VCXConnUtilTestSubscriber.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +USERINCLUDE ../inc +USERINCLUDE ../../inc/ipvideo +USERINCLUDE ../VCXTestUtilModule/inc +USERINCLUDE ../VCXTestCommon/inc + +SYSTEMINCLUDE /Epoc32/include/ecom +/// SYSTEMINCLUDE /Epoc32/include/ipvideo +APP_LAYER_SYSTEMINCLUDE + +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY vcxconnectionutility.lib + +LIBRARY cone.lib +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY VCXTestCommon.lib +LIBRARY FLOGGER.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY edbms.lib // rdbstoredatabase +LIBRARY centralrepository.lib + +LANG SC + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +../conf/VCXConnUtilTestMasterAndSlave.cfg /epoc32/winscw/c/testframework/vcxconnutiltestmasterandslave.cfg +../conf/VCXConnUtilTestSNAP.cfg /epoc32/winscw/c/testframework/vcxconnutiltestsnap.cfg +../conf/VCXConnUtilTestStates.cfg /epoc32/winscw/c/testframework/vcxconnutilteststates.cfg +../conf/VCXConnUtilTest.inc /epoc32/winscw/c/testframework/vcxconnutiltest.inc +../conf/VCXConsts.inc /epoc32/winscw/c/testframework/vcxconsts.inc +../conf/VCXDrives.inc /epoc32/winscw/c/testframework/vcxdrives.inc +../conf/VCXErrors.inc /epoc32/winscw/c/testframework/vcxerrors.inc + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +../VCXTestCommon/group/VCXTestCommon.mmp +../VCXTestUtilModule/group/VCXTestUtilModule.mmp +VCXConnUtilTest.mmp +../VCXConnUtilTestExe/group/VCXConnUtilTestExe.mmp + +PRJ_MMPFILES + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/group/videoconnutility_apitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/group/videoconnutility_apitest.pkg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,72 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Package file for video connection utility API STIF tests; + +; Languages +&EN + +; Provide value for uid +#{"VCXConnUtilTest"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/udeb/VCXConnUtilTest.dll" - "!:/Sys/Bin/VCXConnUtilTest.dll" +"/epoc32/release/armv5/udeb/VCXConnUtilTestExe.exe" - "!:/Sys/Bin/VCXConnUtilTestExe.exe" +"/epoc32/release/armv5/udeb/VCXTestUtilModule.dll" - "!:/Sys/Bin/VCXTestUtilModule.dll" +"/epoc32/release/armv5/udeb/VCXTestCommon.dll" - "!:/Sys/Bin/VCXTestCommon.dll" +"../conf/VCXConnUtilTestMasterAndSlave.cfg" - "C:/TestFramework/VCXConnUtilTestMasterAndSlave.cfg" +"../conf/VCXConnUtilTestSNAP.cfg" - "C:/TestFramework/VCXConnUtilTestSNAP.cfg" +"../conf/VCXConnUtilTestHelium.cfg" - "C:/TestFramework/VCXConnUtilTestHelium.cfg" +"../conf/VCXConnUtilTestStates.cfg" - "C:/TestFramework/VCXConnUtilTestStates.cfg" +"../conf/VCXConnUtilTest.inc" - "C:/TestFramework/VCXConnUtilTest.inc" +"../conf/VCXConsts.inc" - "C:/TestFramework/VCXConsts.inc" +"../conf/VCXDrives.inc" - "C:/TestFramework/VCXDrives.inc" +"../conf/VCXErrors.inc" - "C:/TestFramework/VCXErrors.inc" + +; The cenrep and testframework.ini files won't install with sis, only for ATS test runs. +"../init/TestFramework.ini" - "C:/TestFramework/TestFramework.ini" +; If tests are run in XXXXX CATS uncomment the cenrep file installation line. +"../data/cccccc00.cre" - "c:/private/10202be9/persists/cccccc00.cre" +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTest.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,341 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +#ifndef VCXCONNUTILTEST_H +#define VCXCONNUTILTEST_H + +// INCLUDES +#include +#include +#include + +#include "MIptvTestTimerObserver.h" + +#include "vcxconnutilengineobserver.h" +#include "VCXConnUtilTestPSObserver.h" +#include "../../../../videoconnutility/inc/vcxconnectionutility.hrh" +#include "../../../../videoconnutility/inc/vcxconnutilcommon.h" + +// CONSTANTS +const TInt KVcxConnUtilTestModeSubscriber = 0; +const TInt KVcxConnUtilTestModeConnectivity = 1; +const TInt KVcxConnUtilTestModeBoth = 2; // Default mode, P&S is subscribed and connection creation is allowed + +const TInt KTimeoutTimerId = 0; + +// MACROS + +// Logging path +_LIT( KVCXConnUtilTestLogPath, "\\logs\\testframework\\VCXConnUtilTest\\" ); +// Log file +_LIT( KVCXConnUtilTestLogFile, "VCXConnUtilTest.txt" ); +_LIT( KVCXConnUtilTestLogFileWithTitle, "VCXConnUtilTest_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CVCXConnUtilTest; +class CVCXTestCommon; +class CVCXConnUtilTestSubscriber; +class CIptvTestTimer; +class CIptvTestActiveWait; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +class TVcxConnTestPSProperty + { + public: + TVcxConnTestPSProperty( ) + { + iIsInteger = EFalse; + } + TVcxConnTestPSProperty( TInt aProperty, TInt aValue ) + { + iProperty = aProperty; + iIntegerValue = aValue; + iIsInteger = ETrue; + } + TVcxConnTestPSProperty( TInt aProperty, TDesC& aValue ) + { + iProperty = aProperty; + iStringValue = aValue; + iIsInteger = EFalse; + } + ~TVcxConnTestPSProperty( ) + { + + } + public: + TBool iIsInteger; + TInt iProperty; + TInt iIntegerValue; + TBufC<256> iStringValue; + }; + +/** +* CVCXConnUtilTest test class for STIF Test Framework TestScripter. +*/ +NONSHARABLE_CLASS(CVCXConnUtilTest) : public CScriptBase, + public MVCXConnUtilTestPSObserver, + public MIptvTestTimerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CVCXConnUtilTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CVCXConnUtilTest(); + + public: // New functions + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + /** + * From MVCXConnUtilTestPSObserver, called when P&S key changes. + */ + void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TInt& aValue ); + + /** + * From MVCXConnUtilTestPSObserver, called when P&S key changes. + */ + void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TDesC& aValue ); + + /** + * From MIptvTestTimerObserver Handles timer completion + * @since + * @param aTimerId + * @param aError + */ + void TimerComplete(TInt aTimerId, TInt aError); + + private: // New functions + + /** + * Gets name string for property. + */ + void GetPropertyNameL( TInt aProperty, TDes& aPropertyName ); + + /** + * Gets connection name into a string. + */ + void GetConnectionStatusL( TInt aConnectionStatus, TDes& aStatusString ); + + /** + * Checks that the tester process is still alive. Leaves if it's dead. + */ + void TesterExeAliveL(); + + void CreateTesterProcessL(); + + protected: // New functions + + private: + + /** + * C++ default constructor. + */ + CVCXConnUtilTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + /** + * Tries to close all tester exe's, should be called in start of each case before call + * to any CreateL. + */ + virtual TInt PrepareCaseL( CStifItemParser& aItem ); + + /** + * Commands the tester exe to shutdown checks for any error codes for the process exit. + * Should be called in end of each test case before deleting test module. + */ + virtual TInt ShutdownTesterL( CStifItemParser& aItem ); + + /** + * Initializes the test module. + * @param mode, If KVcxConnUtilTestModeNormal + * - Doesn't subscribe ConnUtil P&S keys. + * - Main use connectivity. + * + * If KVcxConnUtilTestModeSubscribe + * - Subscribes ConnUtil P&S keys and keeps track of the changes. + * - Doesn't create instance of ConnUtil, can't be used for connectivity. + * @param caseId. + */ + virtual TInt CreateL( CStifItemParser& aItem ); + + /** + * Calls CVcxConnectionUtility::GetIap which creates connection. + * Can only be used when test module is created in KVcxConnUtilTestModeNormal mode. + */ + virtual TInt GetIapL( CStifItemParser& aItem ); + + /** + * Calls CVcxConnectionUtility::WapIdFromIapIdL for the defined IAP. + * @param iapName, if IAP is not found then invalid IAP ID is used. + */ + virtual TInt WapIdFromIapIdL( CStifItemParser& aItem ); + + /** + * Calls CVcxConnectionUtility::Disconnect which disconnects active connection. + * Can only be used when test module is created in KVcxConnUtilTestModeNormal mode. + */ + virtual TInt DisconnectL( CStifItemParser& aItem ); + + /** + * Calls CVcxConnectionUtility::Disconnect which disconnects active connection. + * Can be used always. + */ + virtual TInt CheckPropertyL( CStifItemParser& aItem ); + + /** + * Sets roaming flag which is returned to ConnUtil upon request. + * Can only be used when test module is created in KVcxConnUtilTestModeNormal mode. + */ + virtual TInt SetRoamingAllowedL( CStifItemParser& aItem ); + + /** + * Sets flag for test module to cause User::Leave when it gets roaming request. + * Can only be used when test module is created in KVcxConnUtilTestModeNormal mode. + */ + virtual TInt SetLeaveAtRoamingRequestL( CStifItemParser& aItem ); + + /** + * Sets delay before roaming request is answered. + * Can only be used when test module is created in KVcxConnUtilTestModeNormal mode. + */ + virtual TInt SetDelayBeforeRoamingRequestL( CStifItemParser& aItem ); + + /** + * Gets the values for ConnUtil P&S properties and prints 'em to debug ouput. + * Can be used always. + */ + virtual TInt PrintConnUtilDetails( CStifItemParser& aItem ); + + /** + * Adds property and value to queue of waited P&S changes. + * @param property + * @param value + * Can only be used when test module is created in KVcxConnUtilTestModeSubscriber mode. + */ + virtual TInt AddWaitedPropertyL( CStifItemParser& aItem ); + + /** + * Adds property that is causes error signal while there's properties in queue + * added with AddWaitedProperty. + * @param property + * @param value + * Can only be used when test module is created in KVcxConnUtilTestModeSubscriber mode. + */ + virtual TInt AddNotAllowedPropertyL( CStifItemParser& aItem ); + + /** + * Resets the queue of expected property changes. + * Can only be used when test module is created in KVcxConnUtilTestModeSubscriber mode. + */ + virtual TInt ResetWaitedPropertiesL( CStifItemParser& aItem ); + + /** + * After call to this when queue for waited properties is empty the test script will be signaled. + * Can only be used when test module is created in KVcxConnUtilTestModeSubscriber mode. + */ + virtual TInt WaitForPropertyQueueL( CStifItemParser& aItem ); + + private: // Data + + CVCXTestCommon* iTestCommon; + + // KVcxConnUtilTestModeSubscriber or KVcxConnUtilTestModeNormal + TInt iMode; + + CVCXConnUtilTestSubscriber* iConnectionStatusSubscriber; + CVCXConnUtilTestSubscriber* iIapIdSubscriber; + CVCXConnUtilTestSubscriber* iSnapIdSubscriber; + CVCXConnUtilTestSubscriber* iMasterExistsSubscriber; + CVCXConnUtilTestSubscriber* iNbrConnInstancesSubscriber; + CVCXConnUtilTestSubscriber* iRoamingRequestStatusSubscriber; + CVCXConnUtilTestSubscriber* iNbrRoamRespSubscriber; + CVCXConnUtilTestSubscriber* iNbRoamAcceptedSubscriber; + + // Array of P&S changes to properties of VcxConnUtil + RArray iWaitedPSChanges; + + RArray iNotAllowedPSChanges; + + TBool iWaitingForEmptyPropertyQueue; + + // Timeout timer + CIptvTestTimer* iTimeoutTimer; + + CIptvTestActiveWait* iWait; + + // Is wait for connection request enabled. + TInt iWaitTimedRequest; + + // This will show in function traces. + TBuf<256> iName; + + // Testexe + RProcess iProcess; + + TInt iPSKeyBase; + + CVCXConnUtilTestSubscriber* iTesterGetAckResponseSubscriber; + CVCXConnUtilTestSubscriber* iTesterResponseSubscriber; + + CVCXConnUtilTestSubscriber* iTesterCountSubscriber; + + TBool iShutdownCalled; + + TBool iTesterCountChangedAlready; + }; + +#endif // VCXCONNUTILTEST_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestCommon.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +#ifndef VCXCONNUTILTESTCOMMON_H_ +#define VCXCONNUTILTESTCOMMON_H_ + +// Category for PS keys used by tests. +const TUid KVCXConnUtilTestPScategory = { 0x101FB3E3 }; + +const TInt KVCXConnUtilTestExeGlobalTesterCount = 1; + +// Set this to 1 to inform all the tester exe's for shutdown. +const TInt KVCXConnUtilTestExeGlobalShutdownKey = 2; + +/** + * P&S key for commands, created by tester exe which adds it's own process id to this. + */ +const TUint KVCXConnUtilTestExePsKeyCmd = 10; // Observed for changes by tester exe. + +/** + * Parameters for the commands, created by tester exe which adds it's own process id to these. + */ +const TUint KVCXConnUtilTestExePsKeyCmdIntParam1 = 11; +const TUint KVCXConnUtilTestExePsKeyCmdIntParam2 = 12; +const TUint KVCXConnUtilTestExePsKeyCmdDescParam1 = 13; + +/** + * P&S keys for responses, created by tester exe which adds it's own process id to these. + */ +// This is sent after tester exe has received the cmd. +const TUint KVCXConnUtilTestExePsKeyResponseAck = 21; +// Will contain command which sent the repsonse. +const TUint KVCXConnUtilTestExePsKeyResponseCmd = 22; +// Will contain parameter for the repsonse. +const TUint KVCXConnUtilTestExePsKeyResponseParam = 23; +// Symbian error code for the response. +const TUint KVCXConnUtilTestExePsKeyResponseError = 24; + +/** + * List of commands to tester exe. + */ +enum TVcxConnUtilCommand + { + EVcxConnUtilCommandShutdown, // Params: none + EVcxConnUtilCommandSetName, // Params: desc for name + EVcxConnUtilCommandGetIap, // Params: int1 = silent, int2 = timed call + EVcxConnUtilCommandGetWapIdForIap, // Params: int1 = IAP ID + EVcxConnUtilCommandDisconnect, // Params: none + EVcxConnUtilCommandSetRoamingAllowed, // Params: int1 = the value + EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest, // Params: int1 = the value + EVcxConnUtilCommandSetDelayBeforeRoamingRequest, // Params: int1 = the value + }; + +#endif /*VCXCONNUTILTESTCOMMON_H_*/ diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestPSObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestPSObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to observe P&S properties.* +*/ + + +#ifndef VCXCONNUTILTESTPSOBSERVER_H +#define VCXCONNUTILTESTPSOBSERVER_H + +#include +#include + +class MVCXConnUtilTestPSObserver + { +public: + virtual void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TInt& aValue ) = 0; + virtual void ValueChangedL( const TUid& aUid, const TUint32& aKey, const TDesC& aValue ) = 0; + }; + +#endif // VCXCONNUTILTESTPSOBSERVER_H \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestSubscriber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/inc/VCXConnUtilTestSubscriber.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to handle subscribtions from PS* +*/ + + +#ifndef VCXCONNUTILTESTSUBSCRIBER_H +#define VCXCONNUTILTESTSUBSCRIBER_H + +#include // For CActive, link against: euser.lib +#include // For RTimer, link against: euser.lib + +#include + +class MVCXConnUtilTestPSObserver; + +class CVCXConnUtilTestSubscriber : public CActive + { + public: + + /** + * Construction. + * + * @param aUid category for the property + * @param aKey key id for the property + * @param aType type of the key (at the moment only int and text are supported) + * @param aObserver pointer to observer to who to notify about changes + * + * @return The newly constructed CVcxConnUtilPubSub + */ + static CVCXConnUtilTestSubscriber* NewL( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXConnUtilTestPSObserver* aObserver ); + + /** + * Destructor. + * + */ + virtual ~CVCXConnUtilTestSubscriber(); + + /** + * Returns a pubsub value from this property + * + *@param &aValue value to fetch + * + *@return TInt KErrNone or some system level error code + */ + TInt Get( TInt& aValue ); + + /** + * Returns a pubsub value from this property + * + *@param &aValue value tofetch + * + *@return TInt KErrNone or some system level error code + */ + TInt Get( TDes& aValue ); + + /** + * Sets a pubsub value from this property + * + *@param aValue value to set + * + *@return TInt KErrNone or some system level error code + */ + TInt Set( TInt& aValue ); + + /** + * Sets a pubsub value from this property + * + *@param aValue value to set + * + *@return TInt KErrNone or some system level error code + */ + TInt Set( const TDesC& aValue ); + + /** + * Start subscribing if not already started + */ + void Start(); + + /** + * Activate safe wait object to wait modifications + */ + void WaitChangeL(); + + /** + * Explicitly ends waiting + */ + void EndWait(); + + private: // constuct / destruct + + /** + * Constructor + * + */ + CVCXConnUtilTestSubscriber( const TUid aUid, + const TUint32 aKey, + RProperty::TType aType, + MVCXConnUtilTestPSObserver* aObserver ); + + /** + * Symbian 2nd phase construction + * + */ + void ConstructL(); + + private: // from CActive + + /** + * From CActive. Calles when value subscribed to changes + * + */ + void RunL(); + + /** + * From CActive. Cancels subscribtion + * + */ + void DoCancel(); + + private: + + /** + * ETrue if object is initialized and subscribtion starts + */ + TBool iInitialized; + + /** + * Property to subscribe + */ + RProperty iProperty; + + /** + * Category uid for the property + */ + const TUid iUid; + + /** + * Key id for the property + */ + const TUint32 iKey; + + /** + * type of the property + */ + RProperty::TType iKeyType; + + /** + * Waiter object for data change + */ + CActiveSchedulerWait* iSafeWait; + + /** + * Observer + */ + MVCXConnUtilTestPSObserver* iObserver; + }; + +#endif // VCXCONNUTILTESTSUBSCRIBER_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/init/All/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/init/All/TestFramework.ini Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,168 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\Logs\Fusion\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= APPEND # Possible values: OVERWRITE or APPEND +UITestingSupport= Yes +SeparateProcesses= YES +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\VCXConnUtilTestSNAP.cfg +TestCaseFile= c:\testframework\VCXConnUtilTestMasterAndSlave.cfg +TestCaseFile= c:\testframework\VCXConnUtilTestStates.cfg +[End_Module] + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= C:\ +#HardwareFormat= TXT # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/init/TestFramework.ini Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,166 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\Logs\Fusion\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= APPEND # Possible values: OVERWRITE or APPEND +UITestingSupport= Yes +SeparateProcesses= YES +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\VCXConnUtilTestHelium.cfg +TestCaseFile= c:\testframework\VCXConnUtilTestMasterAndSlave.cfg +[End_Module] + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= C:\ +#HardwareFormat= TXT # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/src/VCXConnUtilTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/src/VCXConnUtilTest.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +// INCLUDE FILES +#include +#include "VCXConnUtilTest.h" +#include + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTest::CVCXConnUtilTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVCXConnUtilTest::CVCXConnUtilTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KVCXConnUtilTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KVCXConnUtilTestLogFile); + } + + iLog = CStifLogger::NewL( KVCXConnUtilTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CVCXConnUtilTest* CVCXConnUtilTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CVCXConnUtilTest* self = new (ELeave) CVCXConnUtilTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + +// Destructor +CVCXConnUtilTest::~CVCXConnUtilTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CVCXConnUtilTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoconnutility_api/tsrc/src/VCXConnUtilTestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoconnutility_api/tsrc/src/VCXConnUtilTestBlocks.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1381 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include // CleanupResetAndDestroyPushL + +#include +#include + +#include "VCXConnUtilTest.h" +#include "VCXConnUtilTestCommon.h" +#include "VCXTestCommon.h" +#include "IptvTestUtilALR.h" +#include "VCXConnUtilTestSubscriber.h" +#include "CIptvTestTimer.h" +#include "CIptvTestActiveWait.h" +#include "VCXTestTimerWait.h" + +#include "vcxconnectionutility.h" +#include "VCXTestLog.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTest::Delete() + { + VCXLOGLO2(">>>CVCXConnUtilTest::Delete (%S)", &iName); + + delete iTestCommon; + iTestCommon = NULL; + + if( iConnectionStatusSubscriber ) + { + iConnectionStatusSubscriber->EndWait(); + } + delete iConnectionStatusSubscriber; + iConnectionStatusSubscriber = NULL; + + if( iIapIdSubscriber ) + { + iIapIdSubscriber->EndWait(); + } + delete iIapIdSubscriber; + iIapIdSubscriber = NULL; + + if( iSnapIdSubscriber ) + { + iSnapIdSubscriber->EndWait(); + } + delete iSnapIdSubscriber; + iSnapIdSubscriber = NULL; + + if( iMasterExistsSubscriber ) + { + iMasterExistsSubscriber->EndWait(); + } + delete iMasterExistsSubscriber; + iMasterExistsSubscriber = NULL; + + if( iNbrConnInstancesSubscriber ) + { + iNbrConnInstancesSubscriber->EndWait(); + } + delete iNbrConnInstancesSubscriber; + iNbrConnInstancesSubscriber = NULL; + + if( iRoamingRequestStatusSubscriber ) + { + iRoamingRequestStatusSubscriber->EndWait(); + } + delete iRoamingRequestStatusSubscriber; + iRoamingRequestStatusSubscriber = NULL; + + if( iNbrRoamRespSubscriber ) + { + iNbrRoamRespSubscriber->EndWait(); + } + delete iNbrRoamRespSubscriber; + iNbrRoamRespSubscriber = NULL; + + if( iNbRoamAcceptedSubscriber ) + { + iNbRoamAcceptedSubscriber->EndWait(); + } + delete iNbRoamAcceptedSubscriber; + iNbRoamAcceptedSubscriber = NULL; + + delete iTesterCountSubscriber; + iTesterCountSubscriber = NULL; + + iWaitedPSChanges.Reset(); + iWaitedPSChanges.Close(); + + iNotAllowedPSChanges.Reset(); + iNotAllowedPSChanges.Close(); + + if( iTimeoutTimer ) + { + iTimeoutTimer->CancelTimer(); + delete iTimeoutTimer; + iTimeoutTimer = NULL; + } + + delete iWait; + iWait = NULL; + + if( !iShutdownCalled ) + { + CStifItemParser* fakeParser = NULL; + ShutdownTesterL( *fakeParser ); + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::PrepareCaseL"); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In PrepareCaseL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err = CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalShutdownKey, 1 ); + if( err != KErrNone ) + { + VCXLOGLO2("CVCXConnUtilTest:: Could not read KVCXConnUtilTestExeGlobalShutdownKey from PS. err: %d", err); + } + + VCXLOGLO1("<<>>CVCXConnUtilTest::ShutdownTesterL"); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In ShutdownTesterL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iShutdownCalled = ETrue; + + // Stop listening P&S changes. + + delete iTesterGetAckResponseSubscriber; + iTesterGetAckResponseSubscriber = NULL; + + delete iTesterResponseSubscriber; + iTesterResponseSubscriber = NULL; + + // Tell tester exe to shutdown. + + VCXLOGLO1("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandShutdown"); + + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandShutdown ); + + User::After( 3000000 ); + + // Check the shutdown. + + VCXLOGLO2("CVCXConnUtilTest:: Exit type: %d", iProcess.ExitType()); + VCXLOGLO2("CVCXConnUtilTest:: Exit reason: %d", iProcess.ExitReason()); + TExitCategoryName exitCatName = iProcess.ExitCategory(); + VCXLOGLO2("CVCXConnUtilTest:: Exit category: %S", &exitCatName); + + TInt err = iProcess.ExitReason(); + + if( err == KErrNone && iProcess.ExitType() != EExitKill && exitCatName.Length() == 0 ) + { + VCXLOGLO1("CVCXConnUtilTest:: ERROR: No exit error, no panic but exit type is unusual or exe is stil running."); + err = KErrGeneral; + } + + VCXLOGLO1("<<Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC name; + if( aItem.GetNextString( name ) == KErrNone ) + { + iName = name; + } + else + { + iName = _L("DEFAULT"); + } + + VCXLOGLO2(">>>CVCXConnUtilTest::CreateL (%S) ----->", &iName); + + if( aItem.GetNextInt( iMode ) != KErrNone ) + { + iMode = KVcxConnUtilTestModeBoth; + } + + iTestCommon = CVCXTestCommon::NewL(); + iWait = CIptvTestActiveWait::NewL(); + iTimeoutTimer = CIptvTestTimer::NewL( *this, KTimeoutTimerId ); + iPSKeyBase = 0; + + if( iMode == KVcxConnUtilTestModeBoth || iMode == KVcxConnUtilTestModeConnectivity ) + { + CreateTesterProcessL(); + + User::LeaveIfError( CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExeGlobalTesterCount, iPSKeyBase ) ); + + iPSKeyBase = iPSKeyBase * 1000 + iProcess.Id(); + VCXLOGLO2("CVCXConnUtilTest:: iPSKeyBase: %d", iPSKeyBase); + + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandSetName ); + + CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdDescParam1 + iPSKeyBase, iName ); + + // Start listening P&S for the tester responses. + iTesterGetAckResponseSubscriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase, RProperty::EInt, this ); + iTesterGetAckResponseSubscriber->Start(); + VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExePsKeyResponseAck: %d", KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase); + + iTesterResponseSubscriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase, RProperty::EInt, this ); + iTesterResponseSubscriber->Start(); + VCXLOGLO2("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExePsKeyResponseCmd: %d", KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase); + } + + // Start listening P&S for connutil status changes. + iConnectionStatusSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSConnectionStatus, RProperty::EInt, this ); + + iIapIdSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSIapId, RProperty::EInt, this ); + + iSnapIdSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSSnapId, RProperty::EInt, this ); + + iMasterExistsSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSMasterExists, RProperty::EInt, this ); + + iNbrConnInstancesSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSNbrConnInstances, RProperty::EInt, this ); + + iRoamingRequestStatusSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSRoamingRequestStatus, RProperty::EInt, this ); + + iNbrRoamRespSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSNbrRoamResp, RProperty::EInt, this ); + + iNbRoamAcceptedSubscriber = CVCXConnUtilTestSubscriber::NewL( KVcxConnUtilPScategory, + EVCxPSNbRoamAccepted, RProperty::EInt, this ); + + if( iMode == KVcxConnUtilTestModeSubscriber || iMode == KVcxConnUtilTestModeBoth ) + { + iConnectionStatusSubscriber->Start(); + iIapIdSubscriber->Start(); + iSnapIdSubscriber->Start(); + iMasterExistsSubscriber->Start(); + iNbrConnInstancesSubscriber->Start(); + iRoamingRequestStatusSubscriber->Start(); + iNbrRoamRespSubscriber->Start(); + iNbRoamAcceptedSubscriber->Start(); + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::CreateTesterProcessL (%S)", &iName); + // Define tester count P&S key before starting the exe. + TInt err = CVCXTestCommon::GetPSProperty( + KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, iPSKeyBase ); + + if( err == KErrNotFound ) + { + User::LeaveIfError( RProperty::Define( + KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, RProperty::EInt ) ); + VCXLOGLO1("CVCXConnUtilTest:: Defined KVCXConnUtilTestExeGlobalTesterCount"); + User::LeaveIfError( CVCXTestCommon::SetPSProperty( + KVCXConnUtilTestPScategory, KVCXConnUtilTestExeGlobalTesterCount, 1 ) ); + } + else + if( err != KErrNone ) + { + VCXLOGLO2("CVCXConnUtilTest:: err getting tester count P&S: %d", err); + User::Leave( err ); + } + + // Lets subscribe tester count for changes. + iTesterCountSubscriber = CVCXConnUtilTestSubscriber::NewL( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExeGlobalTesterCount, RProperty::EInt, this ); + iTesterCountSubscriber->Start(); + VCXLOGLO1("CVCXConnUtilTestExeTester:: Listening P&S key KVCXConnUtilTestExeGlobalTesterCount"); + + // Create the process. + User::LeaveIfError( iProcess.Create( _L("VCXConnUtilTestExe.exe"), _L("") ) ); + iProcess.Resume(); + + TesterExeAliveL(); + + // Wait until tester count P&S key has been updated. + if( !iTesterCountChangedAlready ) + { + iTesterCountSubscriber->WaitChangeL(); + } + + // Not interested anymore. + delete iTesterCountSubscriber; + iTesterCountSubscriber = NULL; + + VCXLOGLO2("<<>>CVCXConnUtilTest::GetIapL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In GetIapL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeSubscriber ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC destName; + User::LeaveIfError( aItem.GetNextString( destName ) ); + + CIptvTestUtilALR* alrUtil = CIptvTestUtilALR::NewLC(); + TInt destId = alrUtil->GetDestinationIdL( destName ); + CleanupStack::PopAndDestroy( alrUtil ); + + VCXLOGLO1("CVCXConnUtilTest:: Create cenrep."); + CRepository* cenRep = CRepository::NewLC( VCXTEST_KIptvAlrCenRepUid ); + VCXLOGLO1("CVCXConnUtilTest:: Set cenrep."); + User::LeaveIfError( cenRep->Set( VCXTEST_KIptvCenRepUsedSnapIdKey, destId ) ); + CleanupStack::PopAndDestroy( cenRep ); + + TInt isTimed(0); + if( aItem.GetNextInt( isTimed ) != KErrNone ) + { + isTimed = 0; + } + + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandGetIap (%S) ----->", &iName); + + // Silent call. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, 1 ) ); + + // Is this timed call. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam2 + iPSKeyBase, isTimed ) ); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandGetIap ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + + VCXLOGLO2("<<>>CVCXConnUtilTest::WapIdFromIapIdL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In WapIdFromIapIdL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TPtrC iapName; + User::LeaveIfError( aItem.GetNextString( iapName ) ); + + VCXLOGLO3("CVCXConnUtilTest:: Iap name: %S (%S) ----->", &iapName, &iName); + + TUint32 iapId( 0 ); + + TInt err( KErrNone ); + if( !iTestCommon->GetIapIdL( iapName, iapId ) ) + { + VCXLOGLO2("CVCXConnUtilTest:: Iap not found, error! (%S) ----->", &iName); + err = KErrNotFound; + } + else + { + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandGetWapIdForIap (%S) ----->", &iName); + + // IAP ID + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, iapId ) ); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandGetWapIdForIap ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::DisconnectL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In DisconnectL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeSubscriber ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandDisconnect (%S) ----->", &iName); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandDisconnect ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + + VCXLOGLO2("<<>>CVCXConnUtilTest::CheckPropertyL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In CheckPropertyL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt property; + User::LeaveIfError( aItem.GetNextInt( property ) ); + + TInt intValue(0); + TBuf<256> stringValue; + stringValue.Zero(); + + TBuf<256> propertyName; + GetPropertyNameL( property, propertyName ); + + VCXLOGLO2("CVCXConnUtilTest:: check %S", &propertyName); + + switch( property ) + { + case EVCxPSConnectionStatus: + { + User::LeaveIfError( iConnectionStatusSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSIapId: + { + User::LeaveIfError( iIapIdSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSSnapId: + { + User::LeaveIfError( iSnapIdSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSMasterExists: + { + User::LeaveIfError( iMasterExistsSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSNbrConnInstances: + { + User::LeaveIfError( iNbrConnInstancesSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSRoamingRequestStatus: + { + User::LeaveIfError( iRoamingRequestStatusSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSNbrRoamResp: + { + User::LeaveIfError( iNbrRoamRespSubscriber->Get( intValue ) ); + break; + } + + case EVCxPSNbRoamAccepted: + { + User::LeaveIfError( iNbRoamAcceptedSubscriber->Get( intValue ) ); + break; + } + + default: + { + User::Leave( KErrArgument ); + } + break; + } + + TInt err(KErrNone); + TInt expectedValue(0); + if( aItem.GetNextInt( expectedValue ) != KErrNone ) + { + err = KErrArgument; + } + else + if( err == KErrNone && intValue != expectedValue ) + { + VCXLOGLO3("CVCXConnUtilTest:: mismatch: %d, expected: %d", intValue, expectedValue ); + err = KErrCorrupt; + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::PrintConnUtilDetails (%S)", &iName); + + TInt connectionStatus( 0 ); + TInt iapId( 0 ); + TInt snapId( 0 ); + TInt masterExists( 0 ); + TInt nbrConnInstances( 0 ); + TInt roamingRequestStatus( 0 ); + TInt nbrRoamResp( 0 ); + TInt nbrRoamAccepted( 0 ); + TInt err( KErrNone ); + + err = iConnectionStatusSubscriber->Get( connectionStatus ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iConnectionStatusSubscriber", err); + + err = iIapIdSubscriber->Get( iapId ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iIapIdSubscriber", err); + + err = iSnapIdSubscriber->Get( snapId ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iSnapIdSubscriber", err); + + err = iMasterExistsSubscriber->Get( masterExists ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iMasterExistsSubscriber", err); + + err = iNbrConnInstancesSubscriber->Get( nbrConnInstances ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iNbrConnInstancesSubscriber", err); + + err = iRoamingRequestStatusSubscriber->Get( roamingRequestStatus ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iRoamingRequestStatusSubscriber", err); + + err = iNbrRoamRespSubscriber->Get( nbrRoamResp ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iNbrRoamRespSubscriber", err); + + err = iNbRoamAcceptedSubscriber->Get( nbrRoamAccepted ); + if( err != KErrNone ) VCXLOGLO2("CVCXConnUtilTest:: err: %d getting PS iNbRoamAcceptedSubscriber", err); + + TBuf<256> statusStr; + TRAP_IGNORE( GetConnectionStatusL( connectionStatus, statusStr ) ); + + VCXLOGLO3("CVCXConnUtilTest:: status: %S (%d)", &statusStr, connectionStatus); + VCXLOGLO2("CVCXConnUtilTest:: iapId: %d", iapId); + VCXLOGLO2("CVCXConnUtilTest:: snapId: %d", snapId); + VCXLOGLO2("CVCXConnUtilTest:: masterExists: %d", masterExists); + VCXLOGLO2("CVCXConnUtilTest:: nbrConnInstances: %d", nbrConnInstances); + VCXLOGLO2("CVCXConnUtilTest:: roamingRequestStatus: %d", roamingRequestStatus); + VCXLOGLO2("CVCXConnUtilTest:: nbrRoamResp: %d", nbrRoamResp); + VCXLOGLO2("CVCXConnUtilTest:: nbrRoamAccepted: %d", nbrRoamAccepted); + + VCXLOGLO2("<<>>CVCXConnUtilTest::SetRoamingAllowedL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In SetRoamingAllowedL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeSubscriber ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt temp; + User::LeaveIfError( aItem.GetNextInt( temp ) ); + + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandSetRoamingAllowed (%S) ----->", &iName); + + // Set value. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, temp ) ); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandSetRoamingAllowed ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + + VCXLOGLO2("<<>>CVCXConnUtilTest::SetLeaveAtRoamingRequestL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In SetLeaveAtRoamingRequestL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeSubscriber ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt temp; + User::LeaveIfError( aItem.GetNextInt( temp ) ); + + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest (%S) ----->", &iName); + + // Set value. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, temp ) ); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandSetRoamingLeaveAtRoamingRequest ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + + VCXLOGLO2("<<>>CVCXConnUtilTest::SetDelayBeforeRoamingRequestL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In SetDelayBeforeRoamingRequestL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeSubscriber ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt seconds(0); + User::LeaveIfError( aItem.GetNextInt( seconds ) ); + + VCXLOGLO2("CVCXConnUtilTest:: Setting cmd EVcxConnUtilCommandSetDelayBeforeRoamingRequest (%S) ----->", &iName); + + // Set value. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmdIntParam1 + iPSKeyBase, seconds ) ); + + // Set the cmd. + User::LeaveIfError( CVCXTestCommon::SetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyCmd + iPSKeyBase, EVcxConnUtilCommandSetDelayBeforeRoamingRequest ) ); + + iTesterGetAckResponseSubscriber->WaitChangeL(); + + VCXLOGLO2("<<>>CVCXConnUtilTest::AddWaitedPropertyL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In AddWaitedPropertyL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeConnectivity ) + { + User::Leave( KErrNotSupported ); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt property( -1 ); + User::LeaveIfError( aItem.GetNextInt( property ) ); + + TBuf<256> propertyName; + GetPropertyNameL( property, propertyName ); + + TInt value(0); + User::LeaveIfError( aItem.GetNextInt( value ) ); + + if( property == EVCxPSConnectionStatus ) + { + TBuf<256> connStr; + GetConnectionStatusL( value, connStr ); + VCXLOGLO3("CVCXConnUtilTest:: %S = %S", &propertyName, &connStr); + } + else + { + VCXLOGLO3("CVCXConnUtilTest:: %S = %d", &propertyName, value); + } + + TVcxConnTestPSProperty prop( property, value ); + iWaitedPSChanges.Append( prop ); + + VCXLOGLO2("<<>>CVCXConnUtilTest::AddNotAllowedPropertyL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In AddNotAllowedPropertyL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeConnectivity ) + { + User::Leave( KErrNotSupported ); + } + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + + TInt property( -1 ); + User::LeaveIfError( aItem.GetNextInt( property ) ); + + TBuf<256> propertyName; + GetPropertyNameL( property, propertyName ); + + TInt value(0); + User::LeaveIfError( aItem.GetNextInt( value ) ); + + if( property == EVCxPSConnectionStatus ) + { + TBuf<256> connStr; + GetConnectionStatusL( value, connStr ); + VCXLOGLO3("CVCXConnUtilTest:: %S = %S", &propertyName, &connStr); + } + else + { + VCXLOGLO3("CVCXConnUtilTest:: %S = %d", &propertyName, value); + } + + TVcxConnTestPSProperty prop( property, value ); + iNotAllowedPSChanges.Append( prop ); + + VCXLOGLO2("<<>>CVCXConnUtilTest::ResetWaitedPropertiesL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In ResetWaitedPropertiesL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeConnectivity ) + { + User::Leave( KErrNotSupported ); + } + + iWaitedPSChanges.Reset(); + iWaitingForEmptyPropertyQueue = EFalse; + iNotAllowedPSChanges.Reset(); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + VCXLOGLO2("<<>>CVCXConnUtilTest::WaitForPropertyQueueL (%S)", &iName); + // Print to UI + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "In WaitForPropertyQueueL" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + if( iMode == KVcxConnUtilTestModeConnectivity ) + { + User::Leave( KErrNotSupported ); + } + TesterExeAliveL(); + + iWaitingForEmptyPropertyQueue = ETrue; + + // Timer is started always again when we correct property changes. + const TInt KTimeoutMinute = 60 * 1000000; + iTimeoutTimer->CancelTimer(); + iTimeoutTimer->After( KTimeoutMinute * 1 ); + + aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); + VCXLOGLO2("<<>>CVCXConnUtilTest::ValueChangedL (%S)", &iName); + + if( aUid == KVcxConnUtilPScategory ) + { + TBuf<256> pName; + GetPropertyNameL( aKey, pName ); + if( aKey == EVCxPSConnectionStatus ) + { + TBuf<256> connStr; + GetConnectionStatusL( aValue, connStr ); + VCXLOGLO4("CVCXConnUtilTest::ValueChanged: %S = %S (%S) ----->", &pName, &connStr, &iName); + + _LIT( KVCXConnUtilTest, "S:" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, connStr ); + } + else + { + VCXLOGLO4("CVCXConnUtilTest::ValueChanged: %S = %d (%S) ----->", &pName, aValue, &iName); + } + + TBool found = EFalse; + for( TInt i = iWaitedPSChanges.Count() - 1; i >= 0; i-- ) + { + if( iWaitedPSChanges[i].iProperty == aKey && iWaitedPSChanges[i].iIntegerValue == aValue ) + { + iWaitedPSChanges.Remove( i ); + found = ETrue; + break; + } + } + + if( !found ) + { + VCXLOGLO1("CVCXConnUtilTest:: The key was not found from wait queue."); + + // Check not allowed property changes. + for( TInt i = iNotAllowedPSChanges.Count() - 1; i >= 0; i-- ) + { + if( iNotAllowedPSChanges[i].iProperty == aKey && iNotAllowedPSChanges[i].iIntegerValue == aValue ) + { + VCXLOGLO1("CVCXConnUtilTest:: Property change is not allowed. Error! SIGNAL."); + iNotAllowedPSChanges.Remove( i ); + Signal( KErrCorrupt ); + break; + } + } + } + else + { + VCXLOGLO1("CVCXConnUtilTest:: Key found and removed from wait queue."); + + // Restart timer. + const TInt KTimeoutMinute = 60 * 1000000; + iTimeoutTimer->CancelTimer(); + iTimeoutTimer->After( KTimeoutMinute * 1 ); + + if( iWaitedPSChanges.Count() == 0 ) + { + if( iWaitingForEmptyPropertyQueue ) + { + iWaitingForEmptyPropertyQueue = EFalse; + VCXLOGLO1("CVCXConnUtilTest:: Property queue empty, SIGNAL."); + iTimeoutTimer->CancelTimer(); + Signal(); + } + } + } + + if( iWaitedPSChanges.Count() == 0 ) + { + iNotAllowedPSChanges.Reset(); + } + } + + TInt err( KErrNone ); + + if( aUid == KVCXConnUtilTestPScategory ) + { + if( aKey == KVCXConnUtilTestExeGlobalTesterCount ) + { + iTesterCountChangedAlready = ETrue; + VCXLOGLO1("CVCXConnUtilTest:: KVCXConnUtilTestExeGlobalTesterCount changed."); + } + + if( aKey == KVCXConnUtilTestExePsKeyResponseAck + iPSKeyBase ) + { + VCXLOGLO3("CVCXConnUtilTest:: received KVCXConnUtilTestExePsKeyResponseAck, value: %d (%S) ----->", aValue, &iName); + } + + if( aKey == KVCXConnUtilTestExePsKeyResponseCmd + iPSKeyBase ) + { + VCXLOGLO2("CVCXConnUtilTest:: received KVCXConnUtilTestExePsKeyResponseCmd (%S) ----->", &iName); + + TInt cmd( aValue ); + + TInt response( 0 ); + + CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseParam + iPSKeyBase, response ); + + CVCXTestCommon::GetPSProperty( KVCXConnUtilTestPScategory, + KVCXConnUtilTestExePsKeyResponseError + iPSKeyBase, err ); + + if( cmd == EVcxConnUtilCommandDisconnect ) + { + VCXLOGLO3("CVCXConnUtilTest:: response for EVcxConnUtilCommandDisconnect, error: %d (%S) ----->", err, &iName); + } + + if( cmd == EVcxConnUtilCommandGetIap ) + { + if( response == 0 ) + { + VCXLOGLO1("CVCXConnUtilTest:: response for EVcxConnUtilCommandGetIap, IAP is 0, error!"); + err = KErrGeneral; + } + else + { + VCXLOGLO2("CVCXConnUtilTest:: response for EVcxConnUtilCommandGetIap returned IAP: %d", response); + } + } + + if( cmd == EVcxConnUtilCommandGetWapIdForIap ) + { + VCXLOGLO2("CVCXConnUtilTest:: response for EVcxConnUtilCommandGetWapIdForIap returned: %d", response); + } + + Signal( err ); + } + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::ValueChangedL (%S)", &iName); + + if( aUid == KVcxConnUtilPScategory ) + { + TBuf<256> pName; + GetPropertyNameL( aKey, pName ); + VCXLOGLO3("CVCXConnUtilTest::ValueChanged: %S = %S", &pName, &aValue); + + TBool found = EFalse; + for( TInt i = iWaitedPSChanges.Count() - 1; i >= 0; i-- ) + { + if( iWaitedPSChanges[i].iProperty == aKey && iWaitedPSChanges[i].iStringValue.Compare( aValue ) == 0 ) + { + iWaitedPSChanges.Remove( i ); + found = ETrue; + break; + } + } + + if( !found ) + { + VCXLOGLO1("CVCXConnUtilTest:: The key was not found from wait queue."); + + // Check not allowed property changes. + for( TInt i = iNotAllowedPSChanges.Count() - 1; i >= 0; i-- ) + { + if( iNotAllowedPSChanges[i].iProperty == aKey && iWaitedPSChanges[i].iStringValue.Compare( aValue ) ) + { + VCXLOGLO1("CVCXConnUtilTest:: Property change is not allowed. Error!"); + iNotAllowedPSChanges.Remove( i ); + Signal( KErrCorrupt ); + break; + } + } + } + else + { + VCXLOGLO1("CVCXConnUtilTest:: Key found and removed from wait queue."); + + const TInt KTimeoutMinute = 60 * 1000000; + iTimeoutTimer->CancelTimer(); + iTimeoutTimer->After( KTimeoutMinute * 1 ); + + if( iWaitedPSChanges.Count() == 0 ) + { + if( iWaitingForEmptyPropertyQueue ) + { + iWaitingForEmptyPropertyQueue = EFalse; + VCXLOGLO1("CVCXConnUtilTest:: Property queue empty, SIGNAL."); + iTimeoutTimer->CancelTimer(); + Signal(); + } + } + } + + if( iWaitedPSChanges.Count() == 0 ) + { + iNotAllowedPSChanges.Reset(); + } + } + + if( aUid == KVCXConnUtilTestPScategory ) + { + + } + + VCXLOGLO2("<<>>CVCXConnUtilTest::TimerComplete, err: %d (%S)", aError, &iName); + + if( aError == KErrNone && aTimerId == KTimeoutTimerId && iWaitingForEmptyPropertyQueue ) + { + if( iWaitedPSChanges.Count() > 0 ) + { + VCXLOGLO1("CVCXConnUtilTest:: ---- TIMEOUT --- when waiting P&S changes ----->"); + + _LIT( KVCXConnUtilTest, "CVCXConnUtilTest" ); + _LIT( KWhere, "TIMEOUT!" ); + TestModuleIf().Printf( 0, KVCXConnUtilTest, KWhere ); + + Signal( KErrTimedOut ); + } + else + { + VCXLOGLO1("CVCXConnUtilTest:: Timed out but property queue empty. Signal ok."); + Signal( KErrNone ); + } + } + + VCXLOGLO2("<<ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::ConstructL() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::ConstructL() + { + iInitialized = EFalse; + User::LeaveIfError( iProperty.Attach( iUid, iKey ) ); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::~CVCXConnUtilTestSubscriber() +// ----------------------------------------------------------------------------- +// +CVCXConnUtilTestSubscriber::~CVCXConnUtilTestSubscriber() + { + if( IsActive() ) + { + Cancel(); + } + iProperty.Close(); + + delete iSafeWait; + iSafeWait = NULL; + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::Get() +// ----------------------------------------------------------------------------- +// +TInt CVCXConnUtilTestSubscriber::Get( TInt& aValue ) + { + return iProperty.Get( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::Get() +// ----------------------------------------------------------------------------- +// +TInt CVCXConnUtilTestSubscriber::Get( TDes& aValue ) + { + return iProperty.Get( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::Set() +// ----------------------------------------------------------------------------- +// +TInt CVCXConnUtilTestSubscriber::Set( TInt& aValue ) + { + return iProperty.Set( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::Set() +// ----------------------------------------------------------------------------- +// +TInt CVCXConnUtilTestSubscriber::Set( const TDesC& aValue ) + { + return iProperty.Set( aValue ); + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::Start() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::Start() + { + if( !IsActive() ) + { + iProperty.Subscribe( iStatus ); + SetActive(); + iInitialized = ETrue; + } + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::WaitChange() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::WaitChangeL() + { + if( !iSafeWait ) + { + iSafeWait = new ( ELeave ) CActiveSchedulerWait; + } + if ( iSafeWait && !iSafeWait->IsStarted() ) + { + iSafeWait->Start(); + } + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::EndWait() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::EndWait() + { + if ( iSafeWait && iSafeWait->IsStarted() ) + { + iSafeWait->AsyncStop(); + } + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::DoCancel() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::DoCancel() + { + if( IsActive() ) + { + iProperty.Cancel(); + } + iInitialized = EFalse; + } + +// ----------------------------------------------------------------------------- +// CVCXConnUtilTestSubscriber::RunL() +// ----------------------------------------------------------------------------- +// +void CVCXConnUtilTestSubscriber::RunL() + { + VCXLOGLO1(">>>CVCXConnUtilTestSubscriber::RunL"); + // resubscribe before processing new + // value to prevent missing updates + iProperty.Subscribe( iStatus ); + SetActive(); + + if( iInitialized ) + { + TBuf< KMaxStrLenght > strValue; + TInt intValue; + + if( iKeyType == RProperty::EInt ) + { + // int type changed + if( iProperty.Get( intValue ) == KErrNone && iObserver ) + { + iObserver->ValueChangedL( iUid, iKey, intValue ); + } + } + else if( iKeyType == RProperty::EText ) + { + if( iProperty.Get( strValue ) == KErrNone && iObserver ) + { + iObserver->ValueChangedL( iUid, iKey, strValue ); + } + } + } + EndWait(); + iInitialized = ETrue; + VCXLOGLO1("<< + +Video Connection Utility API +Video Connection Utility API can be used for managing network connections within the same scope for different SW components +C++ +videoserviceutils + + + + +no +no + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoplayer_constants_api/inc/vcxmyvideosdefs.h --- a/videoutils_plat/videoplayer_constants_api/inc/vcxmyvideosdefs.h Tue Aug 31 16:13:59 2010 +0300 +++ b/videoutils_plat/videoplayer_constants_api/inc/vcxmyvideosdefs.h Wed Sep 01 12:20:37 2010 +0100 @@ -26,9 +26,6 @@ #include #include -#define VCX_DOWNLOADS_CATEGORY -#define VCX_ALBUMS - //These are written to TMPXItemId::iId2 const TInt KVcxMvcMediaTypeVideo = 0; const TInt KVcxMvcMediaTypeCategory = 1; diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +// SchedulerClient +../inc/ipvideo/CseEngineUids.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CseEngineUids.h ) +../inc/ipvideo/CCseSchedulerAPI.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCseSchedulerAPI.h ) +../inc/ipvideo/RCseSchedulerClient.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/RCseSchedulerClient.h ) +../inc/ipvideo/RCseSchedulerService.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/RCseSchedulerService.h ) +../inc/ipvideo/RCseSchedulerServiceBase.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/RCseSchedulerServiceBase.h ) +../inc/ipvideo/CCseScheduledProgram.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCseScheduledProgram.h ) +../inc/ipvideo/CseSchedulerClientServerCommon.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CseSchedulerClientServerCommon.h ) + +// SchedulerServer +../inc/ipvideo/CCseSchedulerPluginIF.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCseSchedulerPluginIF.h ) +../inc/ipvideo/CCseSchedulerPluginIF.inl MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/CCseSchedulerPluginIF.inl ) +../inc/ipvideo/MCseScheduleObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MCseScheduleObserver.h ) +../inc/ipvideo/MCsePluginObserver.h MW_LAYER_PLATFORM_EXPORT_PATH( ipvideo/MCsePluginObserver.h ) + + +PRJ_MMPFILES +PRJ_TESTMMPFILES diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CCseScheduledProgram.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CCseScheduledProgram.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class contains data for scheduled programs.* +*/ + + +#ifndef __CCSESCHEDULEDPROGRAM_H__ +#define __CCSESCHEDULEDPROGRAM_H__ + +#include +#include +#include + +// CONSTANTS +const TInt KCseNameMaxLength = 255; // Based on SymbianDB column max length + +/** +* Scheduled program data. +*/ +class CCseScheduledProgram : public CBase + { + public: // Constructors and destructors + /** + * Two-phased constructor. + */ + IMPORT_C static CCseScheduledProgram* NewL(); + + /** + * Two-phased copy constructor. + */ + IMPORT_C static CCseScheduledProgram* NewL( CCseScheduledProgram& aProg ); + + /** + * Destructor. + * @return None. + */ + IMPORT_C virtual ~CCseScheduledProgram(); + + + // Enums + // Schedule type + enum TCseScheduleType + { + ECseReminder = 0, + ECseRecording, + ECseProgramGuideUpdate, + ECseScheduleDownload, + ECseOther + }; + + // Plugin type: + enum TCsePluginType + { + // Only one of this kind of plugin can be running at same time + ECseUniPlugin = 1, + // Several of this kind of plugin can be running same time + ECseMultiPlugin + }; + public: // New methods + /** + * Externalizes class content to stream. + * @param aStream Writestream where to write content + * @return None. + */ + IMPORT_C void ExternalizeL( RWriteStream& aStream ); + + /** + * Internalizes class content from stream. + * @param aStream Readstream from where to read content + * @return None. + */ + IMPORT_C void InternalizeL( RReadStream& aStream ); + + /** + * Calculates externalization length. + * @return Length of the stream needed when class is externalized. + */ + IMPORT_C TInt ExternalizeLength(); + + public: // Setters + + /** + * Sets new plugin type for schedule. + * EUniPlugin for plugins that can have only one running at a given time. + * EMultiPlugin for plugins that can have several running at a given time + * @param aPluginType New plugin type + */ + IMPORT_C void SetPluginType( TInt32 aPluginType ); + + /** + * Sets new schedule name. + * @param aName New name of the schedule + */ + IMPORT_C void SetName( const TDesC8& aName ); + + /** + * Sets new schedule start time. + * @param aStartTime New start time of the schedule + */ + IMPORT_C void SetStartTime( const TTime& aStartTime ); + + /** + * Sets new schedule end time. + * @param aEndTime New end time of the schedule + */ + IMPORT_C void SetEndTime( const TTime& aEndTime ); + + /** + * Sets new application uid for schedule. + * @param aAppUid New application uid of the schedule + */ + IMPORT_C void SetAppUid( const TInt32 aAppUid ); + + /** + * Sets new plugin uid for schedule + * @param aPluginUid New plugin uid of the schedule + */ + IMPORT_C void SetPluginUid( const TInt32 aPluginUid ); + + /** + * Sets new application data for schedule + * @param aAppData New application data of the schedule + */ + IMPORT_C void SetApplicationDataL( const TDesC8& aAppData ); + + /** + * Sets new database identifier for the schedule. Note that this should only + * be set by Common Scheduling Engine, not the application using it. + * @param aDbIdentifier New database identifier of the schedule + */ + IMPORT_C void SetDbIdentifier( const TUint32 aDbIdentifier ); + + /** + * Sets new schedule for the schedule. + * @param aScheduleType New schedule type of the schedule + */ + IMPORT_C void SetScheduleType( const TInt32 aScheduleType ); + + // Getters + /** + * Get the type of scheduler plugin + * EUniPlugin for plugins that can have only one running at a given time. + * EMultiPlugin for plugins that can have several running at a given time + * @return Schedule plugin type. + */ + IMPORT_C TInt32 PluginType() const; + + /** + * Get the name of the schedule. + * @return Schedule name. + */ + IMPORT_C TPtrC8 Name() const; + + /** + * Gets the start time of the schedule. + * @return Start time. + */ + IMPORT_C TTime& StartTime(); + + /** + * Gets the end time of the schedule. + * @return End time. + */ + IMPORT_C TTime& EndTime(); + + /** + * Gets the application uid of the schedule + * @return Application uid. + */ + IMPORT_C TInt32 AppUid() const; + + /** + * Gets the plugin uid of the schedule. + * @return Plugin uid. + */ + IMPORT_C TInt32 PluginUid() const; + + /** + * Gets the application data of the schedule. + * @return Application data. + */ + IMPORT_C TPtrC8 ApplicationData(); + + /** + * Gets the database identifier of the schedule. + * @return Database identifier + */ + IMPORT_C TUint32 DbIdentifier() const; + + /** + * Gets the schedule type of the schedule. + * @return Schedule type + */ + IMPORT_C TInt32 ScheduleType() const; + + /** + * Dumps content of schedule to debug trace + * @return None + */ + IMPORT_C void DebugDump() const; + + protected: // Constructors + /** + * Default constructor + */ + EXPORT_C CCseScheduledProgram(); + + /** + * Symbian 2nd phase constructor can leave. + */ + void ConstructL(); + + protected: // Data + /** + * Name + * Name of the scheduled program, e.g. name of the TV program. + */ + TBuf8 iName; + + /** + * Start time + * Start time when the scheduled program is run (passed to plugin which is defined here). + */ + TTime iStartTime; + + /** + * End time + * End time for schedules that take longer time to complete, for example recording of the TV program. + * If schedule is "instant" (e.g. just notification to user) start time and end time should be the same. + */ + TTime iEndTime; + + /** + * Application UID + * This is the application uid of the program that has added this schedule. Can be used to retrieve + * all schedules of certain application. + */ + TInt32 iAppUid; + + /** + * Plugin UID + * UID of the plugin where this scheduled program is passed when the time is right. + */ + TInt32 iPluginUid; + + /** + * Application Data + * Application specific data for the plugin. Common scheduling Engine has no knowledge what + * this data contains. + */ + HBufC8* iAppData; + + /** + * DB identifier + * Used to separate schedules from each other in database. Should be only added by Common + * scheduling engine, not by application using it. + */ + TUint32 iDbIdentifier; + + /** + * Schedule type + * Type of this schedule, e.g. reminder, recording... + */ + TInt32 iScheduleType; + + /** + * Schedule plugin type + * Type of the plugin where this schedule will be run + */ + TInt32 iPluginType; + }; + +#endif //__CCSESCHEDULEDPROGRAM_H__ + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerAPI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerAPI.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef _CCSESCHEDULERAPI_H +#define _CCSESCHEDULERAPI_H + +// INCLUDES +#include +#include // Client common methods (server start up etc) +#include // Client common methods (open, close etc) + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None. + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +class CCseScheduledProgram; + +// CLASS DECLARATION +/** +* General client api that manages service functionality. +* +* @lib CseSchedulerClient.lib +*/ +class CCseSchedulerApi : public CBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + IMPORT_C static CCseSchedulerApi* NewL(); + + /** + * Destructor. + * @return None. + */ + IMPORT_C virtual ~CCseSchedulerApi(); + + private: // Constructors and destructor + + /** + * C++ default constructor. + */ + CCseSchedulerApi(); + + /** + * Symbian 2nd phase constructor can leave. + */ + void ConstructL(); + + public: // New methods + /** + * Adds given schedule to Common Scheduling Engine database. After the call is + * completed, the parameter contains the DB identifier of the schedule. + * @param aData Schedule to be added to database. + * @return Generic symbian error code. + */ + IMPORT_C TInt AddSchedule( CCseScheduledProgram& aData ) const; + + /** + * Removes schedule from database. + * @param aDbIdentifier Database identifier of the schedule to be removed. + * @return Generic symbian error code. + */ + IMPORT_C TInt RemoveSchedule( const TUint32 aDbIdentifier ) const; + + /** + * Gets schedule from database. + * @param aDbIdentifier Database identifier of the schedule that is wanted + * from the database + * @param aProg Pointer where this scheduled program is get. + * @return Generic symbian error codes. + */ + IMPORT_C TInt GetSchedule( const TUint32 aDbIdentifier, + CCseScheduledProgram* aProg ) const; + + /** + * Get list of scheduled events from the scheduling engine based on given UID. + * @param aAppUid Application UID. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + IMPORT_C TInt GetSchedulesByAppUid( const TInt32 aAppUid, + RPointerArray& aArray ) const; + + /** + * Get overlapping schedule (if any) from the scheduling engine. + * Uses schedule type, start and end times to find overalapping + * schedules from the Commone Scheduling Engine database. + * @param aProgram Schedule to used for finding overlapping schedules. + * @param aResultArray On return, contains array of overlapping + * schedules, empty if none found. + * @return Generic symbian error code. + */ + IMPORT_C TInt GetOverlappingSchedules( CCseScheduledProgram& aProgram, + RPointerArray& aResultArray ); + + /** + * Get list of scheduled events from the scheduling engine based on given UID. + * @param aPluginUid Plugin UID. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + IMPORT_C TInt GetSchedulesByPluginUid( const TInt32 aPluginUid, + RPointerArray& aArray ) const; + + /** + * Get list of scheduled events from the scheduling engine based on given schedule type. + * @param aScheduleType Schedule type. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + IMPORT_C TInt GetSchedulesByType( const TInt32 aScheduleType, + RPointerArray& aArray ) const; + + /** + * Get list of scheduled events from the scheduling engine between given timeframe. + * @param aBeginning Beginning of the time frame + * @param aEnd End of the time frame + * @return Generic symbian error code. + */ + IMPORT_C TInt GetSchedulesByTime( const TTime& aBeginning, + const TTime& aEnd, + RPointerArray& aArray ) const; + + + private: // Data + /** + * Scheduler engine - Client + */ + RCseSchedulerClient iClient; + + /** + * Scheduler engine - Service + */ + RCseSchedulerService iService; + }; + +#endif //_CCSESCHEDULERAPI_H + +// End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerPluginIF.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerPluginIF.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common interface for scheduler plugins.* +*/ + + + + +#ifndef CCSESCHEDULERPLUGINIF_H +#define CCSESCHEDULERPLUGINIF_H + +#include +#include +class CCseScheduledProgram; +class MCsePluginObserver; + +class CCseSchedulerPluginIF : public CBase + { +public: + /** + * Construction method. + * @param aUid Ecom implementation uid of the used plugin. + * @return None + */ + static CCseSchedulerPluginIF* NewL( const TUid& aUid ); + + /** + * Runs given task in plugin. + * @param aProg Schedule to be run in plugin. + * @param aObserver Pointer back to scheduling engine. Called + * when schedule is completed or error occurs. + * @return None + */ + virtual void RunTaskL( CCseScheduledProgram& aProg, + MCsePluginObserver* aObserver ) = 0; + + /** + * Return the ECom implementation uid of this plugin. + * @return ECom implementation uid. + */ + TUid ImplementationUid() const; + + /** + * Destructor + */ + virtual ~CCseSchedulerPluginIF(); + +protected: + /** + * Instance identifier key. When instance of an + * implementation is created by ECOM framework, the + * framework will assign UID for it. The UID is used in + * destructor to notify framework that this instance is + * being destroyed and resources can be released. + */ + TUid iDtorIDKey; + + /** + * Ecom implementation uid + */ + TUid iImplementationUid; + }; + + + +#include +#include + +#endif //CCSESCHEDULERPLUGINIF_H diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerPluginIF.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CCseSchedulerPluginIF.inl Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSE inlines.* +*/ + + + +#ifndef CIPTVSCHEDULERPLUGIN_INL +#define CIPTVSCHEDULERPLUGIN_INL + +// INLINES + +/** +* Contructor +*/ +inline CCseSchedulerPluginIF* CCseSchedulerPluginIF::NewL( const TUid& aUid ) + { + TAny* ext = REComSession::CreateImplementationL( aUid, _FOFF( CCseSchedulerPluginIF, iDtorIDKey )); + + CCseSchedulerPluginIF* result = reinterpret_cast< CCseSchedulerPluginIF* >( ext ); + result->iImplementationUid = aUid; // set the plugin's implementation uid + + return result; + } + + +/** +* Destructor +*/ +inline CCseSchedulerPluginIF::~CCseSchedulerPluginIF() + { + // Inform the ECOM framework that this specific instance of the + // interface has been destroyed. + REComSession::DestroyedImplementation( iDtorIDKey ); + } +/** +* ImplementationUid +*/ +inline TUid CCseSchedulerPluginIF::ImplementationUid() const + { + return iImplementationUid; + } + +#endif diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CseEngineUids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CseEngineUids.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Common scheduling engine UIDs* +*/ + + + + + +const TUint CSE_SCHEDULER_SERVER_UID = 0x10281F20 +const TUint CSE_SCHEDULER_CLIENT_UID = 0x10281F1F diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/CseSchedulerClientServerCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/CseSchedulerClientServerCommon.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: scheduling engine client/server common header.* +*/ + + + + + +#ifndef __CSESCHEDULERCLIENTSERVERCOMMON_H__ +#define __CSESCHEDULERCLIENTSERVERCOMMON_H__ + +// INCLUDE FILES +#include + +// CONSTANTS +_LIT( KCseSchedulerServerName, "CseSchedulerEngineServer" ); // Server name +_LIT( KCseSchedulerServerSemaphoreName, "CseSchedulerServerSemaphore" ); +_LIT( KCseSchedulerServerFileName, "CseSchedulerServer.exe" ); + + +// The server version. A version must be specified when +// creating a session with the server. +const TUint KCseServMajorVersionNumber=0; +const TUint KCseServMinorVersionNumber=1; +const TUint KCseServBuildVersionNumber=1; + + +// Enum for different server requests +typedef enum + { + ECseRequestBase = 0, + ECseAddSchedule, + ECseRemoveSchedule, + ECseGetSchedules, + ECseGetSchedule, + ECseGetScheduleLength, + ECseGetSchedulesByAppUid, + ECseGetScheduleArrayLengthByAppUid, + ECseServCreateSubSession, + ECseServCloseSubSession, + ECseServCloseSession, + ECseGetOverlappingSchedulesLength, + ECseGetOverlappingSchedules, + ECseGetScheduleArrayLengthByPluginUid, + ECseGetSchedulesByPluginUid, + ECseGetScheduleArrayLengthByType, + ECseGetSchedulesByType, + ECseGetScheduleArrayLengthByTimeframe, + ECseGetSchedulesByTimeframe, + ECseRequestLast + } MCseSchedulerServerRequests; + +// Enum for different server responses +typedef enum + { + ECseNoSubsessionHandle = 0x100, + } MCseSchedulerRetValues; + + +#endif // __CSESCHEDULERCLIENTSERVERCOMMON_H__ + +// End of file \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/MCsePluginObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/MCsePluginObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Observer to inform common scheduling engine when plugin is* +*/ + + + + +#ifndef __MCSEPLUGINOBSERVER_H__ +#define __MCSEPLUGINOBSERVER_H__ + +// CLASS DECLARATION +/** +* MCsePluginObserver +* This class specifies the function to be called when a plugin +* cause error or completes. +*/ +class MCsePluginObserver + { + public: // New functions + /** + * Called when plugin is finihed progressing + * @param aCompletionCode Completion code of plugin. KErrNone + * if everything went alright. + */ + virtual void PluginCompleted( TInt aCompletionCode ) = 0; + }; + +#endif // __MCSEPLUGINOBSERVER_H__ + +// End of File \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/MCseScheduleObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/MCseScheduleObserver.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __MCSESCHEDULEOBSERVER_H__ +#define __MCSESCHEDULEOBSERVER_H__ + +// FORWARD DECLARATIONS +// None + +// CLASS DECLARATION +/** +* MCseScheduleObserver +* This class specifies the function to be called when a scheduler +* cause error or completes. +*/ +class MCseScheduleObserver + { + public: // New functions + /** + * Called when schedule is finished prosessing- + * @param aDbIdentifier DbIdentifier of scheduled program that just + * has been processed. + * @param aCompletionCode Completion code of schedule. KErrNone + * if everything went alright. + */ + virtual void ScheduleCompletedL( const TUint32 aDbIdentifier, + TInt aCompletionCode ) = 0; + }; + +#endif // __MCSESCHEDULEOBSERVER_H__ + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerClient.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Cse Scheduler engine Client class* +*/ + + + + + +#ifndef _RCSESCHEDULERCLIENT_H +#define _RCSESCHEDULERCLIENT_H + +// INCLUDES +#include + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None. + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +// None. + +// CLASS DECLARATION + +/** +* This is the client-side interface through which communication +* with the server is channeled. +* +* @lib CseSchedulerClient.dll +*/ +class RCseSchedulerClient : public RSessionBase + { + public: // Constructors and destructor + + /** + * C++ default constructor. + * @return None + */ + RCseSchedulerClient(); + + /** + * Destructor. + * @return None. + */ + virtual ~RCseSchedulerClient(); + + public: // New functions + + /** + * Connect to the server. + * @return KErrNone if successful, otherwise another of the system-wide + * error codes. + */ + TInt Connect(); + + /** + * Close the session. + * @return None + */ + void Close(); + + /** + * Version + * @return version number + */ + TVersion Version() const; + + private: // Data + + }; + +#endif // _RCSESCHEDULERCLIENT_H + +// End of File + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerService.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for CseScheduler Client's Service class* +*/ + + + +#ifndef __RCSESCHEDULERSERVICE_H__ +#define __RCSESCHEDULERSERVICE_H__ + +// INCLUDES +#include // Client common methods (open, close etc) + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None. + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +class CCseScheduledProgram; + +// CLASS DECLARATION +/** +* General client api that manages service functionality. +* +* @lib CseSchedulerClient.lib +*/ +class RCseSchedulerService : public RCseSchedulerServiceBase + { + public: // Constructors and destructor + + /** + * Constructor. + * @return None. + */ + RCseSchedulerService(); + + /** + * Destructor. + * @return None. + */ + virtual ~RCseSchedulerService(); + + public: // New methods + /** + * Adds given schedule to Common Scheduling Engine database. After the call is + * completed, the parameter contains the DB identifier of the schedule. + * @param aData Schedule to be added to database. + */ + void AddScheduleL( CCseScheduledProgram& aData ) const; + + /** + * Removes schedule from database. + * @param aDbIdentifier Database identifier of the schedule to be removed. + * @return Generic symbian error code. + */ + void RemoveScheduleL( const TUint32 aDbIdentifier ) const; + + /** + * Gets schedule from database. + * @param aDbIdentifier Database identifier of the schedule that is wanted + * from the database + * @param aProg Pointer where this scheduled program is get. + * @return Generic symbian error codes. + */ + void GetScheduleL( const TUint32 aDbIdentifier, + CCseScheduledProgram* aProg ) const; + + /** + * Get list of scheduled events from the scheduling engine based on given UID. + * @param aAppUid Application UID. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + void GetSchedulesL( const TInt32 aAppUid, + RPointerArray& aArray ) const; + + /** + * Get overlapping schedule (if any) from the scheduling engine. + * Uses schedule type, start and end times to find overalapping + * schedules from the Commone Scheduling Engine database. + * @param aProgram Schedule to used for finding overlapping schedules. + * @param aResultArray On return, contains array of overlapping + * schedules, empty if none found. + * @return Generic symbian error code. + */ + void GetOverlappingSchedulesL( CCseScheduledProgram& aProgram, + RPointerArray& aResultArray ); + + /** + * Get list of scheduled events from the scheduling engine based on given plugin UID. + * @param aPluginUid Plugin UID. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + void GetSchedulesByPluginUidL( const TInt32 aPluginUid, + RPointerArray& aArray ) const; + + /** + * Get list of scheduled events from the scheduling engine based on given schedule type. + * @param aType Schedule type. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + void GetSchedulesByTypeL( const TInt32 aType, + RPointerArray& aArray ) const; + + /** + * Get list of scheduled events from the scheduling engine between given timeframe. + * @param aBeginning Beginning of the timeframe. + * @param aEnd End of the timeframe. + * @param aArray On return contains items from the database. + * @return Generic symbian error code. + */ + void GetSchedulesByTimeL( const TTime& aBegining, + const TTime& aEnd, + RPointerArray& aArray ) const; + }; + +#endif //__RCSESCHEDULERSERVICE_H__ + +// End of File + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerServiceBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/inc/ipvideo/RCseSchedulerServiceBase.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface for Cse Scheduler engine Client's ServiceBase class.* +*/ + + + + + +#ifndef __RCSESCHEDULERSERVICEBASE_H +#define __RCSESCHEDULERSERVICEBASE_H + +// INCLUDES +#include + +// CONSTANTS +// None. + +// MACROS +// None. + +// DATA TYPES +// None. + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +class RCseSchedulerClient; + +// CLASS DECLARATION + +/** +* Base class for services. This represents a client-side sub-session +* and has a corresponding sub-session object on the server-side. +* +* @lib CseSchedulerClient.dll +*/ +class RCseSchedulerServiceBase : public RSubSessionBase + { + public: + /** + * C++ default constructor. + */ + RCseSchedulerServiceBase(); + + /** + * Destructor. + * @return None. + */ + virtual ~RCseSchedulerServiceBase(); + + /** + * Open server. + * @param aServer + * @return KErrNone if successful, otherwise one of the system-wide error codes. + */ + TInt Open( RCseSchedulerClient& aClient ); + + /** + * Close server. + * @return None + */ + void Close(); + + /** + * Uses user panic to panic client. + * @param aFault Panic reason. + * @return None. + */ + void PanicClient( TInt aFault ) const; + + /** + * Sessionhandle + */ + inline RCseSchedulerClient& SessionHandle() const { return *iClient; } + + private: + + /** + * Pointer to client. Own. + */ + RCseSchedulerClient* iClient; + + }; + +#endif // __RCSESCHEDULERSERVICEBASE_H + +// End of File + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/Bmarm/videoscheduler_apitestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/Bmarm/videoscheduler_apitestU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/Bwins/videoscheduler_apitestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/Bwins/videoscheduler_apitestU.DEF Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/EABI/videoscheduler_apitestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/EABI/videoscheduler_apitestU.def Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/conf/atsconf.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/conf/atsconf.txt Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,14 @@ +;Run \vado\videoplayer\tsrc\testing\tools\genATSdrop.pl from +;the tsrc folder to create ATS3 drop. +[DROP] +NAME VaDo - videoutils_plat - videoscheduler_api +DEVICE INSERT_DEVICE +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +FLASH INSERT_FLASH_IMAGE +SIS \VideoApp_Domain\videoplayer\videoplayerapp\mpxvideoplayer\sis\VideoPlayer.sisx +PKG group\videoscheduler_apitest.pkg +INI init\TestFramework.ini 200 +EMAIL INSERT_EMAIL +RUN +[ENDDROP] diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/conf/videoscheduler_apitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/conf/videoscheduler_apitest.cfg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,295 @@ +#*********************************************************************************** +# +# STIF test script file for testing videoscheduler. +# +#*********************************************************************************** + +[Test] +title ET00101 Program_NewL +create videoscheduler_apitest test +test Program_NewL +delete test +[Endtest] + +[Test] +title ET00102 Program_NewLFromProgram +create videoscheduler_apitest test +test Program_NewL +test Program_NewLFromProgram +delete test +[Endtest] + +[Test] +title ET00103 Program_Externalize +create videoscheduler_apitest test +test Program_NewL +test Program_Externalize +delete test +[Endtest] + +[Test] +title ET00104 Program_ExternalizeLength +create videoscheduler_apitest test +test Program_NewL +test Program_ExternalizeLength +delete test +[Endtest] + +[Test] +title ET00105 Program_Internalize +create videoscheduler_apitest test +test Program_NewL +test Program_Externalize +test Program_Internalize +delete test +[Endtest] + +[Test] +title ET00106 Program_PluginType +create videoscheduler_apitest test +test Program_NewL +test Program_SetPluginType 1 +test Program_PluginType 1 +delete test +[Endtest] + +[Test] +title ET00107 Program_Name +create videoscheduler_apitest test +test Program_NewL +test Program_SetName "Ohojelma" +test Program_Name "Ohojelma" +delete test +[Endtest] + +[Test] +title ET00108 Program_StartTime +create videoscheduler_apitest test +test Program_NewL +test Program_SetStartTime "20090217:142100.000000" +test Program_StartTime "20090217:142100.000000" +delete test +[Endtest] + +[Test] +title ET00109 Program_EndTime +create videoscheduler_apitest test +test Program_NewL +test Program_SetEndTime "20090217:142100.000000" +test Program_EndTime "20090217:142100.000000" +delete test +[Endtest] + +[Test] +title ET00110 Program_AppUid +create videoscheduler_apitest test +test Program_NewL +test Program_SetAppUid 666 +test Program_AppUid 666 +delete test +[Endtest] + +[Test] +title ET00111 Program_PluginUid +create videoscheduler_apitest test +test Program_NewL +test Program_SetPluginUid 666 +test Program_PluginUid 666 +delete test +[Endtest] + +[Test] +title ET00112 Program_ApplicationData +create videoscheduler_apitest test +test Program_NewL +test Program_SetApplicationData "Chuck Norris would never give up his whipped cream" +test Program_ApplicationData "Chuck Norris would never give up his whipped cream" +delete test +[Endtest] + +[Test] +title ET00113 Program_DbIdentifier +create videoscheduler_apitest test +test Program_NewL +test Program_SetDbIdentifier 666 +test Program_DbIdentifier 666 +delete test +[Endtest] + +[Test] +title ET00114 Program_ScheduleType Reminder +create videoscheduler_apitest test +test Program_NewL +test Program_SetScheduleType 0 +test Program_ScheduleType 0 +delete test +[Endtest] + +[Test] +title ET00115 Program_ScheduleType Recording +create videoscheduler_apitest test +test Program_NewL +test Program_SetScheduleType 1 +test Program_ScheduleType 1 +delete test +[Endtest] + +[Test] +title ET00116 Program_ScheduleType EPG Update +create videoscheduler_apitest test +test Program_NewL +test Program_SetScheduleType 2 +test Program_ScheduleType 2 +delete test +[Endtest] + +[Test] +title ET00117 Program_ScheduleType Scheduled download +create videoscheduler_apitest test +test Program_NewL +test Program_SetScheduleType 3 +test Program_ScheduleType 3 +delete test +[Endtest] + +[Test] +title ET00118 Program_ScheduleType Other +create videoscheduler_apitest test +test Program_NewL +test Program_SetScheduleType 4 +test Program_ScheduleType 4 +delete test +[Endtest] + +[Test] +title ET00119 Program_DebugDump +create videoscheduler_apitest test +test Program_NewL +test Program_DebugDump +delete test +[Endtest] + +[Test] +title ET00120 API_NewL +create videoscheduler_apitest test +test API_NewL 0 +delete test +[Endtest] + +[Test] +title ET00121 API_AddSchedule +create videoscheduler_apitest test +test API_NewL +test API_AddSchedule +delete test +[Endtest] + +[Test] +title ET00122 API_RemoveSchedule +create videoscheduler_apitest test +test API_NewL +test Program_SetToFuture 20 30 +test API_AddSchedule +test API_RemoveSchedule +delete test +[Endtest] + +[Test] +title ET00123 API_GetSchedule +create videoscheduler_apitest test +test API_NewL +test Program_SetToFuture 20 30 +test API_AddSchedule +test API_GetSchedule +test RemoveAllSchedules +delete test +[Endtest] + +[Test] +title ET00124 API_GetSchedulesByAppUid +create videoscheduler_apitest test +test API_NewL +test Program_SetAppUid 666 +test Program_SetToFuture 20 30 +test API_AddSchedule +pause 1000 +test API_GetSchedulesByAppUid 666 1 +test Program_AppUid 666 +test RemoveAllSchedules +delete test +[Endtest] + +[Test] +title ET00125 API_GetOverlappingSchedules +create videoscheduler_apitest test +test API_NewL +test Program_NewL +test Program_SetToFuture 30 60 +test API_AddSchedule +test Program_NewL +test Program_SetToFuture 30 60 +test API_AddSchedule +test Program_NewL +test Program_SetToFuture 30 60 +test API_AddSchedule +test API_GetOverlappingSchedules 3 +test RemoveAllSchedules +pause 2000 +test API_GetOverlappingSchedules 0 +delete test +[Endtest] + +[Test] +title ET00126 API_GetSchedulesByPluginUid +create videoscheduler_apitest test +test API_NewL +test Program_NewL +test Program_SetToFuture 20 30 +test Program_SetPluginUid 666 +test API_AddSchedule +test API_GetSchedulesByPluginUid 666 1 +test Program_PluginUid 666 +test RemoveAllSchedules +delete test +[Endtest] + +[Test] +title ET00127 API_GetSchedulesByType +create videoscheduler_apitest test +test API_NewL +test Program_NewL +test Program_SetToFuture 20 30 +test Program_SetScheduleType 0 +test API_AddSchedule +test API_GetSchedulesByType 0 1 +test Program_ScheduleType 0 +test RemoveAllSchedules +delete test +[Endtest] + +[Test] +title ET00128 API_GetSchedulesByTime +create videoscheduler_apitest test +test API_NewL +test Program_NewL +test Program_SetToFuture 20 30 +test API_AddSchedule +test API_GetSchedulesByTime 1 100 1 +test RemoveAllSchedules +delete test +[Endtest] + +[Test] +title ET00129 Schedule reminder, wait for launch +create videoscheduler_apitest test +test API_NewL +test Program_NewL +test Program_SetScheduleType 0 +test Program_SetToFuture 10 20 +test API_AddSchedule +test API_GetSchedule +pause 25000 +allownextresult -20 +test API_GetSchedule +delete test +[Endtest] \ No newline at end of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/custom/postrun_custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/custom/postrun_custom.xml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,64 @@ + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + + + fetch-log + + + + + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/custom/prerun_custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/custom/prerun_custom.xml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,54 @@ + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + + + makedir + + + + diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/group/bld.inf Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS +../conf/videoscheduler_apitest.cfg /epoc32/data/z/system/data/videoscheduler_apitest.cfg +../conf/videoscheduler_apitest.cfg /epoc32/winscw/c/testframework/videoscheduler_apitest.cfg + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +videoscheduler_apitest.mmp + +PRJ_MMPFILES + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/group/videoscheduler_apitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/group/videoscheduler_apitest.mmp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET videoscheduler_apitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +/* Remove comments and replace 0x00000000 with correct vendor id */ +// VENDORID 0x00000000 +/* Remove comments and replace 0x00000000 with correct secure id */ +// SECUREID 0x00000000 + +//TARGETPATH ?target_path +DEFFILE videoscheduler_apitest.def + +USERINCLUDE ../inc + +APP_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src + +SOURCE videoscheduler_apitest.cpp +SOURCE videoscheduler_apitestblocks.cpp + +//RESOURCE resource_file +//RESOURCE resource_file2 + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY CseSchedulerClient.lib // Common Scheduling Engine client +LIBRARY estor.lib +LIBRARY flogger.lib + +LANG SC + +// Other possible keywords: + +// DEFFILE ?filename +// AIF ?filename + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/group/videoscheduler_apitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/group/videoscheduler_apitest.pkg Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,59 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Package file for video scheduler API STIF tests; + +; Languages +&EN + +; Provide value for uid +#{"videoscheduler_apitest"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/udeb/videoscheduler_apitest.dll" - "!:/Sys/Bin/videoscheduler_apitest.dll" +"../conf/videoscheduler_apitest.cfg" - "C:/TestFramework/videoscheduler_apitest.cfg" +"../init/TestFramework.ini" - "C:/TestFramework/TestFramework.ini" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/inc/vcxtestlog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/inc/vcxtestlog.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef VCXTESTLOG_H +#define VCXTESTLOG_H + +// INCLUDES +#include +#include + +//#define FILE_LOGGING_IN_UREL_BUILD 1 + +// MACROS +#ifdef _DEBUG + +// SELECT LOG TYPE FROM HERE +// 0 = RDebug +// 1 = file logging +// 2 = no logging +#ifdef __WINSCW__ + #define LOGTYPE 0 +#else + #define LOGTYPE 1 +#endif __WINSCW__ + +#if LOGTYPE == 0 + + #define VCXLOGLO1(s) RDebug::Print(_L(#s)) + #define VCXLOGLO2(s, a) RDebug::Print(_L(#s), a) + #define VCXLOGLO3(s, a, b) RDebug::Print(_L(#s), a, b) + #define VCXLOGLO4(s, a, b, c) RDebug::Print(_L(#s), a, b, c) + #define VCXLOGLO5(s, a, b, c, d) RDebug::Print(_L(#s), a, b, c, d) + +#endif + +#if LOGTYPE == 1 + + #include + +_LIT(KIPTVLogFolder2,"Fusion"); +_LIT(KIPTVLogFile2,"Fusion.txt"); + + #define VCXLOGLO1(AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) + #define VCXLOGLO2(AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB); } while ( EFalse ) + #define VCXLOGLO3(AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) + #define VCXLOGLO4(AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) + #define VCXLOGLO5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) + +#endif + +#if LOGTYPE == 2 + + #define VCXLOGLO1(s) + #define VCXLOGLO2(s, a) + #define VCXLOGLO3(s, a, b) + #define VCXLOGLO4(s, a, b, c) + #define VCXLOGLO5(s, a, b, c, d) + +#endif + +#else // _DEBUG + + #ifdef FILE_LOGGING_IN_UREL_BUILD + + #include + + _LIT(KIPTVLogFolder2,"Fusion"); + _LIT(KIPTVLogFile2,"Fusion.txt"); + + #define VCXLOGLO1(AAA) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::Write(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,tempIPTVLogDes()); } while ( EFalse ) + #define VCXLOGLO2(AAA,BBB) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB); } while ( EFalse ) + #define VCXLOGLO3(AAA,BBB,CCC) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC); } while ( EFalse ) + #define VCXLOGLO4(AAA,BBB,CCC,DDD) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD); } while ( EFalse ) + #define VCXLOGLO5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempIPTVLogDes,AAA); RFileLogger::WriteFormat(KIPTVLogFolder2(),KIPTVLogFile2(),EFileLoggingModeAppend,TRefByValue(tempIPTVLogDes()),BBB,CCC,DDD,EEE); } while ( EFalse ) + + #else // FILE_LOGGING_IN_UREL_BUILD + + #define VCXLOGLO1(s) + #define VCXLOGLO2(s, a) + #define VCXLOGLO3(s, a, b) + #define VCXLOGLO4(s, a, b, c) + #define VCXLOGLO5(s, a, b, c, d) + + #endif // FILE_LOGGING_IN_UREL_BUILD + +#endif // _DEBUG + + +#endif // VCXTESTLOG_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/inc/videoscheduler_apitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/inc/videoscheduler_apitest.h Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,496 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + + +#ifndef VIDEOSCHEDULER_APITEST_H +#define VIDEOSCHEDULER_APITEST_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +_LIT( KVideoScheduler_ApiTestLogPath, "\\logs\\testframework\\VideoScheduler_ApiTest\\" ); +// Log file +_LIT( KVideoScheduler_ApiTestLogFile, "VideoScheduler_ApiTest.txt" ); +_LIT( KVideoScheduler_ApiTestLogFileWithTitle, "VideoScheduler_ApiTest_[%S].txt" ); + +_LIT( KTestModuleName, "VideoScheduler_ApiTest" ); +_LIT( KLogLocation, "In %S" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CVideoScheduler_ApiTest; +class CCseScheduledProgram; +class CCseSchedulerApi; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* CVideoScheduler_ApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CVideoScheduler_ApiTest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CVideoScheduler_ApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CVideoScheduler_ApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + /** + * CompareProgramsL + * @since ?Series60_version + * @param aProgram1 + * @param aProgram2 + * @return Symbian OS error code. + */ + TInt ComparePrograms( CCseScheduledProgram& aProgram1, CCseScheduledProgram& aProgram2 ); + + /** + * LogMethod + * @since ?Series60_version + * @param aMethod Name of the method where this function is called + * @return Nothing + */ + void LogMethod( TPtrC aMethod ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CVideoScheduler_ApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + * + * Methods starting with API_ test CCseSchedulerAPI class. + * + * Methods starting with Program_ test CCseScheduledProgram class. Test class has member + * instance of this class and it's used when CCseSchedulerAPI methods need the program data. + * + * Default app uid for programs is 0x020202, all these will be removed + * when API_NewL is called without parameter 0. + */ + + /** + * API_NewL test method. + * Creates also CCseScheduledProgram if parameter is not 0. + * + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_NewL( CStifItemParser& aItem ); + + /** + * API_AddSchedule test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_AddScheduleL( CStifItemParser& aItem ); + + /** + * API_RemoveSchedule test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_RemoveScheduleL( CStifItemParser& aItem ); + + /** + * API_RemoveSchedule test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt RemoveAllSchedulesL( CStifItemParser& aItem ); + + /** + * API_GetSchedule test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetScheduleL( CStifItemParser& aItem ); + + /** + * API_GetSchedulesByAppUid test method. + * First schedule is copied to member variable. + * + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetSchedulesByAppUidL( CStifItemParser& aItem ); + + /** + * API_GetOverlappingSchedules test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetOverlappingSchedulesL( CStifItemParser& aItem ); + + /** + * API_GetSchedulesByPluginUidL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetSchedulesByPluginUidL( CStifItemParser& aItem ); + + /** + * API_GetSchedulesByTypeL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetSchedulesByTypeL( CStifItemParser& aItem ); + + /** + * API_GetSchedulesByTimeL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt API_GetSchedulesByTimeL( CStifItemParser& aItem ); + + /** + * Program_NewL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_NewL( CStifItemParser& aItem ); + + /** + * Program_NewLFromProgramL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_NewLFromProgramL( CStifItemParser& aItem ); + + /** + * Program_ExternalizeL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_ExternalizeLL( CStifItemParser& aItem ); + + /** + * Program_InternalizeL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_InternalizeLL( CStifItemParser& aItem ); + + /** + * Program_ExternalizeLength test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_ExternalizeLengthL( CStifItemParser& aItem ); + + /** + * Program_SetPluginType test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetPluginTypeL( CStifItemParser& aItem ); + + /** + * Program_SetName test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetNameL( CStifItemParser& aItem ); + + /** + * Program_SetStartTime test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetStartTimeL( CStifItemParser& aItem ); + + /** + * Program_SetEndTime test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetEndTimeL( CStifItemParser& aItem ); + + /** + * Program_SetAppUid test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetAppUidL( CStifItemParser& aItem ); + + /** + * Program_SetPluginUid test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetPluginUidL( CStifItemParser& aItem ); + + /** + * Program_SetApplicationDataL test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetApplicationDataLL( CStifItemParser& aItem ); + + /** + * Program_SetDbIdentifier test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetDbIdentifierL( CStifItemParser& aItem ); + + /** + * Program_SetScheduleType test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetScheduleTypeL( CStifItemParser& aItem ); + + /** + * Program_PluginType test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_PluginTypeL( CStifItemParser& aItem ); + + /** + * Program_Name test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_NameL( CStifItemParser& aItem ); + + /** + * Program_StartTime test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_StartTimeL( CStifItemParser& aItem ); + + /** + * Program_EndTime test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_EndTimeL( CStifItemParser& aItem ); + + /** + * Program_EndTime test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_SetToFutureL( CStifItemParser& aItem ); + + /** + * Program_AppUid test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_AppUidL( CStifItemParser& aItem ); + + /** + * Program_PluginUid test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_PluginUidL( CStifItemParser& aItem ); + + /** + * Program_ApplicationData test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_ApplicationDataL( CStifItemParser& aItem ); + + /** + * Program_DbIdentifier test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_DbIdentifierL( CStifItemParser& aItem ); + + /** + * Program_ScheduleType test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_ScheduleTypeL( CStifItemParser& aItem ); + + /** + * Program_DebugDump test method. + * @since ?Series60_version + * @param aItem Script line containing parameters. + * @return Symbian OS error code. + */ + virtual TInt Program_DebugDumpL( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + CCseSchedulerApi* iApi; + CCseScheduledProgram* iProgram; + HBufC8* iExternalizeBuff; + RArray iAddedProgramIds; + }; + +#endif // VIDEOSCHEDULER_APITEST_H + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/init/TestFramework.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/init/TestFramework.ini Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,165 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\Logs\Fusion\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= APPEND # Possible values: OVERWRITE or APPEND +UITestingSupport= Yes +SeparateProcesses= YES +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= TestScripter +TestCaseFile= c:\TestFramework\videoscheduler_apitest.cfg +[End_Module] + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= C:\ +#HardwareFormat= TXT # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +FileCreationMode= APPEND # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/src/videoscheduler_apitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/src/videoscheduler_apitest.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + + +// INCLUDE FILES +#include +#include "videoscheduler_apitest.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::CVideoScheduler_ApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CVideoScheduler_ApiTest::CVideoScheduler_ApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CVideoScheduler_ApiTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KVideoScheduler_ApiTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KVideoScheduler_ApiTestLogFile); + } + + iLog = CStifLogger::NewL( KVideoScheduler_ApiTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CVideoScheduler_ApiTest* CVideoScheduler_ApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CVideoScheduler_ApiTest* self = new (ELeave) CVideoScheduler_ApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CVideoScheduler_ApiTest::~CVideoScheduler_ApiTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CVideoScheduler_ApiTest::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("VideoScheduler_ApiTest.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CVideoScheduler_ApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/tsrc/src/videoscheduler_apitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/tsrc/src/videoscheduler_apitestblocks.cpp Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,1162 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description* +*/ + + + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include "videoscheduler_apitest.h" +#include + +#include +#include + +#include "vcxtestlog.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CVideoScheduler_ApiTest::Delete() + { + if( iApi ) + { + for( TInt i=0; iRemoveSchedule( iAddedProgramIds[i] ); + } + } + + delete iApi; + iApi = NULL; + + delete iProgram; + iProgram = NULL; + + delete iExternalizeBuff; + iExternalizeBuff = NULL; + + iAddedProgramIds.Close(); + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "API_NewL", CVideoScheduler_ApiTest::API_NewL ), + ENTRY( "API_AddSchedule", CVideoScheduler_ApiTest::API_AddScheduleL ), + ENTRY( "API_RemoveSchedule", CVideoScheduler_ApiTest::API_RemoveScheduleL ), + ENTRY( "RemoveAllSchedules", CVideoScheduler_ApiTest::RemoveAllSchedulesL ), + ENTRY( "API_GetSchedule", CVideoScheduler_ApiTest::API_GetScheduleL ), + ENTRY( "API_GetSchedulesByAppUid", CVideoScheduler_ApiTest::API_GetSchedulesByAppUidL ), + ENTRY( "API_GetOverlappingSchedules", CVideoScheduler_ApiTest::API_GetOverlappingSchedulesL ), + ENTRY( "API_GetSchedulesByPluginUid", CVideoScheduler_ApiTest::API_GetSchedulesByPluginUidL ), + ENTRY( "API_GetSchedulesByType", CVideoScheduler_ApiTest::API_GetSchedulesByTypeL ), + ENTRY( "API_GetSchedulesByTime", CVideoScheduler_ApiTest::API_GetSchedulesByTimeL ), + + ENTRY( "Program_NewL", CVideoScheduler_ApiTest::Program_NewL ), + ENTRY( "Program_NewLFromProgram", CVideoScheduler_ApiTest::Program_NewLFromProgramL ), + ENTRY( "Program_Externalize", CVideoScheduler_ApiTest::Program_ExternalizeLL ), + ENTRY( "Program_Internalize", CVideoScheduler_ApiTest::Program_InternalizeLL ), + ENTRY( "Program_ExternalizeLength", CVideoScheduler_ApiTest::Program_ExternalizeLengthL ), + ENTRY( "Program_SetPluginType", CVideoScheduler_ApiTest::Program_SetPluginTypeL ), + ENTRY( "Program_SetName", CVideoScheduler_ApiTest::Program_SetNameL ), + ENTRY( "Program_SetStartTime", CVideoScheduler_ApiTest::Program_SetStartTimeL ), + ENTRY( "Program_SetEndTime", CVideoScheduler_ApiTest::Program_SetEndTimeL ), + ENTRY( "Program_SetAppUid", CVideoScheduler_ApiTest::Program_SetAppUidL ), + ENTRY( "Program_SetPluginUid", CVideoScheduler_ApiTest::Program_SetPluginUidL ), + ENTRY( "Program_SetApplicationData", CVideoScheduler_ApiTest::Program_SetApplicationDataLL ), + ENTRY( "Program_SetDbIdentifier", CVideoScheduler_ApiTest::Program_SetDbIdentifierL ), + ENTRY( "Program_SetScheduleType", CVideoScheduler_ApiTest::Program_SetScheduleTypeL ), + ENTRY( "Program_PluginType", CVideoScheduler_ApiTest::Program_PluginTypeL ), + ENTRY( "Program_Name", CVideoScheduler_ApiTest::Program_NameL ), + ENTRY( "Program_StartTime", CVideoScheduler_ApiTest::Program_StartTimeL ), + ENTRY( "Program_EndTime", CVideoScheduler_ApiTest::Program_EndTimeL ), + ENTRY( "Program_AppUid", CVideoScheduler_ApiTest::Program_AppUidL ), + ENTRY( "Program_PluginUid", CVideoScheduler_ApiTest::Program_PluginUidL ), + ENTRY( "Program_ApplicationData", CVideoScheduler_ApiTest::Program_ApplicationDataL ), + ENTRY( "Program_DbIdentifier", CVideoScheduler_ApiTest::Program_DbIdentifierL ), + ENTRY( "Program_ScheduleType", CVideoScheduler_ApiTest::Program_ScheduleTypeL ), + ENTRY( "Program_DebugDump", CVideoScheduler_ApiTest::Program_DebugDumpL ), + + ENTRY( "Program_SetToFuture", CVideoScheduler_ApiTest::Program_SetToFutureL ), + // [test cases entries] - Do not remove + + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::LogMethod +// Generate log from current method +// ----------------------------------------------------------------------------- +// +void CVideoScheduler_ApiTest::LogMethod( TPtrC aMethod ) + { + // Print to UI + TBuf< 64 > buffer; + buffer.Format( KLogLocation, &aMethod ); + TestModuleIf().Printf( 0, KTestModuleName, buffer ); + // Print to log file + iLog->Log( buffer ); + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_NewL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_NewL( CStifItemParser& aItem ) + { + LogMethod(_L("API_NewL")); + + TInt err( KErrNone ); + + iApi = CCseSchedulerApi::NewL(); + + TInt createProgram( 1 ); + if( aItem.GetNextInt( createProgram ) != KErrNone ) + { + createProgram = 1; + } + + if( createProgram == 1 ) + { + iProgram = CCseScheduledProgram::NewL(); + + RPointerArray programs; + err = iApi->GetSchedulesByAppUid( 0x020202, programs ); + if( err == KErrNone ) + { + for( TInt i=0; i < programs.Count(); i++ ) + { + iApi->RemoveSchedule( programs[i]->DbIdentifier() ); + } + } + programs.ResetAndDestroy(); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_AddScheduleL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_AddScheduleL( CStifItemParser& /*aItem*/ ) + { + LogMethod(_L("API_AddSchedule")); + VCXLOGLO1("CVideoScheduler_ApiTest::API_AddScheduleL ------>"); + + TInt err( KErrNone ); + + err = iApi->AddSchedule( *iProgram ); + VCXLOGLO2("CVideoScheduler_ApiTest::API_AddScheduleL: DBID after: %d", iProgram->DbIdentifier() ); + iAddedProgramIds.Append( iProgram->DbIdentifier() ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_RemoveScheduleL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_RemoveScheduleL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_RemoveScheduleL ------>"); + LogMethod(_L("API_RemoveScheduleL")); + + TInt err( KErrNone ); + + VCXLOGLO2("CVideoScheduler_ApiTest::API_RemoveScheduleL: DBID: %d", iProgram->DbIdentifier() ); + + TUint32 id = iProgram->DbIdentifier(); + err = iApi->RemoveSchedule( id ); + + for( TInt i=0; i"); + LogMethod(_L("RemoveAllSchedulesL")); + + TInt err( KErrNone ); + + while( iAddedProgramIds.Count() ) + { + VCXLOGLO2("CVideoScheduler_ApiTest::RemoveAllSchedulesL -- remove ID %d", iAddedProgramIds[0]); + err = iApi->RemoveSchedule( iAddedProgramIds[0] ); + + iAddedProgramIds.Remove( 0 ); + + if( err != KErrNone ) + { + VCXLOGLO2("CVideoScheduler_ApiTest::RemoveAllSchedulesL -- Failed: %d", err); + } + } + + VCXLOGLO2("CVideoScheduler_ApiTest::RemoveAllSchedulesL <------ %d", err); + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetScheduleL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetScheduleL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetScheduleL ------>"); + LogMethod(_L("API_GetScheduleL")); + + TInt err( KErrNone ); + + CCseScheduledProgram* program = CCseScheduledProgram::NewL(); + CleanupStack::PushL( program ); + + err = iApi->GetSchedule( iProgram->DbIdentifier(), program ); + + if( err == KErrNone ) + { + if( !program ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetScheduleL: Error, program is NULL."); + err = KErrCorrupt; + } + else + { + err = ComparePrograms( *program, *iProgram ); + } + } + + CleanupStack::PopAndDestroy( program ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetSchedulesByAppUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetSchedulesByAppUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetSchedulesByAppUidL ------>"); + LogMethod(_L("API_GetSchedulesByAppUidL")); + + TInt err( KErrNone ); + + TInt appUid( 0 ); + User::LeaveIfError( aItem.GetNextInt( appUid ) ); + + TInt expectedCount(0); + User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); + + RPointerArray programs; + + err = iApi->GetSchedulesByAppUid( appUid, programs ); + + if( err == KErrNone ) + { + if( programs.Count() != expectedCount ) + { + err = KErrCorrupt; + } + else + if( programs.Count() > 0 ) + { + delete iProgram; + iProgram = NULL; + + iProgram = programs[0]; + programs.Remove( 0 ); + } + } + + programs.ResetAndDestroy(); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetOverlappingSchedulesL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetOverlappingSchedulesL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetOverlappingSchedulesL ------>"); + LogMethod(_L("API_GetOverlappingSchedulesL")); + + TInt err( KErrNone ); + + TInt expectedCount(0); + User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); + + RPointerArray programs; + + err = iApi->GetOverlappingSchedules( *iProgram, programs ); + + if( err == KErrNone ) + { + if( programs.Count() != expectedCount ) + { + err = KErrCorrupt; + } + else + if( programs.Count() > 0 ) + { + delete iProgram; + iProgram = NULL; + + iProgram = programs[0]; + programs.Remove( 0 ); + } + } + + programs.ResetAndDestroy(); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetSchedulesByPluginUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetSchedulesByPluginUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetSchedulesByPluginUidL ------>"); + LogMethod(_L("API_GetSchedulesByPluginUidL")); + + TInt err( KErrNone ); + + TInt pluginUid( 0 ); + User::LeaveIfError( aItem.GetNextInt( pluginUid ) ); + + TInt expectedCount(0); + User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); + + RPointerArray programs; + + err = iApi->GetSchedulesByPluginUid( pluginUid, programs ); + + if( err == KErrNone ) + { + if( programs.Count() != expectedCount ) + { + err = KErrCorrupt; + } + else + if( programs.Count() > 0 ) + { + delete iProgram; + iProgram = NULL; + + iProgram = programs[0]; + programs.Remove( 0 ); + } + } + + programs.ResetAndDestroy(); + + return err; + } + + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetSchedulesByTypeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetSchedulesByTypeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetSchedulesByTypeL ------>"); + LogMethod(_L("API_GetSchedulesByTypeL")); + + TInt err( KErrNone ); + + TInt type(0); + User::LeaveIfError( aItem.GetNextInt( type ) ); + + TInt expectedCount(0); + User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); + + RPointerArray programs; + + err = iApi->GetSchedulesByType( type, programs ); + + if( err == KErrNone ) + { + VCXLOGLO2("CVideoScheduler_ApiTest::API_GetSchedulesByTypeL count: %d", programs.Count()); + VCXLOGLO2("CVideoScheduler_ApiTest::API_GetSchedulesByTypeL expected: %d", expectedCount); + if( programs.Count() != expectedCount ) + { + err = KErrCorrupt; + } + else + if( programs.Count() > 0 ) + { + delete iProgram; + iProgram = NULL; + + iProgram = programs[0]; + programs.Remove( 0 ); + } + } + + programs.ResetAndDestroy(); + + return err; + } + + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::API_GetSchedulesByTimeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::API_GetSchedulesByTimeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_GetSchedulesByTimeL ------>"); + LogMethod(_L("API_GetSchedulesByTimeL")); + + TInt err( KErrNone ); + TInt intervalStart( 0 ); + TInt intervalEnd( 0 ); + + User::LeaveIfError( aItem.GetNextInt( intervalStart ) ); + User::LeaveIfError( aItem.GetNextInt( intervalEnd ) ); + + TTime startTime( 0 ); + TTime endTime( 0 ); + + startTime.UniversalTime(); + endTime.UniversalTime(); + + startTime += TTimeIntervalSeconds( intervalStart ); + endTime += TTimeIntervalSeconds( intervalEnd ); + + TInt expectedCount(0); + User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); + + RPointerArray programs; + + err = iApi->GetSchedulesByTime( startTime, endTime, programs ); + + if( err == KErrNone ) + { + if( programs.Count() != expectedCount ) + { + err = KErrCorrupt; + } + else + if( programs.Count() > 0 ) + { + delete iProgram; + iProgram = NULL; + + iProgram = programs[0]; + programs.Remove( 0 ); + } + } + + programs.ResetAndDestroy(); + + return err; + } + + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_NewL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_NewL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_NewL ------>"); + LogMethod(_L("Program_NewL")); + + TInt err( KErrNone ); + + iProgram = CCseScheduledProgram::NewL(); + iProgram->SetAppUid( 0x020202 ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_NewLFromProgramL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_NewLFromProgramL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_NewLFromProgramL ------>"); + LogMethod(_L("Program_NewLFromProgramL")); + + TInt err( KErrNone ); + + CCseScheduledProgram* program = iProgram; + iProgram = NULL; + + CleanupStack::PushL( program ); + iProgram = CCseScheduledProgram::NewL( *program ); + CleanupStack::PopAndDestroy( program ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_ExternalizeLL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_ExternalizeLL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_ExternalizeLL ------>"); + LogMethod(_L("Program_ExternalizeLL")); + + TInt err( KErrNone ); + + TUint32 dataSize = iProgram->ExternalizeLength(); + + delete iExternalizeBuff; + iExternalizeBuff = NULL; + iExternalizeBuff = HBufC8::NewL( dataSize ); + TPtr8 buffPtr( iExternalizeBuff->Des() ); + + RDesWriteStream stream; + stream.Open( buffPtr ); + iProgram->ExternalizeL( stream ); + stream.CommitL(); + stream.Close(); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_InternalizeLL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_InternalizeLL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_InternalizeLL ------>"); + LogMethod(_L("Program_InternalizeLL")); + + TInt err( KErrNone ); + + CCseScheduledProgram* program = CCseScheduledProgram::NewL(); + CleanupStack::PushL( program ); + + RDesReadStream stream; + TPtr8 buffPtr( iExternalizeBuff->Des() ); + stream.Open( buffPtr ); + program->InternalizeL( stream ); + stream.Close(); + + err = ComparePrograms( *program, *iProgram ); + + CleanupStack::PopAndDestroy( program ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_ExternalizeLengthL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_ExternalizeLengthL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_ExternalizeLengthL ------>"); + LogMethod(_L("Program_ExternalizeLengthL")); + + TInt err( KErrNone ); + + iProgram->ExternalizeLength(); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetPluginTypeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetPluginTypeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetPluginTypeL ------>"); + LogMethod(_L("Program_SetPluginTypeL")); + + TInt err( KErrNone ); + + TInt pluginType; + User::LeaveIfError( aItem.GetNextInt( pluginType ) ); + + iProgram->SetPluginType( pluginType ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetNameL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetNameL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetNameL ------>"); + LogMethod(_L("Program_SetNameL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC name; + User::LeaveIfError( aItem.GetNextString( name ) ); + + TBuf8<1024> name8; + name8.Copy( name ); + + iProgram->SetName( name8 ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetStartTimeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetStartTimeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetStartTimeL ------>"); + LogMethod(_L("Program_SetStartTimeL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC dayString; + User::LeaveIfError( aItem.GetNextString( dayString ) ); + + TTime time( dayString ); + + iProgram->SetStartTime( time ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetEndTimeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetEndTimeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetEndTimeL ------>"); + LogMethod(_L("Program_SetEndTimeL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC dayString; + User::LeaveIfError( aItem.GetNextString( dayString ) ); + + TTime time( dayString ); + + iProgram->SetEndTime( time ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetAppUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetAppUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetAppUidL ------>"); + LogMethod(_L("Program_SetAppUidL")); + + TInt err( KErrNone ); + + TInt uid( 0 ); + User::LeaveIfError( aItem.GetNextInt( uid ) ); + + iProgram->SetAppUid( uid ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetPluginUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetPluginUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetPluginUidL ------>"); + LogMethod(_L("Program_SetPluginUidL")); + + TInt err( KErrNone ); + + TInt uid( 0 ); + User::LeaveIfError( aItem.GetNextInt( uid ) ); + + iProgram->SetPluginUid( uid ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetApplicationDataLL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetApplicationDataLL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetApplicationDataLL ------>"); + LogMethod(_L("Program_SetApplicationDataLL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC data; + User::LeaveIfError( aItem.GetNextString( data ) ); + + TBuf8<1024> data8; + data8.Copy( data ); + + iProgram->SetApplicationDataL( data8 ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetDbIdentifierL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetDbIdentifierL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetDbIdentifierL ------>"); + LogMethod(_L("Program_SetDbIdentifierL")); + + TInt err( KErrNone ); + + TInt id; + User::LeaveIfError( aItem.GetNextInt( id ) ); + + iProgram->SetDbIdentifier( id ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetScheduleTypeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetScheduleTypeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetScheduleTypeL ------>"); + LogMethod(_L("Program_SetScheduleTypeL")); + + TInt err( KErrNone ); + + TInt type; + User::LeaveIfError( aItem.GetNextInt( type ) ); + + iProgram->SetScheduleType( type ); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_PluginTypeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_PluginTypeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_PluginTypeL ------>"); + LogMethod(_L("Program_PluginTypeL")); + + TInt err( KErrNone ); + + TInt pluginType; + TInt expectedPluginType; + User::LeaveIfError( aItem.GetNextInt( expectedPluginType ) ); + + pluginType = iProgram->PluginType(); + + if( pluginType != expectedPluginType ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_NameL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_NameL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_NameL ------>"); + LogMethod(_L("Program_NameL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC expectedName; + User::LeaveIfError( aItem.GetNextString( expectedName ) ); + + const TPtrC8 name8 = iProgram->Name(); + + TBuf<1024> name; + name.Copy( name8 ); + + if( name != expectedName ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_StartTimeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_StartTimeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_StartTimeL ------>"); + LogMethod(_L("Program_StartTimeL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC dayString; + User::LeaveIfError( aItem.GetNextString( dayString ) ); + + TTime expectedTime( dayString ); + + TTime time = iProgram->StartTime(); + + if( time != expectedTime ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_EndTimeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_EndTimeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_EndTimeL ------>"); + LogMethod(_L("Program_EndTimeL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC dayString; + User::LeaveIfError( aItem.GetNextString( dayString ) ); + + TTime expectedTime( dayString ); + + TTime time = iProgram->EndTime(); + + if( time != expectedTime ) + { + err = KErrCorrupt; + } + + return err; + } + + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_SetToFutureL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_SetToFutureL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_SetToFutureL ------>"); + LogMethod(_L("Program_SetToFutureL")); + + TInt err( KErrNone ); + TInt intervalStart( 0 ); + TInt intervalEnd( 0 ); + + User::LeaveIfError( aItem.GetNextInt( intervalStart ) ); + User::LeaveIfError( aItem.GetNextInt( intervalEnd ) ); + + TTime startTime( 0 ); + TTime endTime( 0 ); + + startTime.UniversalTime(); + endTime.UniversalTime(); + + startTime += TTimeIntervalSeconds( intervalStart ); + endTime += TTimeIntervalSeconds( intervalEnd ); + + iProgram->SetStartTime( startTime ); + iProgram->SetEndTime( endTime ); + + VCXLOGLO3("CVideoScheduler_ApiTest::Program_SetToFutureL -- start %d end %d", startTime, endTime); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_AppUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_AppUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_AppUidL ------>"); + LogMethod(_L("Program_AppUidL")); + + TInt err( KErrNone ); + + TInt expectedUid; + User::LeaveIfError( aItem.GetNextInt( expectedUid ) ); + + TInt32 uid = iProgram->AppUid(); + + if( uid != expectedUid ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_PluginUidL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_PluginUidL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_PluginUidL ------>"); + LogMethod(_L("Program_PluginUidL")); + + TInt err( KErrNone ); + + TInt expectedUid; + User::LeaveIfError( aItem.GetNextInt( expectedUid ) ); + + TInt32 uid = iProgram->PluginUid(); + + if( uid != expectedUid ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_ApplicationDataL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_ApplicationDataL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_ApplicationDataL ------>"); + LogMethod(_L("Program_ApplicationDataL")); + + TInt err( KErrNone ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC expectedData; + User::LeaveIfError( aItem.GetNextString( expectedData ) ); + + const TPtrC8 data8 = iProgram->ApplicationData(); + + TBuf<1024> data; + data.Copy( data8 ); + + if( data != expectedData ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_DbIdentifierL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_DbIdentifierL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_DbIdentifierL ------>"); + LogMethod(_L("Program_DbIdentifierL")); + + TInt err( KErrNone ); + + TInt expectedId; + User::LeaveIfError( aItem.GetNextInt( expectedId ) ); + + TUint32 id = iProgram->DbIdentifier(); + + if( id != expectedId ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_ScheduleTypeL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_ScheduleTypeL( CStifItemParser& aItem ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::API_AddScheduleL ------>"); + LogMethod(_L("Program_ScheduleTypeL")); + + TInt err( KErrNone ); + + TInt expectedType; + User::LeaveIfError( aItem.GetNextInt( expectedType ) ); + + TInt32 type = iProgram->ScheduleType(); + + if( type != expectedType ) + { + err = KErrCorrupt; + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::Program_DebugDumpL +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::Program_DebugDumpL( CStifItemParser& /*aItem*/ ) + { + VCXLOGLO1("CVideoScheduler_ApiTest::Program_DebugDumpL ------>"); + LogMethod(_L("Program_DebugDumpL")); + + TInt err( KErrNone ); + + iProgram->DebugDump(); + + return err; + } + +// ----------------------------------------------------------------------------- +// CVideoScheduler_ApiTest::ComparePrograms +// ----------------------------------------------------------------------------- +// +TInt CVideoScheduler_ApiTest::ComparePrograms( CCseScheduledProgram& aProgram1, CCseScheduledProgram& aProgram2 ) + { + TInt err( KErrNone ); + + if( aProgram1.DbIdentifier() != aProgram2.DbIdentifier() ) + { + VCXLOGLO3("CVideoScheduler_ApiTest::ComparePrograms: Error, db identifiers differ: %d vs. %d.", aProgram1.DbIdentifier(), aProgram2.DbIdentifier() ); + err = KErrCorrupt; + } + + return err; + } +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 826cea16efd9 -r 13a33d82ad98 videoutils_plat/videoscheduler_api/videoscheduler_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoutils_plat/videoscheduler_api/videoscheduler_api.metaxml Wed Sep 01 12:20:37 2010 +0100 @@ -0,0 +1,14 @@ + + +Video Scheduler API +Video Scheduler API provides an interface for creating scheduled events (for example, timed TV recording). +C++ +videoserviceutils + + + + +no +no + +