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

Side by Side Diff: content_decryption_module.h

Issue 130803006: Add LoadSession() to CDM_4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/cdm
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« 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;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 namespace cdm { 76 namespace cdm {
77 77
78 class AudioFrames_1; 78 class AudioFrames_1;
79 class AudioFrames_2; 79 class AudioFrames_2;
80 typedef AudioFrames_2 AudioFrames; 80 typedef AudioFrames_2 AudioFrames;
81 81
82 class Host_1; 82 class Host_1;
83 class Host_2; 83 class Host_2;
84 class Host_3; 84 class Host_4;
85 85
86 class DecryptedBlock; 86 class DecryptedBlock;
87 class VideoFrame; 87 class VideoFrame;
88 88
89 enum Status { 89 enum Status {
90 kSuccess = 0, 90 kSuccess = 0,
91 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. 91 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample.
92 kNoKey, // The required decryption key is not available. 92 kNoKey, // The required decryption key is not available.
93 kSessionError, // Session management error. 93 kSessionError, // Session management error.
94 kDecryptError, // Decryption failed. 94 kDecryptError, // Decryption failed.
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 ContentDecryptionModule_2() {} 656 ContentDecryptionModule_2() {}
657 virtual ~ContentDecryptionModule_2() {} 657 virtual ~ContentDecryptionModule_2() {}
658 }; 658 };
659 659
660 // ContentDecryptionModule interface that all CDMs need to implement. 660 // ContentDecryptionModule interface that all CDMs need to implement.
661 // The interface is versioned for backward compatibility. 661 // The interface is versioned for backward compatibility.
662 // Note: ContentDecryptionModule implementations must use the allocator 662 // Note: ContentDecryptionModule implementations must use the allocator
663 // provided in CreateCdmInstance() to allocate any Buffer that needs to 663 // provided in CreateCdmInstance() to allocate any Buffer that needs to
664 // be passed back to the caller. Implementations must call Buffer::Destroy() 664 // be passed back to the caller. Implementations must call Buffer::Destroy()
665 // when a Buffer is created that will never be returned to the caller. 665 // when a Buffer is created that will never be returned to the caller.
666 class ContentDecryptionModule_3 { 666 class ContentDecryptionModule_4 {
667 public: 667 public:
668 static const int kVersion = 3; 668 static const int kVersion = 4;
669 typedef Host_3 Host; 669 typedef Host_4 Host;
670 670
671 // CreateSession(), UpdateSession(), and ReleaseSession() get passed a 671 // CreateSession(), UpdateSession(), and ReleaseSession() get passed a
672 // |session_id| for a MediaKeySession object. It must be used in the reply via 672 // |session_id| for a MediaKeySession object. It must be used in the reply via
673 // Host methods (e.g. Host::OnSessionMessage()). 673 // Host methods (e.g. Host::OnSessionMessage()).
674 // Note: |session_id| is different from MediaKeySession's sessionId attribute, 674 // Note: |session_id| is different from MediaKeySession's sessionId attribute,
675 // which is referred to as |web_session_id| in this file. 675 // which is referred to as |web_session_id| in this file.
676 676
677 // Creates a session given |type| and |init_data|. 677 // Creates a session given |type| and |init_data|.
678 virtual void CreateSession( 678 virtual void CreateSession(
679 uint32_t session_id, 679 uint32_t session_id,
680 const char* type, uint32_t type_size, 680 const char* type, uint32_t type_size,
681 const uint8_t* init_data, uint32_t init_data_size) = 0; 681 const uint8_t* init_data, uint32_t init_data_size) = 0;
682 682
683 // Loads a session that has |web_session_id|.
684 virtual void LoadSession(
685 uint32_t session_id,
686 const char* web_session_id, uint32_t web_session_id_length) = 0;
687
683 // Updates the session with |response|. 688 // Updates the session with |response|.
684 virtual void UpdateSession( 689 virtual void UpdateSession(
685 uint32_t session_id, 690 uint32_t session_id,
686 const uint8_t* response, uint32_t response_size) = 0; 691 const uint8_t* response, uint32_t response_size) = 0;
687 692
688 // Releases the resources for the session. 693 // Releases the resources for the session.
689 virtual void ReleaseSession(uint32_t session_id) = 0; 694 virtual void ReleaseSession(uint32_t session_id) = 0;
690 695
691 // Performs scheduled operation with |context| when the timer fires. 696 // Performs scheduled operation with |context| when the timer fires.
692 virtual void TimerExpired(void* context) = 0; 697 virtual void TimerExpired(void* context) = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The 791 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The
787 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask| 792 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask|
788 // is a bit mask of OutputProtectionMethods. 793 // is a bit mask of OutputProtectionMethods.
789 virtual void OnQueryOutputProtectionStatus( 794 virtual void OnQueryOutputProtectionStatus(
790 uint32_t link_mask, uint32_t output_protection_mask) = 0; 795 uint32_t link_mask, uint32_t output_protection_mask) = 0;
791 796
792 // Destroys the object in the same context as it was created. 797 // Destroys the object in the same context as it was created.
793 virtual void Destroy() = 0; 798 virtual void Destroy() = 0;
794 799
795 protected: 800 protected:
796 ContentDecryptionModule_3() {} 801 ContentDecryptionModule_4() {}
797 virtual ~ContentDecryptionModule_3() {} 802 virtual ~ContentDecryptionModule_4() {}
798 }; 803 };
799 804
800 typedef ContentDecryptionModule_3 ContentDecryptionModule; 805 typedef ContentDecryptionModule_4 ContentDecryptionModule;
801 806
802 // Represents a buffer created by Allocator implementations. 807 // Represents a buffer created by Allocator implementations.
803 class Buffer { 808 class Buffer {
804 public: 809 public:
805 // Destroys the buffer in the same context as it was created. 810 // Destroys the buffer in the same context as it was created.
806 virtual void Destroy() = 0; 811 virtual void Destroy() = 0;
807 812
808 virtual uint32_t Capacity() const = 0; 813 virtual uint32_t Capacity() const = 0;
809 virtual uint8_t* Data() = 0; 814 virtual uint8_t* Data() = 0;
810 virtual void SetSize(uint32_t size) = 0; 815 virtual void SetSize(uint32_t size) = 0;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 // Must be called by the CDM if it returned kDeferredInitialization during 925 // Must be called by the CDM if it returned kDeferredInitialization during
921 // InitializeAudioDecoder() or InitializeVideoDecoder(). 926 // InitializeAudioDecoder() or InitializeVideoDecoder().
922 virtual void OnDeferredInitializationDone(StreamType stream_type, 927 virtual void OnDeferredInitializationDone(StreamType stream_type,
923 Status decoder_status) = 0; 928 Status decoder_status) = 0;
924 929
925 protected: 930 protected:
926 Host_2() {} 931 Host_2() {}
927 virtual ~Host_2() {} 932 virtual ~Host_2() {}
928 }; 933 };
929 934
930 class Host_3 { 935 class Host_4 {
931 public: 936 public:
932 static const int kVersion = 3; 937 static const int kVersion = 4;
933 938
934 // Returns a Buffer* containing non-zero members upon success, or NULL on 939 // Returns a Buffer* containing non-zero members upon success, or NULL on
935 // failure. The caller owns the Buffer* after this call. The buffer is not 940 // failure. The caller owns the Buffer* after this call. The buffer is not
936 // guaranteed to be zero initialized. The capacity of the allocated Buffer 941 // guaranteed to be zero initialized. The capacity of the allocated Buffer
937 // is guaranteed to be not less than |capacity|. 942 // is guaranteed to be not less than |capacity|.
938 virtual Buffer* Allocate(uint32_t capacity) = 0; 943 virtual Buffer* Allocate(uint32_t capacity) = 0;
939 944
940 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| 945 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
941 // from now with |context|. 946 // from now with |context|.
942 virtual void SetTimer(int64_t delay_ms, void* context) = 0; 947 virtual void SetTimer(int64_t delay_ms, void* context) = 0;
943 948
944 // Returns the current epoch wall time in seconds. 949 // Returns the current epoch wall time in seconds.
945 virtual double GetCurrentWallTimeInSeconds() = 0; 950 virtual double GetCurrentWallTimeInSeconds() = 0;
946 951
947 // Called by the CDM when a session is created and the value for the 952 // Called by the CDM when a session is created or loaded and the value for the
948 // MediaKeySession's sessionId attribute is available (|web_session_id|). 953 // MediaKeySession's sessionId attribute is available (|web_session_id|).
949 // This must be called before OnSessionMessage() or OnSessionReady() is called 954 // This must be called before OnSessionMessage() or OnSessionReady() is called
950 // for |session_id|. |web_session_id_length| should not include null 955 // for |session_id|. |web_session_id_length| should not include null
951 // termination. 956 // termination.
957 // When called in response to LoadSession(), the |web_session_id| must be the
958 // same as the |web_session_id| passed in LoadSession().
952 virtual void OnSessionCreated( 959 virtual void OnSessionCreated(
953 uint32_t session_id, 960 uint32_t session_id,
954 const char* web_session_id, uint32_t web_session_id_length) = 0; 961 const char* web_session_id, uint32_t web_session_id_length) = 0;
955 962
956 // Called by the CDM when it has a message for session |session_id|. 963 // Called by the CDM when it has a message for session |session_id|.
957 // Length parameters should not include null termination. 964 // Length parameters should not include null termination.
958 virtual void OnSessionMessage( 965 virtual void OnSessionMessage(
959 uint32_t session_id, 966 uint32_t session_id,
960 const char* message, uint32_t message_length, 967 const char* message, uint32_t message_length,
961 const char* destination_url, uint32_t destination_url_length) = 0; 968 const char* destination_url, uint32_t destination_url_length) = 0;
962 969
963 // Called by the CDM when session |session_id| is ready. 970 // Called by the CDM when session |session_id| is ready.
971 // Note: "ready" event is deprecated. This is only used for the prefixed EME
972 // API's "keyAdded" event. Drop this when we deprecate prefixed EME API.
964 virtual void OnSessionReady(uint32_t session_id) = 0; 973 virtual void OnSessionReady(uint32_t session_id) = 0;
965 974
966 // Called by the CDM when session |session_id| is closed. 975 // Called by the CDM when session |session_id| is closed.
967 virtual void OnSessionClosed(uint32_t session_id) = 0; 976 virtual void OnSessionClosed(uint32_t session_id) = 0;
968 977
969 // Called by the CDM when an error occurs in session |session_id|. 978 // Called by the CDM when an error occurs in session |session_id|.
970 virtual void OnSessionError(uint32_t session_id, 979 virtual void OnSessionError(uint32_t session_id,
971 MediaKeyError error_code, 980 MediaKeyError error_code,
972 uint32_t system_code) = 0; 981 uint32_t system_code) = 0;
973 982
(...skipping 24 matching lines...) Expand all
998 virtual void OnDeferredInitializationDone(StreamType stream_type, 1007 virtual void OnDeferredInitializationDone(StreamType stream_type,
999 Status decoder_status) = 0; 1008 Status decoder_status) = 0;
1000 1009
1001 // Creates a FileIO object from the host to do file IO operation. Returns NULL 1010 // Creates a FileIO object from the host to do file IO operation. Returns NULL
1002 // if a FileIO object cannot be obtained. Once a valid FileIO object is 1011 // if a FileIO object cannot be obtained. Once a valid FileIO object is
1003 // returned, |client| must be valid until FileIO::Close() is called. The 1012 // returned, |client| must be valid until FileIO::Close() is called. The
1004 // CDM can call this method multiple times to operate on different files. 1013 // CDM can call this method multiple times to operate on different files.
1005 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 1014 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
1006 1015
1007 protected: 1016 protected:
1008 Host_3() {} 1017 Host_4() {}
1009 virtual ~Host_3() {} 1018 virtual ~Host_4() {}
1010 }; 1019 };
1011 1020
1012 // Represents a decrypted block that has not been decoded. 1021 // Represents a decrypted block that has not been decoded.
1013 class DecryptedBlock { 1022 class DecryptedBlock {
1014 public: 1023 public:
1015 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; 1024 virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
1016 virtual Buffer* DecryptedBuffer() = 0; 1025 virtual Buffer* DecryptedBuffer() = 0;
1017 1026
1018 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, 1027 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not,
1019 // we can just pass Buffer pointers around. 1028 // we can just pass Buffer pointers around.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 virtual AudioFormat Format() const = 0; 1104 virtual AudioFormat Format() const = 0;
1096 1105
1097 protected: 1106 protected:
1098 AudioFrames_2() {} 1107 AudioFrames_2() {}
1099 virtual ~AudioFrames_2() {} 1108 virtual ~AudioFrames_2() {}
1100 }; 1109 };
1101 1110
1102 } // namespace cdm 1111 } // namespace cdm
1103 1112
1104 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ 1113 #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