SkyWay for Linux
読み取り中…
検索中…
一致する文字列を見つけられません
local_person.hpp
1//
2// local_person.hpp
3// skyway
4//
5// Created by sandabu on 2022/01/12.
6// Copyright © 2022 NTT Communications. All rights reserved.
7//
8
9#ifndef SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_
10#define SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_
11
12#include <api/peer_connection_interface.h>
13
14#include <boost/optional.hpp>
15#include <string>
16#include <unordered_map>
17
18#include "skyway/analytics/interface/analytics_client.hpp"
19#include "skyway/core/interface/local_person.hpp"
20#include "skyway/signaling/interface/signaling_client.hpp"
21
22namespace skyway {
23namespace core {
24namespace channel {
25namespace member {
26
27using ChannelInterface = interface::Channel;
28using PublicationInterface = interface::Publication;
29using SubscriptionInterface = interface::Subscription;
30using LocalStream = interface::LocalStream;
31using RemoteMember = interface::RemoteMember;
32using ChunkMessengerInterface = interface::ChunkMessenger;
33using AnalyticsClientInterface = analytics::interface::AnalyticsClient;
34
36class LocalPerson : public interface::LocalPerson, public AnalyticsClientInterface::Delegator {
37public:
40 const model::Member& dto,
41 std::unique_ptr<ChunkMessengerInterface> messenger,
42 int keepalive_interval_sec,
43 int keepalive_interval_gap_sec,
44 std::unique_ptr<AnalyticsClientInterface> analytics_client);
46
47 ChunkMessengerInterface* Messenger() const override;
48
49 AnalyticsClientInterface* AnalyticsClient() const override;
51
52 PublicationInterface* Publish(std::shared_ptr<LocalStream> stream,
55 const std::string& publication_id,
56 const interface::LocalPerson::SubscriptionOptions& options) override;
57 bool Unpublish(const std::string& publication_id) const override;
58 bool Unsubscribe(const std::string& subscription_id) const override;
60 void OnPublished(PublicationInterface* publication) override;
61 void OnUnpublished(PublicationInterface* publication) override;
62 void OnSubscribed(SubscriptionInterface* subscription, RemoteMember* publisher) override;
63 void OnUnsubscribed(SubscriptionInterface* subscription, RemoteMember* publisher) override;
64 void OnPublicationSubscribedByRemoteMember(SubscriptionInterface* subscription,
65 RemoteMember* subscriber) override;
66 void OnPublicationUnsubscribedByRemoteMember(SubscriptionInterface* subscription,
67 RemoteMember* subscriber) override;
68 void Dispose() override;
70
71 // AnalyticsClientInterface::Delegator
72 std::vector<analytics::interface::AnalyticsClient::SubscriptionStats> GetSubscriptionStatsForAnalytics()
73 const override;
74
75private:
76 void UpdateMemberTtl(int keepalive_interval_sec);
77 void SetupTtlTimer();
78 using SubscriptionId = std::string;
79 using SubscriptionPair =
80 std::pair<SubscriptionInterface*, interface::LocalPerson::SubscriptionOptions>;
81
82 std::unique_ptr<ChunkMessengerInterface> messenger_;
83 std::mutex tmp_subscriptions_mtx_;
84 std::unordered_map<SubscriptionId, SubscriptionPair> tmp_subscriptions_;
85 int keepalive_interval_sec_;
86 int keepalive_interval_gap_sec_;
87
88 std::unique_ptr<AnalyticsClientInterface> analytics_client_;
89
90 std::mutex stream_mtx_;
91
92 std::mutex disposed_mtx_;
93 std::condition_variable disposed_cv_;
94 bool disposed_;
95 std::unique_ptr<std::thread> ttl_timer_thread_;
96};
97
98} // namespace member
99} // namespace channel
100} // namespace core
101} // namespace skyway
102
103#endif /* SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_ */
LocalPersonの実装クラス
Definition local_person.hpp:36
bool Unpublish(const std::string &publication_id) const override
公開しているPublicationを非公開にします。
bool Unsubscribe(const std::string &subscription_id) const override
購読しているSubscriptionの購読を解除します。
SubscriptionInterface * Subscribe(const std::string &publication_id, const interface::LocalPerson::SubscriptionOptions &options) override
公開されているPublicationを購読します。
PublicationInterface * Publish(std::shared_ptr< LocalStream > stream, interface::LocalPerson::PublicationOptions options) override
Streamを公開します。
Channelのインターフェース
Definition channel.hpp:28
LocalPersonのインターフェース
Definition local_person.hpp:23
Publicationのインターフェース
Definition publication.hpp:29
このSDK以外で生成されたメンバ
Definition remote_member.hpp:32
Subscriptionのインターフェース
Definition subscription.hpp:27
PublishでPublicationに対して指定するオプション
Definition local_person.hpp:39
SubscribeでSubscriptionに対して指定するオプション
Definition local_person.hpp:52
メンバー情報
Definition domain.hpp:54