com.google.android.exoplayer2.util.Util.fromUtf8Bytes()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中com.google.android.exoplayer2.util.Util.fromUtf8Bytes()方法的一些代码示例,展示了Util.fromUtf8Bytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.fromUtf8Bytes()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:fromUtf8Bytes

Util.fromUtf8Bytes介绍

[英]Returns a new String constructed by decoding UTF-8 encoded bytes.
[中]返回通过解码UTF-8编码字节构造的新字符串。

代码示例

代码示例来源:origin: google/ExoPlayer

private static String toString(byte[] data) {
 if (data.length > 100) {
  return "<data is too long>";
 } else {
  return '\'' + Util.fromUtf8Bytes(data) + '\'';
 }
}

代码示例来源:origin: google/ExoPlayer

/**
 * Reads the next {@code length} bytes as UTF-8 characters. A terminating NUL byte is discarded,
 * if present.
 *
 * @param length The number of bytes to read.
 * @return The string, not including any terminating NUL byte.
 */
public String readNullTerminatedString(int length) {
 if (length == 0) {
  return "";
 }
 int stringLength = length;
 int lastIndex = position + length - 1;
 if (lastIndex < limit && data[lastIndex] == 0) {
  stringLength--;
 }
 String result = Util.fromUtf8Bytes(data, position, stringLength);
 position += length;
 return result;
}

代码示例来源:origin: google/ExoPlayer

private static long getManifestPublishTimeMsInEmsg(EventMessage eventMessage) {
 try {
  return parseXsDateTime(Util.fromUtf8Bytes(eventMessage.messageData));
 } catch (ParserException ignored) {
  // if we can't parse this event, ignore
  return C.TIME_UNSET;
 }
}

代码示例来源:origin: google/ExoPlayer

public static String getString(Context context, String fileName) throws IOException {
 return Util.fromUtf8Bytes(getByteArray(context, fileName));
}

代码示例来源:origin: google/ExoPlayer

/**
 * Reads up to the next NUL byte (or the limit) as UTF-8 characters.
 *
 * @return The string not including any terminating NUL byte, or null if the end of the data has
 *     already been reached.
 */
public @Nullable String readNullTerminatedString() {
 if (bytesLeft() == 0) {
  return null;
 }
 int stringLimit = position;
 while (stringLimit < limit && data[stringLimit] != 0) {
  stringLimit++;
 }
 String string = Util.fromUtf8Bytes(data, position, stringLimit - position);
 position = stringLimit;
 if (position < limit) {
  position++;
 }
 return string;
}

代码示例来源:origin: google/ExoPlayer

| (initializationBytes[29] & 0xFF);
String fontFamily =
  Util.fromUtf8Bytes(initializationBytes, 43, initializationBytes.length - 43);
defaultFontFamily = TX3G_SERIF.equals(fontFamily) ? C.SERIF_NAME : C.SANS_SERIF_NAME;

代码示例来源:origin: google/ExoPlayer

JSONObject responseJson = new JSONObject(Util.fromUtf8Bytes(response));
 StringBuilder adjustedResponseBuilder = new StringBuilder("{\"keys\":[");
 JSONArray keysArray = responseJson.getJSONArray("keys");
 return Util.getUtf8Bytes(adjustedResponseBuilder.toString());
} catch (JSONException e) {
 Log.e(TAG, "Failed to adjust response data: " + Util.fromUtf8Bytes(response), e);
 return response;

代码示例来源:origin: google/ExoPlayer

/**
 * Adjusts ClearKey request data obtained from the Android ClearKey CDM to be spec compliant.
 *
 * @param request The request data.
 * @return The adjusted request data.
 */
public static byte[] adjustRequestData(byte[] request) {
 if (Util.SDK_INT >= 27) {
  return request;
 }
 // Prior to O-MR1 the ClearKey CDM encoded the values in the "kids" array using Base64 encoding
 // rather than Base64Url encoding. See [Internal: b/64388098]. We know the exact request format
 // from the platform's InitDataParser.cpp. Since there aren't any "+" or "/" symbols elsewhere
 // in the request, it's safe to fix the encoding by replacement through the whole request.
 String requestString = Util.fromUtf8Bytes(request);
 return Util.getUtf8Bytes(base64ToBase64Url(requestString));
}

代码示例来源:origin: google/ExoPlayer

/**
 * @param initializationData Optional initialization data for the decoder. If not null or empty,
 *     the initialization data must consist of two byte arrays. The first must contain an SSA
 *     format line. The second must contain an SSA header that will be assumed common to all
 *     samples.
 */
public SsaDecoder(List<byte[]> initializationData) {
 super("SsaDecoder");
 if (initializationData != null && !initializationData.isEmpty()) {
  haveInitializationData = true;
  String formatLine = Util.fromUtf8Bytes(initializationData.get(0));
  Assertions.checkArgument(formatLine.startsWith(FORMAT_LINE_PREFIX));
  parseFormatLine(formatLine);
  parseHeader(new ParsableByteArray(initializationData.get(1)));
 } else {
  haveInitializationData = false;
 }
}

代码示例来源:origin: google/ExoPlayer

@Override
public byte[] executeProvisionRequest(UUID uuid, ProvisionRequest request) throws IOException {
 String url =
   request.getDefaultUrl() + "&signedRequest=" + Util.fromUtf8Bytes(request.getData());
 return executePost(dataSourceFactory, url, Util.EMPTY_BYTE_ARRAY, null);
}

代码示例来源:origin: google/ExoPlayer

String line = Util.fromUtf8Bytes(data, position, lineLimit - position);
position = lineLimit;
if (position == limit) {

代码示例来源:origin: google/ExoPlayer

public static String getString(Context context, String fileName) throws IOException {
 return Util.fromUtf8Bytes(getByteArray(context, fileName));
}

代码示例来源:origin: google/ExoPlayer

private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
   int remainingCueBoxBytes) throws SubtitleDecoderException {
 builder.reset();
 while (remainingCueBoxBytes > 0) {
  if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
   throw new SubtitleDecoderException("Incomplete vtt cue box header found.");
  }
  int boxSize = sampleData.readInt();
  int boxType = sampleData.readInt();
  remainingCueBoxBytes -= BOX_HEADER_SIZE;
  int payloadLength = boxSize - BOX_HEADER_SIZE;
  String boxPayload =
    Util.fromUtf8Bytes(sampleData.data, sampleData.getPosition(), payloadLength);
  sampleData.skipBytes(payloadLength);
  remainingCueBoxBytes -= payloadLength;
  if (boxType == TYPE_sttg) {
   WebvttCueParser.parseCueSettingsList(boxPayload, builder);
  } else if (boxType == TYPE_payl) {
   WebvttCueParser.parseCueText(null, boxPayload.trim(), builder, Collections.emptyList());
  } else {
   // Other VTTCueBox children are still not supported and are ignored.
  }
 }
 return builder.build();
}

代码示例来源:origin: google/ExoPlayer

@Test
public void testPartialReads() throws IOException {
 byte[] buffer = new byte[18];
 DataSpec dataSpec = buildDataSpec("data:,012345678901234567");
 assertThat(schemeDataDataSource.open(dataSpec)).isEqualTo(18);
 assertThat(schemeDataDataSource.read(buffer, 0, 9)).isEqualTo(9);
 assertThat(schemeDataDataSource.read(buffer, 3, 0)).isEqualTo(0);
 assertThat(schemeDataDataSource.read(buffer, 9, 15)).isEqualTo(9);
 assertThat(schemeDataDataSource.read(buffer, 1, 0)).isEqualTo(0);
 assertThat(schemeDataDataSource.read(buffer, 1, 1)).isEqualTo(RESULT_END_OF_INPUT);
 assertThat(Util.fromUtf8Bytes(buffer, 0, 18)).isEqualTo("012345678901234567");
}

代码示例来源:origin: lizixian18/StarrySky

CHANNEL_ID,
          Util.fromUtf8Bytes(taskState.action.data));
} else if (taskState.state == TaskState.STATE_FAILED) {
          CHANNEL_ID,
          Util.fromUtf8Bytes(taskState.action.data));

相关文章