Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct{
- int table_id;
- int section_syntax_indicator;
- int zero;
- int reserved1;
- int section_length;
- int transport_stream_id;
- int reserved2;
- int version_number;
- int current_next_indicator;
- int section_number;
- int last_section_number;
- int program_map_PID;
- long int CRC_32;
- }PatInfo;
- typedef struct{
- int table_id ;
- int section_syntax_indicator ;
- int zero;
- int reserved1;
- int section_length;
- int program_number;
- int reserved2;
- int version_number;
- int current_next_indicator;
- int section_number;
- int last_section_number;
- int reserved3;
- int PCR_PID;
- int reserved4;
- int program_info_length;
- long int stream_type;
- long int reserved5;
- long int elementary_PID;
- long int reserved6;
- long int ES_info_length;
- long int CRC_32;
- }PmtInfo;
- typedef struct {
- int sync_byte;
- int transport_error_indicator;
- int payload_unit_start_indicator;
- int transport_priority;
- int PID;
- int transport_scrambling_control;
- int adaptation_field_control;
- int continuity_counter;
- }TransStreamPack;
- int main(){
- int main (void){
- FILE *stream;
- unsigned char buffer[188];
- size_t filesize;
- int i;
- stream = fopen ("video.ts","rb");
- if(stream==NULL){
- printf("Erro ao abrir arquivo.\n");
- return 0;
- }
- //Obtendo tamanho do arquivo
- fseek (stream , 0 , SEEK_END);
- filesize = ftell (stream);
- rewind (stream);
- if(feof(stream))
- return 0;
- fread( buffer, sizeof( buffer ), 1, stream );
- /* Montei as estruturas com todos os dados que preciso preencher das tabelas.
- O problema encontra-se em como localizar os dados através dos bytes dos
- packets. Sei que cada packet possui um tamanho de 188 bytes, e também que
- no início de cada packet encontra-se o cabeçalho contendo os dados da
- TransportStreamPackage, que é exatamente a estrutura que me guiará no processo.
- Lendo, vi que o cabeçalho é constituído de 4 bytes. Então como proceder para
- pegar os dados? :D
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement