~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/googletalk/libjingle/talk/examples/call/callclient.h

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libjingle
3
 
 * Copyright 2004--2005, Google Inc.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
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.
15
 
 *
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.
26
 
 */
27
 
 
28
 
#ifndef TALK_EXAMPLES_CALL_CALLCLIENT_H_
29
 
#define TALK_EXAMPLES_CALL_CALLCLIENT_H_
30
 
 
31
 
#include <map>
32
 
#include <string>
33
 
#include <vector>
34
 
 
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"
43
 
 
44
 
namespace buzz {
45
 
class PresencePushTask;
46
 
class PresenceOutTask;
47
 
class MucInviteRecvTask;
48
 
class MucInviteSendTask;
49
 
class FriendInviteSendTask;
50
 
class DiscoInfoQueryTask;
51
 
class Muc;
52
 
class Status;
53
 
class IqTask;
54
 
class MucRoomConfigTask;
55
 
class MucRoomLookupTask;
56
 
class MucStatus;
57
 
class XmlElement;
58
 
class HangoutPubSubClient;
59
 
struct AvailableMediaEntry;
60
 
struct MucRoomInfo;
61
 
}
62
 
 
63
 
namespace talk_base {
64
 
class Thread;
65
 
class NetworkManager;
66
 
}
67
 
 
68
 
namespace cricket {
69
 
class PortAllocator;
70
 
class MediaEngineInterface;
71
 
class MediaSessionClient;
72
 
class Call;
73
 
class SessionManagerTask;
74
 
struct CallOptions;
75
 
struct MediaStreams;
76
 
struct StreamParams;
77
 
}
78
 
 
79
 
struct RosterItem {
80
 
  buzz::Jid jid;
81
 
  buzz::Status::Show show;
82
 
  std::string status;
83
 
};
84
 
 
85
 
struct StaticRenderedView {
86
 
  StaticRenderedView(const cricket::StaticVideoView& view,
87
 
                     cricket::VideoRenderer* renderer) :
88
 
      view(view),
89
 
      renderer(renderer) {
90
 
  }
91
 
 
92
 
  cricket::StaticVideoView view;
93
 
  cricket::VideoRenderer* renderer;
94
 
};
95
 
 
96
 
typedef std::vector<StaticRenderedView> StaticRenderedViews;
97
 
 
98
 
class CallClient: public sigslot::has_slots<> {
99
 
 public:
100
 
  CallClient(buzz::XmppClient* xmpp_client,
101
 
             const std::string& caps_node,
102
 
             const std::string& version);
103
 
  ~CallClient();
104
 
 
105
 
  cricket::MediaSessionClient* media_client() const { return media_client_; }
106
 
  void SetMediaEngine(cricket::MediaEngineInterface* media_engine) {
107
 
    media_engine_ = media_engine;
108
 
  }
109
 
  void SetAutoAccept(bool auto_accept) {
110
 
    auto_accept_ = auto_accept;
111
 
  }
112
 
  void SetPmucDomain(const std::string &pmuc_domain) {
113
 
    pmuc_domain_ = pmuc_domain;
114
 
  }
115
 
  void SetRender(bool render) {
116
 
    render_ = render;
117
 
  }
118
 
  void SetDataChannelEnabled(bool data_channel_enabled) {
119
 
    data_channel_enabled_ = data_channel_enabled;
120
 
  }
121
 
  void SetConsole(Console *console) {
122
 
    console_ = console;
123
 
  }
124
 
  void SetPriority(int priority) {
125
 
    my_status_.set_priority(priority);
126
 
  }
127
 
  void SendStatus() {
128
 
    SendStatus(my_status_);
129
 
  }
130
 
  void SendStatus(const buzz::Status& status);
131
 
 
132
 
  void ParseLine(const std::string &str);
133
 
 
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);
142
 
  bool InMuc();
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;
149
 
  }
150
 
 
151
 
  void SetInitialProtocol(cricket::SignalingProtocol initial_protocol) {
152
 
    initial_protocol_ = initial_protocol;
153
 
  }
154
 
 
155
 
  void SetSecurePolicy(cricket::SecureMediaPolicy secure_policy) {
156
 
    secure_policy_ = secure_policy;
157
 
  }
158
 
 
159
 
 
160
 
  typedef std::map<buzz::Jid, buzz::Muc*> MucMap;
161
 
 
162
 
  const MucMap& mucs() const {
163
 
    return mucs_;
164
 
  }
165
 
 
166
 
 private:
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);
170
 
 
171
 
  void InitMedia();
172
 
  void InitPresence();
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();
227
 
 
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);
235
 
 
236
 
 
237
 
  static const std::string strerror(buzz::XmppEngine::Error err);
238
 
 
239
 
  void PrintRoster();
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);
243
 
  void Reject();
244
 
  void Quit();
245
 
 
246
 
  void GetDevices();
247
 
  void PrintDevices(const std::vector<std::string>& names);
248
 
 
249
 
  void SetVolume(const std::string& level);
250
 
 
251
 
  typedef std::map<std::string, RosterItem> RosterMap;
252
 
 
253
 
  Console *console_;
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_;
263
 
  MucMap mucs_;
264
 
 
265
 
  cricket::Call* call_;
266
 
  cricket::Session *session_;
267
 
  buzz::HangoutPubSubClient* hangout_pubsub_client_;
268
 
  bool incoming_call_;
269
 
  bool auto_accept_;
270
 
  std::string pmuc_domain_;
271
 
  bool render_;
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_;
277
 
 
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_;
284
 
  RosterMap* roster_;
285
 
  uint32 portallocator_flags_;
286
 
 
287
 
  bool allow_local_ips_;
288
 
  cricket::SignalingProtocol initial_protocol_;
289
 
  cricket::SecureMediaPolicy secure_policy_;
290
 
  std::string last_sent_to_;
291
 
};
292
 
 
293
 
#endif  // TALK_EXAMPLES_CALL_CALLCLIENT_H_