PrivMX Endpoint v2.8.0
Loading...
Searching...
No Matches
StreamApi.hpp
1/*
2PrivMX Endpoint.
3Copyright © 2024 Simplito sp. z o.o.
4
5This file is part of the PrivMX Platform (https://privmx.dev).
6This software is Licensed under the PrivMX Free License.
7
8See the License for the specific language governing permissions and
9limitations under the License.
10*/
11
12#ifndef _PRIVMXLIB_ENDPOINT_STREAM_STREAMAPI_HPP_
13#define _PRIVMXLIB_ENDPOINT_STREAM_STREAMAPI_HPP_
14
15#include "privmx/endpoint/stream/webrtc/OnTrackInterface.hpp"
16#include "privmx/endpoint/stream/webrtc/Types.hpp"
17#include <memory>
18#include <optional>
19#include <privmx/endpoint/core/Connection.hpp>
20#include <privmx/endpoint/core/Types.hpp>
21#include <privmx/endpoint/event/EventApi.hpp>
22#include <string>
23#include <vector>
24
25namespace privmx {
26namespace endpoint {
27namespace stream {
28
29class StreamApiImpl;
30
43class StreamApi {
44public:
56 static StreamApi create(core::Connection& connection, event::EventApi& eventApi);
57
61 StreamApi() = default;
62
78 std::string createStreamRoom(
79 const std::string& contextId,
80 const std::vector<core::UserWithPubKey>& users,
81 const std::vector<core::UserWithPubKey>& managers,
82 const core::Buffer& publicMeta,
83 const core::Buffer& privateMeta,
84 const std::optional<core::ContainerPolicyWithoutItem>& policies,
85 const std::optional<int64_t>& emptyRoomTtl = std::nullopt
86 );
87
103 const std::string& streamRoomId,
104 const std::vector<core::UserWithPubKey>& users,
105 const std::vector<core::UserWithPubKey>& managers,
106 const core::Buffer& publicMeta,
107 const core::Buffer& privateMeta,
108 const int64_t version,
109 const bool force,
110 const bool forceGenerateNewKey,
111 const std::optional<core::ContainerPolicyWithoutItem>& policies
112 );
113
122 core::PagingList<StreamRoom> listStreamRooms(const std::string& contextId, const core::PagingQuery& query);
123
131 StreamRoom getStreamRoom(const std::string& streamRoomId);
132
138 void deleteStreamRoom(const std::string& streamRoomId);
139
149 std::vector<std::string> subscribeFor(const std::vector<std::string>& subscriptionQueries);
150
156 void unsubscribeFrom(const std::vector<std::string>& subscriptionIds);
157
171 EventType eventType,
172 EventSelectorType selectorType,
173 const std::string& selectorId
174 );
175
185 std::vector<StreamInfo> listStreams(const std::string& streamRoomId);
186
198 std::vector<StreamSubscriber> listStreamRoomParticipants(const std::string& streamRoomId);
199
210 void joinStreamRoom(const std::string& streamRoomId); // required before createStream and openStream
211
220 void leaveStreamRoom(const std::string& streamRoomId);
221
234 StreamHandle createStream(const std::string& streamRoomId);
235
243 std::vector<AudioDevice> getAudioDevices();
244
252 std::vector<VideoDevice> getVideoDevices();
253
263 std::vector<DesktopDevice> getDesktopDevices(DesktopType desktopType);
264
280 const StreamHandle& streamHandle,
281 const MediaDevice& track,
282 const MediaTrackConstrains& mediaTrackConstrains
283 );
284
294 void removeTrack(const StreamHandle& streamHandle, const MediaDevice& track);
295
307 StreamPublishResult publishStream(const StreamHandle& streamHandle);
308
318 StreamPublishResult updateStream(const StreamHandle& streamHandle);
319
325 void removeStream(const StreamHandle& streamHandle);
326
341 SubscriberStreamHandle createSubscriberStream(
342 const std::string& streamRoomId,
343 const std::vector<StreamSubscription>& subscriptions
344 );
345
357 const SubscriberStreamHandle& subscriptionHandle,
358 const std::vector<StreamSubscription>& subscriptionsToAdd,
359 const std::vector<StreamSubscription>& subscriptionsToRemove
360 );
361
367 void removeSubscriberStream(const SubscriberStreamHandle& subscriptionHandle);
368
377 void dropBrokenFrames(const std::string& streamRoomId, bool enable);
378
389 const std::string& streamRoomId,
390 std::optional<int64_t> streamId,
391 std::shared_ptr<OnTrackInterface> onTrack
392 );
393
403 void sendData(const StreamHandle& streamHandle, core::Buffer data);
404
408 std::shared_ptr<StreamApiImpl> getImpl() const { return _impl; }
409
410private:
411 void validateEndpoint();
412 StreamApi(const std::shared_ptr<StreamApiImpl>& impl);
413 std::shared_ptr<StreamApiImpl> _impl;
414};
415
416} // namespace stream
417} // namespace endpoint
418} // namespace privmx
419
420#endif // _PRIVMXLIB_ENDPOINT_STREAM_STREAMAPI_HPP_
Definition Buffer.hpp:13
Definition Connection.hpp:21
Definition EventApi.hpp:18
std::vector< std::string > subscribeFor(const std::vector< std::string > &subscriptionQueries)
StreamRoom getStreamRoom(const std::string &streamRoomId)
StreamPublishResult updateStream(const StreamHandle &streamHandle)
SubscriberStreamHandle createSubscriberStream(const std::string &streamRoomId, const std::vector< StreamSubscription > &subscriptions)
std::string buildSubscriptionQuery(EventType eventType, EventSelectorType selectorType, const std::string &selectorId)
void leaveStreamRoom(const std::string &streamRoomId)
void addRemoteStreamListener(const std::string &streamRoomId, std::optional< int64_t > streamId, std::shared_ptr< OnTrackInterface > onTrack)
std::vector< StreamInfo > listStreams(const std::string &streamRoomId)
void updateSubscriberStream(const SubscriberStreamHandle &subscriptionHandle, const std::vector< StreamSubscription > &subscriptionsToAdd, const std::vector< StreamSubscription > &subscriptionsToRemove)
std::vector< AudioDevice > getAudioDevices()
std::shared_ptr< StreamApiImpl > getImpl() const
Definition StreamApi.hpp:408
static StreamApi create(core::Connection &connection, event::EventApi &eventApi)
std::string createStreamRoom(const std::string &contextId, const std::vector< core::UserWithPubKey > &users, const std::vector< core::UserWithPubKey > &managers, const core::Buffer &publicMeta, const core::Buffer &privateMeta, const std::optional< core::ContainerPolicyWithoutItem > &policies, const std::optional< int64_t > &emptyRoomTtl=std::nullopt)
StreamPublishResult publishStream(const StreamHandle &streamHandle)
std::vector< VideoDevice > getVideoDevices()
void unsubscribeFrom(const std::vector< std::string > &subscriptionIds)
void removeStream(const StreamHandle &streamHandle)
void joinStreamRoom(const std::string &streamRoomId)
void dropBrokenFrames(const std::string &streamRoomId, bool enable)
void updateStreamRoom(const std::string &streamRoomId, const std::vector< core::UserWithPubKey > &users, const std::vector< core::UserWithPubKey > &managers, const core::Buffer &publicMeta, const core::Buffer &privateMeta, const int64_t version, const bool force, const bool forceGenerateNewKey, const std::optional< core::ContainerPolicyWithoutItem > &policies)
void sendData(const StreamHandle &streamHandle, core::Buffer data)
core::PagingList< StreamRoom > listStreamRooms(const std::string &contextId, const core::PagingQuery &query)
void removeSubscriberStream(const SubscriberStreamHandle &subscriptionHandle)
std::vector< DesktopDevice > getDesktopDevices(DesktopType desktopType)
std::vector< StreamSubscriber > listStreamRoomParticipants(const std::string &streamRoomId)
void removeTrack(const StreamHandle &streamHandle, const MediaDevice &track)
MediaTrack addTrack(const StreamHandle &streamHandle, const MediaDevice &track, const MediaTrackConstrains &mediaTrackConstrains)
void deleteStreamRoom(const std::string &streamRoomId)
StreamHandle createStream(const std::string &streamRoomId)
Definition Types.hpp:16
Definition Types.hpp:136