Xiaohan Wang | 379a180 | 2017-01-13 13:14:10 -0800 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CDM_CONTENT_DECRYPTION_MODULE_EXT_H_ |
| 6 | #define CDM_CONTENT_DECRYPTION_MODULE_EXT_H_ |
| 7 | |
| 8 | #if defined(WIN32) |
| 9 | #include <windows.h> |
| 10 | #endif |
| 11 | |
| 12 | #include "content_decryption_module_export.h" |
| 13 | |
| 14 | #if defined(_MSC_VER) |
| 15 | typedef unsigned int uint32_t; |
| 16 | #else |
| 17 | #include <stdint.h> |
| 18 | #endif |
| 19 | |
| 20 | namespace cdm { |
| 21 | |
| 22 | #if defined(WIN32) |
| 23 | typedef wchar_t FilePathCharType; |
| 24 | typedef HANDLE PlatformFile; |
| 25 | const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE; |
| 26 | #elif defined(OS_POSIX) |
| 27 | typedef char FilePathCharType; |
| 28 | typedef int PlatformFile; |
| 29 | const PlatformFile kInvalidPlatformFile = -1; |
| 30 | #else // !defined(WIN32) && !defined(OS_POSIX) |
| 31 | #error Unsupported platform. |
| 32 | #endif // defined(WIN32) |
| 33 | |
| 34 | struct HostFile { |
| 35 | HostFile(const FilePathCharType* file_path, |
| 36 | PlatformFile file, |
| 37 | PlatformFile sig_file) |
| 38 | : file_path(file_path), file(file), sig_file(sig_file) {} |
| 39 | |
| 40 | // File that is part of the host of the CDM. |
| 41 | const FilePathCharType* file_path = nullptr; |
| 42 | PlatformFile file = kInvalidPlatformFile; |
| 43 | |
| 44 | // Signature file for |file|. |
| 45 | PlatformFile sig_file = kInvalidPlatformFile; |
| 46 | }; |
| 47 | |
| 48 | } // namespace cdm |
| 49 | |
| 50 | extern "C" { |
| 51 | |
Xiaohan Wang | f45b8d9 | 2017-01-19 11:50:46 -0800 | [diff] [blame^] | 52 | // Functions in this file are dynamically retrieved by their versioned function |
| 53 | // names. Increment the version number for any backward incompatible API |
| 54 | // changes. |
| 55 | |
| 56 | // Verifies CDM host. All files in |host_files| are opened in read-only mode. |
| 57 | // |
| 58 | // Returns false and closes all files if there is an immediate failure. |
| 59 | // Otherwise returns true as soon as possible and processes the files |
Xiaohan Wang | 379a180 | 2017-01-13 13:14:10 -0800 | [diff] [blame] | 60 | // asynchronously. All files MUST be closed by the CDM after this one-time |
| 61 | // processing is finished. |
Xiaohan Wang | f45b8d9 | 2017-01-19 11:50:46 -0800 | [diff] [blame^] | 62 | CDM_API bool VerifyHost_0(const cdm::HostFile* host_files, uint32_t num_files); |
Xiaohan Wang | 379a180 | 2017-01-13 13:14:10 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | #endif // CDM_CONTENT_DECRYPTION_MODULE_EXT_H_ |