From: ws29.jung Date: Wed, 18 Nov 2015 01:20:24 +0000 (+0900) Subject: [MM][M47] Fix segment fault with GetUserMedia X-Git-Tag: submit/tizen/20190801.160004~1160 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ffd26150564aba91d87402a76c52c8a5625780b;p=platform%2Fframework%2Fweb%2Fchromium-efl.git [MM][M47] Fix segment fault with GetUserMedia With Camera capture, new function(OnIncomingCapturedYuvData) is introduced on M47 and replacing |OnIncomingCapturedVideoFrame| to new function resolve the segmentation fault problem with GetUserMedia. Also, using new function does not require allocate buffer on efl(client) side, so allocating and deallocating functions are removed. Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=14494 Reviewed by: sm.venugopal, sns.park Change-Id: I86a8ebdd67a177c27feb5193f2c5c45b43ec1041 Signed-off-by: ws29.jung --- diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc index 9de2489c3efe..bb5a73970f7f 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc +++ b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc @@ -205,7 +205,6 @@ void VideoCaptureDeviceTizen::StopAndDeAllocate() { base::Bind(&VideoCaptureDeviceTizen::OnStopAndDeAllocate, base::Unretained(this))); worker_.Stop(); - DeAllocateVideoBuffers(); } camera_device_e VideoCaptureDeviceTizen::DeviceNameToCameraId( @@ -232,6 +231,7 @@ std::string VideoCaptureDeviceTizen::GetCameraErrorMessage(int err_code) { void VideoCaptureDeviceTizen::OnCameraCaptured(camera_preview_data_s* frame, void* data) { + CHECK(frame->format == CAMERA_PIXEL_FORMAT_I420); VideoCaptureDeviceTizen* self = static_cast(data); camera_attr_fps_e current_fps = static_cast(kTypicalFramerate); @@ -246,42 +246,22 @@ void VideoCaptureDeviceTizen::OnCameraCaptured(camera_preview_data_s* frame, 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(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(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::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(current_fps); + videocaptureformat.pixel_format = media::PIXEL_FORMAT_I420; + + self->client_->OnIncomingCapturedYuvData( + reinterpret_cast(frame->data.triple_plane.y), + reinterpret_cast(frame->data.triple_plane.u), + reinterpret_cast(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, @@ -367,13 +347,6 @@ 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_)) { @@ -387,23 +360,11 @@ void VideoCaptureDeviceTizen::OnStopAndDeAllocate() { 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() || diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h index 3f7390bf667b..9461d2211cf3 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h +++ b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h @@ -51,8 +51,6 @@ class VideoCaptureDeviceTizen : public VideoCaptureDevice { scoped_ptr client); void OnStopAndDeAllocate(); - bool AllocateVideoBuffers(int width, int height); - void DeAllocateVideoBuffers(); void SetErrorState(const std::string& reason); InternalState state_;