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

Side by Side Diff: content_decryption_module.h

Issue 1964083003: Fix the breakage on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/cdm.git@master
Patch Set: add comment 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_API 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. Note: the implementation lives in 18 // can be exported to consumers. Note: the implementation lives in
19 // a dynamic library even in a non-component build. 19 // a dynamic library even in a non-component build.
20 // Also define CDM_CLASS_API to export class types. We have to add
21 // visibility attributes to make sure virtual tables in CDM consumer
22 // and CDM implementation are the same. Generally, it was always a
23 // good idea, as there're no guarantees about that for the internal
24 // symbols, but it has only become a practical issue after
25 // introduction of LTO devirtualization. See more details on
26 // https://crbug.com/609564#c35
20 #if defined(WIN32) 27 #if defined(WIN32)
21 28
29 #if defined(__clang__)
30 #define CDM_CLASS_API [[clang::lto_visibility_public]]
31 #else
32 #define CDM_CLASS_API
33 #endif
34
22 #if defined(CDM_IMPLEMENTATION) 35 #if defined(CDM_IMPLEMENTATION)
23 #define CDM_API __declspec(dllexport) 36 #define CDM_API __declspec(dllexport)
24 #else 37 #else
25 #define CDM_API __declspec(dllimport) 38 #define CDM_API __declspec(dllimport)
26 #endif // defined(CDM_IMPLEMENTATION) 39 #endif // defined(CDM_IMPLEMENTATION)
27 40
28 #else // defined(WIN32) 41 #else // defined(WIN32)
29 #define CDM_API __attribute__((visibility("default"))) 42 #define CDM_API __attribute__((visibility("default")))
43 #define CDM_CLASS_API __attribute__((visibility("default")))
30 #endif // defined(WIN32) 44 #endif // defined(WIN32)
31 45
32 // The version number must be rolled when the exported functions are updated! 46 // The version number must be rolled when the exported functions are updated!
33 // If the CDM and the adapter use different versions of these functions, the 47 // If the CDM and the adapter use different versions of these functions, the
34 // adapter will fail to load or crash! 48 // adapter will fail to load or crash!
35 #define CDM_MODULE_VERSION 4 49 #define CDM_MODULE_VERSION 4
36 50
37 // Build the versioned entrypoint name. 51 // Build the versioned entrypoint name.
38 // The extra macros are necessary to expand version to an actual value. 52 // The extra macros are necessary to expand version to an actual value.
39 #define INITIALIZE_CDM_MODULE \ 53 #define INITIALIZE_CDM_MODULE \
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 386
373 // FileIO interface provides a way for the CDM to store data in a file in 387 // FileIO interface provides a way for the CDM to store data in a file in
374 // persistent storage. This interface aims only at providing basic read/write 388 // persistent storage. This interface aims only at providing basic read/write
375 // capabilities and should not be used as a full fledged file IO API. 389 // capabilities and should not be used as a full fledged file IO API.
376 // Each CDM and origin (e.g. HTTPS, "foo.example.com", 443) combination has 390 // Each CDM and origin (e.g. HTTPS, "foo.example.com", 443) combination has
377 // its own persistent storage. All instances of a given CDM associated with a 391 // its own persistent storage. All instances of a given CDM associated with a
378 // given origin share the same persistent storage. 392 // given origin share the same persistent storage.
379 // Note to implementors of this interface: 393 // Note to implementors of this interface:
380 // Per-origin storage and the ability for users to clear it are important. 394 // Per-origin storage and the ability for users to clear it are important.
381 // See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo. 395 // See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo.
382 class CDM_API FileIO { 396 class CDM_CLASS_API FileIO {
383 public: 397 public:
384 // Opens the file with |file_name| for read and write. 398 // Opens the file with |file_name| for read and write.
385 // FileIOClient::OnOpenComplete() will be called after the opening 399 // FileIOClient::OnOpenComplete() will be called after the opening
386 // operation finishes. 400 // operation finishes.
387 // - When the file is opened by a CDM instance, it will be classified as "in 401 // - When the file is opened by a CDM instance, it will be classified as "in
388 // use". In this case other CDM instances in the same domain may receive 402 // use". In this case other CDM instances in the same domain may receive
389 // kInUse status when trying to open it. 403 // kInUse status when trying to open it.
390 // - |file_name| must not contain forward slash ('/') or backslash ('\'), and 404 // - |file_name| must not contain forward slash ('/') or backslash ('\'), and
391 // must not start with an underscore ('_'). 405 // must not start with an underscore ('_').
392 virtual void Open(const char* file_name, uint32_t file_name_size) = 0; 406 virtual void Open(const char* file_name, uint32_t file_name_size) = 0;
(...skipping 19 matching lines...) Expand all
412 426
413 protected: 427 protected:
414 FileIO() {} 428 FileIO() {}
415 virtual ~FileIO() {} 429 virtual ~FileIO() {}
416 }; 430 };
417 431
418 // Responses to FileIO calls. All responses will be called asynchronously. 432 // Responses to FileIO calls. All responses will be called asynchronously.
419 // When kError is returned, the FileIO object could be in an error state. All 433 // When kError is returned, the FileIO object could be in an error state. All
420 // following calls (other than Close()) could return kError. The CDM should 434 // following calls (other than Close()) could return kError. The CDM should
421 // still call Close() to destroy the FileIO object. 435 // still call Close() to destroy the FileIO object.
422 class CDM_API FileIOClient { 436 class CDM_CLASS_API FileIOClient {
423 public: 437 public:
424 enum Status { 438 enum Status {
425 kSuccess = 0, 439 kSuccess = 0,
426 kInUse, 440 kInUse,
427 kError 441 kError
428 }; 442 };
429 443
430 // Response to a FileIO::Open() call with the open |status|. 444 // Response to a FileIO::Open() call with the open |status|.
431 virtual void OnOpenComplete(Status status) = 0; 445 virtual void OnOpenComplete(Status status) = 0;
432 446
(...skipping 20 matching lines...) Expand all
453 FileIOClient() {} 467 FileIOClient() {}
454 virtual ~FileIOClient() {} 468 virtual ~FileIOClient() {}
455 }; 469 };
456 470
457 // ContentDecryptionModule interface that all CDMs need to implement. 471 // ContentDecryptionModule interface that all CDMs need to implement.
458 // The interface is versioned for backward compatibility. 472 // The interface is versioned for backward compatibility.
459 // Note: ContentDecryptionModule implementations must use the allocator 473 // Note: ContentDecryptionModule implementations must use the allocator
460 // provided in CreateCdmInstance() to allocate any Buffer that needs to 474 // provided in CreateCdmInstance() to allocate any Buffer that needs to
461 // be passed back to the caller. Implementations must call Buffer::Destroy() 475 // be passed back to the caller. Implementations must call Buffer::Destroy()
462 // when a Buffer is created that will never be returned to the caller. 476 // when a Buffer is created that will never be returned to the caller.
463 class CDM_API ContentDecryptionModule_7 { 477 class CDM_CLASS_API ContentDecryptionModule_7 {
464 public: 478 public:
465 static const int kVersion = 7; 479 static const int kVersion = 7;
466 typedef Host_7 Host; 480 typedef Host_7 Host;
467 481
468 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(), 482 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(),
469 // UpdateSession(), CloseSession(), and RemoveSession() all accept a 483 // UpdateSession(), CloseSession(), and RemoveSession() all accept a
470 // |promise_id|, which must be passed to the completion Host method 484 // |promise_id|, which must be passed to the completion Host method
471 // (e.g. Host::OnResolveNewSessionPromise()). 485 // (e.g. Host::OnResolveNewSessionPromise()).
472 486
473 // Provides a server certificate to be used to encrypt messages to the 487 // Provides a server certificate to be used to encrypt messages to the
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 ContentDecryptionModule_7() {} 646 ContentDecryptionModule_7() {}
633 virtual ~ContentDecryptionModule_7() {} 647 virtual ~ContentDecryptionModule_7() {}
634 }; 648 };
635 649
636 // ContentDecryptionModule interface that all CDMs need to implement. 650 // ContentDecryptionModule interface that all CDMs need to implement.
637 // The interface is versioned for backward compatibility. 651 // The interface is versioned for backward compatibility.
638 // Note: ContentDecryptionModule implementations must use the allocator 652 // Note: ContentDecryptionModule implementations must use the allocator
639 // provided in CreateCdmInstance() to allocate any Buffer that needs to 653 // provided in CreateCdmInstance() to allocate any Buffer that needs to
640 // be passed back to the caller. Implementations must call Buffer::Destroy() 654 // be passed back to the caller. Implementations must call Buffer::Destroy()
641 // when a Buffer is created that will never be returned to the caller. 655 // when a Buffer is created that will never be returned to the caller.
642 class CDM_API ContentDecryptionModule_8 { 656 class CDM_CLASS_API ContentDecryptionModule_8 {
643 public: 657 public:
644 static const int kVersion = 8; 658 static const int kVersion = 8;
645 typedef Host_8 Host; 659 typedef Host_8 Host;
646 660
647 // Initializes the CDM instance, providing information about permitted 661 // Initializes the CDM instance, providing information about permitted
648 // functionalities. 662 // functionalities.
649 // If |allow_distinctive_identifier| is false, messages from the CDM, 663 // If |allow_distinctive_identifier| is false, messages from the CDM,
650 // such as message events, must not contain a Distinctive Identifier, 664 // such as message events, must not contain a Distinctive Identifier,
651 // even in an encrypted form. 665 // even in an encrypted form.
652 // If |allow_persistent_state| is false, the CDM must not attempt to 666 // If |allow_persistent_state| is false, the CDM must not attempt to
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 virtual void Destroy() = 0; 831 virtual void Destroy() = 0;
818 832
819 protected: 833 protected:
820 ContentDecryptionModule_8() {} 834 ContentDecryptionModule_8() {}
821 virtual ~ContentDecryptionModule_8() {} 835 virtual ~ContentDecryptionModule_8() {}
822 }; 836 };
823 837
824 typedef ContentDecryptionModule_8 ContentDecryptionModule; 838 typedef ContentDecryptionModule_8 ContentDecryptionModule;
825 839
826 // Represents a buffer created by Allocator implementations. 840 // Represents a buffer created by Allocator implementations.
827 class CDM_API Buffer { 841 class CDM_CLASS_API Buffer {
828 public: 842 public:
829 // Destroys the buffer in the same context as it was created. 843 // Destroys the buffer in the same context as it was created.
830 virtual void Destroy() = 0; 844 virtual void Destroy() = 0;
831 845
832 virtual uint32_t Capacity() const = 0; 846 virtual uint32_t Capacity() const = 0;
833 virtual uint8_t* Data() = 0; 847 virtual uint8_t* Data() = 0;
834 virtual void SetSize(uint32_t size) = 0; 848 virtual void SetSize(uint32_t size) = 0;
835 virtual uint32_t Size() const = 0; 849 virtual uint32_t Size() const = 0;
836 850
837 protected: 851 protected:
838 Buffer() {} 852 Buffer() {}
839 virtual ~Buffer() {} 853 virtual ~Buffer() {}
840 854
841 private: 855 private:
842 Buffer(const Buffer&); 856 Buffer(const Buffer&);
843 void operator=(const Buffer&); 857 void operator=(const Buffer&);
844 }; 858 };
845 859
846 class CDM_API Host_7 { 860 class CDM_CLASS_API Host_7 {
847 public: 861 public:
848 static const int kVersion = 7; 862 static const int kVersion = 7;
849 863
850 // Returns a Buffer* containing non-zero members upon success, or NULL on 864 // Returns a Buffer* containing non-zero members upon success, or NULL on
851 // failure. The caller owns the Buffer* after this call. The buffer is not 865 // failure. The caller owns the Buffer* after this call. The buffer is not
852 // guaranteed to be zero initialized. The capacity of the allocated Buffer 866 // guaranteed to be zero initialized. The capacity of the allocated Buffer
853 // is guaranteed to be not less than |capacity|. 867 // is guaranteed to be not less than |capacity|.
854 virtual Buffer* Allocate(uint32_t capacity) = 0; 868 virtual Buffer* Allocate(uint32_t capacity) = 0;
855 869
856 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| 870 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 // if a FileIO object cannot be obtained. Once a valid FileIO object is 987 // if a FileIO object cannot be obtained. Once a valid FileIO object is
974 // returned, |client| must be valid until FileIO::Close() is called. The 988 // returned, |client| must be valid until FileIO::Close() is called. The
975 // CDM can call this method multiple times to operate on different files. 989 // CDM can call this method multiple times to operate on different files.
976 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 990 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
977 991
978 protected: 992 protected:
979 Host_7() {} 993 Host_7() {}
980 virtual ~Host_7() {} 994 virtual ~Host_7() {}
981 }; 995 };
982 996
983 class CDM_API Host_8 { 997 class CDM_CLASS_API Host_8 {
984 public: 998 public:
985 static const int kVersion = 8; 999 static const int kVersion = 8;
986 1000
987 // Returns a Buffer* containing non-zero members upon success, or NULL on 1001 // Returns a Buffer* containing non-zero members upon success, or NULL on
988 // failure. The caller owns the Buffer* after this call. The buffer is not 1002 // failure. The caller owns the Buffer* after this call. The buffer is not
989 // guaranteed to be zero initialized. The capacity of the allocated Buffer 1003 // guaranteed to be zero initialized. The capacity of the allocated Buffer
990 // is guaranteed to be not less than |capacity|. 1004 // is guaranteed to be not less than |capacity|.
991 virtual Buffer* Allocate(uint32_t capacity) = 0; 1005 virtual Buffer* Allocate(uint32_t capacity) = 0;
992 1006
993 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| 1007 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // returned, |client| must be valid until FileIO::Close() is called. The 1125 // returned, |client| must be valid until FileIO::Close() is called. The
1112 // CDM can call this method multiple times to operate on different files. 1126 // CDM can call this method multiple times to operate on different files.
1113 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 1127 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
1114 1128
1115 protected: 1129 protected:
1116 Host_8() {} 1130 Host_8() {}
1117 virtual ~Host_8() {} 1131 virtual ~Host_8() {}
1118 }; 1132 };
1119 1133
1120 // Represents a decrypted block that has not been decoded. 1134 // Represents a decrypted block that has not been decoded.
1121 class CDM_API DecryptedBlock { 1135 class CDM_CLASS_API DecryptedBlock {
1122 public: 1136 public:
1123 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; 1137 virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
1124 virtual Buffer* DecryptedBuffer() = 0; 1138 virtual Buffer* DecryptedBuffer() = 0;
1125 1139
1126 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, 1140 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not,
1127 // we can just pass Buffer pointers around. 1141 // we can just pass Buffer pointers around.
1128 virtual void SetTimestamp(int64_t timestamp) = 0; 1142 virtual void SetTimestamp(int64_t timestamp) = 0;
1129 virtual int64_t Timestamp() const = 0; 1143 virtual int64_t Timestamp() const = 0;
1130 1144
1131 protected: 1145 protected:
1132 DecryptedBlock() {} 1146 DecryptedBlock() {}
1133 virtual ~DecryptedBlock() {} 1147 virtual ~DecryptedBlock() {}
1134 }; 1148 };
1135 1149
1136 class CDM_API VideoFrame { 1150 class CDM_CLASS_API VideoFrame {
1137 public: 1151 public:
1138 enum VideoPlane { 1152 enum VideoPlane {
1139 kYPlane = 0, 1153 kYPlane = 0,
1140 kUPlane = 1, 1154 kUPlane = 1,
1141 kVPlane = 2, 1155 kVPlane = 2,
1142 kMaxPlanes = 3, 1156 kMaxPlanes = 3,
1143 }; 1157 };
1144 1158
1145 virtual void SetFormat(VideoFormat format) = 0; 1159 virtual void SetFormat(VideoFormat format) = 0;
1146 virtual VideoFormat Format() const = 0; 1160 virtual VideoFormat Format() const = 0;
(...skipping 22 matching lines...) Expand all
1169 // multiple audio output buffers, which are serialized into this format: 1183 // multiple audio output buffers, which are serialized into this format:
1170 // 1184 //
1171 // |<------------------- serialized audio buffer ------------------->| 1185 // |<------------------- serialized audio buffer ------------------->|
1172 // | int64_t timestamp | int64_t length | length bytes of audio data | 1186 // | int64_t timestamp | int64_t length | length bytes of audio data |
1173 // 1187 //
1174 // For example, with three audio output buffers, the AudioFrames will look 1188 // For example, with three audio output buffers, the AudioFrames will look
1175 // like this: 1189 // like this:
1176 // 1190 //
1177 // |<----------------- AudioFrames ------------------>| 1191 // |<----------------- AudioFrames ------------------>|
1178 // | audio buffer 0 | audio buffer 1 | audio buffer 2 | 1192 // | audio buffer 0 | audio buffer 1 | audio buffer 2 |
1179 class CDM_API AudioFrames { 1193 class CDM_CLASS_API AudioFrames {
1180 public: 1194 public:
1181 virtual void SetFrameBuffer(Buffer* buffer) = 0; 1195 virtual void SetFrameBuffer(Buffer* buffer) = 0;
1182 virtual Buffer* FrameBuffer() = 0; 1196 virtual Buffer* FrameBuffer() = 0;
1183 1197
1184 // The CDM must call this method, providing a valid format, when providing 1198 // The CDM must call this method, providing a valid format, when providing
1185 // frame buffers. Planar data should be stored end to end; e.g., 1199 // frame buffers. Planar data should be stored end to end; e.g.,
1186 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... 1200 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|...
1187 virtual void SetFormat(AudioFormat format) = 0; 1201 virtual void SetFormat(AudioFormat format) = 0;
1188 virtual AudioFormat Format() const = 0; 1202 virtual AudioFormat Format() const = 0;
1189 1203
1190 protected: 1204 protected:
1191 AudioFrames() {} 1205 AudioFrames() {}
1192 virtual ~AudioFrames() {} 1206 virtual ~AudioFrames() {}
1193 }; 1207 };
1194 1208
1195 } // namespace cdm 1209 } // namespace cdm
1196 1210
1197 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ 1211 #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