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 |
11 #ifndef WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 11 #ifndef WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
12 #define WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 12 #define WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <set> | 17 #include <set> |
18 #include <string> | 18 #include <string> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "webrtc/audio_sink.h" | 21 #include "webrtc/audio_sink.h" |
22 #include "webrtc/base/buffer.h" | 22 #include "webrtc/base/copyonwritebuffer.h" |
23 #include "webrtc/base/stringutils.h" | 23 #include "webrtc/base/stringutils.h" |
24 #include "webrtc/media/base/audiosource.h" | 24 #include "webrtc/media/base/audiosource.h" |
25 #include "webrtc/media/base/mediaengine.h" | 25 #include "webrtc/media/base/mediaengine.h" |
26 #include "webrtc/media/base/rtputils.h" | 26 #include "webrtc/media/base/rtputils.h" |
27 #include "webrtc/media/base/streamparams.h" | 27 #include "webrtc/media/base/streamparams.h" |
28 #include "webrtc/p2p/base/sessiondescription.h" | 28 #include "webrtc/p2p/base/sessiondescription.h" |
29 | 29 |
30 namespace cricket { | 30 namespace cricket { |
31 | 31 |
32 class FakeMediaEngine; | 32 class FakeMediaEngine; |
(...skipping 18 matching lines...) Expand all Loading... |
51 } | 51 } |
52 bool sending() const { return sending_; } | 52 bool sending() const { return sending_; } |
53 bool playout() const { return playout_; } | 53 bool playout() const { return playout_; } |
54 const std::list<std::string>& rtp_packets() const { return rtp_packets_; } | 54 const std::list<std::string>& rtp_packets() const { return rtp_packets_; } |
55 const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; } | 55 const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; } |
56 | 56 |
57 bool SendRtp(const void* data, int len, const rtc::PacketOptions& options) { | 57 bool SendRtp(const void* data, int len, const rtc::PacketOptions& options) { |
58 if (!sending_) { | 58 if (!sending_) { |
59 return false; | 59 return false; |
60 } | 60 } |
61 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 61 rtc::CopyOnWriteBuffer packet(reinterpret_cast<const uint8_t*>(data), len, |
62 kMaxRtpPacketLen); | 62 kMaxRtpPacketLen); |
63 return Base::SendPacket(&packet, options); | 63 return Base::SendPacket(&packet, options); |
64 } | 64 } |
65 bool SendRtcp(const void* data, int len) { | 65 bool SendRtcp(const void* data, int len) { |
66 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 66 rtc::CopyOnWriteBuffer packet(reinterpret_cast<const uint8_t*>(data), len, |
67 kMaxRtpPacketLen); | 67 kMaxRtpPacketLen); |
68 return Base::SendRtcp(&packet, rtc::PacketOptions()); | 68 return Base::SendRtcp(&packet, rtc::PacketOptions()); |
69 } | 69 } |
70 | 70 |
71 bool CheckRtp(const void* data, int len) { | 71 bool CheckRtp(const void* data, int len) { |
72 bool success = !rtp_packets_.empty(); | 72 bool success = !rtp_packets_.empty(); |
73 if (success) { | 73 if (success) { |
74 std::string packet = rtp_packets_.front(); | 74 std::string packet = rtp_packets_.front(); |
75 rtp_packets_.pop_front(); | 75 rtp_packets_.pop_front(); |
76 success = (packet == std::string(static_cast<const char*>(data), len)); | 76 success = (packet == std::string(static_cast<const char*>(data), len)); |
77 } | 77 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 bool SetRecvRtpHeaderExtensions( | 173 bool SetRecvRtpHeaderExtensions( |
174 const std::vector<RtpHeaderExtension>& extensions) { | 174 const std::vector<RtpHeaderExtension>& extensions) { |
175 recv_extensions_ = extensions; | 175 recv_extensions_ = extensions; |
176 return true; | 176 return true; |
177 } | 177 } |
178 bool SetSendRtpHeaderExtensions( | 178 bool SetSendRtpHeaderExtensions( |
179 const std::vector<RtpHeaderExtension>& extensions) { | 179 const std::vector<RtpHeaderExtension>& extensions) { |
180 send_extensions_ = extensions; | 180 send_extensions_ = extensions; |
181 return true; | 181 return true; |
182 } | 182 } |
183 virtual void OnPacketReceived(rtc::Buffer* packet, | 183 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
184 const rtc::PacketTime& packet_time) { | 184 const rtc::PacketTime& packet_time) { |
185 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 185 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
186 } | 186 } |
187 virtual void OnRtcpReceived(rtc::Buffer* packet, | 187 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, |
188 const rtc::PacketTime& packet_time) { | 188 const rtc::PacketTime& packet_time) { |
189 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 189 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
190 } | 190 } |
191 virtual void OnReadyToSend(bool ready) { | 191 virtual void OnReadyToSend(bool ready) { |
192 ready_to_send_ = ready; | 192 ready_to_send_ = ready; |
193 } | 193 } |
194 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } | 194 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } |
195 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } | 195 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } |
196 | 196 |
197 private: | 197 private: |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 return false; | 570 return false; |
571 return true; | 571 return true; |
572 } | 572 } |
573 virtual bool RemoveRecvStream(uint32_t ssrc) { | 573 virtual bool RemoveRecvStream(uint32_t ssrc) { |
574 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) | 574 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) |
575 return false; | 575 return false; |
576 return true; | 576 return true; |
577 } | 577 } |
578 | 578 |
579 virtual bool SendData(const SendDataParams& params, | 579 virtual bool SendData(const SendDataParams& params, |
580 const rtc::Buffer& payload, | 580 const rtc::CopyOnWriteBuffer& payload, |
581 SendDataResult* result) { | 581 SendDataResult* result) { |
582 if (send_blocked_) { | 582 if (send_blocked_) { |
583 *result = SDR_BLOCK; | 583 *result = SDR_BLOCK; |
584 return false; | 584 return false; |
585 } else { | 585 } else { |
586 last_sent_data_params_ = params; | 586 last_sent_data_params_ = params; |
587 last_sent_data_ = std::string(payload.data<char>(), payload.size()); | 587 last_sent_data_ = std::string(payload.data<char>(), payload.size()); |
588 return true; | 588 return true; |
589 } | 589 } |
590 } | 590 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 866 |
867 private: | 867 private: |
868 std::vector<FakeDataMediaChannel*> channels_; | 868 std::vector<FakeDataMediaChannel*> channels_; |
869 std::vector<DataCodec> data_codecs_; | 869 std::vector<DataCodec> data_codecs_; |
870 DataChannelType last_channel_type_; | 870 DataChannelType last_channel_type_; |
871 }; | 871 }; |
872 | 872 |
873 } // namespace cricket | 873 } // namespace cricket |
874 | 874 |
875 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 875 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |