1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10#ifndef WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_
11#define WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_
12
13#include "webrtc/system_wrappers/interface/tick_util.h"
14#include "webrtc/video_engine/include/vie_render.h"
15
16namespace webrtc {
17
18// A render filter which passes frames directly to an external renderer. This
19// is different from plugging the external renderer directly into the sending
20// side since this will only run on frames that actually get sent and not on
21// frames that only get captured.
22class ExternalRendererEffectFilter : public webrtc::ViEEffectFilter {
23 public:
24  explicit ExternalRendererEffectFilter(webrtc::ExternalRenderer* renderer)
25      : width_(0), height_(0), renderer_(renderer) {}
26  virtual ~ExternalRendererEffectFilter() {}
27  virtual int Transform(int size,
28                        unsigned char* frame_buffer,
29                        int64_t ntp_time_ms,
30                        unsigned int timestamp,
31                        unsigned int width,
32                        unsigned int height) {
33    if (width != width_ || height_ != height) {
34      renderer_->FrameSizeChange(width, height, 1);
35      width_ = width;
36      height_ = height;
37    }
38    return renderer_->DeliverFrame(frame_buffer,
39                                   size,
40                                   ntp_time_ms,
41                                   timestamp,
42                                   webrtc::TickTime::MillisecondTimestamp(),
43                                   NULL);
44  }
45
46 private:
47  unsigned int width_;
48  unsigned int height_;
49  webrtc::ExternalRenderer* renderer_;
50};
51
52}  // namespace webrtc
53
54#endif  // WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_
55