Skip to content

Commit

Permalink
mt2s compatibility fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Feb 2, 2014
1 parent b194e7c commit 6fe60ea
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 35 deletions.
25 changes: 16 additions & 9 deletions mgmt_m2ts_decoder/src/sx_mgmt_m2ts_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,22 @@ static ePKT_TYPE pkt_type_get(
bytes_left -= sizeof(sRTP_HDR);
assert((bytes_left % sizeof(sMPEG2_TS)) == 0);

// printf("(mgmt_m2ts): pkt_type_get() invoked!\n");

do
{
sMPEG2_TS *ts = (sMPEG2_TS *) curr_ptr;
UINT16 pid = PID_GET(ts->hdr);

// printf("(mgmt_m2ts): 0x%x 0x%x 0x%x 0x%x\n",
// ts->hdr.sync_byte,
// ts->hdr.tei_pusi_tp_pid1,
// ts->hdr.pid2,
// ts->hdr.tsc_afc_cc);
//
// printf("(mgmt_m2ts): pid = 0x%.4x\n", pid);
#if 0
printf("(mgmt_m2ts): 0x%x 0x%x 0x%x 0x%x\n",
ts->hdr.sync_byte,
ts->hdr.tei_pusi_tp_pid1,
ts->hdr.pid2,
ts->hdr.tsc_afc_cc);

printf("(mgmt_m2ts): pid = 0x%.4x\n", pid);
#endif

if(pid == 0x1011)
{
Expand All @@ -189,8 +193,6 @@ static ePKT_TYPE pkt_type_get(

} while (bytes_left > 0);

assert(0);

return PKT_TYPE_NULL;
}

Expand Down Expand Up @@ -258,6 +260,11 @@ static void pkt_process_thread(
sx_pipe_put(SX_VRDMA_LPCM, desc);
break;
}
case PKT_TYPE_NULL:
{
sx_desc_put(desc);
break;
}
default:
{
assert(0);
Expand Down
47 changes: 44 additions & 3 deletions mgmt_video_decoder/src/sx_mgmt_video_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void m2ts_data_interpret(

if(PUSI_GET(ts->hdr))
{
assert(afc == 0x01);
// assert(afc == 0x03);

// printf("### 0x%x 0x%x 0x%x 0x%x\n",
// ts->payload.payload[14],
Expand Down Expand Up @@ -304,6 +304,20 @@ static UINT8 slice_start_find(
{
curr_ptr = &ts->payload.payload[0];

UINT8 adaptation_field_len = 0;
if(afc & 0x02)
{
// adaption field is present.
//
// determine how many bytes to skip.

adaptation_field_len = 1 + *curr_ptr;
}

// Skip 'adaptation field length' field.
curr_ptr += adaptation_field_len;

// Skip adaptation field length.
curr_ptr += sizeof(sPES);

sPES_EXT *pes_ext = (sPES_EXT *) curr_ptr;
Expand All @@ -320,8 +334,35 @@ static UINT8 slice_start_find(

curr_ptr += sizeof(sPES_EXT);

// Consistency check.
assert(*curr_ptr == 0x05);
if(*curr_ptr != 0x05)
{
printf("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
((UINT8 *) ts)[0],
((UINT8 *) ts)[1],
((UINT8 *) ts)[2],
((UINT8 *) ts)[3],
((UINT8 *) ts)[4],
((UINT8 *) ts)[5],
((UINT8 *) ts)[6],
((UINT8 *) ts)[7]);

printf("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
((UINT8 *) ts)[8],
((UINT8 *) ts)[9],
((UINT8 *) ts)[10],
((UINT8 *) ts)[11],
((UINT8 *) ts)[12],
((UINT8 *) ts)[13],
((UINT8 *) ts)[14],
((UINT8 *) ts)[15]);

printf("*curr_ptr = 0x%x, delta = %u\n",
*curr_ptr,
(UINT8 *)curr_ptr - (UINT8 *) ts);

// Consistency check.
assert(0);
}

curr_ptr++;

Expand Down
31 changes: 9 additions & 22 deletions mgmt_video_scheduler/src/sx_mgmt_video_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,21 @@ static void video_scheduler_slice_dump(

if(pid == 0x1011)
{
if(PUSI_GET(ts->hdr))
UINT8 stuffing = 0;
if(afc & 0x02)
{
assert(afc == 0x01);
stuffing = 1 + ts->payload.payload[0];
}

start_offset = 14;
start_offset = stuffing;

payload_size = (sizeof(sMPEG2_TS_PAYLOAD) - 14);
}
else
if(PUSI_GET(ts->hdr))
{
if(afc == 0x01)
{
start_offset = 0;

payload_size = sizeof(sMPEG2_TS_PAYLOAD);
}
else if(afc == 0x03)
{
start_offset = 1 + ts->payload.payload[0];

payload_size = sizeof(sMPEG2_TS_PAYLOAD) - 1 - ts->payload.payload[0];
}
else
{
assert(0);
}
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.
Expand Down
2 changes: 1 addition & 1 deletion scripts/piracast.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def lease_file_timestamp_get() :

# Launch application.
cmd = 'sudo nice -n -20 ./core'
subprocess.Popen(cmd.split(), shell=False, stdout=open(os.devnull, 'w'))
subprocess.Popen(cmd.split(), shell=False) # , stdout=open(os.devnull, 'w'))

# Start DHCP.
console_output = subprocess.Popen(cmd_dhcp_start.split(), shell=False, stdout=subprocess.PIPE)
Expand Down

0 comments on commit 6fe60ea

Please sign in to comment.