Leaked source code of windows server 2003
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.

343 lines
7.0 KiB

  1. /*
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. sdp.h
  5. Abstract:
  6. Author:
  7. */
  8. #ifndef __SDP__
  9. #define __SDP__
  10. #include "sdpcommo.h"
  11. #include "sdpcset.h"
  12. #include "sdpgen.h"
  13. #include "sdpver.h"
  14. #include "sdporigi.h"
  15. #include "sdpconn.h"
  16. #include "sdpbw.h"
  17. #include "sdpatt.h"
  18. #include "sdpcstrl.h"
  19. #include "sdpbstrl.h"
  20. #include "sdptime.h"
  21. #include "sdpadtex.h"
  22. #include "sdpenc.h"
  23. #include "sdpmedia.h"
  24. enum PARSE_STATE
  25. {
  26. STATE_START,
  27. STATE_VERSION,
  28. STATE_ORIGIN,
  29. STATE_SESSION_NAME,
  30. STATE_TITLE,
  31. STATE_URI,
  32. STATE_EMAIL,
  33. STATE_PHONE,
  34. STATE_CONNECTION,
  35. STATE_BANDWIDTH,
  36. STATE_TIME,
  37. STATE_REPEAT,
  38. STATE_ADJUSTMENT,
  39. STATE_KEY,
  40. STATE_ATTRIBUTE,
  41. STATE_MEDIA,
  42. STATE_MEDIA_TITLE,
  43. STATE_MEDIA_CONNECTION,
  44. STATE_MEDIA_BANDWIDTH,
  45. STATE_MEDIA_KEY,
  46. STATE_MEDIA_ATTRIBUTE,
  47. STATE_NUM_STATES // not a valid state, merely to count the number of states
  48. };
  49. class _DllDecl SDP
  50. {
  51. public:
  52. inline SDP();
  53. BOOL Init();
  54. BOOL IsValid();
  55. void Reset();
  56. BOOL IsModified();
  57. BOOL ParseSdpPacket(
  58. IN CHAR *SdpPacket,
  59. IN SDP_CHARACTER_SET CharacterSet = CS_IMPLICIT
  60. );
  61. // clears the modified state for each member field/value
  62. // this is used in sdpblb.dll to clear the modified state (when an sdp
  63. // is parsed in, the state of all parsed in fields/values is modified) and
  64. // the m_WasModified dirty flag
  65. void ClearModifiedState();
  66. CHAR *GenerateSdpPacket();
  67. inline BOOL GetWasModified();
  68. inline SDP_CHARACTER_SET GetCharacterSet();
  69. inline SDP_VERSION &GetProtocolVersion();
  70. inline SDP_ORIGIN &GetOrigin();
  71. inline SDP_REQD_BSTRING_LINE &GetSessionName();
  72. inline SDP_REQD_BSTRING_LINE &GetSessionTitle();
  73. inline SDP_CHAR_STRING_LINE &GetUri();
  74. inline SDP_EMAIL_LIST &GetEmailList();
  75. inline SDP_PHONE_LIST &GetPhoneList();
  76. inline SDP_CONNECTION &GetConnection();
  77. inline SDP_BANDWIDTH &GetBandwidth();
  78. inline void ClearDestroyTimeListFlag();
  79. inline SDP_TIME_LIST &GetTimeList();
  80. inline SDP_ENCRYPTION_KEY &GetEncryptionKey();
  81. inline SDP_ATTRIBUTE_LIST &GetAttributeList();
  82. inline void ClearDestroyMediaListFlag();
  83. inline SDP_MEDIA_LIST &GetMediaList();
  84. virtual ~SDP();
  85. protected:
  86. // tracks if the last attempt to generate an sdp packet failed (starts with FALSE)
  87. BOOL m_LastGenFailed;
  88. CHAR *m_SdpPacket;
  89. DWORD m_BytesAllocated;
  90. DWORD m_SdpPacketLength;
  91. // dirty flag - is initially false and is set to TRUE when an sdp is generated because it had
  92. // been modified since the last time the sdp was generated.
  93. // (as IsModified() becomes FALSE after that)
  94. BOOL m_WasModified;
  95. CHAR *m_Current;
  96. PARSE_STATE m_ParseState;
  97. BOOL m_DestroyMediaList;
  98. BOOL m_DestroyTimeList;
  99. SDP_CHARACTER_SET m_CharacterSet;
  100. SDP_VERSION m_ProtocolVersion;
  101. SDP_ORIGIN m_Origin;
  102. SDP_REQD_BSTRING_LINE m_SessionName;
  103. SDP_REQD_BSTRING_LINE m_SessionTitle; // optional
  104. SDP_CHAR_STRING_LINE m_Uri; // optional
  105. SDP_EMAIL_LIST m_EmailList; // optional
  106. SDP_PHONE_LIST m_PhoneList; // optional
  107. SDP_CONNECTION m_Connection;
  108. SDP_BANDWIDTH m_Bandwidth; // optional
  109. SDP_TIME_LIST *m_TimeList; // optional
  110. SDP_ENCRYPTION_KEY m_EncryptionKey; // optional
  111. SDP_ATTRIBUTE_LIST m_AttributeList; // optional
  112. SDP_MEDIA_LIST *m_MediaList;
  113. BOOL DetermineCharacterSet(
  114. IN CHAR *SdpPacket,
  115. OUT SDP_CHARACTER_SET &CharacterSet
  116. );
  117. private:
  118. BOOL GetType(
  119. OUT CHAR &Type,
  120. OUT BOOL &EndOfPacket
  121. );
  122. BOOL CheckTransition(
  123. IN CHAR Type,
  124. IN PARSE_STATE CurrentParseState,
  125. OUT PARSE_STATE &NewParseState
  126. );
  127. BOOL GetValue(IN CHAR Type);
  128. BOOL IsValidEndState() const;
  129. };
  130. inline
  131. SDP::SDP(
  132. )
  133. : m_SessionName(SDP_INVALID_SESSION_NAME, SESSION_NAME_STRING),
  134. m_SessionTitle(SDP_INVALID_SESSION_TITLE, TITLE_STRING),
  135. m_Uri(SDP_INVALID_URI, URI_STRING),
  136. m_AttributeList(ATTRIBUTE_STRING),
  137. m_DestroyMediaList(FALSE),
  138. m_MediaList(NULL),
  139. m_DestroyTimeList(FALSE),
  140. m_TimeList(NULL),
  141. m_SdpPacket(NULL),
  142. m_Current(NULL),
  143. m_ParseState(STATE_START),
  144. m_LastGenFailed(FALSE),
  145. m_WasModified(FALSE),
  146. m_BytesAllocated(0),
  147. m_SdpPacketLength(0)
  148. {
  149. }
  150. inline BOOL
  151. SDP::GetWasModified(
  152. )
  153. {
  154. return m_WasModified;
  155. }
  156. inline SDP_CHARACTER_SET
  157. SDP::GetCharacterSet(
  158. )
  159. {
  160. return m_CharacterSet;
  161. }
  162. inline SDP_VERSION &
  163. SDP::GetProtocolVersion(
  164. )
  165. {
  166. return m_ProtocolVersion;
  167. }
  168. inline SDP_ORIGIN &
  169. SDP::GetOrigin(
  170. )
  171. {
  172. return m_Origin;
  173. }
  174. inline SDP_REQD_BSTRING_LINE &
  175. SDP::GetSessionName(
  176. )
  177. {
  178. return m_SessionName;
  179. }
  180. inline SDP_REQD_BSTRING_LINE &
  181. SDP::GetSessionTitle(
  182. )
  183. {
  184. return m_SessionTitle;
  185. }
  186. inline SDP_CHAR_STRING_LINE &
  187. SDP::GetUri(
  188. )
  189. {
  190. return m_Uri;
  191. }
  192. inline SDP_EMAIL_LIST &
  193. SDP::GetEmailList(
  194. )
  195. {
  196. return m_EmailList;
  197. }
  198. inline SDP_PHONE_LIST &
  199. SDP::GetPhoneList(
  200. )
  201. {
  202. return m_PhoneList;
  203. }
  204. inline SDP_CONNECTION &
  205. SDP::GetConnection(
  206. )
  207. {
  208. return m_Connection;
  209. }
  210. inline SDP_BANDWIDTH &
  211. SDP::GetBandwidth(
  212. )
  213. {
  214. return m_Bandwidth;
  215. }
  216. inline void
  217. SDP::ClearDestroyTimeListFlag(
  218. )
  219. {
  220. m_DestroyTimeList = FALSE;
  221. }
  222. inline SDP_TIME_LIST &
  223. SDP::GetTimeList(
  224. )
  225. {
  226. ASSERT(NULL != m_TimeList);
  227. return *m_TimeList;
  228. }
  229. inline SDP_ENCRYPTION_KEY &
  230. SDP::GetEncryptionKey(
  231. )
  232. {
  233. return m_EncryptionKey;
  234. }
  235. inline SDP_ATTRIBUTE_LIST &
  236. SDP::GetAttributeList(
  237. )
  238. {
  239. return m_AttributeList;
  240. }
  241. inline void
  242. SDP::ClearDestroyMediaListFlag(
  243. )
  244. {
  245. m_DestroyMediaList = FALSE;
  246. }
  247. inline SDP_MEDIA_LIST &
  248. SDP::GetMediaList(
  249. )
  250. {
  251. ASSERT(NULL != m_MediaList);
  252. return *m_MediaList;
  253. }
  254. #endif // __SDP__