1 /*
2 * Copyright (c) 2017-2020, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     media_libva_caps_cp_interface.h
24 //! \brief    This file defines the C++ class/interface for encryption related capbilities.
25 //!
26 
27 #ifndef __MEDIA_LIBVA_CAPS_CP_INTERFACE_H__
28 #define __MEDIA_LIBVA_CAPS_CP_INTERFACE_H__
29 
30 #include "media_libva.h"
31 #include "media_libva_caps.h"
32 
33 class MediaLibvaCapsCpInterface
34 {
35 public:
36     MediaLibvaCapsCpInterface(DDI_MEDIA_CONTEXT *mediaCtx, MediaLibvaCaps *mediaCaps);
~MediaLibvaCapsCpInterface()37     virtual ~MediaLibvaCapsCpInterface() {}
38 
39     virtual bool IsDecEncryptionSupported(DDI_MEDIA_CONTEXT *mediaCtx);
40     virtual int32_t GetEncryptionTypes(
41         VAProfile profile,
42         uint32_t *encrytionType,
43         uint32_t arraySize);
44 
45     virtual VAStatus LoadCpProfileEntrypoints();
46 
47     virtual bool IsCpConfigId(VAConfigID configId);
48 
49     virtual VAStatus CreateCpConfig(
50         int32_t profileTableIdx,
51         VAEntrypoint entrypoint,
52         VAConfigAttrib *attribList,
53         int32_t numAttribs,
54         VAConfigID *configId);
55 
56 protected:
57     DDI_MEDIA_CONTEXT *m_mediaCtx; //!< Pointer to media context
58     MediaLibvaCaps *m_mediaCaps;
59 
60     MediaLibvaCaps::ProfileEntrypoint* GetProfileEntrypoint(int32_t profileTableIdx);
61 
62     uint16_t GetProfileEntryCount();
63 
64     VAStatus GetProfileEntrypointFromConfigId(VAConfigID configId,
65             VAProfile *profile,
66             VAEntrypoint *entrypoint,
67             int32_t *profileTableIdx);
68 
69     VAStatus AddProfileEntry(
70         VAProfile profile,
71         VAEntrypoint entrypoint,
72         AttribMap *attributeList,
73         int32_t configIdxStart,
74         int32_t configNum);
75 
76     MEDIA_CLASS_DEFINE_END(MediaLibvaCapsCpInterface)
77 };
78 
79 //!
80 //! \brief    Create MediaLibvaCapsCpInterface Object
81 //!           Must use Delete_MediaLibvaCapsCpInterface to delete created Object to avoid ULT Memory Leak errors
82 //!
83 //! \return   Return CP Wrapper Object
84 //!
85 MediaLibvaCapsCpInterface* Create_MediaLibvaCapsCpInterface(DDI_MEDIA_CONTEXT *mediaCtx, MediaLibvaCaps *mediaCaps);
86 
87 //!
88 //! \brief    Delete the MediaLibvaCapsCpInterface Object
89 //!
90 //! \param    [in] pMediaLibvaCapsCpInterface
91 //!           MediaLibvaCapsCpInterface
92 //!
93 void Delete_MediaLibvaCapsCpInterface(MediaLibvaCapsCpInterface* pMediaLibvaCapsCpInterface);
94 #endif
95