blob: 7710c043d147a6e63bafdb7bd30047e594d52244 [file] [log] [blame]
eladalonf1841382017-06-12 01:16:46 -07001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
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.
9 */
10
11#ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_
12#define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_
13
14#include <map>
15#include <memory>
16#include <set>
17#include <string>
18#include <vector>
19
20#include "webrtc/api/call/transport.h"
kwiberg84f6a3f2017-09-05 08:43:13 -070021#include "webrtc/api/optional.h"
eladalonf1841382017-06-12 01:16:46 -070022#include "webrtc/api/video/video_frame.h"
eladalonf1841382017-06-12 01:16:46 -070023#include "webrtc/call/call.h"
24#include "webrtc/call/flexfec_receive_stream.h"
aleloi440b6d92017-08-22 05:43:23 -070025#include "webrtc/call/video_receive_stream.h"
26#include "webrtc/call/video_send_stream.h"
eladalonf1841382017-06-12 01:16:46 -070027#include "webrtc/media/base/mediaengine.h"
28#include "webrtc/media/base/videosinkinterface.h"
29#include "webrtc/media/base/videosourceinterface.h"
30#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
31#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020032#include "webrtc/rtc_base/asyncinvoker.h"
33#include "webrtc/rtc_base/criticalsection.h"
34#include "webrtc/rtc_base/networkroute.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020035#include "webrtc/rtc_base/thread_annotations.h"
36#include "webrtc/rtc_base/thread_checker.h"
eladalonf1841382017-06-12 01:16:46 -070037
38namespace webrtc {
39class VideoDecoder;
40class VideoEncoder;
41struct MediaConfig;
42}
43
44namespace rtc {
45class Thread;
46} // namespace rtc
47
48namespace cricket {
49
magjeda35df422017-08-30 04:21:30 -070050class EncoderFactoryAdapter;
eladalonf1841382017-06-12 01:16:46 -070051class VideoCapturer;
52class VideoProcessor;
53class VideoRenderer;
54class VoiceMediaChannel;
55class WebRtcDecoderObserver;
56class WebRtcEncoderObserver;
57class WebRtcLocalStreamInfo;
58class WebRtcRenderAdapter;
59class WebRtcVideoChannel;
60class WebRtcVideoChannelRecvInfo;
61class WebRtcVideoChannelSendInfo;
62class WebRtcVoiceEngine;
63class WebRtcVoiceMediaChannel;
64
65struct Device;
66
67class UnsignalledSsrcHandler {
68 public:
69 enum Action {
70 kDropPacket,
71 kDeliverPacket,
72 };
73 virtual Action OnUnsignalledSsrc(WebRtcVideoChannel* channel,
74 uint32_t ssrc) = 0;
75 virtual ~UnsignalledSsrcHandler() = default;
76};
77
78// TODO(pbos): Remove, use external handlers only.
79class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler {
80 public:
81 DefaultUnsignalledSsrcHandler();
82 Action OnUnsignalledSsrc(WebRtcVideoChannel* channel,
83 uint32_t ssrc) override;
84
85 rtc::VideoSinkInterface<webrtc::VideoFrame>* GetDefaultSink() const;
86 void SetDefaultSink(WebRtcVideoChannel* channel,
87 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink);
88
89 virtual ~DefaultUnsignalledSsrcHandler() = default;
90
91 private:
92 rtc::VideoSinkInterface<webrtc::VideoFrame>* default_sink_;
93};
94
95// WebRtcVideoEngine is used for the new native WebRTC Video API (webrtc:1667).
96class WebRtcVideoEngine {
97 public:
98 WebRtcVideoEngine();
99 virtual ~WebRtcVideoEngine();
100
101 // Basic video engine implementation.
102 void Init();
103
104 WebRtcVideoChannel* CreateChannel(webrtc::Call* call,
105 const MediaConfig& config,
106 const VideoOptions& options);
107
108 std::vector<VideoCodec> codecs() const;
109 RtpCapabilities GetCapabilities() const;
110
111 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does
112 // not take the ownership of |decoder_factory|. The caller needs to make sure
113 // that |decoder_factory| outlives the video engine.
114 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory);
115 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does
116 // not take the ownership of |encoder_factory|. The caller needs to make sure
117 // that |encoder_factory| outlives the video engine.
118 virtual void SetExternalEncoderFactory(
119 WebRtcVideoEncoderFactory* encoder_factory);
120
121 private:
122 bool initialized_;
123
perkj1f885312017-09-04 02:43:10 -0700124 WebRtcVideoDecoderFactory* external_decoder_factory_;
magjeda35df422017-08-30 04:21:30 -0700125 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_;
eladalonf1841382017-06-12 01:16:46 -0700126};
127
128class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
129 public:
130 WebRtcVideoChannel(webrtc::Call* call,
131 const MediaConfig& config,
132 const VideoOptions& options,
magjeda35df422017-08-30 04:21:30 -0700133 const EncoderFactoryAdapter& encoder_factory,
perkj1f885312017-09-04 02:43:10 -0700134 WebRtcVideoDecoderFactory* external_decoder_factory);
eladalonf1841382017-06-12 01:16:46 -0700135 ~WebRtcVideoChannel() override;
136
137 // VideoMediaChannel implementation
138 rtc::DiffServCodePoint PreferredDscp() const override;
139
140 bool SetSendParameters(const VideoSendParameters& params) override;
141 bool SetRecvParameters(const VideoRecvParameters& params) override;
142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
143 bool SetRtpSendParameters(uint32_t ssrc,
144 const webrtc::RtpParameters& parameters) override;
145 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override;
146 bool SetRtpReceiveParameters(
147 uint32_t ssrc,
148 const webrtc::RtpParameters& parameters) override;
149 bool GetSendCodec(VideoCodec* send_codec) override;
150 bool SetSend(bool send) override;
151 bool SetVideoSend(
152 uint32_t ssrc,
153 bool enable,
154 const VideoOptions* options,
155 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) override;
156 bool AddSendStream(const StreamParams& sp) override;
157 bool RemoveSendStream(uint32_t ssrc) override;
158 bool AddRecvStream(const StreamParams& sp) override;
159 bool AddRecvStream(const StreamParams& sp, bool default_stream);
160 bool RemoveRecvStream(uint32_t ssrc) override;
161 bool SetSink(uint32_t ssrc,
162 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
163 void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) override;
164 bool GetStats(VideoMediaInfo* info) override;
165
166 void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
167 const rtc::PacketTime& packet_time) override;
168 void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
169 const rtc::PacketTime& packet_time) override;
170 void OnReadyToSend(bool ready) override;
171 void OnNetworkRouteChanged(const std::string& transport_name,
172 const rtc::NetworkRoute& network_route) override;
173 void OnTransportOverheadChanged(int transport_overhead_per_packet) override;
174 void SetInterface(NetworkInterface* iface) override;
175
176 // Implemented for VideoMediaChannelTest.
177 bool sending() const { return sending_; }
178
179 rtc::Optional<uint32_t> GetDefaultReceiveStreamSsrc();
180
181 // AdaptReason is used for expressing why a WebRtcVideoSendStream request
182 // a lower input frame size than the currently configured camera input frame
183 // size. There can be more than one reason OR:ed together.
184 enum AdaptReason {
185 ADAPTREASON_NONE = 0,
186 ADAPTREASON_CPU = 1,
187 ADAPTREASON_BANDWIDTH = 2,
188 };
189
sprang67561a62017-06-15 06:34:42 -0700190 static constexpr int kDefaultQpMax = 56;
191
eladalonf1841382017-06-12 01:16:46 -0700192 private:
193 class WebRtcVideoReceiveStream;
194 struct VideoCodecSettings {
195 VideoCodecSettings();
196
197 // Checks if all members of |*this| are equal to the corresponding members
198 // of |other|.
199 bool operator==(const VideoCodecSettings& other) const;
200 bool operator!=(const VideoCodecSettings& other) const;
201
202 // Checks if all members of |a|, except |flexfec_payload_type|, are equal
203 // to the corresponding members of |b|.
204 static bool EqualsDisregardingFlexfec(const VideoCodecSettings& a,
205 const VideoCodecSettings& b);
206
207 VideoCodec codec;
208 webrtc::UlpfecConfig ulpfec;
209 int flexfec_payload_type;
210 int rtx_payload_type;
211 };
212
213 struct ChangedSendParameters {
214 // These optionals are unset if not changed.
215 rtc::Optional<VideoCodecSettings> codec;
216 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions;
217 rtc::Optional<int> max_bandwidth_bps;
218 rtc::Optional<bool> conference_mode;
219 rtc::Optional<webrtc::RtcpMode> rtcp_mode;
220 };
221
222 struct ChangedRecvParameters {
223 // These optionals are unset if not changed.
224 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings;
225 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions;
226 // Keep track of the FlexFEC payload type separately from |codec_settings|.
227 // This allows us to recreate the FlexfecReceiveStream separately from the
228 // VideoReceiveStream when the FlexFEC payload type is changed.
229 rtc::Optional<int> flexfec_payload_type;
230 };
231
232 bool GetChangedSendParameters(const VideoSendParameters& params,
233 ChangedSendParameters* changed_params) const;
234 bool GetChangedRecvParameters(const VideoRecvParameters& params,
235 ChangedRecvParameters* changed_params) const;
236
237 void SetMaxSendBandwidth(int bps);
238
239 void ConfigureReceiverRtp(
240 webrtc::VideoReceiveStream::Config* config,
241 webrtc::FlexfecReceiveStream::Config* flexfec_config,
242 const StreamParams& sp) const;
243 bool ValidateSendSsrcAvailability(const StreamParams& sp) const
244 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
245 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const
246 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
247 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream)
248 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_);
249
250 static std::string CodecSettingsVectorToString(
251 const std::vector<VideoCodecSettings>& codecs);
252
253 // Wrapper for the sender part.
254 class WebRtcVideoSendStream
255 : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
256 public:
257 WebRtcVideoSendStream(
258 webrtc::Call* call,
259 const StreamParams& sp,
260 webrtc::VideoSendStream::Config config,
261 const VideoOptions& options,
magjeda35df422017-08-30 04:21:30 -0700262 const EncoderFactoryAdapter& encoder_factory,
eladalonf1841382017-06-12 01:16:46 -0700263 bool enable_cpu_overuse_detection,
264 int max_bitrate_bps,
265 const rtc::Optional<VideoCodecSettings>& codec_settings,
266 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
267 const VideoSendParameters& send_params);
268 virtual ~WebRtcVideoSendStream();
269
270 void SetSendParameters(const ChangedSendParameters& send_params);
271 bool SetRtpParameters(const webrtc::RtpParameters& parameters);
272 webrtc::RtpParameters GetRtpParameters() const;
273
274 // Implements rtc::VideoSourceInterface<webrtc::VideoFrame>.
275 // WebRtcVideoSendStream acts as a source to the webrtc::VideoSendStream
276 // in |stream_|. This is done to proxy VideoSinkWants from the encoder to
277 // the worker thread.
278 void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
279 const rtc::VideoSinkWants& wants) override;
280 void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
281
282 bool SetVideoSend(bool mute,
283 const VideoOptions* options,
284 rtc::VideoSourceInterface<webrtc::VideoFrame>* source);
285
286 void SetSend(bool send);
287
288 const std::vector<uint32_t>& GetSsrcs() const;
289 VideoSenderInfo GetVideoSenderInfo(bool log_stats);
290 void FillBitrateInfo(BandwidthEstimationInfo* bwe_info);
291
292 private:
293 // Parameters needed to reconstruct the underlying stream.
294 // webrtc::VideoSendStream doesn't support setting a lot of options on the
295 // fly, so when those need to be changed we tear down and reconstruct with
296 // similar parameters depending on which options changed etc.
297 struct VideoSendStreamParameters {
298 VideoSendStreamParameters(
299 webrtc::VideoSendStream::Config config,
300 const VideoOptions& options,
301 int max_bitrate_bps,
302 const rtc::Optional<VideoCodecSettings>& codec_settings);
303 webrtc::VideoSendStream::Config config;
304 VideoOptions options;
305 int max_bitrate_bps;
306 bool conference_mode;
307 rtc::Optional<VideoCodecSettings> codec_settings;
308 // Sent resolutions + bitrates etc. by the underlying VideoSendStream,
309 // typically changes when setting a new resolution or reconfiguring
310 // bitrates.
311 webrtc::VideoEncoderConfig encoder_config;
312 };
313
eladalonf1841382017-06-12 01:16:46 -0700314 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
315 ConfigureVideoEncoderSettings(const VideoCodec& codec);
eladalonf1841382017-06-12 01:16:46 -0700316 void SetCodec(const VideoCodecSettings& codec,
317 bool force_encoder_allocation);
318 void RecreateWebRtcStream();
319 webrtc::VideoEncoderConfig CreateVideoEncoderConfig(
320 const VideoCodec& codec) const;
321 void ReconfigureEncoder();
322 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters);
323
324 // Calls Start or Stop according to whether or not |sending_| is true,
325 // and whether or not the encoding in |rtp_parameters_| is active.
326 void UpdateSendState();
327
328 webrtc::VideoSendStream::DegradationPreference GetDegradationPreference()
329 const EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_);
330
331 rtc::ThreadChecker thread_checker_;
332 rtc::AsyncInvoker invoker_;
333 rtc::Thread* worker_thread_;
334 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_);
335 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_);
336 webrtc::Call* const call_;
337 const bool enable_cpu_overuse_detection_;
338 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_
339 ACCESS_ON(&thread_checker_);
magjeda35df422017-08-30 04:21:30 -0700340 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_
eladalonf1841382017-06-12 01:16:46 -0700341 ACCESS_ON(&thread_checker_);
342
343 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_);
344 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
345 ACCESS_ON(&thread_checker_);
346 // Contains settings that are the same for all streams in the MediaChannel,
347 // such as codecs, header extensions, and the global bitrate limit for the
348 // entire channel.
349 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_);
350 // Contains settings that are unique for each stream, such as max_bitrate.
351 // Does *not* contain codecs, however.
352 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_.
353 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only
354 // one stream per MediaChannel.
355 webrtc::RtpParameters rtp_parameters_ ACCESS_ON(&thread_checker_);
magjeda35df422017-08-30 04:21:30 -0700356 std::unique_ptr<webrtc::VideoEncoder> allocated_encoder_
357 ACCESS_ON(&thread_checker_);
358 VideoCodec allocated_codec_ ACCESS_ON(&thread_checker_);
eladalonf1841382017-06-12 01:16:46 -0700359
360 bool sending_ ACCESS_ON(&thread_checker_);
361 };
362
363 // Wrapper for the receiver part, contains configs etc. that are needed to
364 // reconstruct the underlying VideoReceiveStream.
365 class WebRtcVideoReceiveStream
366 : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
367 public:
368 WebRtcVideoReceiveStream(
369 webrtc::Call* call,
370 const StreamParams& sp,
371 webrtc::VideoReceiveStream::Config config,
perkj1f885312017-09-04 02:43:10 -0700372 WebRtcVideoDecoderFactory* external_decoder_factory,
eladalonf1841382017-06-12 01:16:46 -0700373 bool default_stream,
374 const std::vector<VideoCodecSettings>& recv_codecs,
375 const webrtc::FlexfecReceiveStream::Config& flexfec_config);
376 ~WebRtcVideoReceiveStream();
377
378 const std::vector<uint32_t>& GetSsrcs() const;
379 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const;
380
381 void SetLocalSsrc(uint32_t local_ssrc);
382 // TODO(deadbeef): Move these feedback parameters into the recv parameters.
383 void SetFeedbackParameters(bool nack_enabled,
384 bool remb_enabled,
385 bool transport_cc_enabled,
386 webrtc::RtcpMode rtcp_mode);
387 void SetRecvParameters(const ChangedRecvParameters& recv_params);
388
389 void OnFrame(const webrtc::VideoFrame& frame) override;
390 bool IsDefaultStream() const;
391
392 void SetSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink);
393
394 VideoReceiverInfo GetVideoReceiverInfo(bool log_stats);
395
396 private:
perkj1f885312017-09-04 02:43:10 -0700397 struct AllocatedDecoder {
398 AllocatedDecoder(webrtc::VideoDecoder* decoder,
399 webrtc::VideoCodecType type,
400 bool external);
401 webrtc::VideoDecoder* decoder;
402 // Decoder wrapped into a fallback decoder to permit software fallback.
403 webrtc::VideoDecoder* external_decoder;
404 webrtc::VideoCodecType type;
405 bool external;
406 };
407
eladalonf1841382017-06-12 01:16:46 -0700408 void RecreateWebRtcVideoStream();
409 void MaybeRecreateWebRtcFlexfecStream();
410
eladalonc0d481a2017-08-02 07:39:07 -0700411 void MaybeAssociateFlexfecWithVideo();
412 void MaybeDissociateFlexfecFromVideo();
413
perkj1f885312017-09-04 02:43:10 -0700414 void ConfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs,
415 std::vector<AllocatedDecoder>* old_codecs);
eladalonf1841382017-06-12 01:16:46 -0700416 void ConfigureFlexfecCodec(int flexfec_payload_type);
perkj1f885312017-09-04 02:43:10 -0700417 AllocatedDecoder CreateOrReuseVideoDecoder(
418 std::vector<AllocatedDecoder>* old_decoder,
419 const VideoCodec& codec);
420 void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders);
eladalonf1841382017-06-12 01:16:46 -0700421
422 std::string GetCodecNameFromPayloadType(int payload_type);
423
424 webrtc::Call* const call_;
425 StreamParams stream_params_;
426
427 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are
428 // destroyed by calling call_->DestroyVideoReceiveStream and
429 // call_->DestroyFlexfecReceiveStream, respectively.
430 webrtc::VideoReceiveStream* stream_;
431 const bool default_stream_;
432 webrtc::VideoReceiveStream::Config config_;
433 webrtc::FlexfecReceiveStream::Config flexfec_config_;
434 webrtc::FlexfecReceiveStream* flexfec_stream_;
435
perkj1f885312017-09-04 02:43:10 -0700436 WebRtcVideoDecoderFactory* const external_decoder_factory_;
437 std::vector<AllocatedDecoder> allocated_decoders_;
eladalonf1841382017-06-12 01:16:46 -0700438
439 rtc::CriticalSection sink_lock_;
440 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ GUARDED_BY(sink_lock_);
441 // Expands remote RTP timestamps to int64_t to be able to estimate how long
442 // the stream has been running.
443 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_
444 GUARDED_BY(sink_lock_);
445 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_);
446 // Start NTP time is estimated as current remote NTP time (estimated from
447 // RTCP) minus the elapsed time, as soon as remote NTP time is available.
448 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_);
449 };
450
451 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine);
452
453 bool SendRtp(const uint8_t* data,
454 size_t len,
455 const webrtc::PacketOptions& options) override;
456 bool SendRtcp(const uint8_t* data, size_t len) override;
457
458 static std::vector<VideoCodecSettings> MapCodecs(
459 const std::vector<VideoCodec>& codecs);
460 // Select what video codec will be used for sending, i.e. what codec is used
461 // for local encoding, based on supported remote codecs. The first remote
462 // codec that is supported locally will be selected.
463 rtc::Optional<VideoCodecSettings> SelectSendVideoCodec(
464 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const;
465
466 static bool NonFlexfecReceiveCodecsHaveChanged(
467 std::vector<VideoCodecSettings> before,
468 std::vector<VideoCodecSettings> after);
469
470 void FillSenderStats(VideoMediaInfo* info, bool log_stats);
471 void FillReceiverStats(VideoMediaInfo* info, bool log_stats);
472 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats,
473 VideoMediaInfo* info);
474 void FillSendAndReceiveCodecStats(VideoMediaInfo* video_media_info);
475
476 rtc::ThreadChecker thread_checker_;
477
478 uint32_t rtcp_receiver_report_ssrc_;
479 bool sending_;
480 webrtc::Call* const call_;
481
482 DefaultUnsignalledSsrcHandler default_unsignalled_ssrc_handler_;
483 UnsignalledSsrcHandler* const unsignalled_ssrc_handler_;
484
485 const MediaConfig::Video video_config_;
486
487 rtc::CriticalSection stream_crit_;
488 // Using primary-ssrc (first ssrc) as key.
489 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_
490 GUARDED_BY(stream_crit_);
491 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_
492 GUARDED_BY(stream_crit_);
493 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_);
494 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_);
495
496 rtc::Optional<VideoCodecSettings> send_codec_;
497 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_;
498
magjeda35df422017-08-30 04:21:30 -0700499 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_;
perkj1f885312017-09-04 02:43:10 -0700500 WebRtcVideoDecoderFactory* const external_decoder_factory_;
eladalonf1841382017-06-12 01:16:46 -0700501 std::vector<VideoCodecSettings> recv_codecs_;
502 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
503 // See reason for keeping track of the FlexFEC payload type separately in
504 // comment in WebRtcVideoChannel::ChangedRecvParameters.
505 int recv_flexfec_payload_type_;
506 webrtc::Call::Config::BitrateConfig bitrate_config_;
507 // TODO(deadbeef): Don't duplicate information between
508 // send_params/recv_params, rtp_extensions, options, etc.
509 VideoSendParameters send_params_;
510 VideoOptions default_send_options_;
511 VideoRecvParameters recv_params_;
512 int64_t last_stats_log_ms_;
513};
514
ilnik6b826ef2017-06-16 06:53:48 -0700515class EncoderStreamFactory
516 : public webrtc::VideoEncoderConfig::VideoStreamFactoryInterface {
517 public:
518 EncoderStreamFactory(std::string codec_name,
519 int max_qp,
520 int max_framerate,
521 bool is_screencast,
522 bool conference_mode);
523
524 private:
525 std::vector<webrtc::VideoStream> CreateEncoderStreams(
526 int width,
527 int height,
528 const webrtc::VideoEncoderConfig& encoder_config) override;
529
530 const std::string codec_name_;
531 const int max_qp_;
532 const int max_framerate_;
533 const bool is_screencast_;
534 const bool conference_mode_;
535};
536
eladalonf1841382017-06-12 01:16:46 -0700537} // namespace cricket
538
539#endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_