/***************************************************************************** * dvbpsi_GenBouquetNameDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenBouquetNameDr( dvbpsi_bouquet_name_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x47, p_decoded->i_name_length, NULL); if(p_descriptor) { /* Encode data */ if(p_decoded->i_name_length) memcpy(p_descriptor->p_data, p_decoded->i_char, p_decoded->i_name_length); if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_bouquet_name_dr_t * p_dup_decoded = (dvbpsi_bouquet_name_dr_t*)malloc(sizeof(dvbpsi_bouquet_name_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_bouquet_name_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_gen_mpeg_private_data_dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_gen_mpeg_private_data_dr( dvbpsi_mpeg_private_data_dr_t * p_decoded, bool b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0f, 4, NULL); if (!p_descriptor) return NULL; /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_private_data >> 24; p_descriptor->p_data[1] = p_decoded->i_private_data >> 16; p_descriptor->p_data[2] = p_decoded->i_private_data >> 8; p_descriptor->p_data[3] = p_decoded->i_private_data; if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_mpeg_private_data_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenNetworkNameDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenNetworkNameDr( dvbpsi_network_name_dr_t * p_decoded, bool b_duplicate) { if (p_decoded->i_name_length > 255) p_decoded->i_name_length = 255; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x40, p_decoded->i_name_length, NULL); if (!p_descriptor) return NULL; /* Encode data */ if (p_decoded->i_name_length) memcpy(p_descriptor->p_data, p_decoded->i_name_byte, p_decoded->i_name_length); if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_network_name_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenDSAlignmentDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenDSAlignmentDr( dvbpsi_ds_alignment_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x06, 1, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_alignment_type; if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_ds_alignment_dr_t * p_dup_decoded = (dvbpsi_ds_alignment_dr_t*)malloc(sizeof(dvbpsi_ds_alignment_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_ds_alignment_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenComponentDr *****************************************************************************/ dvbpsi_descriptor_t *dvbpsi_GenComponentDr(dvbpsi_component_dr_t * p_decoded, bool b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x50, 6+p_decoded->i_text_length, NULL); if (!p_descriptor) return NULL; /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_stream_content+0xF0; p_descriptor->p_data[1] = p_decoded->i_component_type; p_descriptor->p_data[2] = p_decoded->i_component_tag; memcpy( &p_descriptor->p_data[3], p_decoded->i_iso_639_code, 3 ); if (p_decoded->i_text_length) memcpy(&p_descriptor->p_data[6],p_decoded->i_text,p_decoded->i_text_length); if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_component_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenISO639Dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenISO639Dr(dvbpsi_iso639_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 4, NULL); if(p_descriptor) { /* Encode data */ int i = 0; while( i < p_decoded->i_code_count ) { p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0]; p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1]; p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2]; p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type; i++; } if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_iso639_dr_t * p_dup_decoded = (dvbpsi_iso639_dr_t*)malloc(sizeof(dvbpsi_iso639_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_iso639_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_gen_mpeg_iso639_dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_gen_mpeg_iso639_dr(dvbpsi_mpeg_iso639_dr_t * p_decoded, bool b_duplicate) { if (p_decoded->i_code_count > 64) p_decoded->i_code_count = 64; /* Create the descriptor */ uint8_t i_size = (p_decoded->i_code_count * 4) > UINT8_MAX ? 255 : p_decoded->i_code_count * 4; dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0a, i_size, NULL); if (!p_descriptor) return NULL; /* Encode data */ int i = 0; while( i < p_decoded->i_code_count ) { p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0]; p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1]; p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2]; p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type; i++; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_mpeg_iso639_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenStreamIdentifierDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenStreamIdentifierDr( dvbpsi_stream_identifier_dr_t * p_decoded, bool b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x52, 1, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_component_tag; if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_stream_identifier_dr_t * p_dup_decoded = (dvbpsi_stream_identifier_dr_t*)malloc(sizeof(dvbpsi_stream_identifier_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_stream_identifier_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenSystemClockDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenSystemClockDr( dvbpsi_system_clock_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0b, 2, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = 0x40 | (p_decoded->i_clock_accuracy_integer & 0x3f); if(p_decoded->b_external_clock_ref) p_descriptor->p_data[0] |= 0x80; p_descriptor->p_data[1] = 0x1f | p_decoded->i_clock_accuracy_exponent << 5; if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_system_clock_dr_t * p_dup_decoded = (dvbpsi_system_clock_dr_t*)malloc(sizeof(dvbpsi_system_clock_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_system_clock_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenShortEventDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenShortEventDr(dvbpsi_short_event_dr_t * p_decoded, int b_duplicate) { int i_len1 = p_decoded->i_event_name_length; int i_len2 = p_decoded->i_text_length; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x4d, 5 + i_len1 + i_len2, NULL ); if(p_descriptor) { /* Encode data */ memcpy( &p_descriptor->p_data[0], p_decoded->i_iso_639_code, 3 ); p_descriptor->p_data[3] = i_len1; if( i_len1 ) memcpy( &p_descriptor->p_data[4], p_decoded->i_event_name, i_len1 ); p_descriptor->p_data[3+i_len1] = i_len2; if( i_len2 ) memcpy( &p_descriptor->p_data[3+i_len1+1], p_decoded->i_text, i_len2 ); if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_short_event_dr_t * p_dup_decoded = (dvbpsi_short_event_dr_t*)malloc(sizeof(dvbpsi_short_event_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_short_event_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenISO639Dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenISO639Dr(dvbpsi_iso639_dr_t * p_decoded, bool b_duplicate) { if (p_decoded->i_code_count > 64) p_decoded->i_code_count = 64; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 4, NULL); if (!p_descriptor) return NULL; /* Encode data */ int i = 0; while( i < p_decoded->i_code_count ) { p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0]; p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1]; p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2]; p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type; i++; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_iso639_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenCADr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenCADr(dvbpsi_ca_dr_t * p_decoded, bool b_duplicate) { if (p_decoded->i_private_length > 251) p_decoded->i_private_length = 251; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x09, p_decoded->i_private_length + 4, NULL); if (!p_descriptor) return NULL; /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_ca_system_id >> 8; p_descriptor->p_data[1] = p_decoded->i_ca_system_id; p_descriptor->p_data[2] = 0xe0 | ((p_decoded->i_ca_pid >> 8) & 0x1f); p_descriptor->p_data[3] = p_decoded->i_ca_pid; if (p_decoded->i_private_length) memcpy(p_descriptor->p_data + 4, p_decoded->i_private_data, p_decoded->i_private_length); if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_ca_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_gen_dvb_nvod_ref_dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_gen_dvb_nvod_ref_dr(dvbpsi_dvb_nvod_ref_dr_t * p_decoded, bool b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x4b, p_decoded->i_references * 6, NULL); if (!p_descriptor) return NULL; if (p_decoded->i_references > 43) p_decoded->i_references = 43; /* Encode data */ int pos = 0; for (int i = 0; i < p_decoded->i_references; i++ ) { p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_transport_stream_id >> 8; p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_transport_stream_id; p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_original_network_id >> 8; p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_original_network_id; p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_service_id >> 8; p_descriptor->p_data[pos++] = p_decoded->p_nvod_refs[i].i_service_id; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_dvb_nvod_ref_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenStuffingDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenStuffingDr( dvbpsi_stuffing_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x42, p_decoded->i_stuffing_length, NULL); if(p_descriptor) { /* Encode data */ if(p_decoded->i_stuffing_length) memcpy(p_descriptor->p_data, p_decoded->i_stuffing_byte, p_decoded->i_stuffing_length); if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_stuffing_dr_t * p_dup_decoded = (dvbpsi_stuffing_dr_t*)malloc(sizeof(dvbpsi_stuffing_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_stuffing_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_gen_dvb_country_availability_dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_gen_dvb_country_availability_dr( dvbpsi_dvb_country_availability_dr_t * p_decoded, bool b_duplicate) { /* Check the length */ if (p_decoded->i_code_count > 83) return NULL; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x83, 1+p_decoded->i_code_count*3, NULL); if (!p_descriptor) return NULL; /* Encode data */ p_descriptor->p_data[0] = (p_decoded->b_country_availability_flag) ? 0x80: 0x00; for (uint8_t i = 0; i < p_decoded->i_code_count; i++) { p_descriptor->p_data[1+i*3] = p_decoded->code[i].iso_639_code[0]; p_descriptor->p_data[2+i*3] = p_decoded->code[i].iso_639_code[1]; p_descriptor->p_data[3+i*3] = p_decoded->code[i].iso_639_code[2]; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_dvb_country_availability_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenServiceListDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenServiceListDr( dvbpsi_service_list_dr_t * p_decoded, bool b_duplicate) { /* Check the length */ if (p_decoded->i_service_count > 63) return NULL; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x41, p_decoded->i_service_count*3, NULL); if (!p_descriptor) return NULL; /* Encode data */ for (uint8_t i = 0; i < p_decoded->i_service_count; i++) { p_descriptor->p_data[i*3] = p_decoded->i_service[i].i_service_id >> 8; p_descriptor->p_data[i*3+1] = p_decoded->i_service[i].i_service_id; p_descriptor->p_data[i*3+2] = p_decoded->i_service[i].i_service_type; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_service_list_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenHierarchyDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded, bool b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x04, 4, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = 0xf0 | p_decoded->i_h_type; p_descriptor->p_data[1] = 0xc0 | p_decoded->i_h_layer_index; p_descriptor->p_data[2] = 0xc0 | p_decoded->i_h_embedded_layer; p_descriptor->p_data[3] = 0xc0 | p_decoded->i_h_priority; if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_hierarchy_dr_t * p_dup_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_hierarchy_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenCAIdentifierDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenCAIdentifierDr(dvbpsi_ca_identifier_dr_t *p_decoded, bool b_duplicate) { if (p_decoded->i_number > DVBPSI_CA_SYSTEM_ID_DR_MAX) p_decoded->i_number = DVBPSI_CA_SYSTEM_ID_DR_MAX; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x53, p_decoded->i_number * 2, NULL); if (!p_descriptor) return NULL; /* Encode data */ for (int i = 0; i < p_decoded->i_number; i++ ) { p_descriptor->p_data[2 * i] = p_decoded->p_system[i].i_ca_system_id >> 8; p_descriptor->p_data[2 * i + 1] = p_decoded->p_system[i].i_ca_system_id; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_ca_identifier_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenRegistrationDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenRegistrationDr( dvbpsi_registration_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x05, p_decoded->i_additional_length + 4, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_format_identifier >> 24; p_descriptor->p_data[1] = p_decoded->i_format_identifier >> 16; p_descriptor->p_data[2] = p_decoded->i_format_identifier >> 8; p_descriptor->p_data[3] = p_decoded->i_format_identifier; if(p_decoded->i_additional_length) memcpy(p_descriptor->p_data + 4, p_decoded->i_additional_info, p_decoded->i_additional_length); if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_registration_dr_t * p_dup_decoded = (dvbpsi_registration_dr_t*)malloc(sizeof(dvbpsi_registration_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_registration_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenExtendedEventDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenExtendedEventDr(dvbpsi_extended_event_dr_t * p_decoded, int b_duplicate) { int i_len; int i_len2; dvbpsi_descriptor_t * p_descriptor; int i; i_len2 = 0; for( i = 0; i < p_decoded->i_entry_count; i++ ) i_len2 += 2 + p_decoded->i_item_description_length[i] + p_decoded->i_item_length[i]; i_len = 1 + 3 + 1 + i_len2 + 1 + p_decoded->i_text_length; /* Create the descriptor */ p_descriptor = dvbpsi_NewDescriptor(0x4e, i_len, NULL ); if(p_descriptor) { uint8_t *p = &p_descriptor->p_data[0]; /* Encode data */ p[0] = (p_decoded->i_descriptor_number << 4 ) | p_decoded->i_last_descriptor_number; memcpy( &p[1], p_decoded->i_iso_639_code, 3 ); p[4] = i_len2; p += 4; for( i = 0; i < p_decoded->i_entry_count; i++ ) { p[0] = p_decoded->i_item_description_length[i]; memcpy( &p[1], p_decoded->i_item_description[i], p[0] ); p += 1 + p_decoded->i_item_description_length[i]; p[0] = p_decoded->i_item_length[i]; memcpy( &p[1], p_decoded->i_item[i], p[0] ); p += 1 + p_decoded->i_item_length[i]; } p[0] = p_decoded->i_text_length; memcpy( &p[1], p_decoded->i_text, p[0] ); if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_extended_event_dr_t * p_dup_decoded = (dvbpsi_extended_event_dr_t*)malloc(sizeof(dvbpsi_extended_event_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_extended_event_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
dvbpsi_descriptor_t * dvbpsi_gen_mpeg_sl_dr( dvbpsi_mpeg_sl_dr_t * p_decoded) { dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x1e, 2, NULL); if (!p_descriptor) return NULL; /* encode the data. */ p_descriptor->p_data[0] = p_decoded->i_es_id >> 8; p_descriptor->p_data[1] = p_decoded->i_es_id; return p_descriptor; }
/***************************************************************************** * dvbpsi_GenCUEIDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenCUEIDr(dvbpsi_cuei_dr_t * p_decoded) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x8a, 0x01, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = p_decoded->i_cue_stream_type; } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenSubtitlingDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenSubtitlingDr( dvbpsi_subtitling_dr_t * p_decoded, int b_duplicate) { int i; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x59, p_decoded->i_subtitles_number * 8 , NULL); if(p_descriptor) { /* Encode data */ for (i=0; i < p_decoded->i_subtitles_number; i++ ) { memcpy( p_descriptor->p_data + 8 * i, p_decoded->p_subtitle[i].i_iso6392_language_code, 3); p_descriptor->p_data[8 * i + 3] = p_decoded->p_subtitle[i].i_subtitling_type; p_descriptor->p_data[8 * i + 4] = p_decoded->p_subtitle[i].i_composition_page_id >> 8; p_descriptor->p_data[8 * i + 5] = p_decoded->p_subtitle[i].i_composition_page_id % 0xFF; p_descriptor->p_data[8 * i + 6] = p_decoded->p_subtitle[i].i_ancillary_page_id >> 8; p_descriptor->p_data[8 * i + 7] = p_decoded->p_subtitle[i].i_ancillary_page_id % 0xFF; } if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_subtitling_dr_t * p_dup_decoded = (dvbpsi_subtitling_dr_t*)malloc(sizeof(dvbpsi_subtitling_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_subtitling_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_GenTerrDelivSysDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenTerrDelivSysDr( dvbpsi_terr_deliv_sys_dr_t * p_decoded, int b_duplicate) { /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x5a, 11, NULL); if(p_descriptor) { /* Encode data */ p_descriptor->p_data[0] = (p_decoded->i_centre_frequency >> 24) & 0xff; p_descriptor->p_data[1] = (p_decoded->i_centre_frequency >> 16) & 0xff; p_descriptor->p_data[2] = (p_decoded->i_centre_frequency >> 8) & 0xff; p_descriptor->p_data[3] = p_decoded->i_centre_frequency & 0xff; p_descriptor->p_data[4] = (p_decoded->i_bandwidth & 0x07) << 5 | (p_decoded->i_priority & 0x01) << 4 | (p_decoded->i_time_slice_indicator & 0x01) << 3 | (p_decoded->i_mpe_fec_indicator & 0x01) << 2 | 0x03; p_descriptor->p_data[5] = (p_decoded->i_constellation & 0x03) << 6 | (p_decoded->i_hierarchy_information & 0x07) << 3 | (p_decoded->i_code_rate_hp_stream & 0x07); p_descriptor->p_data[6] = (p_decoded->i_code_rate_lp_stream & 0x07) << 5 | (p_decoded->i_guard_interval & 0x03) << 3 | (p_decoded->i_transmission_mode & 0x03) << 1 | (p_decoded->i_other_frequency_flag & 0x01); p_descriptor->p_data[7] = 0xff; p_descriptor->p_data[8] = 0xff; p_descriptor->p_data[9] = 0xff; p_descriptor->p_data[10] = 0xff; if(b_duplicate) { /* Duplicate decoded data */ dvbpsi_terr_deliv_sys_dr_t * p_dup_decoded = (dvbpsi_terr_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_terr_deliv_sys_dr_t)); if(p_dup_decoded) memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_terr_deliv_sys_dr_t)); p_descriptor->p_decoded = (void*)p_dup_decoded; } } return p_descriptor; }
/***************************************************************************** * dvbpsi_cat_descriptor_add ***************************************************************************** * Add a descriptor in the CAT. *****************************************************************************/ dvbpsi_descriptor_t* dvbpsi_cat_descriptor_add(dvbpsi_cat_t* p_cat, uint8_t i_tag, uint8_t i_length, uint8_t* p_data) { dvbpsi_descriptor_t* p_descriptor = dvbpsi_NewDescriptor(i_tag, i_length, p_data); if (p_descriptor == NULL) return NULL; p_cat->p_first_descriptor = dvbpsi_AddDescriptor(p_cat->p_first_descriptor, p_descriptor); assert(p_cat->p_first_descriptor); if (p_cat->p_first_descriptor == NULL) return NULL; return p_descriptor; }
/***************************************************************************** * dvbpsi_EITTableAddDescriptor ***************************************************************************** * Add a descriptor in the EIT table description. *****************************************************************************/ static dvbpsi_descriptor_t *dvbpsi_atsc_EITChannelAddDescriptor( dvbpsi_atsc_eit_event_t *p_event, uint8_t i_tag, uint8_t i_length, uint8_t *p_data) { dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(i_tag, i_length, p_data); if (p_descriptor == NULL) return NULL; p_event->p_first_descriptor = dvbpsi_AddDescriptor(p_event->p_first_descriptor, p_descriptor); assert(p_event->p_first_descriptor); if (p_event->p_first_descriptor == NULL) return NULL; return p_descriptor; }
/***************************************************************************** * dvbpsi_GenParentalRatingDr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_GenParentalRatingDr( dvbpsi_parental_rating_dr_t * p_decoded, bool b_duplicate) { uint8_t i_length; if (p_decoded->i_ratings_number >= DVBPSI_PARENTAL_RATING_DR_MAX) { i_length = (DVBPSI_PARENTAL_RATING_DR_MAX - 1) * 4; p_decoded->i_ratings_number = DVBPSI_PARENTAL_RATING_DR_MAX; } else i_length = p_decoded->i_ratings_number * 4; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x55, i_length, NULL); if (!p_descriptor) return NULL; /* Encode data */ for (int i = 0; i < p_decoded->i_ratings_number; i++ ) { p_descriptor->p_data[4 * i] = p_decoded->p_parental_rating[i].i_country_code >> 16; p_descriptor->p_data[4 * i + 1] = (p_decoded->p_parental_rating[i].i_country_code >> 8) & 0xff; p_descriptor->p_data[4 * i + 2] = p_decoded->p_parental_rating[i].i_country_code & 0xff; p_descriptor->p_data[4 * i + 3] = p_decoded->p_parental_rating[i].i_rating; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_parental_rating_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_gen_dvb_subtitling_dr *****************************************************************************/ dvbpsi_descriptor_t * dvbpsi_gen_dvb_subtitling_dr( dvbpsi_dvb_subtitling_dr_t * p_decoded, bool b_duplicate) { if (p_decoded->i_subtitles_number > DVBPSI_SUBTITLING_DR_MAX) p_decoded->i_subtitles_number = DVBPSI_SUBTITLING_DR_MAX; /* Create the descriptor */ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x59, p_decoded->i_subtitles_number * 8 , NULL); if (!p_descriptor) return NULL; /* Encode data */ for (int i = 0; i < p_decoded->i_subtitles_number; i++ ) { memcpy( p_descriptor->p_data + 8 * i, p_decoded->p_subtitle[i].i_iso6392_language_code, 3); p_descriptor->p_data[8 * i + 3] = p_decoded->p_subtitle[i].i_subtitling_type; p_descriptor->p_data[8 * i + 4] = p_decoded->p_subtitle[i].i_composition_page_id >> 8; p_descriptor->p_data[8 * i + 5] = p_decoded->p_subtitle[i].i_composition_page_id & 0xFF; p_descriptor->p_data[8 * i + 6] = p_decoded->p_subtitle[i].i_ancillary_page_id >> 8; p_descriptor->p_data[8 * i + 7] = p_decoded->p_subtitle[i].i_ancillary_page_id & 0xFF; } if (b_duplicate) { /* Duplicate decoded data */ p_descriptor->p_decoded = dvbpsi_DuplicateDecodedDescriptor(p_decoded, sizeof(dvbpsi_dvb_subtitling_dr_t)); } return p_descriptor; }
/***************************************************************************** * dvbpsi_pmt_es_descriptor_add ***************************************************************************** * Add a descriptor in the PMT ES. *****************************************************************************/ dvbpsi_descriptor_t* dvbpsi_pmt_es_descriptor_add( dvbpsi_pmt_es_t* p_es, uint8_t i_tag, uint8_t i_length, uint8_t* p_data ) { dvbpsi_descriptor_t* p_descriptor; p_descriptor = dvbpsi_NewDescriptor( i_tag, i_length, p_data ); if ( p_descriptor == NULL ) return(NULL); if ( p_es->p_first_descriptor == NULL ) p_es->p_first_descriptor = p_descriptor; else{ dvbpsi_descriptor_t* p_last_descriptor = p_es->p_first_descriptor; while ( p_last_descriptor->p_next != NULL ) p_last_descriptor = p_last_descriptor->p_next; p_last_descriptor->p_next = p_descriptor; } return(p_descriptor); }
/***************************************************************************** * dvbpsi_nit_descriptor_add ***************************************************************************** * Add a descriptor in the NIT. *****************************************************************************/ dvbpsi_descriptor_t* dvbpsi_nit_descriptor_add(dvbpsi_nit_t* p_nit, uint8_t i_tag, uint8_t i_length, uint8_t* p_data) { dvbpsi_descriptor_t* p_descriptor = dvbpsi_NewDescriptor(i_tag, i_length, p_data); if (p_descriptor == NULL) return NULL; if (p_nit->p_first_descriptor == NULL) p_nit->p_first_descriptor = p_descriptor; else { dvbpsi_descriptor_t* p_last_descriptor = p_nit->p_first_descriptor; while(p_last_descriptor->p_next != NULL) p_last_descriptor = p_last_descriptor->p_next; p_last_descriptor->p_next = p_descriptor; } return p_descriptor; }