2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h"
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2014-02-18 08:40:33 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/producer_fec.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
2014-04-08 11:06:12 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/logging.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/trace_event.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
enum { REDForFECHeaderLength = 1 };
|
|
|
|
|
|
2012-03-20 22:10:56 +00:00
|
|
|
struct RtpPacket {
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t rtpHeaderLength;
|
2012-03-20 22:10:56 +00:00
|
|
|
ForwardErrorCorrection::Packet* pkt;
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender)
|
2014-04-08 11:06:12 +00:00
|
|
|
: _rtpSender(*rtpSender),
|
2013-12-13 09:46:59 +00:00
|
|
|
_videoType(kRtpVideoGeneric),
|
|
|
|
|
_videoCodecInformation(NULL),
|
|
|
|
|
_maxBitrate(0),
|
|
|
|
|
_retransmissionSettings(kRetransmitBaseLayer),
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-12-13 09:46:59 +00:00
|
|
|
// Generic FEC
|
2014-04-08 11:06:12 +00:00
|
|
|
_fec(),
|
2013-12-13 09:46:59 +00:00
|
|
|
_fecEnabled(false),
|
|
|
|
|
_payloadTypeRED(-1),
|
|
|
|
|
_payloadTypeFEC(-1),
|
|
|
|
|
_numberFirstPartition(0),
|
|
|
|
|
delta_fec_params_(),
|
|
|
|
|
key_fec_params_(),
|
|
|
|
|
producer_fec_(&_fec),
|
|
|
|
|
_fecOverheadRate(clock, NULL),
|
|
|
|
|
_videoBitrate(clock, NULL) {
|
2012-03-20 22:10:56 +00:00
|
|
|
memset(&delta_fec_params_, 0, sizeof(delta_fec_params_));
|
|
|
|
|
memset(&key_fec_params_, 0, sizeof(key_fec_params_));
|
|
|
|
|
delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
|
2012-07-13 16:27:51 +00:00
|
|
|
delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
|
2014-09-12 11:05:55 +00:00
|
|
|
kFecMaskRandom;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
RTPSenderVideo::~RTPSenderVideo() {
|
|
|
|
|
if (_videoCodecInformation) {
|
|
|
|
|
delete _videoCodecInformation;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes videoType) {
|
|
|
|
|
_videoType = videoType;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const {
|
|
|
|
|
return _videoType;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t RTPSenderVideo::RegisterVideoPayload(
|
2012-01-20 06:59:06 +00:00
|
|
|
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
2013-04-08 11:08:41 +00:00
|
|
|
const int8_t payloadType,
|
|
|
|
|
const uint32_t maxBitRate,
|
2014-07-08 12:10:51 +00:00
|
|
|
RtpUtility::Payload*& payload) {
|
2013-08-15 23:38:54 +00:00
|
|
|
RtpVideoCodecTypes videoType = kRtpVideoGeneric;
|
2014-07-08 12:10:51 +00:00
|
|
|
if (RtpUtility::StringCompare(payloadName, "VP8", 3)) {
|
2013-08-15 23:38:54 +00:00
|
|
|
videoType = kRtpVideoVp8;
|
2014-07-08 12:10:51 +00:00
|
|
|
} else if (RtpUtility::StringCompare(payloadName, "H264", 4)) {
|
2014-07-04 12:42:07 +00:00
|
|
|
videoType = kRtpVideoH264;
|
2014-07-08 12:10:51 +00:00
|
|
|
} else if (RtpUtility::StringCompare(payloadName, "I420", 4)) {
|
2013-08-15 23:38:54 +00:00
|
|
|
videoType = kRtpVideoGeneric;
|
2012-01-20 06:59:06 +00:00
|
|
|
} else {
|
2013-08-15 23:38:54 +00:00
|
|
|
videoType = kRtpVideoGeneric;
|
2012-01-20 06:59:06 +00:00
|
|
|
}
|
2014-07-08 12:10:51 +00:00
|
|
|
payload = new RtpUtility::Payload;
|
2012-01-24 17:16:59 +00:00
|
|
|
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
|
2012-01-20 06:59:06 +00:00
|
|
|
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
|
|
|
|
|
payload->typeSpecific.Video.videoCodecType = videoType;
|
|
|
|
|
payload->typeSpecific.Video.maxRate = maxBitRate;
|
|
|
|
|
payload->audio = false;
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
int32_t RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t payload_length,
|
|
|
|
|
const size_t rtp_header_length,
|
2014-09-12 11:05:55 +00:00
|
|
|
const uint32_t capture_timestamp,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
StorageType storage,
|
|
|
|
|
bool protect) {
|
|
|
|
|
if (_fecEnabled) {
|
2012-03-20 22:10:56 +00:00
|
|
|
int ret = 0;
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t fec_overhead_sent = 0;
|
|
|
|
|
size_t video_sent = 0;
|
2012-03-20 22:10:56 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
RedPacket* red_packet = producer_fec_.BuildRedPacket(
|
|
|
|
|
data_buffer, payload_length, rtp_header_length, _payloadTypeRED);
|
2015-02-16 12:06:00 +00:00
|
|
|
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
|
|
|
|
|
"Video::PacketRed", "timestamp", capture_timestamp,
|
|
|
|
|
"seqnum", _rtpSender.SequenceNumber());
|
2012-03-20 22:10:56 +00:00
|
|
|
// Sending the media packet with RED header.
|
2014-09-12 11:05:55 +00:00
|
|
|
int packet_success =
|
|
|
|
|
_rtpSender.SendToNetwork(red_packet->data(),
|
|
|
|
|
red_packet->length() - rtp_header_length,
|
|
|
|
|
rtp_header_length,
|
|
|
|
|
capture_time_ms,
|
|
|
|
|
storage,
|
|
|
|
|
PacedSender::kNormalPriority);
|
2012-03-20 22:10:56 +00:00
|
|
|
|
|
|
|
|
ret |= packet_success;
|
|
|
|
|
|
|
|
|
|
if (packet_success == 0) {
|
|
|
|
|
video_sent += red_packet->length();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-03-20 22:10:56 +00:00
|
|
|
delete red_packet;
|
|
|
|
|
red_packet = NULL;
|
|
|
|
|
|
2012-04-11 07:42:25 +00:00
|
|
|
if (protect) {
|
2014-09-12 11:05:55 +00:00
|
|
|
ret = producer_fec_.AddRtpPacketAndGenerateFec(
|
|
|
|
|
data_buffer, payload_length, rtp_header_length);
|
2012-04-11 07:42:25 +00:00
|
|
|
if (ret != 0)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2012-03-20 22:10:56 +00:00
|
|
|
|
|
|
|
|
while (producer_fec_.FecAvailable()) {
|
2014-09-12 11:05:55 +00:00
|
|
|
red_packet =
|
|
|
|
|
producer_fec_.GetFecPacket(_payloadTypeRED,
|
|
|
|
|
_payloadTypeFEC,
|
|
|
|
|
_rtpSender.IncrementSequenceNumber(),
|
|
|
|
|
rtp_header_length);
|
2012-03-20 22:10:56 +00:00
|
|
|
StorageType storage = kDontRetransmit;
|
|
|
|
|
if (_retransmissionSettings & kRetransmitFECPackets) {
|
|
|
|
|
storage = kAllowRetransmission;
|
|
|
|
|
}
|
2015-02-16 12:06:00 +00:00
|
|
|
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
|
|
|
|
|
"Video::PacketFec", "timestamp", capture_timestamp,
|
|
|
|
|
"seqnum", _rtpSender.SequenceNumber());
|
2012-03-20 22:10:56 +00:00
|
|
|
// Sending FEC packet with RED header.
|
2014-09-12 11:05:55 +00:00
|
|
|
int packet_success =
|
|
|
|
|
_rtpSender.SendToNetwork(red_packet->data(),
|
|
|
|
|
red_packet->length() - rtp_header_length,
|
|
|
|
|
rtp_header_length,
|
|
|
|
|
capture_time_ms,
|
|
|
|
|
storage,
|
|
|
|
|
PacedSender::kNormalPriority);
|
2012-03-20 22:10:56 +00:00
|
|
|
|
|
|
|
|
ret |= packet_success;
|
|
|
|
|
|
|
|
|
|
if (packet_success == 0) {
|
|
|
|
|
fec_overhead_sent += red_packet->length();
|
|
|
|
|
}
|
|
|
|
|
delete red_packet;
|
|
|
|
|
red_packet = NULL;
|
2011-10-27 16:08:29 +00:00
|
|
|
}
|
2012-03-20 22:10:56 +00:00
|
|
|
_videoBitrate.Update(video_sent);
|
|
|
|
|
_fecOverheadRate.Update(fec_overhead_sent);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2015-02-16 12:06:00 +00:00
|
|
|
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
|
|
|
|
|
"Video::PacketNormal", "timestamp", capture_timestamp,
|
|
|
|
|
"seqnum", _rtpSender.SequenceNumber());
|
2012-03-20 22:10:56 +00:00
|
|
|
int ret = _rtpSender.SendToNetwork(data_buffer,
|
|
|
|
|
payload_length,
|
|
|
|
|
rtp_header_length,
|
2012-07-03 13:21:22 +00:00
|
|
|
capture_time_ms,
|
2013-06-17 12:53:37 +00:00
|
|
|
storage,
|
|
|
|
|
PacedSender::kNormalPriority);
|
2012-03-20 22:10:56 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
|
_videoBitrate.Update(payload_length + rtp_header_length);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
int32_t RTPSenderVideo::SendRTPIntraRequest() {
|
|
|
|
|
// RFC 2032
|
|
|
|
|
// 5.2.1. Full intra-frame Request (FIR) packet
|
|
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t length = 8;
|
2014-09-12 11:05:55 +00:00
|
|
|
uint8_t data[8];
|
|
|
|
|
data[0] = 0x80;
|
|
|
|
|
data[1] = 192;
|
|
|
|
|
data[2] = 0;
|
|
|
|
|
data[3] = 1; // length
|
|
|
|
|
|
|
|
|
|
RtpUtility::AssignUWord32ToBuffer(data + 4, _rtpSender.SSRC());
|
|
|
|
|
|
2015-02-16 12:06:00 +00:00
|
|
|
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
|
|
|
|
|
"Video::IntraRequest", "seqnum",
|
2014-09-12 11:05:55 +00:00
|
|
|
_rtpSender.SequenceNumber());
|
|
|
|
|
return _rtpSender.SendToNetwork(
|
|
|
|
|
data, 0, length, -1, kDontStore, PacedSender::kNormalPriority);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
int32_t RTPSenderVideo::SetGenericFECStatus(const bool enable,
|
|
|
|
|
const uint8_t payloadTypeRED,
|
|
|
|
|
const uint8_t payloadTypeFEC) {
|
|
|
|
|
_fecEnabled = enable;
|
|
|
|
|
_payloadTypeRED = payloadTypeRED;
|
|
|
|
|
_payloadTypeFEC = payloadTypeFEC;
|
|
|
|
|
memset(&delta_fec_params_, 0, sizeof(delta_fec_params_));
|
|
|
|
|
memset(&key_fec_params_, 0, sizeof(key_fec_params_));
|
|
|
|
|
delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
|
|
|
|
|
delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
|
|
|
|
|
kFecMaskRandom;
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
int32_t RTPSenderVideo::GenericFECStatus(bool& enable,
|
|
|
|
|
uint8_t& payloadTypeRED,
|
|
|
|
|
uint8_t& payloadTypeFEC) const {
|
|
|
|
|
enable = _fecEnabled;
|
|
|
|
|
payloadTypeRED = _payloadTypeRED;
|
|
|
|
|
payloadTypeFEC = _payloadTypeFEC;
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t RTPSenderVideo::FECPacketOverhead() const {
|
2014-09-12 11:05:55 +00:00
|
|
|
if (_fecEnabled) {
|
|
|
|
|
// Overhead is FEC headers plus RED for FEC header plus anything in RTP
|
|
|
|
|
// header beyond the 12 bytes base header (CSRC list, extensions...)
|
|
|
|
|
// This reason for the header extensions to be included here is that
|
|
|
|
|
// from an FEC viewpoint, they are part of the payload to be protected.
|
|
|
|
|
// (The base RTP header is already protected by the FEC header.)
|
|
|
|
|
return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength +
|
|
|
|
|
(_rtpSender.RTPHeaderLength() - kRtpHeaderSize);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t RTPSenderVideo::SetFecParameters(
|
2012-03-20 22:10:56 +00:00
|
|
|
const FecProtectionParams* delta_params,
|
|
|
|
|
const FecProtectionParams* key_params) {
|
|
|
|
|
assert(delta_params);
|
|
|
|
|
assert(key_params);
|
|
|
|
|
delta_fec_params_ = *delta_params;
|
|
|
|
|
key_fec_params_ = *key_params;
|
|
|
|
|
return 0;
|
2011-07-15 21:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-31 14:59:24 +00:00
|
|
|
int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
|
|
|
|
const FrameType frameType,
|
|
|
|
|
const int8_t payloadType,
|
|
|
|
|
const uint32_t captureTimeStamp,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
const uint8_t* payloadData,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t payloadSize,
|
2014-07-31 14:59:24 +00:00
|
|
|
const RTPFragmentationHeader* fragmentation,
|
|
|
|
|
VideoCodecInformation* codecInfo,
|
2015-03-04 22:55:15 +00:00
|
|
|
const RTPVideoHeader* rtpHdr) {
|
2014-07-31 14:59:24 +00:00
|
|
|
if (payloadSize == 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-07-31 14:59:24 +00:00
|
|
|
if (frameType == kVideoFrameKey) {
|
|
|
|
|
producer_fec_.SetFecParameters(&key_fec_params_, _numberFirstPartition);
|
|
|
|
|
} else {
|
|
|
|
|
producer_fec_.SetFecParameters(&delta_fec_params_, _numberFirstPartition);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-07-31 14:59:24 +00:00
|
|
|
// Default setting for number of first partition packets:
|
|
|
|
|
// Will be extracted in SendVP8 for VP8 codec; other codecs use 0
|
|
|
|
|
_numberFirstPartition = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-03-04 22:55:15 +00:00
|
|
|
return Send(videoType, frameType, payloadType, captureTimeStamp,
|
|
|
|
|
capture_time_ms, payloadData, payloadSize, fragmentation, rtpHdr)
|
2014-09-12 11:05:55 +00:00
|
|
|
? 0
|
|
|
|
|
: -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
VideoCodecInformation* RTPSenderVideo::CodecInformationVideo() {
|
|
|
|
|
return _videoCodecInformation;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
void RTPSenderVideo::SetMaxConfiguredBitrateVideo(const uint32_t maxBitrate) {
|
|
|
|
|
_maxBitrate = maxBitrate;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
uint32_t RTPSenderVideo::MaxConfiguredBitrateVideo() const {
|
|
|
|
|
return _maxBitrate;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
bool RTPSenderVideo::Send(const RtpVideoCodecTypes videoType,
|
|
|
|
|
const FrameType frameType,
|
|
|
|
|
const int8_t payloadType,
|
|
|
|
|
const uint32_t captureTimeStamp,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
const uint8_t* payloadData,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t payloadSize,
|
2014-09-12 11:05:55 +00:00
|
|
|
const RTPFragmentationHeader* fragmentation,
|
2015-03-04 22:55:15 +00:00
|
|
|
const RTPVideoHeader* rtpHdr) {
|
2014-09-12 11:05:55 +00:00
|
|
|
uint16_t rtp_header_length = _rtpSender.RTPHeaderLength();
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payload_bytes_to_send = payloadSize;
|
2014-07-31 14:59:24 +00:00
|
|
|
const uint8_t* data = payloadData;
|
|
|
|
|
size_t max_payload_length = _rtpSender.MaxDataPayloadLength();
|
|
|
|
|
|
2015-02-26 14:34:55 +00:00
|
|
|
rtc::scoped_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create(
|
2015-03-04 22:55:15 +00:00
|
|
|
videoType, max_payload_length, &(rtpHdr->codecHeader), frameType));
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
// TODO(changbin): we currently don't support to configure the codec to
|
|
|
|
|
// output multiple partitions for VP8. Should remove below check after the
|
|
|
|
|
// issue is fixed.
|
|
|
|
|
const RTPFragmentationHeader* frag =
|
|
|
|
|
(videoType == kRtpVideoVp8) ? NULL : fragmentation;
|
|
|
|
|
|
|
|
|
|
packetizer->SetPayloadData(data, payload_bytes_to_send, frag);
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
bool last = false;
|
2014-07-31 14:59:24 +00:00
|
|
|
while (!last) {
|
|
|
|
|
uint8_t dataBuffer[IP_PACKET_SIZE] = {0};
|
|
|
|
|
size_t payload_bytes_in_packet = 0;
|
|
|
|
|
if (!packetizer->NextPacket(
|
|
|
|
|
&dataBuffer[rtp_header_length], &payload_bytes_in_packet, &last)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write RTP header.
|
|
|
|
|
// Set marker bit true if this is the last packet in frame.
|
|
|
|
|
_rtpSender.BuildRTPheader(
|
|
|
|
|
dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms);
|
2015-03-04 22:55:15 +00:00
|
|
|
|
|
|
|
|
// According to
|
|
|
|
|
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
|
|
|
|
|
// ts_126114v120700p.pdf Section 7.4.5:
|
|
|
|
|
// The MTSI client shall add the payload bytes as defined in this clause
|
|
|
|
|
// onto the last RTP packet in each group of packets which make up a key
|
|
|
|
|
// frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265
|
|
|
|
|
// (HEVC)). The MTSI client may also add the payload bytes onto the last RTP
|
|
|
|
|
// packet in each group of packets which make up another type of frame
|
|
|
|
|
// (e.g. a P-Frame) only if the current value is different from the previous
|
|
|
|
|
// value sent.
|
|
|
|
|
// Here we are adding it to the last packet of every frame at this point.
|
|
|
|
|
if (!rtpHdr) {
|
|
|
|
|
assert(!_rtpSender.IsRtpHeaderExtensionRegistered(
|
|
|
|
|
kRtpExtensionVideoRotation));
|
|
|
|
|
} else if (last) {
|
|
|
|
|
// Checking whether CVO header extension is registered will require taking
|
|
|
|
|
// a lock. It'll be a no-op if it's not registered.
|
|
|
|
|
size_t packetSize = payloadSize + rtp_header_length;
|
|
|
|
|
RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize);
|
|
|
|
|
RTPHeader rtp_header;
|
|
|
|
|
rtp_parser.Parse(rtp_header);
|
|
|
|
|
_rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header,
|
|
|
|
|
rtpHdr->rotation);
|
|
|
|
|
}
|
2014-07-31 14:59:24 +00:00
|
|
|
if (SendVideoPacket(dataBuffer,
|
|
|
|
|
payload_bytes_in_packet,
|
|
|
|
|
rtp_header_length,
|
|
|
|
|
captureTimeStamp,
|
|
|
|
|
capture_time_ms,
|
2014-09-12 11:05:55 +00:00
|
|
|
packetizer->GetStorageType(_retransmissionSettings),
|
|
|
|
|
packetizer->GetProtectionType() == kProtectedPacket)) {
|
|
|
|
|
LOG(LS_WARNING) << packetizer->ToString()
|
|
|
|
|
<< " failed to send packet number "
|
|
|
|
|
<< _rtpSender.SequenceNumber();
|
2014-07-31 14:59:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-09-12 11:05:55 +00:00
|
|
|
|
|
|
|
|
TRACE_EVENT_ASYNC_END1(
|
|
|
|
|
"webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp());
|
2014-07-31 14:59:24 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 14:24:54 +00:00
|
|
|
void RTPSenderVideo::ProcessBitrate() {
|
2011-10-27 16:08:29 +00:00
|
|
|
_videoBitrate.Process();
|
2011-10-14 14:24:54 +00:00
|
|
|
_fecOverheadRate.Process();
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t RTPSenderVideo::VideoBitrateSent() const {
|
2011-10-27 16:08:29 +00:00
|
|
|
return _videoBitrate.BitrateLast();
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t RTPSenderVideo::FecOverheadRate() const {
|
2011-10-14 14:24:54 +00:00
|
|
|
return _fecOverheadRate.BitrateLast();
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-22 12:52:41 +00:00
|
|
|
int RTPSenderVideo::SelectiveRetransmissions() const {
|
|
|
|
|
return _retransmissionSettings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
|
|
|
|
|
_retransmissionSettings = settings;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|