Home telegram - mediaTrackFrameBuffer
Post
Cancel

telegram - mediaTrackFrameBuffer

class MediaTrackFrameBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
private let stallDuration: Double
private let lowWaterDuration: Double
private let highWaterDuration: Double

private let frameSource: MediaFrameSource
private let decoder: MediaTrackFrameDecoder
private let type: MediaTrackFrameType
public let duration: CMTime
let rotationAngle: Double
let aspect: Double

var statusUpdated: () -> Void = { }
private var frameSourceSinkIndex: Int?
private var frames: [MediaTrackDecodableFrame] = []
private var endOfStream = false
private var bufferedUntilTime: CMTime?

init(frameSource: MediaFrameSource, decoder: MediaTrackFrameDecoder, type: MediaTrackFrameType, duration: CMTime, rotationAngle: Double, aspect:
Double, stallDuration: Double = 1.0, lowWaterDuration: Double = 2.0, highWaterDuration: Double = 3.0) {
    self.frameSource = frameSource
    self.type = type
    self.decoder = decoder
    self.duration = duration
    self.rotationAngle = rotationAngle
    self.aspect = aspect
    self.stallDuration = stallDuration
    self.lowWaterDuration = lowWaterDuration
    self.highWaterDuration = highWaterDuration
    /// addEventSink
    self.frameSourceSinkIndex = self.frameSource.addEventSink { [weak self] event in
        if let strongSelf = self {
            switch event {
                case let .frames(frames):
                    var filteredFrames: [MediaTrackDecodableFrame] = []
                    for frame in frames {
                        if frame.type == type {
                            filteredFrames.append(frame)
                        }
                    }
                    if !filteredFrames.isEmpty {
                        strongSelf.addFrames(filteredFrames)
                    }
                case .endOfStream:
                    strongSelf.endOfStreamReached()
            }
        }
    }
}

class MediaFrameSourceSeekResult

1
2
3
public let buffers: MediaPlaybackBuffers
public let extraDecodedVideoFrames: [MediaTrackFrame]
public let timestamp: CMTime
This post is licensed under CC BY 4.0 by the author.