| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * libjingle | |
| 3 * Copyright 2004 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 WEBRTC_LIBJINGLE_SESSION_MEDIA_MEDIASESSIONCLIENT_H_ | |
| 29 #define WEBRTC_LIBJINGLE_SESSION_MEDIA_MEDIASESSIONCLIENT_H_ | |
| 30 | |
| 31 #include <algorithm> | |
| 32 #include <map> | |
| 33 #include <string> | |
| 34 #include <vector> | |
| 35 | |
| 36 #include "talk/media/base/cryptoparams.h" | |
| 37 #include "talk/session/media/channelmanager.h" | |
| 38 #include "talk/session/media/mediasession.h" | |
| 39 #include "webrtc/base/messagequeue.h" | |
| 40 #include "webrtc/base/sigslot.h" | |
| 41 #include "webrtc/base/sigslotrepeater.h" | |
| 42 #include "webrtc/base/thread.h" | |
| 43 #include "webrtc/libjingle/session/media/call.h" | |
| 44 #include "webrtc/libjingle/session/sessionclient.h" | |
| 45 #include "webrtc/libjingle/session/sessionmanager.h" | |
| 46 #include "webrtc/p2p/base/sessiondescription.h" | |
| 47 | |
| 48 namespace cricket { | |
| 49 | |
| 50 class Call; | |
| 51 | |
| 52 class MediaSessionClient : public SessionClient, public sigslot::has_slots<> { | |
| 53 public: | |
| 54 #if !defined(DISABLE_MEDIA_ENGINE_FACTORY) | |
| 55 MediaSessionClient(const buzz::Jid& jid, SessionManager *manager); | |
| 56 #endif | |
| 57 // Alternative constructor, allowing injection of media_engine | |
| 58 // and device_manager. | |
| 59 MediaSessionClient(const buzz::Jid& jid, SessionManager *manager, | |
| 60 MediaEngineInterface* media_engine, | |
| 61 DataEngineInterface* data_media_engine, | |
| 62 DeviceManagerInterface* device_manager); | |
| 63 ~MediaSessionClient(); | |
| 64 | |
| 65 const buzz::Jid &jid() const { return jid_; } | |
| 66 SessionManager* session_manager() const { return session_manager_; } | |
| 67 ChannelManager* channel_manager() const { return channel_manager_; } | |
| 68 | |
| 69 // Return mapping of call ids to Calls. | |
| 70 const std::map<uint32, Call *>& calls() const { return calls_; } | |
| 71 | |
| 72 // The settings below combine with the settings on SessionManager to choose | |
| 73 | |
| 74 // whether SDES-SRTP, DTLS-SRTP, or no security should be used. The possible | |
| 75 // combinations are shown in the following table. Note that where either DTLS | |
| 76 // or SDES is possible, DTLS is preferred. Thus to require either SDES or | |
| 77 // DTLS, but not mandate DTLS, set SDES to require and DTLS to enable. | |
| 78 // | |
| 79 // | SDES:Disable | SDES:Enable | SDES:Require | | |
| 80 // ----------------------------------------------------------------| | |
| 81 // DTLS:Disable | No SRTP | SDES Optional | SDES Mandatory | | |
| 82 // DTLS:Enable | DTLS Optional | DTLS/SDES Opt | DTLS/SDES Mand | | |
| 83 // DTLS:Require | DTLS Mandatory | DTLS Mandatory | DTLS Mandatory | | |
| 84 | |
| 85 // Control use of SDES-SRTP. | |
| 86 SecurePolicy secure() const { return desc_factory_.secure(); } | |
| 87 void set_secure(SecurePolicy s) { desc_factory_.set_secure(s); } | |
| 88 | |
| 89 // Control use of multiple sessions in a call. | |
| 90 void set_multisession_enabled(bool multisession_enabled) { | |
| 91 multisession_enabled_ = multisession_enabled; | |
| 92 } | |
| 93 | |
| 94 int GetCapabilities() { return channel_manager_->GetCapabilities(); } | |
| 95 | |
| 96 Call *CreateCall(); | |
| 97 void DestroyCall(Call *call); | |
| 98 | |
| 99 Call *GetFocus(); | |
| 100 void SetFocus(Call *call); | |
| 101 | |
| 102 void JoinCalls(Call *call_to_join, Call *call); | |
| 103 | |
| 104 bool GetAudioInputDevices(std::vector<std::string>* names) { | |
| 105 return channel_manager_->GetAudioInputDevices(names); | |
| 106 } | |
| 107 bool GetAudioOutputDevices(std::vector<std::string>* names) { | |
| 108 return channel_manager_->GetAudioOutputDevices(names); | |
| 109 } | |
| 110 bool GetVideoCaptureDevices(std::vector<std::string>* names) { | |
| 111 return channel_manager_->GetVideoCaptureDevices(names); | |
| 112 } | |
| 113 | |
| 114 bool SetAudioOptions(const std::string& in_name, const std::string& out_name, | |
| 115 const AudioOptions& options) { | |
| 116 return channel_manager_->SetAudioOptions(in_name, out_name, options); | |
| 117 } | |
| 118 bool SetOutputVolume(int level) { | |
| 119 return channel_manager_->SetOutputVolume(level); | |
| 120 } | |
| 121 bool SetCaptureDevice(const std::string& cam_device) { | |
| 122 return channel_manager_->SetCaptureDevice(cam_device); | |
| 123 } | |
| 124 | |
| 125 SessionDescription* CreateOffer(const CallOptions& options) { | |
| 126 return desc_factory_.CreateOffer(options, NULL); | |
| 127 } | |
| 128 SessionDescription* CreateAnswer(const SessionDescription* offer, | |
| 129 const CallOptions& options) { | |
| 130 return desc_factory_.CreateAnswer(offer, options, NULL); | |
| 131 } | |
| 132 | |
| 133 sigslot::signal2<Call *, Call *> SignalFocus; | |
| 134 sigslot::signal1<Call *> SignalCallCreate; | |
| 135 sigslot::signal1<Call *> SignalCallDestroy; | |
| 136 sigslot::repeater0<> SignalDevicesChange; | |
| 137 | |
| 138 virtual bool ParseContent(SignalingProtocol protocol, | |
| 139 const buzz::XmlElement* elem, | |
| 140 ContentDescription** content, | |
| 141 ParseError* error); | |
| 142 virtual bool IsWritable(SignalingProtocol protocol, | |
| 143 const ContentDescription* content); | |
| 144 virtual bool WriteContent(SignalingProtocol protocol, | |
| 145 const ContentDescription* content, | |
| 146 buzz::XmlElement** elem, | |
| 147 WriteError* error); | |
| 148 | |
| 149 private: | |
| 150 void Construct(); | |
| 151 void OnSessionCreate(Session *session, bool received_initiate); | |
| 152 void OnSessionState(BaseSession *session, BaseSession::State state); | |
| 153 void OnSessionDestroy(Session *session); | |
| 154 Session *CreateSession(Call *call); | |
| 155 Session *CreateSession(const std::string& id, Call* call); | |
| 156 Call *FindCallByRemoteName(const std::string &remote_name); | |
| 157 | |
| 158 buzz::Jid jid_; | |
| 159 SessionManager* session_manager_; | |
| 160 Call *focus_call_; | |
| 161 ChannelManager *channel_manager_; | |
| 162 MediaSessionDescriptionFactory desc_factory_; | |
| 163 bool multisession_enabled_; | |
| 164 std::map<uint32, Call *> calls_; | |
| 165 | |
| 166 // Maintain a mapping of session id to call. | |
| 167 typedef std::map<std::string, Call *> SessionMap; | |
| 168 SessionMap session_map_; | |
| 169 | |
| 170 friend class Call; | |
| 171 }; | |
| 172 | |
| 173 } // namespace cricket | |
| 174 | |
| 175 #endif // WEBRTC_LIBJINGLE_SESSION_MEDIA_MEDIASESSIONCLIENT_H_ | |
| OLD | NEW |