camera/QCamera2/HAL/QCameraPostProc.cpp
/*===========================================================================
 * FUNCTION   : queryStreams
 *
 * DESCRIPTION: utility method for retrieving main, thumbnail and reprocess
 *              streams and frame from bundled super buffer
 *
 * PARAMETERS :
 *   @main    : ptr to main stream if present
 *   @thumb   : ptr to thumbnail stream if present
 *   @main_image : ptr to main image if present
 *   @thumb_image: ptr to thumbnail image if present
 *   @frame   : bundled super buffer
 *   @reproc_frame : bundled source frame buffer
 *
 * RETURN     : int32_t type of status
 *              NO_ERROR  -- success
 *              none-zero failure code
 *==========================================================================*/
FUNCTION   : queryStreams
DESCRIPTION: utility method for retrieving main, thumbnail and reprocess
streams and frame from bundled super buffer



RETURN     : int32_t type of status
NO_ERROR  -- success
none-zero failure code
FUNCTION : queryStreams DESCRIPTION : utility method for retrieving main thumbnail and reprocess streams and frame from bundled super buffer RETURN : int32_t type of status NO_ERROR -- success none - zero failure code
int32_t QCameraPostProcessor::queryStreams(QCameraStream **main,
        QCameraStream **thumb,
        mm_camera_buf_def_t **main_image,
        mm_camera_buf_def_t **thumb_image,
        mm_camera_super_buf_t *frame,
        mm_camera_super_buf_t *reproc_frame)
{
    if (NULL == frame) {
        return NO_INIT;
    }
    QCameraChannel *pChannel = m_parent->getChannelByHandle(frame->ch_id);
    if (pChannel == NULL) {
        if (m_pReprocChannel != NULL &&
            m_pReprocChannel->getMyHandle() == frame->ch_id) {
            pChannel = m_pReprocChannel;
        } else if (m_pDualReprocChannel != NULL &&
            m_pDualReprocChannel->getMyHandle() == frame->ch_id) {
            pChannel = m_pDualReprocChannel;
        }
    }
    if (pChannel == NULL) {
        CDBG_HIGH("%s: No corresponding channel (ch_id = %d) exist, return here",
              __func__, frame->ch_id);
        return BAD_VALUE;
    }
    *main = *thumb = NULL;
    *main_image = *thumb_image = NULL;
    for (uint32_t i = 0; i < frame->num_bufs; i++) {
        QCameraStream *pStream =
                pChannel->getStreamByHandle(frame->bufs[i]->stream_id);
        if (pStream != NULL) {
            if (pStream->isTypeOf(CAM_STREAM_TYPE_SNAPSHOT) ||
                pStream->isOrignalTypeOf(CAM_STREAM_TYPE_SNAPSHOT) ||
                pStream->isTypeOf(CAM_STREAM_TYPE_VIDEO) ||
                pStream->isOrignalTypeOf(CAM_STREAM_TYPE_VIDEO)) {
                *main= pStream;
                *main_image = frame->bufs[i];
            } else if (pStream->isTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
                       pStream->isTypeOf(CAM_STREAM_TYPE_POSTVIEW) ||
                       pStream->isOrignalTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
                       pStream->isOrignalTypeOf(CAM_STREAM_TYPE_POSTVIEW)) {
                *thumb = pStream;
                *thumb_image = frame->bufs[i];
            }
        }
    }
    if (*thumb_image == NULL && reproc_frame != NULL) {
        QCameraChannel *pSrcReprocChannel = NULL;
        pSrcReprocChannel = m_parent->getChannelByHandle(reproc_frame->ch_id);
        if (pSrcReprocChannel != NULL) {
            for (uint32_t i = 0; i < reproc_frame->num_bufs; i++) {
                QCameraStream *pStream =
                        pSrcReprocChannel->getStreamByHandle(
                                reproc_frame->bufs[i]->stream_id);
                if (pStream != NULL) {
                    if (pStream->isTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
                        pStream->isTypeOf(CAM_STREAM_TYPE_POSTVIEW)) {
                        *thumb = pStream;
                        *thumb_image = reproc_frame->bufs[i];
                    }
                }
            }
        }
    }
    return NO_ERROR;
}
int32_t QCameraPostProcessor :: queryStreams ( QCameraStream * * main , QCameraStream * * thumb , mm_camera_buf_def_t * * main_image , mm_camera_buf_def_t * * thumb_image , mm_camera_super_buf_t * frame , mm_camera_super_buf_t * reproc_frame ) { if ( NULL == frame ) { return NO_INIT ; } QCameraChannel * pChannel = m_parent -> getChannelByHandle ( frame -> ch_id ) ; if ( pChannel == NULL ) { if ( m_pReprocChannel != NULL && m_pReprocChannel -> getMyHandle ( ) == frame -> ch_id ) { pChannel = m_pReprocChannel ; } else if ( m_pDualReprocChannel != NULL && m_pDualReprocChannel -> getMyHandle ( ) == frame -> ch_id ) { pChannel = m_pDualReprocChannel ; } } if ( pChannel == NULL ) { CDBG_HIGH ( " " , __func__ , frame -> ch_id ) ; return BAD_VALUE ; } * main = * thumb = NULL ; * main_image = * thumb_image = NULL ; for ( uint32_t i = 0 ; i < frame -> num_bufs ; i ++ ) { QCameraStream * pStream = pChannel -> getStreamByHandle ( frame -> bufs [ i ] -> stream_id ) ; if ( pStream != NULL ) { if ( pStream -> isTypeOf ( CAM_STREAM_TYPE_SNAPSHOT ) || pStream -> isOrignalTypeOf ( CAM_STREAM_TYPE_SNAPSHOT ) || pStream -> isTypeOf ( CAM_STREAM_TYPE_VIDEO ) || pStream -> isOrignalTypeOf ( CAM_STREAM_TYPE_VIDEO ) ) { * main = pStream ; * main_image = frame -> bufs [ i ] ; } else if ( pStream -> isTypeOf ( CAM_STREAM_TYPE_PREVIEW ) || pStream -> isTypeOf ( CAM_STREAM_TYPE_POSTVIEW ) || pStream -> isOrignalTypeOf ( CAM_STREAM_TYPE_PREVIEW ) || pStream -> isOrignalTypeOf ( CAM_STREAM_TYPE_POSTVIEW ) ) { * thumb = pStream ; * thumb_image = frame -> bufs [ i ] ; } } } if ( * thumb_image == NULL && reproc_frame != NULL ) { QCameraChannel * pSrcReprocChannel = NULL ; pSrcReprocChannel = m_parent -> getChannelByHandle ( reproc_frame -> ch_id ) ; if ( pSrcReprocChannel != NULL ) { for ( uint32_t i = 0 ; i < reproc_frame -> num_bufs ; i ++ ) { QCameraStream * pStream = pSrcReprocChannel -> getStreamByHandle ( reproc_frame -> bufs [ i ] -> stream_id ) ; if ( pStream != NULL ) { if ( pStream -> isTypeOf ( CAM_STREAM_TYPE_PREVIEW ) || pStream -> isTypeOf ( CAM_STREAM_TYPE_POSTVIEW ) ) { * thumb = pStream ; * thumb_image = reproc_frame -> bufs [ i ] ; } } } } } return NO_ERROR ; }
FUNCTION   : queryStreams
 DESCRIPTION: utility method for retrieving main, thumbnail and reprocess
              streams and frame from bundled super buffer
FUNCTION : queryStreams DESCRIPTION : utility method for retrieving main thumbnail and reprocess streams and frame from bundled super buffer
// check reprocess channel if not found // find snapshot frame and thumnail frame // find thumbnail frame