2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-09 13:14:04 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
|
|
|
|
|
|
2012-01-20 06:59:06 +00:00
|
|
|
#include <list>
|
2016-10-02 10:54:29 -07:00
|
|
|
#include <memory>
|
2016-11-10 05:01:11 -08:00
|
|
|
#include <vector>
|
2012-01-20 06:59:06 +00:00
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/common_types.h"
|
2016-11-10 05:01:11 -08:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
2016-10-31 05:27:07 -07:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/video_codec_information.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/criticalsection.h"
|
|
|
|
|
#include "webrtc/rtc_base/onetimeevent.h"
|
|
|
|
|
#include "webrtc/rtc_base/optional.h"
|
|
|
|
|
#include "webrtc/rtc_base/rate_statistics.h"
|
|
|
|
|
#include "webrtc/rtc_base/sequenced_task_checker.h"
|
|
|
|
|
#include "webrtc/rtc_base/thread_annotations.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2016-10-02 10:54:29 -07:00
|
|
|
class RtpPacketToSend;
|
2012-01-20 06:59:06 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
class RTPSenderVideo {
|
|
|
|
|
public:
|
2016-11-10 05:04:48 -08:00
|
|
|
RTPSenderVideo(Clock* clock,
|
|
|
|
|
RTPSender* rtpSender,
|
|
|
|
|
FlexfecSender* flexfec_sender);
|
2014-09-12 11:05:55 +00:00
|
|
|
virtual ~RTPSenderVideo();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
virtual RtpVideoCodecTypes VideoCodecType() const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-04-14 21:28:08 +02:00
|
|
|
static RtpUtility::Payload* CreateVideoPayload(
|
2016-07-28 15:19:10 -07:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
|
|
|
|
int8_t payload_type);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-08-02 17:46:41 -07:00
|
|
|
bool SendVideo(RtpVideoCodecTypes video_type,
|
|
|
|
|
FrameType frame_type,
|
|
|
|
|
int8_t payload_type,
|
|
|
|
|
uint32_t capture_timestamp,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
const uint8_t* payload_data,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation,
|
|
|
|
|
const RTPVideoHeader* video_header);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
void SetVideoCodecType(RtpVideoCodecTypes type);
|
|
|
|
|
|
2016-11-07 03:05:06 -08:00
|
|
|
// ULPFEC.
|
|
|
|
|
void SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type);
|
|
|
|
|
void GetUlpfecConfig(int* red_payload_type, int* ulpfec_payload_type) const;
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
// FlexFEC/ULPFEC.
|
2016-11-07 03:36:05 -08:00
|
|
|
void SetFecParameters(const FecProtectionParams& delta_params,
|
|
|
|
|
const FecProtectionParams& key_params);
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
// FlexFEC.
|
|
|
|
|
rtc::Optional<uint32_t> FlexfecSsrc() const;
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
uint32_t VideoBitrateSent() const;
|
|
|
|
|
uint32_t FecOverheadRate() const;
|
|
|
|
|
|
|
|
|
|
int SelectiveRetransmissions() const;
|
2015-04-14 21:28:08 +02:00
|
|
|
void SetSelectiveRetransmissions(uint8_t settings);
|
|
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
private:
|
2016-11-11 02:27:35 -08:00
|
|
|
size_t CalculateFecPacketOverhead() const EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
|
|
|
|
|
2016-10-02 10:54:29 -07:00
|
|
|
void SendVideoPacket(std::unique_ptr<RtpPacketToSend> packet,
|
2015-04-14 21:28:08 +02:00
|
|
|
StorageType storage);
|
|
|
|
|
|
2016-11-10 05:01:11 -08:00
|
|
|
void SendVideoPacketAsRedMaybeWithUlpfec(
|
|
|
|
|
std::unique_ptr<RtpPacketToSend> media_packet,
|
|
|
|
|
StorageType media_packet_storage,
|
|
|
|
|
bool protect_media_packet);
|
|
|
|
|
|
|
|
|
|
// TODO(brandtr): Remove the FlexFEC functions when FlexfecSender has been
|
|
|
|
|
// moved to PacedSender.
|
|
|
|
|
void SendVideoPacketWithFlexfec(std::unique_ptr<RtpPacketToSend> media_packet,
|
|
|
|
|
StorageType media_packet_storage,
|
|
|
|
|
bool protect_media_packet);
|
2015-04-14 21:28:08 +02:00
|
|
|
|
2016-11-07 03:05:06 -08:00
|
|
|
bool red_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) {
|
|
|
|
|
return red_payload_type_ >= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ulpfec_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) {
|
|
|
|
|
return ulpfec_payload_type_ >= 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 05:01:11 -08:00
|
|
|
bool flexfec_enabled() const { return flexfec_sender_ != nullptr; }
|
|
|
|
|
|
2016-08-09 07:43:25 -07:00
|
|
|
RTPSender* const rtp_sender_;
|
2016-07-13 09:11:28 -07:00
|
|
|
Clock* const clock_;
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2015-04-14 21:28:08 +02:00
|
|
|
// Should never be held when calling out of this class.
|
2016-07-13 09:11:28 -07:00
|
|
|
rtc::CriticalSection crit_;
|
2015-04-14 21:28:08 +02:00
|
|
|
|
2016-11-07 02:08:51 -08:00
|
|
|
RtpVideoCodecTypes video_type_;
|
|
|
|
|
int32_t retransmission_settings_ GUARDED_BY(crit_);
|
2016-11-10 06:22:17 -08:00
|
|
|
VideoRotation last_rotation_ GUARDED_BY(crit_);
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2016-11-07 03:05:06 -08:00
|
|
|
// RED/ULPFEC.
|
2016-11-07 02:08:51 -08:00
|
|
|
int red_payload_type_ GUARDED_BY(crit_);
|
2016-11-07 03:05:06 -08:00
|
|
|
int ulpfec_payload_type_ GUARDED_BY(crit_);
|
2016-11-10 05:01:11 -08:00
|
|
|
UlpfecGenerator ulpfec_generator_ GUARDED_BY(crit_);
|
|
|
|
|
|
|
|
|
|
// FlexFEC.
|
|
|
|
|
FlexfecSender* const flexfec_sender_;
|
|
|
|
|
|
|
|
|
|
// FEC parameters, applicable to either ULPFEC or FlexFEC.
|
2016-11-07 02:08:51 -08:00
|
|
|
FecProtectionParams delta_fec_params_ GUARDED_BY(crit_);
|
|
|
|
|
FecProtectionParams key_fec_params_ GUARDED_BY(crit_);
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2016-07-13 09:11:28 -07:00
|
|
|
rtc::CriticalSection stats_crit_;
|
2014-09-12 11:05:55 +00:00
|
|
|
// Bitrate used for FEC payload, RED headers, RTP headers for FEC packets
|
|
|
|
|
// and any padding overhead.
|
2016-07-13 09:11:28 -07:00
|
|
|
RateStatistics fec_bitrate_ GUARDED_BY(stats_crit_);
|
|
|
|
|
// Bitrate used for video payload and RTP headers.
|
|
|
|
|
RateStatistics video_bitrate_ GUARDED_BY(stats_crit_);
|
2016-04-07 15:36:45 -07:00
|
|
|
OneTimeEvent first_frame_sent_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2016-07-28 15:19:10 -07:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
|