Intel® Collaboration Suite for WebRTC  version 4.3.1
Open WebRTC Toolkit (OWT) Client SDK for Windows*
conferencesubscription.h
1 // Copyright (C) <2018> Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 #ifndef OWT_CONFERENCE_SUBSCRIPTION_H_
5 #define OWT_CONFERENCE_SUBSCRIPTION_H_
6 #include <vector>
7 #include <mutex>
8 #include "owt/base/commontypes.h"
9 #include "owt/base/mediaconstraints.h"
10 #include "owt/base/subscription.h"
11 #include "owt/base/connectionstats.h"
12 #include "owt/base/exception.h"
13 #include "owt/conference/streamupdateobserver.h"
14 #include "owt/conference/subscribeoptions.h"
15 namespace rtc {
16  class TaskQueue;
17 }
18 namespace webrtc{
19  class StatsReport;
20 }
21 namespace owt {
22 namespace conference {
23 class ConferenceClient;
24 using namespace owt::base;
25 class ConferenceSubscription : public ConferenceStreamUpdateObserver,
26  public std::enable_shared_from_this<ConferenceSubscription> {
27  public:
28  ConferenceSubscription(std::shared_ptr<ConferenceClient> client, const std::string& sub_id,
29  const std::string& stream_id);
30  virtual ~ConferenceSubscription();
32  void Mute(TrackKind track_kind,
33  std::function<void()> on_success,
34  std::function<void(std::unique_ptr<Exception>)> on_failure);
36  void Unmute(TrackKind track_kind,
37  std::function<void()> on_success,
38  std::function<void(std::unique_ptr<Exception>)> on_failure);
40  void GetStats(
41  std::function<void(std::shared_ptr<ConnectionStats>)> on_success,
42  std::function<void(std::unique_ptr<Exception>)> on_failure);
43  void GetNativeStats(
44  std::function<void(
45  const std::vector<const webrtc::StatsReport*>& reports)> on_success,
46  std::function<void(std::unique_ptr<Exception>)> on_failure);
48  void Stop();
50  bool Ended() { return ended_; }
52  std::string Id() const { return id_; }
54  void ApplyOptions(
55  const SubscriptionUpdateOptions& options,
56  std::function<void()> on_success,
57  std::function<void(std::unique_ptr<Exception>)> on_failure);
59  void AddObserver(SubscriptionObserver& observer);
61  void RemoveObserver(SubscriptionObserver& observer);
62  private:
63  void OnStreamMuteOrUnmute(const std::string& stream_id, TrackKind track_kind, bool muted);
64  void OnStreamRemoved(const std::string& stream_id);
65  void OnStreamError(const std::string& error_msg);
66  std::string id_;
67  std::string stream_id_;
68  bool ended_;
69  mutable std::mutex observer_mutex_;
70  std::vector<std::reference_wrapper<SubscriptionObserver>> observers_;
71  std::weak_ptr<ConferenceClient> conference_client_; // Weak ref to associated conference client
72  std::shared_ptr<rtc::TaskQueue> event_queue_;
73 };
74 
75 } // namespace conference
76 } // namespace owt
77 #endif // OWT_CONFERENCE_SUBSCRIPTION_H_
Definition: conferencepublication.h:12
bool Ended()
If the Subscription is stopped or not.
Definition: conferencesubscription.h:50
Definition: stream.h:17
Definition: audioplayerinterface.h:8
Definition: audioplayerinterface.h:9
std::string Id() const
Get the subscription ID.
Definition: conferencesubscription.h:52
Observer that receives events from subscription.
Definition: subscription.h:11
Subscription update option used by subscription&#39;s ApplyOptions API.
Definition: subscribeoptions.h:65
Definition: conferencesubscription.h:25