Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/SCTE35Parser/ATSC/ATSCContentIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ extension ATSCContentIdentifier {
InvalidATSCContentIdentifierInUPIDInfo(upidLength: Int(upidLength))
)
}
self.tsid = bitReader.uint16(fromBits: 16)
_ = bitReader.bits(count: 2)
self.endOfDay = bitReader.byte(fromBits: 5)
self.uniqueFor = bitReader.uint16(fromBits: 9)
self.contentID = bitReader.string(fromBytes: UInt(contentIDLength))
self.tsid = try bitReader.uint16(fromBits: 16)
_ = try bitReader.bits(count: 2)
self.endOfDay = try bitReader.byte(fromBits: 5)
self.uniqueFor = try bitReader.uint16(fromBits: 9)
self.contentID = try bitReader.string(fromBytes: UInt(contentIDLength))
}
}
32 changes: 16 additions & 16 deletions Sources/SCTE35Parser/BitParser/BitByteData/Sources/BitReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,56 @@ public protocol BitReader: AnyObject {
init(_ byteReader: ByteReader)

/// Reads bit and returns it, advancing by one BIT position.
func bit() -> UInt8
func bit() throws -> UInt8

/// Reads `count` bits and returns them as an array of `UInt8`, advancing by `count` BIT positions.
func bits(count: Int) -> [UInt8]
func bits(count: Int) throws -> [UInt8]

/// Reads `fromBits` bits and returns them as an `Int` number, advancing by `fromBits` BIT positions.
func int(fromBits count: Int) -> Int
func int(fromBits count: Int) throws -> Int

/// Reads `fromBits` bits and returns them as an `UInt8` number, advancing by `fromBits` BIT positions.
func byte(fromBits count: Int) -> UInt8
func byte(fromBits count: Int) throws -> UInt8

/// Reads `fromBits` bits and returns them as an `UInt16` number, advancing by `fromBits` BIT positions.
func uint16(fromBits count: Int) -> UInt16
func uint16(fromBits count: Int) throws -> UInt16

/// Reads `fromBits` bits and returns them as an `UInt32` number, advancing by `fromBits` BIT positions.
func uint32(fromBits count: Int) -> UInt32
func uint32(fromBits count: Int) throws -> UInt32

/// Reads `fromBits` bits and returns them as an `UInt64` number, advancing by `fromBits` BIT positions.
func uint64(fromBits count: Int) -> UInt64
func uint64(fromBits count: Int) throws -> UInt64

/// Aligns reader's BIT pointer to the BYTE border, i.e. moves BIT pointer to the first BIT of the next BYTE.
func align()

// MARK: ByteReader's methods.

/// Reads byte and returns it, advancing by one BYTE position.
func byte() -> UInt8
func byte() throws -> UInt8

/// Reads `count` bytes and returns them as an array of `UInt8`, advancing by `count` BYTE positions.
func bytes(count: Int) -> [UInt8]
func bytes(count: Int) throws -> [UInt8]

/// Reads `fromBytes` bytes and returns them as an `Int` number, advancing by `fromBytes` BYTE positions.
func int(fromBytes count: Int) -> Int
func int(fromBytes count: Int) throws -> Int

/// Reads 8 bytes and returns them as a `UInt64` number, advancing by 8 BYTE positions.
func uint64() -> UInt64
func uint64() throws -> UInt64

/// Reads `fromBytes` bytes and returns them as a `UInt64` number, advancing by 8 BYTE positions.
func uint64(fromBytes count: Int) -> UInt64
func uint64(fromBytes count: Int) throws -> UInt64

/// Reads 4 bytes and returns them as a `UInt32` number, advancing by 4 BYTE positions.
func uint32() -> UInt32
func uint32() throws -> UInt32

/// Reads `fromBytes` bytes and returns them as a `UInt32` number, advancing by 8 BYTE positions.
func uint32(fromBytes count: Int) -> UInt32
func uint32(fromBytes count: Int) throws -> UInt32

/// Reads 2 bytes and returns them as a `UInt16` number, advancing by 2 BYTE positions.
func uint16() -> UInt16
func uint16() throws -> UInt16

/// Reads `fromBytes` bytes and returns them as a `UInt16` number, advancing by 8 BYTE positions.
func uint16(fromBytes count: Int) -> UInt16
func uint16(fromBytes count: Int) throws -> UInt16

}
4 changes: 2 additions & 2 deletions Sources/SCTE35Parser/BitParser/DataBitReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension DataBitReader {
}
}

func string(fromBytes bytes: UInt) -> String {
return String(self.bytes(count: Int(bytes)).map { Character(UnicodeScalar($0)) })
func string(fromBytes bytes: UInt) throws -> String {
return try String(self.bytes(count: Int(bytes)).map { Character(UnicodeScalar($0)) })
}
}
Loading