OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 break; | 68 break; |
69 } | 69 } |
70 | 70 |
71 if (config.encoder_specific_settings) | 71 if (config.encoder_specific_settings) |
72 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); | 72 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); |
73 | 73 |
74 switch (video_codec.codecType) { | 74 switch (video_codec.codecType) { |
75 case kVideoCodecVP8: { | 75 case kVideoCodecVP8: { |
76 if (!config.encoder_specific_settings) | 76 if (!config.encoder_specific_settings) |
77 *video_codec.VP8() = VideoEncoder::GetDefaultVp8Settings(); | 77 video_codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings(); |
78 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>( | 78 video_codec.codecSpecific.VP8.numberOfTemporalLayers = |
79 streams.back().temporal_layer_thresholds_bps.size() + 1); | 79 static_cast<unsigned char>( |
| 80 streams.back().temporal_layer_thresholds_bps.size() + 1); |
80 break; | 81 break; |
81 } | 82 } |
82 case kVideoCodecVP9: { | 83 case kVideoCodecVP9: { |
83 if (!config.encoder_specific_settings) | 84 if (!config.encoder_specific_settings) |
84 *video_codec.VP9() = VideoEncoder::GetDefaultVp9Settings(); | 85 video_codec.codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings(); |
85 if (video_codec.mode == kScreensharing && | 86 if (video_codec.mode == kScreensharing && |
86 config.encoder_specific_settings) { | 87 config.encoder_specific_settings) { |
87 video_codec.VP9()->flexibleMode = true; | 88 video_codec.codecSpecific.VP9.flexibleMode = true; |
88 // For now VP9 screensharing use 1 temporal and 2 spatial layers. | 89 // For now VP9 screensharing use 1 temporal and 2 spatial layers. |
89 RTC_DCHECK_EQ(1, video_codec.VP9()->numberOfTemporalLayers); | 90 RTC_DCHECK_EQ(1, video_codec.codecSpecific.VP9.numberOfTemporalLayers); |
90 RTC_DCHECK_EQ(2, video_codec.VP9()->numberOfSpatialLayers); | 91 RTC_DCHECK_EQ(2, video_codec.codecSpecific.VP9.numberOfSpatialLayers); |
91 } | 92 } |
92 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>( | 93 video_codec.codecSpecific.VP9.numberOfTemporalLayers = |
93 streams.back().temporal_layer_thresholds_bps.size() + 1); | 94 static_cast<unsigned char>( |
| 95 streams.back().temporal_layer_thresholds_bps.size() + 1); |
94 break; | 96 break; |
95 } | 97 } |
96 case kVideoCodecH264: { | 98 case kVideoCodecH264: { |
97 if (!config.encoder_specific_settings) | 99 if (!config.encoder_specific_settings) |
98 *video_codec.H264() = VideoEncoder::GetDefaultH264Settings(); | 100 video_codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings(); |
99 break; | 101 break; |
100 } | 102 } |
101 default: | 103 default: |
102 // TODO(pbos): Support encoder_settings codec-agnostically. | 104 // TODO(pbos): Support encoder_settings codec-agnostically. |
103 RTC_DCHECK(!config.encoder_specific_settings) | 105 RTC_DCHECK(!config.encoder_specific_settings) |
104 << "Encoder-specific settings for codec type not wired up."; | 106 << "Encoder-specific settings for codec type not wired up."; |
105 break; | 107 break; |
106 } | 108 } |
107 | 109 |
108 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); | 110 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); |
109 video_codec.plName[kPayloadNameSize - 1] = '\0'; | 111 video_codec.plName[kPayloadNameSize - 1] = '\0'; |
110 video_codec.plType = payload_type; | 112 video_codec.plType = payload_type; |
111 video_codec.numberOfSimulcastStreams = | 113 video_codec.numberOfSimulcastStreams = |
112 static_cast<unsigned char>(streams.size()); | 114 static_cast<unsigned char>(streams.size()); |
113 video_codec.minBitrate = streams[0].min_bitrate_bps / 1000; | 115 video_codec.minBitrate = streams[0].min_bitrate_bps / 1000; |
114 if (video_codec.minBitrate < kEncoderMinBitrateKbps) | 116 if (video_codec.minBitrate < kEncoderMinBitrateKbps) |
115 video_codec.minBitrate = kEncoderMinBitrateKbps; | 117 video_codec.minBitrate = kEncoderMinBitrateKbps; |
116 RTC_DCHECK_LE(streams.size(), static_cast<size_t>(kMaxSimulcastStreams)); | 118 RTC_DCHECK_LE(streams.size(), static_cast<size_t>(kMaxSimulcastStreams)); |
117 if (video_codec.codecType == kVideoCodecVP9) { | 119 if (video_codec.codecType == kVideoCodecVP9) { |
118 // If the vector is empty, bitrates will be configured automatically. | 120 // If the vector is empty, bitrates will be configured automatically. |
119 RTC_DCHECK(config.spatial_layers.empty() || | 121 RTC_DCHECK(config.spatial_layers.empty() || |
120 config.spatial_layers.size() == | 122 config.spatial_layers.size() == |
121 video_codec.VP9()->numberOfSpatialLayers); | 123 video_codec.codecSpecific.VP9.numberOfSpatialLayers); |
122 RTC_DCHECK_LE(video_codec.VP9()->numberOfSpatialLayers, | 124 RTC_DCHECK_LE(video_codec.codecSpecific.VP9.numberOfSpatialLayers, |
123 kMaxSimulcastStreams); | 125 kMaxSimulcastStreams); |
124 for (size_t i = 0; i < config.spatial_layers.size(); ++i) | 126 for (size_t i = 0; i < config.spatial_layers.size(); ++i) |
125 video_codec.spatialLayers[i] = config.spatial_layers[i]; | 127 video_codec.spatialLayers[i] = config.spatial_layers[i]; |
126 } | 128 } |
127 for (size_t i = 0; i < streams.size(); ++i) { | 129 for (size_t i = 0; i < streams.size(); ++i) { |
128 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; | 130 SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; |
129 RTC_DCHECK_GT(streams[i].width, 0u); | 131 RTC_DCHECK_GT(streams[i].width, 0u); |
130 RTC_DCHECK_GT(streams[i].height, 0u); | 132 RTC_DCHECK_GT(streams[i].height, 0u); |
131 RTC_DCHECK_GT(streams[i].max_framerate, 0); | 133 RTC_DCHECK_GT(streams[i].max_framerate, 0); |
132 // Different framerates not supported per stream at the moment. | 134 // Different framerates not supported per stream at the moment. |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 656 |
655 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), | 657 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), |
656 "Encode"); | 658 "Encode"); |
657 | 659 |
658 overuse_detector_.FrameCaptured(video_frame, time_when_posted_in_ms); | 660 overuse_detector_.FrameCaptured(video_frame, time_when_posted_in_ms); |
659 | 661 |
660 if (codec_type_ == webrtc::kVideoCodecVP8) { | 662 if (codec_type_ == webrtc::kVideoCodecVP8) { |
661 webrtc::CodecSpecificInfo codec_specific_info; | 663 webrtc::CodecSpecificInfo codec_specific_info; |
662 codec_specific_info.codecType = webrtc::kVideoCodecVP8; | 664 codec_specific_info.codecType = webrtc::kVideoCodecVP8; |
663 | 665 |
664 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = has_received_rpsi_; | 666 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = |
665 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = has_received_sli_; | 667 has_received_rpsi_; |
666 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = picture_id_rpsi_; | 668 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = |
667 codec_specific_info.codecSpecific.VP8.pictureIdSLI = picture_id_sli_; | 669 has_received_sli_; |
668 has_received_sli_ = false; | 670 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = |
669 has_received_rpsi_ = false; | 671 picture_id_rpsi_; |
| 672 codec_specific_info.codecSpecific.VP8.pictureIdSLI = |
| 673 picture_id_sli_; |
| 674 has_received_sli_ = false; |
| 675 has_received_rpsi_ = false; |
670 | 676 |
671 video_sender_.AddVideoFrame(video_frame, &codec_specific_info); | 677 video_sender_.AddVideoFrame(video_frame, &codec_specific_info); |
672 return; | 678 return; |
673 } | 679 } |
674 video_sender_.AddVideoFrame(video_frame, nullptr); | 680 video_sender_.AddVideoFrame(video_frame, nullptr); |
675 } | 681 } |
676 | 682 |
677 void ViEEncoder::SendKeyFrame() { | 683 void ViEEncoder::SendKeyFrame() { |
678 if (!encoder_queue_.IsCurrent()) { | 684 if (!encoder_queue_.IsCurrent()) { |
679 encoder_queue_.PostTask([this] { SendKeyFrame(); }); | 685 encoder_queue_.PostTask([this] { SendKeyFrame(); }); |
680 return; | 686 return; |
681 } | 687 } |
682 RTC_DCHECK_RUN_ON(&encoder_queue_); | 688 RTC_DCHECK_RUN_ON(&encoder_queue_); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 current_pixel_count > *max_pixel_count_step_up_) { | 824 current_pixel_count > *max_pixel_count_step_up_) { |
819 max_pixel_count_ = rtc::Optional<int>(); | 825 max_pixel_count_ = rtc::Optional<int>(); |
820 max_pixel_count_step_up_ = rtc::Optional<int>(current_pixel_count); | 826 max_pixel_count_step_up_ = rtc::Optional<int>(current_pixel_count); |
821 --cpu_restricted_counter_; | 827 --cpu_restricted_counter_; |
822 stats_proxy_->OnCpuRestrictedResolutionChanged(cpu_restricted_counter_ > 0); | 828 stats_proxy_->OnCpuRestrictedResolutionChanged(cpu_restricted_counter_ > 0); |
823 source_proxy_->RequestHigherResolutionThan(current_pixel_count); | 829 source_proxy_->RequestHigherResolutionThan(current_pixel_count); |
824 } | 830 } |
825 } | 831 } |
826 | 832 |
827 } // namespace webrtc | 833 } // namespace webrtc |
OLD | NEW |