/*FUNCTION*---------------------------------------------------------------- * * Function Name : kbd_hid_get_buffer * Returned Value : none * Comments : * Find and parse the HID descriptor, then try to get the report descriptor. * *END*--------------------------------------------------------------------*/ void kbd_hid_get_report_descriptor(void) { usb_status status = USB_OK; usb_device_interface_struct_t* interfaceDescriptor = (usb_device_interface_struct_t*) kbd_hid_get_interface(); descriptor_union_t ptr1, ptr2; ptr1.pntr = interfaceDescriptor->interfaceEx; ptr2.word = ptr1.word + interfaceDescriptor->interfaceExlength; while (ptr1.cfig->bDescriptorType != USB_DESC_TYPE_HID) { ptr1.word += ptr1.cfig->bLength; if (ptr1.word >= ptr2.word) { break; } } if (ptr1.word < ptr2.word) { hid_descriptor_struct_t* hidDescriptor = (hid_descriptor_struct_t*) ptr1.pntr; hid_class_descriptor_struct_t* hidClassDescriptor = (hid_class_descriptor_struct_t*) &(hidDescriptor->bclassdescriptortype); uint8_t index; kbd_reportLength = 0; for (index = 0; index < hidDescriptor->bnumdescriptor; index++) { hid_class_descriptor_struct_t* temp; temp = hidClassDescriptor + index; if (temp->classdescriptortype == USB_DESC_TYPE_REPORT) { kbd_reportLength = USB_SHORT_UNALIGNED_LE_TO_HOST(temp->descriptorlength); break; } } if (kbd_reportLength != 0) { if (kbd_reportDescriptor != NULL) { OS_Mem_free(kbd_reportDescriptor); } kbd_reportDescriptor = (uint8_t*) OS_Mem_alloc_uncached_zero(kbd_reportLength); if (kbd_reportDescriptor == NULL) { USB_PRINTF("allocate memory failed in hid_get_buffer\r\n"); return; } kbd_hid_device.DEV_STATE = USB_DEVICE_GET_REPORT_DESCRIPTOR; kbd_hid_com->class_ptr = kbd_hid_device.CLASS_HANDLE; kbd_hid_com->callback_fn = usb_host_hid_keyboard_ctrl_callback; kbd_hid_com->callback_param = 0; status = usb_class_hid_get_descriptor(kbd_hid_com, (uint8_t) USB_DESC_TYPE_REPORT, kbd_reportDescriptor, kbd_reportLength); if (status != USB_OK) { USB_PRINTF("\r\nError in usb_class_hid_get_descriptor: %x\r\n", status); } } } else { USB_PRINTF("Can't find HID_DESCRIPTOR\r\n"); } return; }
/***************************************************************************** * * @name APP_init * * @brief This function do initialization for APP. * * @param None * * @return None ** *****************************************************************************/ void USB_init() { class_config_struct_t* cdc_vcom_config_callback_handle; class_config_struct_t* msc_disk_config_callback_handle; cdc_vcom_preinit(); msc_disk_preinit(); #if (OS_ADAPTER_ACTIVE_OS == OS_ADAPTER_MQX) if (NULL == g_composite_device) { g_composite_device = OS_Mem_alloc_uncached_zero(sizeof(composite_device_struct_t)); } /* cdc vcom device */ cdc_vcom_config_callback_handle = &g_composite_device->composite_device_config_list[CDC_VCOM_INTERFACE_INDEX]; cdc_vcom_config_callback_handle->composite_application_callback.callback = VCom_USB_App_Device_Callback; cdc_vcom_config_callback_handle->composite_application_callback.arg = &g_composite_device->cdc_vcom; cdc_vcom_config_callback_handle->class_specific_callback.callback = (usb_class_specific_handler_func) VCom_USB_App_Class_Callback; cdc_vcom_config_callback_handle->class_specific_callback.arg = &g_composite_device->cdc_vcom; cdc_vcom_config_callback_handle->desc_callback_ptr = &desc_callback; cdc_vcom_config_callback_handle->type = USB_CLASS_CDC; /* msc disk device */ msc_disk_config_callback_handle = &g_composite_device->composite_device_config_list[MSC_DISK_INTERFACE_INDEX]; msc_disk_config_callback_handle->composite_application_callback.callback = Disk_USB_App_Device_Callback; msc_disk_config_callback_handle->composite_application_callback.arg = &g_composite_device->msc_disk; msc_disk_config_callback_handle->class_specific_callback.callback = (usb_class_specific_handler_func) Disk_USB_App_Class_Callback; msc_disk_config_callback_handle->class_specific_callback.arg = &g_composite_device->msc_disk; msc_disk_config_callback_handle->desc_callback_ptr = &desc_callback; msc_disk_config_callback_handle->type = USB_CLASS_MSC; OS_Mem_zero(&g_composite_device->msc_disk, sizeof(disk_struct_t)); g_composite_device->composite_device_config_callback.count = 2; g_composite_device->composite_device_config_callback.class_app_callback = g_composite_device->composite_device_config_list; msc_disk_init(&g_composite_device->msc_disk); /* Initialize the USB interface */ USB_Composite_Init(CONTROLLER_ID, &g_composite_device->composite_device_config_callback, &g_composite_device->composite_device); g_composite_device->cdc_vcom = (cdc_handle_t) g_composite_device->composite_device_config_list[CDC_VCOM_INTERFACE_INDEX].class_handle; g_composite_device->msc_disk.app_handle = (msd_handle_t) g_composite_device->composite_device_config_list[MSC_DISK_INTERFACE_INDEX].class_handle; cdc_vcom_init(&g_composite_device->cdc_vcom); #else /* cdc vcom device */ cdc_vcom_config_callback_handle = &g_composite_device.composite_device_config_list[CDC_VCOM_INTERFACE_INDEX]; cdc_vcom_config_callback_handle->composite_application_callback.callback = VCom_USB_App_Device_Callback; cdc_vcom_config_callback_handle->composite_application_callback.arg = &g_composite_device.cdc_vcom; cdc_vcom_config_callback_handle->class_specific_callback.callback = (usb_class_specific_handler_func) VCom_USB_App_Class_Callback; cdc_vcom_config_callback_handle->class_specific_callback.arg = &g_composite_device.cdc_vcom; cdc_vcom_config_callback_handle->desc_callback_ptr = &desc_callback; cdc_vcom_config_callback_handle->type = USB_CLASS_CDC; /* msc disk device */ msc_disk_config_callback_handle = &g_composite_device.composite_device_config_list[MSC_DISK_INTERFACE_INDEX]; msc_disk_config_callback_handle->composite_application_callback.callback = Disk_USB_App_Device_Callback; msc_disk_config_callback_handle->composite_application_callback.arg = &g_composite_device.msc_disk; msc_disk_config_callback_handle->class_specific_callback.callback = (usb_class_specific_handler_func) Disk_USB_App_Class_Callback; msc_disk_config_callback_handle->class_specific_callback.arg = &g_composite_device.msc_disk; msc_disk_config_callback_handle->desc_callback_ptr = &desc_callback; msc_disk_config_callback_handle->type = USB_CLASS_MSC; OS_Mem_zero(&g_composite_device.msc_disk, sizeof(disk_struct_t)); g_composite_device.composite_device_config_callback.count = 2; g_composite_device.composite_device_config_callback.class_app_callback = g_composite_device.composite_device_config_list; msc_disk_init(&g_composite_device.msc_disk); /* Initialize the USB interface */ USB_Composite_Init(CONTROLLER_ID, &g_composite_device.composite_device_config_callback, &g_composite_device.composite_device); g_composite_device.cdc_vcom = (cdc_handle_t) g_composite_device.composite_device_config_list[CDC_VCOM_INTERFACE_INDEX].class_handle; g_composite_device.msc_disk.app_handle = (msd_handle_t) g_composite_device.composite_device_config_list[MSC_DISK_INTERFACE_INDEX].class_handle; cdc_vcom_init(&g_composite_device.cdc_vcom); #endif }
/*FUNCTION*---------------------------------------------------------------- * * Function Name : usb_host_dev_mng_attach * Returned Value : * Comments : * This function will be called when attach interrupt happens, to * add onto the device list and do common initialization. * *END*--------------------------------------------------------------------*/ usb_status usb_host_dev_mng_attach ( usb_host_handle handle, hub_device_struct_t* hub_instance, uint8_t speed, uint8_t hub_no, uint8_t port_no, uint8_t level, usb_device_instance_handle* handle_ptr ) { usb_status status; dev_instance_t* new_instance_ptr; dev_instance_t* dev_instance_ptr; dev_instance_t* dev_instance_prev_ptr; usb_host_state_struct_t* usb_host_ptr; //dev_instance_t* device_root = NULL; pipe_init_struct_t pipe_init; #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device attach device"); #endif usb_host_ptr = (usb_host_state_struct_t*)handle; //printf("a %d %d %d\n", hub_no, port_no, level); /* Allocate new device instance */ new_instance_ptr = (dev_instance_t*) OS_Mem_alloc_uncached_zero(sizeof(dev_instance_t)); if (new_instance_ptr == NULL) { #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device failed to malloc device handle"); #endif printf("memory allocation failed in usb_host_dev_mng_attach\n"); return USB_log_error(__FILE__,__LINE__, USBERR_GET_MEMORY_FAILED); } /* EndIf */ new_instance_ptr->host = handle; new_instance_ptr->speed = speed; new_instance_ptr->hub_instance = hub_instance; new_instance_ptr->hub_no = hub_no; new_instance_ptr->port_no = port_no; new_instance_ptr->level = level; new_instance_ptr->cfg_value = 0; /* We don't know yet what the device's default configuration is */ new_instance_ptr->attached = (uint8_t)TRUE; new_instance_ptr->pre_detached = (uint8_t)FALSE; //printf("l1\n"); USB_Host_lock(); //printf("l2\n"); dev_instance_ptr = usb_host_ptr->device_list_ptr; while (dev_instance_ptr != NULL) { if ((dev_instance_ptr->hub_no == hub_no) && (dev_instance_ptr->port_no == port_no)) { USB_Host_unlock(); OS_Mem_free((void*)new_instance_ptr); printf("invalidate attach\n"); *handle_ptr = NULL; return USBERR_ERROR; } else { dev_instance_ptr = dev_instance_ptr->next; } } //printf("l3\n"); /* Find unused address from 1 - 127 for this host */ dev_instance_ptr = usb_host_ptr->device_list_ptr; if ((dev_instance_ptr == NULL) || (dev_instance_ptr->address != 1)) { /* Insert at the beginning of list */ new_instance_ptr->target_address = 1; new_instance_ptr->next = dev_instance_ptr; usb_host_ptr->device_list_ptr = new_instance_ptr; } else { dev_instance_prev_ptr = dev_instance_ptr; /* Searching for a 'hole' in devices instance adresses */ while (dev_instance_ptr->target_address <= (dev_instance_prev_ptr->target_address + 1)) { new_instance_ptr->target_address = dev_instance_ptr->target_address; dev_instance_prev_ptr = dev_instance_ptr; dev_instance_ptr = dev_instance_ptr->next; if (dev_instance_ptr == NULL) break; } /* EndWhile */ if (new_instance_ptr->target_address >= 127) { /* If all 127 addresses used up, delete instance & bail out */ USB_Host_unlock(); OS_Mem_free((void*)new_instance_ptr); #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device out of addresses"); #endif printf("no valid address for the device\n"); *handle_ptr = NULL; return USB_log_error(__FILE__,__LINE__, USBERR_ADDRESS_ALLOC_FAILED); } /* EndIf */ new_instance_ptr->target_address++; new_instance_ptr->next = dev_instance_ptr; dev_instance_prev_ptr->next = new_instance_ptr; }; //printf("l4\n"); USB_Host_unlock(); /*-----------------------------------------------------------** ** Open control pipe, get first 8 bytes of device descriptor ** ** The host_ch9 routine internally sets the callback to ** ** usb_host_cntrl_transaction_done (in usb_host_ch9.c) ** ** where the action resumes on completion of the get. ** **-----------------------------------------------------------*/ pipe_init.endpoint_number = 0; pipe_init.direction = 0; pipe_init.pipetype = USB_CONTROL_PIPE; pipe_init.max_packet_size = 64; pipe_init.interval = 0; pipe_init.flags = 0; pipe_init.dev_instance = new_instance_ptr; pipe_init.nak_count = USBCFG_HOST_DEFAULT_MAX_NAK_COUNT; if (USB_OK != usb_host_open_pipe(new_instance_ptr->host, &new_instance_ptr->control_pipe, &pipe_init)) { OS_Mem_free((void*)new_instance_ptr); *handle_ptr = NULL; #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device open pipe failed"); #endif printf("can't open control pipe\n"); return USB_log_error(__FILE__,__LINE__, USBERR_PIPE_OPENED_FAILED); } /* Endif */ /* Set state to enter after transaction completion */ new_instance_ptr->state = DEVSTATE_DEVDESC8; status = _usb_host_ch9_get_descriptor((usb_device_instance_handle)new_instance_ptr, USB_DESC_TYPE_DEV << 8, 0, 8, (uint8_t *)&new_instance_ptr->dev_descriptor); if (status != USB_OK) { new_instance_ptr->state = DEVSTATE_INITIAL; #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device FAILED"); #endif printf("get descriptor error\n"); *handle_ptr = (usb_device_instance_handle)new_instance_ptr; return USB_log_error(__FILE__,__LINE__, USBERR_NO_DESCRIPTOR); } #ifdef _HOST_DEBUG_ DEBUG_LOG_TRACE("usb_dev_list_attach_device SUCCESSFUL"); #endif *handle_ptr = (usb_device_instance_handle)new_instance_ptr; //printf("attach done\n"); return USB_OK; } /* EndBody */
/* usb_task Note: usb_user_task running in main loop */ void usb_user_task(void *arg) { static usb_status status; static video_probe_and_commit_controls_t probe[3]; static uint32_t spet = 0; switch (g_video_camera.stream_interface_status) { case STREAM_INTERFACE_IDLE: break; case STREAM_INTERFACE_SET_DEFAULT_INTRFACE: { status = usb_host_open_dev_alternate_interface(g_video_camera.host_handle, g_video_camera.dev_handle, g_video_camera.stream_intf_handle, g_video_camera.stream_interface_alternate); if (status != USB_OK) { USB_PRINTF("\r\nError in usb_host_open_dev_alternate_interface: %x\r\n", status); return; } g_video_camera.stream_interface_status = STREAM_INTERFACE_INTERFACE_OPENING; g_video_camera.stream_state = USB_DEVICE_INTERFACE_OPENING; g_video_camera.stream_pipe_opened = 0; } break; case STREAM_INTERFACE_INTERFACE_OPENING: break; case STREAM_INTERFACE_FIND_OPTIMAL_SETTING: { uint32_t min_frame_size = 0xFFFFFFFF; uint32_t temp = 0; uint8_t index; uint8_t min_frame_index = 0xFF; video_payload_mjpeg_video_format_descriptor_t* format_desc_ptr = NULL; video_payload_mjpeg_video_frame_descriptor_t* frame_desc_ptr = NULL; status = usb_class_video_get_format_descriptor(g_video_camera.video_command_ptr, VS_FORMAT_MJPEG, (void*)&format_desc_ptr); if (status == USB_OK) { g_video_camera.video_format_desc_ptr = (void*)format_desc_ptr; for (index = 1;index < format_desc_ptr->bNumFrameDescriptors;index++) { status = usb_class_video_get_frame_descriptor(g_video_camera.video_command_ptr, VS_FRAME_MJPEG, index, (void*)&frame_desc_ptr); if (status == USB_OK) { temp = frame_desc_ptr->wHeight * frame_desc_ptr->wWitd; //if(min_frame_size > temp) if(index == 3) { min_frame_size = temp; min_frame_index = index; g_video_camera.video_frame_desc_ptr = (void*)frame_desc_ptr; } } } if(min_frame_index!= 0xFF) { g_video_camera.stream_interface_status = (uint8_t)STREAM_INTERFACE_GET_SET_PROBE_COMMIT; spet = 0; } } } break; case STREAM_INTERFACE_GET_SET_PROBE_COMMIT: switch (spet) { case 0: if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_CUR, (void*)&probe[0]); spet++; } break; case 1: if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_MAX, (void*)&probe[1]); spet++; } break; case 2: if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_MIN, (void*)&probe[2]); spet++; } break; case 3: { video_payload_mjpeg_video_format_descriptor_t* format_desc_ptr = NULL; video_payload_mjpeg_video_frame_descriptor_t* frame_desc_ptr = NULL; uint32_t * dwFrameInterval_ptr = NULL; uint8_t i = 0; uint32_t frame = 0; uint32_t min_frame = 0xFFFFFFFF; uint32_t frame_interval = 0; if (g_video_camera.in_ctrl == 0) { format_desc_ptr = (video_payload_mjpeg_video_format_descriptor_t*)g_video_camera.video_format_desc_ptr; frame_desc_ptr = (video_payload_mjpeg_video_frame_descriptor_t*)g_video_camera.video_frame_desc_ptr; if (g_video_camera.video_probe_ptr == NULL) { g_video_camera.video_probe_ptr = OS_Mem_alloc_uncached_zero(sizeof(video_probe_and_commit_controls_t)); } OS_Mem_copy((void*)&probe[2],g_video_camera.video_probe_ptr,26); dwFrameInterval_ptr = (uint32_t*)&frame_desc_ptr->dwFrameInterval; for(i = 0;i < frame_desc_ptr->bFrameIntervalType; i++) { OS_Mem_copy((uint8_t*)(dwFrameInterval_ptr + i), (uint8_t*)&frame_interval, 4); frame = 10000000/frame_interval; //if(min_frame > frame) if (frame == 15) //if (0x00051615 == dwFrameInterval_ptr[i]) // 30pfs { min_frame = frame; g_video_camera.video_probe_ptr->dwFrameInterval = frame_interval; } } g_video_camera.video_probe_ptr->bFormatIndex = format_desc_ptr->bFormatIndex; g_video_camera.video_probe_ptr->bFrameIndex = frame_desc_ptr->bFrameIndex; g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_set_probe(g_video_camera.video_command_ptr, SET_CUR, (void*)g_video_camera.video_probe_ptr); spet++; } } break; case 4: case 5: case 6: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; if(spet == 4) { status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_CUR, (void*)&probe[0]); } else if(spet == 5) { status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_MAX, (void*)&probe[1]); } else { status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_MIN, (void*)&probe[2]); } spet++; } } break; case 7: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; OS_Mem_copy((void*)&probe[0],g_video_camera.video_probe_ptr,22); status = usb_class_video_set_probe(g_video_camera.video_command_ptr, SET_CUR, (void*)g_video_camera.video_probe_ptr); spet++; } } break; case 8: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_CUR, (void*)&probe[0]); spet++; } } break; case 9: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; OS_Mem_copy((void*)&probe[0],g_video_camera.video_probe_ptr,26); status = usb_class_video_set_probe(g_video_camera.video_command_ptr, SET_CUR, (void*)g_video_camera.video_probe_ptr); spet++; } } break; case 10: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; status = usb_class_video_get_probe(g_video_camera.video_command_ptr, GET_CUR, (void*)&probe[0]); spet++; } } break; case 11: { if (g_video_camera.in_ctrl == 0) { g_video_camera.in_ctrl = 1; g_video_camera.ctrl_status = USB_OK; g_video_camera.video_command_ptr->callback_param = &g_video_camera; g_video_camera.video_command_ptr->callback_fn = usb_host_video_ctrl_callback; OS_Mem_copy((void*)&probe[0],g_video_camera.video_probe_ptr,26); status = usb_class_video_set_commit(g_video_camera.video_command_ptr, SET_CUR, (void*)g_video_camera.video_probe_ptr); spet++; } } break; case 12: { uint32_t param1 = 0; uint32_t param2 = 0; void* descriptor = NULL; interface_descriptor_t* intf; usb_device_interface_struct_t* pDeviceIntf; if (g_video_camera.in_ctrl == 0) { g_video_camera.stream_interface_alternate = 2; pDeviceIntf = (usb_device_interface_struct_t*)g_video_camera.stream_intf_handle; intf = pDeviceIntf->lpinterfaceDesc; param1 = (uint32_t)((uint32_t)(intf->bInterfaceNumber << 8) | (0x00000000)); usb_host_get_dev_descriptor(g_video_camera.stream_intf_handle, USB_DESC_TYPE_IF, ¶m1, ¶m2, &descriptor); usb_host_get_dev_descriptor(descriptor, USB_DESC_TYPE_EP, ¶m2, NULL, &descriptor); status = usb_class_video_set_stream_inf(g_video_camera.video_stream_handle, g_video_camera.stream_interface_alternate); if (status != USB_OK) { USB_PRINTF("\r\nError in usb_class_video_set_stream_inf: %x\r\n", status); return; } status = usb_host_open_dev_alternate_interface(g_video_camera.host_handle, g_video_camera.dev_handle, g_video_camera.stream_intf_handle, g_video_camera.stream_interface_alternate); if (status != USB_OK) { USB_PRINTF("\r\nError in usb_host_open_dev_alternate_interface: %x\r\n", status); return; } g_video_camera.stream_interface_status = STREAM_INTERFACE_SET_INTERFACE; g_video_camera.stream_state = USB_DEVICE_INTERFACE_OPENING; } } break; default: break; } break; } video_camera_control_task(); video_camera_stream_task(); if (g_video_camera.stream_transfer.is_1ms) { g_video_camera.stream_transfer.is_1ms = 0; get_video_data(); } }