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_SESSION_PHONE_MEDIASESSIONCLIENT_H_
29
#define TALK_SESSION_PHONE_MEDIASESSIONCLIENT_H_
35
#include "talk/session/phone/call.h"
36
#include "talk/session/phone/channelmanager.h"
37
#include "talk/session/phone/cryptoparams.h"
38
#include "talk/session/phone/mediasession.h"
39
#include "talk/base/sigslot.h"
40
#include "talk/base/sigslotrepeater.h"
41
#include "talk/base/messagequeue.h"
42
#include "talk/base/thread.h"
43
#include "talk/p2p/base/sessionmanager.h"
44
#include "talk/p2p/base/session.h"
45
#include "talk/p2p/base/sessionclient.h"
46
#include "talk/p2p/base/sessiondescription.h"
52
class MediaSessionClient : public SessionClient, public sigslot::has_slots<> {
54
MediaSessionClient(const buzz::Jid& jid, SessionManager *manager);
55
// Alternative constructor, allowing injection of media_engine
56
// and device_manager.
57
MediaSessionClient(const buzz::Jid& jid, SessionManager *manager,
58
MediaEngineInterface* media_engine,
59
DataEngineInterface* data_media_engine,
60
DeviceManagerInterface* device_manager);
61
~MediaSessionClient();
63
const buzz::Jid &jid() const { return jid_; }
64
SessionManager* session_manager() const { return session_manager_; }
65
ChannelManager* channel_manager() const { return channel_manager_; }
67
SecureMediaPolicy secure() const { return desc_factory_.secure(); }
68
void set_secure(SecureMediaPolicy s) { desc_factory_.set_secure(s); }
70
int GetCapabilities() { return channel_manager_->GetCapabilities(); }
73
void DestroyCall(Call *call);
76
void SetFocus(Call *call);
78
void JoinCalls(Call *call_to_join, Call *call);
80
bool GetAudioInputDevices(std::vector<std::string>* names) {
81
return channel_manager_->GetAudioInputDevices(names);
83
bool GetAudioOutputDevices(std::vector<std::string>* names) {
84
return channel_manager_->GetAudioOutputDevices(names);
86
bool GetVideoCaptureDevices(std::vector<std::string>* names) {
87
return channel_manager_->GetVideoCaptureDevices(names);
90
bool SetAudioOptions(const std::string& in_name, const std::string& out_name,
92
return channel_manager_->SetAudioOptions(in_name, out_name, opts);
94
bool SetOutputVolume(int level) {
95
return channel_manager_->SetOutputVolume(level);
97
bool SetVideoOptions(const std::string& cam_device) {
98
return channel_manager_->SetVideoOptions(cam_device);
101
SessionDescription* CreateOffer(const CallOptions& options) {
102
return desc_factory_.CreateOffer(options, NULL);
104
SessionDescription* CreateAnswer(const SessionDescription* offer,
105
const CallOptions& options) {
106
return desc_factory_.CreateAnswer(offer, options, NULL);
109
sigslot::signal2<Call *, Call *> SignalFocus;
110
sigslot::signal1<Call *> SignalCallCreate;
111
sigslot::signal1<Call *> SignalCallDestroy;
112
sigslot::repeater0<> SignalDevicesChange;
114
virtual bool ParseContent(SignalingProtocol protocol,
115
const buzz::XmlElement* elem,
116
const ContentDescription** content,
118
virtual bool IsWritable(SignalingProtocol protocol,
119
const ContentDescription* content);
120
virtual bool WriteContent(SignalingProtocol protocol,
121
const ContentDescription* content,
122
buzz::XmlElement** elem,
127
void OnSessionCreate(Session *session, bool received_initiate);
128
void OnSessionState(BaseSession *session, BaseSession::State state);
129
void OnSessionDestroy(Session *session);
130
Session *CreateSession(Call *call);
133
SessionManager* session_manager_;
135
ChannelManager *channel_manager_;
136
MediaSessionDescriptionFactory desc_factory_;
137
std::map<uint32, Call *> calls_;
138
std::map<std::string, Call *> session_map_;
142
} // namespace cricket
144
#endif // TALK_SESSION_PHONE_MEDIASESSIONCLIENT_H_