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 22 matching lines...) Expand all Loading... |
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/statscollector.h" | 37 #include "talk/app/webrtc/statscollector.h" |
38 #include "talk/app/webrtc/streamcollection.h" | 38 #include "talk/app/webrtc/streamcollection.h" |
39 #include "talk/app/webrtc/webrtcsession.h" | 39 #include "talk/app/webrtc/webrtcsession.h" |
40 #include "webrtc/base/scoped_ptr.h" | 40 #include "webrtc/base/scoped_ptr.h" |
41 | 41 |
42 namespace webrtc { | 42 namespace webrtc { |
43 class MediaStreamHandlerContainer; | |
44 | 43 |
45 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> | 44 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> |
46 StunConfigurations; | 45 StunConfigurations; |
47 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> | 46 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> |
48 TurnConfigurations; | 47 TurnConfigurations; |
49 | 48 |
50 // PeerConnectionImpl implements the PeerConnection interface. | 49 // PeerConnectionImpl implements the PeerConnection interface. |
51 // It uses MediaStreamSignaling and WebRtcSession to implement | 50 // It uses MediaStreamSignaling and WebRtcSession to implement |
52 // the PeerConnection functionality. | 51 // the PeerConnection functionality. |
53 class PeerConnection : public PeerConnectionInterface, | 52 class PeerConnection : public PeerConnectionInterface, |
(...skipping 11 matching lines...) Expand all Loading... |
65 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 64 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
66 PeerConnectionObserver* observer); | 65 PeerConnectionObserver* observer); |
67 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); | 66 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); |
68 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); | 67 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); |
69 virtual bool AddStream(MediaStreamInterface* local_stream); | 68 virtual bool AddStream(MediaStreamInterface* local_stream); |
70 virtual void RemoveStream(MediaStreamInterface* local_stream); | 69 virtual void RemoveStream(MediaStreamInterface* local_stream); |
71 | 70 |
72 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( | 71 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( |
73 AudioTrackInterface* track); | 72 AudioTrackInterface* track); |
74 | 73 |
| 74 PeerConnectionInterface::RtpSenders GetSenders() override { |
| 75 return rtp_senders_; |
| 76 } |
| 77 |
| 78 PeerConnectionInterface::RtpReceivers GetReceivers() override { |
| 79 return rtp_receivers_; |
| 80 } |
| 81 |
75 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( | 82 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
76 const std::string& label, | 83 const std::string& label, |
77 const DataChannelInit* config); | 84 const DataChannelInit* config); |
78 virtual bool GetStats(StatsObserver* observer, | 85 virtual bool GetStats(StatsObserver* observer, |
79 webrtc::MediaStreamTrackInterface* track, | 86 webrtc::MediaStreamTrackInterface* track, |
80 StatsOutputLevel level); | 87 StatsOutputLevel level); |
81 | 88 |
82 virtual SignalingState signaling_state(); | 89 virtual SignalingState signaling_state(); |
83 | 90 |
84 // TODO(bemasc): Remove ice_state() when callers are removed. | 91 // TODO(bemasc): Remove ice_state() when callers are removed. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 private: | 124 private: |
118 // Implements MessageHandler. | 125 // Implements MessageHandler. |
119 virtual void OnMessage(rtc::Message* msg); | 126 virtual void OnMessage(rtc::Message* msg); |
120 | 127 |
121 // Implements MediaStreamSignalingObserver. | 128 // Implements MediaStreamSignalingObserver. |
122 void OnAddRemoteStream(MediaStreamInterface* stream) override; | 129 void OnAddRemoteStream(MediaStreamInterface* stream) override; |
123 void OnRemoveRemoteStream(MediaStreamInterface* stream) override; | 130 void OnRemoveRemoteStream(MediaStreamInterface* stream) override; |
124 void OnAddDataChannel(DataChannelInterface* data_channel) override; | 131 void OnAddDataChannel(DataChannelInterface* data_channel) override; |
125 void OnAddRemoteAudioTrack(MediaStreamInterface* stream, | 132 void OnAddRemoteAudioTrack(MediaStreamInterface* stream, |
126 AudioTrackInterface* audio_track, | 133 AudioTrackInterface* audio_track, |
127 uint32 ssrc) override; | 134 uint32 ssrc, |
| 135 const std::string& mid) override; |
128 void OnAddRemoteVideoTrack(MediaStreamInterface* stream, | 136 void OnAddRemoteVideoTrack(MediaStreamInterface* stream, |
129 VideoTrackInterface* video_track, | 137 VideoTrackInterface* video_track, |
130 uint32 ssrc) override; | 138 uint32 ssrc, |
| 139 const std::string& mid) override; |
131 void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, | 140 void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, |
132 AudioTrackInterface* audio_track) override; | 141 AudioTrackInterface* audio_track) override; |
133 void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, | 142 void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, |
134 VideoTrackInterface* video_track) override; | 143 VideoTrackInterface* video_track) override; |
135 void OnAddLocalAudioTrack(MediaStreamInterface* stream, | 144 void OnAddLocalAudioTrack(MediaStreamInterface* stream, |
136 AudioTrackInterface* audio_track, | 145 AudioTrackInterface* audio_track, |
137 uint32 ssrc) override; | 146 uint32 ssrc, |
| 147 const std::string& mid) override; |
138 void OnAddLocalVideoTrack(MediaStreamInterface* stream, | 148 void OnAddLocalVideoTrack(MediaStreamInterface* stream, |
139 VideoTrackInterface* video_track, | 149 VideoTrackInterface* video_track, |
140 uint32 ssrc) override; | 150 uint32 ssrc, |
| 151 const std::string& mid) override; |
141 void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, | 152 void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, |
142 AudioTrackInterface* audio_track, | 153 AudioTrackInterface* audio_track, |
143 uint32 ssrc) override; | 154 uint32 ssrc) override; |
144 void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, | 155 void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, |
145 VideoTrackInterface* video_track) override; | 156 VideoTrackInterface* video_track) override; |
146 void OnRemoveLocalStream(MediaStreamInterface* stream) override; | 157 void OnRemoveLocalStream(MediaStreamInterface* stream) override; |
147 | 158 |
148 // Implements IceObserver | 159 // Implements IceObserver |
149 void OnIceConnectionChange(IceConnectionState new_state) override; | 160 void OnIceConnectionChange(IceConnectionState new_state) override; |
150 void OnIceGatheringChange(IceGatheringState new_state) override; | 161 void OnIceGatheringChange(IceGatheringState new_state) override; |
(...skipping 10 matching lines...) Expand all Loading... |
161 return factory_->signaling_thread(); | 172 return factory_->signaling_thread(); |
162 } | 173 } |
163 | 174 |
164 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, | 175 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
165 const std::string& error); | 176 const std::string& error); |
166 | 177 |
167 bool IsClosed() const { | 178 bool IsClosed() const { |
168 return signaling_state_ == PeerConnectionInterface::kClosed; | 179 return signaling_state_ == PeerConnectionInterface::kClosed; |
169 } | 180 } |
170 | 181 |
| 182 PeerConnectionInterface::RtpSenders::iterator FindRtpSenderForTrack( |
| 183 MediaStreamTrackInterface* track); |
| 184 PeerConnectionInterface::RtpReceivers::iterator FindRtpReceiverForTrack( |
| 185 MediaStreamTrackInterface* track); |
| 186 |
171 // Storing the factory as a scoped reference pointer ensures that the memory | 187 // Storing the factory as a scoped reference pointer ensures that the memory |
172 // in the PeerConnectionFactoryImpl remains available as long as the | 188 // in the PeerConnectionFactoryImpl remains available as long as the |
173 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. | 189 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. |
174 // However, since the reference counting is done in the | 190 // However, since the reference counting is done in the |
175 // PeerConnectionFactoryInteface all instances created using the raw pointer | 191 // PeerConnectionFactoryInteface all instances created using the raw pointer |
176 // will refer to the same reference count. | 192 // will refer to the same reference count. |
177 rtc::scoped_refptr<PeerConnectionFactory> factory_; | 193 rtc::scoped_refptr<PeerConnectionFactory> factory_; |
178 PeerConnectionObserver* observer_; | 194 PeerConnectionObserver* observer_; |
179 UMAObserver* uma_observer_; | 195 UMAObserver* uma_observer_; |
180 SignalingState signaling_state_; | 196 SignalingState signaling_state_; |
181 // TODO(bemasc): Remove ice_state_. | 197 // TODO(bemasc): Remove ice_state_. |
182 IceState ice_state_; | 198 IceState ice_state_; |
183 IceConnectionState ice_connection_state_; | 199 IceConnectionState ice_connection_state_; |
184 IceGatheringState ice_gathering_state_; | 200 IceGatheringState ice_gathering_state_; |
185 | 201 |
186 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; | 202 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; |
187 rtc::scoped_ptr<WebRtcSession> session_; | 203 rtc::scoped_ptr<WebRtcSession> session_; |
188 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; | 204 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; |
189 rtc::scoped_ptr<MediaStreamHandlerContainer> stream_handler_container_; | |
190 rtc::scoped_ptr<StatsCollector> stats_; | 205 rtc::scoped_ptr<StatsCollector> stats_; |
| 206 |
| 207 PeerConnectionInterface::RtpSenders rtp_senders_; |
| 208 PeerConnectionInterface::RtpReceivers rtp_receivers_; |
191 }; | 209 }; |
192 | 210 |
193 } // namespace webrtc | 211 } // namespace webrtc |
194 | 212 |
195 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ | 213 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ |
OLD | NEW |