OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/audio_sink.h" | 21 #include "webrtc/audio_sink.h" |
22 #include "webrtc/base/copyonwritebuffer.h" | 22 #include "webrtc/base/copyonwritebuffer.h" |
23 #include "webrtc/base/networkroute.h" | 23 #include "webrtc/base/networkroute.h" |
24 #include "webrtc/base/stringutils.h" | 24 #include "webrtc/base/stringutils.h" |
25 #include "webrtc/media/base/audiosource.h" | 25 #include "webrtc/media/base/audiosource.h" |
26 #include "webrtc/media/base/mediaengine.h" | 26 #include "webrtc/media/base/mediaengine.h" |
27 #include "webrtc/media/base/rtputils.h" | 27 #include "webrtc/media/base/rtputils.h" |
28 #include "webrtc/media/base/streamparams.h" | 28 #include "webrtc/media/base/streamparams.h" |
29 #include "webrtc/p2p/base/sessiondescription.h" | 29 #include "webrtc/p2p/base/sessiondescription.h" |
30 | 30 |
| 31 using webrtc::RtpExtension; |
| 32 |
31 namespace cricket { | 33 namespace cricket { |
32 | 34 |
33 class FakeMediaEngine; | 35 class FakeMediaEngine; |
34 class FakeVideoEngine; | 36 class FakeVideoEngine; |
35 class FakeVoiceEngine; | 37 class FakeVoiceEngine; |
36 | 38 |
37 // A common helper class that handles sending and receiving RTP/RTCP packets. | 39 // A common helper class that handles sending and receiving RTP/RTCP packets. |
38 template <class Base> class RtpHelper : public Base { | 40 template <class Base> class RtpHelper : public Base { |
39 public: | 41 public: |
40 RtpHelper() | 42 RtpHelper() |
41 : sending_(false), | 43 : sending_(false), |
42 playout_(false), | 44 playout_(false), |
43 fail_set_send_codecs_(false), | 45 fail_set_send_codecs_(false), |
44 fail_set_recv_codecs_(false), | 46 fail_set_recv_codecs_(false), |
45 send_ssrc_(0), | 47 send_ssrc_(0), |
46 ready_to_send_(false) {} | 48 ready_to_send_(false) {} |
47 const std::vector<RtpHeaderExtension>& recv_extensions() { | 49 const std::vector<RtpExtension>& recv_extensions() { |
48 return recv_extensions_; | 50 return recv_extensions_; |
49 } | 51 } |
50 const std::vector<RtpHeaderExtension>& send_extensions() { | 52 const std::vector<RtpExtension>& send_extensions() { |
51 return send_extensions_; | 53 return send_extensions_; |
52 } | 54 } |
53 bool sending() const { return sending_; } | 55 bool sending() const { return sending_; } |
54 bool playout() const { return playout_; } | 56 bool playout() const { return playout_; } |
55 const std::list<std::string>& rtp_packets() const { return rtp_packets_; } | 57 const std::list<std::string>& rtp_packets() const { return rtp_packets_; } |
56 const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; } | 58 const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; } |
57 | 59 |
58 bool SendRtp(const void* data, | 60 bool SendRtp(const void* data, |
59 size_t len, | 61 size_t len, |
60 const rtc::PacketOptions& options) { | 62 const rtc::PacketOptions& options) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } else { | 226 } else { |
225 muted_streams_.erase(ssrc); | 227 muted_streams_.erase(ssrc); |
226 } | 228 } |
227 return true; | 229 return true; |
228 } | 230 } |
229 bool set_sending(bool send) { | 231 bool set_sending(bool send) { |
230 sending_ = send; | 232 sending_ = send; |
231 return true; | 233 return true; |
232 } | 234 } |
233 void set_playout(bool playout) { playout_ = playout; } | 235 void set_playout(bool playout) { playout_ = playout; } |
234 bool SetRecvRtpHeaderExtensions( | 236 bool SetRecvRtpHeaderExtensions(const std::vector<RtpExtension>& extensions) { |
235 const std::vector<RtpHeaderExtension>& extensions) { | |
236 recv_extensions_ = extensions; | 237 recv_extensions_ = extensions; |
237 return true; | 238 return true; |
238 } | 239 } |
239 bool SetSendRtpHeaderExtensions( | 240 bool SetSendRtpHeaderExtensions(const std::vector<RtpExtension>& extensions) { |
240 const std::vector<RtpHeaderExtension>& extensions) { | |
241 send_extensions_ = extensions; | 241 send_extensions_ = extensions; |
242 return true; | 242 return true; |
243 } | 243 } |
244 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, | 244 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
245 const rtc::PacketTime& packet_time) { | 245 const rtc::PacketTime& packet_time) { |
246 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 246 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
247 } | 247 } |
248 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, | 248 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, |
249 const rtc::PacketTime& packet_time) { | 249 const rtc::PacketTime& packet_time) { |
250 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 250 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
251 } | 251 } |
252 virtual void OnReadyToSend(bool ready) { | 252 virtual void OnReadyToSend(bool ready) { |
253 ready_to_send_ = ready; | 253 ready_to_send_ = ready; |
254 } | 254 } |
255 virtual void OnNetworkRouteChanged(const std::string& transport_name, | 255 virtual void OnNetworkRouteChanged(const std::string& transport_name, |
256 const rtc::NetworkRoute& network_route) { | 256 const rtc::NetworkRoute& network_route) { |
257 last_network_route_ = network_route; | 257 last_network_route_ = network_route; |
258 ++num_network_route_changes_; | 258 ++num_network_route_changes_; |
259 } | 259 } |
260 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } | 260 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } |
261 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } | 261 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } |
262 | 262 |
263 private: | 263 private: |
264 bool sending_; | 264 bool sending_; |
265 bool playout_; | 265 bool playout_; |
266 std::vector<RtpHeaderExtension> recv_extensions_; | 266 std::vector<RtpExtension> recv_extensions_; |
267 std::vector<RtpHeaderExtension> send_extensions_; | 267 std::vector<RtpExtension> send_extensions_; |
268 std::list<std::string> rtp_packets_; | 268 std::list<std::string> rtp_packets_; |
269 std::list<std::string> rtcp_packets_; | 269 std::list<std::string> rtcp_packets_; |
270 std::vector<StreamParams> send_streams_; | 270 std::vector<StreamParams> send_streams_; |
271 std::vector<StreamParams> receive_streams_; | 271 std::vector<StreamParams> receive_streams_; |
272 std::set<uint32_t> muted_streams_; | 272 std::set<uint32_t> muted_streams_; |
273 std::map<uint32_t, webrtc::RtpParameters> rtp_send_parameters_; | 273 std::map<uint32_t, webrtc::RtpParameters> rtp_send_parameters_; |
274 std::map<uint32_t, webrtc::RtpParameters> rtp_receive_parameters_; | 274 std::map<uint32_t, webrtc::RtpParameters> rtp_receive_parameters_; |
275 bool fail_set_send_codecs_; | 275 bool fail_set_send_codecs_; |
276 bool fail_set_recv_codecs_; | 276 bool fail_set_recv_codecs_; |
277 uint32_t send_ssrc_; | 277 uint32_t send_ssrc_; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 // A base class for all of the shared parts between FakeVoiceEngine | 705 // A base class for all of the shared parts between FakeVoiceEngine |
706 // and FakeVideoEngine. | 706 // and FakeVideoEngine. |
707 class FakeBaseEngine { | 707 class FakeBaseEngine { |
708 public: | 708 public: |
709 FakeBaseEngine() | 709 FakeBaseEngine() |
710 : options_changed_(false), | 710 : options_changed_(false), |
711 fail_create_channel_(false) {} | 711 fail_create_channel_(false) {} |
712 void set_fail_create_channel(bool fail) { fail_create_channel_ = fail; } | 712 void set_fail_create_channel(bool fail) { fail_create_channel_ = fail; } |
713 | 713 |
714 RtpCapabilities GetCapabilities() const { return capabilities_; } | 714 RtpCapabilities GetCapabilities() const { return capabilities_; } |
715 void set_rtp_header_extensions( | 715 void set_rtp_header_extensions(const std::vector<RtpExtension>& extensions) { |
716 const std::vector<RtpHeaderExtension>& extensions) { | |
717 capabilities_.header_extensions = extensions; | 716 capabilities_.header_extensions = extensions; |
718 } | 717 } |
719 | 718 |
720 protected: | 719 protected: |
721 // Flag used by optionsmessagehandler_unittest for checking whether any | 720 // Flag used by optionsmessagehandler_unittest for checking whether any |
722 // relevant setting has been updated. | 721 // relevant setting has been updated. |
723 // TODO(thaloun): Replace with explicit checks of before & after values. | 722 // TODO(thaloun): Replace with explicit checks of before & after values. |
724 bool options_changed_; | 723 bool options_changed_; |
725 bool fail_create_channel_; | 724 bool fail_create_channel_; |
726 RtpCapabilities capabilities_; | 725 RtpCapabilities capabilities_; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 virtual ~FakeMediaEngine() {} | 846 virtual ~FakeMediaEngine() {} |
848 | 847 |
849 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { | 848 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { |
850 voice_.SetCodecs(codecs); | 849 voice_.SetCodecs(codecs); |
851 } | 850 } |
852 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { | 851 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { |
853 video_.SetCodecs(codecs); | 852 video_.SetCodecs(codecs); |
854 } | 853 } |
855 | 854 |
856 void SetAudioRtpHeaderExtensions( | 855 void SetAudioRtpHeaderExtensions( |
857 const std::vector<RtpHeaderExtension>& extensions) { | 856 const std::vector<RtpExtension>& extensions) { |
858 voice_.set_rtp_header_extensions(extensions); | 857 voice_.set_rtp_header_extensions(extensions); |
859 } | 858 } |
860 void SetVideoRtpHeaderExtensions( | 859 void SetVideoRtpHeaderExtensions( |
861 const std::vector<RtpHeaderExtension>& extensions) { | 860 const std::vector<RtpExtension>& extensions) { |
862 video_.set_rtp_header_extensions(extensions); | 861 video_.set_rtp_header_extensions(extensions); |
863 } | 862 } |
864 | 863 |
865 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { | 864 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { |
866 return voice_.GetChannel(index); | 865 return voice_.GetChannel(index); |
867 } | 866 } |
868 FakeVideoMediaChannel* GetVideoChannel(size_t index) { | 867 FakeVideoMediaChannel* GetVideoChannel(size_t index) { |
869 return video_.GetChannel(index); | 868 return video_.GetChannel(index); |
870 } | 869 } |
871 | 870 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 938 |
940 private: | 939 private: |
941 std::vector<FakeDataMediaChannel*> channels_; | 940 std::vector<FakeDataMediaChannel*> channels_; |
942 std::vector<DataCodec> data_codecs_; | 941 std::vector<DataCodec> data_codecs_; |
943 DataChannelType last_channel_type_; | 942 DataChannelType last_channel_type_; |
944 }; | 943 }; |
945 | 944 |
946 } // namespace cricket | 945 } // namespace cricket |
947 | 946 |
948 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 947 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |