| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef TALK_APP_WEBRTC_PEERCONNECTION_H_ | 28 #ifndef TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| 29 #define TALK_APP_WEBRTC_PEERCONNECTION_H_ | 29 #define TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| 30 | 30 |
| 31 #include <string> | 31 #include <string> |
| 32 | 32 |
| 33 #include "talk/app/webrtc/dtlsidentitystore.h" | 33 #include "talk/app/webrtc/dtlsidentitystore.h" |
| 34 #include "talk/app/webrtc/mediastreamsignaling.h" | 34 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 35 #include "talk/app/webrtc/peerconnectionfactory.h" | 35 #include "talk/app/webrtc/peerconnectionfactory.h" |
| 36 #include "talk/app/webrtc/peerconnectioninterface.h" | 36 #include "talk/app/webrtc/peerconnectioninterface.h" |
| 37 #include "talk/app/webrtc/rtpreceiverinterface.h" |
| 38 #include "talk/app/webrtc/rtpsenderinterface.h" |
| 37 #include "talk/app/webrtc/statscollector.h" | 39 #include "talk/app/webrtc/statscollector.h" |
| 38 #include "talk/app/webrtc/streamcollection.h" | 40 #include "talk/app/webrtc/streamcollection.h" |
| 39 #include "talk/app/webrtc/webrtcsession.h" | 41 #include "talk/app/webrtc/webrtcsession.h" |
| 40 #include "webrtc/base/scoped_ptr.h" | 42 #include "webrtc/base/scoped_ptr.h" |
| 41 | 43 |
| 42 namespace webrtc { | 44 namespace webrtc { |
| 43 class MediaStreamHandlerContainer; | |
| 44 | 45 |
| 45 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> | 46 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> |
| 46 StunConfigurations; | 47 StunConfigurations; |
| 47 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> | 48 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> |
| 48 TurnConfigurations; | 49 TurnConfigurations; |
| 49 | 50 |
| 50 // PeerConnectionImpl implements the PeerConnection interface. | 51 // PeerConnection implements the PeerConnectionInterface interface. |
| 51 // It uses MediaStreamSignaling and WebRtcSession to implement | 52 // It uses MediaStreamSignaling and WebRtcSession to implement |
| 52 // the PeerConnection functionality. | 53 // the PeerConnection functionality. |
| 53 class PeerConnection : public PeerConnectionInterface, | 54 class PeerConnection : public PeerConnectionInterface, |
| 54 public MediaStreamSignalingObserver, | 55 public MediaStreamSignalingObserver, |
| 55 public IceObserver, | 56 public IceObserver, |
| 56 public rtc::MessageHandler, | 57 public rtc::MessageHandler, |
| 57 public sigslot::has_slots<> { | 58 public sigslot::has_slots<> { |
| 58 public: | 59 public: |
| 59 explicit PeerConnection(PeerConnectionFactory* factory); | 60 explicit PeerConnection(PeerConnectionFactory* factory); |
| 60 | 61 |
| 61 bool Initialize( | 62 bool Initialize( |
| 62 const PeerConnectionInterface::RTCConfiguration& configuration, | 63 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 63 const MediaConstraintsInterface* constraints, | 64 const MediaConstraintsInterface* constraints, |
| 64 PortAllocatorFactoryInterface* allocator_factory, | 65 PortAllocatorFactoryInterface* allocator_factory, |
| 65 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 66 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 66 PeerConnectionObserver* observer); | 67 PeerConnectionObserver* observer); |
| 67 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); | 68 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); |
| 68 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); | 69 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); |
| 69 virtual bool AddStream(MediaStreamInterface* local_stream); | 70 virtual bool AddStream(MediaStreamInterface* local_stream); |
| 70 virtual void RemoveStream(MediaStreamInterface* local_stream); | 71 virtual void RemoveStream(MediaStreamInterface* local_stream); |
| 71 | 72 |
| 72 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( | 73 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( |
| 73 AudioTrackInterface* track); | 74 AudioTrackInterface* track); |
| 74 | 75 |
| 76 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() |
| 77 const override; |
| 78 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() |
| 79 const override; |
| 80 |
| 75 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( | 81 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
| 76 const std::string& label, | 82 const std::string& label, |
| 77 const DataChannelInit* config); | 83 const DataChannelInit* config); |
| 78 virtual bool GetStats(StatsObserver* observer, | 84 virtual bool GetStats(StatsObserver* observer, |
| 79 webrtc::MediaStreamTrackInterface* track, | 85 webrtc::MediaStreamTrackInterface* track, |
| 80 StatsOutputLevel level); | 86 StatsOutputLevel level); |
| 81 | 87 |
| 82 virtual SignalingState signaling_state(); | 88 virtual SignalingState signaling_state(); |
| 83 | 89 |
| 84 // TODO(bemasc): Remove ice_state() when callers are removed. | 90 // TODO(bemasc): Remove ice_state() when callers are removed. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return factory_->signaling_thread(); | 167 return factory_->signaling_thread(); |
| 162 } | 168 } |
| 163 | 169 |
| 164 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, | 170 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
| 165 const std::string& error); | 171 const std::string& error); |
| 166 | 172 |
| 167 bool IsClosed() const { | 173 bool IsClosed() const { |
| 168 return signaling_state_ == PeerConnectionInterface::kClosed; | 174 return signaling_state_ == PeerConnectionInterface::kClosed; |
| 169 } | 175 } |
| 170 | 176 |
| 177 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator |
| 178 FindSenderForTrack(MediaStreamTrackInterface* track); |
| 179 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator |
| 180 FindReceiverForTrack(MediaStreamTrackInterface* track); |
| 181 |
| 171 // Storing the factory as a scoped reference pointer ensures that the memory | 182 // Storing the factory as a scoped reference pointer ensures that the memory |
| 172 // in the PeerConnectionFactoryImpl remains available as long as the | 183 // in the PeerConnectionFactoryImpl remains available as long as the |
| 173 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. | 184 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. |
| 174 // However, since the reference counting is done in the | 185 // However, since the reference counting is done in the |
| 175 // PeerConnectionFactoryInteface all instances created using the raw pointer | 186 // PeerConnectionFactoryInteface all instances created using the raw pointer |
| 176 // will refer to the same reference count. | 187 // will refer to the same reference count. |
| 177 rtc::scoped_refptr<PeerConnectionFactory> factory_; | 188 rtc::scoped_refptr<PeerConnectionFactory> factory_; |
| 178 PeerConnectionObserver* observer_; | 189 PeerConnectionObserver* observer_; |
| 179 UMAObserver* uma_observer_; | 190 UMAObserver* uma_observer_; |
| 180 SignalingState signaling_state_; | 191 SignalingState signaling_state_; |
| 181 // TODO(bemasc): Remove ice_state_. | 192 // TODO(bemasc): Remove ice_state_. |
| 182 IceState ice_state_; | 193 IceState ice_state_; |
| 183 IceConnectionState ice_connection_state_; | 194 IceConnectionState ice_connection_state_; |
| 184 IceGatheringState ice_gathering_state_; | 195 IceGatheringState ice_gathering_state_; |
| 185 | 196 |
| 186 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; | 197 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; |
| 187 rtc::scoped_ptr<WebRtcSession> session_; | 198 rtc::scoped_ptr<WebRtcSession> session_; |
| 188 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; | 199 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; |
| 189 rtc::scoped_ptr<MediaStreamHandlerContainer> stream_handler_container_; | |
| 190 rtc::scoped_ptr<StatsCollector> stats_; | 200 rtc::scoped_ptr<StatsCollector> stats_; |
| 201 |
| 202 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_; |
| 203 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_; |
| 191 }; | 204 }; |
| 192 | 205 |
| 193 } // namespace webrtc | 206 } // namespace webrtc |
| 194 | 207 |
| 195 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ | 208 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| OLD | NEW |