1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /*********************************************************************************/ 19 /* ------------------------------------------------------------------- */ 20 /* MPEG-4 Util: MediaBuffer */ 21 /* ------------------------------------------------------------------- */ 22 /*********************************************************************************/ 23 /* 24 This MediaBuffer Class is the implementation of the IMediaBuffer interface 25 that contains the guts of the data handling of media data. 26 */ 27 28 29 #define IMPLEMENT_MediaBuffer 30 31 #include "mediabuffer.h" 32 #include "atomutils.h" 33 34 35 // Constructor MediaBuffer(int32 size)36MediaBuffer::MediaBuffer(int32 size) 37 { 38 _owner = NULL; 39 _pdata = (uint8 *) oscl_malloc(size); // Allocate buffer space 40 } 41 42 // Destructor ~MediaBuffer()43MediaBuffer::~MediaBuffer() 44 { 45 oscl_free(_pdata); 46 } 47 48 void freeBuf()49MediaBuffer::freeBuf() 50 { 51 if (_owner != NULL) 52 { 53 _owner->freeBuf(this); 54 } 55 } 56 57 void setOwner(MediaBufferManager * owner)58MediaBuffer::setOwner(MediaBufferManager *owner) 59 { 60 _owner = owner; 61 } 62 63 void readByteData(MP4_FF_FILE * fp,uint32 size)64MediaBuffer::readByteData(MP4_FF_FILE *fp, uint32 size) 65 { 66 AtomUtils::readByteData(fp, size, _pdata); 67 _size = size; 68 } 69