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

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: Fix Mac CE Created 3 years, 8 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::VideoContentType::kDefault));
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 for (FILE* file : files_) 145 for (FILE* file : files_)
145 fclose(file); 146 fclose(file);
146 } 147 }
147 148
148 VideoFrame* NextFrame() override { 149 VideoFrame* NextFrame() override {
149 if (current_display_count_ == 0) 150 if (current_display_count_ == 0)
150 ReadNextFrame(); 151 ReadNextFrame();
151 if (++current_display_count_ >= frame_display_count_) 152 if (++current_display_count_ >= frame_display_count_)
152 current_display_count_ = 0; 153 current_display_count_ = 0;
153 154
154 temp_frame_.reset( 155 temp_frame_.reset(new VideoFrame(last_read_buffer_, 0, 0,
155 new VideoFrame(last_read_buffer_, 0, 0, webrtc::kVideoRotation_0)); 156 webrtc::kVideoRotation_0,
157 webrtc::VideoContentType::kDefault));
156 return temp_frame_.get(); 158 return temp_frame_.get();
157 } 159 }
158 160
159 void ReadNextFrame() { 161 void ReadNextFrame() {
160 last_read_buffer_ = 162 last_read_buffer_ =
161 test::ReadI420Buffer(static_cast<int>(width_), 163 test::ReadI420Buffer(static_cast<int>(width_),
162 static_cast<int>(height_), 164 static_cast<int>(height_),
163 files_[file_index_]); 165 files_[file_index_]);
164 if (!last_read_buffer_) { 166 if (!last_read_buffer_) {
165 // No more frames to read in this file, rewind and move to next file. 167 // 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
260 (pixels_scrolled_y / 2)) + 262 (pixels_scrolled_y / 2)) +
261 (pixels_scrolled_x / 2); 263 (pixels_scrolled_x / 2);
262 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * 264 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() *
263 (pixels_scrolled_y / 2)) + 265 (pixels_scrolled_y / 2)) +
264 (pixels_scrolled_x / 2); 266 (pixels_scrolled_x / 2);
265 267
266 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer( 268 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer(
267 current_source_frame_->video_frame_buffer()); 269 current_source_frame_->video_frame_buffer());
268 current_frame_ = rtc::Optional<webrtc::VideoFrame>(webrtc::VideoFrame( 270 current_frame_ = rtc::Optional<webrtc::VideoFrame>(webrtc::VideoFrame(
269 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( 271 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
270 target_width_, target_height_, 272 target_width_, target_height_, &frame_buffer->DataY()[offset_y],
271 &frame_buffer->DataY()[offset_y], frame_buffer->StrideY(), 273 frame_buffer->StrideY(), &frame_buffer->DataU()[offset_u],
272 &frame_buffer->DataU()[offset_u], frame_buffer->StrideU(), 274 frame_buffer->StrideU(), &frame_buffer->DataV()[offset_v],
273 &frame_buffer->DataV()[offset_v], frame_buffer->StrideV(), 275 frame_buffer->StrideV(), KeepRefUntilDone(frame_buffer)),
274 KeepRefUntilDone(frame_buffer)), 276 kVideoRotation_0, webrtc::VideoContentType::kDefault, 0));
275 kVideoRotation_0, 0));
276 } 277 }
277 278
278 Clock* const clock_; 279 Clock* const clock_;
279 const int64_t start_time_; 280 const int64_t start_time_;
280 const int64_t scroll_time_; 281 const int64_t scroll_time_;
281 const int64_t pause_time_; 282 const int64_t pause_time_;
282 const size_t num_frames_; 283 const size_t num_frames_;
283 const int target_width_; 284 const int target_width_;
284 const int target_height_; 285 const int target_height_;
285 286
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 files.push_back(file); 366 files.push_back(file);
366 } 367 }
367 368
368 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator( 369 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator(
369 clock, files, source_width, source_height, target_width, target_height, 370 clock, files, source_width, source_height, target_width, target_height,
370 scroll_time_ms, pause_time_ms)); 371 scroll_time_ms, pause_time_ms));
371 } 372 }
372 373
373 } // namespace test 374 } // namespace test
374 } // namespace webrtc 375 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698