1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=3db7459a1940c37898699cc97f69ba9249a6f1fd$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_callback_capi.h" 45 #include "include/capi/cef_registration_capi.h" 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 struct _cef_media_observer_t; 52 struct _cef_media_route_create_callback_t; 53 struct _cef_media_route_t; 54 struct _cef_media_sink_device_info_callback_t; 55 struct _cef_media_sink_t; 56 struct _cef_media_source_t; 57 58 /// 59 // Supports discovery of and communication with media devices on the local 60 // network via the Cast and DIAL protocols. The functions of this structure may 61 // be called on any browser process thread unless otherwise indicated. 62 /// 63 typedef struct _cef_media_router_t { 64 /// 65 // Base structure. 66 /// 67 cef_base_ref_counted_t base; 68 69 /// 70 // Add an observer for MediaRouter events. The observer will remain registered 71 // until the returned Registration object is destroyed. 72 /// 73 struct _cef_registration_t*(CEF_CALLBACK* add_observer)( 74 struct _cef_media_router_t* self, 75 struct _cef_media_observer_t* observer); 76 77 /// 78 // Returns a MediaSource object for the specified media source URN. Supported 79 // URN schemes include "cast:" and "dial:", and will be already known by the 80 // client application (e.g. "cast:<appId>?clientId=<clientId>"). 81 /// 82 struct _cef_media_source_t*(CEF_CALLBACK* get_source)( 83 struct _cef_media_router_t* self, 84 const cef_string_t* urn); 85 86 /// 87 // Trigger an asynchronous call to cef_media_observer_t::OnSinks on all 88 // registered observers. 89 /// 90 void(CEF_CALLBACK* notify_current_sinks)(struct _cef_media_router_t* self); 91 92 /// 93 // Create a new route between |source| and |sink|. Source and sink must be 94 // valid, compatible (as reported by cef_media_sink_t::IsCompatibleWith), and 95 // a route between them must not already exist. |callback| will be executed on 96 // success or failure. If route creation succeeds it will also trigger an 97 // asynchronous call to cef_media_observer_t::OnRoutes on all registered 98 // observers. 99 /// 100 void(CEF_CALLBACK* create_route)( 101 struct _cef_media_router_t* self, 102 struct _cef_media_source_t* source, 103 struct _cef_media_sink_t* sink, 104 struct _cef_media_route_create_callback_t* callback); 105 106 /// 107 // Trigger an asynchronous call to cef_media_observer_t::OnRoutes on all 108 // registered observers. 109 /// 110 void(CEF_CALLBACK* notify_current_routes)(struct _cef_media_router_t* self); 111 } cef_media_router_t; 112 113 /// 114 // Returns the MediaRouter object associated with the global request context. If 115 // |callback| is non-NULL it will be executed asnychronously on the UI thread 116 // after the manager's storage has been initialized. Equivalent to calling cef_r 117 // equest_context_t::cef_request_context_get_global_context()->get_media_router( 118 // ). 119 /// 120 CEF_EXPORT cef_media_router_t* cef_media_router_get_global( 121 struct _cef_completion_callback_t* callback); 122 123 /// 124 // Implemented by the client to observe MediaRouter events and registered via 125 // cef_media_router_t::AddObserver. The functions of this structure will be 126 // called on the browser process UI thread. 127 /// 128 typedef struct _cef_media_observer_t { 129 /// 130 // Base structure. 131 /// 132 cef_base_ref_counted_t base; 133 134 /// 135 // The list of available media sinks has changed or 136 // cef_media_router_t::NotifyCurrentSinks was called. 137 /// 138 void(CEF_CALLBACK* on_sinks)(struct _cef_media_observer_t* self, 139 size_t sinksCount, 140 struct _cef_media_sink_t* const* sinks); 141 142 /// 143 // The list of available media routes has changed or 144 // cef_media_router_t::NotifyCurrentRoutes was called. 145 /// 146 void(CEF_CALLBACK* on_routes)(struct _cef_media_observer_t* self, 147 size_t routesCount, 148 struct _cef_media_route_t* const* routes); 149 150 /// 151 // The connection state of |route| has changed. 152 /// 153 void(CEF_CALLBACK* on_route_state_changed)( 154 struct _cef_media_observer_t* self, 155 struct _cef_media_route_t* route, 156 cef_media_route_connection_state_t state); 157 158 /// 159 // A message was recieved over |route|. |message| is only valid for the scope 160 // of this callback and should be copied if necessary. 161 /// 162 void(CEF_CALLBACK* on_route_message_received)( 163 struct _cef_media_observer_t* self, 164 struct _cef_media_route_t* route, 165 const void* message, 166 size_t message_size); 167 } cef_media_observer_t; 168 169 /// 170 // Represents the route between a media source and sink. Instances of this 171 // object are created via cef_media_router_t::CreateRoute and retrieved via 172 // cef_media_observer_t::OnRoutes. Contains the status and metadata of a routing 173 // operation. The functions of this structure may be called on any browser 174 // process thread unless otherwise indicated. 175 /// 176 typedef struct _cef_media_route_t { 177 /// 178 // Base structure. 179 /// 180 cef_base_ref_counted_t base; 181 182 /// 183 // Returns the ID for this route. 184 /// 185 // The resulting string must be freed by calling cef_string_userfree_free(). 186 cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_route_t* self); 187 188 /// 189 // Returns the source associated with this route. 190 /// 191 struct _cef_media_source_t*(CEF_CALLBACK* get_source)( 192 struct _cef_media_route_t* self); 193 194 /// 195 // Returns the sink associated with this route. 196 /// 197 struct _cef_media_sink_t*(CEF_CALLBACK* get_sink)( 198 struct _cef_media_route_t* self); 199 200 /// 201 // Send a message over this route. |message| will be copied if necessary. 202 /// 203 void(CEF_CALLBACK* send_route_message)(struct _cef_media_route_t* self, 204 const void* message, 205 size_t message_size); 206 207 /// 208 // Terminate this route. Will result in an asynchronous call to 209 // cef_media_observer_t::OnRoutes on all registered observers. 210 /// 211 void(CEF_CALLBACK* terminate)(struct _cef_media_route_t* self); 212 } cef_media_route_t; 213 214 /// 215 // Callback structure for cef_media_router_t::CreateRoute. The functions of this 216 // structure will be called on the browser process UI thread. 217 /// 218 typedef struct _cef_media_route_create_callback_t { 219 /// 220 // Base structure. 221 /// 222 cef_base_ref_counted_t base; 223 224 /// 225 // Method that will be executed when the route creation has finished. |result| 226 // will be CEF_MRCR_OK if the route creation succeeded. |error| will be a 227 // description of the error if the route creation failed. |route| is the 228 // resulting route, or NULL if the route creation failed. 229 /// 230 void(CEF_CALLBACK* on_media_route_create_finished)( 231 struct _cef_media_route_create_callback_t* self, 232 cef_media_route_create_result_t result, 233 const cef_string_t* error, 234 struct _cef_media_route_t* route); 235 } cef_media_route_create_callback_t; 236 237 /// 238 // Represents a sink to which media can be routed. Instances of this object are 239 // retrieved via cef_media_observer_t::OnSinks. The functions of this structure 240 // may be called on any browser process thread unless otherwise indicated. 241 /// 242 typedef struct _cef_media_sink_t { 243 /// 244 // Base structure. 245 /// 246 cef_base_ref_counted_t base; 247 248 /// 249 // Returns the ID for this sink. 250 /// 251 // The resulting string must be freed by calling cef_string_userfree_free(). 252 cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self); 253 254 /// 255 // Returns the name of this sink. 256 /// 257 // The resulting string must be freed by calling cef_string_userfree_free(). 258 cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_media_sink_t* self); 259 260 /// 261 // Returns the description of this sink. 262 /// 263 // The resulting string must be freed by calling cef_string_userfree_free(). 264 cef_string_userfree_t(CEF_CALLBACK* get_description)( 265 struct _cef_media_sink_t* self); 266 267 /// 268 // Returns the icon type for this sink. 269 /// 270 cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)( 271 struct _cef_media_sink_t* self); 272 273 /// 274 // Asynchronously retrieves device info. 275 /// 276 void(CEF_CALLBACK* get_device_info)( 277 struct _cef_media_sink_t* self, 278 struct _cef_media_sink_device_info_callback_t* callback); 279 280 /// 281 // Returns true (1) if this sink accepts content via Cast. 282 /// 283 int(CEF_CALLBACK* is_cast_sink)(struct _cef_media_sink_t* self); 284 285 /// 286 // Returns true (1) if this sink accepts content via DIAL. 287 /// 288 int(CEF_CALLBACK* is_dial_sink)(struct _cef_media_sink_t* self); 289 290 /// 291 // Returns true (1) if this sink is compatible with |source|. 292 /// 293 int(CEF_CALLBACK* is_compatible_with)(struct _cef_media_sink_t* self, 294 struct _cef_media_source_t* source); 295 } cef_media_sink_t; 296 297 /// 298 // Callback structure for cef_media_sink_t::GetDeviceInfo. The functions of this 299 // structure will be called on the browser process UI thread. 300 /// 301 typedef struct _cef_media_sink_device_info_callback_t { 302 /// 303 // Base structure. 304 /// 305 cef_base_ref_counted_t base; 306 307 /// 308 // Method that will be executed asyncronously once device information has been 309 // retrieved. 310 /// 311 void(CEF_CALLBACK* on_media_sink_device_info)( 312 struct _cef_media_sink_device_info_callback_t* self, 313 const struct _cef_media_sink_device_info_t* device_info); 314 } cef_media_sink_device_info_callback_t; 315 316 /// 317 // Represents a source from which media can be routed. Instances of this object 318 // are retrieved via cef_media_router_t::GetSource. The functions of this 319 // structure may be called on any browser process thread unless otherwise 320 // indicated. 321 /// 322 typedef struct _cef_media_source_t { 323 /// 324 // Base structure. 325 /// 326 cef_base_ref_counted_t base; 327 328 /// 329 // Returns the ID (media source URN or URL) for this source. 330 /// 331 // The resulting string must be freed by calling cef_string_userfree_free(). 332 cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self); 333 334 /// 335 // Returns true (1) if this source outputs its content via Cast. 336 /// 337 int(CEF_CALLBACK* is_cast_source)(struct _cef_media_source_t* self); 338 339 /// 340 // Returns true (1) if this source outputs its content via DIAL. 341 /// 342 int(CEF_CALLBACK* is_dial_source)(struct _cef_media_source_t* self); 343 } cef_media_source_t; 344 345 #ifdef __cplusplus 346 } 347 #endif 348 349 #endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_ 350