3 * Copyright 2014 Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
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
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_
29 #define TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_
34 #include "webrtc/call.h"
35 #include "webrtc/video_receive_stream.h"
36 #include "webrtc/video_send_stream.h"
39 class FakeVideoSendStream : public webrtc::VideoSendStream {
41 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config,
42 const std::vector<webrtc::VideoStream>& video_streams,
43 const void* encoder_settings);
44 webrtc::VideoSendStream::Config GetConfig();
45 std::vector<webrtc::VideoStream> GetVideoStreams();
47 bool IsSending() const;
48 bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const;
51 virtual webrtc::VideoSendStream::Stats GetStats() const OVERRIDE;
53 virtual bool ReconfigureVideoEncoder(
54 const std::vector<webrtc::VideoStream>& streams,
55 const void* encoder_specific);
57 virtual webrtc::VideoSendStreamInput* Input() OVERRIDE;
59 virtual void Start() OVERRIDE;
60 virtual void Stop() OVERRIDE;
63 webrtc::VideoSendStream::Config config_;
64 std::vector<webrtc::VideoStream> video_streams_;
65 bool codec_settings_set_;
66 webrtc::VideoCodecVP8 vp8_settings_;
69 class FakeVideoReceiveStream : public webrtc::VideoReceiveStream {
71 explicit FakeVideoReceiveStream(
72 const webrtc::VideoReceiveStream::Config& config);
74 webrtc::VideoReceiveStream::Config GetConfig();
76 bool IsReceiving() const;
79 virtual webrtc::VideoReceiveStream::Stats GetStats() const OVERRIDE;
81 virtual void Start() OVERRIDE;
82 virtual void Stop() OVERRIDE;
83 virtual void GetCurrentReceiveCodec(webrtc::VideoCodec* codec);
85 webrtc::VideoReceiveStream::Config config_;
89 class FakeCall : public webrtc::Call {
94 void SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs);
96 std::vector<FakeVideoSendStream*> GetVideoSendStreams();
97 std::vector<FakeVideoReceiveStream*> GetVideoReceiveStreams();
99 webrtc::VideoCodec GetEmptyVideoCodec();
101 webrtc::VideoCodec GetVideoCodecVp8();
102 webrtc::VideoCodec GetVideoCodecVp9();
104 std::vector<webrtc::VideoCodec> GetDefaultVideoCodecs();
107 virtual webrtc::VideoSendStream* CreateVideoSendStream(
108 const webrtc::VideoSendStream::Config& config,
109 const std::vector<webrtc::VideoStream>& video_streams,
110 const void* encoder_settings) OVERRIDE;
112 virtual void DestroyVideoSendStream(
113 webrtc::VideoSendStream* send_stream) OVERRIDE;
115 virtual webrtc::VideoReceiveStream* CreateVideoReceiveStream(
116 const webrtc::VideoReceiveStream::Config& config) OVERRIDE;
118 virtual void DestroyVideoReceiveStream(
119 webrtc::VideoReceiveStream* receive_stream) OVERRIDE;
120 virtual webrtc::PacketReceiver* Receiver() OVERRIDE;
122 virtual uint32_t SendBitrateEstimate() OVERRIDE;
123 virtual uint32_t ReceiveBitrateEstimate() OVERRIDE;
125 std::vector<webrtc::VideoCodec> codecs_;
126 std::vector<FakeVideoSendStream*> video_send_streams_;
127 std::vector<FakeVideoReceiveStream*> video_receive_streams_;
130 class FakeWebRtcVideoChannel2 : public WebRtcVideoChannel2 {
132 FakeWebRtcVideoChannel2(FakeCall* call,
133 WebRtcVideoEngine2* engine,
134 VoiceMediaChannel* voice_channel);
135 virtual ~FakeWebRtcVideoChannel2();
137 VoiceMediaChannel* GetVoiceChannel();
138 FakeCall* GetFakeCall();
141 FakeCall* fake_call_;
142 VoiceMediaChannel* voice_channel_;
145 class FakeWebRtcVideoMediaChannelFactory : public WebRtcVideoChannelFactory {
147 FakeWebRtcVideoChannel2* GetFakeChannel(VideoMediaChannel* channel);
150 virtual WebRtcVideoChannel2* Create(
151 WebRtcVideoEngine2* engine,
152 VoiceMediaChannel* voice_channel) OVERRIDE;
154 std::map<VideoMediaChannel*, FakeWebRtcVideoChannel2*> channel_map_;
158 } // namespace cricket
159 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_