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.

99 lines
3.7 KiB

  1. #ifndef StreamMgr_h
  2. #define StreamMgr_h
  3. // Handles DRM streams. Each protected audio stream has a streamId generated
  4. // by this class. Each stream has rights information provided by DRM. This
  5. // class is responsible for mapping DRM rights to kernel rights, streamId
  6. // lifetime managment and construction of composite streamIds required by
  7. // mixers.
  8. // Composite streams start 0x80000000. Primary streams start at 0x0. Simple
  9. // streams can be tagged with the handle held by the process that created them.
  10. // bug todo - primary and composite should be maps, not lists (probably)
  11. #define INVALID_POS 0xffffffff
  12. class StreamMgr{
  13. public:
  14. StreamMgr();
  15. ~StreamMgr();
  16. // these are called by DRM when streams are explicitly created and destroyed
  17. DRM_STATUS createStream(HANDLE Handle, DWORD* StreamId, const DRMRIGHTS* RightsStruct, IN STREAMKEY* Key);
  18. DRM_STATUS destroyStream(DWORD StreamId);
  19. // this is called when the KRM-handle is closed (by whatever means)
  20. DRM_STATUS destroyAllStreamsByHandle(HANDLE Handle);
  21. // This is called by the KS2 graph when a mixer is encountered
  22. DRM_STATUS createCompositeStream(OUT DWORD* StreamId, IN DWORD* StreamInArray, DWORD NumStreams);
  23. DRM_STATUS destroyCompositeStream(IN DWORD CompositeStreamId);
  24. // get a key for a primary stream
  25. DRM_STATUS getKey(IN DWORD StreamId, OUT STREAMKEY*& Key);
  26. // query rights for primary or composite streams
  27. DRM_STATUS getRights(DWORD StreamId,DRMRIGHTS* Rights);
  28. // notify of new proving function associated with a stream.
  29. DRM_STATUS addProvingFunction(DWORD StreamId,PVOID Func);
  30. // initiate driver graph walk
  31. DRM_STATUS walkDrivers(DWORD StreamId, PVOID* ProveFuncList, DWORD& NumDrivers, DWORD MaxDrivers);
  32. // allow drmk filter to inform StreamMgr of output pin (several forms)
  33. DRM_STATUS setRecipient(IN DWORD StreamId, IN PFILE_OBJECT OutPinFileObject, IN PDEVICE_OBJECT OutPinDeviceObject);
  34. DRM_STATUS setRecipient(IN DWORD StreamId, IN IUnknown* OutPin);
  35. DRM_STATUS clearRecipient(IN DWORD StreamId);
  36. // authentication errors can be 'logged to a stream'
  37. void logErrorToStream(IN DWORD StreamId, DWORD ErrorCode);
  38. // Query error-status of (primary) streams
  39. DRM_STATUS getStreamErrorCode(IN DWORD StreamId, OUT DWORD& ErrorCode);
  40. DRM_STATUS clearStreamError(IN DWORD StreamId);
  41. // fatal errors (e.g. memory starvation) should switch off all stream.
  42. void setFatalError(DWORD ErrorCode);
  43. NTSTATUS getFatalError();
  44. KCritMgr& getCritMgr(){return critMgr;};
  45. protected:
  46. enum OutPinType{IsUndefined, IsInterface, IsHandle};
  47. // Describes a primary stream
  48. struct StreamInfo{
  49. DWORD StreamId;
  50. HANDLE Handle;
  51. STREAMKEY Key;
  52. DRMRIGHTS Rights;
  53. KList<PVOID> proveFuncs;
  54. BOOL newProveFuncs;
  55. OutPinType OutType;
  56. PFILE_OBJECT OutPinFileObject;
  57. PDEVICE_OBJECT OutPinDeviceObject;
  58. PUNKNOWN OutInt;
  59. BYTE* drmFormat;
  60. bool streamWalked;
  61. DRM_STATUS streamStatus;
  62. };
  63. // describes a composite stream
  64. struct CompositeStreamInfo{
  65. DWORD StreamId;
  66. KList<DWORD> parents;
  67. };
  68. //-----------
  69. bool addStream(StreamInfo& NewInfo);
  70. POS getStreamPos(DWORD StreamId);
  71. void deleteStreamAt(bool primary,POS pos);
  72. bool isPrimaryStream(DWORD StreamId);
  73. StreamInfo* getPrimaryStream(DWORD StreamId);
  74. CompositeStreamInfo* getCompositeStream(DWORD StreamId);
  75. DRM_STATUS getRightsWorker(DWORD StreamId, DRMRIGHTS* Rights);
  76. void logErrorToStreamWorker(IN DWORD StreamId, DWORD ErrorCode);
  77. //-----------
  78. DWORD nextStreamId;
  79. DWORD nextCompositeId;
  80. KList<StreamInfo*> primary;
  81. KList<CompositeStreamInfo*> composite;
  82. KCritMgr critMgr;
  83. volatile NTSTATUS criticalErrorCode;
  84. };
  85. extern StreamMgr* TheStreamMgr;
  86. #endif