omx_camera_source_component.c File Reference

#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <OMX_Core.h>
#include <omx_comp_debug_levels.h>
#include "omx_camera_source_component.h"

Go to the source code of this file.

Data Structures

struct  CAM_SENSOR_OMXV4LCOLORTYPE
struct  CAM_CAPTURE_FRAMESIZETYPE

Defines

#define DEFAULT_FRAME_RATE   15
#define DEFAULT_FRAME_WIDTH   320
#define DEFAULT_FRAME_HEIGHT   240
#define DEFAULT_COLOR_FORMAT   OMX_COLOR_FormatYUV420PackedPlanar
#define GET_SYSERR_STRING()   strerror(errno)
#define OMX_CAM_VC_SNAPSHOT_INDEX   5
#define CLEAR(x)   memset (&(x), 0, sizeof (x))
#define OMX_MAPBUFQUEUE_ISEMPTY(_queue_)   (0 == (_queue_).nBufCountTotal)
#define OMX_MAPBUFQUEUE_ISFULL(_queue_)   ((_queue_).nBufCountTotal > 0 && (_queue_).nNextCaptureIndex == (_queue_).nLastBufIndex)
#define OMX_MAPBUFQUEUE_NOBUFCAPTURED(_queue_)   (0 == (_queue_).nBufCountCaptured)
#define OMX_MAPBUFQUEUE_HASBUFCAPTURED(_queue_)   (!(OMX_MAPBUFQUEUE_NOBUFCAPTURED(_queue_)))
#define OMX_MAPBUFQUEUE_NOBUFWAITTOCAPTURE(_queue_)   (OMX_MAPBUFQUEUE_HASBUFCAPTURED(_queue_) && (_queue_).nNextWaitIndex == (_queue_).nNextCaptureIndex)
#define OMX_MAPBUFQUEUE_HASBUFWAITTOCAPTURE(_queue_)   (!(OMX_MAPBUFQUEUE_NOBUFWAITTOCAPTURE(_queue_)))
#define OMX_MAPBUFQUEUE_GETMAXLEN(_queue_)   ((_queue_).nFrame)
#define OMX_MAPBUFQUEUE_GETNEXTCAPTURE(_queue_)   ((_queue_).nNextCaptureIndex)
#define OMX_MAPBUFQUEUE_GETNEXTWAIT(_queue_)   ((_queue_).nNextWaitIndex)
#define OMX_MAPBUFQUEUE_GETLASTBUFFER(_queue_)   ((_queue_).nLastBufIndex)
#define OMX_MAPBUFQUEUE_GETNEXTINDEX(_queue_, _curindex_)   ((_curindex_ + 1) % (_queue_).nFrame)
#define OMX_MAPBUFQUEUE_GETBUFCOUNTCAPTURED(_queue_)   ((_queue_).nBufCountCaptured)
#define OMX_MAPBUFQUEUE_GETBUFADDR(_queue_, _bufindex_)   ((OMX_PTR) (_queue_).buffers[(_bufindex_)].pCapAddrStart)
#define OMX_MAPBUFQUEUE_MAKEEMPTY(_queue_)
#define OMX_MAPBUFQUEUE_ENQUEUE(_queue_)
#define OMX_MAPBUFQUEUE_DEQUEUE(_queue_)
#define OMX_MAPBUFQUEUE_ADDCAPTUREDBUF(_queue_)
#define OMX_MAPBUFQUEUE_GETTIMESTAMP(_queue_, _bufindex_)   ((_queue_).qTimeStampQueue[(_bufindex_)])
#define OMX_MAPBUFQUEUE_SETTIMESTAMP(_queue_, _bufindex_, _timestamp_)

Functions

OMX_ERRORTYPE omx_camera_source_component_Constructor (OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
OMX_ERRORTYPE omx_camera_source_component_Destructor (OMX_COMPONENTTYPE *openmaxStandComp)


Detailed Description

OpenMAX camera source component. The OpenMAX camera component is a V4L2-based video source whose functionalities include preview, video capture, image capture, video thumbnail and image thumbnail. It has 3 (output) ports: Port 0 is used for preview; Port 1 is used for video and image capture; Port 2 is used for video and image thumbnail.

Copyright (C) 2007 Motorola

This code is licensed under LGPL see README for full LGPL notice.

Date Author Comment Mon, 09 Jul 2007 Motorola File created Tue, 06 Apr 2008 STM Modified to support Video for Linux Two(V4L2)

This Program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

$Date$ Revision $Rev$ Author $Author$

Definition in file omx_camera_source_component.c.


Define Documentation

#define CLEAR (  )     memset (&(x), 0, sizeof (x))

Definition at line 55 of file omx_camera_source_component.c.

#define DEFAULT_COLOR_FORMAT   OMX_COLOR_FormatYUV420PackedPlanar

#define DEFAULT_FRAME_HEIGHT   240

#define DEFAULT_FRAME_RATE   15

#define DEFAULT_FRAME_WIDTH   320

 
#define GET_SYSERR_STRING (  )     strerror(errno)

Definition at line 50 of file omx_camera_source_component.c.

#define OMX_CAM_VC_SNAPSHOT_INDEX   5

Definition at line 53 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_ADDCAPTUREDBUF ( _queue_   ) 

Value:

do \
                                                                               { \
                                                                                   (_queue_).nNextWaitIndex = ((_queue_).nNextWaitIndex + 1) % (_queue_).nFrame; \
                                                                                   (_queue_).nBufCountCaptured ++; \
                                                                               } while (0)

Definition at line 98 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_DEQUEUE ( _queue_   ) 

Value:

do \
                                                                               { \
                                                                                   (_queue_).nLastBufIndex = ((_queue_).nLastBufIndex + 1) % (_queue_).nFrame; \
                                                                                   (_queue_).nBufCountTotal --; \
                                                                                   (_queue_).nBufCountCaptured --; \
                                                                               } while (0)

Definition at line 91 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_ENQUEUE ( _queue_   ) 

Value:

do \
                                                                               { \
                                                                                   (_queue_).nNextCaptureIndex = ((_queue_).nNextCaptureIndex + 1) % (_queue_).nFrame; \
                                                                                   (_queue_).nBufCountTotal ++; \
                                                                               } while (0)

Definition at line 86 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETBUFADDR ( _queue_,
_bufindex_   )     ((OMX_PTR) (_queue_).buffers[(_bufindex_)].pCapAddrStart)

Definition at line 76 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETBUFCOUNTCAPTURED ( _queue_   )     ((_queue_).nBufCountCaptured)

Definition at line 74 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETLASTBUFFER ( _queue_   )     ((_queue_).nLastBufIndex)

Definition at line 71 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETMAXLEN ( _queue_   )     ((_queue_).nFrame)

Definition at line 67 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETNEXTCAPTURE ( _queue_   )     ((_queue_).nNextCaptureIndex)

Definition at line 69 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETNEXTINDEX ( _queue_,
_curindex_   )     ((_curindex_ + 1) % (_queue_).nFrame)

Definition at line 72 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETNEXTWAIT ( _queue_   )     ((_queue_).nNextWaitIndex)

Definition at line 70 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_GETTIMESTAMP ( _queue_,
_bufindex_   )     ((_queue_).qTimeStampQueue[(_bufindex_)])

Definition at line 104 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_HASBUFCAPTURED ( _queue_   )     (!(OMX_MAPBUFQUEUE_NOBUFCAPTURED(_queue_)))

Definition at line 63 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_HASBUFWAITTOCAPTURE ( _queue_   )     (!(OMX_MAPBUFQUEUE_NOBUFWAITTOCAPTURE(_queue_)))

Definition at line 65 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_ISEMPTY ( _queue_   )     (0 == (_queue_).nBufCountTotal)

Definition at line 60 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_ISFULL ( _queue_   )     ((_queue_).nBufCountTotal > 0 && (_queue_).nNextCaptureIndex == (_queue_).nLastBufIndex)

Definition at line 61 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_MAKEEMPTY ( _queue_   ) 

Value:

do \
                                                                               { \
                                                                                   (_queue_).nNextCaptureIndex = 0; \
                                                                                   (_queue_).nNextWaitIndex = 0; \
                                                                                   (_queue_).nLastBufIndex = 0; \
                                                                                   (_queue_).nBufCountTotal = 0; \
                                                                                   (_queue_).nBufCountCaptured = 0; \
                                                                               } while (0)

Definition at line 78 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_NOBUFCAPTURED ( _queue_   )     (0 == (_queue_).nBufCountCaptured)

Definition at line 62 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_NOBUFWAITTOCAPTURE ( _queue_   )     (OMX_MAPBUFQUEUE_HASBUFCAPTURED(_queue_) && (_queue_).nNextWaitIndex == (_queue_).nNextCaptureIndex)

Definition at line 64 of file omx_camera_source_component.c.

#define OMX_MAPBUFQUEUE_SETTIMESTAMP ( _queue_,
_bufindex_,
_timestamp_   ) 

Value:

do \
                                                                               { \
                                                                                   (_queue_).qTimeStampQueue[(_bufindex_)] = (OMX_TICKS)(_timestamp_); \
                                                                               } while (0)

Definition at line 105 of file omx_camera_source_component.c.


Function Documentation

OMX_ERRORTYPE omx_camera_source_component_Constructor ( OMX_COMPONENTTYPE openmaxStandComp,
OMX_STRING  cComponentName 
)

The Constructor for camera source component

Parameters:
openmaxStandComp is the pointer to the OMX component
cComponentName is the name of the constructed component

Allocate camera component private structure

Init camera private parameters by default values

Allocate Ports.

this is the important thing separating this from the base class; size of the struct is for derived class port type this could be refactored as a smarter factory function instead?

Call base port constructor

Init port parameters by default values

set the function pointers

Definition at line 700 of file omx_camera_source_component.c.

References base_video_port_Constructor(), DEB_LEV_FUNCTION_NAME, DEBUG, DEFAULT_COLOR_FORMAT, DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_RATE, DEFAULT_FRAME_WIDTH, OMX_COMPONENTTYPE::GetConfig, OMX_COMPONENTTYPE::GetParameter, NUM_CAMERAPORTS, omx_base_source_Constructor(), omx_camera_source_component_Destructor(), OMX_ErrorInsufficientResources, OMX_ErrorNone, OMX_FALSE, OMX_COMPONENTTYPE::pComponentPrivate, OMX_COMPONENTTYPE::SetConfig, setHeader(), and OMX_COMPONENTTYPE::SetParameter.

Referenced by omx_component_library_Setup().

OMX_ERRORTYPE omx_camera_source_component_Destructor ( OMX_COMPONENTTYPE openmaxStandComp  ) 

The Destructor for camera source component

Parameters:
openmaxStandComp is the pointer to the OMX component

frees the port structures

Definition at line 808 of file omx_camera_source_component.c.

References base_port_Destructor(), DEB_LEV_FUNCTION_NAME, DEBUG, omx_base_source_Destructor(), OMX_ErrorNone, and OMX_COMPONENTTYPE::pComponentPrivate.

Referenced by omx_camera_source_component_Constructor().


Generated for OpenMAX Bellagio rel. 0.3.5-svn by  doxygen 1.5.1
SourceForge.net Logo