Tabnine Logo
DecoderInputBuffer.ensureSpaceForWrite
Code IndexAdd Tabnine to your IDE (free)

How to use
ensureSpaceForWrite
method
in
com.google.android.exoplayer2.decoder.DecoderInputBuffer

Best Java code snippets using com.google.android.exoplayer2.decoder.DecoderInputBuffer.ensureSpaceForWrite (Showing top 6 results out of 315)

origin: google/ExoPlayer

/**
 * Sets the initial size of each input buffer.
 * <p>
 * This method should only be called before the decoder is used (i.e. before the first call to
 * {@link #dequeueInputBuffer()}.
 *
 * @param size The required input buffer size.
 */
protected final void setInitialInputBufferSize(int size) {
 Assertions.checkState(availableInputBufferCount == availableInputBuffers.length);
 for (I inputBuffer : availableInputBuffers) {
  inputBuffer.ensureSpaceForWrite(size);
 }
}
origin: google/ExoPlayer

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
  boolean formatRequired) {
 if (eventDispatcher != null && !notifiedDownstreamFormat) {
  eventDispatcher.downstreamFormatChanged(
    C.TRACK_TYPE_UNKNOWN,
    format,
    C.SELECTION_REASON_UNKNOWN,
    /* trackSelectionData= */ null,
    /* mediaTimeUs= */ 0);
  notifiedDownstreamFormat = true;
 }
 if (formatRequired || !readFormat) {
  formatHolder.format = format;
  readFormat = true;
  return C.RESULT_FORMAT_READ;
 } else if (!readSample) {
  buffer.timeUs = 0;
  buffer.ensureSpaceForWrite(1);
  buffer.data.put((byte) 0);
  buffer.flip();
  readSample = true;
  return C.RESULT_BUFFER_READ;
 } else {
  buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
  return C.RESULT_BUFFER_READ;
 }
}
origin: google/ExoPlayer

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
  boolean formatRequired) {
 if (formatRequired || !isFormatSentDownstream) {
  formatHolder.format = upstreamFormat;
  isFormatSentDownstream = true;
  return C.RESULT_FORMAT_READ;
 }
 if (currentIndex == eventTimesUs.length) {
  if (!eventStreamAppendable) {
   buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
   return C.RESULT_BUFFER_READ;
  } else {
   return C.RESULT_NOTHING_READ;
  }
 }
 int sampleIndex = currentIndex++;
 byte[] serializedEvent = eventMessageEncoder.encode(eventStream.events[sampleIndex],
   eventStream.timescale);
 if (serializedEvent != null) {
  buffer.ensureSpaceForWrite(serializedEvent.length);
  buffer.setFlags(C.BUFFER_FLAG_KEY_FRAME);
  buffer.data.put(serializedEvent);
  buffer.timeUs = eventTimesUs[sampleIndex];
  return C.RESULT_BUFFER_READ;
 } else {
  return C.RESULT_NOTHING_READ;
 }
}
origin: google/ExoPlayer

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
  boolean requireFormat) {
 maybeNotifyDownstreamFormat();
 if (streamState == STREAM_STATE_END_OF_STREAM) {
  buffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
  return C.RESULT_BUFFER_READ;
 } else if (requireFormat || streamState == STREAM_STATE_SEND_FORMAT) {
  formatHolder.format = format;
  streamState = STREAM_STATE_SEND_SAMPLE;
  return C.RESULT_FORMAT_READ;
 } else if (loadingFinished) {
  if (loadingSucceeded) {
   buffer.timeUs = 0;
   buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
   buffer.ensureSpaceForWrite(sampleSize);
   buffer.data.put(sampleData, 0, sampleSize);
  } else {
   buffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
  }
  streamState = STREAM_STATE_END_OF_STREAM;
  return C.RESULT_BUFFER_READ;
 }
 return C.RESULT_NOTHING_READ;
}
origin: google/ExoPlayer

buffer.ensureSpaceForWrite(extrasHolder.size);
readData(extrasHolder.offset, buffer.data, extrasHolder.size);
origin: google/ExoPlayer

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
  boolean formatRequired) {
 if (eventDispatcher != null && !notifiedDownstreamFormat) {
  eventDispatcher.downstreamFormatChanged(
    C.TRACK_TYPE_UNKNOWN,
    format,
    C.SELECTION_REASON_UNKNOWN,
    /* trackSelectionData= */ null,
    /* mediaTimeUs= */ 0);
  notifiedDownstreamFormat = true;
 }
 if (formatRequired || !readFormat) {
  formatHolder.format = format;
  readFormat = true;
  return C.RESULT_FORMAT_READ;
 } else if (!readSample) {
  buffer.timeUs = 0;
  buffer.ensureSpaceForWrite(1);
  buffer.data.put((byte) 0);
  buffer.flip();
  readSample = true;
  return C.RESULT_BUFFER_READ;
 } else {
  buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
  return C.RESULT_BUFFER_READ;
 }
}
com.google.android.exoplayer2.decoderDecoderInputBufferensureSpaceForWrite

Javadoc

Ensures that #data is large enough to accommodate a write of a given length at its current position.

If the capacity of #data is sufficient this method does nothing. If the capacity is insufficient then an attempt is made to replace #data with a new ByteBufferwhose capacity is sufficient. Data up to the current position is copied to the new buffer.

Popular methods of DecoderInputBuffer

  • <init>
  • clear
  • isEndOfStream
  • setFlags
  • flip
    Flips #data in preparation for being queued to a decoder.
  • isEncrypted
    Returns whether the C#BUFFER_FLAG_ENCRYPTED flag is set.
  • isDecodeOnly
  • isKeyFrame
  • newFlagsOnlyInstance
    Creates a new instance for which #isFlagsOnly() will return true.
  • addFlag
  • createReplacementByteBuffer
  • getFlag
  • createReplacementByteBuffer,
  • getFlag,
  • isFlagsOnly

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • findViewById (Activity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • JList (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now