Index: media/cdm/ppapi/cdm_wrapper.cc |
diff --git a/media/cdm/ppapi/cdm_wrapper.cc b/media/cdm/ppapi/cdm_wrapper.cc |
index 6d8a7885f76082093b292e8ddb368b380eb653cc..9b3e06e7431f07d10ccc3c368aa51c4cc510aeb9 100644 |
--- a/media/cdm/ppapi/cdm_wrapper.cc |
+++ b/media/cdm/ppapi/cdm_wrapper.cc |
@@ -75,8 +75,7 @@ void ConfigureInputBuffer( |
input_buffer->data = static_cast<uint8_t*>(encrypted_buffer.data()); |
input_buffer->data_size = encrypted_block_info.data_size; |
- PP_DCHECK(encrypted_buffer.size() >= |
- static_cast<uint32_t>(input_buffer->data_size)); |
+ PP_DCHECK(encrypted_buffer.size() >= input_buffer->data_size); |
input_buffer->data_offset = encrypted_block_info.data_offset; |
PP_DCHECK(encrypted_block_info.key_id_size <= |
@@ -230,16 +229,15 @@ class PpbBuffer : public cdm::Buffer { |
// cdm::Buffer implementation. |
virtual void Destroy() OVERRIDE { delete this; } |
- virtual int32_t Capacity() const OVERRIDE { return buffer_.size(); } |
+ virtual uint32_t Capacity() const OVERRIDE { return buffer_.size(); } |
virtual uint8_t* Data() OVERRIDE { |
return static_cast<uint8_t*>(buffer_.data()); |
} |
- virtual void SetSize(int32_t size) OVERRIDE { |
- PP_DCHECK(size >= 0); |
+ virtual void SetSize(uint32_t size) OVERRIDE { |
PP_DCHECK(size < Capacity()); |
- if (size < 0 || size > Capacity()) { |
+ if (size > Capacity()) { |
size_ = 0; |
return; |
} |
@@ -247,7 +245,7 @@ class PpbBuffer : public cdm::Buffer { |
size_ = size; |
} |
- virtual int32_t Size() const OVERRIDE { return size_; } |
+ virtual uint32_t Size() const OVERRIDE { return size_; } |
pp::Buffer_Dev buffer_dev() const { return buffer_; } |
@@ -262,7 +260,7 @@ class PpbBuffer : public cdm::Buffer { |
pp::Buffer_Dev buffer_; |
uint32_t buffer_id_; |
- int32_t size_; |
+ uint32_t size_; |
DISALLOW_COPY_AND_ASSIGN(PpbBuffer); |
}; |
@@ -274,7 +272,7 @@ class PpbBufferAllocator { |
next_buffer_id_(1) {} |
~PpbBufferAllocator() {} |
- cdm::Buffer* Allocate(int32_t capacity); |
+ cdm::Buffer* Allocate(uint32_t capacity); |
// Releases the buffer with |buffer_id|. A buffer can be recycled after |
// it is released. |
@@ -282,17 +280,17 @@ class PpbBufferAllocator { |
private: |
typedef std::map<uint32_t, pp::Buffer_Dev> AllocatedBufferMap; |
- typedef std::multimap<int, std::pair<uint32_t, pp::Buffer_Dev> > |
+ typedef std::multimap<uint32_t, std::pair<uint32_t, pp::Buffer_Dev> > |
FreeBufferMap; |
// Always pad new allocated buffer so that we don't need to reallocate |
// buffers frequently if requested sizes fluctuate slightly. |
- static const int kBufferPadding = 512; |
+ static const uint32_t kBufferPadding = 512; |
// Maximum number of free buffers we can keep when allocating new buffers. |
- static const int kFreeLimit = 3; |
+ static const uint32_t kFreeLimit = 3; |
- pp::Buffer_Dev AllocateNewBuffer(int capacity); |
+ pp::Buffer_Dev AllocateNewBuffer(uint32_t capacity); |
pp::Instance* const instance_; |
uint32_t next_buffer_id_; |
@@ -302,10 +300,10 @@ class PpbBufferAllocator { |
DISALLOW_COPY_AND_ASSIGN(PpbBufferAllocator); |
}; |
-cdm::Buffer* PpbBufferAllocator::Allocate(int32_t capacity) { |
+cdm::Buffer* PpbBufferAllocator::Allocate(uint32_t capacity) { |
PP_DCHECK(IsMainThread()); |
- if (capacity <= 0) |
+ if (!capacity) |
return NULL; |
pp::Buffer_Dev buffer; |
@@ -346,12 +344,12 @@ void PpbBufferAllocator::Release(uint32_t buffer_id) { |
allocated_buffers_.erase(found); |
} |
-pp::Buffer_Dev PpbBufferAllocator::AllocateNewBuffer(int32_t capacity) { |
+pp::Buffer_Dev PpbBufferAllocator::AllocateNewBuffer(uint32_t capacity) { |
// Destroy the smallest buffer before allocating a new bigger buffer if the |
// number of free buffers exceeds a limit. This mechanism helps avoid ending |
// up with too many small buffers, which could happen if the size to be |
// allocated keeps increasing. |
- if (free_buffers_.size() >= static_cast<uint32_t>(kFreeLimit)) |
+ if (free_buffers_.size() >= kFreeLimit) |
free_buffers_.erase(free_buffers_.begin()); |
// Creation of pp::Buffer_Dev is expensive! It involves synchronous IPC calls. |
@@ -400,22 +398,21 @@ class VideoFrameImpl : public cdm::VideoFrame { |
virtual cdm::Buffer* FrameBuffer() OVERRIDE { return frame_buffer_; } |
virtual void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, |
- int32_t offset) OVERRIDE { |
- PP_DCHECK(0 <= plane && plane < kMaxPlanes); |
- PP_DCHECK(offset >= 0); |
+ uint32_t offset) OVERRIDE { |
+ PP_DCHECK(plane < kMaxPlanes); |
plane_offsets_[plane] = offset; |
} |
- virtual int32_t PlaneOffset(VideoPlane plane) OVERRIDE { |
- PP_DCHECK(0 <= plane && plane < kMaxPlanes); |
+ virtual uint32_t PlaneOffset(VideoPlane plane) OVERRIDE { |
+ PP_DCHECK(plane < kMaxPlanes); |
return plane_offsets_[plane]; |
} |
- virtual void SetStride(VideoPlane plane, int32_t stride) OVERRIDE { |
- PP_DCHECK(0 <= plane && plane < kMaxPlanes); |
+ virtual void SetStride(VideoPlane plane, uint32_t stride) OVERRIDE { |
+ PP_DCHECK(plane < kMaxPlanes); |
strides_[plane] = stride; |
} |
- virtual int32_t Stride(VideoPlane plane) OVERRIDE { |
- PP_DCHECK(0 <= plane && plane < kMaxPlanes); |
+ virtual uint32_t Stride(VideoPlane plane) OVERRIDE { |
+ PP_DCHECK(plane < kMaxPlanes); |
return strides_[plane]; |
} |
@@ -435,12 +432,12 @@ class VideoFrameImpl : public cdm::VideoFrame { |
PpbBuffer* frame_buffer_; |
// Array of data pointers to each plane in the video frame buffer. |
- int32_t plane_offsets_[kMaxPlanes]; |
+ uint32_t plane_offsets_[kMaxPlanes]; |
// Array of strides for each plane, typically greater or equal to the width |
// of the surface divided by the horizontal sampling period. Note that |
// strides can be negative. |
- int32_t strides_[kMaxPlanes]; |
+ uint32_t strides_[kMaxPlanes]; |
// Presentation timestamp in microseconds. |
int64_t timestamp_; |
@@ -452,7 +449,7 @@ VideoFrameImpl::VideoFrameImpl() |
: format_(cdm::kUnknownVideoFormat), |
frame_buffer_(NULL), |
timestamp_(0) { |
- for (int32_t i = 0; i < kMaxPlanes; ++i) { |
+ for (uint32_t i = 0; i < kMaxPlanes; ++i) { |
plane_offsets_[i] = 0; |
strides_[i] = 0; |
} |
@@ -541,15 +538,15 @@ class CdmWrapper : public pp::Instance, |
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
// cdm::Host_1 implementation. |
- virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE; |
+ virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; |
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; |
virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
virtual void SendKeyMessage( |
- const char* session_id, int32_t session_id_length, |
- const char* message, int32_t message_length, |
- const char* default_url, int32_t default_url_length) OVERRIDE; |
+ const char* session_id, uint32_t session_id_length, |
+ const char* message, uint32_t message_length, |
+ const char* default_url, uint32_t default_url_length) OVERRIDE; |
virtual void SendKeyError(const char* session_id, |
- int32_t session_id_length, |
+ uint32_t session_id_length, |
cdm::MediaKeyError error_code, |
uint32_t system_code) OVERRIDE; |
virtual void GetPrivateData(int32_t* instance, |
@@ -558,8 +555,8 @@ class CdmWrapper : public pp::Instance, |
// cdm::Host_2 implementation. |
virtual bool CanChallengePlatform() OVERRIDE; |
virtual void SendPlatformChallenge( |
- const char* service_id, int32_t service_id_length, |
- const char* challenge, int32_t challenge_length) OVERRIDE; |
+ const char* service_id, uint32_t service_id_length, |
+ const char* challenge, uint32_t challenge_length) OVERRIDE; |
virtual void EnableOutputProtection( |
uint32_t desired_protection_mask) OVERRIDE; |
virtual void QueryOutputProtectionStatus() OVERRIDE; |
@@ -756,12 +753,12 @@ void CdmWrapper::AddKey(const std::string& session_id, |
} |
const uint8_t* key_ptr = static_cast<const uint8_t*>(key.Map()); |
- int key_size = key.ByteLength(); |
+ uint32_t key_size = key.ByteLength(); |
const uint8_t* init_data_ptr = static_cast<const uint8_t*>(init_data.Map()); |
- int init_data_size = init_data.ByteLength(); |
+ uint32_t init_data_size = init_data.ByteLength(); |
PP_DCHECK(!init_data_ptr == !init_data_size); |
- if (!key_ptr || key_size <= 0) { |
+ if (!key_ptr || !key_size) { |
SendUnknownKeyError(key_system_, session_id); |
return; |
} |
@@ -839,8 +836,7 @@ void CdmWrapper::InitializeAudioDecoder( |
cdm_decoder_config.samples_per_second = decoder_config.samples_per_second; |
cdm_decoder_config.extra_data = |
static_cast<uint8_t*>(extra_data_buffer.data()); |
- cdm_decoder_config.extra_data_size = |
- static_cast<int32_t>(extra_data_buffer.size()); |
+ cdm_decoder_config.extra_data_size = extra_data_buffer.size(); |
status = cdm_->InitializeAudioDecoder(cdm_decoder_config); |
} |
@@ -869,8 +865,7 @@ void CdmWrapper::InitializeVideoDecoder( |
cdm_decoder_config.coded_size.height = decoder_config.height; |
cdm_decoder_config.extra_data = |
static_cast<uint8_t*>(extra_data_buffer.data()); |
- cdm_decoder_config.extra_data_size = |
- static_cast<int32_t>(extra_data_buffer.size()); |
+ cdm_decoder_config.extra_data_size = extra_data_buffer.size(); |
status = cdm_->InitializeVideoDecoder(cdm_decoder_config); |
} |
@@ -959,7 +954,7 @@ void CdmWrapper::DecryptAndDecode( |
} |
} |
-cdm::Buffer* CdmWrapper::Allocate(int32_t capacity) { |
+cdm::Buffer* CdmWrapper::Allocate(uint32_t capacity) { |
return allocator_.Allocate(capacity); |
} |
@@ -983,9 +978,9 @@ double CdmWrapper::GetCurrentWallTimeInSeconds() { |
} |
void CdmWrapper::SendKeyMessage( |
- const char* session_id, int32_t session_id_length, |
- const char* message, int32_t message_length, |
- const char* default_url, int32_t default_url_length) { |
+ const char* session_id, uint32_t session_id_length, |
+ const char* message, uint32_t message_length, |
+ const char* default_url, uint32_t default_url_length) { |
PP_DCHECK(!key_system_.empty()); |
PostOnMain(callback_factory_.NewCallback( |
&CdmWrapper::KeyMessage, |
@@ -996,7 +991,7 @@ void CdmWrapper::SendKeyMessage( |
} |
void CdmWrapper::SendKeyError(const char* session_id, |
- int32_t session_id_length, |
+ uint32_t session_id_length, |
cdm::MediaKeyError error_code, |
uint32_t system_code) { |
SendKeyErrorInternal(key_system_, |
@@ -1211,7 +1206,7 @@ bool CdmWrapper::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { |
PpbBuffer* ppb_buffer = static_cast<PpbBuffer*>(video_frame->FrameBuffer()); |
- for (int i = 0; i < cdm::VideoFrame::kMaxPlanes; ++i) { |
+ for (uint32_t i = 0; i < cdm::VideoFrame::kMaxPlanes; ++i) { |
int plane_height = (i == cdm::VideoFrame::kYPlane) ? |
video_frame->Size().height : (video_frame->Size().height + 1) / 2; |
cdm::VideoFrame::VideoPlane plane = |
@@ -1234,8 +1229,8 @@ bool CdmWrapper::CanChallengePlatform() { |
} |
void CdmWrapper::SendPlatformChallenge( |
- const char* service_id, int32_t service_id_length, |
- const char* challenge, int32_t challenge_length) { |
+ const char* service_id, uint32_t service_id_length, |
+ const char* challenge, uint32_t challenge_length) { |
#if defined(OS_CHROMEOS) |
PP_DCHECK(!challenge_in_progress_); |
@@ -1323,13 +1318,13 @@ void CdmWrapper::SendPlatformChallengeDone(int32_t result) { |
cdm::PlatformChallengeResponse response = { |
static_cast<uint8_t*>(signed_data_var.Map()), |
- static_cast<int32_t>(signed_data_var.ByteLength()), |
+ signed_data_var.ByteLength(), |
static_cast<uint8_t*>(signed_data_signature_var.Map()), |
- static_cast<int32_t>(signed_data_signature_var.ByteLength()), |
+ signed_data_signature_var.ByteLength(), |
reinterpret_cast<const uint8_t*>(platform_key_certificate_string.c_str()), |
- static_cast<int32_t>(platform_key_certificate_string.length()) |
+ static_cast<uint32_t>(platform_key_certificate_string.length()) |
}; |
cdm_->OnPlatformChallengeResponse(response); |