int Opc_client_ae_DriverThread::send_ack_to_child(int address, int data, char* pipeName) { struct iec_item item_to_send; memset(&item_to_send,0x00, sizeof(struct iec_item)); item_to_send.iec_type = 37; item_to_send.iec_obj.ioa = address; item_to_send.iec_obj.o.type37.counter = data; item_to_send.msg_id = msg_id++; item_to_send.checksum = clearCrc((unsigned char *)&item_to_send, sizeof(struct iec_item)); int rc = pipe_put(pipeName, (char *)&item_to_send, sizeof(struct iec_item)); //Send to process_manager the packet (the first packet is lost) return rc; }
static void video_scheduler_slice_dump( sdesc *slice_head ) { UINT8 *curr_ptr; UINT32 bytes_left; UINT32 afc; UINT32 pes_byte_count; UINT32 payload_size; UINT32 start_offset; UINT32 copy_index; UINT32 pid; sdesc *curr_desc; sdesc *head_desc; // Consistency check assert(slice_head); // Get descriptor sdesc *hw_desc = desc_get(); // Set this as another chain sdesc *hw_desc_head = hw_desc; // Get a hw buffer sDECODER_HW_BUFFER * hw_buf = video_sink_buf_get(); assert(hw_buf != NULL); // Set payload hw_desc->data = (UINT8 *) hw_buf; // Get first descriptor // First descriptor holds the timestamp and will be skipped curr_desc = slice_head; copy_index = 0; do { // Get next curr_desc = curr_desc->next; // Get current curr_ptr = curr_desc->data; // Get data left bytes_left = curr_desc->data_len; assert(bytes_left > sizeof(sRTP_HDR)); // Get TS header curr_ptr += sizeof(sRTP_HDR); // Get TS bytes left bytes_left -= sizeof(sRTP_HDR); assert((bytes_left % sizeof(sMPEG2_TS)) == 0); pes_byte_count = 0; do { sMPEG2_TS *ts = (sMPEG2_TS *) curr_ptr; afc = AFC_GET(ts->hdr); pid = PID_GET(ts->hdr); if(pid == 0x1011) { UINT8 stuffing = 0; if(afc & 0x02) { stuffing = 1 + ts->payload.payload[0]; } start_offset = stuffing; if(PUSI_GET(ts->hdr)) { start_offset += 14; } payload_size = sizeof(sMPEG2_TS_PAYLOAD) - start_offset; if((copy_index + payload_size) > 81920) { // If the hw buffer is full, just submit the current buffer hw_buf->buffer_len = copy_index; // Get a new descriptor hw_desc->next = desc_get(); // Point to the new descriptor hw_desc = hw_desc->next; // Get a new buffer hw_buf = video_sink_buf_get(); assert(hw_buf != NULL); // Set new payload hw_desc->data = (UINT8 *) hw_buf; // Reset index copy_index = 0; } memcpy(&hw_buf->buffer[copy_index], &ts->payload.payload[start_offset], payload_size); copy_index += payload_size; } curr_ptr += sizeof(sMPEG2_TS); bytes_left -= sizeof(sMPEG2_TS); } while (bytes_left > 0); } while (curr_desc->next != NULL); // Set length hw_buf->buffer_len = copy_index; // Free the existing slice, minus the head (timestamp) desc_put(slice_head->next); // Set slice slice_head->next = hw_desc_head; pipe_put(VRDMA_SLICE_READY, slice_head); }