blob: 312cf648048902ac97f473b5e499748ae4db8ad2 [file] [log] [blame]
/*
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_
#define WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/media/base/fakevideorenderer.h"
namespace webrtc {
class FakeVideoTrackRenderer
: public rtc::VideoSinkInterface<cricket::VideoFrame> {
public:
FakeVideoTrackRenderer(VideoTrackInterface* video_track)
: video_track_(video_track) {
video_track_->AddOrUpdateSink(this, rtc::VideoSinkWants());
}
~FakeVideoTrackRenderer() { video_track_->RemoveSink(this); }
virtual void OnFrame(const cricket::VideoFrame& video_frame) override {
fake_renderer_.RenderFrame(&video_frame);
}
int errors() const { return fake_renderer_.errors(); }
int width() const { return fake_renderer_.width(); }
int height() const { return fake_renderer_.height(); }
webrtc::VideoRotation rotation() const { return fake_renderer_.rotation(); }
bool black_frame() const { return fake_renderer_.black_frame(); }
int num_rendered_frames() const {
return fake_renderer_.num_rendered_frames();
}
private:
cricket::FakeVideoRenderer fake_renderer_;
rtc::scoped_refptr<VideoTrackInterface> video_track_;
};
// Similar class, testing the deprecated AddRenderer/RemoveRenderer methods.
class FakeVideoTrackRendererOld : public VideoRendererInterface {
public:
FakeVideoTrackRendererOld(VideoTrackInterface* video_track)
: video_track_(video_track) {
video_track_->AddRenderer(this);
}
~FakeVideoTrackRendererOld() { video_track_->RemoveRenderer(this); }
virtual void RenderFrame(const cricket::VideoFrame* video_frame) override {
fake_renderer_.RenderFrame(video_frame);
}
int errors() const { return fake_renderer_.errors(); }
int width() const { return fake_renderer_.width(); }
int height() const { return fake_renderer_.height(); }
bool black_frame() const { return fake_renderer_.black_frame(); }
int num_rendered_frames() const {
return fake_renderer_.num_rendered_frames();
}
private:
cricket::FakeVideoRenderer fake_renderer_;
rtc::scoped_refptr<VideoTrackInterface> video_track_;
};
} // namespace webrtc
#endif // WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_