• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TEST_FRAME_GENERATOR_CAPTURER_H_
11 #define WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
12 
13 #include <string>
14 
15 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/platform_thread.h"
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/test/video_capturer.h"
19 #include "webrtc/typedefs.h"
20 
21 namespace webrtc {
22 
23 class CriticalSectionWrapper;
24 class EventTimerWrapper;
25 
26 namespace test {
27 
28 class FrameGenerator;
29 
30 class FrameGeneratorCapturer : public VideoCapturer {
31  public:
32   static FrameGeneratorCapturer* Create(VideoCaptureInput* input,
33                                         size_t width,
34                                         size_t height,
35                                         int target_fps,
36                                         Clock* clock);
37 
38   static FrameGeneratorCapturer* CreateFromYuvFile(VideoCaptureInput* input,
39                                                    const std::string& file_name,
40                                                    size_t width,
41                                                    size_t height,
42                                                    int target_fps,
43                                                    Clock* clock);
44   virtual ~FrameGeneratorCapturer();
45 
46   void Start() override;
47   void Stop() override;
48   void ForceFrame();
49 
first_frame_capture_time()50   int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
51 
52   FrameGeneratorCapturer(Clock* clock,
53                          VideoCaptureInput* input,
54                          FrameGenerator* frame_generator,
55                          int target_fps);
56   bool Init();
57 
58  private:
59   void InsertFrame();
60   static bool Run(void* obj);
61 
62   Clock* const clock_;
63   bool sending_;
64 
65   rtc::scoped_ptr<EventTimerWrapper> tick_;
66   rtc::CriticalSection lock_;
67   rtc::PlatformThread thread_;
68   rtc::scoped_ptr<FrameGenerator> frame_generator_;
69 
70   int target_fps_;
71 
72   int64_t first_frame_capture_time_;
73 };
74 }  // test
75 }  // webrtc
76 
77 #endif  // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
78