blob: 367116731fd6fe4437561cc39efdbe0c4f00f795 [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
46 bool IsSending();
47
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
72 private:
73 virtual webrtc::VideoReceiveStream::Stats GetStats() const OVERRIDE;
74
75 virtual void Start() OVERRIDE;
76 virtual void Stop() OVERRIDE;
77 virtual void GetCurrentReceiveCodec(webrtc::VideoCodec* codec);
78
79 webrtc::VideoReceiveStream::Config config_;
80 bool receiving_;
81};
82
83class FakeCall : public webrtc::Call {
84 public:
85 FakeCall();
86 ~FakeCall();
87
88 void SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs);
89
90 std::vector<FakeVideoSendStream*> GetVideoSendStreams();
91 std::vector<FakeVideoReceiveStream*> GetVideoReceiveStreams();
92
93 webrtc::VideoCodec GetEmptyVideoCodec();
94
95 webrtc::VideoCodec GetVideoCodecVp8();
96 webrtc::VideoCodec GetVideoCodecVp9();
97
98 std::vector<webrtc::VideoCodec> GetDefaultVideoCodecs();
99
100 private:
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000101 virtual webrtc::VideoSendStream* CreateVideoSendStream(
102 const webrtc::VideoSendStream::Config& config,
103 const std::vector<webrtc::VideoStream>& video_streams,
104 const void* encoder_settings) OVERRIDE;
105
106 virtual void DestroyVideoSendStream(
107 webrtc::VideoSendStream* send_stream) OVERRIDE;
108
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000109 virtual webrtc::VideoReceiveStream* CreateVideoReceiveStream(
110 const webrtc::VideoReceiveStream::Config& config) OVERRIDE;
111
112 virtual void DestroyVideoReceiveStream(
113 webrtc::VideoReceiveStream* receive_stream) OVERRIDE;
114 virtual webrtc::PacketReceiver* Receiver() OVERRIDE;
115
116 virtual uint32_t SendBitrateEstimate() OVERRIDE;
117 virtual uint32_t ReceiveBitrateEstimate() OVERRIDE;
118
119 std::vector<webrtc::VideoCodec> codecs_;
120 std::vector<FakeVideoSendStream*> video_send_streams_;
121 std::vector<FakeVideoReceiveStream*> video_receive_streams_;
122};
123
124class FakeWebRtcVideoChannel2 : public WebRtcVideoChannel2 {
125 public:
126 FakeWebRtcVideoChannel2(FakeCall* call,
127 WebRtcVideoEngine2* engine,
128 VoiceMediaChannel* voice_channel);
129 virtual ~FakeWebRtcVideoChannel2();
130
131 VoiceMediaChannel* GetVoiceChannel();
132 FakeCall* GetFakeCall();
133
134 private:
135 FakeCall* fake_call_;
136 VoiceMediaChannel* voice_channel_;
137};
138
139class FakeWebRtcVideoMediaChannelFactory : public WebRtcVideoChannelFactory {
140 public:
141 FakeWebRtcVideoChannel2* GetFakeChannel(VideoMediaChannel* channel);
142
143 private:
144 virtual WebRtcVideoChannel2* Create(
145 WebRtcVideoEngine2* engine,
146 VoiceMediaChannel* voice_channel) OVERRIDE;
147
148 std::map<VideoMediaChannel*, FakeWebRtcVideoChannel2*> channel_map_;
149};
150
151
152} // namespace cricket
153#endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_