2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
20 using Tizen.Multimedia.Remoting;
22 internal static partial class Interop
24 internal static partial class NativeDataChannel
26 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
27 internal delegate void CreatedCallback(IntPtr handle, IntPtr dataChanndelHandle, IntPtr userData);
29 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30 internal delegate void OpenedCallback(IntPtr dataChannelHandle, IntPtr userData);
32 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33 internal delegate void MessageReceivedCallback(IntPtr dataChannelHandle, DataChannelType type, IntPtr message, IntPtr userData);
35 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
36 internal delegate void ErrorOccurredCallback(IntPtr dataChanndelHandle, WebRTCErrorCode error, IntPtr userData);
38 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
39 internal delegate void ClosedCallback(IntPtr dataChanndelHandle, IntPtr userData);
42 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_create_data_channel")]
43 internal static extern WebRTCErrorCode Create(IntPtr handle, string label, SafeBundleHandle bundle, out IntPtr dataChanndelHandle);
45 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_destroy_data_channel")]
46 internal static extern WebRTCErrorCode Destroy(IntPtr dataChanndelHandle);
48 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_send_string")]
49 internal static extern WebRTCErrorCode SendString(IntPtr dataChanndelHandle, string data);
51 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_send_bytes")]
52 internal static extern WebRTCErrorCode SendBytes(IntPtr dataChanndelHandle, byte[] data, uint size);
54 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_get_label")]
55 internal static extern WebRTCErrorCode GetLabel(IntPtr dataChanndelHandle, out string label);
57 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_data")]
58 internal static extern WebRTCErrorCode GetData(IntPtr byteDataHandle, out IntPtr data, out ulong size);
60 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_data_channel_cb")]
61 internal static extern WebRTCErrorCode SetCreatedByPeerCb(IntPtr handle, CreatedCallback callback, IntPtr userData = default);
63 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_unset_data_channel_cb")]
64 internal static extern WebRTCErrorCode UnsetCreatedByPeerCb(IntPtr handle);
66 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_open_cb")]
67 internal static extern WebRTCErrorCode SetOpenedCb(IntPtr dataChanndelHandle, OpenedCallback callback, IntPtr userData = default);
69 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_open_cb")]
70 internal static extern WebRTCErrorCode UnsetOpenedCb(IntPtr dataChanndelHandle);
72 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_message_cb")]
73 internal static extern WebRTCErrorCode SetMessageReceivedCb(IntPtr dataChanndelHandle, MessageReceivedCallback callback, IntPtr userData = default);
75 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_message_cb")]
76 internal static extern WebRTCErrorCode UnsetMessageReceivedCb(IntPtr dataChanndelHandle);
78 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_error_cb")]
79 internal static extern WebRTCErrorCode SetErrorOccurredCb(IntPtr dataChanndelHandle, ErrorOccurredCallback callback, IntPtr userData = default);
81 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_error_cb")]
82 internal static extern WebRTCErrorCode UnsetErrorOccurredCb(IntPtr handle);
84 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_close_cb")]
85 internal static extern WebRTCErrorCode SetClosedCb(IntPtr dataChanndelHandle, ClosedCallback callback, IntPtr userData = default);
87 [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_close_cb")]
88 internal static extern WebRTCErrorCode UnsetClosedCb(IntPtr handle);