Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
11 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // INTEL Corporation Proprietary Information
  3. // This listing is supplied under the terms of a license agreement with Intel
  4. // Corporation and many not be copied nor disclosed except in accordance
  5. // with the terms of that agreement.
  6. // Copyright (c) 1995, 1996 Intel Corporation.
  7. //
  8. //
  9. // Module Name: PPMSnd.h
  10. // Abstract: Header file for PPM Send COM Object
  11. // Environment: MSVC 4.0, OLE 2
  12. /////////////////////////////////////////////////////////////////////////////////
  13. // NOTES:
  14. //
  15. // The three functions that are members of the IUnknown interface need to be
  16. // implemented in the most derived class. (Generally the class derived from
  17. // this one.) This is done because if one of your super classes
  18. // is derived from more than one interface, each of which derive from IUnknown,
  19. // the compiler will be confused as to which implementation of the IUnknown
  20. // interface to use. So, by requiring that only the most derived class implement
  21. // these functions then you will never run into this problem.
  22. //
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // //This code goes into your class declaration, it defines three functions
  26. // //IUnknown Functions (Overrides)
  27. //
  28. // STDMETHODIMP GetInterface( REFIID riid, LPVOID FAR* ppvObj );
  29. // STDMETHODIMP_( ULONG )AddRef( void );
  30. // STDMETHODIMP_( ULONG )Release( void );
  31. //
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // This code is the implementation of
  34. // CUnknown Functions (Overrides)
  35. //
  36. // //Three Cases:
  37. // //
  38. // //1. If you multiply derive from ppmSend and another interface you would have to
  39. // //write your own QueryInterface and call CUnknown::QueryInterface AND handle
  40. // //the interface you derived from. As well as having the GetInterface function
  41. // //as shown below.
  42. //
  43. // //2. If you derive from another object and ppmSend you would need to write your
  44. // //own QueryInterface to call CUnknown::QueryInterface and
  45. // //OtherObject::QueryInterface. As well as having the GetInterface function shown
  46. // //below.
  47. //
  48. // //3. If you are only derived from ppmSend then all you need is the code below.
  49. //
  50. // STDMETHODIMP GetInterface( void REFIID riid, LPVOID FAR* ppvObj )
  51. // {
  52. // return ppmSend::GetInterface( riid, ppvObj );
  53. // }
  54. //
  55. // STDMETHODIMP_( ULONG )AddRef( void )
  56. // {
  57. // return CUnknown::AddRef();
  58. // }
  59. //
  60. // STDMETHODIMP_( ULONG )Release( void )
  61. // {
  62. // return CUnknown::Release();
  63. // }
  64. //
  65. /////////////////////////////////////////////////////////////////////////////
  66. #ifndef PPMSEND_H
  67. #define PPMSEND_H
  68. #include "isubmit.h"
  69. #include "ippm.h"
  70. #include "ppm.h"
  71. #include "freelist.h"
  72. #include "core.h"
  73. #include "que.h"
  74. class ppmSend : public ppm,
  75. public IPPMSend,
  76. public IPPMSendExperimental,
  77. public IPPMSendSession,
  78. public ISubmit,
  79. public ISubmitCallback ,
  80. public ISubmitUser,
  81. public CUnknown
  82. {
  83. protected:
  84. ///////////////////////
  85. //Members
  86. ISubmit *m_pSubmit;
  87. ISubmitCallback *m_pSubmitCallback;
  88. IMalloc *m_pIMalloc;
  89. FreeList *m_pRTPHeaders;
  90. WORD m_SequenceNum;
  91. const int m_Frequency;
  92. int m_MaxPacketSize; //Max size the packet should be
  93. int m_MaxDataSize; //Max amount of bytes of data in a packet
  94. //i.e. MaxPacketSize-Headers
  95. int m_reg_NumMsgDescriptors; //Number of BufDescriptors.
  96. int m_reg_NumFragDescriptors; //Number of FragDescriptors.
  97. //Things only accessed in internal functions.
  98. BOOL m_inFlushMode;
  99. BOOL m_DropBufferFlag;
  100. MsgDescriptor *m_pCurrentBuffer;
  101. DWORD m_CurrentOffset;
  102. DWORD m_CurrentFragSize;
  103. BOOL m_lastBufSilence;
  104. BOOL m_markTalkSpurt;
  105. DWORD m_dwStartTime;
  106. DWORD m_dwBase;
  107. DWORD m_dwLastTime;
  108. DWORD m_dwFreq;
  109. /////////////////////////////////////////////////////////////////////////////
  110. /////////////////////////////////////////////////////////////////////////////
  111. //External PPMSend Functions
  112. /////////////////////////////////////////////////////////////////////////////
  113. /////////////////////////////////////////////////////////////////////////////
  114. public:
  115. //////////////////////////////////////////////////////////////////////////////
  116. // PPMSend Functions
  117. //constructor:
  118. ppmSend(int PayloadTypeArg, int ProfileHdrSizeArg, int FreqArg, IUnknown* pUnkOuter, IUnknown** ppUnkInner);
  119. //destructor
  120. ~ppmSend();
  121. //////////////////////////////////////////////////////////////////////////////
  122. // IPPMSend Functions (Overrides)
  123. STDMETHOD(InitPPMSend)(THIS_ int MaxBufferSize,
  124. int iBuffers,
  125. int iPackets,
  126. DWORD dwCookie);
  127. STDMETHOD(InitPPMSend)(THIS_ int MaxBufferSize, DWORD dwCookie)
  128. {
  129. m_LimitBuffers = FALSE;
  130. return InitPPMSend(MaxBufferSize,
  131. DEFAULT_MSG_COUNT_SND,
  132. DEFAULT_FRAG_COUNT,
  133. dwCookie);
  134. }
  135. STDMETHOD(SetSession)(THIS_ PPMSESSPARAM_T *pSessparam);
  136. STDMETHOD(SetAlloc)(THIS_ IMalloc *pIMalloc);
  137. //see documentation (PHEPS.DOC)
  138. //////////////////////////////////////////////////////////////////////////////
  139. // IPPMSendSession Functions (Overrides)
  140. //see documentation (PHEPS.DOC)
  141. STDMETHOD(GetPayloadType)(THIS_ LPBYTE lpcPayloadType);
  142. STDMETHOD(SetPayloadType)(THIS_ BYTE cPayloadType);
  143. //////////////////////////////////////////////////////////////////////////////
  144. // ISubmit Functions (Overrides)
  145. //see documentation (PHEPS.DOC)
  146. STDMETHOD(InitSubmit)(ISubmitCallback *pSubmitCallback);
  147. //see documentation (PHEPS.DOC)
  148. STDMETHOD(Submit)(WSABUF *pWSABuffer, DWORD BufferCount,
  149. void *pUserToken, HRESULT Error);
  150. //see documentation (PHEPS.DOC)
  151. //Stubs for now; overriding both ISubmit calls and ISubmitCallback
  152. //calls for ReportError
  153. STDMETHOD_(void,ReportError)(THIS_ HRESULT Error){}
  154. STDMETHOD(Flush)(THIS);
  155. //////////////////////////////////////////////////////////////////////////////
  156. // ISubmitCallback Functions (Overrides)
  157. //see documentation (PHEPS.DOC)
  158. STDMETHOD_(void,SubmitComplete)(void *pUserToken, HRESULT Error);
  159. STDMETHOD_(void,ReportError)(THIS_ HRESULT Error, int=0){}
  160. //////////////////////////////////////////////////////////////////////////////
  161. // ISubmitUser Functions (Overrides)
  162. STDMETHOD(SetOutput)(THIS_ IUnknown *pSubmit);
  163. /////////////////////////////////////////////////////////////////////////////
  164. /////////////////////////////////////////////////////////////////////////////
  165. //Internal PPMSend Functions
  166. /////////////////////////////////////////////////////////////////////////////
  167. /////////////////////////////////////////////////////////////////////////////
  168. protected:
  169. /////////////////////////////////////////////////////////////////////////////
  170. // CUnknown Functions (Overrides)
  171. //
  172. // Call this method to get interface pointers supported by derived objects
  173. // called by CInnerUnknown::QueryInterface; should return S_FALSE
  174. // if interface is AddRef'd, S_OK if caller needs to AddRef the interface.
  175. STDMETHOD(GetInterface)( REFIID riid, LPVOID FAR* ppvObj );
  176. /////////////////////////////////////////////////////////////////////////////
  177. // ppm Functions (Overrides)
  178. //
  179. //Need to override this so we can delete memory when a frag descriptor is deleted.
  180. //It has already been declared as virtual in ppm.h
  181. HRESULT FreeFragDescriptor(FragDescriptor* frag);
  182. /////////////////////////////////////////////////////////////////////////////
  183. // ppmSend Functions
  184. //
  185. //////////////////////////////////////////////////////////////////////////////////////////
  186. //MakeFragments: Intelligently calls the rest of the internal functions.
  187. //////////////////////////////////////////////////////////////////////////////////////////
  188. HRESULT MakeFragments(void);
  189. //////////////////////////////////////////////////////////////////////////////////////////
  190. //InitFragStatus: Initializes values needed for fragmenting.
  191. //////////////////////////////////////////////////////////////////////////////////////////
  192. virtual HRESULT InitFragStatus(MsgDescriptor *pMsgDescrip);
  193. //////////////////////////////////////////////////////////////////////////////////////////
  194. //AllocFrag: Allcates memory for FragDescriptor and all things it points to.
  195. //////////////////////////////////////////////////////////////////////////////////////////
  196. virtual FragDescriptor * AllocFrag();
  197. //////////////////////////////////////////////////////////////////////////////////////////
  198. //DeleteFrag: Virtual This function does the opposite of AllocFrag, it deletes any memory allocated
  199. // by AllocFrag.
  200. //////////////////////////////////////////////////////////////////////////////////////////
  201. virtual void DeleteFrag(FragDescriptor *pFragDescrip, HRESULT Error);
  202. //////////////////////////////////////////////////////////////////////////////////////////
  203. //FragStatus: This funtion returns TRUE if still fragmenting, FALSE if fragmenting is done.
  204. //////////////////////////////////////////////////////////////////////////////////////////
  205. virtual BOOL FragStatus();
  206. //////////////////////////////////////////////////////////////////////////////////////////
  207. //MakeFrag: This function should get the next fragment from the buffer and fill in the
  208. // RTP header and payload header.
  209. //////////////////////////////////////////////////////////////////////////////////////////
  210. virtual HRESULT MakeFrag(FragDescriptor *pFragDescrip); //fills in fields, including data of fragment class.
  211. //////////////////////////////////////////////////////////////////////////////////////////
  212. //SetMarkerBit: Determines whether to set the marker bit or not. lastPacket is TRUE if
  213. // this is the last packet of the frame; FALSE if not.
  214. //////////////////////////////////////////////////////////////////////////////////////////
  215. virtual BOOL SetMarkerBit(BOOL lastPacket);
  216. //////////////////////////////////////////////////////////////////////////////////////////
  217. //SendFrag: Puts the pieces of the packet into a WSABUF and sends the packet to the client
  218. // with the callback supplied by the client.
  219. //////////////////////////////////////////////////////////////////////////////////////////
  220. virtual HRESULT SendFrag(FragDescriptor *pFragDescrip);
  221. //////////////////////////////////////////////////////////////////////////////////////////
  222. //MakeTimeStamp: Generate a time stamp
  223. //////////////////////////////////////////////////////////////////////////////////////////
  224. virtual DWORD MakeTimeStamp(MsgDescriptor* pMsgDescrip, BOOL bStartStream, BOOL bUseInputTime);
  225. //////////////////////////////////////////////////////////////////////////////////////////
  226. //FreeProfileHeader: Given a buffer as type void, frees up a profile header.
  227. //////////////////////////////////////////////////////////////////////////////////////////
  228. virtual void FreeProfileHeader(void *pBuffer);
  229. //////////////////////////////////////////////////////////////////////////////////////////
  230. //ReadProfileHeader: Given a buffer as type void, returns the data for a profile header.
  231. // Does nothing for the Generic case. Intended for overrides for various
  232. // payloads.
  233. //////////////////////////////////////////////////////////////////////////////////////////
  234. virtual void *ReadProfileHeader(void *pProfileHeader);
  235. }; //end of ppmSend class
  236. #endif