| 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 |
| 11 #include "webrtc/video/video_send_stream.h" | 11 #include "webrtc/video/video_send_stream.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/base/trace_event.h" | 20 #include "webrtc/base/trace_event.h" |
| 21 #include "webrtc/call/congestion_controller.h" | 21 #include "webrtc/call/congestion_controller.h" |
| 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 23 #include "webrtc/modules/pacing/include/packet_router.h" | 23 #include "webrtc/modules/pacing/include/packet_router.h" |
| 24 #include "webrtc/video/video_capture_input.h" | 24 #include "webrtc/video/video_capture_input.h" |
| 25 #include "webrtc/video_engine/call_stats.h" | 25 #include "webrtc/video_engine/call_stats.h" |
| 26 #include "webrtc/video_engine/encoder_state_feedback.h" | 26 #include "webrtc/video_engine/encoder_state_feedback.h" |
| 27 #include "webrtc/video_engine/payload_router.h" | 27 #include "webrtc/video_engine/payload_router.h" |
| 28 #include "webrtc/video_engine/vie_channel.h" | 28 #include "webrtc/video_engine/vie_channel.h" |
| 29 #include "webrtc/video_engine/vie_defines.h" | |
| 30 #include "webrtc/video_engine/vie_encoder.h" | 29 #include "webrtc/video_engine/vie_encoder.h" |
| 31 #include "webrtc/video_send_stream.h" | 30 #include "webrtc/video_send_stream.h" |
| 32 | 31 |
| 33 namespace webrtc { | 32 namespace webrtc { |
| 34 | 33 |
| 35 class BitrateAllocator; | 34 class BitrateAllocator; |
| 36 class PacedSender; | 35 class PacedSender; |
| 37 class RtcpIntraFrameObserver; | 36 class RtcpIntraFrameObserver; |
| 38 class TransportFeedbackObserver; | 37 class TransportFeedbackObserver; |
| 39 | 38 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 int64_t rtt_ms; | 520 int64_t rtt_ms; |
| 522 if (vie_channel_->GetSendRtcpStatistics(&frac_lost, &cumulative_lost, | 521 if (vie_channel_->GetSendRtcpStatistics(&frac_lost, &cumulative_lost, |
| 523 &extended_max_sequence_number, | 522 &extended_max_sequence_number, |
| 524 &jitter, &rtt_ms) == 0) { | 523 &jitter, &rtt_ms) == 0) { |
| 525 return rtt_ms; | 524 return rtt_ms; |
| 526 } | 525 } |
| 527 return -1; | 526 return -1; |
| 528 } | 527 } |
| 529 | 528 |
| 530 bool VideoSendStream::SetSendCodec(VideoCodec video_codec) { | 529 bool VideoSendStream::SetSendCodec(VideoCodec video_codec) { |
| 530 static const int kEncoderMinBitrate = 30; |
| 531 if (video_codec.maxBitrate == 0) { | 531 if (video_codec.maxBitrate == 0) { |
| 532 // Unset max bitrate -> cap to one bit per pixel. | 532 // Unset max bitrate -> cap to one bit per pixel. |
| 533 video_codec.maxBitrate = | 533 video_codec.maxBitrate = |
| 534 (video_codec.width * video_codec.height * video_codec.maxFramerate) / | 534 (video_codec.width * video_codec.height * video_codec.maxFramerate) / |
| 535 1000; | 535 1000; |
| 536 } | 536 } |
| 537 | 537 |
| 538 if (video_codec.minBitrate < kViEMinCodecBitrate) | 538 if (video_codec.minBitrate < kEncoderMinBitrate) |
| 539 video_codec.minBitrate = kViEMinCodecBitrate; | 539 video_codec.minBitrate = kEncoderMinBitrate; |
| 540 if (video_codec.maxBitrate < kViEMinCodecBitrate) | 540 if (video_codec.maxBitrate < kEncoderMinBitrate) |
| 541 video_codec.maxBitrate = kViEMinCodecBitrate; | 541 video_codec.maxBitrate = kEncoderMinBitrate; |
| 542 | 542 |
| 543 // Stop the media flow while reconfiguring. | 543 // Stop the media flow while reconfiguring. |
| 544 vie_encoder_->Pause(); | 544 vie_encoder_->Pause(); |
| 545 | 545 |
| 546 if (vie_encoder_->SetEncoder(video_codec) != 0) { | 546 if (vie_encoder_->SetEncoder(video_codec) != 0) { |
| 547 LOG(LS_ERROR) << "Failed to set encoder."; | 547 LOG(LS_ERROR) << "Failed to set encoder."; |
| 548 return false; | 548 return false; |
| 549 } | 549 } |
| 550 | 550 |
| 551 if (vie_channel_->SetSendCodec(video_codec, false) != 0) { | 551 if (vie_channel_->SetSendCodec(video_codec, false) != 0) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 566 vie_channel_->IsSendingFecEnabled()); | 566 vie_channel_->IsSendingFecEnabled()); |
| 567 | 567 |
| 568 // Restart the media flow | 568 // Restart the media flow |
| 569 vie_encoder_->Restart(); | 569 vie_encoder_->Restart(); |
| 570 | 570 |
| 571 return true; | 571 return true; |
| 572 } | 572 } |
| 573 | 573 |
| 574 } // namespace internal | 574 } // namespace internal |
| 575 } // namespace webrtc | 575 } // namespace webrtc |
| OLD | NEW |