mp3rend.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:11k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #ifndef _HXMP3REN_H_
  36. #define _HXMP3REN_H_
  37. #include "ihxdefpackethookhlp.h"
  38. #include "baseobj.h"
  39. ///////////////////////////////////////////////////////////////////////////////
  40. // Constants
  41. //
  42. #define MY_PLUGIN_VERSION    0
  43. #define MY_DESCRIPTION       "RealNetworks MPEG Renderer Plugin"
  44. #define MY_COPYRIGHT         "(c) 1999-2000 RealNetworks, Inc. All rights reserved."
  45. #define MY_MORE_INFO_URL     "http://www.real.com"
  46. #define MY_DFLT_PREROLL     3000
  47. #ifdef DEMUXER
  48. #define MY_STREAM_MIME_TYPES {  "audio/X-MP3-draft-00",     
  49.                                 "audio/X-MP3-draft-00-RN",  
  50.                                 "audio/MPEG-ELEMENTARY",    
  51.                                 "audio/MPEG-ELEMENTARY-RN", 
  52.                                 "audio/MPEG-ELEMENTARY-RAW",
  53.                                 "audio/rn-mpeg",            
  54.                                 "audio/mpa-robust",         
  55.                                 "audio/MPA",                
  56.                                 "audio/mp1s",               
  57.                                 "audio/mp2p",               
  58.                                 "audio/vnd.rn-mp1s",        
  59.                                 "audio/vnd.rn-mp2p",        
  60. NULL}
  61. const int MIME_MPG1_2250[]  = { 8, -1 };
  62. const int MIME_MPG2_2250[]  = { 9, -1 };
  63. const int MIME_MPG1_SYS []  = { 10, -1 };
  64. const int MIME_MPG2_SYS[]   = { 11, -1 };
  65. #else
  66. #define MY_STREAM_MIME_TYPES {  "audio/X-MP3-draft-00",     
  67.                                 "audio/X-MP3-draft-00-RN",  
  68.                                 "audio/MPEG-ELEMENTARY",    
  69.                                 "audio/MPEG-ELEMENTARY-RN", 
  70.                                 "audio/MPEG-ELEMENTARY-RAW",
  71.                                 "audio/rn-mpeg",            
  72.                                 "audio/mpa-robust",         
  73.                                 "audio/MPA",                
  74. NULL}
  75. #endif
  76. const int MIME_FMT_BASIC[]  = { 0, 1, -1 };
  77. const int MIME_MPA_BASIC[]  = { 2, 3, 4, 5, -1 };
  78. const int MIME_FMT_3119[]   = { 6, -1 };
  79. const int MIME_MPA_2250[]   = { 7, -1 };
  80. #define STREAM_MAJOR_VERSION  0
  81. #define STREAM_MINOR_VERSION  0
  82. #define CONTENT_MAJOR_VERSION 0
  83. #define CONTENT_MINOR_VERSION 0
  84. ///////////////////////////////////////////////////////////////////////////////
  85. // Forward declarations
  86. class CPacketParser;
  87. ///////////////////////////////////////////////////////////////////////////////
  88. //
  89. //  CRnMp3Ren Class
  90. //
  91. //  This class inherits the minimum number of interfaces required to create
  92. //  an RMA Renderer plug-in. The IHXRenderer interface provides routines
  93. //  for handling all rendering operations. The IHXPlugin interface is
  94. //  required by all plug-ins to handle fundamental plug-in operations. Since
  95. //  this is a COM object, this class also inherits COM's IUnknown interface
  96. //  to handle object reference counting and interface query.
  97. //
  98. class CRnMp3Ren :   public IHXRenderer,
  99.                     public IHXInterruptSafe,
  100.                     public IHXDryNotification,
  101.                     public IHXStatistics,
  102.                     public IHXPlugin,
  103.     public IHXUpdateProperties,
  104.     public CHXBaseCountingObject
  105. {
  106. public:
  107.     CRnMp3Ren();
  108.     virtual ~CRnMp3Ren(void);
  109.     ///////////////////////////////////////////////////////////////////////////
  110.     //  IHXRenderer Interface Methods                       ref:  hxrendr.h
  111.     //
  112.     STDMETHOD(StartStream) (THIS_ IHXStream* pStream, IHXPlayer* pPlayer);
  113.     STDMETHOD(EndStream )  (THIS);
  114.     STDMETHOD(OnHeader  )  (THIS_ IHXValues* pStreamHeaderObj);
  115.     STDMETHOD(OnPacket  )  (THIS_ IHXPacket* pPacket, INT32 timeOffset);
  116.     STDMETHOD(OnTimeSync)  (THIS_ UINT32 currentPlayBackTime);
  117.     STDMETHOD(OnPreSeek )  (THIS_ UINT32 timeBefore, UINT32 timeAfter);
  118.     STDMETHOD(OnPostSeek)  (THIS_ UINT32 timeBefore, UINT32 timeAfter);
  119.     STDMETHOD(OnPause   )  (THIS_ UINT32 timeBeforePause);
  120.     STDMETHOD(OnBegin   )  (THIS_ UINT32 timeAfterBegin);
  121.     STDMETHOD(OnBuffering) (THIS_ UINT32 reason, UINT16 percentComplete);
  122.     STDMETHOD(GetRendererInfo)
  123.         (THIS_
  124.          REF(const char**) pStreamMimeTypes,
  125.          REF(UINT32)       initialGranularity
  126.         );
  127.     STDMETHOD(GetDisplayType)
  128.         (THIS_
  129.          REF(HX_DISPLAY_TYPE) displayType,
  130.          REF(IHXBuffer*)      pDisplayInfo
  131.         );
  132.     STDMETHOD(OnEndofPackets) (THIS);
  133.     ///////////////////////////////////////////////////////////////////////////
  134.     //  IHXInterruptSafe Interface Methods
  135.     //
  136.     STDMETHOD_(int,IsInterruptSafe)()
  137.     {return TRUE;};
  138.     
  139.     ///////////////////////////////////////////////////////////////////////////
  140.     //  IHXDryNotification Interface Methods                ref:  hxausvc.h
  141.     //
  142.     STDMETHOD(OnDryNotification)
  143.     (THIS_
  144.      UINT32 /*IN*/ ulCurrentStreamTime,
  145.      UINT32 /*IN*/ ulMinimumDurationRequired
  146.     );
  147.     ///////////////////////////////////////////////////////////////////////////
  148.     //  IHXStatistics Interface Methods                    ref:  hxausvc.h
  149.     //
  150.     STDMETHOD (InitializeStatistics)(THIS_ UINT32 ulRegistryID);
  151.     STDMETHOD (UpdateStatistics)(THIS);
  152.     
  153.     ///////////////////////////////////////////////////////////////////////////
  154.     //  IHXPlugin Interface Methods                         ref:  hxplugn.h
  155.     //
  156.     STDMETHOD(GetPluginInfo)
  157.         (THIS_ 
  158.           REF(int)         bLoadMultiple,
  159.           REF(const char*) pDescription,
  160.           REF(const char*) pCopyright,
  161.           REF(const char*) pMoreInfoURL,
  162.           REF(UINT32)      versionNumber
  163.         );
  164.     STDMETHOD(InitPlugin) (THIS_ IUnknown* pHXCore);
  165.     ///////////////////////////////////////////////////////////////////////////
  166.     //  IUnknown COM Interface Methods                          ref:  hxcom.h
  167.     //
  168.     STDMETHOD (QueryInterface ) (THIS_ REFIID ID, void** ppInterfaceObj);
  169.     STDMETHOD_(UINT32, AddRef ) (THIS);
  170.     STDMETHOD_(UINT32, Release) (THIS);
  171.     /************************************************************************
  172.      * Method:
  173.      *     IHXUpdateProperties::UpdatePacketTimeOffset
  174.      * Purpose:
  175.      *     Call this method to update the timestamp offset of cached packets
  176.      */
  177.     STDMETHOD(UpdatePacketTimeOffset) (THIS_ INT32 lTimeOffset);
  178.     /************************************************************************
  179.      * Method:
  180.      *     IHXUpdateProperties::UpdatePlayTimes
  181.      * Purpose:
  182.      *     Call this method to update the playtime attributes
  183.      */
  184.     STDMETHOD(UpdatePlayTimes)       (THIS_
  185.        IHXValues* pProps);
  186.     BOOL InitAudioStream(HXAudioFormat audioFmt);
  187.     BOOL ReInitAudioStream(HXAudioFormat audioFmt);
  188.     virtual void Render(IHXBuffer* pPCMBuffer, double dTime);
  189. protected:
  190.     // Private Class Methods
  191.     STDMETHOD (CheckStreamVersions) (THIS_ IHXValues* pHeader);    
  192.     void    SetPacketFormat(const char* szMimeType);
  193.     // Private Class Variables
  194.     INT32                       m_RefCount;         // Object's reference count
  195.     IUnknown*             m_pContext;
  196.     IHXCommonClassFactory*     m_pClassFactory;    // Creates common RMA classes
  197.     IHXStream                  *m_pStream;
  198.     IHXAudioPlayer             *m_pAudioPlayer;    // Audio services
  199.     IHXAudioStream             *m_pDefAudStream,   // Default pcm stream properties
  200.                                 *m_aAudStreamList[256],
  201.                                 *m_pAudioStream;    // Buffer to write PCM data
  202.     IHXAudioPushdown2 *m_pAudioPushdown2;
  203.     IHXValues                  *m_pHeader;         // For audio init
  204.     CPacketParser               *m_pPacketParser;   // Packet parser
  205.     UCHAR                       m_bInSeekMode,      // In the process of seeking
  206.                                 m_bDiscontinuity,   // Break in the PCM data
  207.                                 m_bEndOfPackets,    // No more packets are coming
  208.                                 m_bStarving;        // We are rebuffering
  209.     UINT8                       m_wAudStream,       // Index of our audio stream list
  210.                                 m_nPacketsNeeded;   // Num packets in preroll
  211.     UINT32                      m_ulDelay,          // ms of delay for presentation
  212.                                 m_ulNumPackets,    
  213.                                 m_ulPreroll;
  214.     LONG32 m_lTimeLineOffset;  // ms of presentation time-line offset
  215.     // Statistics members
  216.     IHXRegistry              *m_pRegistry;
  217.     UINT32                      m_ulRegistryID,    
  218.                                 m_ulChannelsRegID,
  219.                                 m_ulCodecRegID;
  220.     
  221.     UINT32                      m_ulPacketsDecoded,
  222.                                 m_ulFramesDecoded,
  223.                                 m_ulBadPackets;
  224.     UCHAR                       m_bStarted;
  225.     BOOL                        m_bTrustPackets;
  226.     // Private Static Class Variables
  227.     static const char* const      zm_pDescription;
  228.     static const char* const     zm_pCopyright;
  229.     static const char* const     zm_pMoreInfoURL;
  230.     static const char* const     zm_pStreamMimeTypes[];
  231.     IHXDefaultPacketHookHelper* m_pDefaultPacketHookHelper;
  232.     PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME       // Avoids GCC compiler warning
  233. };
  234. #endif