1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Kernel Streaming
4  * FILE:            drivers/wdm/audio/backpln/portcls/drm_port.cpp
5  * PURPOSE:         portcls drm port object
6  * PROGRAMMER:      Johannes Anderwald
7  */
8 
9 #include "private.hpp"
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 class CDrmPort2 : public CUnknownImpl<IDrmPort2>
15 {
16 public:
17     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
18 
19     IMP_IDrmPort2;
20     CDrmPort2(IUnknown *OuterUnknown){}
21     virtual ~CDrmPort2(){}
22 };
23 
24 NTSTATUS
25 NTAPI
26 CDrmPort2::QueryInterface(
27     IN  REFIID refiid,
28     OUT PVOID* Output)
29 {
30     UNICODE_STRING GuidString;
31 
32     if (IsEqualGUIDAligned(refiid, IID_IDrmPort) ||
33         IsEqualGUIDAligned(refiid, IID_IDrmPort2) ||
34         IsEqualGUIDAligned(refiid, IID_IUnknown))
35     {
36         *Output = PVOID(PUNKNOWN(this));
37         PUNKNOWN(*Output)->AddRef();
38         return STATUS_SUCCESS;
39     }
40 
41     if (RtlStringFromGUID(refiid, &GuidString) == STATUS_SUCCESS)
42     {
43         DPRINT("IDrmPort2_QueryInterface no interface!!! iface %S\n", GuidString.Buffer);
44         RtlFreeUnicodeString(&GuidString);
45     }
46     return STATUS_UNSUCCESSFUL;
47 }
48 
49 NTSTATUS
50 NTAPI
51 CDrmPort2::CreateContentMixed(
52     IN  PULONG paContentId,
53     IN  ULONG cContentId,
54     OUT PULONG pMixedContentId)
55 {
56     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
57     return DrmCreateContentMixed(paContentId, cContentId, pMixedContentId);
58 }
59 
60 NTSTATUS
61 NTAPI
62 CDrmPort2::DestroyContent(
63     IN ULONG ContentId)
64 {
65     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
66     return DrmDestroyContent(ContentId);
67 }
68 
69 NTSTATUS
70 NTAPI
71 CDrmPort2::ForwardContentToFileObject(
72     IN ULONG ContentId,
73     IN PFILE_OBJECT FileObject)
74 {
75     return DrmForwardContentToFileObject(ContentId, FileObject);
76 }
77 
78 NTSTATUS
79 NTAPI
80 CDrmPort2::ForwardContentToInterface(
81     IN ULONG ContentId,
82     IN PUNKNOWN pUnknown,
83     IN ULONG NumMethods)
84 {
85     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
86     return DrmForwardContentToInterface(ContentId, pUnknown, NumMethods);
87 }
88 
89 NTSTATUS
90 NTAPI
91 CDrmPort2::GetContentRights(
92     IN ULONG ContentId,
93     OUT PDRMRIGHTS  DrmRights)
94 {
95     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
96     return DrmGetContentRights(ContentId, DrmRights);
97 }
98 
99 NTSTATUS
100 NTAPI
101 CDrmPort2::AddContentHandlers(
102     IN ULONG ContentId,
103     IN PVOID * paHandlers,
104     IN ULONG NumHandlers)
105 {
106     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
107     return DrmAddContentHandlers(ContentId, paHandlers, NumHandlers);
108 }
109 
110 NTSTATUS
111 NTAPI
112 CDrmPort2::ForwardContentToDeviceObject(
113     IN ULONG ContentId,
114     IN PVOID Reserved,
115     IN PCDRMFORWARD DrmForward)
116 {
117     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
118     return DrmForwardContentToDeviceObject(ContentId, Reserved, DrmForward);
119 }
120 
121 NTSTATUS
122 NewIDrmPort(
123     OUT PDRMPORT2 *OutPort)
124 {
125     CDrmPort2 * This = new(NonPagedPool, TAG_PORTCLASS)CDrmPort2(NULL);
126     if (!This)
127         return STATUS_INSUFFICIENT_RESOURCES;
128 
129     This->AddRef();
130 
131     *OutPort = (PDRMPORT2)This;
132     return STATUS_SUCCESS;
133 }
134