C++11 in-class member initialization in Call configs.

BUG=
R=mflodman@webrtc.org, pbos@webrtc.org

Review URL: https://codereview.webrtc.org/1166263004.

Cr-Commit-Position: refs/heads/master@{#9416}
This commit is contained in:
Fredrik Solenberg
2015-06-11 12:38:38 +02:00
parent eb82309d06
commit 78fb3b3f8f
3 changed files with 56 additions and 107 deletions

View File

@ -73,54 +73,43 @@ class Call {
kNetworkDown,
};
struct Config {
Config() = delete;
explicit Config(newapi::Transport* send_transport)
: send_transport(send_transport),
voice_engine(NULL),
overuse_callback(NULL) {}
: send_transport(send_transport) {}
static const int kDefaultStartBitrateBps;
// TODO(solenberg): Need to add media type to the interface for outgoing
// packets too.
newapi::Transport* send_transport;
newapi::Transport* send_transport = nullptr;
// VoiceEngine used for audio/video synchronization for this Call.
VoiceEngine* voice_engine;
VoiceEngine* voice_engine = nullptr;
// Callback for overuse and normal usage based on the jitter of incoming
// captured frames. 'NULL' disables the callback.
LoadObserver* overuse_callback;
// captured frames. 'nullptr' disables the callback.
LoadObserver* overuse_callback = nullptr;
// Bitrate config used until valid bitrate estimates are calculated. Also
// used to cap total bitrate used.
struct BitrateConfig {
BitrateConfig()
: min_bitrate_bps(0),
start_bitrate_bps(kDefaultStartBitrateBps),
max_bitrate_bps(-1) {}
int min_bitrate_bps;
int start_bitrate_bps;
int max_bitrate_bps;
int min_bitrate_bps = 0;
int start_bitrate_bps = kDefaultStartBitrateBps;
int max_bitrate_bps = -1;
} bitrate_config;
struct AudioConfig {
AudioDeviceModule* audio_device_manager;
AudioProcessing* audio_processing;
VoiceEngineObserver* voice_engine_observer;
AudioDeviceModule* audio_device_manager = nullptr;
AudioProcessing* audio_processing = nullptr;
VoiceEngineObserver* voice_engine_observer = nullptr;
} audio_config;
};
struct Stats {
Stats()
: send_bandwidth_bps(0),
recv_bandwidth_bps(0),
pacer_delay_ms(0),
rtt_ms(-1) {}
int send_bandwidth_bps;
int recv_bandwidth_bps;
int64_t pacer_delay_ms;
int64_t rtt_ms;
int send_bandwidth_bps = 0;
int recv_bandwidth_bps = 0;
int64_t pacer_delay_ms = 0;
int64_t rtt_ms = -1;
};
static Call* Create(const Call::Config& config);

View File

@ -36,32 +36,27 @@ class VideoReceiveStream {
// TODO(mflodman) Move all these settings to VideoDecoder and move the
// declaration to common_types.h.
struct Decoder {
Decoder()
: decoder(NULL),
payload_type(0),
is_renderer(false),
expected_delay_ms(0) {}
std::string ToString() const;
// The actual decoder instance.
VideoDecoder* decoder;
VideoDecoder* decoder = nullptr;
// Received RTP packets with this payload type will be sent to this decoder
// instance.
int payload_type;
int payload_type = 0;
// Name of the decoded payload (such as VP8). Maps back to the depacketizer
// used to unpack incoming packets.
std::string payload_name;
// 'true' if the decoder handles rendering as well.
bool is_renderer;
bool is_renderer = false;
// The expected delay for decoding and rendering, i.e. the frame will be
// delivered this many milliseconds, if possible, earlier than the ideal
// render time.
// Note: Ignored if 'renderer' is false.
int expected_delay_ms;
int expected_delay_ms = 0;
};
struct Stats {
@ -90,13 +85,6 @@ class VideoReceiveStream {
};
struct Config {
Config()
: renderer(NULL),
render_delay_ms(10),
audio_channel_id(-1),
pre_decode_callback(NULL),
pre_render_callback(NULL),
target_delay_ms(0) {}
std::string ToString() const;
// Decoders for every payload that we can receive.
@ -104,32 +92,25 @@ class VideoReceiveStream {
// Receive-stream specific RTP settings.
struct Rtp {
Rtp()
: remote_ssrc(0),
local_ssrc(0),
rtcp_mode(newapi::kRtcpCompound),
remb(false) {}
std::string ToString() const;
// Synchronization source (stream identifier) to be received.
uint32_t remote_ssrc;
uint32_t remote_ssrc = 0;
// Sender SSRC used for sending RTCP (such as receiver reports).
uint32_t local_ssrc;
uint32_t local_ssrc = 0;
// See RtcpMode for description.
newapi::RtcpMode rtcp_mode;
newapi::RtcpMode rtcp_mode = newapi::kRtcpCompound;
// Extended RTCP settings.
struct RtcpXr {
RtcpXr() : receiver_reference_time_report(false) {}
// True if RTCP Receiver Reference Time Report Block extension
// (RFC 3611) should be enabled.
bool receiver_reference_time_report;
bool receiver_reference_time_report = false;
} rtcp_xr;
// See draft-alvestrand-rmcat-remb for information.
bool remb;
bool remb = false;
// See NackConfig for description.
NackConfig nack;
@ -140,13 +121,11 @@ class VideoReceiveStream {
// RTX settings for incoming video payloads that may be received. RTX is
// disabled if there's no config present.
struct Rtx {
Rtx() : ssrc(0), payload_type(0) {}
// SSRCs to use for the RTX streams.
uint32_t ssrc;
uint32_t ssrc = 0;
// Payload type to use for the RTX stream.
int payload_type;
int payload_type = 0;
};
// Map from video RTP payload type -> RTX config.
@ -157,33 +136,33 @@ class VideoReceiveStream {
std::vector<RtpExtension> extensions;
} rtp;
// VideoRenderer will be called for each decoded frame. 'NULL' disables
// VideoRenderer will be called for each decoded frame. 'nullptr' disables
// rendering of this stream.
VideoRenderer* renderer;
VideoRenderer* renderer = nullptr;
// Expected delay needed by the renderer, i.e. the frame will be delivered
// this many milliseconds, if possible, earlier than the ideal render time.
// Only valid if 'renderer' is set.
int render_delay_ms;
int render_delay_ms = 10;
// Audio channel corresponding to this video stream, used for audio/video
// synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
// when creating the VideoEngine instance. '-1' disables a/v sync.
int audio_channel_id;
int audio_channel_id = -1;
// Called for each incoming video frame, i.e. in encoded state. E.g. used
// when
// saving the stream to a file. 'NULL' disables the callback.
EncodedFrameObserver* pre_decode_callback;
// saving the stream to a file. 'nullptr' disables the callback.
EncodedFrameObserver* pre_decode_callback = nullptr;
// Called for each decoded frame. E.g. used when adding effects to the
// decoded
// stream. 'NULL' disables the callback.
I420FrameCallback* pre_render_callback;
// stream. 'nullptr' disables the callback.
I420FrameCallback* pre_render_callback = nullptr;
// Target delay in milliseconds. A positive value indicates this stream is
// used for streaming instead of a real-time call.
int target_delay_ms;
int target_delay_ms = 0;
};
virtual void Start() = 0;

View File

@ -52,56 +52,38 @@ class VideoSendStream {
};
struct Stats {
Stats()
: input_frame_rate(0),
encode_frame_rate(0),
avg_encode_time_ms(0),
encode_usage_percent(0),
target_media_bitrate_bps(0),
media_bitrate_bps(0),
suspended(false) {}
int input_frame_rate;
int encode_frame_rate;
int avg_encode_time_ms;
int encode_usage_percent;
int target_media_bitrate_bps;
int media_bitrate_bps;
bool suspended;
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;
std::map<uint32_t, StreamStats> substreams;
};
struct Config {
Config()
: pre_encode_callback(NULL),
post_encode_callback(NULL),
local_renderer(NULL),
render_delay_ms(0),
target_delay_ms(0),
suspend_below_min_bitrate(false) {}
std::string ToString() const;
struct EncoderSettings {
EncoderSettings() : payload_type(-1), encoder(NULL) {}
std::string ToString() const;
std::string payload_name;
int payload_type;
int payload_type = -1;
// Uninitialized VideoEncoder instance to be used for encoding. Will be
// initialized from inside the VideoSendStream.
VideoEncoder* encoder;
VideoEncoder* encoder = nullptr;
} encoder_settings;
static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
struct Rtp {
Rtp() : max_packet_size(kDefaultMaxPacketSize) {}
std::string ToString() const;
std::vector<uint32_t> ssrcs;
// Max RTP packet size delivered to send transport from VideoEngine.
size_t max_packet_size;
size_t max_packet_size = kDefaultMaxPacketSize;
// RTP header extensions to use for this send stream.
std::vector<RtpExtension> extensions;
@ -115,13 +97,12 @@ class VideoSendStream {
// Settings for RTP retransmission payload format, see RFC 4588 for
// details.
struct Rtx {
Rtx() : payload_type(-1) {}
std::string ToString() const;
// SSRCs to use for the RTX streams.
std::vector<uint32_t> ssrcs;
// Payload type to use for the RTX stream.
int payload_type;
int payload_type = -1;
} rtx;
// RTCP CNAME, see RFC 3550.
@ -129,30 +110,30 @@ class VideoSendStream {
} rtp;
// Called for each I420 frame before encoding the frame. Can be used for
// effects, snapshots etc. 'NULL' disables the callback.
I420FrameCallback* pre_encode_callback;
// effects, snapshots etc. 'nullptr' disables the callback.
I420FrameCallback* pre_encode_callback = nullptr;
// Called for each encoded frame, e.g. used for file storage. 'NULL'
// Called for each encoded frame, e.g. used for file storage. 'nullptr'
// disables the callback.
EncodedFrameObserver* post_encode_callback;
EncodedFrameObserver* post_encode_callback = nullptr;
// Renderer for local preview. The local renderer will be called even if
// sending hasn't started. 'NULL' disables local rendering.
VideoRenderer* local_renderer;
// sending hasn't started. 'nullptr' disables local rendering.
VideoRenderer* local_renderer = nullptr;
// Expected delay needed by the renderer, i.e. the frame will be delivered
// this many milliseconds, if possible, earlier than expected render time.
// Only valid if |local_renderer| is set.
int render_delay_ms;
int render_delay_ms = 0;
// Target delay in milliseconds. A positive value indicates this stream is
// used for streaming instead of a real-time call.
int target_delay_ms;
int target_delay_ms = 0;
// 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.
bool suspend_below_min_bitrate;
bool suspend_below_min_bitrate = false;
};
// Gets interface used to insert captured frames. Valid as long as the