Skip to content
Snippets Groups Projects
Commit ecbf80e9 authored by Bruce Flynn's avatar Bruce Flynn
Browse files

merge: don't crash for non-order apids

parent 4419cdf0
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
""" """
import logging import logging
import os import os
from collections import deque, OrderedDict from collections import deque
from functools import total_ordering
from . import eos as _eos from . import eos as _eos
...@@ -71,17 +70,18 @@ class _Ptr(object): ...@@ -71,17 +70,18 @@ class _Ptr(object):
def _sort_key(p, order=None, eos=False): def _sort_key(p, order=None, eos=False):
if eos and p.apid == 64: if eos and p.apid == 64:
return _eos._modis_sort_key(p) return _eos._modis_sort_key(p)
return (p.stamp, order.index(p.apid) if order else p.apid) apid_order = order.index(p.apid) if p.apid in order else 0
return (p.stamp, apid_order if order else p.apid)
def read_packet_index(stream, order=None, eos=False): def read_packet_index(stream, order=None, eos=False):
order = tuple(order) if order else tuple()
index = deque() index = deque()
try: try:
# drop any leading hanging packets # drop any leading hanging packets
count = 0 count = 0
packet = stream.next() packet = stream.next()
while not packet.stamp: while not packet.stamp:
#while not (packet.is_first() or packet.is_standalone()):
packet = stream.next() packet = stream.next()
count += 1 count += 1
if count: if count:
...@@ -89,7 +89,6 @@ def read_packet_index(stream, order=None, eos=False): ...@@ -89,7 +89,6 @@ def read_packet_index(stream, order=None, eos=False):
while True: while True:
if not packet.stamp: if not packet.stamp:
#if not (packet.is_first() or packet.is_standalone()):
# corrupt packet groups can cause apid mismatch # corrupt packet groups can cause apid mismatch
# so skip until we get to the next group # so skip until we get to the next group
packet = stream.next() packet = stream.next()
...@@ -107,7 +106,6 @@ def read_packet_index(stream, order=None, eos=False): ...@@ -107,7 +106,6 @@ def read_packet_index(stream, order=None, eos=False):
# collect all packets for this timecode/group # collect all packets for this timecode/group
packet = stream.next() packet = stream.next()
while not packet.stamp: while not packet.stamp:
#while not (packet.is_first() or packet.is_standalone()):
# Bail if we're collecting group packets and apids don't match # Bail if we're collecting group packets and apids don't match
# This means group is corrupt # This means group is corrupt
if ptr.apid != packet.apid: if ptr.apid != packet.apid:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment