OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_LIBJINGLE_XMPP_HANGOUTPUBSUBCLIENT_H_ |
| 12 #define WEBRTC_LIBJINGLE_XMPP_HANGOUTPUBSUBCLIENT_H_ |
| 13 |
| 14 #include <map> |
| 15 #include <memory> |
| 16 #include <string> |
| 17 #include <vector> |
| 18 |
| 19 #include "webrtc/libjingle/xmpp/jid.h" |
| 20 #include "webrtc/libjingle/xmpp/pubsubclient.h" |
| 21 #include "webrtc/libjingle/xmpp/pubsubstateclient.h" |
| 22 #include "webrtc/base/sigslot.h" |
| 23 #include "webrtc/base/sigslotrepeater.h" |
| 24 |
| 25 // Gives a high-level API for MUC call PubSub needs such as |
| 26 // presenter state, recording state, mute state, and remote mute. |
| 27 |
| 28 namespace buzz { |
| 29 |
| 30 class Jid; |
| 31 class XmlElement; |
| 32 class XmppTaskParentInterface; |
| 33 |
| 34 // A client tied to a specific MUC jid and local nick. Provides ways |
| 35 // to get updates and publish state and events. Must call |
| 36 // RequestAll() to start getting updates. |
| 37 class HangoutPubSubClient : public sigslot::has_slots<> { |
| 38 public: |
| 39 HangoutPubSubClient(XmppTaskParentInterface* parent, |
| 40 const Jid& mucjid, |
| 41 const std::string& nick); |
| 42 ~HangoutPubSubClient(); |
| 43 const Jid& mucjid() const { return mucjid_; } |
| 44 const std::string& nick() const { return nick_; } |
| 45 |
| 46 // Requests all of the different states and subscribes for updates. |
| 47 // Responses and updates will be signalled via the various signals. |
| 48 void RequestAll(); |
| 49 // Signal (nick, was_presenting, is_presenting) |
| 50 sigslot::signal3<const std::string&, bool, bool> SignalPresenterStateChange; |
| 51 // Signal (nick, was_muted, is_muted) |
| 52 sigslot::signal3<const std::string&, bool, bool> SignalAudioMuteStateChange; |
| 53 // Signal (nick, was_muted, is_muted) |
| 54 sigslot::signal3<const std::string&, bool, bool> SignalVideoMuteStateChange; |
| 55 // Signal (nick, was_paused, is_paused) |
| 56 sigslot::signal3<const std::string&, bool, bool> SignalVideoPauseStateChange; |
| 57 // Signal (nick, was_recording, is_recording) |
| 58 sigslot::signal3<const std::string&, bool, bool> SignalRecordingStateChange; |
| 59 // Signal (mutee_nick, muter_nick, should_mute_locally) |
| 60 sigslot::signal3<const std::string&, |
| 61 const std::string&, |
| 62 bool> SignalRemoteMute; |
| 63 // Signal (blockee_nick, blocker_nick) |
| 64 sigslot::signal2<const std::string&, const std::string&> SignalMediaBlock; |
| 65 |
| 66 // Signal (node, error stanza) |
| 67 sigslot::signal2<const std::string&, const XmlElement*> SignalRequestError; |
| 68 |
| 69 // On each of these, provide a task_id_out to get the task_id, which |
| 70 // can be correlated to the error and result signals. |
| 71 void PublishPresenterState( |
| 72 bool presenting, std::string* task_id_out = NULL); |
| 73 void PublishAudioMuteState( |
| 74 bool muted, std::string* task_id_out = NULL); |
| 75 void PublishVideoMuteState( |
| 76 bool muted, std::string* task_id_out = NULL); |
| 77 void PublishVideoPauseState( |
| 78 bool paused, std::string* task_id_out = NULL); |
| 79 void PublishRecordingState( |
| 80 bool recording, std::string* task_id_out = NULL); |
| 81 void RemoteMute( |
| 82 const std::string& mutee_nick, std::string* task_id_out = NULL); |
| 83 void BlockMedia( |
| 84 const std::string& blockee_nick, std::string* task_id_out = NULL); |
| 85 |
| 86 // Signal task_id |
| 87 sigslot::signal1<const std::string&> SignalPublishAudioMuteResult; |
| 88 sigslot::signal1<const std::string&> SignalPublishVideoMuteResult; |
| 89 sigslot::signal1<const std::string&> SignalPublishVideoPauseResult; |
| 90 sigslot::signal1<const std::string&> SignalPublishPresenterResult; |
| 91 sigslot::signal1<const std::string&> SignalPublishRecordingResult; |
| 92 // Signal (task_id, mutee_nick) |
| 93 sigslot::signal2<const std::string&, |
| 94 const std::string&> SignalRemoteMuteResult; |
| 95 // Signal (task_id, blockee_nick) |
| 96 sigslot::signal2<const std::string&, |
| 97 const std::string&> SignalMediaBlockResult; |
| 98 |
| 99 // Signal (task_id, error stanza) |
| 100 sigslot::signal2<const std::string&, |
| 101 const XmlElement*> SignalPublishAudioMuteError; |
| 102 sigslot::signal2<const std::string&, |
| 103 const XmlElement*> SignalPublishVideoMuteError; |
| 104 sigslot::signal2<const std::string&, |
| 105 const XmlElement*> SignalPublishVideoPauseError; |
| 106 sigslot::signal2<const std::string&, |
| 107 const XmlElement*> SignalPublishPresenterError; |
| 108 sigslot::signal2<const std::string&, |
| 109 const XmlElement*> SignalPublishRecordingError; |
| 110 sigslot::signal2<const std::string&, |
| 111 const XmlElement*> SignalPublishMediaBlockError; |
| 112 // Signal (task_id, mutee_nick, error stanza) |
| 113 sigslot::signal3<const std::string&, |
| 114 const std::string&, |
| 115 const XmlElement*> SignalRemoteMuteError; |
| 116 // Signal (task_id, blockee_nick, error stanza) |
| 117 sigslot::signal3<const std::string&, |
| 118 const std::string&, |
| 119 const XmlElement*> SignalMediaBlockError; |
| 120 |
| 121 |
| 122 private: |
| 123 void OnPresenterRequestError(PubSubClient* client, |
| 124 const XmlElement* stanza); |
| 125 void OnMediaRequestError(PubSubClient* client, |
| 126 const XmlElement* stanza); |
| 127 |
| 128 void OnPresenterStateChange(const PubSubStateChange<bool>& change); |
| 129 void OnPresenterPublishResult(const std::string& task_id, |
| 130 const XmlElement* item); |
| 131 void OnPresenterPublishError(const std::string& task_id, |
| 132 const XmlElement* item, |
| 133 const XmlElement* stanza); |
| 134 void OnAudioMuteStateChange(const PubSubStateChange<bool>& change); |
| 135 void OnAudioMutePublishResult(const std::string& task_id, |
| 136 const XmlElement* item); |
| 137 void OnAudioMutePublishError(const std::string& task_id, |
| 138 const XmlElement* item, |
| 139 const XmlElement* stanza); |
| 140 void OnVideoMuteStateChange(const PubSubStateChange<bool>& change); |
| 141 void OnVideoMutePublishResult(const std::string& task_id, |
| 142 const XmlElement* item); |
| 143 void OnVideoMutePublishError(const std::string& task_id, |
| 144 const XmlElement* item, |
| 145 const XmlElement* stanza); |
| 146 void OnVideoPauseStateChange(const PubSubStateChange<bool>& change); |
| 147 void OnVideoPausePublishResult(const std::string& task_id, |
| 148 const XmlElement* item); |
| 149 void OnVideoPausePublishError(const std::string& task_id, |
| 150 const XmlElement* item, |
| 151 const XmlElement* stanza); |
| 152 void OnRecordingStateChange(const PubSubStateChange<bool>& change); |
| 153 void OnRecordingPublishResult(const std::string& task_id, |
| 154 const XmlElement* item); |
| 155 void OnRecordingPublishError(const std::string& task_id, |
| 156 const XmlElement* item, |
| 157 const XmlElement* stanza); |
| 158 void OnMediaBlockStateChange(const PubSubStateChange<bool>& change); |
| 159 void OnMediaBlockPublishResult(const std::string& task_id, |
| 160 const XmlElement* item); |
| 161 void OnMediaBlockPublishError(const std::string& task_id, |
| 162 const XmlElement* item, |
| 163 const XmlElement* stanza); |
| 164 Jid mucjid_; |
| 165 std::string nick_; |
| 166 std::unique_ptr<PubSubClient> media_client_; |
| 167 std::unique_ptr<PubSubClient> presenter_client_; |
| 168 std::unique_ptr<PubSubStateClient<bool> > presenter_state_client_; |
| 169 std::unique_ptr<PubSubStateClient<bool> > audio_mute_state_client_; |
| 170 std::unique_ptr<PubSubStateClient<bool> > video_mute_state_client_; |
| 171 std::unique_ptr<PubSubStateClient<bool> > video_pause_state_client_; |
| 172 std::unique_ptr<PubSubStateClient<bool> > recording_state_client_; |
| 173 std::unique_ptr<PubSubStateClient<bool> > media_block_state_client_; |
| 174 }; |
| 175 |
| 176 } // namespace buzz |
| 177 |
| 178 #endif // WEBRTC_LIBJINGLE_XMPP_HANGOUTPUBSUBCLIENT_H_ |
OLD | NEW |