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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 bool SetRecvRtpHeaderExtensions( | 198 bool SetRecvRtpHeaderExtensions( |
199 const std::vector<RtpHeaderExtension>& extensions) { | 199 const std::vector<RtpHeaderExtension>& extensions) { |
200 recv_extensions_ = extensions; | 200 recv_extensions_ = extensions; |
201 return true; | 201 return true; |
202 } | 202 } |
203 bool SetSendRtpHeaderExtensions( | 203 bool SetSendRtpHeaderExtensions( |
204 const std::vector<RtpHeaderExtension>& extensions) { | 204 const std::vector<RtpHeaderExtension>& extensions) { |
205 send_extensions_ = extensions; | 205 send_extensions_ = extensions; |
206 return true; | 206 return true; |
207 } | 207 } |
208 virtual void OnPacketReceived(rtc::Buffer* packet, | 208 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
209 const rtc::PacketTime& packet_time) { | 209 const rtc::PacketTime& packet_time) { |
210 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 210 rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
211 } | 211 } |
212 virtual void OnRtcpReceived(rtc::Buffer* packet, | 212 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, |
213 const rtc::PacketTime& packet_time) { | 213 const rtc::PacketTime& packet_time) { |
214 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); | 214 rtcp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
215 } | 215 } |
216 virtual void OnReadyToSend(bool ready) { | 216 virtual void OnReadyToSend(bool ready) { |
217 ready_to_send_ = ready; | 217 ready_to_send_ = ready; |
218 } | 218 } |
219 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } | 219 bool fail_set_send_codecs() const { return fail_set_send_codecs_; } |
220 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } | 220 bool fail_set_recv_codecs() const { return fail_set_recv_codecs_; } |
221 | 221 |
222 private: | 222 private: |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 return false; | 602 return false; |
603 return true; | 603 return true; |
604 } | 604 } |
605 virtual bool RemoveRecvStream(uint32_t ssrc) { | 605 virtual bool RemoveRecvStream(uint32_t ssrc) { |
606 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) | 606 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) |
607 return false; | 607 return false; |
608 return true; | 608 return true; |
609 } | 609 } |
610 | 610 |
611 virtual bool SendData(const SendDataParams& params, | 611 virtual bool SendData(const SendDataParams& params, |
612 const rtc::Buffer& payload, | 612 const rtc::CopyOnWriteBuffer& payload, |
613 SendDataResult* result) { | 613 SendDataResult* result) { |
614 if (send_blocked_) { | 614 if (send_blocked_) { |
615 *result = SDR_BLOCK; | 615 *result = SDR_BLOCK; |
616 return false; | 616 return false; |
617 } else { | 617 } else { |
618 last_sent_data_params_ = params; | 618 last_sent_data_params_ = params; |
619 last_sent_data_ = std::string(payload.data<char>(), payload.size()); | 619 last_sent_data_ = std::string(payload.data<char>(), payload.size()); |
620 return true; | 620 return true; |
621 } | 621 } |
622 } | 622 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 | 892 |
893 private: | 893 private: |
894 std::vector<FakeDataMediaChannel*> channels_; | 894 std::vector<FakeDataMediaChannel*> channels_; |
895 std::vector<DataCodec> data_codecs_; | 895 std::vector<DataCodec> data_codecs_; |
896 DataChannelType last_channel_type_; | 896 DataChannelType last_channel_type_; |
897 }; | 897 }; |
898 | 898 |
899 } // namespace cricket | 899 } // namespace cricket |
900 | 900 |
901 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 901 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |