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; |
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 Loading... |
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 if (mode == kScreensharing) |
| 148 encoded.content_type_ = VideoContentType::kScreenshare; |
| 149 else |
| 150 encoded.content_type_ = VideoContentType::kDefault; |
145 specifics.codec_name = ImplementationName(); | 151 specifics.codec_name = ImplementationName(); |
146 RTC_DCHECK(callback); | 152 RTC_DCHECK(callback); |
147 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error != | 153 if (callback->OnEncodedImage(encoded, &specifics, nullptr).error != |
148 EncodedImageCallback::Result::OK) { | 154 EncodedImageCallback::Result::OK) { |
149 return -1; | 155 return -1; |
150 } | 156 } |
151 bits_available -= std::min(encoded._length * 8, bits_available); | 157 bits_available -= std::min(encoded._length * 8, bits_available); |
152 } | 158 } |
153 return 0; | 159 return 0; |
154 } | 160 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); | 356 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
351 | 357 |
352 queue1_.reset(); | 358 queue1_.reset(); |
353 queue2_.reset(); | 359 queue2_.reset(); |
354 | 360 |
355 return FakeH264Encoder::Release(); | 361 return FakeH264Encoder::Release(); |
356 } | 362 } |
357 | 363 |
358 } // namespace test | 364 } // namespace test |
359 } // namespace webrtc | 365 } // namespace webrtc |
OLD | NEW |