Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: talk/app/webrtc/peerconnection.h

Issue 1351803002: Exposing RtpSenders and RtpReceivers from PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing indentation. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 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 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
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 #include <utility> // for std::pair
32 33
33 #include "talk/app/webrtc/dtlsidentitystore.h" 34 #include "talk/app/webrtc/dtlsidentitystore.h"
34 #include "talk/app/webrtc/mediastreamsignaling.h" 35 #include "talk/app/webrtc/mediastreamsignaling.h"
35 #include "talk/app/webrtc/peerconnectionfactory.h" 36 #include "talk/app/webrtc/peerconnectionfactory.h"
36 #include "talk/app/webrtc/peerconnectioninterface.h" 37 #include "talk/app/webrtc/peerconnectioninterface.h"
38 #include "talk/app/webrtc/rtpreceiver.h"
39 #include "talk/app/webrtc/rtpsender.h"
37 #include "talk/app/webrtc/statscollector.h" 40 #include "talk/app/webrtc/statscollector.h"
38 #include "talk/app/webrtc/streamcollection.h" 41 #include "talk/app/webrtc/streamcollection.h"
39 #include "talk/app/webrtc/webrtcsession.h" 42 #include "talk/app/webrtc/webrtcsession.h"
40 #include "webrtc/base/scoped_ptr.h" 43 #include "webrtc/base/scoped_ptr.h"
41 44
42 namespace webrtc { 45 namespace webrtc {
43 class MediaStreamHandlerContainer;
44 46
45 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> 47 typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration>
46 StunConfigurations; 48 StunConfigurations;
47 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> 49 typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration>
48 TurnConfigurations; 50 TurnConfigurations;
49 51
50 // PeerConnectionImpl implements the PeerConnection interface. 52 // PeerConnection implements the PeerConnectionInterface interface.
51 // It uses MediaStreamSignaling and WebRtcSession to implement 53 // It uses MediaStreamSignaling and WebRtcSession to implement
52 // the PeerConnection functionality. 54 // the PeerConnection functionality.
53 class PeerConnection : public PeerConnectionInterface, 55 class PeerConnection : public PeerConnectionInterface,
54 public MediaStreamSignalingObserver, 56 public MediaStreamSignalingObserver,
55 public IceObserver, 57 public IceObserver,
56 public rtc::MessageHandler, 58 public rtc::MessageHandler,
57 public sigslot::has_slots<> { 59 public sigslot::has_slots<> {
58 public: 60 public:
59 explicit PeerConnection(PeerConnectionFactory* factory); 61 explicit PeerConnection(PeerConnectionFactory* factory);
60 62
61 bool Initialize( 63 bool Initialize(
62 const PeerConnectionInterface::RTCConfiguration& configuration, 64 const PeerConnectionInterface::RTCConfiguration& configuration,
63 const MediaConstraintsInterface* constraints, 65 const MediaConstraintsInterface* constraints,
64 PortAllocatorFactoryInterface* allocator_factory, 66 PortAllocatorFactoryInterface* allocator_factory,
65 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 67 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
66 PeerConnectionObserver* observer); 68 PeerConnectionObserver* observer);
67 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams(); 69 virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams();
68 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams(); 70 virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams();
69 virtual bool AddStream(MediaStreamInterface* local_stream); 71 virtual bool AddStream(MediaStreamInterface* local_stream);
70 virtual void RemoveStream(MediaStreamInterface* local_stream); 72 virtual void RemoveStream(MediaStreamInterface* local_stream);
71 73
72 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( 74 virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
73 AudioTrackInterface* track); 75 AudioTrackInterface* track);
74 76
77 RtpSenderRefptrs GetSenders() const override;
78 RtpReceiverRefptrs GetReceivers() const override;
79
75 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( 80 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
76 const std::string& label, 81 const std::string& label,
77 const DataChannelInit* config); 82 const DataChannelInit* config);
78 virtual bool GetStats(StatsObserver* observer, 83 virtual bool GetStats(StatsObserver* observer,
79 webrtc::MediaStreamTrackInterface* track, 84 webrtc::MediaStreamTrackInterface* track,
80 StatsOutputLevel level); 85 StatsOutputLevel level);
81 86
82 virtual SignalingState signaling_state(); 87 virtual SignalingState signaling_state();
83 88
84 // TODO(bemasc): Remove ice_state() when callers are removed. 89 // TODO(bemasc): Remove ice_state() when callers are removed.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return factory_->signaling_thread(); 166 return factory_->signaling_thread();
162 } 167 }
163 168
164 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, 169 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
165 const std::string& error); 170 const std::string& error);
166 171
167 bool IsClosed() const { 172 bool IsClosed() const {
168 return signaling_state_ == PeerConnectionInterface::kClosed; 173 return signaling_state_ == PeerConnectionInterface::kClosed;
169 } 174 }
170 175
176 typedef std::pair<rtc::scoped_refptr<BaseRtpSender>,
177 rtc::scoped_refptr<RtpSenderInterface>> RtpSenderPair;
178 typedef std::pair<rtc::scoped_refptr<BaseRtpReceiver>,
179 rtc::scoped_refptr<RtpReceiverInterface>> RtpReceiverPair;
pthatcher1 2015/09/23 14:47:39 This seems a bit too complicated. Can we just mov
180 typedef std::vector<RtpSenderPair> RtpSenderPairList;
181 typedef std::vector<RtpReceiverPair> RtpReceiverPairList;
182
183 void AddRtpSender(BaseRtpSender* sender);
184 void AddRtpReceiver(BaseRtpReceiver* receiver);
185
186 RtpSenderPairList::iterator FindRtpSenderPairForTrack(
187 MediaStreamTrackInterface* track);
188 RtpReceiverPairList::iterator FindRtpReceiverPairForTrack(
189 MediaStreamTrackInterface* track);
190
171 // Storing the factory as a scoped reference pointer ensures that the memory 191 // Storing the factory as a scoped reference pointer ensures that the memory
172 // in the PeerConnectionFactoryImpl remains available as long as the 192 // in the PeerConnectionFactoryImpl remains available as long as the
173 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. 193 // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
174 // However, since the reference counting is done in the 194 // However, since the reference counting is done in the
175 // PeerConnectionFactoryInteface all instances created using the raw pointer 195 // PeerConnectionFactoryInteface all instances created using the raw pointer
176 // will refer to the same reference count. 196 // will refer to the same reference count.
177 rtc::scoped_refptr<PeerConnectionFactory> factory_; 197 rtc::scoped_refptr<PeerConnectionFactory> factory_;
178 PeerConnectionObserver* observer_; 198 PeerConnectionObserver* observer_;
179 UMAObserver* uma_observer_; 199 UMAObserver* uma_observer_;
180 SignalingState signaling_state_; 200 SignalingState signaling_state_;
181 // TODO(bemasc): Remove ice_state_. 201 // TODO(bemasc): Remove ice_state_.
182 IceState ice_state_; 202 IceState ice_state_;
183 IceConnectionState ice_connection_state_; 203 IceConnectionState ice_connection_state_;
184 IceGatheringState ice_gathering_state_; 204 IceGatheringState ice_gathering_state_;
185 205
186 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; 206 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_;
187 rtc::scoped_ptr<WebRtcSession> session_; 207 rtc::scoped_ptr<WebRtcSession> session_;
188 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_; 208 rtc::scoped_ptr<MediaStreamSignaling> mediastream_signaling_;
189 rtc::scoped_ptr<MediaStreamHandlerContainer> stream_handler_container_;
190 rtc::scoped_ptr<StatsCollector> stats_; 209 rtc::scoped_ptr<StatsCollector> stats_;
210
211 // Store pairs of base pointers and pointers to proxy objects, so that when
212 // GetSenders/GetReceivers is called, we can return the same proxy objects
213 // each time.
214 RtpSenderPairList rtp_sender_pairs_;
215 RtpReceiverPairList rtp_receiver_pairs_;
pthatcher1 2015/09/23 14:47:39 ***
pthatcher1 2015/09/23 14:59:09 This was a not to myself to come back and say "Why
191 }; 216 };
192 217
193 } // namespace webrtc 218 } // namespace webrtc
194 219
195 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ 220 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698