mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-25 04:11:38 +00:00
added concat function and some parameter in payload in structure
This commit is contained in:
parent
d9fb5bb350
commit
1e75295939
@ -116,6 +116,9 @@ struct ts_payload
|
||||
unsigned pid; // Stream PID
|
||||
int counter; // continuity counter
|
||||
int transport_error; // 0 = packet OK, non-zero damaged
|
||||
unsigned char *section_buf;
|
||||
int section_index;
|
||||
int section_size;
|
||||
};
|
||||
|
||||
struct PAT_entry
|
||||
@ -337,7 +340,7 @@ void init_ts( void );
|
||||
int ts_readpacket(void);
|
||||
long ts_readstream(void);
|
||||
LLONG ts_getmoredata( void );
|
||||
int parse_PMT (int pos);
|
||||
int parse_PMT (unsigned char *buf,int len, int pos);
|
||||
int parse_PAT (void);
|
||||
|
||||
// myth.cpp
|
||||
|
@ -20,12 +20,6 @@
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
/* convert values between host and network byte order(big endian) */
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf(str,size,format,...) _snprintf(str,size-1,format,__VA_ARGS__)
|
||||
@ -34,6 +28,7 @@
|
||||
#include "dvb_subtitle_decoder.h"
|
||||
#include "spupng_encoder.h"
|
||||
#include "ocr.h"
|
||||
#include "utility.h"
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -48,11 +43,6 @@
|
||||
#define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14
|
||||
#define DVBSUB_DISPLAY_SEGMENT 0x80
|
||||
|
||||
#define RL32(x) (*(unsigned int *)(x))
|
||||
#define RB32(x) (ntohl(*(unsigned int *)(x)))
|
||||
#define RL16(x) (*(unsigned short int*)(x))
|
||||
#define RB16(x) (ntohs(*(unsigned short int*)(x)))
|
||||
|
||||
#define SCALEBITS 10
|
||||
#define ONE_HALF (1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
|
||||
|
@ -292,7 +292,7 @@ long ts_readstream(void)
|
||||
if (is_pmt)
|
||||
{
|
||||
PIDs_seen[payload.pid]=2;
|
||||
if (parse_PMT (j))
|
||||
if (parse_PMT (NULL,0,j))
|
||||
gotpes=1; // Signals that something changed and that we must flush the buffer
|
||||
if (payload.pid==pmtpid && ccx_options.ts_cappid==0 && ccx_options.investigate_packets) // It was our PMT yet we don't have a PID to get data from
|
||||
packet_analysis_mode=1;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "ccextractor.h"
|
||||
#include "dvb_subtitle_decoder.h"
|
||||
|
||||
#include "utility.h"
|
||||
static unsigned pmt_warning_shown=0; // Only display warning once
|
||||
void *cxx_dvb_context = NULL;
|
||||
|
||||
@ -62,23 +62,20 @@ void clear_PMT_array (void)
|
||||
}
|
||||
pmt_array_length=0;
|
||||
}
|
||||
|
||||
int parse_PMT (int pos)
|
||||
int parse_PMT (unsigned char *buf,int len, int pos)
|
||||
{
|
||||
int must_flush=0;
|
||||
int ret = 0;
|
||||
unsigned char desc_len = 0;
|
||||
unsigned char desc_len = 0;
|
||||
|
||||
if ((ccx_options.ts_forced_cappid || (ccx_options.teletext_mode==CCX_TXT_IN_USE && ccx_options.ts_cappid)) &&
|
||||
cap_stream_type!=CCX_STREAM_TYPE_UNKNOWNSTREAM) // Already know what we need, skip
|
||||
return 0;
|
||||
|
||||
if (!payload.pesstart) // Not the first entry. Ignore it, it should not be here.
|
||||
return 0;
|
||||
|
||||
unsigned pointer_field = *(payload.start);
|
||||
unsigned char *payload_start = payload.start + pointer_field + 1;
|
||||
unsigned payload_length = tspacket+188-payload_start;
|
||||
unsigned pointer_field = *(payload.start);
|
||||
unsigned char *payload_start = payload.start + pointer_field + 1;
|
||||
unsigned payload_length = tspacket+188-payload_start;
|
||||
|
||||
/* We keep a copy of all PMTs, even if not interesting to us for now */
|
||||
if (pmt_array[pos].last_pmt_payload!=NULL && payload_length == pmt_array[pos].last_pmt_length &&
|
||||
@ -88,7 +85,7 @@ int parse_PMT (int pos)
|
||||
return 0;
|
||||
}
|
||||
pmt_array[pos].last_pmt_payload=(unsigned char *)
|
||||
realloc (pmt_array[pos].last_pmt_payload, payload_length+8); // Extra 8 in case memcpy copies dwords, etc
|
||||
realloc (pmt_array[pos].last_pmt_payload, payload_length+8); // Extra 8 in case memcpy copies dwords, etc
|
||||
if (pmt_array[pos].last_pmt_payload==NULL)
|
||||
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory to process PMT.\n");
|
||||
memcpy (pmt_array[pos].last_pmt_payload, payload_start, payload_length);
|
||||
@ -401,6 +398,29 @@ int parse_PMT (int pos)
|
||||
return must_flush;
|
||||
}
|
||||
|
||||
void write_section(struct ts_payload *payload, unsigned char*buf, int size)
|
||||
{
|
||||
if (payload->pesstart)
|
||||
{
|
||||
memcpy(payload->section_buf, buf, size);
|
||||
payload->section_index = size;
|
||||
payload->section_size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(payload->section_buf + payload->section_index, buf, size);
|
||||
payload->section_index += size;
|
||||
|
||||
}
|
||||
if(payload->section_size == -1 && payload->section_index >= 3)
|
||||
payload->section_size = (RB16(payload->section_buf + 1) & 0xfff) + 3 ;
|
||||
|
||||
if(payload->section_index >= (unsigned)payload->section_size)
|
||||
parse_PMT(NULL,0,0);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Program Allocation Table. It contains a list of all programs and the
|
||||
PIDs of their Program Map Table.
|
||||
Returns: gotpes */
|
||||
|
Loading…
Reference in New Issue
Block a user