diff options
Diffstat (limited to 'media/base/android/media_drm_bridge.cc')
-rw-r--r-- | media/base/android/media_drm_bridge.cc | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc index e898816..37eaa33 100644 --- a/media/base/android/media_drm_bridge.cc +++ b/media/base/android/media_drm_bridge.cc @@ -236,7 +236,7 @@ MediaDrmBridge::~MediaDrmBridge() { Java_MediaDrmBridge_release(env, j_media_drm_.obj()); } -bool MediaDrmBridge::CreateSession(uint32 reference_id, +bool MediaDrmBridge::CreateSession(uint32 session_id, const std::string& type, const uint8* init_data, int init_data_length) { @@ -248,13 +248,13 @@ bool MediaDrmBridge::CreateSession(uint32 reference_id, ScopedJavaLocalRef<jbyteArray> j_pssh_data = base::android::ToJavaByteArray(env, &pssh_data[0], pssh_data.size()); ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, type); - pending_key_request_reference_ids_.push(reference_id); + pending_key_request_session_ids_.push(session_id); Java_MediaDrmBridge_generateKeyRequest( env, j_media_drm_.obj(), j_pssh_data.obj(), j_mime.obj()); return true; } -void MediaDrmBridge::UpdateSession(uint32 reference_id, +void MediaDrmBridge::UpdateSession(uint32 session_id, const uint8* response, int response_length) { DVLOG(1) << __FUNCTION__; @@ -262,16 +262,16 @@ void MediaDrmBridge::UpdateSession(uint32 reference_id, ScopedJavaLocalRef<jbyteArray> j_response = base::android::ToJavaByteArray(env, response, response_length); ScopedJavaLocalRef<jstring> j_session_id = - ConvertUTF8ToJavaString(env, LookupSessionId(reference_id)); + ConvertUTF8ToJavaString(env, LookupWebSessionId(session_id)); // TODO(jrummell): Update Android names to match new functionality. Java_MediaDrmBridge_addKey( env, j_media_drm_.obj(), j_session_id.obj(), j_response.obj()); } -void MediaDrmBridge::ReleaseSession(uint32 reference_id) { +void MediaDrmBridge::ReleaseSession(uint32 session_id) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jstring> j_session_id = - ConvertUTF8ToJavaString(env, LookupSessionId(reference_id)); + ConvertUTF8ToJavaString(env, LookupWebSessionId(session_id)); Java_MediaDrmBridge_cancelKeyRequest( env, j_media_drm_.obj(), j_session_id.obj()); } @@ -303,29 +303,29 @@ void MediaDrmBridge::OnKeyMessage(JNIEnv* env, jstring j_session_id, jbyteArray j_message, jstring j_destination_url) { - std::string session_id = ConvertJavaStringToUTF8(env, j_session_id); - uint32_t reference_id = DetermineReferenceId(session_id); + std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id); + uint32_t session_id = LookupSessionId(web_session_id); std::vector<uint8> message; JavaByteArrayToByteVector(env, j_message, &message); std::string destination_url = ConvertJavaStringToUTF8(env, j_destination_url); - manager_->OnSessionCreated(media_keys_id_, reference_id, session_id); + manager_->OnSessionCreated(media_keys_id_, session_id, web_session_id); manager_->OnSessionMessage( - media_keys_id_, reference_id, message, destination_url); + media_keys_id_, session_id, message, destination_url); } void MediaDrmBridge::OnKeyAdded(JNIEnv* env, jobject, jstring j_session_id) { - std::string session_id = ConvertJavaStringToUTF8(env, j_session_id); - uint32_t reference_id = DetermineReferenceId(session_id); - manager_->OnSessionReady(media_keys_id_, reference_id); + std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id); + uint32_t session_id = LookupSessionId(web_session_id); + manager_->OnSessionReady(media_keys_id_, session_id); } void MediaDrmBridge::OnKeyError(JNIEnv* env, jobject, jstring j_session_id) { // |j_session_id| can be NULL, in which case we'll return an empty string. - std::string session_id = ConvertJavaStringToUTF8(env, j_session_id); - uint32 reference_id = DetermineReferenceId(session_id); + std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id); + uint32 session_id = LookupSessionId(web_session_id); manager_->OnSessionError( - media_keys_id_, reference_id, MediaKeys::kUnknownError, 0); + media_keys_id_, session_id, MediaKeys::kUnknownError, 0); } ScopedJavaLocalRef<jobject> MediaDrmBridge::GetMediaCrypto() { @@ -364,7 +364,7 @@ void MediaDrmBridge::OnResetDeviceCredentialsCompleted( base::ResetAndReturn(&reset_credentials_cb_).Run(success); } -uint32_t MediaDrmBridge::DetermineReferenceId(const std::string& session_id) { +uint32_t MediaDrmBridge::LookupSessionId(const std::string& session_id) { for (SessionMap::iterator it = session_map_.begin(); it != session_map_.end(); ++it) { @@ -374,25 +374,24 @@ uint32_t MediaDrmBridge::DetermineReferenceId(const std::string& session_id) { // There is no entry in the map; assume it came from the oldest // GenerateKeyRequest() call. - DCHECK(!pending_key_request_reference_ids_.empty()); - uint32 reference_id = pending_key_request_reference_ids_.front(); - pending_key_request_reference_ids_.pop(); + DCHECK(!pending_key_request_session_ids_.empty()); + uint32 session_reference_id = pending_key_request_session_ids_.front(); + pending_key_request_session_ids_.pop(); // If this is a valid |session_id|, add it to the list. Otherwise, avoid // adding empty string as a mapping to prevent future calls with an empty - // string from using the wrong reference_id. + // string from using the wrong session_reference_id. if (!session_id.empty()) { - DCHECK(session_map_.find(reference_id) == session_map_.end()); - DCHECK(!session_id.empty()); - session_map_[reference_id] = session_id; + DCHECK(session_map_.find(session_reference_id) == session_map_.end()); + session_map_[session_reference_id] = session_id; } - return reference_id; + return session_reference_id; } -const std::string& MediaDrmBridge::LookupSessionId(uint32 reference_id) { +const std::string& MediaDrmBridge::LookupWebSessionId(uint32 session_id) { // Session may not exist if error happens during GenerateKeyRequest(). - SessionMap::iterator it = session_map_.find(reference_id); + SessionMap::iterator it = session_map_.find(session_id); return (it != session_map_.end()) ? it->second : base::EmptyString(); } |