本文整理了Java中android.hardware.Camera.addCallbackBuffer()
方法的一些代码示例,展示了Camera.addCallbackBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.addCallbackBuffer()
方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:addCallbackBuffer
暂无
代码示例来源:origin: googlesamples/android-vision
/**
* Sets the frame data received from the camera. This adds the previous unused frame buffer
* (if present) back to the camera, and keeps a pending reference to the frame data for
* future use.
*/
void setNextFrame(byte[] data, Camera camera) {
synchronized (mLock) {
if (mPendingFrameData != null) {
camera.addCallbackBuffer(mPendingFrameData.array());
mPendingFrameData = null;
}
if (!mBytesToByteBuffer.containsKey(data)) {
Log.d(TAG,
"Skipping frame. Could not find ByteBuffer associated with the image " +
"data from the camera.");
return;
}
// Timestamp and frame ID are maintained here, which will give downstream code some
// idea of the timing of frames received and when frames were dropped along the way.
mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
mPendingFrameId++;
mPendingFrameData = mBytesToByteBuffer.get(data);
// Notify the processor thread if it is waiting on the next frame (see below).
mLock.notifyAll();
}
}
代码示例来源:origin: googlesamples/android-vision
/**
* Sets the frame data received from the camera. This adds the previous unused frame buffer
* (if present) back to the camera, and keeps a pending reference to the frame data for
* future use.
*/
void setNextFrame(byte[] data, Camera camera) {
synchronized (mLock) {
if (mPendingFrameData != null) {
camera.addCallbackBuffer(mPendingFrameData.array());
mPendingFrameData = null;
}
if (!mBytesToByteBuffer.containsKey(data)) {
Log.d(TAG,
"Skipping frame. Could not find ByteBuffer associated with the image " +
"data from the camera.");
return;
}
// Timestamp and frame ID are maintained here, which will give downstream code some
// idea of the timing of frames received and when frames were dropped along the way.
mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
mPendingFrameId++;
mPendingFrameData = mBytesToByteBuffer.get(data);
// Notify the processor thread if it is waiting on the next frame (see below).
mLock.notifyAll();
}
}
代码示例来源:origin: googlesamples/android-vision
/**
* Sets the frame data received from the camera. This adds the previous unused frame buffer
* (if present) back to the camera, and keeps a pending reference to the frame data for
* future use.
*/
void setNextFrame(byte[] data, Camera camera) {
synchronized (mLock) {
if (mPendingFrameData != null) {
camera.addCallbackBuffer(mPendingFrameData.array());
mPendingFrameData = null;
}
if (!bytesToByteBuffer.containsKey(data)) {
Log.d(TAG,
"Skipping frame. Could not find ByteBuffer associated with the image " +
"data from the camera.");
return;
}
// Timestamp and frame ID are maintained here, which will give downstream code some
// idea of the timing of frames received and when frames were dropped along the way.
mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
mPendingFrameId++;
mPendingFrameData = bytesToByteBuffer.get(data);
// Notify the processor thread if it is waiting on the next frame (see below).
mLock.notifyAll();
}
}
代码示例来源:origin: daniulive/SmarterStreaming
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
frameCount++;
if (frameCount % 3000 == 0) {
Log.i("OnPre", "gc+");
System.gc();
Log.i("OnPre", "gc-");
}
if (data == null) {
Parameters params = camera.getParameters();
Size size = params.getPreviewSize();
int bufferSize = (((size.width | 0x1f) + 1) * size.height * ImageFormat.getBitsPerPixel(params.getPreviewFormat())) / 8;
camera.addCallbackBuffer(new byte[bufferSize]);
} else {
if (isRTSPPublisherRunning || isPushingRtmp || isRecording || isPushingRtsp) {
libPublisher.SmartPublisherOnCaptureVideoData(publisherHandle, data, data.length, currentCameraType, currentOrigentation);
}
camera.addCallbackBuffer(data);
}
}
代码示例来源:origin: daniulive/SmarterStreaming
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
frameCount++;
if ( frameCount % 3000 == 0 )
{
Log.i("OnPre", "gc+");
System.gc();
Log.i("OnPre", "gc-");
}
if (data == null) {
Parameters params = camera.getParameters();
Size size = params.getPreviewSize();
int bufferSize = (((size.width|0x1f)+1) * size.height * ImageFormat.getBitsPerPixel(params.getPreviewFormat())) / 8;
camera.addCallbackBuffer(new byte[bufferSize]);
}
else
{
if(isPushing || isRecording)
{
libPublisher.SmartPublisherOnCaptureVideoData(publisherHandle, data, data.length, currentCameraType, currentOrigentation);
}
camera.addCallbackBuffer(data);
}
}
}
代码示例来源:origin: daniulive/SmarterStreaming
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
pushFrameCount++;
if ( pushFrameCount % 3000 == 0 )
{
Log.i("OnPre", "gc+");
System.gc();
Log.i("OnPre", "gc-");
}
if (data == null) {
Parameters params = camera.getParameters();
Size size = params.getPreviewSize();
int bufferSize = (((size.width|0x1f)+1) * size.height * ImageFormat.getBitsPerPixel(params.getPreviewFormat())) / 8;
camera.addCallbackBuffer(new byte[bufferSize]);
}
else
{
if( isPushStart )
{
libPublisher.SmartPublisherOnCaptureVideoData(publisherHandle, data, data.length, pushCurrentCameraType, currentPushOrigentation);
}
camera.addCallbackBuffer(data);
}
}
代码示例来源:origin: daniulive/SmarterStreaming
mCamera.addCallbackBuffer(new byte[bufferSize]);
代码示例来源:origin: daniulive/SmarterStreaming
pushCamera.addCallbackBuffer(new byte[bufferSize]);
代码示例来源:origin: daniulive/SmarterStreaming
mCamera.addCallbackBuffer(new byte[bufferSize]);
代码示例来源:origin: robolectric/robolectric
@Test
public void testAddCallbackBuffer() {
byte[] buf1 = new byte[0];
byte[] buf2 = new byte[1];
camera.addCallbackBuffer(buf1);
assertThat(shadowCamera.getAddedCallbackBuffers()).containsExactly(buf1);
camera.addCallbackBuffer(buf2);
assertThat(shadowCamera.getAddedCallbackBuffers()).containsExactly(buf1, buf2);
}
代码示例来源:origin: googlesamples/android-vision
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
代码示例来源:origin: googlesamples/android-vision
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
代码示例来源:origin: googlesamples/android-vision
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
代码示例来源:origin: googlesamples/android-vision
Log.e(TAG, "Exception thrown from receiver.", t);
} finally {
mCamera.addCallbackBuffer(data.array());
代码示例来源:origin: googlesamples/android-vision
Log.e(TAG, "Exception thrown from receiver.", t);
} finally {
mCamera.addCallbackBuffer(data.array());
代码示例来源:origin: googlesamples/android-vision
Log.e(TAG, "Exception thrown from receiver.", t);
} finally {
camera.addCallbackBuffer(data.array());
代码示例来源:origin: doggycoder/AndroidOpenGLDemo
public void addBuffer(byte[] buffer){
if(mCamera!=null){
mCamera.addCallbackBuffer(buffer);
}
}
代码示例来源:origin: doggycoder/AndroidOpenGLDemo
public void addBuffer(byte[] buffer){
if(mCamera!=null){
mCamera.addCallbackBuffer(buffer);
}
}
代码示例来源:origin: WangShuo1143368701/WSLiveDemo
private boolean prepareVideo() {
if (resCoreParameters.filterMode == RESCoreParameters.FILTER_MODE_SOFT) {
camera.addCallbackBuffer(new byte[resCoreParameters.previewBufferSize]);
camera.addCallbackBuffer(new byte[resCoreParameters.previewBufferSize]);
}
return true;
}
代码示例来源:origin: WangShuo1143368701/WSLiveDemo
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
synchronized (syncOp) {
if (videoCore != null && data != null) {
((RESSoftVideoCore) videoCore).queueVideo(data);
}
camera.addCallbackBuffer(data);
}
}
});
内容来源于网络,如有侵权,请联系作者删除!