OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
25 #include "webrtc/system_wrappers/include/sleep.h" | 25 #include "webrtc/system_wrappers/include/sleep.h" |
26 #include "webrtc/test/call_test.h" | 26 #include "webrtc/test/call_test.h" |
27 #include "webrtc/test/encoder_settings.h" | 27 #include "webrtc/test/encoder_settings.h" |
28 #include "webrtc/test/fake_decoder.h" | 28 #include "webrtc/test/fake_decoder.h" |
29 #include "webrtc/test/gtest.h" | 29 #include "webrtc/test/gtest.h" |
30 #include "webrtc/test/null_transport.h" | 30 #include "webrtc/test/null_transport.h" |
31 #include "webrtc/test/rtp_file_reader.h" | 31 #include "webrtc/test/rtp_file_reader.h" |
32 #include "webrtc/test/run_loop.h" | 32 #include "webrtc/test/run_loop.h" |
33 #include "webrtc/test/run_test.h" | 33 #include "webrtc/test/run_test.h" |
34 #include "webrtc/test/testsupport/frame_writer.h" | |
34 #include "webrtc/test/video_capturer.h" | 35 #include "webrtc/test/video_capturer.h" |
35 #include "webrtc/test/video_renderer.h" | 36 #include "webrtc/test/video_renderer.h" |
36 #include "webrtc/typedefs.h" | 37 #include "webrtc/typedefs.h" |
37 | 38 |
38 namespace webrtc { | 39 namespace webrtc { |
39 namespace flags { | 40 namespace flags { |
40 | 41 |
41 // TODO(pbos): Multiple receivers. | 42 // TODO(pbos): Multiple receivers. |
42 | 43 |
43 // Flag for payload type. | 44 // Flag for payload type. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 130 |
130 DEFINE_string(input_file, "", "input file"); | 131 DEFINE_string(input_file, "", "input file"); |
131 static std::string InputFile() { | 132 static std::string InputFile() { |
132 return static_cast<std::string>(FLAGS_input_file); | 133 return static_cast<std::string>(FLAGS_input_file); |
133 } | 134 } |
134 static const bool input_file_dummy = | 135 static const bool input_file_dummy = |
135 google::RegisterFlagValidator(&FLAGS_input_file, | 136 google::RegisterFlagValidator(&FLAGS_input_file, |
136 &ValidateInputFilenameNotEmpty); | 137 &ValidateInputFilenameNotEmpty); |
137 | 138 |
138 // Flag for raw output files. | 139 // Flag for raw output files. |
139 DEFINE_string(out_base, "", "Basename (excluding .yuv) for raw output"); | 140 DEFINE_string(out_base, "", "Basename (excluding .yuv) for raw output"); |
ilnik
2017/08/24 14:47:46
You should also change a discription, since now it
philipel
2017/08/25 09:29:52
Done.
| |
140 static std::string OutBase() { | 141 static std::string OutBase() { |
141 return static_cast<std::string>(FLAGS_out_base); | 142 return static_cast<std::string>(FLAGS_out_base); |
142 } | 143 } |
143 | 144 |
144 DEFINE_string(decoder_bitstream_filename, "", "Decoder bitstream output file"); | 145 DEFINE_string(decoder_bitstream_filename, "", "Decoder bitstream output file"); |
145 static std::string DecoderBitstreamFilename() { | 146 static std::string DecoderBitstreamFilename() { |
146 return static_cast<std::string>(FLAGS_decoder_bitstream_filename); | 147 return static_cast<std::string>(FLAGS_decoder_bitstream_filename); |
147 } | 148 } |
148 | 149 |
149 // Flag for video codec. | 150 // Flag for video codec. |
150 DEFINE_string(codec, "VP8", "Video codec"); | 151 DEFINE_string(codec, "VP8", "Video codec"); |
151 static std::string Codec() { return static_cast<std::string>(FLAGS_codec); } | 152 static std::string Codec() { return static_cast<std::string>(FLAGS_codec); } |
152 | 153 |
153 } // namespace flags | 154 } // namespace flags |
154 | 155 |
155 static const uint32_t kReceiverLocalSsrc = 0x123456; | 156 static const uint32_t kReceiverLocalSsrc = 0x123456; |
156 | 157 |
157 class FileRenderPassthrough : public rtc::VideoSinkInterface<VideoFrame> { | 158 class FileRenderPassthrough : public rtc::VideoSinkInterface<VideoFrame> { |
158 public: | 159 public: |
159 FileRenderPassthrough(const std::string& basename, | 160 FileRenderPassthrough(const std::string& basename, |
160 rtc::VideoSinkInterface<VideoFrame>* renderer) | 161 rtc::VideoSinkInterface<VideoFrame>* renderer) |
161 : basename_(basename), | 162 : basename_(basename), |
162 renderer_(renderer), | 163 renderer_(renderer), |
163 file_(nullptr), | 164 file_(nullptr), |
164 count_(0), | 165 count_(0) {} |
165 last_width_(0), | |
166 last_height_(0) {} | |
167 | 166 |
168 ~FileRenderPassthrough() { | 167 ~FileRenderPassthrough() { |
169 if (file_) | 168 if (file_) |
170 fclose(file_); | 169 fclose(file_); |
171 } | 170 } |
172 | 171 |
173 private: | 172 private: |
174 void OnFrame(const VideoFrame& video_frame) override { | 173 void OnFrame(const VideoFrame& video_frame) override { |
175 if (renderer_) | 174 if (renderer_) |
176 renderer_->OnFrame(video_frame); | 175 renderer_->OnFrame(video_frame); |
176 | |
177 if (basename_.empty()) | 177 if (basename_.empty()) |
178 return; | 178 return; |
179 if (last_width_ != video_frame.width() || | 179 |
180 last_height_ != video_frame.height()) { | 180 std::stringstream filename; |
181 if (file_) | 181 filename << basename_; |
182 fclose(file_); | 182 filename << count_++ << "_" << video_frame.timestamp() << ".jpg"; |
sprang_webrtc
2017/08/25 08:32:19
nit: merge into single statement
philipel
2017/08/25 09:29:52
Done.
| |
183 std::stringstream filename; | 183 |
184 filename << basename_; | 184 test::JpegFrameWriter frame_writer(filename.str()); |
185 if (++count_ > 1) | 185 RTC_CHECK(frame_writer.WriteFrame(video_frame, 100)); |
186 filename << '-' << count_; | |
187 filename << '_' << video_frame.width() << 'x' << video_frame.height() | |
188 << ".yuv"; | |
189 file_ = fopen(filename.str().c_str(), "wb"); | |
190 if (!file_) { | |
191 fprintf(stderr, | |
192 "Couldn't open file for writing: %s\n", | |
193 filename.str().c_str()); | |
194 } | |
195 } | |
196 last_width_ = video_frame.width(); | |
197 last_height_ = video_frame.height(); | |
198 if (!file_) | |
199 return; | |
200 PrintVideoFrame(video_frame, file_); | |
201 } | 186 } |
202 | 187 |
203 const std::string basename_; | 188 const std::string basename_; |
204 rtc::VideoSinkInterface<VideoFrame>* const renderer_; | 189 rtc::VideoSinkInterface<VideoFrame>* const renderer_; |
205 FILE* file_; | 190 FILE* file_; |
206 size_t count_; | 191 size_t count_; |
207 int last_width_; | |
208 int last_height_; | |
209 }; | 192 }; |
210 | 193 |
211 class DecoderBitstreamFileWriter : public EncodedFrameObserver { | 194 class DecoderBitstreamFileWriter : public EncodedFrameObserver { |
212 public: | 195 public: |
213 explicit DecoderBitstreamFileWriter(const char* filename) | 196 explicit DecoderBitstreamFileWriter(const char* filename) |
214 : file_(fopen(filename, "wb")) { | 197 : file_(fopen(filename, "wb")) { |
215 RTC_DCHECK(file_); | 198 RTC_DCHECK(file_); |
216 } | 199 } |
217 ~DecoderBitstreamFileWriter() { fclose(file_); } | 200 ~DecoderBitstreamFileWriter() { fclose(file_); } |
218 | 201 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 } | 331 } |
349 } // namespace webrtc | 332 } // namespace webrtc |
350 | 333 |
351 int main(int argc, char* argv[]) { | 334 int main(int argc, char* argv[]) { |
352 ::testing::InitGoogleTest(&argc, argv); | 335 ::testing::InitGoogleTest(&argc, argv); |
353 google::ParseCommandLineFlags(&argc, &argv, true); | 336 google::ParseCommandLineFlags(&argc, &argv, true); |
354 | 337 |
355 webrtc::test::RunTest(webrtc::RtpReplay); | 338 webrtc::test::RunTest(webrtc::RtpReplay); |
356 return 0; | 339 return 0; |
357 } | 340 } |
OLD | NEW |