def extractVrtPayloadFromBin()

in python/awsgs.py [0:0]


def extractVrtPayloadFromBin(udpData):

    #   Strips the VITA49 header and returns the payload data
    #   Expects VITA 49.2 AWS Uncoded Frame Data Format

    #   packet type       : first 4 bits of Byte 1 (streamIdIncluded)
    #   classIdIncluded   : bit 5 of Byte 1
    #   trailerIncluded   : bit 6 of Byte 1
    #   timeStampIncluded : first 2 bits of Byte 2

    #print("============================================")
    #print("Parsing VRT Header...")
    #print('')
    #print("  Byte 1: {:08b}".format(int.from_bytes(udpData[0:1], r'big')))
    #print("  Byte 2: {:08b}".format(int.from_bytes(udpData[1:2], r'big')))
    #print('')

    #   Check Byte 01 to see if StreamId is included
    streamIdIncluded = checkForStreamId(udpData[0:1])
    #print("  streamIdIncluded  : %s" % streamIdIncluded)

    #   Check Byte 01 to see if ClassId is included
    classIdIncluded = checkForClassId(udpData[0:1])
    #print("  classIdIncluded   : %s" % classIdIncluded)

    #   Check Byte 01 to see if a Trailer is included
    trailerIncluded = checkForTrailer(udpData[0:1])
    #print("  trailerIncluded   : %s" % trailerIncluded)

    #   Check Byte 02 to see if a TimeStamp is included
    timeStampIncluded = checkForTimeStamp(udpData[1:2])
    #print("  timeStampIncluded : %s" % (timeStampIncluded) )

    #   Calculate the length of the VITA 49 header based on the above fields
    vrtHeaderLength = 4 #   Min header length
    vrtHeaderLength += 4 if streamIdIncluded[0] else 0
    vrtHeaderLength += 8 if classIdIncluded[0] else 0
    vrtHeaderLength += 12 if timeStampIncluded[0] else 0
    #print("Processed packet. VRT Header Length : %d" % (vrtHeaderLength) )
    #print('')
    #print("============================================")

    #   Return the vrt payload only (skip the vrt header)
    return udpData[vrtHeaderLength:]