| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 red_payload[0] = media_packet.PayloadType(); | 42 red_payload[0] = media_packet.PayloadType(); |
| 43 memcpy(&red_payload[kRedForFecHeaderLength], media_packet.payload(), | 43 memcpy(&red_payload[kRedForFecHeaderLength], media_packet.payload(), |
| 44 media_packet.payload_size()); | 44 media_packet.payload_size()); |
| 45 } | 45 } |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSender* rtp_sender) | 48 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSender* rtp_sender) |
| 49 : rtp_sender_(rtp_sender), | 49 : rtp_sender_(rtp_sender), |
| 50 clock_(clock), | 50 clock_(clock), |
| 51 fec_bitrate_(1000, RateStatistics::kBpsScale), | 51 fec_bitrate_(1000, RateStatistics::kBpsScale), |
| 52 video_bitrate_(1000, RateStatistics::kBpsScale) {} | 52 video_bitrate_(1000, RateStatistics::kBpsScale) { |
| 53 encoder_checker_.Detach(); |
| 54 } |
| 53 | 55 |
| 54 RTPSenderVideo::~RTPSenderVideo() {} | 56 RTPSenderVideo::~RTPSenderVideo() {} |
| 55 | 57 |
| 56 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) { | 58 void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) { |
| 57 video_type_ = video_type; | 59 video_type_ = video_type; |
| 58 } | 60 } |
| 59 | 61 |
| 60 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { | 62 RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { |
| 61 return video_type_; | 63 return video_type_; |
| 62 } | 64 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 223 |
| 222 bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, | 224 bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
| 223 FrameType frame_type, | 225 FrameType frame_type, |
| 224 int8_t payload_type, | 226 int8_t payload_type, |
| 225 uint32_t rtp_timestamp, | 227 uint32_t rtp_timestamp, |
| 226 int64_t capture_time_ms, | 228 int64_t capture_time_ms, |
| 227 const uint8_t* payload_data, | 229 const uint8_t* payload_data, |
| 228 size_t payload_size, | 230 size_t payload_size, |
| 229 const RTPFragmentationHeader* fragmentation, | 231 const RTPFragmentationHeader* fragmentation, |
| 230 const RTPVideoHeader* video_header) { | 232 const RTPVideoHeader* video_header) { |
| 233 RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_checker_); |
| 231 if (payload_size == 0) | 234 if (payload_size == 0) |
| 232 return false; | 235 return false; |
| 233 | 236 |
| 234 // Create header that will be reused in all packets. | 237 // Create header that will be reused in all packets. |
| 235 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); | 238 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); |
| 236 rtp_header->SetPayloadType(payload_type); | 239 rtp_header->SetPayloadType(payload_type); |
| 237 rtp_header->SetTimestamp(rtp_timestamp); | 240 rtp_header->SetTimestamp(rtp_timestamp); |
| 238 rtp_header->set_capture_time_ms(capture_time_ms); | 241 rtp_header->set_capture_time_ms(capture_time_ms); |
| 239 // According to | 242 // According to |
| 240 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 243 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 241 // ts_126114v120700p.pdf Section 7.4.5: | 244 // ts_126114v120700p.pdf Section 7.4.5: |
| 242 // The MTSI client shall add the payload bytes as defined in this clause | 245 // The MTSI client shall add the payload bytes as defined in this clause |
| 243 // onto the last RTP packet in each group of packets which make up a key | 246 // onto the last RTP packet in each group of packets which make up a key |
| 244 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 247 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| 245 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 248 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
| 246 // packet in each group of packets which make up another type of frame | 249 // packet in each group of packets which make up another type of frame |
| 247 // (e.g. a P-Frame) only if the current value is different from the previous | 250 // (e.g. a P-Frame) only if the current value is different from the previous |
| 248 // value sent. | 251 // value sent. |
| 249 // Here we are adding it to every packet of every frame at this point. | 252 if (video_header) { |
| 250 if (video_header && video_header->rotation != kVideoRotation_0) | 253 // Set rotation when key frame or when changed (to follow standard). |
| 251 rtp_header->SetExtension<VideoOrientation>(video_header->rotation); | 254 // Or when different from 0 (to follow current receiver implementation). |
| 255 VideoRotation current_rotation = video_header->rotation; |
| 256 if (frame_type == kVideoFrameKey || |
| 257 current_rotation != last_rotation_ || |
| 258 current_rotation != kVideoRotation_0) |
| 259 rtp_header->SetExtension<VideoOrientation>(current_rotation); |
| 260 last_rotation_ = current_rotation; |
| 261 } |
| 252 | 262 |
| 253 size_t packet_capacity = rtp_sender_->MaxPayloadLength() - | 263 size_t packet_capacity = rtp_sender_->MaxPayloadLength() - |
| 254 FecPacketOverhead() - | 264 FecPacketOverhead() - |
| 255 (rtp_sender_->RtxStatus() ? kRtxHeaderSize : 0); | 265 (rtp_sender_->RtxStatus() ? kRtxHeaderSize : 0); |
| 256 RTC_DCHECK_LE(packet_capacity, rtp_header->capacity()); | 266 RTC_DCHECK_LE(packet_capacity, rtp_header->capacity()); |
| 257 RTC_DCHECK_GT(packet_capacity, rtp_header->headers_size()); | 267 RTC_DCHECK_GT(packet_capacity, rtp_header->headers_size()); |
| 258 size_t max_data_payload_length = packet_capacity - rtp_header->headers_size(); | 268 size_t max_data_payload_length = packet_capacity - rtp_header->headers_size(); |
| 259 | 269 |
| 260 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 270 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( |
| 261 video_type, max_data_payload_length, | 271 video_type, max_data_payload_length, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 rtc::CritScope cs(&crit_); | 346 rtc::CritScope cs(&crit_); |
| 337 return retransmission_settings_; | 347 return retransmission_settings_; |
| 338 } | 348 } |
| 339 | 349 |
| 340 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 350 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 341 rtc::CritScope cs(&crit_); | 351 rtc::CritScope cs(&crit_); |
| 342 retransmission_settings_ = settings; | 352 retransmission_settings_ = settings; |
| 343 } | 353 } |
| 344 | 354 |
| 345 } // namespace webrtc | 355 } // namespace webrtc |
| OLD | NEW |