# All files / src/utils output-filter.ts

100% Statements 15/15
100% Branches 6/6
100% Functions 3/3
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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

    3140x
    628x
    628x
    628x
    628x
    628x

    4x
    1x

    3x
    3x

    6x
    4x

    6x
    6x
    6x

     import { CaptionScreen } from './cea-608-parser';

    export default class OutputFilter {
      timelineController: any;
      trackName: string;
      startTime: number | null;
      endTime: number | null;
      screen: CaptionScreen | null;

      // TODO(typescript-timelineController)
      constructor (timelineController: any, trackName: string) {
        this.timelineController = timelineController;
        this.trackName = trackName;
        this.startTime = null;
        this.endTime = null;
        this.screen = null;
      }

      dispatchCue () {
        if (this.startTime === null) {
          return;
        }

        this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen);
        this.startTime = null;
      }

      newCue (startTime: number, endTime: number, screen: CaptionScreen) {
        if (this.startTime === null || this.startTime > startTime) {
          this.startTime = startTime;
        }

        this.endTime = endTime;
        this.screen = screen;
        this.timelineController.createCaptionsTrack(this.trackName);
      }
    }