Index: ppapi/thunk/ppb_video_capture_thunk.cc |
diff --git a/ppapi/thunk/ppb_video_capture_thunk.cc b/ppapi/thunk/ppb_video_capture_thunk.cc |
index fbd1f2b7d4b4c9c51436115482324595e939ae4f..9e6cd5d6b1f8f9a90249b85b2688272a753ca928 100644 |
--- a/ppapi/thunk/ppb_video_capture_thunk.cc |
+++ b/ppapi/thunk/ppb_video_capture_thunk.cc |
@@ -3,11 +3,13 @@ |
// found in the LICENSE file. |
#include "ppapi/c/pp_errors.h" |
+#include "ppapi/shared_impl/ppb_device_ref_shared.h" |
#include "ppapi/thunk/common.h" |
#include "ppapi/thunk/enter.h" |
-#include "ppapi/thunk/thunk.h" |
+#include "ppapi/thunk/ppb_device_ref_api.h" |
#include "ppapi/thunk/ppb_video_capture_api.h" |
#include "ppapi/thunk/resource_creation_api.h" |
+#include "ppapi/thunk/thunk.h" |
namespace ppapi { |
namespace thunk { |
@@ -28,14 +30,49 @@ PP_Bool IsVideoCapture(PP_Resource resource) { |
return PP_FromBool(enter.succeeded()); |
} |
-int32_t StartCapture(PP_Resource video_capture, |
- const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
- uint32_t buffer_count) { |
+int32_t EnumerateDevices(PP_Resource video_capture, |
+ PP_CompletionCallback callback) { |
+ EnterVideoCapture enter(video_capture, true); |
+ if (enter.failed()) |
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
+ |
+ int32_t result = enter.object()->EnumerateDevices(callback); |
+ return MayForceCallback(callback, result); |
+} |
+ |
+PP_Resource GetDevices(PP_Resource video_capture) { |
+ EnterVideoCapture enter(video_capture, true); |
+ if (enter.failed()) |
+ return 0; |
+ |
+ return enter.object()->GetDevices(); |
+} |
+ |
+int32_t StartCapture0_2(PP_Resource video_capture, |
+ PP_Resource device_ref, |
+ const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
+ uint32_t buffer_count) { |
EnterVideoCapture enter(video_capture, true); |
if (enter.failed()) |
return PP_ERROR_BADRESOURCE; |
- return enter.object()->StartCapture(*requested_info, buffer_count); |
+ std::string device_id; |
+ // |device_id| remains empty if |device_ref| is 0, which means the default |
+ // device. |
+ if (device_ref != 0) { |
+ EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); |
+ if (enter_device_ref.failed()) |
+ return PP_ERROR_BADRESOURCE; |
+ device_id = enter_device_ref.object()->GetDeviceRefData().id; |
+ } |
+ |
+ return enter.object()->StartCapture(device_id, *requested_info, buffer_count); |
+} |
+ |
+int32_t StartCapture0_1(PP_Resource video_capture, |
+ const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
+ uint32_t buffer_count) { |
+ return StartCapture0_2(video_capture, 0, requested_info, buffer_count); |
} |
int32_t ReuseBuffer(PP_Resource video_capture, |
@@ -55,10 +92,20 @@ int32_t StopCapture(PP_Resource video_capture) { |
return enter.object()->StopCapture(); |
} |
-const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = { |
+const PPB_VideoCapture_Dev_0_1 g_ppb_video_capture_0_1_thunk = { |
&Create, |
&IsVideoCapture, |
- &StartCapture, |
+ &StartCapture0_1, |
+ &ReuseBuffer, |
+ &StopCapture |
+}; |
+ |
+const PPB_VideoCapture_Dev_0_2 g_ppb_video_capture_0_2_thunk = { |
+ &Create, |
+ &IsVideoCapture, |
+ &EnumerateDevices, |
+ &GetDevices, |
+ &StartCapture0_2, |
&ReuseBuffer, |
&StopCapture |
}; |
@@ -66,7 +113,11 @@ const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = { |
} // namespace |
const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() { |
- return &g_ppb_videocapture_thunk; |
+ return &g_ppb_video_capture_0_1_thunk; |
+} |
+ |
+const PPB_VideoCapture_Dev_0_2* GetPPB_VideoCapture_Dev_0_2_Thunk() { |
+ return &g_ppb_video_capture_0_2_thunk; |
} |
} // namespace thunk |