| OLD | NEW |
| 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 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" | 5 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "media/base/decoder_buffer.h" | 12 #include "media/base/decoder_buffer.h" |
| 13 | 13 |
| 14 static const char kClearKeyCdmVersion[] = "0.1.0.0"; | 14 static const char kClearKeyCdmVersion[] = "0.1.0.0"; |
| 15 | 15 |
| 16 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( | 16 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( |
| 17 const cdm::InputBuffer& input_buffer) { | 17 const cdm::InputBuffer& input_buffer) { |
| 18 scoped_refptr<media::DecoderBuffer> output_buffer = | 18 scoped_refptr<media::DecoderBuffer> output_buffer = |
| 19 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size); | 19 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size); |
| 20 | 20 |
| 21 std::vector<media::SubsampleEntry> subsamples; | 21 std::vector<media::SubsampleEntry> subsamples; |
| 22 for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) { | 22 for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) { |
| 23 media::SubsampleEntry subsample; | 23 media::SubsampleEntry subsample; |
| 24 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes; | 24 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes; |
| 25 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes; | 25 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes; |
| 26 subsamples.push_back(subsample); | 26 subsamples.push_back(subsample); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // TODO(xhwang): Update this code when checksum is removed in DecryptConfig. |
| 29 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( | 30 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( |
| 30 std::string(reinterpret_cast<const char*>(input_buffer.key_id), | 31 std::string(reinterpret_cast<const char*>(input_buffer.key_id), |
| 31 input_buffer.key_id_size), | 32 input_buffer.key_id_size), |
| 32 std::string(reinterpret_cast<const char*>(input_buffer.iv), | 33 std::string(reinterpret_cast<const char*>(input_buffer.iv), |
| 33 input_buffer.iv_size), | 34 input_buffer.iv_size), |
| 34 std::string(reinterpret_cast<const char*>(input_buffer.checksum), | 35 std::string(), |
| 35 input_buffer.checksum_size), | |
| 36 input_buffer.data_offset, | 36 input_buffer.data_offset, |
| 37 subsamples)); | 37 subsamples)); |
| 38 | 38 |
| 39 output_buffer->SetDecryptConfig(decrypt_config.Pass()); | 39 output_buffer->SetDecryptConfig(decrypt_config.Pass()); |
| 40 output_buffer->SetTimestamp( | 40 output_buffer->SetTimestamp( |
| 41 base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); | 41 base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); |
| 42 | 42 |
| 43 return output_buffer; | 43 return output_buffer; |
| 44 } | 44 } |
| 45 | 45 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 void ClearKeyCdm::ResetVideoDecoder() { | 232 void ClearKeyCdm::ResetVideoDecoder() { |
| 233 NOTIMPLEMENTED(); | 233 NOTIMPLEMENTED(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void ClearKeyCdm::StopVideoDecoder() { | 236 void ClearKeyCdm::StopVideoDecoder() { |
| 237 NOTIMPLEMENTED(); | 237 NOTIMPLEMENTED(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace webkit_media | 240 } // namespace webkit_media |
| OLD | NEW |