OLD | NEW |
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 Loading... |
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; | |
65 { | 64 { |
66 rtc::CritScope cs(&crit_sect_); | 65 rtc::CritScope cs(&crit_sect_); |
67 max_framerate = config_.maxFramerate; | 66 max_framerate = config_.maxFramerate; |
68 num_simulcast_streams = config_.numberOfSimulcastStreams; | 67 num_simulcast_streams = config_.numberOfSimulcastStreams; |
69 for (int i = 0; i < num_simulcast_streams; ++i) { | 68 for (int i = 0; i < num_simulcast_streams; ++i) { |
70 simulcast_streams[i] = config_.simulcastStream[i]; | 69 simulcast_streams[i] = config_.simulcastStream[i]; |
71 } | 70 } |
72 callback = callback_; | 71 callback = callback_; |
73 target_bitrate_sum_kbps = target_bitrate_.get_sum_kbps(); | 72 target_bitrate_sum_kbps = target_bitrate_.get_sum_kbps(); |
74 max_target_bitrate_kbps = max_target_bitrate_kbps_; | 73 max_target_bitrate_kbps = max_target_bitrate_kbps_; |
75 last_encode_time_ms = last_encode_time_ms_; | 74 last_encode_time_ms = last_encode_time_ms_; |
76 num_encoded_bytes = sizeof(encoded_buffer_); | 75 num_encoded_bytes = sizeof(encoded_buffer_); |
77 mode = config_.mode; | |
78 } | 76 } |
79 | 77 |
80 int64_t time_now_ms = clock_->TimeInMilliseconds(); | 78 int64_t time_now_ms = clock_->TimeInMilliseconds(); |
81 const bool first_encode = (last_encode_time_ms == 0); | 79 const bool first_encode = (last_encode_time_ms == 0); |
82 RTC_DCHECK_GT(max_framerate, 0); | 80 RTC_DCHECK_GT(max_framerate, 0); |
83 int64_t time_since_last_encode_ms = 1000 / max_framerate; | 81 int64_t time_since_last_encode_ms = 1000 / max_framerate; |
84 if (!first_encode) { | 82 if (!first_encode) { |
85 // For all frames but the first we can estimate the display time by looking | 83 // For all frames but the first we can estimate the display time by looking |
86 // at the display time of the previous frame. | 84 // at the display time of the previous frame. |
87 time_since_last_encode_ms = time_now_ms - last_encode_time_ms; | 85 time_since_last_encode_ms = time_now_ms - last_encode_time_ms; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 135 |
138 std::unique_ptr<uint8_t[]> encoded_buffer(new uint8_t[num_encoded_bytes]); | 136 std::unique_ptr<uint8_t[]> encoded_buffer(new uint8_t[num_encoded_bytes]); |
139 memcpy(encoded_buffer.get(), encoded_buffer_, num_encoded_bytes); | 137 memcpy(encoded_buffer.get(), encoded_buffer_, num_encoded_bytes); |
140 EncodedImage encoded(encoded_buffer.get(), stream_bytes, num_encoded_bytes); | 138 EncodedImage encoded(encoded_buffer.get(), stream_bytes, num_encoded_bytes); |
141 encoded._timeStamp = input_image.timestamp(); | 139 encoded._timeStamp = input_image.timestamp(); |
142 encoded.capture_time_ms_ = input_image.render_time_ms(); | 140 encoded.capture_time_ms_ = input_image.render_time_ms(); |
143 encoded._frameType = (*frame_types)[i]; | 141 encoded._frameType = (*frame_types)[i]; |
144 encoded._encodedWidth = simulcast_streams[i].width; | 142 encoded._encodedWidth = simulcast_streams[i].width; |
145 encoded._encodedHeight = simulcast_streams[i].height; | 143 encoded._encodedHeight = simulcast_streams[i].height; |
146 encoded.rotation_ = input_image.rotation(); | 144 encoded.rotation_ = input_image.rotation(); |
147 encoded.content_type_ = (mode == kScreensharing) | |
148 ? VideoContentType::SCREENSHARE | |
149 : VideoContentType::UNSPECIFIED; | |
150 specifics.codec_name = ImplementationName(); | 145 specifics.codec_name = ImplementationName(); |
151 RTC_DCHECK(callback); | 146 RTC_DCHECK(callback); |
152 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error != | 147 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error != |
153 EncodedImageCallback::Result::OK) { | 148 EncodedImageCallback::Result::OK) { |
154 return -1; | 149 return -1; |
155 } | 150 } |
156 bits_available -= std::min(encoded._length * 8, bits_available); | 151 bits_available -= std::min(encoded._length * 8, bits_available); |
157 } | 152 } |
158 return 0; | 153 return 0; |
159 } | 154 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); | 350 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
356 | 351 |
357 queue1_.reset(); | 352 queue1_.reset(); |
358 queue2_.reset(); | 353 queue2_.reset(); |
359 | 354 |
360 return FakeH264Encoder::Release(); | 355 return FakeH264Encoder::Release(); |
361 } | 356 } |
362 | 357 |
363 } // namespace test | 358 } // namespace test |
364 } // namespace webrtc | 359 } // namespace webrtc |
OLD | NEW |