Index: content/browser/renderer_host/media/video_capture_controller.cc |
diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc |
index 4775a77c061688c4dfb76d33b847fd23be70eeaf..dcaf531957897d4cbd06c63eacdd623e64ed8610 100644 |
--- a/content/browser/renderer_host/media/video_capture_controller.cc |
+++ b/content/browser/renderer_host/media/video_capture_controller.cc |
@@ -12,8 +12,10 @@ |
#include "base/metrics/histogram.h" |
#include "base/metrics/sparse_histogram.h" |
#include "base/stl_util.h" |
+#include "content/browser/compositor/image_transport_factory.h" |
#include "content/browser/renderer_host/media/media_stream_manager.h" |
#include "content/browser/renderer_host/media/video_capture_manager.h" |
+#include "content/common/gpu/client/gl_helper.h" |
#include "content/public/browser/browser_thread.h" |
#include "gpu/command_buffer/common/mailbox_holder.h" |
#include "media/base/video_frame.h" |
@@ -53,6 +55,31 @@ class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { |
const scoped_refptr<VideoCaptureBufferPool> pool_; |
}; |
+class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
+ public: |
+ explicit SyncPointClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} |
+ virtual ~SyncPointClientImpl() {} |
+ virtual uint32 InsertSyncPoint() OVERRIDE { |
+ return gl_helper_->InsertSyncPoint(); |
+ } |
+ virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE { |
+ gl_helper_->WaitSyncPoint(sync_point); |
+ } |
+ |
+ private: |
+ GLHelper* gl_helper_; |
+}; |
+ |
+void ReturnVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
+ uint32 sync_point) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
dshwang
2014/06/23 19:42:07
I found that android can not use ImageTransportFac
|
+ DCHECK(gl_helper); |
+ gl_helper->WaitSyncPoint(sync_point); |
+ SyncPointClientImpl client(gl_helper); |
+ video_frame->UpdateReleaseSyncPoint(&client); |
+} |
+ |
} // anonymous namespace |
struct VideoCaptureController::ControllerClient { |
@@ -249,7 +276,7 @@ void VideoCaptureController::ReturnBuffer( |
const VideoCaptureControllerID& id, |
VideoCaptureControllerEventHandler* event_handler, |
int buffer_id, |
- const std::vector<uint32>& sync_points) { |
+ uint32 sync_point) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
ControllerClient* client = FindClient(id, event_handler, controller_clients_); |
@@ -264,13 +291,12 @@ void VideoCaptureController::ReturnBuffer( |
} |
scoped_refptr<media::VideoFrame> frame = iter->second; |
client->active_buffers.erase(iter); |
- |
- if (frame->format() == media::VideoFrame::NATIVE_TEXTURE) { |
- for (size_t i = 0; i < sync_points.size(); i++) |
- frame->AppendReleaseSyncPoint(sync_points[i]); |
- } |
- |
buffer_pool_->RelinquishConsumerHold(buffer_id, 1); |
+ |
+ if (sync_point) |
+ BrowserThread::PostTask(BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&ReturnVideoFrame, frame, sync_point)); |
} |
const media::VideoCaptureFormat& |