File: GStreamerIceAgent.h

package info (click to toggle)
webkit2gtk 2.51.3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 477,912 kB
  • sloc: cpp: 3,898,343; javascript: 198,215; ansic: 165,229; python: 50,371; asm: 21,819; ruby: 18,095; perl: 16,953; xml: 4,623; sh: 2,398; yacc: 2,356; java: 2,019; lex: 1,358; pascal: 372; makefile: 197
file content (120 lines) | stat: -rw-r--r-- 5,353 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 *  Copyright (C) 2025 Igalia S.L. All rights reserved.
 *  Copyright (C) 2025 Metrological Group B.V.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#pragma once

#if USE(GSTREAMER_WEBRTC) && USE(LIBRICE)

#include "ExceptionData.h"
#include "ExceptionOr.h"
#include "GRefPtrGStreamer.h"
#include "RTCIceComponent.h"
#include "RTCIceConnectionState.h"
#include "RTCIceProtocol.h"
#include "ScriptExecutionContextIdentifier.h"
#include "SharedMemory.h"

#include <glib-object.h>
#include <rice-proto.h>
#include <wtf/Expected.h>
#include <wtf/Forward.h>
#include <wtf/Function.h>
#include <wtf/Identified.h>
#include <wtf/Noncopyable.h>
#include <wtf/ObjectIdentifier.h>
#include <wtf/RefCounted.h>
#include <wtf/glib/GThreadSafeWeakPtr.h>

typedef struct _WebKitGstIceAgent WebKitGstIceAgent;
typedef struct _WebKitGstIceAgentClass WebKitGstIceAgentClass;

typedef struct _WebKitGstIceStream WebKitGstIceStream;
typedef struct _WebKitGstIceStreamClass WebKitGstIceStreamClass;

#define WEBKIT_TYPE_GST_WEBRTC_ICE_BACKEND (webkit_gst_webrtc_ice_backend_get_type())
#define WEBKIT_GST_WEBRTC_ICE_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_GST_WEBRTC_ICE_BACKEND, WebKitGstIceAgent))
#define WEBKIT_GST_WEBRTC_ICE_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_GST_WEBRTC_ICE_BACKEND, WebKitGstIceAgentClass))
#define WEBKIT_IS_GST_WEBRTC_ICE_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_GST_WEBRTC_ICE_BACKEND))
#define WEBKIT_IS_GST_WEBRTC_ICE_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_GST_WEBRTC_ICE_BACKEND))

GType webkit_gst_webrtc_ice_backend_get_type();

namespace WebCore {
class ScriptExecutionContext;
class SocketProvider;

class RiceBackendClient : public RefCounted<RiceBackendClient> {
    WTF_MAKE_NONCOPYABLE(RiceBackendClient);
public:
    static Ref<RiceBackendClient> create() { return adoptRef(*new RiceBackendClient); }

    using IncomingDataCallback = WTF::Function<void(unsigned, RTCIceProtocol, String&&, String&&, WebCore::SharedMemory::Handle&&)>;
    void setIncomingDataCallback(IncomingDataCallback&& callback) { m_incomingDataCallback = WTFMove(callback); }
    void notifyIncomingData(unsigned streamId, RTCIceProtocol protocol, String&& from, String&& to, WebCore::SharedMemoryHandle&& data) { m_incomingDataCallback(streamId, protocol, WTFMove(from), WTFMove(to), WTFMove(data)); }

private:
    RiceBackendClient() = default;

    IncomingDataCallback m_incomingDataCallback;
};

using RiceBackendIdentifier = AtomicObjectIdentifier<RiceBackendClient>;

class RiceBackend : public Identified<RiceBackendIdentifier> {
    WTF_MAKE_NONCOPYABLE(RiceBackend);
public:
    void ref() { refRiceBackend(); }
    void deref() { derefRiceBackend(); }

    using ResolveAddressCallback = Function<void(ExceptionOr<String>&&)>;
    virtual void resolveAddress(const String&, ResolveAddressCallback&&) = 0;

    virtual void send(unsigned, RTCIceProtocol, String&&, String&&, SharedMemory::Handle&&) = 0;

    virtual Vector<String> gatherSocketAddresses(unsigned) = 0;
    virtual void finalizeStream(unsigned) = 0;

protected:
    RiceBackend() = default;
    virtual ~RiceBackend() = default;
    virtual void refRiceBackend() = 0;
    virtual void derefRiceBackend() = 0;
};

} // namespace WebCore

WebKitGstIceAgent* webkitGstWebRTCCreateIceAgent(const String&, WebCore::ScriptExecutionContext*);

const GRefPtr<RiceAgent>& webkitGstWebRTCIceAgentGetRiceAgent(WebKitGstIceAgent*);
Vector<GRefPtr<RiceTurnConfig>> webkitGstWebRTCIceAgentGetTurnConfigs(WebKitGstIceAgent*);
Vector<String> webkitGstWebRTCIceAgentGatherSocketAddresses(WebKitGstIceAgent*, unsigned);

GstWebRTCICETransport *webkitGstWebRTCIceAgentCreateTransport(WebKitGstIceAgent*, GThreadSafeWeakPtr<WebKitGstIceStream>&&, WebCore::RTCIceComponent);

void webkitGstWebRTCIceAgentSend(WebKitGstIceAgent*, unsigned, WebCore::RTCIceProtocol, String&& from, String&& to, WebCore::SharedMemory::Handle&&);

void webkitGstWebRTCIceAgentWakeup(WebKitGstIceAgent*);
void webkitGstWebRTCIceAgentGatheringDoneForStream(WebKitGstIceAgent*, unsigned);
void webkitGstWebRTCIceAgentLocalCandidateGatheredForStream(WebKitGstIceAgent*, unsigned, RiceAgentGatheredCandidate&);
void webkitGstWebRTCIceAgentComponentStateChangedForStream(WebKitGstIceAgent*, unsigned, RiceAgentComponentStateChange&);
void webkitGstWebRTCIceAgentNewSelectedPairForStream(WebKitGstIceAgent*, unsigned, RiceAgentSelectedPair&);
void webkitGstWebRTCIceAgentClosed(WebKitGstIceAgent*);
void webkitGstWebRTCIceAgentFinalizeStream(WebKitGstIceAgent*, unsigned);

#endif // USE(GSTREAMER_WEBRTC) && USE(LIBRICE)