summaryrefslogtreecommitdiffstats
path: root/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/text/cea/Cea708InitializationData.java
blob: 5d63ca8e82d45655b7a3635f95d83d0e455fba8d (plain)
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
49
50
51
52
53
54
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.mozilla.thirdparty.com.google.android.exoplayer2.text.cea;

import java.util.Collections;
import java.util.List;

/** Initialization data for CEA-708 decoders. */
public final class Cea708InitializationData {

  /**
   * Whether the closed caption service is formatted for displays with 16:9 aspect ratio. If false,
   * the closed caption service is formatted for 4:3 displays.
   */
  public final boolean isWideAspectRatio;

  private Cea708InitializationData(List<byte[]> initializationData) {
    isWideAspectRatio = initializationData.get(0)[0] != 0;
  }

  /**
   * Returns an object representation of CEA-708 initialization data
   *
   * @param initializationData Binary CEA-708 initialization data.
   * @return The object representation.
   */
  public static Cea708InitializationData fromData(List<byte[]> initializationData) {
    return new Cea708InitializationData(initializationData);
  }

  /**
   * Builds binary CEA-708 initialization data.
   *
   * @param isWideAspectRatio Whether the closed caption service is formatted for displays with 16:9
   *     aspect ratio.
   * @return Binary CEA-708 initializaton data.
   */
  public static List<byte[]> buildData(boolean isWideAspectRatio) {
    return Collections.singletonList(new byte[] {(byte) (isWideAspectRatio ? 1 : 0)});
  }
}