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