1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=53afe2dd1a5d413790a04a6d622bf0175302da00$
13 //
14
15 #include "libcef_dll/ctocpp/media_observer_ctocpp.h"
16 #include "libcef_dll/cpptoc/media_route_cpptoc.h"
17 #include "libcef_dll/cpptoc/media_sink_cpptoc.h"
18 #include "libcef_dll/shutdown_checker.h"
19
20 // VIRTUAL METHODS - Body may be edited by hand.
21
22 NO_SANITIZE("cfi-icall")
OnSinks(const std::vector<CefRefPtr<CefMediaSink>> & sinks)23 void CefMediaObserverCToCpp::OnSinks(
24 const std::vector<CefRefPtr<CefMediaSink>>& sinks) {
25 shutdown_checker::AssertNotShutdown();
26
27 cef_media_observer_t* _struct = GetStruct();
28 if (CEF_MEMBER_MISSING(_struct, on_sinks))
29 return;
30
31 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
32
33 // Translate param: sinks; type: refptr_vec_diff_byref_const
34 const size_t sinksCount = sinks.size();
35 cef_media_sink_t** sinksList = NULL;
36 if (sinksCount > 0) {
37 sinksList = new cef_media_sink_t*[sinksCount];
38 DCHECK(sinksList);
39 if (sinksList) {
40 for (size_t i = 0; i < sinksCount; ++i) {
41 sinksList[i] = CefMediaSinkCppToC::Wrap(sinks[i]);
42 }
43 }
44 }
45
46 // Execute
47 _struct->on_sinks(_struct, sinksCount, sinksList);
48
49 // Restore param:sinks; type: refptr_vec_diff_byref_const
50 if (sinksList)
51 delete[] sinksList;
52 }
53
54 NO_SANITIZE("cfi-icall")
OnRoutes(const std::vector<CefRefPtr<CefMediaRoute>> & routes)55 void CefMediaObserverCToCpp::OnRoutes(
56 const std::vector<CefRefPtr<CefMediaRoute>>& routes) {
57 shutdown_checker::AssertNotShutdown();
58
59 cef_media_observer_t* _struct = GetStruct();
60 if (CEF_MEMBER_MISSING(_struct, on_routes))
61 return;
62
63 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
64
65 // Translate param: routes; type: refptr_vec_diff_byref_const
66 const size_t routesCount = routes.size();
67 cef_media_route_t** routesList = NULL;
68 if (routesCount > 0) {
69 routesList = new cef_media_route_t*[routesCount];
70 DCHECK(routesList);
71 if (routesList) {
72 for (size_t i = 0; i < routesCount; ++i) {
73 routesList[i] = CefMediaRouteCppToC::Wrap(routes[i]);
74 }
75 }
76 }
77
78 // Execute
79 _struct->on_routes(_struct, routesCount, routesList);
80
81 // Restore param:routes; type: refptr_vec_diff_byref_const
82 if (routesList)
83 delete[] routesList;
84 }
85
86 NO_SANITIZE("cfi-icall")
OnRouteStateChanged(CefRefPtr<CefMediaRoute> route,ConnectionState state)87 void CefMediaObserverCToCpp::OnRouteStateChanged(CefRefPtr<CefMediaRoute> route,
88 ConnectionState state) {
89 shutdown_checker::AssertNotShutdown();
90
91 cef_media_observer_t* _struct = GetStruct();
92 if (CEF_MEMBER_MISSING(_struct, on_route_state_changed))
93 return;
94
95 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
96
97 // Verify param: route; type: refptr_diff
98 DCHECK(route.get());
99 if (!route.get())
100 return;
101
102 // Execute
103 _struct->on_route_state_changed(_struct, CefMediaRouteCppToC::Wrap(route),
104 state);
105 }
106
107 NO_SANITIZE("cfi-icall")
OnRouteMessageReceived(CefRefPtr<CefMediaRoute> route,const void * message,size_t message_size)108 void CefMediaObserverCToCpp::OnRouteMessageReceived(
109 CefRefPtr<CefMediaRoute> route,
110 const void* message,
111 size_t message_size) {
112 shutdown_checker::AssertNotShutdown();
113
114 cef_media_observer_t* _struct = GetStruct();
115 if (CEF_MEMBER_MISSING(_struct, on_route_message_received))
116 return;
117
118 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
119
120 // Verify param: route; type: refptr_diff
121 DCHECK(route.get());
122 if (!route.get())
123 return;
124 // Verify param: message; type: simple_byaddr
125 DCHECK(message);
126 if (!message)
127 return;
128
129 // Execute
130 _struct->on_route_message_received(_struct, CefMediaRouteCppToC::Wrap(route),
131 message, message_size);
132 }
133
134 // CONSTRUCTOR - Do not edit by hand.
135
CefMediaObserverCToCpp()136 CefMediaObserverCToCpp::CefMediaObserverCToCpp() {}
137
138 // DESTRUCTOR - Do not edit by hand.
139
~CefMediaObserverCToCpp()140 CefMediaObserverCToCpp::~CefMediaObserverCToCpp() {
141 shutdown_checker::AssertNotShutdown();
142 }
143
144 template <>
145 cef_media_observer_t*
146 CefCToCppRefCounted<CefMediaObserverCToCpp,
147 CefMediaObserver,
UnwrapDerived(CefWrapperType type,CefMediaObserver * c)148 cef_media_observer_t>::UnwrapDerived(CefWrapperType type,
149 CefMediaObserver* c) {
150 NOTREACHED() << "Unexpected class type: " << type;
151 return nullptr;
152 }
153
154 template <>
155 CefWrapperType CefCToCppRefCounted<CefMediaObserverCToCpp,
156 CefMediaObserver,
157 cef_media_observer_t>::kWrapperType =
158 WT_MEDIA_OBSERVER;
159