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 /*********************************************************************************/
     19 /*     -------------------------------------------------------------------       */
     20 /*                         MPEG-4 SampleToChunkAtom Class                        */
     21 /*     -------------------------------------------------------------------       */
     22 /*********************************************************************************/
     23 /*
     24     This SampleSizeAtom Class contains the sample count and a table giving the
     25     size of each sample.
     26 */
     27 
     28 
     29 #ifndef SAMPLETOCHUNKATOM_H_INCLUDED
     30 #define SAMPLETOCHUNKATOM_H_INCLUDED
     31 
     32 #define PV_ERROR -1
     33 
     34 #ifndef OSCL_FILE_IO_H_INCLUDED
     35 #include "oscl_file_io.h"
     36 #endif
     37 
     38 #ifndef FULLATOM_H_INCLUDED
     39 #include "fullatom.h"
     40 #endif
     41 
     42 class SampleToChunkAtom : public FullAtom
     43 {
     44 
     45     public:
     46         SampleToChunkAtom(MP4_FF_FILE *fp, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode);
     47         virtual ~SampleToChunkAtom();
     48 
     49         // Member gets and sets
     50         uint32 getEntryCount() const
     51         {
     52             return _entryCount;
     53         }
     54 
     55         uint32 getNextChunkNumber()
     56         {
     57             return _currentChunkNumber++;
     58         }
     59 
     60         int32 getFirstChunkAt(uint32 index);
     61         int32 getSamplesPerChunkAt(uint32 index) ;
     62 
     63         uint32 getSDIndex() const;
     64         // Returns the chunk number for the given sample number
     65         uint32 getChunkNumberForSample(uint32 sampleNum);
     66         uint32 getChunkNumberForSampleGet(uint32 sampleNum);
     67 
     68         // Returns the number of the first sample in chunk number 'chunk'
     69         uint32 getFirstSampleNumInChunk(uint32 chunkNum) ;
     70         uint32 getFirstSampleNumInChunkPeek() const;
     71 
     72         int32 getMaxNumSamlplesPerChunk()
     73         {
     74             return _maxNumSamplesPerChunk;
     75         }
     76         void setMaxNumSamlplesPerChunk(int32 max)
     77         {
     78             _maxNumSamplesPerChunk = max;
     79         }
     80         int32 getMaxChunkDataSize()
     81         {
     82             return _maxChunkDataSize;
     83         }
     84         void setMaxChunkDataSize(int32 max)
     85         {
     86             _maxChunkDataSize = max;
     87         }
     88 
     89         uint32 getNumChunksInRunofChunks(uint32 chunk) ;
     90         uint32 getSamplesPerChunkCorrespondingToSample(uint32 sampleNum) ;
     91         uint32 getSamplesPerChunkCorrespondingToSampleGet() const;
     92         int32 resetStateVariables();
     93         int32 resetStateVariables(uint32 sampleNum);
     94         uint32 getFirstSampleNumInChunkGet() const;
     95         uint32 getChunkNumberForSamplePeek(uint32 sampleNum);
     96         uint32 getNumChunksInRunofChunksGet() const;
     97         uint32 getSDIndexPeek() const;
     98         uint32 getSDIndexGet() const;
     99         int32 resetPeekwithGet();
    100         uint32 getCurrPeekSampleCount()
    101         {
    102             return _currPeekSampleCount;
    103         }
    104 
    105     private:
    106 
    107         bool ParseEntryUnit(uint32 sample_cnt);
    108         void CheckAndParseEntry(uint32 i);
    109         uint32 _entryCount;
    110         uint32 *_pfirstChunkVec;
    111         uint32 *_psamplesPerChunkVec;
    112         uint32 *_psampleDescriptionIndexVec;
    113 
    114         int32 _mediaType;
    115 
    116         uint32 _currentChunkNumSamples;
    117         uint32 _currentChunkDataSize; // Ad up all sample sizes for the current chunk
    118         uint32 _currentChunkNumber;
    119 
    120         int32 _maxNumSamplesPerChunk;
    121         int32 _maxChunkDataSize;
    122 
    123         uint32 _Index;
    124 
    125         int32 _numChunksInRun;
    126         int32 _majorGetIndex;
    127         int32 _currGetChunk;
    128         int32 _numGetChunksInRun;
    129         uint32 _currGetSampleCount;
    130         int32 _firstGetSampleInCurrChunk;
    131         int32 _numGetSamplesPerChunk;
    132         int32 _currGetSDI;
    133 
    134         int32 _majorPeekIndex;
    135         int32 _currPeekChunk;
    136         int32 _numPeekChunksInRun;
    137         uint32 _currPeekSampleCount;
    138         int32 _firstPeekSampleInCurrChunk;
    139         int32 _numPeekSamplesPerChunk;
    140         int32 _currPeekSDI;
    141         PVLogger *iLogger, *iStateVarLogger, *iParsedDataLogger;
    142         uint32 _parsing_mode;
    143 
    144         MP4_FF_FILE *_fileptr;
    145         uint32  _parsed_entry_cnt;
    146         MP4_FF_FILE *_curr_fptr;
    147         uint32 *_stbl_fptr_vec;
    148         uint32 _stbl_buff_size;
    149         uint32 _curr_entry_point;
    150         uint32 _curr_buff_number;
    151         uint32 _next_buff_number;
    152 
    153 
    154 
    155 };
    156 
    157 
    158 #endif // SAMPLETOCHUNKATOM_H_INCLUDED
    159 
    160