34 Channel(std::unique_ptr<rtc_api::interface::ChannelState> rtc_api_channel_state,
35 std::unique_ptr<interface::ChunkMessengerFactory> chunk_messenger_factory);
36 Channel(std::unique_ptr<rtc_api::interface::ChannelState> rtc_api_channel_state);
46 static std::shared_ptr<Channel>
Create();
56 static void DisposeAllChannels();
62 std::string
Id()
const override;
63 std::optional<std::string>
Name()
const override;
64 std::optional<std::string>
Metadata()
const override;
65 std::shared_ptr<interface::LocalPerson>
LocalPerson()
override;
66 std::vector<std::shared_ptr<interface::RemoteMember>>
Bots(
bool active_only =
true)
override;
67 std::vector<std::shared_ptr<interface::Member>>
Members(
bool active_only =
true)
override;
68 std::vector<std::shared_ptr<interface::Publication>>
Publications(
bool active_only =
true)
override;
69 std::vector<std::shared_ptr<interface::Subscription>>
Subscriptions(
bool active_only =
true)
override;
70 ChannelState
State()
const override;
74 bool Leave(std::shared_ptr<interface::Member> member)
override;
76 void Dispose(
bool remove_myself_if_needed =
true)
override;
79 std::shared_ptr<interface::Member> FindMember(
const std::string& member_id,
bool active_only =
true)
override;
80 std::shared_ptr<interface::RemoteMember> FindRemoteMember(
const std::string& member_id,
bool active_only =
true)
override;
81 std::shared_ptr<interface::Publication> FindPublication(
const std::string& publication_id,
82 bool active_only =
true)
override;
83 std::shared_ptr<interface::Subscription> FindSubscription(
const std::string& subscription_id,
84 bool active_only =
true)
override;
85 std::vector<std::shared_ptr<interface::Subscription>> GetSubscriptionsByPublicationId(
86 const std::string& publication_id,
bool active_only =
true)
override;
87 std::vector<std::shared_ptr<interface::Subscription>> GetSubscriptionsBySubscriberId(
88 const std::string& subscriber_id,
bool active_only =
true)
override;
89 std::vector<std::shared_ptr<interface::Publication>> GetPublicationsByPublisherId(
90 const std::string& publisher_id,
bool active_only =
true)
override;
92 std::optional<model::Member> GetMemberDto(
const std::string& member_id)
const override;
93 std::optional<model::Publication> GetPublicationDto(
94 const std::string& publication_id)
const override;
95 std::optional<model::Subscription> GetSubscriptionDto(
96 const std::string& subscription_id)
const override;
99 void OnChannelDeleted(
const std::string& channel_id)
override;
102 void OnMemberRemoved(
const std::string& member_id)
override;
103 void OnMemberMetadataUpdated(
const model::Member& member)
override;
105 void OnStreamUnpublished(
const std::string& publication_id)
override;
110 void OnPublicationUnsubscribed(
const std::string& subscription_id)
override;
114 std::vector<std::shared_ptr<interface::LocalPerson>> LocalPersons(
bool active_only =
true);
115 std::vector<std::shared_ptr<interface::RemoteMember>> RemoteMembers(
bool active_only =
true);
116 std::shared_ptr<member::LocalPerson> CreateLocalPerson(
const model::Member& member);
117 std::shared_ptr<interface::RemoteMember> CreateRemoteMember(
const model::Member& member);
119 std::unique_ptr<rtc_api::interface::ChannelState> rtc_api_channel_state_;
121 std::atomic<bool> is_disposed_;
123 std::vector<std::shared_ptr<member::LocalPerson>> persons_;
124 std::vector<std::shared_ptr<interface::RemoteMember>> remote_members_;
125 std::vector<std::shared_ptr<interface::Publication>> publications_;
126 std::vector<std::shared_ptr<interface::Subscription>> subscriptions_;
128 std::unordered_set<interface::Channel::EventListener*> listeners_;
130 std::optional<std::string> tmp_local_person_id_;
131 std::optional<int> tmp_keepalive_interval_sec_;
132 std::optional<int> tmp_keepalive_interval_gap_sec_;
133 bool waiting_for_local_person_creation_;
135 std::mutex listeners_mtx_;
138 std::mutex persons_mtx_;
139 std::mutex remote_members_mtx_;
140 std::mutex publications_mtx_;
141 std::mutex subscriptions_mtx_;
142 std::mutex dispose_mtx_;
144 std::unique_ptr<interface::ChunkMessengerFactory> chunk_messenger_factory_;
146 static std::unordered_set<std::shared_ptr<Channel>> channels_;
150 friend class CoreChannelTest;