1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef WEBVIEW_MEDIA_FFI_H 17 #define WEBVIEW_MEDIA_FFI_H 18 19 #include "ffi_remote_data.h" 20 #include "webview_utils.h" 21 #include "cj_common_ffi.h" 22 23 extern "C" { 24 struct AtCMediaPlayer { 25 void (*atCOHOSNativeMediaPlayerBridgeResumePlayer)(int64_t self) = nullptr; 26 void (*atCOHOSNativeMediaPlayerBridgeSuspendPlayer)(int64_t self, int32_t ctype) = nullptr; 27 void (*atCOHOSNativeMediaPlayerBridgeExitFullscreen)(int64_t self) = nullptr; 28 void (*atCOHOSNativeMediaPlayerBridgeEnterFullscreen)(int64_t self) = nullptr; 29 void (*atCOHOSNativeMediaPlayerBridgeRelease)(int64_t self) = nullptr; 30 void (*atCOHOSNativeMediaPlayerBridgeSetPlaybackRate)(int64_t self, double rate) = nullptr; 31 void (*atCOHOSNativeMediaPlayerBridgeSetMuted)(int64_t self, bool muted) = nullptr; 32 void (*atCOHOSNativeMediaPlayerBridgeSetVolume)(int64_t self, double volume) = nullptr; 33 void (*atCOHOSNativeMediaPlayerBridgeSeek)(int64_t self, double targetTime) = nullptr; 34 void (*atCOHOSNativeMediaPlayerBridgePause)(int64_t self) = nullptr; 35 void (*atCOHOSNativeMediaPlayerBridgePlay)(int64_t self) = nullptr; 36 void (*atCOHOSNativeMediaPlayerBridgeUpdateRect)(int64_t self, OHOS::Webview::CRectEvent cRectEvent) = nullptr; 37 }; 38 39 // NativeMediaPlayerBridge 40 FFI_EXPORT void FfiOHOSNativeMediaPlayerBridgeRegisterCJFuncs(AtCMediaPlayer cjFuncs); 41 42 // NativeMediaPlayerHandler 43 FFI_EXPORT int64_t FfiOHOSNmphConstructor(); 44 FFI_EXPORT int32_t FfiOHOSNmphhandleVideoSizeChanged(int64_t id, double width, double height); 45 FFI_EXPORT int32_t FfiOHOSNmphhandleError(int64_t id, int32_t error, const char* errorMessage); 46 FFI_EXPORT int32_t FfiOHOSNmphhandleSeekFinished(int64_t id); 47 FFI_EXPORT int32_t FfiOHOSNmphhandleSeeking(int64_t id); 48 FFI_EXPORT int32_t FfiOHOSNmphhandleFullscreenChanged(int64_t id, bool fullscreen); 49 FFI_EXPORT int32_t FfiOHOSNmphhandleReadyStateChanged(int64_t id, int32_t state); 50 FFI_EXPORT int32_t FfiOHOSNmphhandleNetworkStateChanged(int64_t id, int32_t state); 51 FFI_EXPORT int32_t FfiOHOSNmphhandleEnded(int64_t id); 52 FFI_EXPORT int32_t FfiOHOSNmphhandleBufferedEndTimeChanged(int64_t id, double bufferedEndTime); 53 FFI_EXPORT int32_t FfiOHOSNmphhandleTimeUpdate(int64_t id, double currentPlayTime); 54 FFI_EXPORT int32_t FfiOHOSNmphhandleDurationChanged(int64_t id, double duration); 55 FFI_EXPORT int32_t FfiOHOSNmphhandlePlaybackRateChanged(int64_t id, double playbackRate); 56 FFI_EXPORT int32_t FfiOHOSNmphhandleMutedChanged(int64_t id, bool muted); 57 FFI_EXPORT int32_t FfiOHOSNmphhandleVolumeChanged(int64_t id, double volume); 58 FFI_EXPORT int32_t FfiOHOSNmphhandleStatusChanged(int64_t id, int32_t status); 59 } 60 61 #endif // WEBVIEW_MEDIA_FFI_H