code: public void writeSampleData(MediaCodec encoder, int trackIndex, int bufferIndex, ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo){
          if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
              signalEndOfTrack();
          }
      }
docs: Write the MediaCodec output buffer. This method <b>must</b>
  be overridden by subclasses to release encodedData, transferring
  ownership back to encoder, by calling encoder.releaseOutputBuffer(bufferIndex, false);
  
  @param trackIndex
  @param encodedData
  @param bufferInfo