3
* Copyright 2004--2005, Google Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* 3. The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#ifndef TALK_EXAMPLES_CALL_CALLCLIENT_H_
29
#define TALK_EXAMPLES_CALL_CALLCLIENT_H_
35
#include "talk/p2p/base/session.h"
36
#include "talk/session/phone/mediachannel.h"
37
#include "talk/session/phone/mediamessages.h"
38
#include "talk/session/phone/mediasessionclient.h"
39
#include "talk/xmpp/hangoutpubsubclient.h"
40
#include "talk/xmpp/xmppclient.h"
41
#include "talk/examples/call/status.h"
42
#include "talk/examples/call/console.h"
45
class PresencePushTask;
46
class PresenceOutTask;
47
class MucInviteRecvTask;
48
class MucInviteSendTask;
49
class FriendInviteSendTask;
50
class DiscoInfoQueryTask;
54
class MucRoomConfigTask;
55
class MucRoomLookupTask;
58
class HangoutPubSubClient;
59
struct AvailableMediaEntry;
70
class MediaEngineInterface;
71
class MediaSessionClient;
73
class SessionManagerTask;
81
buzz::Status::Show show;
85
struct StaticRenderedView {
86
StaticRenderedView(const cricket::StaticVideoView& view,
87
cricket::VideoRenderer* renderer) :
92
cricket::StaticVideoView view;
93
cricket::VideoRenderer* renderer;
96
typedef std::vector<StaticRenderedView> StaticRenderedViews;
98
class CallClient: public sigslot::has_slots<> {
100
CallClient(buzz::XmppClient* xmpp_client,
101
const std::string& caps_node,
102
const std::string& version);
105
cricket::MediaSessionClient* media_client() const { return media_client_; }
106
void SetMediaEngine(cricket::MediaEngineInterface* media_engine) {
107
media_engine_ = media_engine;
109
void SetAutoAccept(bool auto_accept) {
110
auto_accept_ = auto_accept;
112
void SetPmucDomain(const std::string &pmuc_domain) {
113
pmuc_domain_ = pmuc_domain;
115
void SetRender(bool render) {
118
void SetDataChannelEnabled(bool data_channel_enabled) {
119
data_channel_enabled_ = data_channel_enabled;
121
void SetConsole(Console *console) {
124
void SetPriority(int priority) {
125
my_status_.set_priority(priority);
128
SendStatus(my_status_);
130
void SendStatus(const buzz::Status& status);
132
void ParseLine(const std::string &str);
134
void SendChat(const std::string& to, const std::string msg);
135
void SendData(const std::string& stream_name,
136
const std::string& text);
137
void InviteFriend(const std::string& user);
138
void JoinMuc(const buzz::Jid& room_jid);
139
void JoinMuc(const std::string& room_jid_str);
140
void LookupAndJoinMuc(const std::string& room_name);
141
void InviteToMuc(const std::string& user, const std::string& room);
143
const buzz::Jid* FirstMucJid();
144
void LeaveMuc(const std::string& room);
145
void SetNick(const std::string& muc_nick);
146
void SetPortAllocatorFlags(uint32 flags) { portallocator_flags_ = flags; }
147
void SetAllowLocalIps(bool allow_local_ips) {
148
allow_local_ips_ = allow_local_ips;
151
void SetInitialProtocol(cricket::SignalingProtocol initial_protocol) {
152
initial_protocol_ = initial_protocol;
155
void SetSecurePolicy(cricket::SecureMediaPolicy secure_policy) {
156
secure_policy_ = secure_policy;
160
typedef std::map<buzz::Jid, buzz::Muc*> MucMap;
162
const MucMap& mucs() const {
167
void AddStream(uint32 audio_src_id, uint32 video_src_id);
168
void RemoveStream(uint32 audio_src_id, uint32 video_src_id);
169
void OnStateChange(buzz::XmppEngine::State state);
173
void OnRequestSignaling();
174
void OnSessionCreate(cricket::Session* session, bool initiate);
175
void OnCallCreate(cricket::Call* call);
176
void OnCallDestroy(cricket::Call* call);
177
void OnSessionState(cricket::Call* call,
178
cricket::Session* session,
179
cricket::Session::State state);
180
void OnStatusUpdate(const buzz::Status& status);
181
void OnMucInviteReceived(const buzz::Jid& inviter, const buzz::Jid& room,
182
const std::vector<buzz::AvailableMediaEntry>& avail);
183
void OnMucJoined(const buzz::Jid& endpoint);
184
void OnMucStatusUpdate(const buzz::Jid& jid, const buzz::MucStatus& status);
185
void OnMucLeft(const buzz::Jid& endpoint, int error);
186
void OnPresenterStateChange(const std::string& nick,
187
bool was_presenting, bool is_presenting);
188
void OnAudioMuteStateChange(const std::string& nick,
189
bool was_muted, bool is_muted);
190
void OnRecordingStateChange(const std::string& nick,
191
bool was_recording, bool is_recording);
192
void OnRemoteMuted(const std::string& mutee_nick,
193
const std::string& muter_nick,
194
bool should_mute_locally);
195
void OnMediaBlocked(const std::string& blockee_nick,
196
const std::string& blocker_nick);
197
void OnHangoutRequestError(const std::string& node,
198
const buzz::XmlElement* stanza);
199
void OnHangoutPublishAudioMuteError(const std::string& task_id,
200
const buzz::XmlElement* stanza);
201
void OnHangoutPublishPresenterError(const std::string& task_id,
202
const buzz::XmlElement* stanza);
203
void OnHangoutPublishRecordingError(const std::string& task_id,
204
const buzz::XmlElement* stanza);
205
void OnHangoutRemoteMuteError(const std::string& task_id,
206
const std::string& mutee_nick,
207
const buzz::XmlElement* stanza);
208
void OnDevicesChange();
209
void OnMediaStreamsUpdate(cricket::Call* call,
210
cricket::Session* session,
211
const cricket::MediaStreams& added,
212
const cricket::MediaStreams& removed);
213
void OnSpeakerChanged(cricket::Call* call,
214
cricket::Session* session,
215
const cricket::StreamParams& speaker_stream);
216
void OnRoomLookupResponse(buzz::MucRoomLookupTask* task,
217
const buzz::MucRoomInfo& room_info);
218
void OnRoomLookupError(buzz::IqTask* task,
219
const buzz::XmlElement* stanza);
220
void OnRoomConfigResult(buzz::MucRoomConfigTask* task);
221
void OnRoomConfigError(buzz::IqTask* task,
222
const buzz::XmlElement* stanza);
223
void OnDataReceived(cricket::Call*,
224
const cricket::ReceiveDataParams& params,
225
const std::string& data);
226
buzz::Jid GenerateRandomMucJid();
228
void AddStaticRenderedView(
229
cricket::Session* session,
230
uint32 ssrc, int width, int height, int framerate,
231
int x_offset, int y_offset);
232
bool RemoveStaticRenderedView(uint32 ssrc);
233
void RemoveAllStaticRenderedViews();
234
void SendViewRequest(cricket::Session* session);
237
static const std::string strerror(buzz::XmppEngine::Error err);
240
void MakeCallTo(const std::string& name, const cricket::CallOptions& options);
241
void PlaceCall(const buzz::Jid& jid, const cricket::CallOptions& options);
242
void Accept(const cricket::CallOptions& options);
247
void PrintDevices(const std::vector<std::string>& names);
249
void SetVolume(const std::string& level);
251
typedef std::map<std::string, RosterItem> RosterMap;
254
buzz::XmppClient* xmpp_client_;
255
talk_base::Thread* worker_thread_;
256
talk_base::NetworkManager* network_manager_;
257
cricket::PortAllocator* port_allocator_;
258
cricket::SessionManager* session_manager_;
259
cricket::SessionManagerTask* session_manager_task_;
260
cricket::MediaEngineInterface* media_engine_;
261
cricket::DataEngineInterface* data_engine_;
262
cricket::MediaSessionClient* media_client_;
265
cricket::Call* call_;
266
cricket::Session *session_;
267
buzz::HangoutPubSubClient* hangout_pubsub_client_;
270
std::string pmuc_domain_;
272
bool data_channel_enabled_;
273
cricket::VideoRenderer* local_renderer_;
274
cricket::VideoRenderer* remote_renderer_;
275
StaticRenderedViews static_rendered_views_;
276
uint32 static_views_accumulated_count_;
278
buzz::Status my_status_;
279
buzz::PresencePushTask* presence_push_;
280
buzz::PresenceOutTask* presence_out_;
281
buzz::MucInviteRecvTask* muc_invite_recv_;
282
buzz::MucInviteSendTask* muc_invite_send_;
283
buzz::FriendInviteSendTask* friend_invite_send_;
285
uint32 portallocator_flags_;
287
bool allow_local_ips_;
288
cricket::SignalingProtocol initial_protocol_;
289
cricket::SecureMediaPolicy secure_policy_;
290
std::string last_sent_to_;
293
#endif // TALK_EXAMPLES_CALL_CALLCLIENT_H_