OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 // This file contains fake implementations, for use in unit tests, of the | 11 // This file contains fake implementations, for use in unit tests, of the |
12 // following classes: | 12 // following classes: |
13 // | 13 // |
14 // webrtc::Call | 14 // webrtc::Call |
15 // webrtc::AudioSendStream | 15 // webrtc::AudioSendStream |
16 // webrtc::AudioReceiveStream | 16 // webrtc::AudioReceiveStream |
17 // webrtc::VideoSendStream | 17 // webrtc::VideoSendStream |
18 // webrtc::VideoReceiveStream | 18 // webrtc::VideoReceiveStream |
19 | 19 |
20 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCCALL_H_ | 20 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCCALL_H_ |
21 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCCALL_H_ | 21 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCCALL_H_ |
22 | 22 |
23 #include <memory> | 23 #include <memory> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "webrtc/audio_receive_stream.h" | 26 #include "webrtc/audio_receive_stream.h" |
27 #include "webrtc/audio_send_stream.h" | 27 #include "webrtc/audio_send_stream.h" |
| 28 #include "webrtc/base/buffer.h" |
28 #include "webrtc/call.h" | 29 #include "webrtc/call.h" |
29 #include "webrtc/video_frame.h" | 30 #include "webrtc/video_frame.h" |
30 #include "webrtc/video_receive_stream.h" | 31 #include "webrtc/video_receive_stream.h" |
31 #include "webrtc/video_send_stream.h" | 32 #include "webrtc/video_send_stream.h" |
32 | 33 |
33 namespace cricket { | 34 namespace cricket { |
34 class FakeAudioSendStream final : public webrtc::AudioSendStream { | 35 class FakeAudioSendStream final : public webrtc::AudioSendStream { |
35 public: | 36 public: |
36 struct TelephoneEvent { | 37 struct TelephoneEvent { |
37 int payload_type = -1; | 38 int payload_type = -1; |
(...skipping 29 matching lines...) Expand all Loading... |
67 }; | 68 }; |
68 | 69 |
69 class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { | 70 class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { |
70 public: | 71 public: |
71 explicit FakeAudioReceiveStream( | 72 explicit FakeAudioReceiveStream( |
72 const webrtc::AudioReceiveStream::Config& config); | 73 const webrtc::AudioReceiveStream::Config& config); |
73 | 74 |
74 const webrtc::AudioReceiveStream::Config& GetConfig() const; | 75 const webrtc::AudioReceiveStream::Config& GetConfig() const; |
75 void SetStats(const webrtc::AudioReceiveStream::Stats& stats); | 76 void SetStats(const webrtc::AudioReceiveStream::Stats& stats); |
76 int received_packets() const { return received_packets_; } | 77 int received_packets() const { return received_packets_; } |
77 void IncrementReceivedPackets(); | 78 bool VerifyLastPacket(const uint8_t* data, size_t length) const; |
78 const webrtc::AudioSinkInterface* sink() const { return sink_.get(); } | 79 const webrtc::AudioSinkInterface* sink() const { return sink_.get(); } |
79 | 80 |
| 81 bool DeliverRtp(const uint8_t* packet, |
| 82 size_t length, |
| 83 const webrtc::PacketTime& packet_time) override; |
| 84 bool DeliverRtcp(const uint8_t* packet, size_t length) override; |
80 private: | 85 private: |
81 // webrtc::ReceiveStream implementation. | 86 // webrtc::ReceiveStream implementation. |
82 void Start() override {} | 87 void Start() override {} |
83 void Stop() override {} | 88 void Stop() override {} |
84 void SignalNetworkState(webrtc::NetworkState state) override {} | 89 void SignalNetworkState(webrtc::NetworkState state) override {} |
85 bool DeliverRtcp(const uint8_t* packet, size_t length) override { | |
86 return true; | |
87 } | |
88 bool DeliverRtp(const uint8_t* packet, | |
89 size_t length, | |
90 const webrtc::PacketTime& packet_time) override { | |
91 return true; | |
92 } | |
93 | 90 |
94 // webrtc::AudioReceiveStream implementation. | 91 // webrtc::AudioReceiveStream implementation. |
95 webrtc::AudioReceiveStream::Stats GetStats() const override; | 92 webrtc::AudioReceiveStream::Stats GetStats() const override; |
96 void SetSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) override; | 93 void SetSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) override; |
97 | 94 |
98 webrtc::AudioReceiveStream::Config config_; | 95 webrtc::AudioReceiveStream::Config config_; |
99 webrtc::AudioReceiveStream::Stats stats_; | 96 webrtc::AudioReceiveStream::Stats stats_; |
100 int received_packets_; | 97 int received_packets_; |
101 std::unique_ptr<webrtc::AudioSinkInterface> sink_; | 98 std::unique_ptr<webrtc::AudioSinkInterface> sink_; |
| 99 rtc::Buffer last_packet_; |
102 }; | 100 }; |
103 | 101 |
104 class FakeVideoSendStream final : public webrtc::VideoSendStream, | 102 class FakeVideoSendStream final : public webrtc::VideoSendStream, |
105 public webrtc::VideoCaptureInput { | 103 public webrtc::VideoCaptureInput { |
106 public: | 104 public: |
107 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, | 105 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, |
108 const webrtc::VideoEncoderConfig& encoder_config); | 106 const webrtc::VideoEncoderConfig& encoder_config); |
109 webrtc::VideoSendStream::Config GetConfig() const; | 107 webrtc::VideoSendStream::Config GetConfig() const; |
110 webrtc::VideoEncoderConfig GetEncoderConfig() const; | 108 webrtc::VideoEncoderConfig GetEncoderConfig() const; |
111 std::vector<webrtc::VideoStream> GetVideoStreams(); | 109 std::vector<webrtc::VideoStream> GetVideoStreams(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 std::vector<FakeAudioSendStream*> audio_send_streams_; | 252 std::vector<FakeAudioSendStream*> audio_send_streams_; |
255 std::vector<FakeVideoReceiveStream*> video_receive_streams_; | 253 std::vector<FakeVideoReceiveStream*> video_receive_streams_; |
256 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; | 254 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; |
257 | 255 |
258 int num_created_send_streams_; | 256 int num_created_send_streams_; |
259 int num_created_receive_streams_; | 257 int num_created_receive_streams_; |
260 }; | 258 }; |
261 | 259 |
262 } // namespace cricket | 260 } // namespace cricket |
263 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ | 261 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |
OLD | NEW |