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.

188 lines
3.8 KiB

  1. /**************************************************************************
  2. AVStream Simulated Hardware Sample
  3. Copyright (c) 2001, Microsoft Corporation.
  4. File:
  5. TStream.h
  6. Abstract:
  7. History:
  8. created 8/1/2001
  9. **************************************************************************/
  10. /**************************************************************************
  11. Constants
  12. **************************************************************************/
  13. /*************************************************
  14. CTsSynthesizer
  15. This class synthesizes a transport stream for output from the
  16. capture filter.
  17. *************************************************/
  18. class CTsSynthesizer {
  19. protected:
  20. //
  21. // The packet size of the transport stream
  22. //
  23. ULONG m_PacketSize;
  24. //
  25. // The number of packets in a capture buffer
  26. //
  27. ULONG m_PacketsPerBuffer;
  28. //
  29. // The size of the actual data in the capture buffer
  30. //
  31. ULONG m_SampleSize;
  32. //
  33. // The synthesis buffer. All transport stream samples are created in this
  34. // buffer. This must be set with SetBuffer() before any sample creation
  35. // routines are called.
  36. //
  37. PUCHAR m_SynthesisBuffer;
  38. //
  39. // The default cursor. This is a pointer into the synthesis buffer where
  40. // the next transport stream byte will be placed.
  41. //
  42. PUCHAR m_Cursor;
  43. public:
  44. //
  45. // SetSampleSize():
  46. //
  47. // Set the size of the synthesis buffer.
  48. //
  49. void
  50. SetSampleSize (
  51. ULONG PacketSize,
  52. ULONG PacketsPerBuffer
  53. )
  54. {
  55. m_PacketSize = PacketSize;
  56. m_PacketsPerBuffer = PacketsPerBuffer;
  57. m_SampleSize = PacketSize * PacketsPerBuffer;
  58. }
  59. //
  60. // SetBuffer():
  61. //
  62. // Set the buffer the synthesizer generates images to.
  63. //
  64. void
  65. SetBuffer (
  66. PUCHAR SynthesisBuffer
  67. )
  68. {
  69. m_SynthesisBuffer = SynthesisBuffer;
  70. }
  71. //
  72. // GetTsLocation():
  73. //
  74. // Set the cursor to point at the given packet index.
  75. //
  76. virtual PUCHAR
  77. GetTsLocation (
  78. ULONG PacketIndex
  79. )
  80. {
  81. if ( m_SynthesisBuffer
  82. && m_PacketSize
  83. && (PacketIndex < m_PacketsPerBuffer)
  84. )
  85. {
  86. m_Cursor = m_SynthesisBuffer + (PacketIndex * m_PacketSize);
  87. }
  88. else
  89. {
  90. m_Cursor = NULL;
  91. }
  92. return m_Cursor;
  93. }
  94. //
  95. // PutPacket():
  96. //
  97. // Place a transport stream packet at the default cursor location.
  98. // The cursor location must be set via GetTsLocation(PacketIndex).
  99. //
  100. virtual void
  101. PutPacket (
  102. PUCHAR TsPacket
  103. )
  104. {
  105. //
  106. // Copy the transport packet to the synthesis buffer.
  107. //
  108. RtlCopyMemory (
  109. m_Cursor,
  110. TsPacket,
  111. m_PacketSize
  112. );
  113. m_Cursor += m_PacketSize;
  114. }
  115. //
  116. // SynthesizeTS():
  117. //
  118. // Synthesize the next transport stream buffer to be captured.
  119. //
  120. virtual void
  121. SynthesizeTS (
  122. );
  123. //
  124. // DEFAULT CONSTRUCTOR
  125. //
  126. CTsSynthesizer (
  127. ) :
  128. m_PacketSize (0),
  129. m_PacketsPerBuffer (0),
  130. m_SynthesisBuffer (NULL)
  131. {
  132. }
  133. //
  134. // CONSTRUCTOR:
  135. //
  136. CTsSynthesizer (
  137. ULONG PacketSize,
  138. ULONG PacketsPerBuffer
  139. ) :
  140. m_PacketSize (PacketSize),
  141. m_PacketsPerBuffer (PacketsPerBuffer),
  142. m_SynthesisBuffer (NULL)
  143. {
  144. }
  145. //
  146. // DESTRUCTOR:
  147. //
  148. virtual
  149. ~CTsSynthesizer (
  150. )
  151. {
  152. }
  153. };