Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: webrtc/test/frame_generator_capturer.cc

Issue 2344923002: Revert of Replace interface VideoCapturerInput with VideoSinkInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/frame_generator_capturer.h ('k') | webrtc/test/test.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/test/frame_generator_capturer.h" 11 #include "webrtc/test/frame_generator_capturer.h"
12 12
13 #include "webrtc/base/criticalsection.h" 13 #include "webrtc/base/criticalsection.h"
14 #include "webrtc/base/platform_thread.h" 14 #include "webrtc/base/platform_thread.h"
15 #include "webrtc/system_wrappers/include/clock.h" 15 #include "webrtc/system_wrappers/include/clock.h"
16 #include "webrtc/system_wrappers/include/event_wrapper.h" 16 #include "webrtc/system_wrappers/include/event_wrapper.h"
17 #include "webrtc/system_wrappers/include/sleep.h" 17 #include "webrtc/system_wrappers/include/sleep.h"
18 #include "webrtc/test/frame_generator.h" 18 #include "webrtc/test/frame_generator.h"
19 #include "webrtc/video_send_stream.h" 19 #include "webrtc/video_send_stream.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 namespace test { 22 namespace test {
23 23
24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width, 24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(VideoCaptureInput* input,
25 size_t width,
25 size_t height, 26 size_t height,
26 int target_fps, 27 int target_fps,
27 Clock* clock) { 28 Clock* clock) {
28 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( 29 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer(
29 clock, FrameGenerator::CreateChromaGenerator(width, height), target_fps); 30 clock, input, FrameGenerator::CreateChromaGenerator(width, height),
31 target_fps);
30 if (!capturer->Init()) { 32 if (!capturer->Init()) {
31 delete capturer; 33 delete capturer;
32 return NULL; 34 return NULL;
33 } 35 }
34 36
35 return capturer; 37 return capturer;
36 } 38 }
37 39
38 FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( 40 FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile(
41 VideoCaptureInput* input,
39 const std::string& file_name, 42 const std::string& file_name,
40 size_t width, 43 size_t width,
41 size_t height, 44 size_t height,
42 int target_fps, 45 int target_fps,
43 Clock* clock) { 46 Clock* clock) {
44 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( 47 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer(
45 clock, FrameGenerator::CreateFromYuvFile( 48 clock, input,
46 std::vector<std::string>(1, file_name), width, height, 1), 49 FrameGenerator::CreateFromYuvFile(std::vector<std::string>(1, file_name),
50 width, height, 1),
47 target_fps); 51 target_fps);
48 if (!capturer->Init()) { 52 if (!capturer->Init()) {
49 delete capturer; 53 delete capturer;
50 return NULL; 54 return NULL;
51 } 55 }
52 56
53 return capturer; 57 return capturer;
54 } 58 }
55 59
56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, 60 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock,
61 VideoCaptureInput* input,
57 FrameGenerator* frame_generator, 62 FrameGenerator* frame_generator,
58 int target_fps) 63 int target_fps)
59 : clock_(clock), 64 : VideoCapturer(input),
65 clock_(clock),
60 sending_(false), 66 sending_(false),
61 sink_(nullptr),
62 tick_(EventTimerWrapper::Create()), 67 tick_(EventTimerWrapper::Create()),
63 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), 68 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"),
64 frame_generator_(frame_generator), 69 frame_generator_(frame_generator),
65 target_fps_(target_fps), 70 target_fps_(target_fps),
66 first_frame_capture_time_(-1) { 71 first_frame_capture_time_(-1) {
67 RTC_DCHECK(frame_generator); 72 assert(input != NULL);
68 RTC_DCHECK_GT(target_fps, 0); 73 assert(frame_generator != NULL);
74 assert(target_fps > 0);
69 } 75 }
70 76
71 FrameGeneratorCapturer::~FrameGeneratorCapturer() { 77 FrameGeneratorCapturer::~FrameGeneratorCapturer() {
72 Stop(); 78 Stop();
73 79
74 thread_.Stop(); 80 thread_.Stop();
75 } 81 }
76 82
77 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) { 83 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) {
78 rtc::CritScope cs(&lock_); 84 rtc::CritScope cs(&lock_);
(...skipping 21 matching lines...) Expand all
100 void FrameGeneratorCapturer::InsertFrame() { 106 void FrameGeneratorCapturer::InsertFrame() {
101 { 107 {
102 rtc::CritScope cs(&lock_); 108 rtc::CritScope cs(&lock_);
103 if (sending_) { 109 if (sending_) {
104 VideoFrame* frame = frame_generator_->NextFrame(); 110 VideoFrame* frame = frame_generator_->NextFrame();
105 frame->set_ntp_time_ms(clock_->CurrentNtpInMilliseconds()); 111 frame->set_ntp_time_ms(clock_->CurrentNtpInMilliseconds());
106 frame->set_rotation(fake_rotation_); 112 frame->set_rotation(fake_rotation_);
107 if (first_frame_capture_time_ == -1) { 113 if (first_frame_capture_time_ == -1) {
108 first_frame_capture_time_ = frame->ntp_time_ms(); 114 first_frame_capture_time_ = frame->ntp_time_ms();
109 } 115 }
110 if (sink_) 116 input_->IncomingCapturedFrame(*frame);
111 sink_->OnFrame(*frame);
112 } 117 }
113 } 118 }
114 tick_->Wait(WEBRTC_EVENT_INFINITE); 119 tick_->Wait(WEBRTC_EVENT_INFINITE);
115 } 120 }
116 121
117 void FrameGeneratorCapturer::Start() { 122 void FrameGeneratorCapturer::Start() {
118 rtc::CritScope cs(&lock_); 123 rtc::CritScope cs(&lock_);
119 sending_ = true; 124 sending_ = true;
120 } 125 }
121 126
122 void FrameGeneratorCapturer::Stop() { 127 void FrameGeneratorCapturer::Stop() {
123 rtc::CritScope cs(&lock_); 128 rtc::CritScope cs(&lock_);
124 sending_ = false; 129 sending_ = false;
125 } 130 }
126 131
127 void FrameGeneratorCapturer::AddOrUpdateSink(
128 rtc::VideoSinkInterface<VideoFrame>* sink,
129 const rtc::VideoSinkWants& wants) {
130 rtc::CritScope cs(&lock_);
131 RTC_CHECK(!sink_);
132 sink_ = sink;
133 }
134
135 void FrameGeneratorCapturer::RemoveSink(
136 rtc::VideoSinkInterface<VideoFrame>* sink) {
137 rtc::CritScope cs(&lock_);
138 RTC_CHECK(sink_ == sink);
139 sink_ = nullptr;
140 }
141
142 void FrameGeneratorCapturer::ForceFrame() { 132 void FrameGeneratorCapturer::ForceFrame() {
143 tick_->Set(); 133 tick_->Set();
144 } 134 }
145 } // test 135 } // test
146 } // webrtc 136 } // webrtc
OLDNEW
« no previous file with comments | « webrtc/test/frame_generator_capturer.h ('k') | webrtc/test/test.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698