2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_VIDEO_SEND_STREAM_H_
12 #define WEBRTC_VIDEO_SEND_STREAM_H_
17 #include "webrtc/common_types.h"
18 #include "webrtc/config.h"
19 #include "webrtc/frame_callback.h"
20 #include "webrtc/video_renderer.h"
26 // Class to deliver captured frame to the video send stream.
27 class VideoSendStreamInput {
29 // These methods do not lock internally and must be called sequentially.
30 // If your application switches input sources synchronization must be done
31 // externally to make sure that any old frames are not delivered concurrently.
32 virtual void PutFrame(const I420VideoFrame& video_frame) = 0;
33 virtual void SwapFrame(I420VideoFrame* video_frame) = 0;
36 virtual ~VideoSendStreamInput() {}
39 class VideoSendStream {
43 : input_frame_rate(0),
49 int encode_frame_rate;
53 std::map<uint32_t, StreamStats> substreams;
58 : pre_encode_callback(NULL),
59 post_encode_callback(NULL),
63 internal_source(false),
66 suspend_below_min_bitrate(false) {}
69 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
71 Rtp() : max_packet_size(kDefaultMaxPacketSize) {}
73 std::vector<uint32_t> ssrcs;
75 // Max RTP packet size delivered to send transport from VideoEngine.
76 size_t max_packet_size;
78 // RTP header extensions to use for this send stream.
79 std::vector<RtpExtension> extensions;
81 // See NackConfig for description.
84 // See FecConfig for description.
87 // Settings for RTP retransmission payload format, see RFC 4588 for
90 Rtx() : payload_type(0) {}
91 // SSRCs to use for the RTX streams.
92 std::vector<uint32_t> ssrcs;
94 // Payload type to use for the RTX stream.
98 // RTCP CNAME, see RFC 3550.
102 // Called for each I420 frame before encoding the frame. Can be used for
103 // effects, snapshots etc. 'NULL' disables the callback.
104 I420FrameCallback* pre_encode_callback;
106 // Called for each encoded frame, e.g. used for file storage. 'NULL'
107 // disables the callback.
108 EncodedFrameObserver* post_encode_callback;
110 // Renderer for local preview. The local renderer will be called even if
111 // sending hasn't started. 'NULL' disables local rendering.
112 VideoRenderer* local_renderer;
114 // Expected delay needed by the renderer, i.e. the frame will be delivered
115 // this many milliseconds, if possible, earlier than expected render time.
116 // Only valid if |renderer| is set.
119 // TODO(mflodman) Move VideoEncoder to common_types.h and redefine.
120 // External encoding. 'encoder' is the external encoder instance and
121 // 'internal_source' is set to true if the encoder also captures the video
123 VideoEncoder* encoder;
124 bool internal_source;
126 // Target delay in milliseconds. A positive value indicates this stream is
127 // used for streaming instead of a real-time call.
130 // True if network a send-side packet buffer should be used to pace out
131 // packets onto the network.
134 // True if the stream should be suspended when the available bitrate fall
135 // below the minimum configured bitrate. If this variable is false, the
136 // stream may send at a rate higher than the estimated available bitrate.
137 // Enabling suspend_below_min_bitrate will also enable pacing and padding,
138 // otherwise, the video will be unable to recover from suspension.
139 bool suspend_below_min_bitrate;
142 // Gets interface used to insert captured frames. Valid as long as the
143 // VideoSendStream is valid.
144 virtual VideoSendStreamInput* Input() = 0;
146 virtual void StartSending() = 0;
147 virtual void StopSending() = 0;
149 virtual bool SetCodec(const VideoCodec& codec) = 0;
150 virtual VideoCodec GetCodec() = 0;
152 virtual Stats GetStats() const = 0;
155 virtual ~VideoSendStream() {}
158 } // namespace webrtc
160 #endif // WEBRTC_VIDEO_SEND_STREAM_H_