Chromium Code Reviews| Index: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc |
| diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc |
| index a643920e28fbd8dc85277611e1447655696db562..43b8e168490ca08818147c097676bdaedba88219 100644 |
| --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc |
| +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc |
| @@ -95,7 +95,7 @@ const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT"; |
| // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is |
| // empty, an empty (end-of-stream) media::DecoderBuffer is returned. |
| static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( |
| - const cdm::InputBuffer_1& input_buffer) { |
| + const cdm::InputBuffer& input_buffer) { |
| if (!input_buffer.data) { |
| DCHECK(!input_buffer.data_size); |
| return media::DecoderBuffer::CreateEOSBuffer(); |
| @@ -113,7 +113,6 @@ static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( |
| subsamples.push_back(subsample); |
| } |
| - DCHECK_EQ(input_buffer.data_offset, 0u); |
| scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( |
| std::string(reinterpret_cast<const char*>(input_buffer.key_id), |
| input_buffer.key_id_size), |
| @@ -298,11 +297,11 @@ void ClearKeyCdm::LoadSession(uint32 promise_id, |
| void ClearKeyCdm::UpdateSession(uint32 promise_id, |
| const char* web_session_id, |
| - uint32_t web_session_id_size, |
| + uint32_t web_session_id_length, |
| const uint8* response, |
| uint32 response_size) { |
| DVLOG(1) << __FUNCTION__; |
| - std::string web_session_str(web_session_id, web_session_id_size); |
| + std::string web_session_str(web_session_id, web_session_id_length); |
| scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise( |
| base::Bind(&ClearKeyCdm::OnSessionUpdated, |
| @@ -320,11 +319,11 @@ void ClearKeyCdm::UpdateSession(uint32 promise_id, |
| } |
| } |
| -void ClearKeyCdm::ReleaseSession(uint32 promise_id, |
| - const char* web_session_id, |
| - uint32_t web_session_id_size) { |
| +void ClearKeyCdm::CloseSession(uint32 promise_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_length) { |
| DVLOG(1) << __FUNCTION__; |
| - std::string web_session_str(web_session_id, web_session_id_size); |
| + std::string web_session_str(web_session_id, web_session_id_length); |
| scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise( |
| base::Bind(&ClearKeyCdm::OnSessionReleased, |
| @@ -336,6 +335,24 @@ void ClearKeyCdm::ReleaseSession(uint32 promise_id, |
| decryptor_.ReleaseSession(web_session_str, promise.Pass()); |
| } |
| +void ClearKeyCdm::RemoveSession(uint32 promise_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_length) { |
| + DVLOG(1) << __FUNCTION__; |
| + // RemoveSession only allowed for the simulated loadable session. |
|
ddorwin
2014/08/08 23:36:25
Really, the session must be persistent. How about
jrummell
2014/08/11 18:59:04
Done.
|
| + if (std::string(kLoadableWebSessionId) == |
| + std::string(web_session_id, web_session_id_length)) { |
| + host_->OnResolvePromise(promise_id); |
| + } else { |
| + std::string message("Incorrect session id specified for RemoveSession()."); |
|
ddorwin
2014/08/08 23:36:25
"Not supported for non-persistent sessions."
jrummell
2014/08/11 18:59:04
Done.
|
| + host_->OnRejectPromise(promise_id, |
| + cdm::kInvalidAccessError, |
| + 0, |
| + message.data(), |
| + message.length()); |
| + } |
| +} |
| + |
| void ClearKeyCdm::SetServerCertificate(uint32 promise_id, |
| const uint8_t* server_certificate_data, |
| uint32_t server_certificate_data_size) { |
| @@ -343,6 +360,19 @@ void ClearKeyCdm::SetServerCertificate(uint32 promise_id, |
| host_->OnResolvePromise(promise_id); |
| } |
| +void ClearKeyCdm::GetUsableKeyIds(uint32_t promise_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_length) { |
| + std::string web_session_str(web_session_id, web_session_id_length); |
| + scoped_ptr<media::KeyIdsPromise> promise(new media::KeyIdsPromise( |
| + base::Bind(&ClearKeyCdm::OnUsableKeyIdsObtained, |
| + base::Unretained(this), |
| + promise_id), |
| + base::Bind( |
| + &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); |
| + decryptor_.GetUsableKeyIds(web_session_str, promise.Pass()); |
| +} |
| + |
| void ClearKeyCdm::TimerExpired(void* context) { |
| if (context == &session_id_for_emulated_loadsession_) { |
| LoadLoadableSession(); |
| @@ -381,7 +411,7 @@ static void CopyDecryptResults( |
| *buffer_copy = buffer; |
| } |
| -cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer_1& encrypted_buffer, |
| +cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer& encrypted_buffer, |
| cdm::DecryptedBlock* decrypted_block) { |
| DVLOG(1) << "Decrypt()"; |
| DCHECK(encrypted_buffer.data); |
| @@ -487,7 +517,7 @@ void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType decoder_type) { |
| } |
| cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( |
| - const cdm::InputBuffer_1& encrypted_buffer, |
| + const cdm::InputBuffer& encrypted_buffer, |
| cdm::VideoFrame* decoded_frame) { |
| DVLOG(1) << "DecryptAndDecodeFrame()"; |
| TRACE_EVENT0("media", "ClearKeyCdm::DecryptAndDecodeFrame"); |
| @@ -511,7 +541,7 @@ cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( |
| } |
| cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( |
| - const cdm::InputBuffer_1& encrypted_buffer, |
| + const cdm::InputBuffer& encrypted_buffer, |
| cdm::AudioFrames* audio_frames) { |
| DVLOG(1) << "DecryptAndDecodeSamples()"; |
| @@ -557,7 +587,7 @@ void ClearKeyCdm::ScheduleNextHeartBeat() { |
| // Prepare the next heartbeat message and set timer. |
| std::ostringstream msg_stream; |
| msg_stream << kHeartBeatHeader << " from ClearKey CDM set at time " |
| - << host_->GetCurrentTime() << "."; |
| + << host_->GetCurrentWallTime() << "."; |
| next_heartbeat_message_ = msg_stream.str(); |
| host_->SetTimer(timer_delay_ms_, &next_heartbeat_message_[0]); |
| @@ -569,7 +599,7 @@ void ClearKeyCdm::ScheduleNextHeartBeat() { |
| } |
| cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer( |
| - const cdm::InputBuffer_1& encrypted_buffer, |
| + const cdm::InputBuffer& encrypted_buffer, |
| scoped_refptr<media::DecoderBuffer>* decrypted_buffer) { |
| DCHECK(decrypted_buffer); |
| scoped_refptr<media::DecoderBuffer> buffer = |
| @@ -687,15 +717,13 @@ void ClearKeyCdm::OnSessionLoaded(uint32 promise_id, |
| void ClearKeyCdm::OnSessionUpdated(uint32 promise_id, |
| const std::string& web_session_id) { |
| - // OnSessionReady() only called as success for UpdateSession(). However, |
| - // UpdateSession() also called to finish loading sessions, so handle |
| + // UpdateSession() may be called to finish loading sessions, so handle |
|
ddorwin
2014/08/08 23:36:25
I wonder what this means. Is itan artifact of the
jrummell
2014/08/11 18:59:04
It's part of simulating LoadSession().
|
| // appropriately. |
| if (web_session_id == session_id_for_emulated_loadsession_) { |
| session_id_for_emulated_loadsession_ = std::string(); |
|
ddorwin
2014/08/08 23:36:25
Separate CL: Do we need session_id_for_emulated_lo
jrummell
2014/08/11 18:59:03
I think this is needed by the simulated LoadSessio
|
| // |promise_id| is the LoadSession() promise, so resolve appropriately. |
| host_->OnResolveNewSessionPromise( |
| promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); |
| - host_->OnSessionReady(kLoadableWebSessionId, strlen(kLoadableWebSessionId)); |
| return; |
| } |
| @@ -707,6 +735,16 @@ void ClearKeyCdm::OnSessionReleased(uint32 promise_id, |
| host_->OnResolvePromise(promise_id); |
| } |
| +void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id, |
| + const KeyIdsVector& key_ids) { |
| + scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]); |
| + for (uint32 i = 0; i < key_ids.size(); ++i) { |
| + result[i].data = key_ids[i].data(); |
| + result[i].length = key_ids[i].size(); |
| + } |
| + host_->OnResolveKeyIdsPromise(promise_id, result.get(), key_ids.size()); |
|
ddorwin
2014/08/08 23:36:25
result.size()
jrummell
2014/08/11 18:59:03
Not done. No operators on scoped_ptr<T[]> return t
|
| +} |
| + |
| void ClearKeyCdm::OnPromiseFailed(uint32 promise_id, |
| MediaKeys::Exception exception_code, |
| uint32 system_code, |