com.google.android.exoplayer.util.Util Java Examples

The following examples show how to use com.google.android.exoplayer.util.Util. 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: SmoothStreamingManifest.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public StreamElement(Uri baseUri, String chunkTemplate, int type, String subType,
    long timescale, String name, int qualityLevels, int maxWidth, int maxHeight,
    int displayWidth, int displayHeight, String language, TrackElement[] tracks,
    List<Long> chunkStartTimes, long lastChunkDuration) {
  this.baseUri = baseUri;
  this.chunkTemplate = chunkTemplate;
  this.type = type;
  this.subType = subType;
  this.timescale = timescale;
  this.name = name;
  this.qualityLevels = qualityLevels;
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  this.displayWidth = displayWidth;
  this.displayHeight = displayHeight;
  this.language = language;
  this.tracks = tracks;
  this.chunkCount = chunkStartTimes.size();
  this.chunkStartTimes = chunkStartTimes;
  lastChunkDurationUs =
      Util.scaleLargeTimestamp(lastChunkDuration, C.MICROS_PER_SECOND, timescale);
  chunkStartTimesUs =
      Util.scaleLargeTimestamps(chunkStartTimes, C.MICROS_PER_SECOND, timescale);
}
 
Example #2
Source File: MediaCodecTrackRenderer.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
private void flushCodec() throws ExoPlaybackException {
  codecHotswapTimeMs = -1;
  inputIndex = -1;
  outputIndex = -1;
  waitingForFirstSyncFrame = true;
  decodeOnlyPresentationTimestamps.clear();
  // Workaround for framework bugs.
  // See [Internal: b/8347958], [Internal: b/8578467], [Internal: b/8543366].
  if (Util.SDK_INT >= 18) {
    codec.flush();
  } else {
    releaseCodec();
    maybeInitCodec();
  }
  if (codecReconfigured && format != null) {
    // Any reconfiguration data that we send shortly before the flush may be discarded. We
    // avoid this issue by sending reconfiguration data following every flush.
    codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
  }
}
 
Example #3
Source File: MediaCodecTrackRenderer.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * @param source The upstream source from which the renderer obtains samples.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisision. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public MediaCodecTrackRenderer(SampleSource source, DrmSessionManager drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler, EventListener eventListener) {
  Assertions.checkState(Util.SDK_INT >= 16);
  this.source = source;
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
  codecCounters = new CodecCounters();
  sampleHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_DISABLED);
  formatHolder = new MediaFormatHolder();
  decodeOnlyPresentationTimestamps = new ArrayList<Long>();
  outputBufferInfo = new MediaCodec.BufferInfo();

}
 
Example #4
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
private DemoPlayer.RendererBuilder getRendererBuilder() {
    String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
    switch (contentType) {
        case Util.TYPE_DASH:
            return new DashRendererBuilder(this, userAgent, contentUri.toString());
        default:
            throw new IllegalStateException("Unsupported type: " + contentType);
    }
}
 
Example #5
Source File: MediaFormat.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
private boolean equalsInternal(MediaFormat other, boolean ignoreMaxDimensions) {
  if (maxInputSize != other.maxInputSize || width != other.width || height != other.height
      || pixelWidthHeightRatio != other.pixelWidthHeightRatio
      || (!ignoreMaxDimensions && (maxWidth != other.maxWidth || maxHeight != other.maxHeight))
      || channelCount != other.channelCount || sampleRate != other.sampleRate
      || !Util.areEqual(mimeType, other.mimeType)
      || bitrate != other.bitrate
      || initializationData.size() != other.initializationData.size()) {
    return false;
  }
  for (int i = 0; i < initializationData.size(); i++) {
    if (!Arrays.equals(initializationData.get(i), other.initializationData.get(i))) {
      return false;
    }
  }
  return true;
}
 
Example #6
Source File: SubtitleView.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  final int widthSpec = MeasureSpec.getSize(widthMeasureSpec);

  if (computeMeasurements(widthSpec)) {
    final StaticLayout layout = this.layout;
    final int paddingX = getPaddingLeft() + getPaddingRight() + innerPaddingX * 2;
    final int height = layout.getHeight() + getPaddingTop() + getPaddingBottom();
    int width = 0;
    int lineCount = layout.getLineCount();
    for (int i = 0; i < lineCount; i++) {
      width = Math.max((int) Math.ceil(layout.getLineWidth(i)), width);
    }
    width += paddingX;
    setMeasuredDimension(width, height);
  } else if (Util.SDK_INT >= 11) {
    setTooSmallMeasureDimensionV11();
  } else {
    setMeasuredDimension(0, 0);
  }
}
 
Example #7
Source File: AC3ReaderATSC.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
@Override
public void consume(ParsableByteArray data, long pesTimeUs, boolean startOfPacket) {
    Util.printByteArray("AC3 reader !!!!!!!!!!", data.data, 0, 30);
    data.setPosition(1);
    if (!hasMediaFormat()) {
        parseAudioDescriptor(data);
    }
    else {
        data.skip(audiodesclen);
    }

    // move to access unit
    if (writingSample())
        appendData(data, data.bytesLeft());

    // ISO/IEC 13818-1 [1] specifies a fixed value for BSn (3584 bytes)

}
 
Example #8
Source File: IjkExoMediaPlayer.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
private RendererBuilder getRendererBuilder() {
    Uri contentUri = Uri.parse(mDataSource);
    String userAgent = Util.getUserAgent(mAppContext, "IjkExoMediaPlayer");
    int contentType = inferContentType(contentUri);
    switch (contentType) {
        case Util.TYPE_SS:
            return new SmoothStreamingRendererBuilder(mAppContext, userAgent, contentUri.toString(),
                    new SmoothStreamingTestMediaDrmCallback());
     /*   case Util.TYPE_DASH:
            return new DashRendererBuilder(mAppContext , userAgent, contentUri.toString(),
                    new WidevineTestMediaDrmCallback(contentId, provider));*/
        case Util.TYPE_HLS:
            return new HlsRendererBuilder(mAppContext, userAgent, contentUri.toString());
        case Util.TYPE_OTHER:
        default:
            return new ExtractorRendererBuilder(mAppContext, userAgent, contentUri);
    }
}
 
Example #9
Source File: MediaCodecUtil.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the name of the best decoder and its capabilities for the given mimeType.
 */
private static synchronized Pair<String, CodecCapabilities> getMediaCodecInfo(
    String mimeType, boolean secure) throws DecoderQueryException {
  CodecKey key = new CodecKey(mimeType, secure);
  if (codecs.containsKey(key)) {
    return codecs.get(key);
  }
  MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
      ? new MediaCodecListCompatV21(secure) : new MediaCodecListCompatV16();
  Pair<String, CodecCapabilities> codecInfo = getMediaCodecInfo(key, mediaCodecList);
  // TODO: Verify this cannot occur on v22, and change >= to == [Internal: b/18678462].
  if (secure && codecInfo == null && Util.SDK_INT >= 21) {
    // Some devices don't list secure decoders on API level 21. Try the legacy path.
    mediaCodecList = new MediaCodecListCompatV16();
    codecInfo = getMediaCodecInfo(key, mediaCodecList);
    if (codecInfo != null) {
      Log.w(TAG, "MediaCodecList API didn't list secure decoder for: " + mimeType
          + ". Assuming: " + codecInfo.first);
    }
  }
  return codecInfo;
}
 
Example #10
Source File: CommonMp4AtomParsers.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a trak atom (defined in 14496-12)
 *
 * @param trak Atom to parse.
 * @param mvhd Movie header atom, used to get the timescale.
 * @return A {@link Track} instance.
 */
public static Track parseTrak(Atom.ContainerAtom trak, Atom.LeafAtom mvhd) {
  Atom.ContainerAtom mdia = trak.getContainerAtomOfType(Atom.TYPE_mdia);
  int trackType = parseHdlr(mdia.getLeafAtomOfType(Atom.TYPE_hdlr).data);
  Assertions.checkState(trackType == Track.TYPE_AUDIO || trackType == Track.TYPE_VIDEO
      || trackType == Track.TYPE_TEXT || trackType == Track.TYPE_TIME_CODE);

  Pair<Integer, Long> header = parseTkhd(trak.getLeafAtomOfType(Atom.TYPE_tkhd).data);
  int id = header.first;
  long duration = header.second;
  long movieTimescale = parseMvhd(mvhd.data);
  long durationUs;
  if (duration == -1) {
    durationUs = C.UNKNOWN_TIME_US;
  } else {
    durationUs = Util.scaleLargeTimestamp(duration, C.MICROS_PER_SECOND, movieTimescale);
  }
  Atom.ContainerAtom stbl = mdia.getContainerAtomOfType(Atom.TYPE_minf)
      .getContainerAtomOfType(Atom.TYPE_stbl);

  long mediaTimescale = parseMdhd(mdia.getLeafAtomOfType(Atom.TYPE_mdhd).data);
  Pair<MediaFormat, TrackEncryptionBox[]> sampleDescriptions =
      parseStsd(stbl.getLeafAtomOfType(Atom.TYPE_stsd).data);
  return new Track(id, trackType, mediaTimescale, durationUs, sampleDescriptions.first,
        sampleDescriptions.second);
}
 
Example #11
Source File: AudioTrack.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public AudioTrack() {
  releasingConditionVariable = new ConditionVariable(true);
  if (Util.SDK_INT >= 18) {
    try {
      getLatencyMethod =
          android.media.AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
    } catch (NoSuchMethodException e) {
      // There's no guarantee this method exists. Do nothing.
    }
  }
  playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
  volume = 1.0f;
  startMediaTimeState = START_NOT_SET;
}
 
Example #12
Source File: FrameworkSampleExtractor.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new sample extractor reading from the specified {@code uri}.
 *
 * @param context Context for resolving {@code uri}.
 * @param uri The content URI from which to extract data.
 * @param headers Headers to send with requests for data.
 */
public FrameworkSampleExtractor(Context context, Uri uri, Map<String, String> headers) {
  Assertions.checkState(Util.SDK_INT >= 16);

  this.context = Assertions.checkNotNull(context);
  this.uri = Assertions.checkNotNull(uri);
  this.headers = headers;

  fileDescriptor = null;
  fileDescriptorOffset = 0;
  fileDescriptorLength = 0;

  mediaExtractor = new MediaExtractor();
}
 
Example #13
Source File: SegmentBase.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * @see DashSegmentIndex#getTimeUs(int)
 */
public final long getSegmentTimeUs(int sequenceNumber) {
  long unscaledSegmentTime;
  if (segmentTimeline != null) {
    unscaledSegmentTime = segmentTimeline.get(sequenceNumber - startNumber).startTime
        - presentationTimeOffset;
  } else {
    unscaledSegmentTime = (sequenceNumber - startNumber) * duration;
  }
  return Util.scaleLargeTimestamp(unscaledSegmentTime, C.MICROS_PER_SECOND, timescale);
}
 
Example #14
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
private void configureSubtitleView() {
    CaptionStyleCompat style;
    float fontScale;
    if (Util.SDK_INT >= 19) {
        style = getUserCaptionStyleV19();
        fontScale = getUserCaptionFontScaleV19();
    } else {
        style = CaptionStyleCompat.DEFAULT;
        fontScale = 1.0f;
    }
    subtitleLayout.setStyle(style);
    subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale);
}
 
Example #15
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Exception e) {
    String errorString = null;
    if (e instanceof UnsupportedDrmException) {
        // Special case DRM failures.
        UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
        errorString = getString(Util.SDK_INT < 18 ? R.string.video_error_drm_not_supported
                : unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                ? R.string.video_error_drm_unsupported_scheme : R.string.video_error_drm_unknown);
    } else if (e instanceof ExoPlaybackException
            && e.getCause() instanceof DecoderInitializationException) {
        // Special case for decoder initialization failures.
        DecoderInitializationException decoderInitializationException =
                (DecoderInitializationException) e.getCause();
        if (decoderInitializationException.decoderName == null) {
            if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
                errorString = getString(R.string.video_error_querying_decoders);
            } else if (decoderInitializationException.secureDecoderRequired) {
                errorString = getString(R.string.video_error_no_secure_decoder,
                        decoderInitializationException.mimeType);
            } else {
                errorString = getString(R.string.video_error_no_decoder,
                        decoderInitializationException.mimeType);
            }
        } else {
            errorString = getString(R.string.video_error_instantiating_decoder,
                    decoderInitializationException.decoderName);
        }
    }
    if (errorString != null) {
        Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
    }
    playerNeedsPrepare = true;
    showControls();
}
 
Example #16
Source File: AudioTrack.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the audio track for writing new buffers using {@link #handleBuffer}.
 *
 * @param sessionId Audio track session identifier to re-use, or {@link #SESSION_ID_NOT_SET} to
 *     create a new one.
 * @return The new (or re-used) session identifier.
 */
public int initialize(int sessionId) throws InitializationException {
  // If we're asynchronously releasing a previous audio track then we block until it has been
  // released. This guarantees that we cannot end up in a state where we have multiple audio
  // track instances. Without this guarantee it would be possible, in extreme cases, to exhaust
  // the shared memory that's available for audio track buffers. This would in turn cause the
  // initialization of the audio track to fail.
  releasingConditionVariable.block();

  if (sessionId == SESSION_ID_NOT_SET) {
    audioTrack = new android.media.AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
        channelConfig, encoding, bufferSize, android.media.AudioTrack.MODE_STREAM);
  } else {
    // Re-attach to the same audio session.
    audioTrack = new android.media.AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
        channelConfig, encoding, bufferSize, android.media.AudioTrack.MODE_STREAM, sessionId);
  }

  checkAudioTrackInitialized();
  if (Util.SDK_INT >= 19) {
    audioTrackUtil = new AudioTrackUtilV19(audioTrack);
  } else {
    audioTrackUtil = new AudioTrackUtil(audioTrack);
  }
  setVolume(volume);
  return audioTrack.getAudioSessionId();
}
 
Example #17
Source File: AudioTrack.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/** Sets the playback volume. */
public void setVolume(float volume) {
  this.volume = volume;
  if (isInitialized()) {
    if (Util.SDK_INT >= 21) {
      setVolumeV21(audioTrack, volume);
    } else {
      setVolumeV3(audioTrack, volume);
    }
  }
}
 
Example #18
Source File: MediaCodecUtil.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private static boolean isAdaptive(CodecCapabilities capabilities) {
  if (Util.SDK_INT >= 19) {
    return isAdaptiveV19(capabilities);
  } else {
    return false;
  }
}
 
Example #19
Source File: RawHttpDataSource.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public boolean evaluate(String contentType) {
  contentType = Util.toLowerInvariant(contentType);
  return !TextUtils.isEmpty(contentType)
      && (!contentType.contains("text") || contentType.contains("text/vtt"))
      && !contentType.contains("html") && !contentType.contains("xml");
}
 
Example #20
Source File: HttpDataSource.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public boolean evaluate(String contentType) {
  contentType = Util.toLowerInvariant(contentType);
  return !TextUtils.isEmpty(contentType)
      && (!contentType.contains("text") || contentType.contains("text/vtt"))
      && !contentType.contains("html") && !contentType.contains("xml");
}
 
Example #21
Source File: UdpUnicastDataSource.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public int read(byte[] buffer, int offset, int readLength) throws IOException {
    if (readLength > rcvBufferSize) {
        rcvBufferSize = readLength+1;
        socket.setReceiveBufferSize(rcvBufferSize);
    }
    DatagramPacket packet = new DatagramPacket(buffer, offset, readLength);
    socket.receive(packet);
    Log.i(TAG, ">>>> read "+packet.getLength() + " MMMMMMMMMMM " + readLength);
    Util.printByteArray(TAG, packet.getData(), offset, 50);
    Util.findThisByte("sync interval ", (byte) 0x47, packet.getData());
    return packet.getLength();
}
 
Example #22
Source File: VideoPlayerView.java    From iview-android-tv with MIT License 5 votes vote down vote up
public void configureSubtitleView() {
    CaptionStyleCompat captionStyle;
    float captionFontScale;
    if (Util.SDK_INT >= 19) {
        captionStyle = getUserCaptionStyleV19();
        captionFontScale = getUserCaptionFontScaleV19();
    } else {
        captionStyle = CaptionStyleCompat.DEFAULT;
        captionFontScale = 1.0f;
    }
    subtitleLayout.setStyle(captionStyle);
    subtitleLayout.setFontScale(captionFontScale);
}
 
Example #23
Source File: Mp4TrackSampleTable.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the sample index of the closest synchronization sample at or before the given
 * timestamp, if one is available.
 *
 * @param timeUs Timestamp adjacent to which to find a synchronization sample.
 * @return Index of the synchronization sample, or {@link Mp4Util#NO_SAMPLE} if none.
 */
public int getIndexOfEarlierOrEqualSynchronizationSample(long timeUs) {
  int startIndex = Util.binarySearchFloor(timestampsUs, timeUs, true, false);
  for (int i = startIndex; i >= 0; i--) {
    if (timestampsUs[i] <= timeUs && (flags[i] & C.SAMPLE_FLAG_SYNC) != 0) {
      return i;
    }
  }

  return Mp4Util.NO_SAMPLE;
}
 
Example #24
Source File: VideoPlayerActivity.java    From iview-android-tv with MIT License 5 votes vote down vote up
@Override
public void onError(Exception e) {
    if (e instanceof UnsupportedDrmException) {
        // Special case DRM failures.
        UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
        int stringId = Util.SDK_INT < 18 ? R.string.drm_error_not_supported
                : unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                ? R.string.drm_error_unsupported_scheme : R.string.drm_error_unknown;
        Toast.makeText(getApplicationContext(), stringId, Toast.LENGTH_LONG).show();
    }
    playerNeedsPrepare = true;
    videoPlayerView.showControls();
}
 
Example #25
Source File: PlayerActivity.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private void configureSubtitleView() {
  CaptionStyleCompat captionStyle;
  float captionTextSize = getCaptionFontSize();
  if (Util.SDK_INT >= 19) {
    captionStyle = getUserCaptionStyleV19();
    captionTextSize *= getUserCaptionFontScaleV19();
  } else {
    captionStyle = CaptionStyleCompat.DEFAULT;
  }
  subtitleView.setStyle(captionStyle);
  subtitleView.setTextSize(captionTextSize);
}
 
Example #26
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
private DemoPlayer.RendererBuilder getRendererBuilder() {
    String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
    switch (contentType) {
        case Util.TYPE_DASH:
            return new DashRendererBuilder(this, userAgent, contentUri.toString());
        default:
            throw new IllegalStateException("Unsupported type: " + contentType);
    }
}
 
Example #27
Source File: CryptoInfo.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, int mode) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  if (Util.SDK_INT >= 16) {
    updateFrameworkCryptoInfoV16();
  }
}
 
Example #28
Source File: Eia608TrackRenderer.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private void invokeRenderer(String text) {
  if (Util.areEqual(lastRenderedCaption, text)) {
    // No change.
    return;
  }
  this.lastRenderedCaption = text;
  if (textRendererHandler != null) {
    textRendererHandler.obtainMessage(MSG_INVOKE_RENDERER, text).sendToTarget();
  } else {
    invokeRendererInternal(text);
  }
}
 
Example #29
Source File: CaptionStyleCompat.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link CaptionStyleCompat} equivalent to a provided {@link CaptionStyle}.
 *
 * @param captionStyle A {@link CaptionStyle}.
 * @return The equivalent {@link CaptionStyleCompat}.
 */
@TargetApi(19)
public static CaptionStyleCompat createFromCaptionStyle(
    CaptioningManager.CaptionStyle captionStyle) {
  if (Util.SDK_INT >= 21) {
    return createFromCaptionStyleV21(captionStyle);
  } else {
    // Note - Any caller must be on at least API level 19 or greater (because CaptionStyle did
    // not exist in earlier API levels).
    return createFromCaptionStyleV19(captionStyle);
  }
}
 
Example #30
Source File: Mp4TrackSampleTable.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the sample index of the closest synchronization sample at or after the given timestamp,
 * if one is available.
 *
 * @param timeUs Timestamp adjacent to which to find a synchronization sample.
 * @return index Index of the synchronization sample, or {@link Mp4Util#NO_SAMPLE} if none.
 */
public int getIndexOfLaterOrEqualSynchronizationSample(long timeUs) {
  int startIndex = Util.binarySearchCeil(timestampsUs, timeUs, true, false);
  for (int i = startIndex; i < timestampsUs.length; i++) {
    if (timestampsUs[i] >= timeUs && (flags[i] & C.SAMPLE_FLAG_SYNC) != 0) {
      return i;
    }
  }

  return Mp4Util.NO_SAMPLE;
}