Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1058)

Side by Side Diff: content/browser/renderer_host/media/video_capture_device_client.cc

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mock gpu video accelerator factory Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/video_capture_device_client.h" 5 #include "content/browser/renderer_host/media/video_capture_device_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 // Creates some necessary members in |capture_task_runner_|. 166 // Creates some necessary members in |capture_task_runner_|.
167 void Init(); 167 void Init();
168 // Runs the bottom half of the GlHelper creation. 168 // Runs the bottom half of the GlHelper creation.
169 void CreateGlHelper( 169 void CreateGlHelper(
170 scoped_refptr<ContextProviderCommandBuffer> capture_thread_context); 170 scoped_refptr<ContextProviderCommandBuffer> capture_thread_context);
171 171
172 // Recycles |memory_buffer|, deletes Image and Texture on VideoFrame release. 172 // Recycles |memory_buffer|, deletes Image and Texture on VideoFrame release.
173 void ReleaseCallback(const std::vector<GLuint>& image_ids, 173 void ReleaseCallback(const std::vector<GLuint>& image_ids,
174 const std::vector<GLuint>& texture_ids, 174 const std::vector<GLuint>& texture_ids,
175 uint32 sync_point); 175 uint32 sync_point,
176 const gpu::SyncToken& sync_token);
176 177
177 // The Command Buffer lost the GL context, f.i. GPU process crashed. Signal 178 // The Command Buffer lost the GL context, f.i. GPU process crashed. Signal
178 // error to our owner so the capture can be torn down. 179 // error to our owner so the capture can be torn down.
179 void LostContextCallback(); 180 void LostContextCallback();
180 181
181 // Prints the error |message| and notifies |controller_| of an error. 182 // Prints the error |message| and notifies |controller_| of an error.
182 void OnError(const std::string& message); 183 void OnError(const std::string& message);
183 184
184 // |controller_| should only be used on IO thread. 185 // |controller_| should only be used on IO thread.
185 const base::WeakPtr<VideoCaptureController> controller_; 186 const base::WeakPtr<VideoCaptureController> controller_;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 texture_id); 642 texture_id);
642 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); 643 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id);
643 } 644 }
644 texture_ids.push_back(texture_id); 645 texture_ids.push_back(texture_id);
645 646
646 const gpu::MailboxHolder& mailbox_holder( 647 const gpu::MailboxHolder& mailbox_holder(
647 gl_helper_->ProduceMailboxHolderFromTexture(texture_id)); 648 gl_helper_->ProduceMailboxHolderFromTexture(texture_id));
648 DCHECK(!mailbox_holder.mailbox.IsZero()); 649 DCHECK(!mailbox_holder.mailbox.IsZero());
649 DCHECK(mailbox_holder.mailbox.Verify()); 650 DCHECK(mailbox_holder.mailbox.Verify());
650 DCHECK(mailbox_holder.texture_target); 651 DCHECK(mailbox_holder.texture_target);
651 DCHECK(mailbox_holder.sync_point); 652 DCHECK(mailbox_holder.sync_point || mailbox_holder.sync_token.HasData());
652 mailbox_holders.push_back(mailbox_holder); 653 mailbox_holders.push_back(mailbox_holder);
653 } 654 }
654 655
655 scoped_refptr<media::VideoFrame> video_frame = 656 scoped_refptr<media::VideoFrame> video_frame =
656 VideoFrame::WrapYUV420NativeTextures( 657 VideoFrame::WrapYUV420NativeTextures(
657 mailbox_holders[VideoFrame::kYPlane], 658 mailbox_holders[VideoFrame::kYPlane],
658 mailbox_holders[VideoFrame::kUPlane], 659 mailbox_holders[VideoFrame::kUPlane],
659 mailbox_holders[VideoFrame::kVPlane], 660 mailbox_holders[VideoFrame::kVPlane],
660 media::BindToCurrentLoop(base::Bind( 661 media::BindToCurrentLoop(base::Bind(
661 &VideoCaptureDeviceClient::TextureWrapHelper::ReleaseCallback, 662 &VideoCaptureDeviceClient::TextureWrapHelper::ReleaseCallback,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 // At this point, |capture_thread_context| is a cc::ContextProvider. Creation 733 // At this point, |capture_thread_context| is a cc::ContextProvider. Creation
733 // of our GLHelper should happen on Capture Thread. 734 // of our GLHelper should happen on Capture Thread.
734 gl_helper_.reset(new GLHelper(capture_thread_context->ContextGL(), 735 gl_helper_.reset(new GLHelper(capture_thread_context->ContextGL(),
735 capture_thread_context->ContextSupport())); 736 capture_thread_context->ContextSupport()));
736 DCHECK(gl_helper_); 737 DCHECK(gl_helper_);
737 } 738 }
738 739
739 void VideoCaptureDeviceClient::TextureWrapHelper::ReleaseCallback( 740 void VideoCaptureDeviceClient::TextureWrapHelper::ReleaseCallback(
740 const std::vector<GLuint>& image_ids, 741 const std::vector<GLuint>& image_ids,
741 const std::vector<GLuint>& texture_ids, 742 const std::vector<GLuint>& texture_ids,
742 uint32 sync_point) { 743 uint32 sync_point,
744 const gpu::SyncToken& sync_token) {
743 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 745 DCHECK(capture_task_runner_->BelongsToCurrentThread());
744 DCHECK_EQ(image_ids.size(), texture_ids.size()); 746 DCHECK_EQ(image_ids.size(), texture_ids.size());
745 747
746 if (!gl_helper_) 748 if (!gl_helper_)
747 return; 749 return;
748 for (size_t i = 0; i < image_ids.size(); ++i) { 750 for (size_t i = 0; i < image_ids.size(); ++i) {
749 gl_helper_->DeleteTexture(texture_ids[i]); 751 gl_helper_->DeleteTexture(texture_ids[i]);
750 capture_thread_context_->ContextGL()->DestroyImageCHROMIUM(image_ids[i]); 752 capture_thread_context_->ContextGL()->DestroyImageCHROMIUM(image_ids[i]);
751 } 753 }
752 } 754 }
753 755
754 void VideoCaptureDeviceClient::TextureWrapHelper::LostContextCallback() { 756 void VideoCaptureDeviceClient::TextureWrapHelper::LostContextCallback() {
755 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 757 DCHECK(capture_task_runner_->BelongsToCurrentThread());
756 // Prevent incoming frames from being processed while OnError gets groked. 758 // Prevent incoming frames from being processed while OnError gets groked.
757 gl_helper_.reset(); 759 gl_helper_.reset();
758 OnError("GLContext lost"); 760 OnError("GLContext lost");
759 } 761 }
760 762
761 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( 763 void VideoCaptureDeviceClient::TextureWrapHelper::OnError(
762 const std::string& message) { 764 const std::string& message) {
763 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 765 DCHECK(capture_task_runner_->BelongsToCurrentThread());
764 DLOG(ERROR) << message; 766 DLOG(ERROR) << message;
765 BrowserThread::PostTask( 767 BrowserThread::PostTask(
766 BrowserThread::IO, FROM_HERE, 768 BrowserThread::IO, FROM_HERE,
767 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); 769 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_));
768 } 770 }
769 771
770 } // namespace content 772 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698