Home | History | Annotate | Download | only in include
      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 #ifndef __InterleaveBuffer_H__
     19 #define __InterleaveBuffer_H__
     20 
     21 #include "atom.h"
     22 #include "a_atomdefs.h"
     23 #include "atomutils.h"
     24 
     25 #include "oscl_byte_order.h"
     26 #include "oscl_bin_stream.h"
     27 #ifndef OSCL_MEM_H_INCLUDED
     28 #include "oscl_mem.h"
     29 #endif
     30 
     31 class PVA_FF_InterLeaveBuffer
     32 {
     33 
     34     public:
     35 
     36         PVA_FF_InterLeaveBuffer(uint32 mediaType, uint32 codecType, uint32 trackId);
     37 
     38         virtual ~PVA_FF_InterLeaveBuffer();
     39 
     40         bool    addSampleToInterLeaveBuffer(Oscl_Vector < OsclMemoryFragment,
     41                                             OsclMemAllocator > & fragmentList,
     42                                             uint32 size, uint32 ts, uint8 flags, int32 index);
     43 
     44         bool    checkInterLeaveBufferSpace(uint32 size);
     45 
     46         Oscl_Vector<uint32, OsclMemAllocator>* getTimeStampVec();
     47         Oscl_Vector<uint32, OsclMemAllocator>* getSampleSizeVec();
     48         Oscl_Vector<uint8, OsclMemAllocator>* getFlagsVec();
     49         Oscl_Vector<int32, OsclMemAllocator>* getTextIndexVec();
     50 
     51         uint8*  resetInterLeaveBuffer(uint32 &chunkSize);
     52         uint32  getCurrentInterLeaveBufferSize();
     53 
     54         uint32  getLastChunkEndTime();
     55         void    setLastChunkEndTime();
     56         void    setLastChunkEndTime(uint32 time);
     57         uint32  getTrackID();
     58         uint32  getFirstTSEntry();
     59         uint32  getLastSampleTS();
     60 
     61     private:
     62 
     63         uint32  _trackId;
     64         uint32  _mediaType;
     65         uint32  _codecType;
     66         uint32  _lastChunkEndTime;      // use to calculate present trun duration from sample time stamp
     67         uint8*  _interLeaveBuffer;      // samples copied to buffer before written to file
     68         uint32  _maxInterLeaveBufferSize;   // max size if interleave buffer ( codec dependent)
     69         uint32  _currInterLeaveBufferSize;  // current occupancy in interleave buffer
     70         uint32  _lastInterLeaveBufferTS;    // Time stamp of last interleave buffer
     71         // to calculate duration of interleave buffer
     72         uint32  _lastSampleTS;
     73 
     74 
     75 
     76         // Sample parameters are stored in these vectors before writing to TRUN when
     77         // interleave duration is reached
     78         Oscl_Vector<uint32, OsclMemAllocator>* _pTimeStampVec;
     79         Oscl_Vector<uint32, OsclMemAllocator>* _pSampleSizeVec;
     80         Oscl_Vector<uint8, OsclMemAllocator>* _pSampleFlagsVec;
     81         Oscl_Vector<int32, OsclMemAllocator>* _pIndexVec;
     82 
     83 };
     84 
     85 #endif
     86