Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / webrtc / webrtc_video_capturer_adapter.cc
index 6d6f7ff..eb56669 100644 (file)
@@ -17,6 +17,7 @@ WebRtcVideoCapturerAdapter::WebRtcVideoCapturerAdapter(bool is_screencast)
       running_(false),
       buffer_(NULL),
       buffer_size_(0) {
+  thread_checker_.DetachFromThread();
 }
 
 WebRtcVideoCapturerAdapter::~WebRtcVideoCapturerAdapter() {
@@ -24,27 +25,9 @@ WebRtcVideoCapturerAdapter::~WebRtcVideoCapturerAdapter() {
   base::AlignedFree(buffer_);
 }
 
-void WebRtcVideoCapturerAdapter::SetRequestedFormat(
-    const media::VideoCaptureFormat& format) {
-  DCHECK_EQ(media::PIXEL_FORMAT_I420, format.pixel_format);
-  DVLOG(3) << "WebRtcVideoCapturerAdapter::SetRequestedFormat"
-           << " w = " << format.frame_size.width()
-           << " h = " << format.frame_size.height();
-  cricket::VideoFormat supported_format(format.frame_size.width(),
-                                        format.frame_size.height(),
-                                        cricket::VideoFormat::FpsToInterval(
-                                            format.frame_rate),
-                                        cricket::FOURCC_I420);
-  SetCaptureFormat(&supported_format);
-
-  // Update the desired aspect ratio so that later the video frame can be
-  // cropped to meet the requirement if the camera returns a different
-  // resolution than the |request|.
-  UpdateAspectRatio(format.frame_size.width(), format.frame_size.height());
-}
-
 cricket::CaptureState WebRtcVideoCapturerAdapter::Start(
     const cricket::VideoFormat& capture_format) {
+  DCHECK(thread_checker_.CalledOnValidThread());
   DCHECK(!running_);
   DVLOG(3) << " WebRtcVideoCapturerAdapter::Start w = " << capture_format.width
            << " h = " << capture_format.height;
@@ -54,6 +37,7 @@ cricket::CaptureState WebRtcVideoCapturerAdapter::Start(
 }
 
 void WebRtcVideoCapturerAdapter::Stop() {
+  DCHECK(thread_checker_.CalledOnValidThread());
   DVLOG(3) << " WebRtcVideoCapturerAdapter::Stop ";
   DCHECK(running_);
   running_ = false;
@@ -62,11 +46,13 @@ void WebRtcVideoCapturerAdapter::Stop() {
 }
 
 bool WebRtcVideoCapturerAdapter::IsRunning() {
+  DCHECK(thread_checker_.CalledOnValidThread());
   return running_;
 }
 
 bool WebRtcVideoCapturerAdapter::GetPreferredFourccs(
     std::vector<uint32>* fourccs) {
+  DCHECK(thread_checker_.CalledOnValidThread());
   if (!fourccs)
     return false;
   fourccs->push_back(cricket::FOURCC_I420);
@@ -80,6 +66,7 @@ bool WebRtcVideoCapturerAdapter::IsScreencast() const {
 bool WebRtcVideoCapturerAdapter::GetBestCaptureFormat(
     const cricket::VideoFormat& desired,
     cricket::VideoFormat* best_format) {
+  DCHECK(thread_checker_.CalledOnValidThread());
   DVLOG(3) << " GetBestCaptureFormat:: "
            << " w = " << desired.width
            << " h = " << desired.height;
@@ -96,19 +83,20 @@ bool WebRtcVideoCapturerAdapter::GetBestCaptureFormat(
 
 void WebRtcVideoCapturerAdapter::OnFrameCaptured(
     const scoped_refptr<media::VideoFrame>& frame) {
+  DCHECK(thread_checker_.CalledOnValidThread());
   DCHECK(media::VideoFrame::I420 == frame->format() ||
          media::VideoFrame::YV12 == frame->format());
   if (first_frame_timestamp_ == media::kNoTimestamp())
-    first_frame_timestamp_ = frame->GetTimestamp();
+    first_frame_timestamp_ = frame->timestamp();
 
   cricket::CapturedFrame captured_frame;
   captured_frame.width = frame->visible_rect().width();
   captured_frame.height = frame->visible_rect().height();
   // cricket::CapturedFrame time is in nanoseconds.
   captured_frame.elapsed_time =
-      (frame->GetTimestamp() - first_frame_timestamp_).InMicroseconds() *
+      (frame->timestamp() - first_frame_timestamp_).InMicroseconds() *
       base::Time::kNanosecondsPerMicrosecond;
-  captured_frame.time_stamp = frame->GetTimestamp().InMicroseconds() *
+  captured_frame.time_stamp = frame->timestamp().InMicroseconds() *
                               base::Time::kNanosecondsPerMicrosecond;
   captured_frame.pixel_height = 1;
   captured_frame.pixel_width = 1;
@@ -139,6 +127,7 @@ void WebRtcVideoCapturerAdapter::OnFrameCaptured(
 
 void WebRtcVideoCapturerAdapter::UpdateI420Buffer(
     const scoped_refptr<media::VideoFrame>& src) {
+  DCHECK(thread_checker_.CalledOnValidThread());
   const int src_width = src->coded_size().width();
   const int src_height = src->coded_size().height();
   const int dst_width = src->visible_rect().width();