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=fd8d34089842ee8f8490ef1828c3091d12052e28$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_browser_capi.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /// 51 // Implement this structure to handle audio events. 52 /// 53 typedef struct _cef_audio_handler_t { 54 /// 55 // Base structure. 56 /// 57 cef_base_ref_counted_t base; 58 59 /// 60 // Called on the UI thread to allow configuration of audio stream parameters. 61 // Return true (1) to proceed with audio stream capture, or false (0) to 62 // cancel it. All members of |params| can optionally be configured here, but 63 // they are also pre-filled with some sensible defaults. 64 /// 65 int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self, 66 struct _cef_browser_t* browser, 67 cef_audio_parameters_t* params); 68 69 /// 70 // Called on a browser audio capture thread when the browser starts streaming 71 // audio. OnAudioSteamStopped will always be called after 72 // OnAudioStreamStarted; both functions may be called multiple times for the 73 // same browser. |params| contains the audio parameters like sample rate and 74 // channel layout. |channels| is the number of channels. 75 /// 76 void(CEF_CALLBACK* on_audio_stream_started)( 77 struct _cef_audio_handler_t* self, 78 struct _cef_browser_t* browser, 79 const cef_audio_parameters_t* params, 80 int channels); 81 82 /// 83 // Called on the audio stream thread when a PCM packet is received for the 84 // stream. |data| is an array representing the raw PCM data as a floating 85 // point type, i.e. 4-byte value(s). |frames| is the number of frames in the 86 // PCM packet. |pts| is the presentation timestamp (in milliseconds since the 87 // Unix Epoch) and represents the time at which the decompressed packet should 88 // be presented to the user. Based on |frames| and the |channel_layout| value 89 // passed to OnAudioStreamStarted you can calculate the size of the |data| 90 // array in bytes. 91 /// 92 void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self, 93 struct _cef_browser_t* browser, 94 const float** data, 95 int frames, 96 int64 pts); 97 98 /// 99 // Called on the UI thread when the stream has stopped. OnAudioSteamStopped 100 // will always be called after OnAudioStreamStarted; both functions may be 101 // called multiple times for the same stream. 102 /// 103 void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self, 104 struct _cef_browser_t* browser); 105 106 /// 107 // Called on the UI or audio stream thread when an error occurred. During the 108 // stream creation phase this callback will be called on the UI thread while 109 // in the capturing phase it will be called on the audio stream thread. The 110 // stream will be stopped immediately. 111 /// 112 void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self, 113 struct _cef_browser_t* browser, 114 const cef_string_t* message); 115 } cef_audio_handler_t; 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_ 122