Camera.rpl

From WiiUBrew
Jump to navigation Jump to search

camera.rpl is the library for communication with the Wii U GamePad camera. It provides functions for initialising, getting memory requirements and decoding frames for a surface.

Functions

Name Prototype Description
CAMInit CAMHandle CAMInit(int instance, CAMSetupInfo *setupInfo, CAMError *err) Initialize the camera
CAMExit void CAMExit(CAMHandle handle) Deinitialize and clean up
CAMOpen CAMError CAMOpen(CAMHandle handle) Start recording and decoding frames
CAMClose CAMError CAMClose(CAMHandle handle) Stops recording and encoding. Automatically called when the process is moved to the background.
CAMGetMemReq int32_t CAMGetMemReq(CAMStreamInfo *streamInfo) Get the number of bytes requied by the work memory
CAMSubmitTargetSurface CAMError CAMSubmitTargetSurface(CAMHandle handle, CAMSurface *surface) Submit 1 surface to the working queue. Once the frame is captured and decoded, the event handler set in CAMInit will fire, and the frame will be dequeued. Up to 20 surfaces may be queued. Surface data is returned in the NV12 format
CAMCheckMemSegmentation CAMError CAMCheckMemSegmentation(void *pMem, uint32_t size) Checks whether memory is segmented correctly to be used with the camera library

Defines

Camera Specifications

#define CAMERA_WIDTH                640
#define CAMERA_PITCH                768
#define CAMERA_HEIGHT               480

#define CAMERA_Y_BUFFER_SIZE        (CAMERA_PITCH * CAMERA_HEIGHT)
#define CAMERA_UV_BUFFER_SIZE       (CAMERA_PITCH * CAMERA_HEIGHT / 2)
#define CAMERA_YUV_BUFFER_SIZE      (CAMERA_Y_BUFFER_SIZE + CAMERA_UV_BUFFER_SIZE)

Enums

CAMError

Name Value
CAMERA_ERROR_OK 0
CAMERA_ERROR_INVALID_ARG -1
CAMERA_ERROR_INVALID_HANDLE -2
CAMERA_ERROR_TOO_MANY_SURFACES -4
CAMERA_ERROR_INSUFFICIENT_MEMORY -5
CAMERA_ERROR_NOT_READY -6
CAMERA_ERROR_UNINITIALIZED -8
CAMERA_ERROR_UVC -9
CAMERA_ERROR_UVD_CONTEXT -10
CAMERA_ERROR_DEVICE_IN_USE -12
CAMERA_ERROR_UVD_SESSION -13
CAMERA_ERROR_SEGMENT_VIOLATION -15

CamStreamType

Only CAM_STREAM_TYPE_1 is valid.

Name Value
CAM_STREAM_TYPE_1 0

CamFps

Name Value
CAMERA_FPS_15 0
CAMERA_FPS_30 1

CamEventType

Name Value
CAMERA_DECODE_DONE 0
CAMERA_DRC_DETACH 1

Structs

CAMMode

struct CAMMode
{
   //! If TRUE, the GamePad will display the camera output regardless of what is being rendered
   BOOL forceDrc;
   //! Framerate setting
   CamFps fps;
}

CAMWorkMem

{
   //! Size of the work memory
   uint32_t size;
   //! Pointer to the work memory
   void *pMem;
}

CAMStreamInfo

{
   //! Stream type, only CAMERA_STREAM_TYPE_1 is valid
   CamStreamType type;
   //! Stream height
   uint32_t height;
   //! Stream width
   uint32_t width;
}

CAMSetupInfo

struct CAMSetupInfo
{
   //! Stream info
   CAMStreamInfo streamInfo;
   //! Memory used by library to record and decode frames
   CAMWorkMem workMem;
   //! Event handler
   CAMEventHandler eventHandler;
   //! Camera mode
   CAMMode mode;
   //! See \link OS_THREAD_ATTRIB \endlink
   uint32_t threadAffinity;
   WUT_PADDING_BYTES(0x10);
}

CAMSurface

struct CAMSurface
{
   //! Number of bytes allocated to surface buffer
   int32_t surfaceSize;
   //! Surface buffer data
   void *surfaceBuffer;
   //! Surface height
   int32_t height;
   //! Surface width
   int32_t width;
   //! Surface pitch
   int32_t pitch;
   //! Surface alignment
   int32_t alignment;
   //! Tile mode, should be zero
   int32_t tileMode;
   //! Pixel format, Should be zero
   int32_t pixelFormat;
}