OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 #include "webrtc/call/video_config.h" |
| 11 |
| 12 #include <algorithm> |
| 13 #include <sstream> |
| 14 #include <string> |
| 15 |
| 16 #include "webrtc/rtc_base/checks.h" |
| 17 |
| 18 namespace webrtc { |
| 19 VideoStream::VideoStream() |
| 20 : width(0), |
| 21 height(0), |
| 22 max_framerate(-1), |
| 23 min_bitrate_bps(-1), |
| 24 target_bitrate_bps(-1), |
| 25 max_bitrate_bps(-1), |
| 26 max_qp(-1) {} |
| 27 |
| 28 VideoStream::~VideoStream() = default; |
| 29 |
| 30 std::string VideoStream::ToString() const { |
| 31 std::stringstream ss; |
| 32 ss << "{width: " << width; |
| 33 ss << ", height: " << height; |
| 34 ss << ", max_framerate: " << max_framerate; |
| 35 ss << ", min_bitrate_bps:" << min_bitrate_bps; |
| 36 ss << ", target_bitrate_bps:" << target_bitrate_bps; |
| 37 ss << ", max_bitrate_bps:" << max_bitrate_bps; |
| 38 ss << ", max_qp: " << max_qp; |
| 39 |
| 40 ss << ", temporal_layer_thresholds_bps: ["; |
| 41 for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) { |
| 42 ss << temporal_layer_thresholds_bps[i]; |
| 43 if (i != temporal_layer_thresholds_bps.size() - 1) |
| 44 ss << ", "; |
| 45 } |
| 46 ss << ']'; |
| 47 |
| 48 ss << '}'; |
| 49 return ss.str(); |
| 50 } |
| 51 |
| 52 VideoEncoderConfig::VideoEncoderConfig() |
| 53 : content_type(ContentType::kRealtimeVideo), |
| 54 encoder_specific_settings(nullptr), |
| 55 min_transmit_bitrate_bps(0), |
| 56 max_bitrate_bps(0), |
| 57 number_of_streams(0) {} |
| 58 |
| 59 VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default; |
| 60 |
| 61 VideoEncoderConfig::~VideoEncoderConfig() = default; |
| 62 |
| 63 std::string VideoEncoderConfig::ToString() const { |
| 64 std::stringstream ss; |
| 65 ss << "{content_type: "; |
| 66 switch (content_type) { |
| 67 case ContentType::kRealtimeVideo: |
| 68 ss << "kRealtimeVideo"; |
| 69 break; |
| 70 case ContentType::kScreen: |
| 71 ss << "kScreenshare"; |
| 72 break; |
| 73 } |
| 74 ss << ", encoder_specific_settings: "; |
| 75 ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); |
| 76 |
| 77 ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; |
| 78 ss << '}'; |
| 79 return ss.str(); |
| 80 } |
| 81 |
| 82 VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default; |
| 83 |
| 84 void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings( |
| 85 VideoCodec* codec) const { |
| 86 if (codec->codecType == kVideoCodecH264) { |
| 87 FillVideoCodecH264(codec->H264()); |
| 88 } else if (codec->codecType == kVideoCodecVP8) { |
| 89 FillVideoCodecVp8(codec->VP8()); |
| 90 } else if (codec->codecType == kVideoCodecVP9) { |
| 91 FillVideoCodecVp9(codec->VP9()); |
| 92 } else { |
| 93 RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type."; |
| 94 } |
| 95 } |
| 96 |
| 97 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264( |
| 98 VideoCodecH264* h264_settings) const { |
| 99 RTC_NOTREACHED(); |
| 100 } |
| 101 |
| 102 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8( |
| 103 VideoCodecVP8* vp8_settings) const { |
| 104 RTC_NOTREACHED(); |
| 105 } |
| 106 |
| 107 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9( |
| 108 VideoCodecVP9* vp9_settings) const { |
| 109 RTC_NOTREACHED(); |
| 110 } |
| 111 |
| 112 VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings( |
| 113 const VideoCodecH264& specifics) |
| 114 : specifics_(specifics) {} |
| 115 |
| 116 void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264( |
| 117 VideoCodecH264* h264_settings) const { |
| 118 *h264_settings = specifics_; |
| 119 } |
| 120 |
| 121 VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings( |
| 122 const VideoCodecVP8& specifics) |
| 123 : specifics_(specifics) {} |
| 124 |
| 125 void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8( |
| 126 VideoCodecVP8* vp8_settings) const { |
| 127 *vp8_settings = specifics_; |
| 128 } |
| 129 |
| 130 VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings( |
| 131 const VideoCodecVP9& specifics) |
| 132 : specifics_(specifics) {} |
| 133 |
| 134 void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9( |
| 135 VideoCodecVP9* vp9_settings) const { |
| 136 *vp9_settings = specifics_; |
| 137 } |
| 138 |
| 139 } // namespace webrtc |
OLD | NEW |