com.google.android.exoplayer2.metadata.id3.MlltFrame Java Examples

The following examples show how to use com.google.android.exoplayer2.metadata.id3.MlltFrame. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MlltSeeker.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an {@link MlltSeeker} for seeking in the stream.
 *
 * @param firstFramePosition The position of the start of the first frame in the stream.
 * @param mlltFrame The MLLT frame with seeking metadata.
 * @return An {@link MlltSeeker} for seeking in the stream.
 */
public static MlltSeeker create(long firstFramePosition, MlltFrame mlltFrame) {
  int referenceCount = mlltFrame.bytesDeviations.length;
  long[] referencePositions = new long[1 + referenceCount];
  long[] referenceTimesMs = new long[1 + referenceCount];
  referencePositions[0] = firstFramePosition;
  referenceTimesMs[0] = 0;
  long position = firstFramePosition;
  long timeMs = 0;
  for (int i = 1; i <= referenceCount; i++) {
    position += mlltFrame.bytesBetweenReference + mlltFrame.bytesDeviations[i - 1];
    timeMs += mlltFrame.millisecondsBetweenReference + mlltFrame.millisecondsDeviations[i - 1];
    referencePositions[i] = position;
    referenceTimesMs[i] = timeMs;
  }
  return new MlltSeeker(referencePositions, referenceTimesMs);
}
 
Example #2
Source File: MlltSeeker.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an {@link MlltSeeker} for seeking in the stream.
 *
 * @param firstFramePosition The position of the start of the first frame in the stream.
 * @param mlltFrame The MLLT frame with seeking metadata.
 * @return An {@link MlltSeeker} for seeking in the stream.
 */
public static MlltSeeker create(long firstFramePosition, MlltFrame mlltFrame) {
  int referenceCount = mlltFrame.bytesDeviations.length;
  long[] referencePositions = new long[1 + referenceCount];
  long[] referenceTimesMs = new long[1 + referenceCount];
  referencePositions[0] = firstFramePosition;
  referenceTimesMs[0] = 0;
  long position = firstFramePosition;
  long timeMs = 0;
  for (int i = 1; i <= referenceCount; i++) {
    position += mlltFrame.bytesBetweenReference + mlltFrame.bytesDeviations[i - 1];
    timeMs += mlltFrame.millisecondsBetweenReference + mlltFrame.millisecondsDeviations[i - 1];
    referencePositions[i] = position;
    referenceTimesMs[i] = timeMs;
  }
  return new MlltSeeker(referencePositions, referenceTimesMs);
}
 
Example #3
Source File: MlltSeeker.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an {@link MlltSeeker} for seeking in the stream.
 *
 * @param firstFramePosition The position of the start of the first frame in the stream.
 * @param mlltFrame The MLLT frame with seeking metadata.
 * @return An {@link MlltSeeker} for seeking in the stream.
 */
public static MlltSeeker create(long firstFramePosition, MlltFrame mlltFrame) {
  int referenceCount = mlltFrame.bytesDeviations.length;
  long[] referencePositions = new long[1 + referenceCount];
  long[] referenceTimesMs = new long[1 + referenceCount];
  referencePositions[0] = firstFramePosition;
  referenceTimesMs[0] = 0;
  long position = firstFramePosition;
  long timeMs = 0;
  for (int i = 1; i <= referenceCount; i++) {
    position += mlltFrame.bytesBetweenReference + mlltFrame.bytesDeviations[i - 1];
    timeMs += mlltFrame.millisecondsBetweenReference + mlltFrame.millisecondsDeviations[i - 1];
    referencePositions[i] = position;
    referenceTimesMs[i] = timeMs;
  }
  return new MlltSeeker(referencePositions, referenceTimesMs);
}
 
Example #4
Source File: Mp3Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Nullable
private static MlltSeeker maybeHandleSeekMetadata(Metadata metadata, long firstFramePosition) {
  if (metadata != null) {
    int length = metadata.length();
    for (int i = 0; i < length; i++) {
      Metadata.Entry entry = metadata.get(i);
      if (entry instanceof MlltFrame) {
        return MlltSeeker.create(firstFramePosition, (MlltFrame) entry);
      }
    }
  }
  return null;
}
 
Example #5
Source File: Mp3Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
private static MlltSeeker maybeHandleSeekMetadata(Metadata metadata, long firstFramePosition) {
  if (metadata != null) {
    int length = metadata.length();
    for (int i = 0; i < length; i++) {
      Metadata.Entry entry = metadata.get(i);
      if (entry instanceof MlltFrame) {
        return MlltSeeker.create(firstFramePosition, (MlltFrame) entry);
      }
    }
  }
  return null;
}
 
Example #6
Source File: Mp3Extractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
private static MlltSeeker maybeHandleSeekMetadata(Metadata metadata, long firstFramePosition) {
  if (metadata != null) {
    int length = metadata.length();
    for (int i = 0; i < length; i++) {
      Metadata.Entry entry = metadata.get(i);
      if (entry instanceof MlltFrame) {
        return MlltSeeker.create(firstFramePosition, (MlltFrame) entry);
      }
    }
  }
  return null;
}