/** * Initialize this class, sharing resources with |sharedContext|. It is allowed to call init() to * reinitialize the renderer after a previous init()/release() cycle. */ public void init( EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents) { init(sharedContext, rendererEvents, EglBase.CONFIG_PLAIN, new GlRectDrawer()); }
public void start(final EglBase eglBase) { mHandler.post(new Runnable() { @Override public void run() { try { mEglBase = EglBase.create(eglBase.getEglBaseContext(), EglBase.CONFIG_RECORDABLE); mEncoder = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC); MediaFormat encodeFormat = MediaFormat.createVideoFormat( MediaFormat.MIMETYPE_VIDEO_AVC, mConfig.outputWidth(), mConfig.outputHeight()); encodeFormat.setInteger(MediaFormat.KEY_BIT_RATE, mConfig.initBr() * 1000); encodeFormat.setInteger(MediaFormat.KEY_FRAME_RATE, mConfig.outputFps()); encodeFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, mConfig.outputKeyFrameInterval()); encodeFormat.setInteger(MediaFormat.KEY_BITRATE_MODE, mConfig.brMode()); if (mConfig.brMode() == MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CQ) { encodeFormat.setInteger("quality", mConfig.quality()); } encodeFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); if (mConfig.asyncEnc()) { mEncoder.setCallback(EncoderWrapper.this); } mEncoder.configure(encodeFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); Log.i(TAG, "VideoFormat encoder " + encodeFormat); mEncoderSurface = mEncoder.createInputSurface(); mEncoder.start(); mCurrentBr = mConfig.initBr(); mEglBase.createSurface(mEncoderSurface); mEglBase.makeCurrent(); mDrawer = new GlRectDrawer(); mLastResetBitsTime = System.currentTimeMillis(); if (!mConfig.asyncEnc()) { startOutputThread(); } } catch (IOException e) { e.printStackTrace(); } } }); if (mConfig.updateBr()) { mUiHandler.postDelayed(mRcRunnable, RC_INTERVAL); } }
/** * Initialize this class, sharing resources with |sharedContext|. It is allowed to call init() to * reinitialize the renderer after a previous init()/release() cycle. */ public void init(EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents) { init(sharedContext, rendererEvents, EglBase.CONFIG_PLAIN, new GlRectDrawer()); }