Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      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 express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ESDS_H_
     18 
     19 #define ESDS_H_
     20 
     21 #include <stdint.h>
     22 
     23 #include <media/stagefright/MediaErrors.h>
     24 
     25 namespace android {
     26 
     27 class ESDS {
     28 public:
     29     ESDS(const void *data, size_t size);
     30     ~ESDS();
     31 
     32     status_t InitCheck() const;
     33 
     34     status_t getObjectTypeIndication(uint8_t *objectTypeIndication) const;
     35     status_t getCodecSpecificInfo(const void **data, size_t *size) const;
     36     status_t getCodecSpecificOffset(size_t *offset, size_t *size) const;
     37     status_t getBitRate(uint32_t *brateMax, uint32_t *brateAvg) const;
     38     status_t getStreamType(uint8_t *streamType) const;
     39 
     40 private:
     41     enum {
     42         kTag_ESDescriptor            = 0x03,
     43         kTag_DecoderConfigDescriptor = 0x04,
     44         kTag_DecoderSpecificInfo     = 0x05
     45     };
     46 
     47     uint8_t *mData;
     48     size_t mSize;
     49 
     50     status_t mInitCheck;
     51 
     52     size_t mDecoderSpecificOffset;
     53     size_t mDecoderSpecificLength;
     54     uint8_t mObjectTypeIndication;
     55     uint8_t mStreamType;
     56     uint32_t mBitRateMax;
     57     uint32_t mBitRateAvg;
     58 
     59     status_t skipDescriptorHeader(
     60             size_t offset, size_t size,
     61             uint8_t *tag, size_t *data_offset, size_t *data_size) const;
     62 
     63     status_t parse();
     64     status_t parseESDescriptor(size_t offset, size_t size);
     65     status_t parseDecoderConfigDescriptor(size_t offset, size_t size);
     66 
     67     ESDS(const ESDS &);
     68     ESDS &operator=(const ESDS &);
     69 };
     70 
     71 }  // namespace android
     72 #endif  // ESDS_H_
     73