private long encode() {
		int n = 0;
		long elapsed = 0, now = timestamp();
		int encOutputIndex = 0, encInputIndex = 0;
		BufferInfo info = new BufferInfo();
		ByteBuffer[] encInputBuffers = mEncoder.getInputBuffers();
		ByteBuffer[] encOutputBuffers = mEncoder.getOutputBuffers();

		while (elapsed<5000000) {
			// Feeds the encoder with an image
			encInputIndex = mEncoder.dequeueInputBuffer(1000000/FRAMERATE);
			if (encInputIndex>=0) {
				check(encInputBuffers[encInputIndex].capacity()>=mData.length, "The input buffer is not big enough.");
				encInputBuffers[encInputIndex].clear();
				encInputBuffers[encInputIndex].put(mData, 0, mData.length);
				mEncoder.queueInputBuffer(encInputIndex, 0, mData.length, timestamp(), 0);
			} else {
				if (VERBOSE) Log.d(TAG,"No buffer available !");
			}

			// Tries to get a NAL unit
			encOutputIndex = mEncoder.dequeueOutputBuffer(info, 1000000/FRAMERATE);
			if (encOutputIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
				encOutputBuffers = mEncoder.getOutputBuffers();
			} else if (encOutputIndex>=0) {
				mVideo[n] = new byte[info.size];
				encOutputBuffers[encOutputIndex].clear();
				encOutputBuffers[encOutputIndex].get(mVideo[n++], 0, info.size);
				mEncoder.releaseOutputBuffer(encOutputIndex, false);
				if (n>=NB_ENCODED) {
					flushMediaCodec(mEncoder);
					return elapsed;
				}
			}

			elapsed = timestamp() - now;
		}

		throw new RuntimeException("The encoder is too slow.");

	}
Tries to obtain the SPS and the PPS for the encoder.
src/net/majorkernelpanic/streaming/hw/EncoderDebugger.java