|
|
|
@ -10,6 +10,7 @@ import android.view.SurfaceView;
|
|
|
|
|
import com.yinuo.library.vlc.encoder.BaseMovieEncoder;
|
|
|
|
|
import com.yinuo.library.vlc.encoder.CameraHelper;
|
|
|
|
|
import com.yinuo.library.vlc.encoder.MovieEncoder1;
|
|
|
|
|
import com.yinuo.library.vlc.utils.BitmapUtil;
|
|
|
|
|
import com.yinuo.library.vlc.utils.LogUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
@ -29,8 +30,8 @@ public class RtspSurfaceRender2 implements RtspHelper.RtspCallback {
|
|
|
|
|
|
|
|
|
|
private final Object mBitmapLock = new Object();
|
|
|
|
|
private Bitmap mVideoBitmap = null;
|
|
|
|
|
private boolean mIsResumed = false;
|
|
|
|
|
private boolean mRecording = false;
|
|
|
|
|
private volatile boolean mIsResumed = false;
|
|
|
|
|
private volatile boolean mRecording = false;
|
|
|
|
|
|
|
|
|
|
// mSurfaceView 渲染线程
|
|
|
|
|
Thread renderThread = new Thread(new Runnable() {
|
|
|
|
@ -117,7 +118,7 @@ public class RtspSurfaceRender2 implements RtspHelper.RtspCallback {
|
|
|
|
|
synchronized (mBitmapLock) {
|
|
|
|
|
Bitmap overLayBitmap = TxtOverlay.INSTANCE.buildOverlayBitmap();
|
|
|
|
|
mVideoBitmap.copyPixelsFromBuffer(buffer.position(0));
|
|
|
|
|
mVideoBitmap = mergeBitmap(mVideoBitmap, overLayBitmap);
|
|
|
|
|
mVideoBitmap = BitmapUtil.mergeBitmap(mVideoBitmap, overLayBitmap);
|
|
|
|
|
buffer.clear();
|
|
|
|
|
mVideoBitmap.copyPixelsToBuffer(buffer);
|
|
|
|
|
}
|
|
|
|
@ -127,34 +128,6 @@ public class RtspSurfaceRender2 implements RtspHelper.RtspCallback {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 把两个位图覆盖合成为一个位图,以底层位图的长宽为基准
|
|
|
|
|
*
|
|
|
|
|
* @param backBitmap 在底部的位图
|
|
|
|
|
* @param frontBitmap 盖在上面的位图
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static Bitmap mergeBitmap(Bitmap backBitmap, Bitmap frontBitmap) {
|
|
|
|
|
|
|
|
|
|
if (backBitmap == null || backBitmap.isRecycled()
|
|
|
|
|
|| frontBitmap == null || frontBitmap.isRecycled()) {
|
|
|
|
|
return backBitmap;
|
|
|
|
|
}
|
|
|
|
|
//create the new blank bitmap 创建一个新的和SRC长度宽度一样的位图
|
|
|
|
|
Bitmap newbmp = Bitmap.createBitmap(backBitmap.getWidth(), backBitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
|
|
|
|
Canvas cv = new Canvas(newbmp);
|
|
|
|
|
//draw bg into
|
|
|
|
|
cv.drawBitmap(backBitmap, 0, 0, null);//在 0,0坐标开始画入bg
|
|
|
|
|
//draw fg into
|
|
|
|
|
cv.drawBitmap(frontBitmap, 100, 100, null);//在 0,0坐标开始画入fg ,可以从任意位置画入
|
|
|
|
|
//save all clip
|
|
|
|
|
cv.save();//保存
|
|
|
|
|
//store
|
|
|
|
|
cv.restore();//存储
|
|
|
|
|
return newbmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
|
this.mIsResumed = true;
|
|
|
|
|
}
|
|
|
|
|