闲暇时间,做了一个Demo,用来网络传输视频内容。
通过MediaPlayer播放视频文件,将其内容渲染到MediaCodec,中间也可加入其他特效处理。
最后将MediaCodec的内容发送出去。
1、首先需要准备一个渲染线程,用来opengl 渲染
public class VideoRenderer extends Thread implements SurfaceTexture.OnFrameAvailableListener {
private static final String TAG = "VideoRenderer";
private GLHelper mGLHelper;
private boolean mExit = false;
private boolean mFrameAvailable = false;
private VideoSender mSender;
public VideoRenderer(Surface surface, VideoSender sender, int width, int height) {
mSender = sender;
mGLHelper = new GLHelper(surface, this, width, height);
}
@Override
public void run() {
super.run();
loop();
}
private void loop() {
mGLHelper.init();
mSender.onSurfaceTextureAvailable(mGLHelper.getSurfaceTexture());
while (true) {
|