| 1 | #ifndef __LIVE_VIEW_H |
|---|
| 2 | #define __LIVE_VIEW_H |
|---|
| 3 | |
|---|
| 4 | // Live View protocol version |
|---|
| 5 | #define LIVE_VIEW_VERSION_MAJOR 1 // increase only with backwards incompatible changes (and reset minor) |
|---|
| 6 | #define LIVE_VIEW_VERSION_MINOR 0 // increase with extensions of functionality |
|---|
| 7 | |
|---|
| 8 | // Control flags for determining which data block to transfer |
|---|
| 9 | #define LV_TFR_CORE_DETAILS 0x80 |
|---|
| 10 | #define LV_TFR_VIEWPORT 0x01 |
|---|
| 11 | #define LV_TFR_BITMAP 0x04 |
|---|
| 12 | #define LV_TFR_PALETTE 0x08 |
|---|
| 13 | |
|---|
| 14 | // Structure to populate with live view base info |
|---|
| 15 | // These details are static and only need to be retrieved once |
|---|
| 16 | typedef struct { |
|---|
| 17 | int version_major; // Major version number |
|---|
| 18 | int version_minor; // Minor version number |
|---|
| 19 | int vp_max_width; // Maximum viewport width (in pixels) |
|---|
| 20 | int vp_max_height; // Maximum viewport height (in pixels) |
|---|
| 21 | int vp_buffer_width; // Viewport buffer width in case buffer is wider than visible viewport (in pixels) |
|---|
| 22 | int bm_max_width; // Maximum width of bitmap (in pixels) |
|---|
| 23 | int bm_max_height; // Maximum height of bitmap (in pixels) |
|---|
| 24 | int bm_buffer_width; // Bitmap buffer width in case buffer is wider than visible bitmap (in pixels) |
|---|
| 25 | int lcd_aspect_ratio; // 0 = 4:3, 1 = 16:9 |
|---|
| 26 | } lv_base_info; |
|---|
| 27 | |
|---|
| 28 | // Structure containing the info for the current live view frame |
|---|
| 29 | // This information may change across calls |
|---|
| 30 | typedef struct { |
|---|
| 31 | int vp_xoffset; // Viewport X offset in pixels (for cameras with variable image size) |
|---|
| 32 | int vp_yoffset; // Viewport Y offset in pixels (for cameras with variable image size) |
|---|
| 33 | int vp_width; // Actual viewport width in pixels (for cameras with variable image size) |
|---|
| 34 | int vp_height; // Actual viewport height in pixels (for cameras with variable image size) |
|---|
| 35 | int vp_buffer_start; // Offset in data transferred where the viewport data starts |
|---|
| 36 | int vp_buffer_size; // Size of viewport data sent (in bytes) |
|---|
| 37 | int bm_buffer_start; // Offset in data transferred where the bitmap data starts |
|---|
| 38 | int bm_buffer_size; // Size of bitmap data sent (in bytes) |
|---|
| 39 | int palette_type; // Camera palette type |
|---|
| 40 | // (0 = no palette, 1 = 16 x 4 byte AYUV values, 2 = 16 x 4 byte AYUV values with A = 0..3, 3 = 256 x 4 byte AYUV values with A = 0..3) |
|---|
| 41 | int palette_buffer_start; // Offset in data transferred where the palette data starts |
|---|
| 42 | int palette_buffer_size; // Size of palette data sent (in bytes) |
|---|
| 43 | } lv_vid_info; |
|---|
| 44 | |
|---|
| 45 | enum lv_aspect_rato { |
|---|
| 46 | LV_ASPECT_4_3, |
|---|
| 47 | LV_ASPECT_16_9, |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | typedef struct { |
|---|
| 51 | /* |
|---|
| 52 | logical screen |
|---|
| 53 | descibes how big the buffer would be in pixels, if it exactly filled the physical screen |
|---|
| 54 | may be larger or smaller than the buffer data, due to letter boxing or unused data |
|---|
| 55 | using lcd_aspect_ratio, you can create a correct representation of the screen |
|---|
| 56 | */ |
|---|
| 57 | int logical_width; |
|---|
| 58 | int logical_height; |
|---|
| 59 | /* |
|---|
| 60 | buffer - describes the actual data sent |
|---|
| 61 | data size is always buffer_width*buffer_height*(buffer bpp implied by type) |
|---|
| 62 | offsets represent the position of the data on the logical screen, |
|---|
| 63 | > 0 for sub images (16:9 on a 4:3 screen, stitch window, etc) |
|---|
| 64 | */ |
|---|
| 65 | int buffer_width; |
|---|
| 66 | // TODO will go away |
|---|
| 67 | int buffer_height; |
|---|
| 68 | |
|---|
| 69 | int buffer_logical_xoffset; |
|---|
| 70 | int buffer_logical_yoffset; |
|---|
| 71 | |
|---|
| 72 | /* |
|---|
| 73 | visible - describes data within the buffer which contains image data to be displayed |
|---|
| 74 | offsets are relative to buffer |
|---|
| 75 | width must be <= logical_width - buffer_logical_xoffset and width + xoffset must be <= buffer_width |
|---|
| 76 | */ |
|---|
| 77 | int visible_width; |
|---|
| 78 | int visible_height; |
|---|
| 79 | // TODO these will go away |
|---|
| 80 | int visible_buffer_xoffset; |
|---|
| 81 | int visible_buffer_yoffset; |
|---|
| 82 | int data_start; // offset of data |
|---|
| 83 | } lv_framebuffer_desc; |
|---|
| 84 | |
|---|
| 85 | typedef struct { |
|---|
| 86 | int lcd_aspect_ratio; // physical aspect ratio of LCD |
|---|
| 87 | int palette_type; |
|---|
| 88 | int palette_data_start; |
|---|
| 89 | lv_framebuffer_desc vp; // viewport |
|---|
| 90 | lv_framebuffer_desc bm; // bitmap |
|---|
| 91 | } lv_data_header; |
|---|
| 92 | |
|---|
| 93 | #ifdef CAM_CHDK_PTP |
|---|
| 94 | extern int live_view_data_handler(ptp_data *data, int flags, int arg2); |
|---|
| 95 | extern int live_view_get_data(ptp_data *data, int flags); |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | #endif // __LIVE_VIEW_H |
|---|