Home | History | Annotate | Download | only in hardware
      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 #ifndef METADATA_BUFFER_TYPE_H
     18 #define METADATA_BUFFER_TYPE_H
     19 
     20 #ifdef __cplusplus
     21 extern "C" {
     22 namespace android {
     23 #endif
     24 
     25 /*
     26  * MetadataBufferType defines the type of the metadata buffers that
     27  * can be passed to video encoder component for encoding, via Stagefright
     28  * media recording framework. To see how to work with the metadata buffers
     29  * in media recording framework, please consult HardwareAPI.h
     30  *
     31  * The creator of metadata buffers and video encoder share common knowledge
     32  * on what is actually being stored in these metadata buffers, and
     33  * how the information can be used by the video encoder component
     34  * to locate the actual pixel data as the source input for video
     35  * encoder, plus whatever other information that is necessary. Stagefright
     36  * media recording framework does not need to know anything specific about the
     37  * metadata buffers, except for receving each individual metadata buffer
     38  * as the source input, making a copy of the metadata buffer, and passing the
     39  * copy via OpenMAX API to the video encoder component.
     40  *
     41  * The creator of the metadata buffers must ensure that the first
     42  * 4 bytes in every metadata buffer indicates its buffer type,
     43  * and the rest of the metadata buffer contains the
     44  * actual metadata information. When a video encoder component receives
     45  * a metadata buffer, it uses the first 4 bytes in that buffer to find
     46  * out the type of the metadata buffer, and takes action appropriate
     47  * to that type of metadata buffers (for instance, locate the actual
     48  * pixel data input and then encoding the input data to produce a
     49  * compressed output buffer).
     50  *
     51  * The following shows the layout of a metadata buffer,
     52  * where buffer type is a 4-byte field of MetadataBufferType,
     53  * and the payload is the metadata information.
     54  *
     55  * --------------------------------------------------------------
     56  * |  buffer type  |          payload                           |
     57  * --------------------------------------------------------------
     58  *
     59  */
     60 typedef enum {
     61 
     62     /*
     63      * kMetadataBufferTypeCameraSource is used to indicate that
     64      * the source of the metadata buffer is the camera component.
     65      */
     66     kMetadataBufferTypeCameraSource  = 0,
     67 
     68     /*
     69      * kMetadataBufferTypeGrallocSource is used to indicate that
     70      * the payload of the metadata buffers can be interpreted as
     71      * a buffer_handle_t.
     72      * So in this case,the metadata that the encoder receives
     73      * will have a byte stream that consists of two parts:
     74      * 1. First, there is an integer indicating that it is a GRAlloc
     75      * source (kMetadataBufferTypeGrallocSource)
     76      * 2. This is followed by the buffer_handle_t that is a handle to the
     77      * GRalloc buffer. The encoder needs to interpret this GRalloc handle
     78      * and encode the frames.
     79      * --------------------------------------------------------------
     80      * |  kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) |
     81      * --------------------------------------------------------------
     82      */
     83     kMetadataBufferTypeGrallocSource = 1,
     84 
     85     /*
     86      * kMetadataBufferTypeGraphicBuffer is used to indicate that
     87      * the payload of the metadata buffers can be interpreted as
     88      * a GraphicBuffer.  It is only to be used by software encoders.
     89      * In this case, the metadata that the encoder receives
     90      * will have a byte stream that consists of two parts:
     91      * 1. First, there is an integer indicating that the metadata
     92      * contains a GraphicBuffer (kMetadataBufferTypeGraphicBuffer)
     93      * 2. This is followed by the pointer to the GraphicBuffer that
     94      * is to be encoded.  Encoder must not create a sp<> from this
     95      * graphic buffer, or free it, as it does not actually own this
     96      * buffer.
     97      * --------------------------------------------------------------
     98      * |  kMetadataBufferTypeGraphicBuffer | sizeof(GraphicBuffer *) |
     99      * --------------------------------------------------------------
    100      */
    101     kMetadataBufferTypeGraphicBuffer = 2,
    102 
    103     // Add more here...
    104 
    105 } MetadataBufferType;
    106 
    107 #ifdef __cplusplus
    108 }  // namespace android
    109 }
    110 #endif
    111 
    112 #endif  // METADATA_BUFFER_TYPE_H
    113