com.google.android.exoplayer2.C Java Examples

The following examples show how to use com.google.android.exoplayer2.C. 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: DefaultAudioSink.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(21)
private AudioTrack createAudioTrackV21() {
  android.media.AudioAttributes attributes;
  if (tunneling) {
    attributes = new android.media.AudioAttributes.Builder()
        .setContentType(android.media.AudioAttributes.CONTENT_TYPE_MOVIE)
        .setFlags(android.media.AudioAttributes.FLAG_HW_AV_SYNC)
        .setUsage(android.media.AudioAttributes.USAGE_MEDIA)
        .build();
  } else {
    attributes = audioAttributes.getAudioAttributesV21();
  }
  AudioFormat format =
      new AudioFormat.Builder()
          .setChannelMask(outputChannelConfig)
          .setEncoding(outputEncoding)
          .setSampleRate(outputSampleRate)
          .build();
  int audioSessionId = this.audioSessionId != C.AUDIO_SESSION_ID_UNSET ? this.audioSessionId
      : AudioManager.AUDIO_SESSION_ID_GENERATE;
  return new AudioTrack(attributes, format, bufferSize, MODE_STREAM, audioSessionId);
}
 
Example #2
Source File: ExtractorMediaPeriod.java    From K-Sonic with MIT License 6 votes vote down vote up
private void startLoading() {
  ExtractingLoadable loadable = new ExtractingLoadable(uri, dataSource, extractorHolder,
      loadCondition);
  if (prepared) {
    Assertions.checkState(isPendingReset());
    if (durationUs != C.TIME_UNSET && pendingResetPositionUs >= durationUs) {
      loadingFinished = true;
      pendingResetPositionUs = C.TIME_UNSET;
      return;
    }
    loadable.setLoadPosition(seekMap.getPosition(pendingResetPositionUs), pendingResetPositionUs);
    pendingResetPositionUs = C.TIME_UNSET;
  }
  extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();

  int minRetryCount = minLoadableRetryCount;
  if (minRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA) {
    // We assume on-demand before we're prepared.
    minRetryCount = !prepared || length != C.LENGTH_UNSET
        || (seekMap != null && seekMap.getDurationUs() != C.TIME_UNSET)
        ? ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
        : ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE;
  }
  loader.startLoading(loadable, this, minRetryCount);
}
 
Example #3
Source File: FileDataSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public int read(byte[] buffer, int offset, int readLength) throws FileDataSourceException {
  if (readLength == 0) {
    return 0;
  } else if (bytesRemaining == 0) {
    return C.RESULT_END_OF_INPUT;
  } else {
    int bytesRead;
    try {
      bytesRead =
          castNonNull(file).read(buffer, offset, (int) Math.min(bytesRemaining, readLength));
    } catch (IOException e) {
      throw new FileDataSourceException(e);
    }

    if (bytesRead > 0) {
      bytesRemaining -= bytesRead;
      bytesTransferred(bytesRead);
    }

    return bytesRead;
  }
}
 
Example #4
Source File: ProgressiveDownloader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void download() throws InterruptedException, IOException {
  priorityTaskManager.add(C.PRIORITY_DOWNLOAD);
  try {
    CacheUtil.cache(
        dataSpec,
        cache,
        dataSource,
        new byte[BUFFER_SIZE_BYTES],
        priorityTaskManager,
        C.PRIORITY_DOWNLOAD,
        cachingCounters,
        isCanceled,
        /* enableEOFException= */ true);
  } finally {
    priorityTaskManager.remove(C.PRIORITY_DOWNLOAD);
  }
}
 
Example #5
Source File: AdPlaybackState.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a new instance with the specified ad set to the specified {@code state}. The ad
 * specified must currently either be in {@link #AD_STATE_UNAVAILABLE} or {@link
 * #AD_STATE_AVAILABLE}.
 *
 * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the
 * ad count specified later. Otherwise, {@code index} must be less than the current ad count.
 */
@CheckResult
public AdGroup withAdState(@AdState int state, int index) {
  Assertions.checkArgument(count == C.LENGTH_UNSET || index < count);
  @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1);
  Assertions.checkArgument(
      states[index] == AD_STATE_UNAVAILABLE
          || states[index] == AD_STATE_AVAILABLE
          || states[index] == state);
  long[] durationsUs =
      this.durationsUs.length == states.length
          ? this.durationsUs
          : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length);
  Uri[] uris =
      this.uris.length == states.length ? this.uris : Arrays.copyOf(this.uris, states.length);
  states[index] = state;
  return new AdGroup(count, states, uris, durationsUs);
}
 
Example #6
Source File: MediaCodecAudioRenderer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content 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 acquisition. 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 enableDecoderFallback Whether to enable fallback to lower-priority decoders if decoder
 *     initialization fails. This may result in using a decoder that is slower/less efficient than
 *     the primary decoder.
 * @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.
 * @param audioSink The sink to which audio will be output.
 */
public MediaCodecAudioRenderer(
    Context context,
    MediaCodecSelector mediaCodecSelector,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys,
    boolean enableDecoderFallback,
    @Nullable Handler eventHandler,
    @Nullable AudioRendererEventListener eventListener,
    AudioSink audioSink) {
  super(
      C.TRACK_TYPE_AUDIO,
      mediaCodecSelector,
      drmSessionManager,
      playClearSamplesWithoutKeys,
      enableDecoderFallback,
      /* assumedMinimumCodecOperatingRate= */ 44100);
  this.context = context.getApplicationContext();
  this.audioSink = audioSink;
  lastInputTimeUs = C.TIME_UNSET;
  pendingStreamChangeTimesUs = new long[MAX_PENDING_STREAM_CHANGE_COUNT];
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  audioSink.setListener(new AudioSinkListener());
}
 
Example #7
Source File: KExoMediaPlayer.java    From K-Sonic with MIT License 6 votes vote down vote up
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
Example #8
Source File: CryptoInfo.java    From Telegram with GNU General Public License v2.0 6 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, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  // Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
  // object allocation on Android N.
  frameworkCryptoInfo.numSubSamples = numSubSamples;
  frameworkCryptoInfo.numBytesOfClearData = numBytesOfClearData;
  frameworkCryptoInfo.numBytesOfEncryptedData = numBytesOfEncryptedData;
  frameworkCryptoInfo.key = key;
  frameworkCryptoInfo.iv = iv;
  frameworkCryptoInfo.mode = mode;
  if (Util.SDK_INT >= 24) {
    patternHolder.set(encryptedBlocks, clearBlocks);
  }
}
 
Example #9
Source File: TrackEncryptionBox.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example #10
Source File: SsManifest.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public StreamElement(String baseUri, String chunkTemplate, int type, String subType,
    long timescale, String name, int maxWidth, int maxHeight, int displayWidth,
    int displayHeight, String language, Format[] formats, List<Long> chunkStartTimes,
    long lastChunkDuration) {
  this(
      baseUri,
      chunkTemplate,
      type,
      subType,
      timescale,
      name,
      maxWidth,
      maxHeight,
      displayWidth,
      displayHeight,
      language,
      formats,
      chunkStartTimes,
      Util.scaleLargeTimestamps(chunkStartTimes, C.MICROS_PER_SECOND, timescale),
      Util.scaleLargeTimestamp(lastChunkDuration, C.MICROS_PER_SECOND, timescale));
}
 
Example #11
Source File: AdsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onAdLoadError(final AdLoadException error, DataSpec dataSpec) {
  if (released) {
    return;
  }
  createEventDispatcher(/* mediaPeriodId= */ null)
      .loadError(
          dataSpec,
          dataSpec.uri,
          /* responseHeaders= */ Collections.emptyMap(),
          C.DATA_TYPE_AD,
          C.TRACK_TYPE_UNKNOWN,
          /* loadDurationMs= */ 0,
          /* bytesLoaded= */ 0,
          error,
          /* wasCanceled= */ true);
}
 
Example #12
Source File: WebPlayerView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
    if (playbackState != ExoPlayer.STATE_BUFFERING) {
        if (videoPlayer.getDuration() != C.TIME_UNSET) {
            controlsView.setDuration((int) (videoPlayer.getDuration() / 1000));
        } else {
            controlsView.setDuration(0);
        }
    }
    if (playbackState != ExoPlayer.STATE_ENDED && playbackState != ExoPlayer.STATE_IDLE && videoPlayer.isPlaying()) {
        delegate.onPlayStateChanged(this, true);
    } else {
        delegate.onPlayStateChanged(this, false);
    }
    if (videoPlayer.isPlaying() && playbackState != ExoPlayer.STATE_ENDED) {
        updatePlayButton();
    } else {
        if (playbackState == ExoPlayer.STATE_ENDED) {
            isCompleted = true;
            videoPlayer.pause();
            videoPlayer.seekTo(0);
            updatePlayButton();
            controlsView.show(true, true);
        }
    }
}
 
Example #13
Source File: DefaultHttpDataSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at
 * index {@code offset}.
 * <p>
 * This method blocks until at least one byte of data can be read, the end of the opened range is
 * detected, or an exception is thrown.
 *
 * @param buffer The buffer into which the read data should be stored.
 * @param offset The start offset into {@code buffer} at which data should be written.
 * @param readLength The maximum number of bytes to read.
 * @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
 *     range is reached.
 * @throws IOException If an error occurs reading from the source.
 */
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
  if (readLength == 0) {
    return 0;
  }
  if (bytesToRead != C.LENGTH_UNSET) {
    long bytesRemaining = bytesToRead - bytesRead;
    if (bytesRemaining == 0) {
      return C.RESULT_END_OF_INPUT;
    }
    readLength = (int) Math.min(readLength, bytesRemaining);
  }

  int read = inputStream.read(buffer, offset, readLength);
  if (read == -1) {
    if (bytesToRead != C.LENGTH_UNSET) {
      // End of stream reached having not read sufficient data.
      throw new EOFException();
    }
    return C.RESULT_END_OF_INPUT;
  }

  bytesRead += read;
  bytesTransferred(read);
  return read;
}
 
Example #14
Source File: PlaybackStatsListener.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Notifies the tracker that the track selection for the current playback changed.
 *
 * @param eventTime The {@link EventTime}.
 * @param trackSelections The new {@link TrackSelectionArray}.
 */
public void onTracksChanged(EventTime eventTime, TrackSelectionArray trackSelections) {
  boolean videoEnabled = false;
  boolean audioEnabled = false;
  for (TrackSelection trackSelection : trackSelections.getAll()) {
    if (trackSelection != null && trackSelection.length() > 0) {
      int trackType = MimeTypes.getTrackType(trackSelection.getFormat(0).sampleMimeType);
      if (trackType == C.TRACK_TYPE_VIDEO) {
        videoEnabled = true;
      } else if (trackType == C.TRACK_TYPE_AUDIO) {
        audioEnabled = true;
      }
    }
  }
  if (!videoEnabled) {
    maybeUpdateVideoFormat(eventTime, /* newFormat= */ null);
  }
  if (!audioEnabled) {
    maybeUpdateAudioFormat(eventTime, /* newFormat= */ null);
  }
}
 
Example #15
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void maybeInitExtraTracks() {
  if (emsgTrackOutputs == null) {
    emsgTrackOutputs = new TrackOutput[2];
    int emsgTrackOutputCount = 0;
    if (additionalEmsgTrackOutput != null) {
      emsgTrackOutputs[emsgTrackOutputCount++] = additionalEmsgTrackOutput;
    }
    if ((flags & FLAG_ENABLE_EMSG_TRACK) != 0) {
      emsgTrackOutputs[emsgTrackOutputCount++] =
          extractorOutput.track(trackBundles.size(), C.TRACK_TYPE_METADATA);
    }
    emsgTrackOutputs = Arrays.copyOf(emsgTrackOutputs, emsgTrackOutputCount);

    for (TrackOutput eventMessageTrackOutput : emsgTrackOutputs) {
      eventMessageTrackOutput.format(EMSG_FORMAT);
    }
  }
  if (cea608TrackOutputs == null) {
    cea608TrackOutputs = new TrackOutput[closedCaptionFormats.size()];
    for (int i = 0; i < cea608TrackOutputs.length; i++) {
      TrackOutput output = extractorOutput.track(trackBundles.size() + 1 + i, C.TRACK_TYPE_TEXT);
      output.format(closedCaptionFormats.get(i));
      cea608TrackOutputs[i] = output;
    }
  }
}
 
Example #16
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo mpdEventTrack(int eventStreamIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_MANIFEST_EVENTS,
      null,
      -1,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      eventStreamIndex);
}
 
Example #17
Source File: DoubleViewTubiPlayerActivity.java    From TubiPlayer with MIT License 5 votes vote down vote up
private void updateAdResumePosition() {
    if (adPlayer != null && playerUIController != null) {
        int adResumeWindow = adPlayer.getCurrentWindowIndex();
        long adResumePosition = adPlayer.isCurrentWindowSeekable() ? Math.max(0, adPlayer.getCurrentPosition())
                : C.TIME_UNSET;
        playerUIController.setAdResumeInfo(adResumeWindow, adResumePosition);
    }
}
 
Example #18
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onVideoInputFormatChanged(Format format) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_VIDEO, format);
  }
}
 
Example #19
Source File: AdtsReader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Reads the rest of the sample
 */
private void readSample(ParsableByteArray data) {
  int bytesToRead = Math.min(data.bytesLeft(), sampleSize - bytesRead);
  currentOutput.sampleData(data, bytesToRead);
  bytesRead += bytesToRead;
  if (bytesRead == sampleSize) {
    currentOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0, null);
    timeUs += currentSampleDuration;
    setFindingSampleState();
  }
}
 
Example #20
Source File: AdaptiveTrackSelection.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private long minDurationForQualityIncreaseUs(long availableDurationUs) {
  boolean isAvailableDurationTooShort = availableDurationUs != C.TIME_UNSET
      && availableDurationUs <= minDurationForQualityIncreaseUs;
  return isAvailableDurationTooShort
      ? (long) (availableDurationUs * bufferedFractionToLiveEdgeForQualityIncrease)
      : minDurationForQualityIncreaseUs;
}
 
Example #21
Source File: SingleMediaManager.java    From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void restoreMediaPlayer() {
    initPlayer();
    if (isPlayerViewCurrent(playerView)) {
        playerView.setPlayer(exoPlayer);
    }
    MediaSource mediaSource = SimpleExoPlayerInitializer.buildMediaSource(uri, context);
    boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
    if (haveResumePosition) {
        exoPlayer.seekTo(resumeWindow, resumePosition);
    }
    exoPlayer.prepare(mediaSource, !haveResumePosition, false);
    exoPlayer.setPlayWhenReady(shouldAutoPlay);
}
 
Example #22
Source File: Mp3Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private int readSample(ExtractorInput extractorInput) throws IOException, InterruptedException {
  if (sampleBytesRemaining == 0) {
    extractorInput.resetPeekPosition();
    if (peekEndOfStreamOrHeader(extractorInput)) {
      return RESULT_END_OF_INPUT;
    }
    scratch.setPosition(0);
    int sampleHeaderData = scratch.readInt();
    if (!headersMatch(sampleHeaderData, synchronizedHeaderData)
        || MpegAudioHeader.getFrameSize(sampleHeaderData) == C.LENGTH_UNSET) {
      // We have lost synchronization, so attempt to resynchronize starting at the next byte.
      extractorInput.skipFully(1);
      synchronizedHeaderData = 0;
      return RESULT_CONTINUE;
    }
    MpegAudioHeader.populateHeader(sampleHeaderData, synchronizedHeader);
    if (basisTimeUs == C.TIME_UNSET) {
      basisTimeUs = seeker.getTimeUs(extractorInput.getPosition());
      if (forcedFirstSampleTimestampUs != C.TIME_UNSET) {
        long embeddedFirstSampleTimestampUs = seeker.getTimeUs(0);
        basisTimeUs += forcedFirstSampleTimestampUs - embeddedFirstSampleTimestampUs;
      }
    }
    sampleBytesRemaining = synchronizedHeader.frameSize;
  }
  int bytesAppended = trackOutput.sampleData(extractorInput, sampleBytesRemaining, true);
  if (bytesAppended == C.RESULT_END_OF_INPUT) {
    return RESULT_END_OF_INPUT;
  }
  sampleBytesRemaining -= bytesAppended;
  if (sampleBytesRemaining > 0) {
    return RESULT_CONTINUE;
  }
  long timeUs = basisTimeUs + (samplesRead * C.MICROS_PER_SECOND / synchronizedHeader.sampleRate);
  trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, synchronizedHeader.frameSize, 0,
      null);
  samplesRead += synchronizedHeader.samplesPerFrame;
  sampleBytesRemaining = 0;
  return RESULT_CONTINUE;
}
 
Example #23
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void packetFinished() {
  if (writingSample) {
    for (TrackOutput output : outputs) {
      output.sampleMetadata(sampleTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleBytesWritten, 0, null);
    }
    writingSample = false;
  }
}
 
Example #24
Source File: FloatResamplingAudioProcessor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new audio processor that converts audio data to {@link C#ENCODING_PCM_FLOAT}. */
public FloatResamplingAudioProcessor() {
  sampleRateHz = Format.NO_VALUE;
  channelCount = Format.NO_VALUE;
  sourceEncoding = C.ENCODING_INVALID;
  buffer = EMPTY_BUFFER;
  outputBuffer = EMPTY_BUFFER;
}
 
Example #25
Source File: RendererTrackIndexExtractorTest.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public int getRendererTypeFor(int index) {
    if (index == 0) {
        return C.TRACK_TYPE_AUDIO;
    }

    return -1;
}
 
Example #26
Source File: TrackSelectionParameters.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
TrackSelectionParameters(
    @Nullable String preferredAudioLanguage,
    @Nullable String preferredTextLanguage,
    @C.RoleFlags int preferredTextRoleFlags,
    boolean selectUndeterminedTextLanguage,
    @C.SelectionFlags int disabledTextTrackSelectionFlags) {
  // Audio
  this.preferredAudioLanguage = Util.normalizeLanguageCode(preferredAudioLanguage);
  // Text
  this.preferredTextLanguage = Util.normalizeLanguageCode(preferredTextLanguage);
  this.preferredTextRoleFlags = preferredTextRoleFlags;
  this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage;
  this.disabledTextTrackSelectionFlags = disabledTextTrackSelectionFlags;
}
 
Example #27
Source File: VideoFrameReleaseTimeHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private VSyncSampler() {
  sampledVsyncTimeNs = C.TIME_UNSET;
  choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler");
  choreographerOwnerThread.start();
  handler = Util.createHandler(choreographerOwnerThread.getLooper(), /* callback= */ this);
  handler.sendEmptyMessage(CREATE_CHOREOGRAPHER);
}
 
Example #28
Source File: HlsMediaPlaylist.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param uri See {@link #url}.
 * @param byterangeOffset See {@link #byterangeOffset}.
 * @param byterangeLength See {@link #byterangeLength}.
 */
public Segment(String uri, long byterangeOffset, long byterangeLength) {
  this(
      uri,
      /* initializationSegment= */ null,
      /* title= */ "",
      /* durationUs= */ 0,
      /* relativeDiscontinuitySequence= */ -1,
      /* relativeStartTimeUs= */ C.TIME_UNSET,
      /* fullSegmentEncryptionKeyUri= */ null,
      /* encryptionIV= */ null,
      byterangeOffset,
      byterangeLength,
      /* hasGapTag= */ false);
}
 
Example #29
Source File: AtomParsers.java    From K-Sonic with MIT License 5 votes vote down vote up
public ChunkIterator(ParsableByteArray stsc, ParsableByteArray chunkOffsets,
    boolean chunkOffsetsAreLongs) {
  this.stsc = stsc;
  this.chunkOffsets = chunkOffsets;
  this.chunkOffsetsAreLongs = chunkOffsetsAreLongs;
  chunkOffsets.setPosition(Atom.FULL_HEADER_SIZE);
  length = chunkOffsets.readUnsignedIntToInt();
  stsc.setPosition(Atom.FULL_HEADER_SIZE);
  remainingSamplesPerChunkChanges = stsc.readUnsignedIntToInt();
  Assertions.checkState(stsc.readInt() == 1, "first_chunk must be 1");
  index = C.INDEX_UNSET;
}
 
Example #30
Source File: PlayerEmsgHandler.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
private MetadataInputBuffer dequeueSample() {
  buffer.clear();
  int result = sampleQueue.read(formatHolder, buffer, false, false, 0);
  if (result == C.RESULT_BUFFER_READ) {
    buffer.flip();
    return buffer;
  }
  return null;
}