Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: content_decryption_module.h

Issue 1956123002: Fix visibility for CDM API types and functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/cdm.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CDM_CONTENT_DECRYPTION_MODULE_H_ 5 #ifndef CDM_CONTENT_DECRYPTION_MODULE_H_
6 #define CDM_CONTENT_DECRYPTION_MODULE_H_ 6 #define CDM_CONTENT_DECRYPTION_MODULE_H_
7 7
8 #if defined(_MSC_VER) 8 #if defined(_MSC_VER)
9 typedef unsigned char uint8_t; 9 typedef unsigned char uint8_t;
10 typedef unsigned int uint32_t; 10 typedef unsigned int uint32_t;
11 typedef int int32_t; 11 typedef int int32_t;
12 typedef __int64 int64_t; 12 typedef __int64 int64_t;
13 #else 13 #else
14 #include <stdint.h> 14 #include <stdint.h>
15 #endif 15 #endif
16 16
17 // Define CDM_EXPORT so that functionality implemented by the CDM module 17 // Define CDM_API so that functionality implemented by the CDM module
18 // can be exported to consumers. 18 // can be exported to consumers.
pcc1 2016/05/09 23:01:15 You might want to explicitly state that this is ex
krasin 2016/05/10 01:09:20 Done.
19 #if defined(WIN32) 19 #if defined(WIN32)
20 20
21 #if defined(CDM_IMPLEMENTATION) 21 #if defined(CDM_IMPLEMENTATION)
22 #define CDM_EXPORT __declspec(dllexport) 22 #define CDM_API __declspec(dllexport)
23 #else 23 #else
24 #define CDM_EXPORT __declspec(dllimport) 24 #define CDM_API __declspec(dllimport)
25 #endif // defined(CDM_IMPLEMENTATION) 25 #endif // defined(CDM_IMPLEMENTATION)
26 26
27 #else // defined(WIN32) 27 #else // defined(WIN32)
28 28 #define CDM_API __attribute__((visibility("default")))
29 #if defined(CDM_IMPLEMENTATION)
30 #define CDM_EXPORT __attribute__((visibility("default")))
31 #else
32 #define CDM_EXPORT
33 #endif
34
35 #endif // defined(WIN32) 29 #endif // defined(WIN32)
36 30
37 // The version number must be rolled when the exported functions are updated! 31 // The version number must be rolled when the exported functions are updated!
38 // If the CDM and the adapter use different versions of these functions, the 32 // If the CDM and the adapter use different versions of these functions, the
39 // adapter will fail to load or crash! 33 // adapter will fail to load or crash!
40 #define CDM_MODULE_VERSION 4 34 #define CDM_MODULE_VERSION 4
41 35
42 // Build the versioned entrypoint name. 36 // Build the versioned entrypoint name.
43 // The extra macros are necessary to expand version to an actual value. 37 // The extra macros are necessary to expand version to an actual value.
44 #define INITIALIZE_CDM_MODULE \ 38 #define INITIALIZE_CDM_MODULE \
45 BUILD_ENTRYPOINT(InitializeCdmModule, CDM_MODULE_VERSION) 39 BUILD_ENTRYPOINT(InitializeCdmModule, CDM_MODULE_VERSION)
46 #define BUILD_ENTRYPOINT(name, version) \ 40 #define BUILD_ENTRYPOINT(name, version) \
47 BUILD_ENTRYPOINT_NO_EXPANSION(name, version) 41 BUILD_ENTRYPOINT_NO_EXPANSION(name, version)
48 #define BUILD_ENTRYPOINT_NO_EXPANSION(name, version) name##_##version 42 #define BUILD_ENTRYPOINT_NO_EXPANSION(name, version) name##_##version
49 43
50 extern "C" { 44 extern "C" {
51 CDM_EXPORT void INITIALIZE_CDM_MODULE(); 45 CDM_API void INITIALIZE_CDM_MODULE();
52 46
53 CDM_EXPORT void DeinitializeCdmModule(); 47 CDM_API void DeinitializeCdmModule();
54 48
55 // Returns a pointer to the requested CDM Host interface upon success. 49 // Returns a pointer to the requested CDM Host interface upon success.
56 // Returns NULL if the requested CDM Host interface is not supported. 50 // Returns NULL if the requested CDM Host interface is not supported.
57 // The caller should cast the returned pointer to the type matching 51 // The caller should cast the returned pointer to the type matching
58 // |host_interface_version|. 52 // |host_interface_version|.
59 typedef void* (*GetCdmHostFunc)(int host_interface_version, void* user_data); 53 typedef void* (*GetCdmHostFunc)(int host_interface_version, void* user_data);
60 54
61 // Returns a pointer to the requested CDM upon success. 55 // Returns a pointer to the requested CDM upon success.
62 // Returns NULL if an error occurs or the requested |cdm_interface_version| or 56 // Returns NULL if an error occurs or the requested |cdm_interface_version| or
63 // |key_system| is not supported or another error occurs. 57 // |key_system| is not supported or another error occurs.
64 // The caller should cast the returned pointer to the type matching 58 // The caller should cast the returned pointer to the type matching
65 // |cdm_interface_version|. 59 // |cdm_interface_version|.
66 // Caller retains ownership of arguments and must call Destroy() on the returned 60 // Caller retains ownership of arguments and must call Destroy() on the returned
67 // object. 61 // object.
68 CDM_EXPORT void* CreateCdmInstance( 62 CDM_API void* CreateCdmInstance(
69 int cdm_interface_version, 63 int cdm_interface_version,
70 const char* key_system, uint32_t key_system_size, 64 const char* key_system, uint32_t key_system_size,
71 GetCdmHostFunc get_cdm_host_func, void* user_data); 65 GetCdmHostFunc get_cdm_host_func, void* user_data);
72 66
73 CDM_EXPORT const char* GetCdmVersion(); 67 CDM_API const char* GetCdmVersion();
74 } 68 }
75 69
76 namespace cdm { 70 namespace cdm {
77 71
78 class AudioFrames; 72 class AudioFrames;
79 class DecryptedBlock; 73 class DecryptedBlock;
80 class VideoFrame; 74 class VideoFrame;
81 75
82 class Host_7; 76 class Host_7;
83 class Host_8; 77 class Host_8;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 371
378 // FileIO interface provides a way for the CDM to store data in a file in 372 // FileIO interface provides a way for the CDM to store data in a file in
379 // persistent storage. This interface aims only at providing basic read/write 373 // persistent storage. This interface aims only at providing basic read/write
380 // capabilities and should not be used as a full fledged file IO API. 374 // capabilities and should not be used as a full fledged file IO API.
381 // Each CDM and origin (e.g. HTTPS, "foo.example.com", 443) combination has 375 // Each CDM and origin (e.g. HTTPS, "foo.example.com", 443) combination has
382 // its own persistent storage. All instances of a given CDM associated with a 376 // its own persistent storage. All instances of a given CDM associated with a
383 // given origin share the same persistent storage. 377 // given origin share the same persistent storage.
384 // Note to implementors of this interface: 378 // Note to implementors of this interface:
385 // Per-origin storage and the ability for users to clear it are important. 379 // Per-origin storage and the ability for users to clear it are important.
386 // See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo. 380 // See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo.
387 class FileIO { 381 class CDM_API FileIO {
388 public: 382 public:
389 // Opens the file with |file_name| for read and write. 383 // Opens the file with |file_name| for read and write.
390 // FileIOClient::OnOpenComplete() will be called after the opening 384 // FileIOClient::OnOpenComplete() will be called after the opening
391 // operation finishes. 385 // operation finishes.
392 // - When the file is opened by a CDM instance, it will be classified as "in 386 // - When the file is opened by a CDM instance, it will be classified as "in
393 // use". In this case other CDM instances in the same domain may receive 387 // use". In this case other CDM instances in the same domain may receive
394 // kInUse status when trying to open it. 388 // kInUse status when trying to open it.
395 // - |file_name| must not contain forward slash ('/') or backslash ('\'), and 389 // - |file_name| must not contain forward slash ('/') or backslash ('\'), and
396 // must not start with an underscore ('_'). 390 // must not start with an underscore ('_').
397 virtual void Open(const char* file_name, uint32_t file_name_size) = 0; 391 virtual void Open(const char* file_name, uint32_t file_name_size) = 0;
(...skipping 19 matching lines...) Expand all
417 411
418 protected: 412 protected:
419 FileIO() {} 413 FileIO() {}
420 virtual ~FileIO() {} 414 virtual ~FileIO() {}
421 }; 415 };
422 416
423 // Responses to FileIO calls. All responses will be called asynchronously. 417 // Responses to FileIO calls. All responses will be called asynchronously.
424 // When kError is returned, the FileIO object could be in an error state. All 418 // When kError is returned, the FileIO object could be in an error state. All
425 // following calls (other than Close()) could return kError. The CDM should 419 // following calls (other than Close()) could return kError. The CDM should
426 // still call Close() to destroy the FileIO object. 420 // still call Close() to destroy the FileIO object.
427 class FileIOClient { 421 class CDM_API FileIOClient {
428 public: 422 public:
429 enum Status { 423 enum Status {
430 kSuccess = 0, 424 kSuccess = 0,
431 kInUse, 425 kInUse,
432 kError 426 kError
433 }; 427 };
434 428
435 // Response to a FileIO::Open() call with the open |status|. 429 // Response to a FileIO::Open() call with the open |status|.
436 virtual void OnOpenComplete(Status status) = 0; 430 virtual void OnOpenComplete(Status status) = 0;
437 431
(...skipping 20 matching lines...) Expand all
458 FileIOClient() {} 452 FileIOClient() {}
459 virtual ~FileIOClient() {} 453 virtual ~FileIOClient() {}
460 }; 454 };
461 455
462 // ContentDecryptionModule interface that all CDMs need to implement. 456 // ContentDecryptionModule interface that all CDMs need to implement.
463 // The interface is versioned for backward compatibility. 457 // The interface is versioned for backward compatibility.
464 // Note: ContentDecryptionModule implementations must use the allocator 458 // Note: ContentDecryptionModule implementations must use the allocator
465 // provided in CreateCdmInstance() to allocate any Buffer that needs to 459 // provided in CreateCdmInstance() to allocate any Buffer that needs to
466 // be passed back to the caller. Implementations must call Buffer::Destroy() 460 // be passed back to the caller. Implementations must call Buffer::Destroy()
467 // when a Buffer is created that will never be returned to the caller. 461 // when a Buffer is created that will never be returned to the caller.
468 class ContentDecryptionModule_7 { 462 class CDM_API ContentDecryptionModule_7 {
469 public: 463 public:
470 static const int kVersion = 7; 464 static const int kVersion = 7;
471 typedef Host_7 Host; 465 typedef Host_7 Host;
472 466
473 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(), 467 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(),
474 // UpdateSession(), CloseSession(), and RemoveSession() all accept a 468 // UpdateSession(), CloseSession(), and RemoveSession() all accept a
475 // |promise_id|, which must be passed to the completion Host method 469 // |promise_id|, which must be passed to the completion Host method
476 // (e.g. Host::OnResolveNewSessionPromise()). 470 // (e.g. Host::OnResolveNewSessionPromise()).
477 471
478 // Provides a server certificate to be used to encrypt messages to the 472 // Provides a server certificate to be used to encrypt messages to the
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 ContentDecryptionModule_7() {} 631 ContentDecryptionModule_7() {}
638 virtual ~ContentDecryptionModule_7() {} 632 virtual ~ContentDecryptionModule_7() {}
639 }; 633 };
640 634
641 // ContentDecryptionModule interface that all CDMs need to implement. 635 // ContentDecryptionModule interface that all CDMs need to implement.
642 // The interface is versioned for backward compatibility. 636 // The interface is versioned for backward compatibility.
643 // Note: ContentDecryptionModule implementations must use the allocator 637 // Note: ContentDecryptionModule implementations must use the allocator
644 // provided in CreateCdmInstance() to allocate any Buffer that needs to 638 // provided in CreateCdmInstance() to allocate any Buffer that needs to
645 // be passed back to the caller. Implementations must call Buffer::Destroy() 639 // be passed back to the caller. Implementations must call Buffer::Destroy()
646 // when a Buffer is created that will never be returned to the caller. 640 // when a Buffer is created that will never be returned to the caller.
647 class ContentDecryptionModule_8 { 641 class CDM_API ContentDecryptionModule_8 {
648 public: 642 public:
649 static const int kVersion = 8; 643 static const int kVersion = 8;
650 typedef Host_8 Host; 644 typedef Host_8 Host;
651 645
652 // Initializes the CDM instance, providing information about permitted 646 // Initializes the CDM instance, providing information about permitted
653 // functionalities. 647 // functionalities.
654 // If |allow_distinctive_identifier| is false, messages from the CDM, 648 // If |allow_distinctive_identifier| is false, messages from the CDM,
655 // such as message events, must not contain a Distinctive Identifier, 649 // such as message events, must not contain a Distinctive Identifier,
656 // even in an encrypted form. 650 // even in an encrypted form.
657 // If |allow_persistent_state| is false, the CDM must not attempt to 651 // If |allow_persistent_state| is false, the CDM must not attempt to
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 virtual void Destroy() = 0; 816 virtual void Destroy() = 0;
823 817
824 protected: 818 protected:
825 ContentDecryptionModule_8() {} 819 ContentDecryptionModule_8() {}
826 virtual ~ContentDecryptionModule_8() {} 820 virtual ~ContentDecryptionModule_8() {}
827 }; 821 };
828 822
829 typedef ContentDecryptionModule_8 ContentDecryptionModule; 823 typedef ContentDecryptionModule_8 ContentDecryptionModule;
830 824
831 // Represents a buffer created by Allocator implementations. 825 // Represents a buffer created by Allocator implementations.
832 class Buffer { 826 class CDM_API Buffer {
833 public: 827 public:
834 // Destroys the buffer in the same context as it was created. 828 // Destroys the buffer in the same context as it was created.
835 virtual void Destroy() = 0; 829 virtual void Destroy() = 0;
836 830
837 virtual uint32_t Capacity() const = 0; 831 virtual uint32_t Capacity() const = 0;
838 virtual uint8_t* Data() = 0; 832 virtual uint8_t* Data() = 0;
839 virtual void SetSize(uint32_t size) = 0; 833 virtual void SetSize(uint32_t size) = 0;
840 virtual uint32_t Size() const = 0; 834 virtual uint32_t Size() const = 0;
841 835
842 protected: 836 protected:
843 Buffer() {} 837 Buffer() {}
844 virtual ~Buffer() {} 838 virtual ~Buffer() {}
845 839
846 private: 840 private:
847 Buffer(const Buffer&); 841 Buffer(const Buffer&);
848 void operator=(const Buffer&); 842 void operator=(const Buffer&);
849 }; 843 };
850 844
851 class Host_7 { 845 class CDM_API Host_7 {
852 public: 846 public:
853 static const int kVersion = 7; 847 static const int kVersion = 7;
854 848
855 // Returns a Buffer* containing non-zero members upon success, or NULL on 849 // Returns a Buffer* containing non-zero members upon success, or NULL on
856 // failure. The caller owns the Buffer* after this call. The buffer is not 850 // failure. The caller owns the Buffer* after this call. The buffer is not
857 // guaranteed to be zero initialized. The capacity of the allocated Buffer 851 // guaranteed to be zero initialized. The capacity of the allocated Buffer
858 // is guaranteed to be not less than |capacity|. 852 // is guaranteed to be not less than |capacity|.
859 virtual Buffer* Allocate(uint32_t capacity) = 0; 853 virtual Buffer* Allocate(uint32_t capacity) = 0;
860 854
861 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| 855 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 // if a FileIO object cannot be obtained. Once a valid FileIO object is 972 // if a FileIO object cannot be obtained. Once a valid FileIO object is
979 // returned, |client| must be valid until FileIO::Close() is called. The 973 // returned, |client| must be valid until FileIO::Close() is called. The
980 // CDM can call this method multiple times to operate on different files. 974 // CDM can call this method multiple times to operate on different files.
981 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 975 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
982 976
983 protected: 977 protected:
984 Host_7() {} 978 Host_7() {}
985 virtual ~Host_7() {} 979 virtual ~Host_7() {}
986 }; 980 };
987 981
988 class Host_8 { 982 class CDM_API Host_8 {
989 public: 983 public:
990 static const int kVersion = 8; 984 static const int kVersion = 8;
991 985
992 // Returns a Buffer* containing non-zero members upon success, or NULL on 986 // Returns a Buffer* containing non-zero members upon success, or NULL on
993 // failure. The caller owns the Buffer* after this call. The buffer is not 987 // failure. The caller owns the Buffer* after this call. The buffer is not
994 // guaranteed to be zero initialized. The capacity of the allocated Buffer 988 // guaranteed to be zero initialized. The capacity of the allocated Buffer
995 // is guaranteed to be not less than |capacity|. 989 // is guaranteed to be not less than |capacity|.
996 virtual Buffer* Allocate(uint32_t capacity) = 0; 990 virtual Buffer* Allocate(uint32_t capacity) = 0;
997 991
998 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| 992 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 // returned, |client| must be valid until FileIO::Close() is called. The 1110 // returned, |client| must be valid until FileIO::Close() is called. The
1117 // CDM can call this method multiple times to operate on different files. 1111 // CDM can call this method multiple times to operate on different files.
1118 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 1112 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
1119 1113
1120 protected: 1114 protected:
1121 Host_8() {} 1115 Host_8() {}
1122 virtual ~Host_8() {} 1116 virtual ~Host_8() {}
1123 }; 1117 };
1124 1118
1125 // Represents a decrypted block that has not been decoded. 1119 // Represents a decrypted block that has not been decoded.
1126 class DecryptedBlock { 1120 class CDM_API DecryptedBlock {
1127 public: 1121 public:
1128 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; 1122 virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
1129 virtual Buffer* DecryptedBuffer() = 0; 1123 virtual Buffer* DecryptedBuffer() = 0;
1130 1124
1131 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, 1125 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not,
1132 // we can just pass Buffer pointers around. 1126 // we can just pass Buffer pointers around.
1133 virtual void SetTimestamp(int64_t timestamp) = 0; 1127 virtual void SetTimestamp(int64_t timestamp) = 0;
1134 virtual int64_t Timestamp() const = 0; 1128 virtual int64_t Timestamp() const = 0;
1135 1129
1136 protected: 1130 protected:
1137 DecryptedBlock() {} 1131 DecryptedBlock() {}
1138 virtual ~DecryptedBlock() {} 1132 virtual ~DecryptedBlock() {}
1139 }; 1133 };
1140 1134
1141 class VideoFrame { 1135 class CDM_API VideoFrame {
1142 public: 1136 public:
1143 enum VideoPlane { 1137 enum VideoPlane {
1144 kYPlane = 0, 1138 kYPlane = 0,
1145 kUPlane = 1, 1139 kUPlane = 1,
1146 kVPlane = 2, 1140 kVPlane = 2,
1147 kMaxPlanes = 3, 1141 kMaxPlanes = 3,
1148 }; 1142 };
1149 1143
1150 virtual void SetFormat(VideoFormat format) = 0; 1144 virtual void SetFormat(VideoFormat format) = 0;
1151 virtual VideoFormat Format() const = 0; 1145 virtual VideoFormat Format() const = 0;
(...skipping 22 matching lines...) Expand all
1174 // multiple audio output buffers, which are serialized into this format: 1168 // multiple audio output buffers, which are serialized into this format:
1175 // 1169 //
1176 // |<------------------- serialized audio buffer ------------------->| 1170 // |<------------------- serialized audio buffer ------------------->|
1177 // | int64_t timestamp | int64_t length | length bytes of audio data | 1171 // | int64_t timestamp | int64_t length | length bytes of audio data |
1178 // 1172 //
1179 // For example, with three audio output buffers, the AudioFrames will look 1173 // For example, with three audio output buffers, the AudioFrames will look
1180 // like this: 1174 // like this:
1181 // 1175 //
1182 // |<----------------- AudioFrames ------------------>| 1176 // |<----------------- AudioFrames ------------------>|
1183 // | audio buffer 0 | audio buffer 1 | audio buffer 2 | 1177 // | audio buffer 0 | audio buffer 1 | audio buffer 2 |
1184 class AudioFrames { 1178 class CDM_API AudioFrames {
1185 public: 1179 public:
1186 virtual void SetFrameBuffer(Buffer* buffer) = 0; 1180 virtual void SetFrameBuffer(Buffer* buffer) = 0;
1187 virtual Buffer* FrameBuffer() = 0; 1181 virtual Buffer* FrameBuffer() = 0;
1188 1182
1189 // The CDM must call this method, providing a valid format, when providing 1183 // The CDM must call this method, providing a valid format, when providing
1190 // frame buffers. Planar data should be stored end to end; e.g., 1184 // frame buffers. Planar data should be stored end to end; e.g.,
1191 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... 1185 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|...
1192 virtual void SetFormat(AudioFormat format) = 0; 1186 virtual void SetFormat(AudioFormat format) = 0;
1193 virtual AudioFormat Format() const = 0; 1187 virtual AudioFormat Format() const = 0;
1194 1188
1195 protected: 1189 protected:
1196 AudioFrames() {} 1190 AudioFrames() {}
1197 virtual ~AudioFrames() {} 1191 virtual ~AudioFrames() {}
1198 }; 1192 };
1199 1193
1200 } // namespace cdm 1194 } // namespace cdm
1201 1195
1202 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ 1196 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698