• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "ppapi/c/pp_completion_callback.h"
6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/c/private/pp_video_frame_private.h"
8 #include "ppapi/c/private/ppb_video_destination_private.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppb_instance_api.h"
12 #include "ppapi/thunk/ppb_video_destination_private_api.h"
13 #include "ppapi/thunk/resource_creation_api.h"
14 #include "ppapi/thunk/thunk.h"
15 
16 namespace ppapi {
17 namespace thunk {
18 
19 namespace {
20 
Create(PP_Instance instance)21 PP_Resource Create(PP_Instance instance) {
22   EnterResourceCreation enter(instance);
23   if (enter.failed())
24     return 0;
25   return enter.functions()->CreateVideoDestination(instance);
26 }
27 
IsVideoDestination(PP_Resource resource)28 PP_Bool IsVideoDestination(PP_Resource resource) {
29   EnterResource<PPB_VideoDestination_Private_API> enter(resource, false);
30   return PP_FromBool(enter.succeeded());
31 }
32 
Open(PP_Resource destination,PP_Var stream_url,PP_CompletionCallback callback)33 int32_t Open(PP_Resource destination,
34              PP_Var stream_url,
35              PP_CompletionCallback callback) {
36   EnterResource<PPB_VideoDestination_Private_API> enter(destination,
37                                                         callback, true);
38   if (enter.failed())
39     return enter.retval();
40   return enter.SetResult(enter.object()->Open(stream_url, enter.callback()));
41 }
42 
PutFrame(PP_Resource destination,const PP_VideoFrame_Private * frame)43 int32_t PutFrame(PP_Resource destination,
44                  const PP_VideoFrame_Private* frame) {
45   EnterResource<PPB_VideoDestination_Private_API> enter(destination, true);
46   if (enter.failed())
47     return enter.retval();
48   return enter.object()->PutFrame(*frame);
49 }
50 
Close(PP_Resource destination)51 void Close(PP_Resource destination) {
52   EnterResource<PPB_VideoDestination_Private_API> enter(destination, true);
53   if (enter.succeeded())
54     enter.object()->Close();
55 }
56 
57 const PPB_VideoDestination_Private_0_1
58     g_ppb_video_destination_private_thunk_0_1 = {
59   &Create,
60   &IsVideoDestination,
61   &Open,
62   &PutFrame,
63   &Close
64 };
65 
66 }  // namespace
67 
68 const PPB_VideoDestination_Private_0_1*
GetPPB_VideoDestination_Private_0_1_Thunk()69     GetPPB_VideoDestination_Private_0_1_Thunk() {
70   return &g_ppb_video_destination_private_thunk_0_1;
71 }
72 
73 }  // namespace thunk
74 }  // namespace ppapi
75