2013-04-18 12:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* 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-12-18 09:46:22 +00:00
|
|
|
#ifndef WEBRTC_VIDEO_SEND_STREAM_H_
|
|
|
|
|
#define WEBRTC_VIDEO_SEND_STREAM_H_
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2014-01-07 09:54:34 +00:00
|
|
|
#include <map>
|
2013-04-18 12:02:52 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "webrtc/common_types.h"
|
2013-10-28 16:32:01 +00:00
|
|
|
#include "webrtc/config.h"
|
|
|
|
|
#include "webrtc/frame_callback.h"
|
2015-07-16 09:30:09 +02:00
|
|
|
#include "webrtc/stream.h"
|
2015-08-28 04:07:10 -07:00
|
|
|
#include "webrtc/transport.h"
|
2016-03-23 04:48:10 -07:00
|
|
|
#include "webrtc/media/base/videosinkinterface.h"
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-09-08 05:13:22 -07:00
|
|
|
class LoadObserver;
|
2013-04-18 12:02:52 +00:00
|
|
|
class VideoEncoder;
|
|
|
|
|
|
|
|
|
|
// Class to deliver captured frame to the video send stream.
|
2015-06-26 06:58:16 +02:00
|
|
|
class VideoCaptureInput {
|
2013-04-18 12:02:52 +00:00
|
|
|
public:
|
2013-12-11 16:26:16 +00:00
|
|
|
// These methods do not lock internally and must be called sequentially.
|
|
|
|
|
// If your application switches input sources synchronization must be done
|
|
|
|
|
// externally to make sure that any old frames are not delivered concurrently.
|
2015-05-29 17:21:40 -07:00
|
|
|
virtual void IncomingCapturedFrame(const VideoFrame& video_frame) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
|
protected:
|
2015-06-26 06:58:16 +02:00
|
|
|
virtual ~VideoCaptureInput() {}
|
2013-04-18 12:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
2015-07-16 09:30:09 +02:00
|
|
|
class VideoSendStream : public SendStream {
|
2013-04-18 12:02:52 +00:00
|
|
|
public:
|
2015-02-25 10:42:16 +00:00
|
|
|
struct StreamStats {
|
|
|
|
|
FrameCounts frame_counts;
|
|
|
|
|
int width = 0;
|
|
|
|
|
int height = 0;
|
|
|
|
|
// TODO(holmer): Move bitrate_bps out to the webrtc::Call layer.
|
|
|
|
|
int total_bitrate_bps = 0;
|
|
|
|
|
int retransmit_bitrate_bps = 0;
|
|
|
|
|
int avg_delay_ms = 0;
|
|
|
|
|
int max_delay_ms = 0;
|
|
|
|
|
StreamDataCounters rtp_stats;
|
|
|
|
|
RtcpPacketTypeCounter rtcp_packet_type_counts;
|
|
|
|
|
RtcpStatistics rtcp_stats;
|
|
|
|
|
};
|
|
|
|
|
|
2013-06-05 11:33:21 +00:00
|
|
|
struct Stats {
|
2015-12-18 16:01:11 +01:00
|
|
|
std::string encoder_implementation_name = "unknown";
|
2015-06-11 12:38:38 +02:00
|
|
|
int input_frame_rate = 0;
|
|
|
|
|
int encode_frame_rate = 0;
|
|
|
|
|
int avg_encode_time_ms = 0;
|
|
|
|
|
int encode_usage_percent = 0;
|
|
|
|
|
int target_media_bitrate_bps = 0;
|
|
|
|
|
int media_bitrate_bps = 0;
|
|
|
|
|
bool suspended = false;
|
2015-12-14 02:08:12 -08:00
|
|
|
bool bw_limited_resolution = false;
|
2015-02-25 10:42:16 +00:00
|
|
|
std::map<uint32_t, StreamStats> substreams;
|
2013-06-05 11:33:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Config {
|
2015-08-28 04:07:10 -07:00
|
|
|
Config() = delete;
|
2015-09-28 09:59:31 -07:00
|
|
|
explicit Config(Transport* send_transport)
|
2015-08-28 04:07:10 -07:00
|
|
|
: send_transport(send_transport) {}
|
|
|
|
|
|
2014-05-15 09:35:06 +00:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2014-03-19 08:43:57 +00:00
|
|
|
struct EncoderSettings {
|
2014-05-15 09:35:06 +00:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2014-03-19 08:43:57 +00:00
|
|
|
std::string payload_name;
|
2015-06-11 12:38:38 +02:00
|
|
|
int payload_type = -1;
|
2014-03-19 08:43:57 +00:00
|
|
|
|
2015-09-03 18:24:44 -07:00
|
|
|
// TODO(sophiechang): Delete this field when no one is using internal
|
|
|
|
|
// sources anymore.
|
|
|
|
|
bool internal_source = false;
|
|
|
|
|
|
2016-02-05 11:13:28 +01:00
|
|
|
// Allow 100% encoder utilization. Used for HW encoders where CPU isn't
|
|
|
|
|
// expected to be the limiting factor, but a chip could be running at
|
|
|
|
|
// 30fps (for example) exactly.
|
|
|
|
|
bool full_overuse_time = false;
|
|
|
|
|
|
2014-03-19 08:43:57 +00:00
|
|
|
// Uninitialized VideoEncoder instance to be used for encoding. Will be
|
|
|
|
|
// initialized from inside the VideoSendStream.
|
2015-06-11 12:38:38 +02:00
|
|
|
VideoEncoder* encoder = nullptr;
|
2014-03-19 08:43:57 +00:00
|
|
|
} encoder_settings;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
2013-10-16 13:29:14 +00:00
|
|
|
static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
|
2013-06-05 11:33:21 +00:00
|
|
|
struct Rtp {
|
2014-05-15 09:35:06 +00:00
|
|
|
std::string ToString() const;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
std::vector<uint32_t> ssrcs;
|
|
|
|
|
|
2015-12-09 12:37:51 -08:00
|
|
|
// See RtcpMode for description.
|
|
|
|
|
RtcpMode rtcp_mode = RtcpMode::kCompound;
|
|
|
|
|
|
2013-06-05 11:33:21 +00:00
|
|
|
// Max RTP packet size delivered to send transport from VideoEngine.
|
2015-06-11 12:38:38 +02:00
|
|
|
size_t max_packet_size = kDefaultMaxPacketSize;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
// RTP header extensions to use for this send stream.
|
|
|
|
|
std::vector<RtpExtension> extensions;
|
|
|
|
|
|
|
|
|
|
// See NackConfig for description.
|
|
|
|
|
NackConfig nack;
|
|
|
|
|
|
|
|
|
|
// See FecConfig for description.
|
|
|
|
|
FecConfig fec;
|
|
|
|
|
|
2014-01-24 09:30:53 +00:00
|
|
|
// Settings for RTP retransmission payload format, see RFC 4588 for
|
|
|
|
|
// details.
|
|
|
|
|
struct Rtx {
|
2014-05-15 09:35:06 +00:00
|
|
|
std::string ToString() const;
|
2014-01-24 09:30:53 +00:00
|
|
|
// SSRCs to use for the RTX streams.
|
|
|
|
|
std::vector<uint32_t> ssrcs;
|
|
|
|
|
|
|
|
|
|
// Payload type to use for the RTX stream.
|
2015-06-11 12:38:38 +02:00
|
|
|
int payload_type = -1;
|
2014-01-24 09:30:53 +00:00
|
|
|
} rtx;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
// RTCP CNAME, see RFC 3550.
|
|
|
|
|
std::string c_name;
|
|
|
|
|
} rtp;
|
|
|
|
|
|
2015-08-28 04:07:10 -07:00
|
|
|
// Transport for outgoing packets.
|
2015-09-28 09:59:31 -07:00
|
|
|
Transport* send_transport = nullptr;
|
2015-08-28 04:07:10 -07:00
|
|
|
|
2015-09-08 05:13:22 -07:00
|
|
|
// Callback for overuse and normal usage based on the jitter of incoming
|
|
|
|
|
// captured frames. 'nullptr' disables the callback.
|
|
|
|
|
LoadObserver* overuse_callback = nullptr;
|
|
|
|
|
|
2013-06-05 11:33:21 +00:00
|
|
|
// Called for each I420 frame before encoding the frame. Can be used for
|
2015-06-11 12:38:38 +02:00
|
|
|
// effects, snapshots etc. 'nullptr' disables the callback.
|
|
|
|
|
I420FrameCallback* pre_encode_callback = nullptr;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
2015-06-11 12:38:38 +02:00
|
|
|
// Called for each encoded frame, e.g. used for file storage. 'nullptr'
|
2016-02-05 11:13:28 +01:00
|
|
|
// disables the callback. Also measures timing and passes the time
|
|
|
|
|
// spent on encoding. This timing will not fire if encoding takes longer
|
|
|
|
|
// than the measuring window, since the sample data will have been dropped.
|
2015-06-11 12:38:38 +02:00
|
|
|
EncodedFrameObserver* post_encode_callback = nullptr;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
// Renderer for local preview. The local renderer will be called even if
|
2015-06-11 12:38:38 +02:00
|
|
|
// sending hasn't started. 'nullptr' disables local rendering.
|
2016-03-23 04:48:10 -07:00
|
|
|
rtc::VideoSinkInterface<VideoFrame>* local_renderer = nullptr;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
// Expected delay needed by the renderer, i.e. the frame will be delivered
|
|
|
|
|
// this many milliseconds, if possible, earlier than expected render time.
|
2014-05-15 09:35:06 +00:00
|
|
|
// Only valid if |local_renderer| is set.
|
2015-06-11 12:38:38 +02:00
|
|
|
int render_delay_ms = 0;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
|
|
|
|
// Target delay in milliseconds. A positive value indicates this stream is
|
|
|
|
|
// used for streaming instead of a real-time call.
|
2015-06-11 12:38:38 +02:00
|
|
|
int target_delay_ms = 0;
|
2013-06-05 11:33:21 +00:00
|
|
|
|
2013-11-18 12:18:43 +00:00
|
|
|
// True if the stream should be suspended when the available bitrate fall
|
|
|
|
|
// below the minimum configured bitrate. If this variable is false, the
|
|
|
|
|
// stream may send at a rate higher than the estimated available bitrate.
|
2015-06-11 12:38:38 +02:00
|
|
|
bool suspend_below_min_bitrate = false;
|
2013-06-05 11:33:21 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-18 12:02:52 +00:00
|
|
|
// Gets interface used to insert captured frames. Valid as long as the
|
|
|
|
|
// VideoSendStream is valid.
|
2015-06-26 06:58:16 +02:00
|
|
|
virtual VideoCaptureInput* Input() = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2014-03-19 08:43:57 +00:00
|
|
|
// Set which streams to send. Must have at least as many SSRCs as configured
|
|
|
|
|
// in the config. Encoder settings are passed on to the encoder instance along
|
|
|
|
|
// with the VideoStream settings.
|
2016-03-02 16:59:56 +01:00
|
|
|
virtual void ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2014-12-01 15:23:21 +00:00
|
|
|
virtual Stats GetStats() = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2013-12-18 09:46:22 +00:00
|
|
|
#endif // WEBRTC_VIDEO_SEND_STREAM_H_
|