Skip to content

Commit

Permalink
Allow dynamic changes of format description.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Apr 23, 2024
1 parent 78a945a commit d4f9168
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Sources/Codec/VideoCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ final class VideoCodec<T: VideoCodecDelegate> {
private var startedAt: CMTime = .zero
private(set) var inputFormat: CMFormatDescription? {
didSet {
guard !CMFormatDescriptionEqual(inputFormat, otherFormatDescription: oldValue) else {
guard inputFormat != oldValue else {
return
}
invalidateSession = true
outputFormat = nil
}
}
private(set) var outputFormat: CMFormatDescription? {
didSet {
guard !CMFormatDescriptionEqual(outputFormat, otherFormatDescription: oldValue) else {
guard outputFormat != oldValue else {
return
}
delegate?.videoCodec(self, didOutput: outputFormat)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ISO/ESSpecificData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum ESStreamType: UInt8 {
}
}

struct ESSpecificData {
struct ESSpecificData: Equatable {
static let fixedHeaderSize: Int = 5

var streamType: ESStreamType = .unspecific
Expand Down
5 changes: 4 additions & 1 deletion Sources/ISO/TSReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public class TSReader<T: TSReaderDelegate> {
didSet {
for (_, pmt) in pmt {
for data in pmt.elementaryStreamSpecificData {
esSpecData[data.elementaryPID] = data
if esSpecData[data.elementaryPID] != data {
esSpecData[data.elementaryPID] = data
formatDescriptions[data.elementaryPID] = nil
}
}
}
if logger.isEnabledFor(level: .trace) {
Expand Down

0 comments on commit d4f9168

Please sign in to comment.