1/*
2 *  Copyright (c) 2013 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_COMMON_FRAME_GENERATOR_CAPTURER_H_
11#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_
12
13#include "webrtc/system_wrappers/interface/scoped_ptr.h"
14#include "webrtc/test/video_capturer.h"
15#include "webrtc/typedefs.h"
16
17namespace webrtc {
18
19class CriticalSectionWrapper;
20class EventWrapper;
21class ThreadWrapper;
22
23namespace test {
24
25class FrameGenerator;
26
27class FrameGeneratorCapturer : public VideoCapturer {
28 public:
29  static FrameGeneratorCapturer* Create(VideoSendStreamInput* input,
30                                        size_t width,
31                                        size_t height,
32                                        int target_fps,
33                                        Clock* clock);
34
35  static FrameGeneratorCapturer* CreateFromYuvFile(VideoSendStreamInput* input,
36                                                   const char* file_name,
37                                                   size_t width,
38                                                   size_t height,
39                                                   int target_fps,
40                                                   Clock* clock);
41  virtual ~FrameGeneratorCapturer();
42
43  virtual void Start() OVERRIDE;
44  virtual void Stop() OVERRIDE;
45
46  int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
47
48 private:
49  FrameGeneratorCapturer(Clock* clock,
50                         VideoSendStreamInput* input,
51                         FrameGenerator* frame_generator,
52                         int target_fps);
53  bool Init();
54  void InsertFrame();
55  static bool Run(void* obj);
56
57  Clock* const clock_;
58  bool sending_;
59
60  scoped_ptr<EventWrapper> tick_;
61  scoped_ptr<CriticalSectionWrapper> lock_;
62  scoped_ptr<ThreadWrapper> thread_;
63  scoped_ptr<FrameGenerator> frame_generator_;
64
65  int target_fps_;
66
67  int64_t first_frame_capture_time_;
68};
69}  // test
70}  // webrtc
71
72#endif  // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_
73