1/*
2 * Copyright (C) 2011 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 ************************************************************************
18 * @file         M4SYS_AccessUnit.h
19 * @brief        Access unit manipulation
20 * @note         This file defines the access unit structure,
21 *               and declares functions to manipulate it.
22 ************************************************************************
23*/
24
25#ifndef M4SYS_ACCESSUNIT_H
26#define M4SYS_ACCESSUNIT_H
27
28#include "M4OSA_Types.h"
29#include "M4OSA_Error.h"
30#include "M4OSA_Memory.h"
31#include "M4OSA_Time.h"
32#include "M4SYS_Stream.h"
33
34/** The attribute of a fragment*/
35typedef enum {
36  M4SYS_kFragAttrOk        = 01, /**< The fragment is correct, there is no error
37                                         (size cannot be 0)*/
38  M4SYS_kFragAttrCorrupted = 02, /**< The fragment is corrupted (there is at least a bit or byte
39                                        error somewhere in the fragment (size cannot be 0)*/
40  M4SYS_kFragAttrLost      = 03  /**< The fragment is lost, so the size must be 0.*/
41} M4SYS_FragAttr;
42
43
44/** A Fragment is a piece of access unit. It can be decoded without decoding the others*/
45typedef struct {
46  M4OSA_MemAddr8  fragAddress;   /**< The data pointer. All fragments of the same access unit
47                                        must be contiguous in memory*/
48  M4OSA_UInt32    size;          /**< The size of the fragment. It must be 0 if fragment is
49                                        flagged 'lost'*/
50  M4SYS_FragAttr  isCorrupted;   /**< The attribute of this fragment*/
51} M4SYS_Frag;
52
53/**< The attribute of an access unit*/
54typedef M4OSA_UInt8 M4SYS_AU_Attr;
55
56#define AU_Corrupted   0x01 /**< At least one fragment of the access unit is flagged corrupted.*/
57#define AU_P_Frame     0x02 /**< The access unit is a P_frame*/
58#define AU_RAP         0x04 /**< The access unit is a random access point.*/
59
60
61/** An access unit is the smallest piece of data with timing information.*/
62typedef struct {
63  M4SYS_StreamDescription*    stream ;
64  M4OSA_MemAddr32             dataAddress; /**< The data pointer. The size of this block
65                                            (allocated size) must be a 32-bits integer multiple*/
66  M4OSA_UInt32                size;        /**< The size in bytes of the dataAddress. The size may
67                                                 not match a 32-bits word boundary.*/
68  M4OSA_Time                  CTS;         /**< The Composition Time Stamp*/
69  M4OSA_Time                  DTS;         /**< The Decoded Time Stamp*/
70  M4SYS_AU_Attr               attribute;   /**< The attribute of the access unit*/
71  M4OSA_UInt8                 nbFrag;      /**< The number of fragments. It can be 0 if there is
72                                                no fragment.*/
73  M4SYS_Frag**                frag;        /**< An array of 'nbFrag' fragments. It stores the
74                                                fragments structure. The original definition
75                                              < of frag has been changed from M4SYS_Frag* frag[]
76                                                to M4SYS_Frag** frag since the support
77                                              < of such syntax is only a Microsoft extension of
78                                                the C compiler. */
79} M4SYS_AccessUnit;
80
81/* Error codes */
82#define M4ERR_AU_NO_MORE_FRAG      M4OSA_ERR_CREATE(M4_ERR,M4SYS_CMAPI,0x000001)
83#define M4ERR_AU_BUFFER_OVERFLOW   M4OSA_ERR_CREATE(M4_ERR,M4SYS_CMAPI,0x000002)
84#define M4ERR_AU_BAD_INDEX         M4OSA_ERR_CREATE(M4_ERR,M4SYS_CMAPI,0x000003)
85#define M4ERR_NOT_ENOUGH_FRAG      M4OSA_ERR_CREATE(M4_ERR,M4SYS_CMAPI,0x000004)
86
87
88
89#endif /*M4SYS_ACCESSUNIT_H*/
90
91