当前位置: 首页>>代码示例>>Java>>正文


Java SurfaceTexture.setDefaultBufferSize方法代码示例

本文整理汇总了Java中android.graphics.SurfaceTexture.setDefaultBufferSize方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceTexture.setDefaultBufferSize方法的具体用法?Java SurfaceTexture.setDefaultBufferSize怎么用?Java SurfaceTexture.setDefaultBufferSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.SurfaceTexture的用法示例。


在下文中一共展示了SurfaceTexture.setDefaultBufferSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStart

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
@Override
protected void onStart() {
    if (DEBUG) Log.d(TAG,"mScreenCaptureTask#onStart:");
	mDrawer = new GLDrawer2D(true);
	mTexId = mDrawer.initTex();
	mSourceTexture = new SurfaceTexture(mTexId);
	mSourceTexture.setDefaultBufferSize(mWidth, mHeight);	// これを入れないと映像が取れない
	mSourceSurface = new Surface(mSourceTexture);
	mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
	mEncoderSurface = getEgl().createFromSurface(mSurface);

   	if (DEBUG) Log.d(TAG,"setup VirtualDisplay");
	intervals = (long)(1000f / fps);
    display = mMediaProjection.createVirtualDisplay(
    	"Capturing Display",
    	mWidth, mHeight, mDensity,
    	DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
    	mSourceSurface, mCallback, mHandler);
	if (DEBUG) Log.v(TAG,  "screen capture loop:display=" + display);
	// 録画タスクを起床
	queueEvent(mDrawTask);
}
 
开发者ID:itsnothingg,项目名称:EasyScreenRecorder,代码行数:23,代码来源:MediaScreenEncoder.java

示例2: configureTextureView

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
/**
 * configures the ProportionalTextureView to respect the aspect ratio of the image and using an appropriate buffer size
 */
@VisibleForTesting
void configureTextureView(@NonNull ProportionalTextureView textureView, @ConfigurationOrientation int deviceOrientation,
                          @SurfaceRotation int relativeDisplayRotation, @NonNull Size previewSize) {
    switch (deviceOrientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            // swap values because preview sizes are always landscape
            textureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth(), relativeDisplayRotation);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            textureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight(), relativeDisplayRotation);
            break;
    }

    // working more memory efficient
    SurfaceTexture surface = textureView.getSurfaceTexture();
    if (surface != null) {
        surface.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
    } else {
        throw new CameraException("surface texture not attached to view");
    }
}
 
开发者ID:BioID-GmbH,项目名称:BWS-Android,代码行数:25,代码来源:CameraHelper.java

示例3: onOpened

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
@Override
public void onOpened(CameraDevice camera) {
  checkIsOnCameraThread();

  Logging.d(TAG, "Camera opened.");
  cameraDevice = camera;

  final SurfaceTexture surfaceTexture = surfaceTextureHelper.getSurfaceTexture();
  surfaceTexture.setDefaultBufferSize(captureFormat.width, captureFormat.height);
  surface = new Surface(surfaceTexture);
  List<Surface> surfaces = new ArrayList<Surface>();
  surfaces.add(surface);
  if (mediaRecorderSurface != null) {
    Logging.d(TAG, "Add MediaRecorder surface to capture session.");
    surfaces.add(mediaRecorderSurface);
  }
  try {
    camera.createCaptureSession(surfaces, new CaptureSessionCallback(), cameraThreadHandler);
  } catch (CameraAccessException e) {
    reportError("Failed to create capture session. " + e);
    return;
  }
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:24,代码来源:Camera2Session.java

示例4: onOpened

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
@Override
public void onOpened(CameraDevice camera) {
  checkIsOnCameraThread();

  Logging.d(TAG, "Camera opened.");
  cameraDevice = camera;

  final SurfaceTexture surfaceTexture = surfaceTextureHelper.getSurfaceTexture();
  surfaceTexture.setDefaultBufferSize(captureFormat.width, captureFormat.height);
  surface = new Surface(surfaceTexture);
  try {
    camera.createCaptureSession(
        Arrays.asList(surface), new CaptureSessionCallback(), cameraThreadHandler);
  } catch (CameraAccessException e) {
    reportError("Failed to create capture session. " + e);
    return;
  }
}
 
开发者ID:lgyjg,项目名称:AndroidRTC,代码行数:19,代码来源:Camera2Session.java

示例5: setUp

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(),
      true /* initializeAudio */, true /* initializeVideo */, true /* videoHwAcceleration */);
  eglRenderer = new EglRenderer("TestRenderer: ");
  eglRenderer.init(null /* sharedContext */, EglBase.CONFIG_RGBA, new GlRectDrawer());
  oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
  surfaceTexture = new SurfaceTexture(oesTextureId);
  surfaceTexture.setDefaultBufferSize(1 /* width */, 1 /* height */);
  eglRenderer.createEglSurface(surfaceTexture);
}
 
开发者ID:lgyjg,项目名称:AndroidRTC,代码行数:12,代码来源:EglRendererTest.java

示例6: onOpened

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
@Override
public void onOpened(CameraDevice cameraDevice) {
    Log.d(TAG, "相机已经打开");
    try {
        mPreViewBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        SurfaceTexture texture = mTextureView.getSurfaceTexture();
        texture.setDefaultBufferSize(mPreViewSize.getWidth(), mPreViewSize.getHeight());
        surface = new Surface(texture);
        mPreViewBuilder.addTarget(surface);
        cameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface
                ()), mSessionStateCallBack, mHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:lupwei,项目名称:Croprotector,代码行数:16,代码来源:Shoot_fragment.java

示例7: initCamera

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
private void initCamera(boolean front) {
    CameraInfo info = null;
    ArrayList<CameraInfo> cameraInfos = CameraController.getInstance().getCameras();
    if (cameraInfos == null) {
        return;
    }
    for (int a = 0; a < cameraInfos.size(); a++) {
        CameraInfo cameraInfo = cameraInfos.get(a);
        if (isFrontface && cameraInfo.frontCamera != 0 || !isFrontface && cameraInfo.frontCamera == 0) {
            info = cameraInfo;
            break;
        }
    }
    if (info == null) {
        return;
    }
    float size4to3 = 4.0f / 3.0f;
    float size16to9 = 16.0f / 9.0f;
    float screenSize = (float) Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
    Size aspectRatio;
    int wantedWidth;
    int wantedHeight;
    if (Math.abs(screenSize - size4to3) < 0.1f) {
        aspectRatio = new Size(4, 3);
        wantedWidth = 1280;
        wantedHeight = 960;
    } else {
        aspectRatio = new Size(16, 9);
        wantedWidth = 1280;
        wantedHeight = 720;
    }
    if (textureView.getWidth() > 0 && textureView.getHeight() > 0) {
        int width = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
        int height = width * aspectRatio.getHeight() / aspectRatio.getWidth();
        previewSize = CameraController.chooseOptimalSize(info.getPreviewSizes(), width, height, aspectRatio);
    }
    Size pictureSize = CameraController.chooseOptimalSize(info.getPictureSizes(), wantedWidth, wantedHeight, aspectRatio);
    if (pictureSize.getWidth() >= 1280 && pictureSize.getHeight() >= 1280) {
        if (Math.abs(screenSize - size4to3) < 0.1f) {
            aspectRatio = new Size(3, 4);
        } else {
            aspectRatio = new Size(9, 16);
        }
        Size pictureSize2 = CameraController.chooseOptimalSize(info.getPictureSizes(), wantedHeight, wantedWidth, aspectRatio);
        if (pictureSize2.getWidth() < 1280 || pictureSize2.getHeight() < 1280) {
            pictureSize = pictureSize2;
        }
    }
    SurfaceTexture surfaceTexture = textureView.getSurfaceTexture();
    if (previewSize != null && surfaceTexture != null) {
        surfaceTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
        cameraSession = new CameraSession(info, previewSize, pictureSize, ImageFormat.JPEG);
        CameraController.getInstance().open(cameraSession, surfaceTexture, new Runnable() {
            @Override
            public void run() {
                if (cameraSession != null) {
                    cameraSession.setInitied();
                }
                checkPreviewMatrix();
            }
        }, new Runnable() {
            @Override
            public void run() {
                if (delegate != null) {
                    delegate.onCameraCreated(cameraSession.cameraInfo.camera);
                }
            }
        });
    }
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:71,代码来源:CameraView.java

示例8: prepareCamera

import android.graphics.SurfaceTexture; //导入方法依赖的package包/类
public void prepareCamera(SurfaceTexture surfaceTexture, int width, int height) {
  surfaceTexture.setDefaultBufferSize(width, height);
  this.surfaceEncoder = new Surface(surfaceTexture);
  prepared = true;
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:6,代码来源:Camera2ApiManager.java


注:本文中的android.graphics.SurfaceTexture.setDefaultBufferSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。