18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef MEDIA_CDM_PPAPI_CDM_HELPERS_H_ 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define MEDIA_CDM_PPAPI_CDM_HELPERS_H_ 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <map> 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <utility> 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h" 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/compiler_specific.h" 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "build/build_config.h" 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/api/content_decryption_module.h" 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/pp_errors.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/pp_stdint.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/dev/buffer_dev.h" 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/instance.h" 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/logging.h" 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace media { 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PpbBufferAllocator; 24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// cdm::Buffer implementation that provides access to memory owned by a 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// pp::Buffer_Dev. 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// This class holds a reference to the Buffer_Dev throughout its lifetime. 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// TODO(xhwang): Find a better name. It's confusing to have PpbBuffer, 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// pp::Buffer_Dev and PPB_Buffer_Dev. 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class PpbBuffer : public cdm::Buffer { 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch static PpbBuffer* Create(const pp::Buffer_Dev& buffer, uint32_t buffer_id, 33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PpbBufferAllocator* allocator); 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // cdm::Buffer implementation. 36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void Destroy() OVERRIDE; 37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual uint32_t Capacity() const OVERRIDE; 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual uint8_t* Data() OVERRIDE; 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void SetSize(uint32_t size) OVERRIDE; 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual uint32_t Size() const OVERRIDE { return size_; } 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Takes the |buffer_| from this class and returns it. 43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Note: The caller must ensure |allocator->Release()| is called later so that 44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // the buffer can be reused by the allocator. 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Since pp::Buffer_Dev is ref-counted, the caller now holds one reference to 46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // the buffer and this class holds no reference. Note that other references 47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // may still exist. For example, PpbBufferAllocator always holds a reference 48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // to all allocated buffers. 49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch pp::Buffer_Dev TakeBuffer(); 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t buffer_id() const { return buffer_id_; } 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PpbBuffer(pp::Buffer_Dev buffer, 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch uint32_t buffer_id, 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PpbBufferAllocator* allocator); 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ~PpbBuffer(); 588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Buffer_Dev buffer_; 608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t buffer_id_; 611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t size_; 62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PpbBufferAllocator* allocator_; 638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(PpbBuffer); 658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class PpbBufferAllocator { 688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) explicit PpbBufferAllocator(pp::Instance* instance) 708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : instance_(instance), 718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) next_buffer_id_(1) {} 728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ~PpbBufferAllocator() {} 738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) cdm::Buffer* Allocate(uint32_t capacity); 758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Releases the buffer with |buffer_id|. A buffer can be recycled after 778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // it is released. 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void Release(uint32_t buffer_id); 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) typedef std::map<uint32_t, pp::Buffer_Dev> AllocatedBufferMap; 821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) typedef std::multimap<uint32_t, std::pair<uint32_t, pp::Buffer_Dev> > 838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) FreeBufferMap; 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) pp::Buffer_Dev AllocateNewBuffer(uint32_t capacity); 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Instance* const instance_; 888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t next_buffer_id_; 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) AllocatedBufferMap allocated_buffers_; 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) FreeBufferMap free_buffers_; 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(PpbBufferAllocator); 938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class DecryptedBlockImpl : public cdm::DecryptedBlock { 968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DecryptedBlockImpl() : buffer_(NULL), timestamp_(0) {} 988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~DecryptedBlockImpl() { if (buffer_) buffer_->Destroy(); } 998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetDecryptedBuffer(cdm::Buffer* buffer) OVERRIDE { 1018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) buffer_ = static_cast<PpbBuffer*>(buffer); 1028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Buffer* DecryptedBuffer() OVERRIDE { return buffer_; } 1048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetTimestamp(int64_t timestamp) OVERRIDE { 1068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) timestamp_ = timestamp; 1078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual int64_t Timestamp() const OVERRIDE { return timestamp_; } 1098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PpbBuffer* buffer_; 1128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) int64_t timestamp_; 1138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); 1158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class VideoFrameImpl : public cdm::VideoFrame { 1188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) VideoFrameImpl(); 1208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~VideoFrameImpl(); 1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetFormat(cdm::VideoFormat format) OVERRIDE { 1238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) format_ = format; 1248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::VideoFormat Format() const OVERRIDE { return format_; } 1268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetSize(cdm::Size size) OVERRIDE { size_ = size; } 1288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Size Size() const OVERRIDE { return size_; } 1298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetFrameBuffer(cdm::Buffer* frame_buffer) OVERRIDE { 1318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) frame_buffer_ = static_cast<PpbBuffer*>(frame_buffer); 1328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Buffer* FrameBuffer() OVERRIDE { return frame_buffer_; } 1348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, 1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t offset) OVERRIDE { 1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) PP_DCHECK(plane < kMaxPlanes); 1388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) plane_offsets_[plane] = offset; 1398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual uint32_t PlaneOffset(VideoPlane plane) OVERRIDE { 1411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) PP_DCHECK(plane < kMaxPlanes); 1428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return plane_offsets_[plane]; 1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void SetStride(VideoPlane plane, uint32_t stride) OVERRIDE { 1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) PP_DCHECK(plane < kMaxPlanes); 1478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) strides_[plane] = stride; 1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual uint32_t Stride(VideoPlane plane) OVERRIDE { 1501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) PP_DCHECK(plane < kMaxPlanes); 1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return strides_[plane]; 1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetTimestamp(int64_t timestamp) OVERRIDE { 1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) timestamp_ = timestamp; 1568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual int64_t Timestamp() const OVERRIDE { return timestamp_; } 1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // The video buffer format. 1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::VideoFormat format_; 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Width and height of the video frame. 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::Size size_; 1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // The video frame buffer. 1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PpbBuffer* frame_buffer_; 1688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Array of data pointers to each plane in the video frame buffer. 1701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t plane_offsets_[kMaxPlanes]; 1718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Array of strides for each plane, typically greater or equal to the width 1738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // of the surface divided by the horizontal sampling period. Note that 1748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // strides can be negative. 1751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t strides_[kMaxPlanes]; 1768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Presentation timestamp in microseconds. 1788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) int64_t timestamp_; 1798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); 1818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 183c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass AudioFramesImpl : public cdm::AudioFrames_2 { 1848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) AudioFramesImpl() : buffer_(NULL), format_(cdm::kUnknownAudioFormat) {} 1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~AudioFramesImpl() { 1878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (buffer_) 1888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) buffer_->Destroy(); 1898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // AudioFrames implementation. 1928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetFrameBuffer(cdm::Buffer* buffer) OVERRIDE { 1938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) buffer_ = static_cast<PpbBuffer*>(buffer); 1948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Buffer* FrameBuffer() OVERRIDE { 1968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return buffer_; 1978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetFormat(cdm::AudioFormat format) OVERRIDE { 1998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) format_ = format; 2008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::AudioFormat Format() const OVERRIDE { 2028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return format_; 2038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::Buffer* PassFrameBuffer() { 2068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PpbBuffer* temp_buffer = buffer_; 2078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) buffer_ = NULL; 2088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return temp_buffer; 2098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 2128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PpbBuffer* buffer_; 2138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::AudioFormat format_; 2148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); 2168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 2178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace media 2198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif // MEDIA_CDM_PPAPI_CDM_HELPERS_H_ 221