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>
|
2012-01-20 06:59:06 +00:00
|
|
|
|
2016-04-14 03:05:31 -07:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2016-04-07 15:36:45 -07:00
|
|
|
#include "webrtc/base/onetimeevent.h"
|
2016-07-13 09:11:28 -07:00
|
|
|
#include "webrtc/base/rate_statistics.h"
|
2016-10-26 03:33:11 -07:00
|
|
|
#include "webrtc/base/sequenced_task_checker.h"
|
2015-04-14 21:28:08 +02:00
|
|
|
#include "webrtc/base/thread_annotations.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/common_types.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/forward_error_correction.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/producer_fec.h"
|
|
|
|
|
#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"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/video_codec_information.h"
|
|
|
|
|
#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-08-09 07:43:25 -07:00
|
|
|
RTPSenderVideo(Clock* clock, RTPSender* rtpSender);
|
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
|
|
|
|
2016-09-13 03:23:29 -07:00
|
|
|
size_t FecPacketOverhead() 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
|
|
|
int32_t SendRTPIntraRequest();
|
|
|
|
|
|
|
|
|
|
void SetVideoCodecType(RtpVideoCodecTypes type);
|
|
|
|
|
|
|
|
|
|
// FEC
|
2016-07-28 15:19:10 -07:00
|
|
|
void SetGenericFECStatus(bool enable,
|
|
|
|
|
uint8_t payload_type_red,
|
|
|
|
|
uint8_t payload_type_fec);
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2015-12-15 02:54:47 -08:00
|
|
|
void GenericFECStatus(bool* enable,
|
2016-07-28 15:19:10 -07:00
|
|
|
uint8_t* payload_type_red,
|
|
|
|
|
uint8_t* payload_type_fec) const;
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2015-04-14 21:28:08 +02:00
|
|
|
void SetFecParameters(const FecProtectionParams* delta_params,
|
|
|
|
|
const FecProtectionParams* key_params);
|
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-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-10-02 10:54:29 -07:00
|
|
|
void SendVideoPacketAsRed(std::unique_ptr<RtpPacketToSend> media_packet,
|
2015-04-14 21:28:08 +02:00
|
|
|
StorageType media_packet_storage,
|
|
|
|
|
bool protect);
|
|
|
|
|
|
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_;
|
2016-10-26 03:33:11 -07:00
|
|
|
rtc::SequencedTaskChecker encoder_checker_;
|
2015-04-14 21:28:08 +02:00
|
|
|
|
2016-07-28 15:19:10 -07:00
|
|
|
RtpVideoCodecTypes video_type_ = kRtpVideoGeneric;
|
|
|
|
|
int32_t retransmission_settings_ GUARDED_BY(crit_) = kRetransmitBaseLayer;
|
2016-10-26 03:33:11 -07:00
|
|
|
VideoRotation last_rotation_ GUARDED_BY(encoder_checker_) = kVideoRotation_0;
|
2014-09-12 11:05:55 +00:00
|
|
|
|
|
|
|
|
// FEC
|
2016-07-28 15:19:10 -07:00
|
|
|
bool fec_enabled_ GUARDED_BY(crit_) = false;
|
|
|
|
|
int8_t red_payload_type_ GUARDED_BY(crit_) = 0;
|
|
|
|
|
int8_t fec_payload_type_ GUARDED_BY(crit_) = 0;
|
|
|
|
|
FecProtectionParams delta_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
|
|
|
|
|
0, 1, kFecMaskRandom};
|
|
|
|
|
FecProtectionParams key_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
|
|
|
|
|
0, 1, kFecMaskRandom};
|
2015-04-14 21:28:08 +02:00
|
|
|
ProducerFec producer_fec_ 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_
|