blob: b5baa341d904b26642ecc81b5f900ba95c5a8992 [file] [log] [blame]
pbos@webrtc.org86f613d2014-06-10 08:53:05 +00001/*
2 * libjingle
3 * Copyright 2014 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
15 *
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.
26 */
27
28#ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_
29#define TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_
30
31#include <map>
32#include <vector>
33
34#include "webrtc/call.h"
35#include "webrtc/video_receive_stream.h"
36#include "webrtc/video_send_stream.h"
37
38namespace cricket {
39class FakeVideoSendStream : public webrtc::VideoSendStream {
40 public:
41 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config,
42 const std::vector<webrtc::VideoStream>& video_streams);
43 webrtc::VideoSendStream::Config GetConfig();
44 std::vector<webrtc::VideoStream> GetVideoStreams();
45
pbos@webrtc.org85f42942014-07-22 09:14:58 +000046 bool IsSending() const;
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000047
48 private:
49 virtual webrtc::VideoSendStream::Stats GetStats() const OVERRIDE;
50
51 virtual bool ReconfigureVideoEncoder(
52 const std::vector<webrtc::VideoStream>& streams,
53 const void* encoder_specific);
54
55 virtual webrtc::VideoSendStreamInput* Input() OVERRIDE;
56
57 virtual void Start() OVERRIDE;
58 virtual void Stop() OVERRIDE;
59
60 bool sending_;
61 webrtc::VideoSendStream::Config config_;
62 std::vector<webrtc::VideoStream> video_streams_;
63};
64
65class FakeVideoReceiveStream : public webrtc::VideoReceiveStream {
66 public:
67 explicit FakeVideoReceiveStream(
68 const webrtc::VideoReceiveStream::Config& config);
69
70 webrtc::VideoReceiveStream::Config GetConfig();
71
pbos@webrtc.org85f42942014-07-22 09:14:58 +000072 bool IsReceiving() const;
73
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000074 private:
75 virtual webrtc::VideoReceiveStream::Stats GetStats() const OVERRIDE;
76
77 virtual void Start() OVERRIDE;
78 virtual void Stop() OVERRIDE;
79 virtual void GetCurrentReceiveCodec(webrtc::VideoCodec* codec);
80
81 webrtc::VideoReceiveStream::Config config_;
82 bool receiving_;
83};
84
85class FakeCall : public webrtc::Call {
86 public:
87 FakeCall();
88 ~FakeCall();
89
90 void SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs);
91
92 std::vector<FakeVideoSendStream*> GetVideoSendStreams();
93 std::vector<FakeVideoReceiveStream*> GetVideoReceiveStreams();
94
95 webrtc::VideoCodec GetEmptyVideoCodec();
96
97 webrtc::VideoCodec GetVideoCodecVp8();
98 webrtc::VideoCodec GetVideoCodecVp9();
99
100 std::vector<webrtc::VideoCodec> GetDefaultVideoCodecs();
101
102 private:
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000103 virtual webrtc::VideoSendStream* CreateVideoSendStream(
104 const webrtc::VideoSendStream::Config& config,
105 const std::vector<webrtc::VideoStream>& video_streams,
106 const void* encoder_settings) OVERRIDE;
107
108 virtual void DestroyVideoSendStream(
109 webrtc::VideoSendStream* send_stream) OVERRIDE;
110
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000111 virtual webrtc::VideoReceiveStream* CreateVideoReceiveStream(
112 const webrtc::VideoReceiveStream::Config& config) OVERRIDE;
113
114 virtual void DestroyVideoReceiveStream(
115 webrtc::VideoReceiveStream* receive_stream) OVERRIDE;
116 virtual webrtc::PacketReceiver* Receiver() OVERRIDE;
117
118 virtual uint32_t SendBitrateEstimate() OVERRIDE;
119 virtual uint32_t ReceiveBitrateEstimate() OVERRIDE;
120
121 std::vector<webrtc::VideoCodec> codecs_;
122 std::vector<FakeVideoSendStream*> video_send_streams_;
123 std::vector<FakeVideoReceiveStream*> video_receive_streams_;
124};
125
126class FakeWebRtcVideoChannel2 : public WebRtcVideoChannel2 {
127 public:
128 FakeWebRtcVideoChannel2(FakeCall* call,
129 WebRtcVideoEngine2* engine,
130 VoiceMediaChannel* voice_channel);
131 virtual ~FakeWebRtcVideoChannel2();
132
133 VoiceMediaChannel* GetVoiceChannel();
134 FakeCall* GetFakeCall();
135
136 private:
137 FakeCall* fake_call_;
138 VoiceMediaChannel* voice_channel_;
139};
140
141class FakeWebRtcVideoMediaChannelFactory : public WebRtcVideoChannelFactory {
142 public:
143 FakeWebRtcVideoChannel2* GetFakeChannel(VideoMediaChannel* channel);
144
145 private:
146 virtual WebRtcVideoChannel2* Create(
147 WebRtcVideoEngine2* engine,
148 VoiceMediaChannel* voice_channel) OVERRIDE;
149
150 std::map<VideoMediaChannel*, FakeWebRtcVideoChannel2*> channel_map_;
151};
152
153
154} // namespace cricket
155#endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_