source: branches/reyalp-ptp-live/core/live_view.c @ 1824

Revision 1824, 3.3 KB checked in by reyalp, 13 months ago (diff)

remove old protocol - note completely incompatible with previous test versions and chdkptp builds

  • Property svn:eol-style set to native
Line 
1#include "platform.h"
2#include "conf.h"
3#include "stdlib.h"
4#include "ptp.h"
5#include "core.h"
6#include "live_view.h"
7
8#ifdef CAM_CHDK_PTP
9
10int live_view_get_data(ptp_data *data, int flags) {
11    lv_data_header lv;
12    lv.version_major = LIVE_VIEW_VERSION_MAJOR;
13    lv.version_minor = LIVE_VIEW_VERSION_MINOR;
14
15    lv.lcd_aspect_ratio    = vid_get_aspect_ratio();
16
17    lv.vp.logical_width = vid_get_viewport_logical_width();
18    lv.vp.logical_height = vid_get_viewport_logical_height();
19
20    lv.vp.buffer_width = vid_get_viewport_buffer_width_proper();
21    // TODO will go away, always the same as visible
22    lv.vp.buffer_height = vid_get_viewport_height_proper();
23
24    // TODO
25    lv.vp.buffer_logical_xoffset = vid_get_viewport_display_xoffset_proper();
26    lv.vp.buffer_logical_yoffset = vid_get_viewport_display_yoffset_proper();
27
28    lv.vp.visible_width = vid_get_viewport_width_proper();
29    lv.vp.visible_height = vid_get_viewport_height_proper();
30
31    lv.bm.logical_width = ASPECT_XCORRECTION(camera_screen.width);
32    lv.bm.logical_height = camera_screen.height;
33
34    lv.bm.buffer_width = camera_screen.buffer_width;
35    // TODO will go away
36    lv.bm.buffer_height = camera_screen.height;
37
38    lv.bm.buffer_logical_xoffset = 0;
39    lv.bm.buffer_logical_yoffset = 0;
40
41    lv.bm.visible_width = lv.bm.logical_width;
42    lv.bm.visible_height = lv.bm.logical_height;
43
44    lv.palette_type = vid_get_palette_type();
45
46    lv.vp.data_start = 0;
47    lv.bm.data_start = 0;
48    lv.palette_data_start = 0;
49
50    int total_size = sizeof(lv);
51    int vp_size = 0,bm_size = 0,pal_size = 0;
52
53    void *vp = vid_get_viewport_active_buffer();
54    // Add viewport details if requested, and not null
55    if ( flags & LV_TFR_VIEWPORT && vp) // live buffer
56    {
57        lv.vp.data_start = total_size;
58        vp_size = (lv.vp.buffer_width*lv.vp.visible_height*6)/4;
59        total_size += vp_size;
60        // offset to start of actual data
61        vp += vid_get_viewport_image_offset();
62    }
63
64    // Add bitmap details if requested
65    if ( flags & LV_TFR_BITMAP ) // bitmap buffer
66    {
67        lv.bm.data_start = total_size;
68        bm_size = camera_screen.buffer_width*camera_screen.buffer_height;
69        total_size += bm_size;
70    }
71
72    // Add palette detals if requested and available
73    if ( flags & LV_TFR_PALETTE && vid_get_palette_size() ) // bitmap palette
74    {
75        lv.palette_data_start = total_size;
76        total_size += vid_get_palette_size();
77    }
78
79    // Send header structure (along with total size to be sent)
80    data->send_data(data->handle,(char*)&lv,sizeof(lv),total_size,0,0,0);
81
82    // Send viewport data if requested
83    if ( flags & LV_TFR_VIEWPORT && vp_size)
84    {
85        data->send_data(data->handle,vp,vp_size,0,0,0,0);
86    }
87
88    // Send bitmap data if requested
89    if ( flags & LV_TFR_BITMAP )
90    {
91        data->send_data(data->handle,vid_get_bitmap_active_buffer(),bm_size,0,0,0,0);
92    }
93
94    // Send palette data if requested
95    // don't try to send zero sized palette data, since palette type is theoretically variable,
96    // doesn't make sense for clients to check before requesting
97    if ( (flags & LV_TFR_PALETTE) && vid_get_palette_size() )
98    {
99        data->send_data(data->handle,vid_get_bitmap_active_palette(),vid_get_palette_size(),0,0,0,0);
100    }
101
102    return total_size;
103}
104#endif
Note: See TracBrowser for help on using the repository browser.