base::Bind(&VideoCaptureDeviceTizen::OnStopAndDeAllocate,
base::Unretained(this)));
worker_.Stop();
- DeAllocateVideoBuffers();
}
camera_device_e VideoCaptureDeviceTizen::DeviceNameToCameraId(
void VideoCaptureDeviceTizen::OnCameraCaptured(camera_preview_data_s* frame,
void* data) {
+ CHECK(frame->format == CAMERA_PIXEL_FORMAT_I420);
VideoCaptureDeviceTizen* self = static_cast<VideoCaptureDeviceTizen*>(data);
camera_attr_fps_e current_fps =
static_cast<camera_attr_fps_e>(kTypicalFramerate);
gfx::Size target_resolution(frame->width, frame->height);
int target_rotation = (orientation +
GetCameraOrientation(self->device_name_.id().c_str())) % DEGREE_360;
- if ((target_rotation / DEGREE_90) & 0x1) {
- target_resolution.SetSize(frame->height, frame->width);
- DVLOG(3) << " rotation from:" << orientation
- << " to: " << target_rotation;
- }
- uint8* yplane = reinterpret_cast<uint8*>(self->buffer_->data());
- uint8* uplane = yplane + frame->data.triple_plane.y_size;
- uint8* vplane = uplane + frame->data.triple_plane.u_size;
int src_stride_y = frame->width;
int src_stride_uv = (src_stride_y + 1) / 2;
- int tgt_stride_y = target_resolution.width();
- int tgt_stride_uv = (tgt_stride_y + 1) / 2;
-
- if (0 != libyuv::I420Rotate(
- frame->data.triple_plane.y, src_stride_y,
- frame->data.triple_plane.u, src_stride_uv,
- frame->data.triple_plane.v, src_stride_uv,
- yplane, tgt_stride_y,
- uplane, tgt_stride_uv,
- vplane, tgt_stride_uv,
- frame->width, frame->height,
- static_cast<libyuv::RotationMode>(target_rotation))) {
- LOG(ERROR) << " Error when rotating the video frame";
- }
WEBRTC_DEBUG_DUMPFRAME(frame, yplane);
- gfx::Rect rect(target_resolution.width(), target_resolution.height());
-
- scoped_refptr<VideoFrame> videoframe =
- VideoFrame::CreateFrame(media::PIXEL_FORMAT_I420, target_resolution,
- rect, target_resolution, base::TimeDelta());
-
- self->client_->OnIncomingCapturedVideoFrame(self->buffer_.Pass(),
- videoframe,
- base::TimeTicks::Now());
+ media::VideoCaptureFormat videocaptureformat;
+ videocaptureformat.frame_size = gfx::Size(frame->width, frame->height);
+ videocaptureformat.frame_rate = static_cast<int>(current_fps);
+ videocaptureformat.pixel_format = media::PIXEL_FORMAT_I420;
+
+ self->client_->OnIncomingCapturedYuvData(
+ reinterpret_cast<uint8*>(frame->data.triple_plane.y),
+ reinterpret_cast<uint8*>(frame->data.triple_plane.u),
+ reinterpret_cast<uint8*>(frame->data.triple_plane.v),
+ src_stride_y, src_stride_uv, src_stride_uv,
+ videocaptureformat, target_rotation, base::TimeTicks::Now());
}
void VideoCaptureDeviceTizen::OnAllocateAndStart(int width,
return;
}
}
-
- if (!AllocateVideoBuffers(width, height)) {
- LOG(ERROR) << "Allocate buffer failed";
- SetErrorState("Camera internal Error");
- return;
- }
-
state_ = kCapturing;
if (CAMERA_ERROR_NONE != camera_start_preview(camera_)) {
camera_stop_preview(camera_);
camera_destroy(camera_);
- DeAllocateVideoBuffers();
state_ = kIdle;
client_.reset();
}
-bool VideoCaptureDeviceTizen::AllocateVideoBuffers(int width, int height) {
- buffer_ = client_->ReserveOutputBuffer(gfx::Size(width, height),
- media::PIXEL_FORMAT_I420,
- media::PIXEL_STORAGE_GPUMEMORYBUFFER);
- return (buffer_.get() != NULL);
-}
-
-void VideoCaptureDeviceTizen::DeAllocateVideoBuffers() {
- /* Nothing to do */
-}
-
void VideoCaptureDeviceTizen::SetErrorState(const std::string& reason) {
LOG(ERROR) << "Camera Error: " << reason;
DCHECK(!worker_.IsRunning() ||