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

Side by Side Diff: webrtc/video/replay.cc

Issue 2998353002: Update video_replay tool to be able to dump .jpg files. (Closed)
Patch Set: iOS fix take 2 Created 3 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/video/BUILD.gn ('k') | no next file » | 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) 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
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
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 .jpg) for raw output");
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), renderer_(renderer), file_(nullptr), count_(0) {}
162 renderer_(renderer),
163 file_(nullptr),
164 count_(0),
165 last_width_(0),
166 last_height_(0) {}
167 163
168 ~FileRenderPassthrough() { 164 ~FileRenderPassthrough() {
169 if (file_) 165 if (file_)
170 fclose(file_); 166 fclose(file_);
171 } 167 }
172 168
173 private: 169 private:
174 void OnFrame(const VideoFrame& video_frame) override { 170 void OnFrame(const VideoFrame& video_frame) override {
175 if (renderer_) 171 if (renderer_)
176 renderer_->OnFrame(video_frame); 172 renderer_->OnFrame(video_frame);
173
177 if (basename_.empty()) 174 if (basename_.empty())
178 return; 175 return;
179 if (last_width_ != video_frame.width() || 176
180 last_height_ != video_frame.height()) { 177 std::stringstream filename;
181 if (file_) 178 filename << basename_ << count_++ << "_" << video_frame.timestamp()
182 fclose(file_); 179 << ".jpg";
183 std::stringstream filename; 180
184 filename << basename_; 181 #if !defined(WEBRTC_IOS)
185 if (++count_ > 1) 182 test::JpegFrameWriter frame_writer(filename.str());
186 filename << '-' << count_; 183 RTC_CHECK(frame_writer.WriteFrame(video_frame, 100));
187 filename << '_' << video_frame.width() << 'x' << video_frame.height() 184 #endif
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 } 185 }
202 186
203 const std::string basename_; 187 const std::string basename_;
204 rtc::VideoSinkInterface<VideoFrame>* const renderer_; 188 rtc::VideoSinkInterface<VideoFrame>* const renderer_;
205 FILE* file_; 189 FILE* file_;
206 size_t count_; 190 size_t count_;
207 int last_width_;
208 int last_height_;
209 }; 191 };
210 192
211 class DecoderBitstreamFileWriter : public EncodedFrameObserver { 193 class DecoderBitstreamFileWriter : public EncodedFrameObserver {
212 public: 194 public:
213 explicit DecoderBitstreamFileWriter(const char* filename) 195 explicit DecoderBitstreamFileWriter(const char* filename)
214 : file_(fopen(filename, "wb")) { 196 : file_(fopen(filename, "wb")) {
215 RTC_DCHECK(file_); 197 RTC_DCHECK(file_);
216 } 198 }
217 ~DecoderBitstreamFileWriter() { fclose(file_); } 199 ~DecoderBitstreamFileWriter() { fclose(file_); }
218 200
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 330 }
349 } // namespace webrtc 331 } // namespace webrtc
350 332
351 int main(int argc, char* argv[]) { 333 int main(int argc, char* argv[]) {
352 ::testing::InitGoogleTest(&argc, argv); 334 ::testing::InitGoogleTest(&argc, argv);
353 google::ParseCommandLineFlags(&argc, &argv, true); 335 google::ParseCommandLineFlags(&argc, &argv, true);
354 336
355 webrtc::test::RunTest(webrtc::RtpReplay); 337 webrtc::test::RunTest(webrtc::RtpReplay);
356 return 0; 338 return 0;
357 } 339 }
OLDNEW
« no previous file with comments | « webrtc/video/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698