906d02da916c96d8d99433575fcdb8a9656a007f
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Remoting / Interop / Interop.WebRTC.DataChannel.cs
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
20 using Tizen.Multimedia.Remoting;
21
22 internal static partial class Interop
23 {
24     internal static partial class NativeDataChannel
25     {
26         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
27         internal delegate void CreatedCallback(IntPtr handle, IntPtr dataChanndelHandle, IntPtr userData);
28
29         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30         internal delegate void OpenedCallback(IntPtr dataChannelHandle, IntPtr userData);
31
32         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33         internal delegate void MessageReceivedCallback(IntPtr dataChannelHandle, DataChannelType type, IntPtr message, IntPtr userData);
34
35         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
36         internal delegate void ErrorOccurredCallback(IntPtr dataChanndelHandle, WebRTCErrorCode error, IntPtr userData);
37
38         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
39         internal delegate void ClosedCallback(IntPtr dataChanndelHandle, IntPtr userData);
40
41
42         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_create_data_channel")]
43         internal static extern WebRTCErrorCode Create(IntPtr handle, string label, SafeBundleHandle bundle, out IntPtr dataChanndelHandle);
44
45         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_destroy_data_channel")]
46         internal static extern WebRTCErrorCode Destroy(IntPtr dataChanndelHandle);
47
48         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_send_string")]
49         internal static extern WebRTCErrorCode SendString(IntPtr dataChanndelHandle, string data);
50
51         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_send_bytes")]
52         internal static extern WebRTCErrorCode SendBytes(IntPtr dataChanndelHandle, byte[] data, uint size);
53
54         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_get_label")]
55         internal static extern WebRTCErrorCode GetLabel(IntPtr dataChanndelHandle, out string label);
56
57         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_data")]
58         internal static extern WebRTCErrorCode GetData(IntPtr byteDataHandle, out IntPtr data, out ulong size);
59
60         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_data_channel_cb")]
61         internal static extern WebRTCErrorCode SetCreatedByPeerCb(IntPtr handle, CreatedCallback callback, IntPtr userData = default);
62
63         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_unset_data_channel_cb")]
64         internal static extern WebRTCErrorCode UnsetCreatedByPeerCb(IntPtr handle);
65
66         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_open_cb")]
67         internal static extern WebRTCErrorCode SetOpenedCb(IntPtr dataChanndelHandle, OpenedCallback callback, IntPtr userData = default);
68
69         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_open_cb")]
70         internal static extern WebRTCErrorCode UnsetOpenedCb(IntPtr dataChanndelHandle);
71
72         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_message_cb")]
73         internal static extern WebRTCErrorCode SetMessageReceivedCb(IntPtr dataChanndelHandle, MessageReceivedCallback callback, IntPtr userData = default);
74
75         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_message_cb")]
76         internal static extern WebRTCErrorCode UnsetMessageReceivedCb(IntPtr dataChanndelHandle);
77
78         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_error_cb")]
79         internal static extern WebRTCErrorCode SetErrorOccurredCb(IntPtr dataChanndelHandle, ErrorOccurredCallback callback, IntPtr userData = default);
80
81         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_error_cb")]
82         internal static extern WebRTCErrorCode UnsetErrorOccurredCb(IntPtr handle);
83
84         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_set_close_cb")]
85         internal static extern WebRTCErrorCode SetClosedCb(IntPtr dataChanndelHandle, ClosedCallback callback, IntPtr userData = default);
86
87         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_data_channel_unset_close_cb")]
88         internal static extern WebRTCErrorCode UnsetClosedCb(IntPtr handle);
89     }
90 }