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=2e7db3a335f170dad7a1793f5695593b8c75d853$
13 //
14
15 #include "libcef_dll/cpptoc/media_observer_cpptoc.h"
16 #include "libcef_dll/ctocpp/media_route_ctocpp.h"
17 #include "libcef_dll/ctocpp/media_sink_ctocpp.h"
18 #include "libcef_dll/shutdown_checker.h"
19
20 namespace {
21
22 // MEMBER FUNCTIONS - Body may be edited by hand.
23
24 void CEF_CALLBACK
media_observer_on_sinks(struct _cef_media_observer_t * self,size_t sinksCount,struct _cef_media_sink_t * const * sinks)25 media_observer_on_sinks(struct _cef_media_observer_t* self,
26 size_t sinksCount,
27 struct _cef_media_sink_t* const* sinks) {
28 shutdown_checker::AssertNotShutdown();
29
30 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
31
32 DCHECK(self);
33 if (!self)
34 return;
35 // Verify param: sinks; type: refptr_vec_diff_byref_const
36 DCHECK(sinksCount == 0 || sinks);
37 if (sinksCount > 0 && !sinks)
38 return;
39
40 // Translate param: sinks; type: refptr_vec_diff_byref_const
41 std::vector<CefRefPtr<CefMediaSink>> sinksList;
42 if (sinksCount > 0) {
43 for (size_t i = 0; i < sinksCount; ++i) {
44 CefRefPtr<CefMediaSink> sinksVal = CefMediaSinkCToCpp::Wrap(sinks[i]);
45 sinksList.push_back(sinksVal);
46 }
47 }
48
49 // Execute
50 CefMediaObserverCppToC::Get(self)->OnSinks(sinksList);
51 }
52
53 void CEF_CALLBACK
media_observer_on_routes(struct _cef_media_observer_t * self,size_t routesCount,struct _cef_media_route_t * const * routes)54 media_observer_on_routes(struct _cef_media_observer_t* self,
55 size_t routesCount,
56 struct _cef_media_route_t* const* routes) {
57 shutdown_checker::AssertNotShutdown();
58
59 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
60
61 DCHECK(self);
62 if (!self)
63 return;
64 // Verify param: routes; type: refptr_vec_diff_byref_const
65 DCHECK(routesCount == 0 || routes);
66 if (routesCount > 0 && !routes)
67 return;
68
69 // Translate param: routes; type: refptr_vec_diff_byref_const
70 std::vector<CefRefPtr<CefMediaRoute>> routesList;
71 if (routesCount > 0) {
72 for (size_t i = 0; i < routesCount; ++i) {
73 CefRefPtr<CefMediaRoute> routesVal = CefMediaRouteCToCpp::Wrap(routes[i]);
74 routesList.push_back(routesVal);
75 }
76 }
77
78 // Execute
79 CefMediaObserverCppToC::Get(self)->OnRoutes(routesList);
80 }
81
media_observer_on_route_state_changed(struct _cef_media_observer_t * self,struct _cef_media_route_t * route,cef_media_route_connection_state_t state)82 void CEF_CALLBACK media_observer_on_route_state_changed(
83 struct _cef_media_observer_t* self,
84 struct _cef_media_route_t* route,
85 cef_media_route_connection_state_t state) {
86 shutdown_checker::AssertNotShutdown();
87
88 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
89
90 DCHECK(self);
91 if (!self)
92 return;
93 // Verify param: route; type: refptr_diff
94 DCHECK(route);
95 if (!route)
96 return;
97
98 // Execute
99 CefMediaObserverCppToC::Get(self)->OnRouteStateChanged(
100 CefMediaRouteCToCpp::Wrap(route), state);
101 }
102
103 void CEF_CALLBACK
media_observer_on_route_message_received(struct _cef_media_observer_t * self,struct _cef_media_route_t * route,const void * message,size_t message_size)104 media_observer_on_route_message_received(struct _cef_media_observer_t* self,
105 struct _cef_media_route_t* route,
106 const void* message,
107 size_t message_size) {
108 shutdown_checker::AssertNotShutdown();
109
110 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
111
112 DCHECK(self);
113 if (!self)
114 return;
115 // Verify param: route; type: refptr_diff
116 DCHECK(route);
117 if (!route)
118 return;
119 // Verify param: message; type: simple_byaddr
120 DCHECK(message);
121 if (!message)
122 return;
123
124 // Execute
125 CefMediaObserverCppToC::Get(self)->OnRouteMessageReceived(
126 CefMediaRouteCToCpp::Wrap(route), message, message_size);
127 }
128
129 } // namespace
130
131 // CONSTRUCTOR - Do not edit by hand.
132
CefMediaObserverCppToC()133 CefMediaObserverCppToC::CefMediaObserverCppToC() {
134 GetStruct()->on_sinks = media_observer_on_sinks;
135 GetStruct()->on_routes = media_observer_on_routes;
136 GetStruct()->on_route_state_changed = media_observer_on_route_state_changed;
137 GetStruct()->on_route_message_received =
138 media_observer_on_route_message_received;
139 }
140
141 // DESTRUCTOR - Do not edit by hand.
142
~CefMediaObserverCppToC()143 CefMediaObserverCppToC::~CefMediaObserverCppToC() {
144 shutdown_checker::AssertNotShutdown();
145 }
146
147 template <>
148 CefRefPtr<CefMediaObserver> CefCppToCRefCounted<
149 CefMediaObserverCppToC,
150 CefMediaObserver,
UnwrapDerived(CefWrapperType type,cef_media_observer_t * s)151 cef_media_observer_t>::UnwrapDerived(CefWrapperType type,
152 cef_media_observer_t* s) {
153 NOTREACHED() << "Unexpected class type: " << type;
154 return nullptr;
155 }
156
157 template <>
158 CefWrapperType CefCppToCRefCounted<CefMediaObserverCppToC,
159 CefMediaObserver,
160 cef_media_observer_t>::kWrapperType =
161 WT_MEDIA_OBSERVER;
162