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

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

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix typo, leading to failed video catpure test 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
« no previous file with comments | « webrtc/test/constants.cc ('k') | webrtc/test/fuzzers/rtp_packet_fuzzer.cc » ('j') | 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) 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 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const CodecSpecificInfo* codec_specific_info, 54 const CodecSpecificInfo* codec_specific_info,
55 const std::vector<FrameType>* frame_types) { 55 const std::vector<FrameType>* frame_types) {
56 unsigned char max_framerate; 56 unsigned char max_framerate;
57 unsigned char num_simulcast_streams; 57 unsigned char num_simulcast_streams;
58 SimulcastStream simulcast_streams[kMaxSimulcastStreams]; 58 SimulcastStream simulcast_streams[kMaxSimulcastStreams];
59 EncodedImageCallback* callback; 59 EncodedImageCallback* callback;
60 uint32_t target_bitrate_sum_kbps; 60 uint32_t target_bitrate_sum_kbps;
61 int max_target_bitrate_kbps; 61 int max_target_bitrate_kbps;
62 int64_t last_encode_time_ms; 62 int64_t last_encode_time_ms;
63 size_t num_encoded_bytes; 63 size_t num_encoded_bytes;
64 VideoCodecMode mode;
64 { 65 {
65 rtc::CritScope cs(&crit_sect_); 66 rtc::CritScope cs(&crit_sect_);
66 max_framerate = config_.maxFramerate; 67 max_framerate = config_.maxFramerate;
67 num_simulcast_streams = config_.numberOfSimulcastStreams; 68 num_simulcast_streams = config_.numberOfSimulcastStreams;
68 for (int i = 0; i < num_simulcast_streams; ++i) { 69 for (int i = 0; i < num_simulcast_streams; ++i) {
69 simulcast_streams[i] = config_.simulcastStream[i]; 70 simulcast_streams[i] = config_.simulcastStream[i];
70 } 71 }
71 callback = callback_; 72 callback = callback_;
72 target_bitrate_sum_kbps = target_bitrate_.get_sum_kbps(); 73 target_bitrate_sum_kbps = target_bitrate_.get_sum_kbps();
73 max_target_bitrate_kbps = max_target_bitrate_kbps_; 74 max_target_bitrate_kbps = max_target_bitrate_kbps_;
74 last_encode_time_ms = last_encode_time_ms_; 75 last_encode_time_ms = last_encode_time_ms_;
75 num_encoded_bytes = sizeof(encoded_buffer_); 76 num_encoded_bytes = sizeof(encoded_buffer_);
77 mode = config_.mode;
76 } 78 }
77 79
78 int64_t time_now_ms = clock_->TimeInMilliseconds(); 80 int64_t time_now_ms = clock_->TimeInMilliseconds();
79 const bool first_encode = (last_encode_time_ms == 0); 81 const bool first_encode = (last_encode_time_ms == 0);
80 RTC_DCHECK_GT(max_framerate, 0); 82 RTC_DCHECK_GT(max_framerate, 0);
81 int64_t time_since_last_encode_ms = 1000 / max_framerate; 83 int64_t time_since_last_encode_ms = 1000 / max_framerate;
82 if (!first_encode) { 84 if (!first_encode) {
83 // For all frames but the first we can estimate the display time by looking 85 // For all frames but the first we can estimate the display time by looking
84 // at the display time of the previous frame. 86 // at the display time of the previous frame.
85 time_since_last_encode_ms = time_now_ms - last_encode_time_ms; 87 time_since_last_encode_ms = time_now_ms - last_encode_time_ms;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 std::unique_ptr<uint8_t[]> encoded_buffer(new uint8_t[num_encoded_bytes]); 138 std::unique_ptr<uint8_t[]> encoded_buffer(new uint8_t[num_encoded_bytes]);
137 memcpy(encoded_buffer.get(), encoded_buffer_, num_encoded_bytes); 139 memcpy(encoded_buffer.get(), encoded_buffer_, num_encoded_bytes);
138 EncodedImage encoded(encoded_buffer.get(), stream_bytes, num_encoded_bytes); 140 EncodedImage encoded(encoded_buffer.get(), stream_bytes, num_encoded_bytes);
139 encoded._timeStamp = input_image.timestamp(); 141 encoded._timeStamp = input_image.timestamp();
140 encoded.capture_time_ms_ = input_image.render_time_ms(); 142 encoded.capture_time_ms_ = input_image.render_time_ms();
141 encoded._frameType = (*frame_types)[i]; 143 encoded._frameType = (*frame_types)[i];
142 encoded._encodedWidth = simulcast_streams[i].width; 144 encoded._encodedWidth = simulcast_streams[i].width;
143 encoded._encodedHeight = simulcast_streams[i].height; 145 encoded._encodedHeight = simulcast_streams[i].height;
144 encoded.rotation_ = input_image.rotation(); 146 encoded.rotation_ = input_image.rotation();
147 encoded.content_type_ = (mode == kScreensharing)
148 ? VideoContentType::SCREENSHARE
149 : VideoContentType::UNSPECIFIED;
145 specifics.codec_name = ImplementationName(); 150 specifics.codec_name = ImplementationName();
146 RTC_DCHECK(callback); 151 RTC_DCHECK(callback);
147 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error != 152 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error !=
148 EncodedImageCallback::Result::OK) { 153 EncodedImageCallback::Result::OK) {
149 return -1; 154 return -1;
150 } 155 }
151 bits_available -= std::min(encoded._length * 8, bits_available); 156 bits_available -= std::min(encoded._length * 8, bits_available);
152 } 157 }
153 return 0; 158 return 0;
154 } 159 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); 355 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
351 356
352 queue1_.reset(); 357 queue1_.reset();
353 queue2_.reset(); 358 queue2_.reset();
354 359
355 return FakeH264Encoder::Release(); 360 return FakeH264Encoder::Release();
356 } 361 }
357 362
358 } // namespace test 363 } // namespace test
359 } // namespace webrtc 364 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/constants.cc ('k') | webrtc/test/fuzzers/rtp_packet_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698