public boolean config(int width, int height, Surface surface) { try { Bundle params = new Bundle(); params.putInt(IVideoDecoder.KEY_WIDTH, width); params.putInt(IVideoDecoder.KEY_HEIGHT, height); params.putParcelable(IVideoDecoder.KEY_SURFACE, surface); if (!decoder.config(params)) { Log.e(LOG_TAG, "Failed to config decoder"); return false; } ParcelFileDescriptor pfd = decoder.getInputMemoryFile(); inputMemoryFileSize = decoder.getInputMemoryFileSize(); try { inputMemoryFile = new AshmemFile(pfd, inputMemoryFileSize, AshmemFile.PROT_WRITE); } catch (IOException e) { Log.e(LOG_TAG, "Failed to create decoder's input memory file"); } return true; } catch (RemoteException e) { Log.e(LOG_TAG, "Failed to create x264 encoder"); } return false; }