srcinfo.h
Upload User: dangjiwu
Upload Date: 2013-07-19
Package Size: 42019k
Code Size: 14k
Category:

Symbian

Development Platform:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: srcinfo.h,v 1.8.2.1 2004/07/09 02:05:58 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #ifndef _SOURCEINFO_
  50. #define _SOURCEINFO_
  51. #include "hxcbobj.h"
  52. // forward decl.
  53. _INTERFACE IHXPlayer;      
  54. _INTERFACE IHXPlayerProps;
  55. _INTERFACE IHXRenderer;
  56. _INTERFACE IHXScheduler;
  57. _INTERFACE IHXPendingStatus;
  58. _INTERFACE IHXMetaTrack;
  59. _INTERFACE IHXMetaLayout;
  60. class HXSource;
  61. class HXStream;
  62. class CTimeSyncCallback;
  63. class CSignatureChecker;
  64. struct STREAM_INFO;
  65. typedef ULONG32 BufferingReason;
  66. struct RepeatInfo;
  67. struct RendererInfo;
  68. class  SourceInfo;
  69. class  HXPlayer;
  70. class  HXMutex;
  71. struct IHXPluginSearchEnumerator;
  72. struct timeSyncParamStruct
  73. {
  74.     SourceInfo* pSourceInfo;
  75.     RendererInfo* pRenderInfo;
  76. };
  77. struct RepeatInfo
  78. {
  79.     UINT16  uTrackID;
  80.     UINT32  ulStart;
  81.     UINT32  ulEnd;
  82.     UINT32  ulDelay;
  83.     UINT32  ulDuration;
  84. };
  85. // stores header info for each renderer
  86. struct RendererInfo
  87. {
  88.     RendererInfo()
  89.     {
  90. m_pRenderer     = NULL;
  91. m_pStreamInfo     = NULL;
  92. m_ulLatestEventTime     = 0;
  93. m_ulGranularity     = 0;
  94. m_ulLastSyncTime     = 0;
  95. m_ulNextDueSyncTime     = 0;
  96. m_ulDuration     = 0;
  97. m_pTimeSyncCallback     = 0;
  98. m_pTimeSyncCBTime     = new Timeval;
  99. m_bIsFirstCallback     = TRUE;
  100. m_BufferingReason     = BUFFERING_START_UP;
  101. m_ulNumberOfPacketsQueued   = 0;
  102. m_ulStreamStartTime     = 0;
  103. m_ulTimeDiff     = 0;
  104. m_bTimeDiffPositive     = TRUE;
  105. m_bIsFirstPacket     = TRUE;
  106. m_bIsFirstTimeSync     = TRUE;
  107. m_bIsPersistent     = FALSE;
  108. m_pStream     = NULL;
  109. m_pRendererEnumerator     = NULL;
  110. m_bInitialBeginToBeSent     = TRUE;
  111.      m_bInterruptSafe     = FALSE;
  112. m_bDurationTimeSyncSent     = FALSE;
  113. m_bOnEndOfPacketSent     = FALSE;
  114.     };
  115.     ~RendererInfo()
  116.     {
  117. if (m_pTimeSyncCBTime)
  118. {
  119.     delete m_pTimeSyncCBTime;
  120.     m_pTimeSyncCBTime = 0;
  121. }
  122.     };
  123.     IHXRenderer* m_pRenderer;
  124.     STREAM_INFO* m_pStreamInfo;
  125.     ULONG32 m_ulLatestEventTime;
  126.     ULONG32 m_ulGranularity;
  127.     ULONG32 m_ulLastSyncTime;
  128.     ULONG32 m_ulNextDueSyncTime;
  129.     ULONG32 m_ulDuration;
  130.     CTimeSyncCallback*  m_pTimeSyncCallback;
  131.     Timeval* m_pTimeSyncCBTime;
  132.     BufferingReason m_BufferingReason;
  133.     UINT32 m_ulStreamStartTime;
  134.     UINT32 m_ulTimeDiff;
  135.     HXStream* m_pStream;
  136.     IHXPluginSearchEnumerator* m_pRendererEnumerator;
  137.     UINT16 m_ulNumberOfPacketsQueued : 16;
  138.     HX_BITFIELD m_bIsCallbackPending : 1;
  139.     HX_BITFIELD m_bIsFirstCallback : 1;
  140.     HX_BITFIELD m_bTimeDiffPositive : 1;
  141.     HX_BITFIELD m_bIsFirstPacket : 1;
  142.     HX_BITFIELD m_bIsFirstTimeSync : 1;
  143.     HX_BITFIELD m_bIsPersistent : 1;
  144.     HX_BITFIELD m_bInitialBeginToBeSent : 1;
  145.     HX_BITFIELD m_bInterruptSafe : 1;
  146.     HX_BITFIELD m_bDurationTimeSyncSent : 1;
  147.     HX_BITFIELD m_bOnEndOfPacketSent : 1;
  148. };
  149. /*
  150.  * -- LIVE SYNC SUPPORT --
  151.  *
  152.  * The SharedWallClock class is used for supporting syncing of
  153.  * multiple live sources. See other LIVE SYNC SUPPORT comments 
  154.  * in the source code for more details.
  155.  */
  156. class SourceInfo;
  157. class SharedWallClock
  158. {
  159. protected:
  160.     CHXString m_strName;
  161.     UINT32 m_ulStartTime;
  162.     CHXSimpleList m_UserList;
  163.     /* A wall clock is only associated with one player */
  164.     HXPlayer* m_pPlayer; 
  165. public:
  166.     SharedWallClock(const char* pName, UINT32 ulStartTime,HXPlayer* pPlayer);
  167.     UINT32 ResetStartTime(UINT32 ulStartTime);
  168.     UINT32 GetStartTime() { return m_ulStartTime; };
  169.     void AddUser(SourceInfo* pSourceInfo);
  170.     void RemoveUser(SourceInfo* pSourceInfo);
  171. };
  172. class SourceInfo
  173. {
  174. public:
  175. SourceInfo(HXPlayer* pPlayer);
  176. ~SourceInfo();
  177.     HX_RESULT Begin(void);
  178.     HX_RESULT Pause(void);
  179.     HX_RESULT Seek(UINT32 ulSeekTo);
  180.     void Stop(EndCode endCode = END_STOP);
  181.     void Remove(void);
  182.     void Reset(void);
  183.     virtual void DoCleanup(EndCode endCode = END_STOP);
  184.     void RenderersCleanup(void);
  185.     virtual void RenderersCleanupExt(RendererInfo* pRendInfo);
  186.     virtual RendererInfo* NewRendererInfo();
  187.     HX_RESULT BeginTrack(void);    
  188.     HX_RESULT PauseTrack(void);
  189.     HX_RESULT SeekTrack(UINT32 ulSeekTime);    
  190.     HX_RESULT StopTrack(void);    
  191.     HX_RESULT SetSoundLevel(UINT16 uSoundLevel, BOOL bReflushAudioDevice);
  192.     HX_RESULT ProcessIdle(BOOL bIsFirst,
  193.     ULONG32& ulNumStreamsToBeFilled,
  194.     BOOL& bIsBuffering,
  195.     UINT16& uLowestBuffering,
  196.     BOOL bPersistent = FALSE);
  197.     HX_RESULT Register(void);
  198.     HX_RESULT UnRegister(void);
  199.     void CheckIfDone(void);
  200.     void SetupRendererSites(BOOL bIsPersistent);
  201.     HX_RESULT InitializeAndSetupRendererSites();
  202.     HX_RESULT InitializeRenderers(BOOL& bSourceInitialized);
  203.     virtual HX_RESULT InitializeRenderersExt(BOOL& bSourceInitialized);
  204.     HX_RESULT SetupStreams(void);
  205.     HX_RESULT SetupRenderer(RendererInfo*& pRendInfo, 
  206.       IHXRenderer*& pRenderer,
  207.       STREAM_INFO*& pStreamInfo, 
  208.       HXStream*& pStream);
  209.     HX_RESULT CloseRenderers(void);
  210.     HX_RESULT OnTimeSync(ULONG32 ulCurrentTime);
  211.     HX_RESULT OnTimeSync(RendererInfo* pRendInfo, 
  212.    BOOL bUseCurrentTime = FALSE);
  213.     void ChangeAccelerationStatus(BOOL bMayBeAccelerated,
  214.  BOOL bUseAccelerationFactor = FALSE,
  215.  UINT32 ulAccelerationFactor = 0);
  216.     BOOL IsInitialized()     {return m_bInitialized;};
  217.     BOOL AreStreamsSetup()     {return m_bAreStreamsSetup;};
  218.     
  219.     BOOL IsRegistered()     {return m_bIsRegisterSourceDone;}; 
  220.     BOOL IsActive()     {return m_bActive;}; 
  221.     void Resumed();
  222.     void UpdateDuration(UINT32 ulDuration);
  223.     void UpdateDelay(UINT32 ulDelay);
  224.     BOOL ToBeInitialized() {return m_bTobeInitializedBeforeBegin;};
  225.     void ReInitializeStats();
  226.     BOOL IsRebufferDone(void);
  227.     HX_RESULT HandleRedirectRequest(char* pURL);
  228.     void ScheduleProcessCallback();
  229.     void SetLiveSyncStartTime(HXSource* pSource, 
  230.      RendererInfo* pTmpRendInfo, 
  231.      UINT32 ulLowestTime);
  232.     BOOL AllOtherStreamsHaveEnded(STREAM_INFO* pThisStreamInfo);    
  233.     CHXSimpleList* GetRepeatList() {return m_bLeadingSource?m_pRepeatList:m_pPeerSourceInfo->m_pRepeatList; };
  234.     HX_RESULT AppendRepeatRequest(UINT16 uTrackID, IHXValues* pTrack);
  235.     BOOL IsAdjustSeekNeeded(UINT32 ulSeekTime);
  236.     SourceInfo* DoAdjustSeek(UINT32 ulSeekTime);
  237.     UINT32 GetActiveDuration();
  238.     BOOL KeepSourceActive(void);    
  239.     BOOL IsDone() { return (BOOL)m_bDone;};
  240.     friend class HXPlayer;
  241.     friend class NextGroupManager;
  242.     friend class PrefetchManager;
  243.     friend class CTimeSyncCallback;
  244.     friend class ProcessCallback;
  245.     friend class HXPersistentComponent;
  246.     friend class HXPersistentComponentManager;
  247.     friend class HXSource;
  248.     friend class HXFileSource;
  249.     friend class HXNetSource;
  250.     // XXX HP
  251.     LISTPOSITION m_curPosition;
  252.     CHXSimpleList* m_pRepeatList;    
  253.     SourceInfo* m_pPeerSourceInfo;
  254.     HXSource* m_pSource;
  255.     HX_BITFIELD m_bLeadingSource : 1;
  256.     HX_BITFIELD m_bSeekPending : 1;
  257.     HX_BITFIELD m_bIndefiniteDuration : 1;
  258.     HX_BITFIELD m_bRepeatPending : 1;
  259.     HX_BITFIELD m_bRepeatIndefinite : 1;    
  260.     HX_BITFIELD m_bSeekToLastFrame : 1;
  261.     UINT16 m_uGroupID;
  262.     UINT16 m_uTrackID;
  263.     UINT32 m_ulPersistentComponentID;
  264.     UINT32 m_ulPersistentComponentSelfID;
  265.     UINT32 m_ulMaxDuration;    
  266.     UINT32 m_ulSeekTime;
  267.     UINT32 m_ulRepeatInterval;
  268.     UINT32 m_ulRepeatDelayTimeOffset;
  269.     CHXMapLongToObj* m_pRendererMap;     // list of renderers for this source...
  270. protected:
  271.     HXPlayer* m_pPlayer;
  272.     IHXPendingStatus* m_pStatus;
  273.     IHXRendererAdviseSink* m_pRendererAdviseSink;
  274.     HX_BITFIELD m_bDone : 1;     // source end...all streams are done..
  275.     HX_BITFIELD m_bStopped : 1;     // track stopped
  276.     HX_BITFIELD m_bInitialized : 1; // all streams of source have been 
  277.     // associated with renderers?
  278.     HX_BITFIELD m_bAllPacketsReceived : 1;
  279.     HX_BITFIELD m_bActive : 1;
  280.     HX_BITFIELD m_bIsPersistentSource : 1;
  281.     HX_BITFIELD m_bIsRegisterSourceDone : 1;
  282.     HX_BITFIELD m_bAltURL : 1;
  283.     HX_BITFIELD m_bToBeResumed : 1;
  284.     HX_BITFIELD m_bAreStreamsSetup : 1;
  285.     HX_BITFIELD m_bTrackStartedToBeSent : 1;
  286.     HX_BITFIELD m_bTrackStoppedToBeSent : 1;
  287.     HX_BITFIELD m_bPrefetch : 1;
  288.     HX_BITFIELD m_bLoadPluginAttempted : 1;
  289.     HX_BITFIELD m_bTobeInitializedBeforeBegin : 1;
  290.     HX_BITFIELD m_bLocked : 1;
  291.     HX_BITFIELD m_bIsTrackDurationSet : 1;
  292.     HX_BITFIELD m_bDurationTimeSyncScheduled : 1;
  293.     HX_BITFIELD m_bAudioDeviceReflushHint : 1;
  294.     HX_RESULT m_lastErrorFromMainURL;
  295.     HX_RESULT           m_lastError;
  296.     CHXString m_lastErrorStringFromMainURL;
  297.     CHXString m_id;
  298.     CHXSimpleList* m_pCurrentScheduleList;
  299.     /*
  300.            repeat0            repeat1             repeat2            repeat3
  301.      |------------------|------------------|------------------|------------------|
  302.      ^          ^       ^                                                        ^
  303.      |----------|       |                                                        |
  304.    (sourceduration)     |                                                        |
  305.      ^                  |                                                        |
  306.      |------------------|                                                        |
  307.        (trackduration)                                                           |
  308.      ^                                                                           |
  309.      |---------------------------------------------------------------------------|
  310.                                 (totaltrackduration)
  311.      */
  312.     UINT32 m_ulSourceDuration; // encoded duration
  313.     UINT32 m_ulTrackDuration; // customized duration(per repeat)
  314.     UINT32 m_ulTotalTrackDuration; // customized total duration(total repeats)
  315.     UINT32 m_ulPausedStartTime;
  316.     UINT16* m_pDependNode;
  317.     UINT16 m_uNumDependencies;
  318.     HXMutex* m_pMutex;
  319.     CHXGenericCallback*m_pProcessCallback;
  320.     INT64 m_llLatestPacketTime;
  321.     PrefetchType m_prefetchType;
  322.     UINT32 m_ulPrefetchValue;
  323.     UINT16 m_uSoundLevel;
  324.     FillType m_fillType;
  325. /*
  326.  * -- LIVE SYNC SUPPORT --
  327.  *
  328.  * The SharedWallClock class is used for supporting syncing of
  329.  * multiple live sources. See other LIVE SYNC SUPPORT comments 
  330.  * in the source code for more details.
  331.  */
  332. private:
  333.     UINT32 CalculateLiveStartTime(IHXPacket* pFirstPacket);
  334.     void DoneWithWallClock();
  335.     UINT32 m_ulStreamStartTime;
  336.     CHXString m_strWallClockName;
  337.     SharedWallClock* m_pWallClock;
  338. public:
  339.     void ResetStartTime(UINT32 ulStartTime);
  340.     static void         TimeSyncCallback(void* pParam);
  341.     static void         ProcessCallback(void* pParam);
  342. };
  343. class CTimeSyncCallback : public CHXGenericCallback
  344. {
  345. public:
  346.     CTimeSyncCallback(void* pParam, fGenericCBFunc pFunc)
  347.      : CHXGenericCallback(pParam, pFunc)
  348.     {
  349.         m_pParam = (void*)new struct timeSyncParamStruct;
  350.         *((struct timeSyncParamStruct*)m_pParam) = *((struct timeSyncParamStruct*)pParam);
  351.     }
  352.     virtual ~CTimeSyncCallback()
  353.     {
  354.         if (m_pParam)
  355.         {
  356.             delete (timeSyncParamStruct*)m_pParam;
  357.         }
  358.     }
  359. };
  360. #endif /*_SOURCEINFO_*/