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

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

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Set EncodedImage content_type from vie_encoder Created 3 years, 9 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
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 #include "webrtc/test/frame_generator.h" 10 #include "webrtc/test/frame_generator.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Ensure stride == width. 57 // Ensure stride == width.
58 rtc::scoped_refptr<I420Buffer> buffer( 58 rtc::scoped_refptr<I420Buffer> buffer(
59 I420Buffer::Create(width_, height_, width_, half_width_, half_width_)); 59 I420Buffer::Create(width_, height_, width_, half_width_, half_width_));
60 memset(buffer->MutableDataY(), 127, y_size_); 60 memset(buffer->MutableDataY(), 127, y_size_);
61 memset(buffer->MutableDataU(), 127, uv_size_); 61 memset(buffer->MutableDataU(), 127, uv_size_);
62 memset(buffer->MutableDataV(), 127, uv_size_); 62 memset(buffer->MutableDataV(), 127, uv_size_);
63 63
64 for (const auto& square : squares_) 64 for (const auto& square : squares_)
65 square->Draw(buffer); 65 square->Draw(buffer);
66 66
67 frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0)); 67 frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0,
68 webrtc::kVideoContent_Default));
68 return frame_.get(); 69 return frame_.get();
69 } 70 }
70 71
71 private: 72 private:
72 class Square { 73 class Square {
73 public: 74 public:
74 Square(int width, int height, int seed) 75 Square(int width, int height, int seed)
75 : random_generator_(seed), 76 : random_generator_(seed),
76 x_(random_generator_.Rand(0, width)), 77 x_(random_generator_.Rand(0, width)),
77 y_(random_generator_.Rand(0, height)), 78 y_(random_generator_.Rand(0, height)),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 for (FILE* file : files_) 143 for (FILE* file : files_)
143 fclose(file); 144 fclose(file);
144 } 145 }
145 146
146 VideoFrame* NextFrame() override { 147 VideoFrame* NextFrame() override {
147 if (current_display_count_ == 0) 148 if (current_display_count_ == 0)
148 ReadNextFrame(); 149 ReadNextFrame();
149 if (++current_display_count_ >= frame_display_count_) 150 if (++current_display_count_ >= frame_display_count_)
150 current_display_count_ = 0; 151 current_display_count_ = 0;
151 152
152 temp_frame_.reset( 153 temp_frame_.reset(new VideoFrame(last_read_buffer_, 0, 0,
153 new VideoFrame(last_read_buffer_, 0, 0, webrtc::kVideoRotation_0)); 154 webrtc::kVideoRotation_0,
155 webrtc::kVideoContent_Default));
154 return temp_frame_.get(); 156 return temp_frame_.get();
155 } 157 }
156 158
157 void ReadNextFrame() { 159 void ReadNextFrame() {
158 last_read_buffer_ = 160 last_read_buffer_ =
159 test::ReadI420Buffer(static_cast<int>(width_), 161 test::ReadI420Buffer(static_cast<int>(width_),
160 static_cast<int>(height_), 162 static_cast<int>(height_),
161 files_[file_index_]); 163 files_[file_index_]);
162 if (!last_read_buffer_) { 164 if (!last_read_buffer_) {
163 // No more frames to read in this file, rewind and move to next file. 165 // No more frames to read in this file, rewind and move to next file.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 (pixels_scrolled_y / 2)) + 260 (pixels_scrolled_y / 2)) +
259 (pixels_scrolled_x / 2); 261 (pixels_scrolled_x / 2);
260 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * 262 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() *
261 (pixels_scrolled_y / 2)) + 263 (pixels_scrolled_y / 2)) +
262 (pixels_scrolled_x / 2); 264 (pixels_scrolled_x / 2);
263 265
264 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer( 266 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer(
265 current_source_frame_->video_frame_buffer()); 267 current_source_frame_->video_frame_buffer());
266 current_frame_ = rtc::Optional<webrtc::VideoFrame>(webrtc::VideoFrame( 268 current_frame_ = rtc::Optional<webrtc::VideoFrame>(webrtc::VideoFrame(
267 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( 269 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
268 target_width_, target_height_, 270 target_width_, target_height_, &frame_buffer->DataY()[offset_y],
269 &frame_buffer->DataY()[offset_y], frame_buffer->StrideY(), 271 frame_buffer->StrideY(), &frame_buffer->DataU()[offset_u],
270 &frame_buffer->DataU()[offset_u], frame_buffer->StrideU(), 272 frame_buffer->StrideU(), &frame_buffer->DataV()[offset_v],
271 &frame_buffer->DataV()[offset_v], frame_buffer->StrideV(), 273 frame_buffer->StrideV(), KeepRefUntilDone(frame_buffer)),
272 KeepRefUntilDone(frame_buffer)), 274 kVideoRotation_0, webrtc::kVideoContent_Default, 0));
273 kVideoRotation_0, 0));
274 } 275 }
275 276
276 Clock* const clock_; 277 Clock* const clock_;
277 const int64_t start_time_; 278 const int64_t start_time_;
278 const int64_t scroll_time_; 279 const int64_t scroll_time_;
279 const int64_t pause_time_; 280 const int64_t pause_time_;
280 const size_t num_frames_; 281 const size_t num_frames_;
281 const int target_width_; 282 const int target_width_;
282 const int target_height_; 283 const int target_height_;
283 284
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 files.push_back(file); 364 files.push_back(file);
364 } 365 }
365 366
366 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator( 367 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator(
367 clock, files, source_width, source_height, target_width, target_height, 368 clock, files, source_width, source_height, target_width, target_height,
368 scroll_time_ms, pause_time_ms)); 369 scroll_time_ms, pause_time_ms));
369 } 370 }
370 371
371 } // namespace test 372 } // namespace test
372 } // namespace webrtc 373 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698