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

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