Changeset 1824 for branches/reyalp-ptp-live/core/live_view.c
- Timestamp:
- 04/22/12 23:07:50 (14 months ago)
- File:
-
- 1 edited
-
branches/reyalp-ptp-live/core/live_view.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/reyalp-ptp-live/core/live_view.c
r1821 r1824 8 8 #ifdef CAM_CHDK_PTP 9 9 10 // PTP Live View functions11 12 // Function used to send core live view info back to client13 // this is data that does not change (including version info)14 static int live_view_core_info(ptp_data *data)15 {16 int total_size; // Calculated total size of data to transfer to client17 18 // Structure to populate with live view info19 lv_base_info details;20 21 // Populate structure info22 details.version_major = LIVE_VIEW_VERSION_MAJOR;23 details.version_minor = LIVE_VIEW_VERSION_MINOR;24 details.vp_max_width = vid_get_viewport_max_width();25 details.vp_max_height = vid_get_viewport_max_height();26 details.vp_buffer_width = vid_get_viewport_buffer_width_proper();27 /*28 details.bm_max_width = ASPECT_XCORRECTION(vid_get_bitmap_screen_width());29 details.bm_max_height = vid_get_bitmap_screen_height();30 details.bm_buffer_width = vid_get_bitmap_buffer_width();31 */32 details.bm_max_width = ASPECT_XCORRECTION(camera_screen.width);33 details.bm_max_height = camera_screen.height;34 details.bm_buffer_width = camera_screen.buffer_width;35 details.lcd_aspect_ratio = vid_get_aspect_ratio();36 37 total_size = sizeof(details);38 39 // Send header structure (along with total size to be sent)40 data->send_data(data->handle,(char*)&details,sizeof(details),total_size,0,0,0);41 42 return total_size;43 }44 45 // Function used to get viewport, bitmap and palette data via PTP46 // Address of this function sent back to client program which then47 // calls this with options to determine what to transfer48 int live_view_data_handler(ptp_data *data, int flags, int arg2)49 {50 int total_size; // Calculated total size of data to transfer to client51 52 if (flags & LV_TFR_CORE_DETAILS)53 {54 // Send base info including version55 return live_view_core_info(data);56 }57 58 // Structure containing the info for the current live view frame59 lv_vid_info vid_info;60 61 // Populate the above structure with the current default details62 vid_info.vp_xoffset = vid_get_viewport_xoffset_proper();63 vid_info.vp_yoffset = vid_get_viewport_yoffset_proper();64 vid_info.vp_width = vid_get_viewport_width_proper();65 vid_info.vp_height = vid_get_viewport_height_proper();66 vid_info.vp_buffer_start = 0;67 vid_info.vp_buffer_size = 0;68 vid_info.bm_buffer_start = 0;69 vid_info.bm_buffer_size = 0;70 vid_info.palette_type = vid_get_palette_type();71 vid_info.palette_buffer_start = 0;72 vid_info.palette_buffer_size = 0;73 74 total_size = sizeof(vid_info);75 76 void *vp = vid_get_viewport_active_buffer();77 // Add viewport details if requested, and not null78 if ( flags & LV_TFR_VIEWPORT && vp) // live buffer79 {80 vid_info.vp_buffer_start = total_size;81 // TODO viewport buffer height can vary, e.g. a540 in 640x480 video=528, normal 24082 // but shouldn't send max size when not in use83 vid_info.vp_buffer_size = (vid_get_viewport_buffer_width_proper()*vid_get_viewport_max_height()*6)/4;84 total_size += vid_info.vp_buffer_size;85 }86 87 // Add bitmap details if requested88 if ( flags & LV_TFR_BITMAP ) // bitmap buffer89 {90 vid_info.bm_buffer_start = total_size;91 //vid_info.bm_buffer_size = vid_get_bitmap_buffer_width()*vid_get_bitmap_screen_height();92 vid_info.bm_buffer_size = camera_screen.buffer_width*camera_screen.buffer_height;93 total_size += vid_info.bm_buffer_size;94 }95 96 // Add palette detals if requested and available97 if ( flags & LV_TFR_PALETTE && vid_get_palette_size() ) // bitmap palette98 {99 vid_info.palette_buffer_start = total_size;100 vid_info.palette_buffer_size = vid_get_palette_size();101 total_size += vid_info.palette_buffer_size;102 }103 104 // Send header structure (along with total size to be sent)105 data->send_data(data->handle,(char*)&vid_info,sizeof(vid_info),total_size,0,0,0);106 107 // Send viewport data if requested108 if ( flags & LV_TFR_VIEWPORT && vp)109 {110 data->send_data(data->handle,vp,vid_info.vp_buffer_size,0,0,0,0);111 }112 113 // Send bitmap data if requested114 if ( flags & LV_TFR_BITMAP )115 {116 data->send_data(data->handle,vid_get_bitmap_active_buffer(),vid_info.bm_buffer_size,0,0,0,0);117 }118 119 // Send palette data if requested120 // don't try to send zero sized palette data, since palette type is theoretically variable,121 // doesn't make sense for clients to check before requesting122 if ( (flags & LV_TFR_PALETTE) && vid_get_palette_size() )123 {124 data->send_data(data->handle,vid_get_bitmap_active_palette(),vid_info.palette_buffer_size,0,0,0,0);125 }126 127 return total_size;128 }129 130 10 int live_view_get_data(ptp_data *data, int flags) { 131 11 lv_data_header lv; 12 lv.version_major = LIVE_VIEW_VERSION_MAJOR; 13 lv.version_minor = LIVE_VIEW_VERSION_MINOR; 14 132 15 lv.lcd_aspect_ratio = vid_get_aspect_ratio(); 133 16
Note: See TracChangeset
for help on using the changeset viewer.