| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // It uses MediaStreamSignaling and WebRtcSession to implement | 50 // It uses MediaStreamSignaling and WebRtcSession to implement |
| 51 // the PeerConnection functionality. | 51 // the PeerConnection functionality. |
| 52 class PeerConnection : public PeerConnectionInterface, | 52 class PeerConnection : public PeerConnectionInterface, |
| 53 public MediaStreamSignalingObserver, | 53 public MediaStreamSignalingObserver, |
| 54 public IceObserver, | 54 public IceObserver, |
| 55 public rtc::MessageHandler, | 55 public rtc::MessageHandler, |
| 56 public sigslot::has_slots<> { | 56 public sigslot::has_slots<> { |
| 57 public: | 57 public: |
| 58 explicit PeerConnection(PeerConnectionFactory* factory); | 58 explicit PeerConnection(PeerConnectionFactory* factory); |
| 59 | 59 |
| 60 // This method takes the ownership of |dtls_identity_service|. |
| 60 bool Initialize( | 61 bool Initialize( |
| 61 const PeerConnectionInterface::RTCConfiguration& configuration, | 62 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 62 const MediaConstraintsInterface* constraints, | 63 const MediaConstraintsInterface* constraints, |
| 63 PortAllocatorFactoryInterface* allocator_factory, | 64 PortAllocatorFactoryInterface* allocator_factory, |
| 64 DTLSIdentityServiceInterface* dtls_identity_service, | 65 DTLSIdentityServiceInterface* dtls_identity_service, |
| 65 PeerConnectionObserver* observer); | 66 PeerConnectionObserver* observer); |
| 67 bool Initialize( |
| 68 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 69 const MediaConstraintsInterface* constraints, |
| 70 PortAllocatorFactoryInterface* allocator_factory, |
| 71 rtc::scoped_refptr<DtlsCertificate> certificate, |
| 72 PeerConnectionObserver* observer); |
| 66 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); | 73 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); |
| 67 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); | 74 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); |
| 68 virtual bool AddStream(MediaStreamInterface* local_stream); | 75 virtual bool AddStream(MediaStreamInterface* local_stream); |
| 69 virtual void RemoveStream(MediaStreamInterface* local_stream); | 76 virtual void RemoveStream(MediaStreamInterface* local_stream); |
| 70 | 77 |
| 71 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( | 78 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( |
| 72 AudioTrackInterface* track); | 79 AudioTrackInterface* track); |
| 73 | 80 |
| 74 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( | 81 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
| 75 const std::string& label, | 82 const std::string& label, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 virtual bool AddIceCandidate(const IceCandidateInterface* candidate); | 115 virtual bool AddIceCandidate(const IceCandidateInterface* candidate); |
| 109 | 116 |
| 110 virtual void RegisterUMAObserver(UMAObserver* observer); | 117 virtual void RegisterUMAObserver(UMAObserver* observer); |
| 111 | 118 |
| 112 virtual void Close(); | 119 virtual void Close(); |
| 113 | 120 |
| 114 protected: | 121 protected: |
| 115 virtual ~PeerConnection(); | 122 virtual ~PeerConnection(); |
| 116 | 123 |
| 117 private: | 124 private: |
| 125 bool InitializeCommon( |
| 126 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 127 const MediaConstraintsInterface* constraints, |
| 128 PortAllocatorFactoryInterface* allocator_factory, |
| 129 PeerConnectionObserver* observer); |
| 130 void InitializeSessionAfterInit(); |
| 131 |
| 118 // Implements MessageHandler. | 132 // Implements MessageHandler. |
| 119 virtual void OnMessage(rtc::Message* msg); | 133 virtual void OnMessage(rtc::Message* msg); |
| 120 | 134 |
| 121 // Implements MediaStreamSignalingObserver. | 135 // Implements MediaStreamSignalingObserver. |
| 122 void OnAddRemoteStream(MediaStreamInterface* stream) override; | 136 void OnAddRemoteStream(MediaStreamInterface* stream) override; |
| 123 void OnRemoveRemoteStream(MediaStreamInterface* stream) override; | 137 void OnRemoveRemoteStream(MediaStreamInterface* stream) override; |
| 124 void OnAddDataChannel(DataChannelInterface* data_channel) override; | 138 void OnAddDataChannel(DataChannelInterface* data_channel) override; |
| 125 void OnAddRemoteAudioTrack(MediaStreamInterface* stream, | 139 void OnAddRemoteAudioTrack(MediaStreamInterface* stream, |
| 126 AudioTrackInterface* audio_track, | 140 AudioTrackInterface* audio_track, |
| 127 uint32 ssrc) override; | 141 uint32 ssrc) override; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 150 void OnIceGatheringChange(IceGatheringState new_state) override; | 164 void OnIceGatheringChange(IceGatheringState new_state) override; |
| 151 void OnIceCandidate(const IceCandidateInterface* candidate) override; | 165 void OnIceCandidate(const IceCandidateInterface* candidate) override; |
| 152 void OnIceComplete() override; | 166 void OnIceComplete() override; |
| 153 void OnIceConnectionReceivingChange(bool receiving) override; | 167 void OnIceConnectionReceivingChange(bool receiving) override; |
| 154 | 168 |
| 155 // Signals from WebRtcSession. | 169 // Signals from WebRtcSession. |
| 156 void OnSessionStateChange(cricket::BaseSession* session, | 170 void OnSessionStateChange(cricket::BaseSession* session, |
| 157 cricket::BaseSession::State state); | 171 cricket::BaseSession::State state); |
| 158 void ChangeSignalingState(SignalingState signaling_state); | 172 void ChangeSignalingState(SignalingState signaling_state); |
| 159 | 173 |
| 160 bool DoInitialize(IceTransportsType type, | |
| 161 const StunConfigurations& stun_config, | |
| 162 const TurnConfigurations& turn_config, | |
| 163 const MediaConstraintsInterface* constraints, | |
| 164 PortAllocatorFactoryInterface* allocator_factory, | |
| 165 DTLSIdentityServiceInterface* dtls_identity_service, | |
| 166 PeerConnectionObserver* observer); | |
| 167 | |
| 168 rtc::Thread* signaling_thread() const { | 174 rtc::Thread* signaling_thread() const { |
| 169 return factory_->signaling_thread(); | 175 return factory_->signaling_thread(); |
| 170 } | 176 } |
| 171 | 177 |
| 172 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, | 178 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
| 173 const std::string& error); | 179 const std::string& error); |
| 174 | 180 |
| 175 bool IsClosed() const { | 181 bool IsClosed() const { |
| 176 return signaling_state_ == PeerConnectionInterface::kClosed; | 182 return signaling_state_ == PeerConnectionInterface::kClosed; |
| 177 } | 183 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 194 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; | 200 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; |
| 195 rtc::scoped_ptr<WebRtcSession> session_; | 201 rtc::scoped_ptr<WebRtcSession> session_; |
| 196 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; | 202 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; |
| 197 rtc::scoped_ptr<MediaStreamHandlerContainer> stream_handler_container_; | 203 rtc::scoped_ptr<MediaStreamHandlerContainer> stream_handler_container_; |
| 198 rtc::scoped_ptr<StatsCollector> stats_; | 204 rtc::scoped_ptr<StatsCollector> stats_; |
| 199 }; | 205 }; |
| 200 | 206 |
| 201 } // namespace webrtc | 207 } // namespace webrtc |
| 202 | 208 |
| 203 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ | 209 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| OLD | NEW |