| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 FileRenderPassthrough(const std::string& basename, | 141 FileRenderPassthrough(const std::string& basename, |
| 142 rtc::VideoSinkInterface<VideoFrame>* renderer) | 142 rtc::VideoSinkInterface<VideoFrame>* renderer) |
| 143 : basename_(basename), | 143 : basename_(basename), |
| 144 renderer_(renderer), | 144 renderer_(renderer), |
| 145 file_(nullptr), | 145 file_(nullptr), |
| 146 count_(0), | 146 count_(0), |
| 147 last_width_(0), | 147 last_width_(0), |
| 148 last_height_(0) {} | 148 last_height_(0) {} |
| 149 | 149 |
| 150 ~FileRenderPassthrough() { | 150 ~FileRenderPassthrough() { |
| 151 if (file_ != nullptr) | 151 if (file_) |
| 152 fclose(file_); | 152 fclose(file_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 void OnFrame(const VideoFrame& video_frame) override { | 156 void OnFrame(const VideoFrame& video_frame) override { |
| 157 if (renderer_ != nullptr) | 157 if (renderer_) |
| 158 renderer_->OnFrame(video_frame); | 158 renderer_->OnFrame(video_frame); |
| 159 if (basename_.empty()) | 159 if (basename_.empty()) |
| 160 return; | 160 return; |
| 161 if (last_width_ != video_frame.width() || | 161 if (last_width_ != video_frame.width() || |
| 162 last_height_ != video_frame.height()) { | 162 last_height_ != video_frame.height()) { |
| 163 if (file_ != nullptr) | 163 if (file_) |
| 164 fclose(file_); | 164 fclose(file_); |
| 165 std::stringstream filename; | 165 std::stringstream filename; |
| 166 filename << basename_; | 166 filename << basename_; |
| 167 if (++count_ > 1) | 167 if (++count_ > 1) |
| 168 filename << '-' << count_; | 168 filename << '-' << count_; |
| 169 filename << '_' << video_frame.width() << 'x' << video_frame.height() | 169 filename << '_' << video_frame.width() << 'x' << video_frame.height() |
| 170 << ".yuv"; | 170 << ".yuv"; |
| 171 file_ = fopen(filename.str().c_str(), "wb"); | 171 file_ = fopen(filename.str().c_str(), "wb"); |
| 172 if (file_ == nullptr) { | 172 if (file_ == nullptr) { |
| 173 fprintf(stderr, | 173 fprintf(stderr, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 187 FILE* file_; | 187 FILE* file_; |
| 188 size_t count_; | 188 size_t count_; |
| 189 int last_width_; | 189 int last_width_; |
| 190 int last_height_; | 190 int last_height_; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 class DecoderBitstreamFileWriter : public EncodedFrameObserver { | 193 class DecoderBitstreamFileWriter : public EncodedFrameObserver { |
| 194 public: | 194 public: |
| 195 explicit DecoderBitstreamFileWriter(const char* filename) | 195 explicit DecoderBitstreamFileWriter(const char* filename) |
| 196 : file_(fopen(filename, "wb")) { | 196 : file_(fopen(filename, "wb")) { |
| 197 RTC_DCHECK(file_ != nullptr); | 197 RTC_DCHECK(file_); |
| 198 } | 198 } |
| 199 ~DecoderBitstreamFileWriter() { fclose(file_); } | 199 ~DecoderBitstreamFileWriter() { fclose(file_); } |
| 200 | 200 |
| 201 virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) { | 201 virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) { |
| 202 fwrite(encoded_frame.data_, 1, encoded_frame.length_, file_); | 202 fwrite(encoded_frame.data_, 1, encoded_frame.length_, file_); |
| 203 } | 203 } |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 FILE* file_; | 206 FILE* file_; |
| 207 }; | 207 }; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 319 } |
| 320 } // namespace webrtc | 320 } // namespace webrtc |
| 321 | 321 |
| 322 int main(int argc, char* argv[]) { | 322 int main(int argc, char* argv[]) { |
| 323 ::testing::InitGoogleTest(&argc, argv); | 323 ::testing::InitGoogleTest(&argc, argv); |
| 324 google::ParseCommandLineFlags(&argc, &argv, true); | 324 google::ParseCommandLineFlags(&argc, &argv, true); |
| 325 | 325 |
| 326 webrtc::test::RunTest(webrtc::RtpReplay); | 326 webrtc::test::RunTest(webrtc::RtpReplay); |
| 327 return 0; | 327 return 0; |
| 328 } | 328 } |
| OLD | NEW |