From b28d332db87f262560fa1519ed3a6d36ee339a83 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Mon, 29 Jul 2024 07:29:52 -0400 Subject: [PATCH] Avoid warnings --- interfaces/CMakeLists.txt | 1 + interfaces/DRMHelper.h | 144 +++++++++++++++++++++++++++++++ interfaces/IDRM.h | 147 +++++--------------------------- jsonrpc/PersistentStore.json | 20 +++-- qa_interfaces/ITestAutomation.h | 2 +- 5 files changed, 179 insertions(+), 135 deletions(-) create mode 100644 interfaces/DRMHelper.h diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt index 564e1887..82b2dd16 100644 --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -40,6 +40,7 @@ file(GLOB INTERFACES_HEADERS ${INTERFACES_PATTERNS}) ProxyStubGenerator(INPUT "${INTERFACES_HEADERS}" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH}) file(GLOB JSON_HEADERS json/*.h) +list(APPEND INTERFACES_HEADERS DRMHelper.h) list(APPEND INTERFACES_HEADERS Portability.h) list(APPEND INTERFACES_HEADERS Module.h) diff --git a/interfaces/DRMHelper.h b/interfaces/DRMHelper.h new file mode 100644 index 00000000..f418474e --- /dev/null +++ b/interfaces/DRMHelper.h @@ -0,0 +1,144 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2021 Metrological + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Metrological has done changes to the original interface definition + * from Fraunhofer FOKUS + */ +/* + * Copyright 2014 Fraunhofer FOKUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +class BufferReader { +private: + BufferReader() = delete; + BufferReader(const BufferReader&) = delete; + BufferReader& operator=(const BufferReader&) = delete; + + // Internal implementation of multi-byte reads + template + bool Read(T* v) + { + if ((v != nullptr) && (HasBytes(sizeof(T)) == true)) { + T tmp = 0; + for (size_t i = 0; i < sizeof(T); i++) { + tmp <<= 8; + tmp += buf_[pos_++]; + } + *v = tmp; + return true; + } + return false; + } + +public: + inline BufferReader(const uint8_t* buf, size_t size) + : buf_(buf) + , size_(buf != NULL ? size : 0) + , pos_(0) + { + } + inline ~BufferReader() = default; + +public: + inline bool HasBytes(size_t count) const { return pos_ + count <= size_; } + inline bool IsEOF() const { return pos_ >= size_; } + inline const uint8_t* data() const { return buf_; } + inline size_t size() const { return size_; } + inline size_t pos() const { return pos_; } + + // Read a value from the stream, performing endian correction, + // and advance the stream pointer. + inline bool Read1(uint8_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read2(uint16_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read2s(int16_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read4(uint32_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read4s(int32_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read8(uint64_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + inline bool Read8s(int64_t* v) WARNING_RESULT_NOT_USED { return Read(v); } + + inline bool ReadString(std::string* str, size_t count) WARNING_RESULT_NOT_USED + { + if ((str != nullptr) && (HasBytes(count) == true)) { + str->assign(buf_ + pos_, buf_ + pos_ + count); + pos_ += count; + return true; + } + return false; + } + inline bool ReadVec(std::vector* vec, size_t count) WARNING_RESULT_NOT_USED + { + if ((vec != nullptr) && (HasBytes(count) == true)) { + vec->clear(); + vec->insert(vec->end(), buf_ + pos_, buf_ + pos_ + count); + pos_ += count; + return true; + } + return false; + } + + // These variants read a 4-byte integer of the corresponding signedness and + // store it in the 8-byte return type. + inline bool Read4Into8(uint64_t* v) WARNING_RESULT_NOT_USED + { + uint32_t tmp; + if ((v != nullptr) && (Read4(&tmp) == true)) { + *v = tmp; + return true; + } + return false; + } + inline bool Read4sInto8s(int64_t* v) WARNING_RESULT_NOT_USED + { + int32_t tmp; + if ((v != nullptr) && (Read4s(&tmp) == true)) { + *v = tmp; + return true; + } + return false; + } + + // Advance the stream by this many bytes. + inline bool SkipBytes(size_t bytes) WARNING_RESULT_NOT_USED + { + if (HasBytes(bytes) == true) { + pos_ += bytes; + return true; + } + return false; + } + +private: + const uint8_t* buf_; + size_t size_; + size_t pos_; +}; diff --git a/interfaces/IDRM.h b/interfaces/IDRM.h index c17b0ddb..c08644ea 100644 --- a/interfaces/IDRM.h +++ b/interfaces/IDRM.h @@ -38,7 +38,7 @@ #pragma once -// @stubgen:skip +// @stubgen:omit // For the support of portable data types such as uint8_t. #include @@ -48,111 +48,7 @@ #include #include - -class BufferReader { -private: - BufferReader() = delete; - BufferReader(const BufferReader&) = delete; - BufferReader& operator=(const BufferReader&) = delete; - - // Internal implementation of multi-byte reads - template - bool Read(T* v) - { - if ((v != nullptr) && (HasBytes(sizeof(T)) == true)) { - T tmp = 0; - for (size_t i = 0; i < sizeof(T); i++) { - tmp <<= 8; - tmp += buf_[pos_++]; - } - *v = tmp; - return true; - } - return false; - } - -public: - inline BufferReader(const uint8_t* buf, size_t size) - : buf_(buf) - , size_(buf != NULL ? size : 0) - , pos_(0) - { - } - inline ~BufferReader() = default; - -public: - inline bool HasBytes(size_t count) const { return pos_ + count <= size_; } - inline bool IsEOF() const { return pos_ >= size_; } - inline const uint8_t* data() const { return buf_; } - inline size_t size() const { return size_; } - inline size_t pos() const { return pos_; } - - // Read a value from the stream, performing endian correction, - // and advance the stream pointer. - inline bool Read1(uint8_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read2(uint16_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read2s(int16_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read4(uint32_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read4s(int32_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read8(uint64_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - inline bool Read8s(int64_t* v) WARNING_RESULT_NOT_USED { return Read(v); } - - inline bool ReadString(std::string* str, size_t count) WARNING_RESULT_NOT_USED - { - if ((str != nullptr) && (HasBytes(count) == true)) { - str->assign(buf_ + pos_, buf_ + pos_ + count); - pos_ += count; - return true; - } - return false; - } - inline bool ReadVec(std::vector* vec, size_t count) WARNING_RESULT_NOT_USED - { - if ((vec != nullptr) && (HasBytes(count) == true)) { - vec->clear(); - vec->insert(vec->end(), buf_ + pos_, buf_ + pos_ + count); - pos_ += count; - return true; - } - return false; - } - - // These variants read a 4-byte integer of the corresponding signedness and - // store it in the 8-byte return type. - inline bool Read4Into8(uint64_t* v) WARNING_RESULT_NOT_USED - { - uint32_t tmp; - if ((v != nullptr) && (Read4(&tmp) == true)) { - *v = tmp; - return true; - } - return false; - } - inline bool Read4sInto8s(int64_t* v) WARNING_RESULT_NOT_USED - { - int32_t tmp; - if ((v != nullptr) && (Read4s(&tmp) == true)) { - *v = tmp; - return true; - } - return false; - } - - // Advance the stream by this many bytes. - inline bool SkipBytes(size_t bytes) WARNING_RESULT_NOT_USED - { - if (HasBytes(bytes) == true) { - pos_ += bytes; - return true; - } - return false; - } - -private: - const uint8_t* buf_; - size_t size_; - size_t pos_; -}; +#include namespace Thunder { @@ -189,7 +85,7 @@ namespace CDMi { #define MEDIA_KEY_STATUS_KEY_STATUS_PENDING 5 #define MEDIA_KEY_STATUS_KEY_STATUS_MAX KEY_STATUS_PENDING -typedef enum { +enum CDMi_RESULT { CDMi_SUCCESS = 0, CDMi_S_FALSE = 1, CDMi_MORE_DATA_AVAILABLE = 2, @@ -207,57 +103,56 @@ typedef enum { CDMi_SERVER_INVALID_MESSAGE = 0x8004C601, CDMi_SERVER_SERVICE_SPECIFIC = 0x8004C604, CDMi_BUSY_CANNOT_INITIALIZE = 0x8004DD00, -} CDMi_RESULT; +}; -typedef enum { +enum LicenseType { Temporary, PersistentUsageRecord, PersistentLicense -} LicenseType; +}; -typedef enum { +enum LicenseTypeExt { Invalid = 0, LimitedDuration, Standard -} LicenseTypeExt; +}; -typedef enum { +enum SessionStateExt { LicenseAcquisitionState = 0, InactiveDecryptionState, ActiveDecryptionState, InvalidState -} SessionStateExt; +}; -typedef enum -{ +enum MediaType { Unknown = 0, Video, Audio, Data -} MediaType; +}; // ISO/IEC 23001-7 defines two Common Encryption Schemes with Full Sample and Subsample modes -typedef enum : uint8_t { +enum EncryptionScheme : uint8_t { Clear = 0, AesCtr_Cenc, // AES-CTR mode and Sub-Sample encryption AesCbc_Cbc1, // AES-CBC mode and Sub-Sample encryption AesCtr_Cens, // AES-CTR mode and Sub-Sample + patterned encryption AesCbc_Cbcs // AES-CBC mode and Sub-Sample + patterned encryption + Constant IV -} EncryptionScheme; +}; // CBCS & CENC3.0 pattern is a number of encrypted blocks followed a number of clear // blocks after which the pattern repeats. -typedef struct { +struct EncryptionPattern { uint32_t clear_blocks; uint32_t encrypted_blocks; -} EncryptionPattern; +}; -typedef struct { +struct SubSampleInfo { uint16_t clear_bytes; uint32_t encrypted_bytes; -} SubSampleInfo; +}; -typedef struct { +struct SampleInfo { EncryptionScheme scheme; // Encryption scheme used in this sample EncryptionPattern pattern; // Encryption Pattern used in this sample uint8_t* iv; // Initialization vector(IV) to decrypt this sample @@ -266,7 +161,7 @@ typedef struct { uint8_t keyIdLength; // Length of KeyId uint8_t subSampleCount; // Number or Sub-Samples in this sample SubSampleInfo* subSample; // SubSample mapping - Repeating pair of Clear bytes and Encrypted Bytes representing each subsample. -} SampleInfo; +}; // IStreamProperties to provide information about the current stream class IStreamProperties { @@ -513,6 +408,7 @@ struct IMediaSessionMetrics { virtual CDMi_RESULT Metrics (uint32_t& bufferLength, uint8_t buffer[]) const = 0; }; +// @stop struct ISystemFactory { virtual ~ISystemFactory() = default; virtual IMediaKeys* Instance() = 0; @@ -654,6 +550,7 @@ class SystemFactoryType : public ISystemFactory { const std::vector _mimes; IMPLEMENTATION _instance; }; +// @stop } // namespace CDMi diff --git a/jsonrpc/PersistentStore.json b/jsonrpc/PersistentStore.json index 0eab3418..7b71a4ee 100644 --- a/jsonrpc/PersistentStore.json +++ b/jsonrpc/PersistentStore.json @@ -2,31 +2,33 @@ "$schema": "interface.schema.json", "jsonrpc": "2.0", "info": { + "version": "1.0.0", "title": "PertsistentStore API", "class": "PersistentStore", - "description": "Persistent Store JSON-RPC interface" + "description": "Persistent Store JSON-RPC interface", + "legacy": true }, "common": { "$ref": "common.json" }, "definitions": { "namespace": { - "summary": "Namespace", + "description": "Namespace", "type": "string", "example": "ns1" }, "key": { - "summary": "Key", + "description": "Key", "type": "string", "example": "key1" }, "value": { - "summary": "Value", + "description": "Value", "type": "string", "example": "value1" }, "scope": { - "summary": "Scope", + "description": "Scope", "type": "string", "enum": [ "device", @@ -36,17 +38,17 @@ "example": "device" }, "size": { - "summary": "Size in bytes", + "description": "Size in bytes", "type": "number", "example": 100 }, "ttl": { - "summary": "Time in seconds", + "description": "Time in seconds", "type": "number", "example": 100 }, "success": { - "summary": "Legacy parameter (always true)", + "description": "Legacy parameter (always true)", "type": "boolean", "default": true, "example": true @@ -477,4 +479,4 @@ } } } -} \ No newline at end of file +} diff --git a/qa_interfaces/ITestAutomation.h b/qa_interfaces/ITestAutomation.h index 7c47dd1d..08ef7083 100644 --- a/qa_interfaces/ITestAutomation.h +++ b/qa_interfaces/ITestAutomation.h @@ -24,7 +24,7 @@ namespace Thunder { namespace QualityAssurance { - // @json + // @json 1.0.0 struct EXTERNAL IMemory : virtual public Core::IUnknown { // Ask Pierre if using namespace+interface as ID! Is there a coding guide line enum { ID = ID_TESTAUTOMATIONMEMORY };