| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * libjingle | |
| 3 * Copyright 2014 Google Inc. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | |
| 9 * this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 * this list of conditions and the following disclaimer in the documentation | |
| 12 * and/or other materials provided with the distribution. | |
| 13 * 3. The name of the author may not be used to endorse or promote products | |
| 14 * derived from this software without specific prior written permission. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 */ | |
| 27 | |
| 28 #ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ | |
| 29 #define TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ | |
| 30 | |
| 31 #include <map> | |
| 32 #include <string> | |
| 33 #include <vector> | |
| 34 | |
| 35 #include "talk/media/base/mediaengine.h" | |
| 36 #include "talk/media/webrtc/webrtcvideochannelfactory.h" | |
| 37 #include "talk/media/webrtc/webrtcvideodecoderfactory.h" | |
| 38 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" | |
| 39 #include "webrtc/base/criticalsection.h" | |
| 40 #include "webrtc/base/scoped_ptr.h" | |
| 41 #include "webrtc/base/thread_annotations.h" | |
| 42 #include "webrtc/base/thread_checker.h" | |
| 43 #include "webrtc/media/base/videosinkinterface.h" | |
| 44 #include "webrtc/call.h" | |
| 45 #include "webrtc/transport.h" | |
| 46 #include "webrtc/video_frame.h" | |
| 47 #include "webrtc/video_receive_stream.h" | |
| 48 #include "webrtc/video_renderer.h" | |
| 49 #include "webrtc/video_send_stream.h" | |
| 50 | |
| 51 namespace webrtc { | |
| 52 class VideoDecoder; | |
| 53 class VideoEncoder; | |
| 54 } | |
| 55 | |
| 56 namespace rtc { | |
| 57 class Thread; | |
| 58 } // namespace rtc | |
| 59 | |
| 60 namespace cricket { | |
| 61 | |
| 62 class VideoCapturer; | |
| 63 class VideoFrame; | |
| 64 class VideoProcessor; | |
| 65 class VideoRenderer; | |
| 66 class VoiceMediaChannel; | |
| 67 class WebRtcDecoderObserver; | |
| 68 class WebRtcEncoderObserver; | |
| 69 class WebRtcLocalStreamInfo; | |
| 70 class WebRtcRenderAdapter; | |
| 71 class WebRtcVideoChannelRecvInfo; | |
| 72 class WebRtcVideoChannelSendInfo; | |
| 73 class WebRtcVoiceEngine; | |
| 74 class WebRtcVoiceMediaChannel; | |
| 75 | |
| 76 struct CapturedFrame; | |
| 77 struct Device; | |
| 78 | |
| 79 // Exposed here for unittests. | |
| 80 std::vector<VideoCodec> DefaultVideoCodecList(); | |
| 81 | |
| 82 class UnsignalledSsrcHandler { | |
| 83 public: | |
| 84 enum Action { | |
| 85 kDropPacket, | |
| 86 kDeliverPacket, | |
| 87 }; | |
| 88 virtual Action OnUnsignalledSsrc(WebRtcVideoChannel2* channel, | |
| 89 uint32_t ssrc) = 0; | |
| 90 }; | |
| 91 | |
| 92 // TODO(pbos): Remove, use external handlers only. | |
| 93 class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler { | |
| 94 public: | |
| 95 DefaultUnsignalledSsrcHandler(); | |
| 96 Action OnUnsignalledSsrc(WebRtcVideoChannel2* channel, | |
| 97 uint32_t ssrc) override; | |
| 98 | |
| 99 rtc::VideoSinkInterface<VideoFrame>* GetDefaultSink() const; | |
| 100 void SetDefaultSink(VideoMediaChannel* channel, | |
| 101 rtc::VideoSinkInterface<VideoFrame>* sink); | |
| 102 | |
| 103 private: | |
| 104 uint32_t default_recv_ssrc_; | |
| 105 rtc::VideoSinkInterface<VideoFrame>* default_sink_; | |
| 106 }; | |
| 107 | |
| 108 // WebRtcVideoEngine2 is used for the new native WebRTC Video API (webrtc:1667). | |
| 109 class WebRtcVideoEngine2 { | |
| 110 public: | |
| 111 WebRtcVideoEngine2(); | |
| 112 ~WebRtcVideoEngine2(); | |
| 113 | |
| 114 // Basic video engine implementation. | |
| 115 void Init(); | |
| 116 | |
| 117 WebRtcVideoChannel2* CreateChannel(webrtc::Call* call, | |
| 118 const VideoOptions& options); | |
| 119 | |
| 120 const std::vector<VideoCodec>& codecs() const; | |
| 121 RtpCapabilities GetCapabilities() const; | |
| 122 | |
| 123 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does | |
| 124 // not take the ownership of |decoder_factory|. The caller needs to make sure | |
| 125 // that |decoder_factory| outlives the video engine. | |
| 126 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); | |
| 127 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does | |
| 128 // not take the ownership of |encoder_factory|. The caller needs to make sure | |
| 129 // that |encoder_factory| outlives the video engine. | |
| 130 virtual void SetExternalEncoderFactory( | |
| 131 WebRtcVideoEncoderFactory* encoder_factory); | |
| 132 | |
| 133 private: | |
| 134 std::vector<VideoCodec> GetSupportedCodecs() const; | |
| 135 | |
| 136 std::vector<VideoCodec> video_codecs_; | |
| 137 | |
| 138 bool initialized_; | |
| 139 | |
| 140 WebRtcVideoDecoderFactory* external_decoder_factory_; | |
| 141 WebRtcVideoEncoderFactory* external_encoder_factory_; | |
| 142 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; | |
| 143 }; | |
| 144 | |
| 145 class WebRtcVideoChannel2 : public VideoMediaChannel, | |
| 146 public webrtc::Transport, | |
| 147 public webrtc::LoadObserver { | |
| 148 public: | |
| 149 WebRtcVideoChannel2(webrtc::Call* call, | |
| 150 const VideoOptions& options, | |
| 151 const std::vector<VideoCodec>& recv_codecs, | |
| 152 WebRtcVideoEncoderFactory* external_encoder_factory, | |
| 153 WebRtcVideoDecoderFactory* external_decoder_factory); | |
| 154 ~WebRtcVideoChannel2() override; | |
| 155 | |
| 156 // VideoMediaChannel implementation | |
| 157 bool SetSendParameters(const VideoSendParameters& params) override; | |
| 158 bool SetRecvParameters(const VideoRecvParameters& params) override; | |
| 159 bool GetSendCodec(VideoCodec* send_codec) override; | |
| 160 bool SetSend(bool send) override; | |
| 161 bool SetVideoSend(uint32_t ssrc, | |
| 162 bool mute, | |
| 163 const VideoOptions* options) override; | |
| 164 bool AddSendStream(const StreamParams& sp) override; | |
| 165 bool RemoveSendStream(uint32_t ssrc) override; | |
| 166 bool AddRecvStream(const StreamParams& sp) override; | |
| 167 bool AddRecvStream(const StreamParams& sp, bool default_stream); | |
| 168 bool RemoveRecvStream(uint32_t ssrc) override; | |
| 169 bool SetSink(uint32_t ssrc, | |
| 170 rtc::VideoSinkInterface<VideoFrame>* sink) override; | |
| 171 bool GetStats(VideoMediaInfo* info) override; | |
| 172 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; | |
| 173 | |
| 174 void OnPacketReceived(rtc::Buffer* packet, | |
| 175 const rtc::PacketTime& packet_time) override; | |
| 176 void OnRtcpReceived(rtc::Buffer* packet, | |
| 177 const rtc::PacketTime& packet_time) override; | |
| 178 void OnReadyToSend(bool ready) override; | |
| 179 void SetInterface(NetworkInterface* iface) override; | |
| 180 | |
| 181 void OnLoadUpdate(Load load) override; | |
| 182 | |
| 183 // Implemented for VideoMediaChannelTest. | |
| 184 bool sending() const { return sending_; } | |
| 185 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } | |
| 186 | |
| 187 private: | |
| 188 class WebRtcVideoReceiveStream; | |
| 189 struct VideoCodecSettings { | |
| 190 VideoCodecSettings(); | |
| 191 | |
| 192 bool operator==(const VideoCodecSettings& other) const; | |
| 193 bool operator!=(const VideoCodecSettings& other) const; | |
| 194 | |
| 195 VideoCodec codec; | |
| 196 webrtc::FecConfig fec; | |
| 197 int rtx_payload_type; | |
| 198 }; | |
| 199 | |
| 200 struct ChangedSendParameters { | |
| 201 // These optionals are unset if not changed. | |
| 202 rtc::Optional<VideoCodecSettings> codec; | |
| 203 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; | |
| 204 rtc::Optional<int> max_bandwidth_bps; | |
| 205 rtc::Optional<VideoOptions> options; | |
| 206 rtc::Optional<webrtc::RtcpMode> rtcp_mode; | |
| 207 }; | |
| 208 | |
| 209 struct ChangedRecvParameters { | |
| 210 // These optionals are unset if not changed. | |
| 211 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; | |
| 212 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; | |
| 213 rtc::Optional<webrtc::RtcpMode> rtcp_mode; | |
| 214 }; | |
| 215 | |
| 216 bool GetChangedSendParameters(const VideoSendParameters& params, | |
| 217 ChangedSendParameters* changed_params) const; | |
| 218 bool GetChangedRecvParameters(const VideoRecvParameters& params, | |
| 219 ChangedRecvParameters* changed_params) const; | |
| 220 | |
| 221 bool MuteStream(uint32_t ssrc, bool mute); | |
| 222 | |
| 223 void SetMaxSendBandwidth(int bps); | |
| 224 void SetOptions(const VideoOptions& options); | |
| 225 | |
| 226 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, | |
| 227 const StreamParams& sp) const; | |
| 228 bool CodecIsExternallySupported(const std::string& name) const; | |
| 229 bool ValidateSendSsrcAvailability(const StreamParams& sp) const | |
| 230 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | |
| 231 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const | |
| 232 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | |
| 233 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | |
| 234 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | |
| 235 | |
| 236 static std::string CodecSettingsVectorToString( | |
| 237 const std::vector<VideoCodecSettings>& codecs); | |
| 238 | |
| 239 // Wrapper for the sender part, this is where the capturer is connected and | |
| 240 // frames are then converted from cricket frames to webrtc frames. | |
| 241 class WebRtcVideoSendStream : public sigslot::has_slots<> { | |
| 242 public: | |
| 243 WebRtcVideoSendStream( | |
| 244 webrtc::Call* call, | |
| 245 const StreamParams& sp, | |
| 246 const webrtc::VideoSendStream::Config& config, | |
| 247 WebRtcVideoEncoderFactory* external_encoder_factory, | |
| 248 const VideoOptions& options, | |
| 249 int max_bitrate_bps, | |
| 250 const rtc::Optional<VideoCodecSettings>& codec_settings, | |
| 251 const std::vector<webrtc::RtpExtension>& rtp_extensions, | |
| 252 const VideoSendParameters& send_params); | |
| 253 ~WebRtcVideoSendStream(); | |
| 254 | |
| 255 void SetOptions(const VideoOptions& options); | |
| 256 // TODO(pbos): Move logic from SetOptions into this method. | |
| 257 void SetSendParameters(const ChangedSendParameters& send_params); | |
| 258 | |
| 259 void InputFrame(VideoCapturer* capturer, const VideoFrame* frame); | |
| 260 bool SetCapturer(VideoCapturer* capturer); | |
| 261 void MuteStream(bool mute); | |
| 262 bool DisconnectCapturer(); | |
| 263 | |
| 264 void Start(); | |
| 265 void Stop(); | |
| 266 | |
| 267 const std::vector<uint32_t>& GetSsrcs() const; | |
| 268 VideoSenderInfo GetVideoSenderInfo(); | |
| 269 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | |
| 270 | |
| 271 private: | |
| 272 // Parameters needed to reconstruct the underlying stream. | |
| 273 // webrtc::VideoSendStream doesn't support setting a lot of options on the | |
| 274 // fly, so when those need to be changed we tear down and reconstruct with | |
| 275 // similar parameters depending on which options changed etc. | |
| 276 struct VideoSendStreamParameters { | |
| 277 VideoSendStreamParameters( | |
| 278 const webrtc::VideoSendStream::Config& config, | |
| 279 const VideoOptions& options, | |
| 280 int max_bitrate_bps, | |
| 281 const rtc::Optional<VideoCodecSettings>& codec_settings); | |
| 282 webrtc::VideoSendStream::Config config; | |
| 283 VideoOptions options; | |
| 284 int max_bitrate_bps; | |
| 285 rtc::Optional<VideoCodecSettings> codec_settings; | |
| 286 // Sent resolutions + bitrates etc. by the underlying VideoSendStream, | |
| 287 // typically changes when setting a new resolution or reconfiguring | |
| 288 // bitrates. | |
| 289 webrtc::VideoEncoderConfig encoder_config; | |
| 290 }; | |
| 291 | |
| 292 struct AllocatedEncoder { | |
| 293 AllocatedEncoder(webrtc::VideoEncoder* encoder, | |
| 294 webrtc::VideoCodecType type, | |
| 295 bool external); | |
| 296 webrtc::VideoEncoder* encoder; | |
| 297 webrtc::VideoEncoder* external_encoder; | |
| 298 webrtc::VideoCodecType type; | |
| 299 bool external; | |
| 300 }; | |
| 301 | |
| 302 struct Dimensions { | |
| 303 // Initial encoder configuration (QCIF, 176x144) frame (to ensure that | |
| 304 // hardware encoders can be initialized). This gives us low memory usage | |
| 305 // but also makes it so configuration errors are discovered at the time we | |
| 306 // apply the settings rather than when we get the first frame (waiting for | |
| 307 // the first frame to know that you gave a bad codec parameter could make | |
| 308 // debugging hard). | |
| 309 // TODO(pbos): Consider setting up encoders lazily. | |
| 310 Dimensions() : width(176), height(144), is_screencast(false) {} | |
| 311 int width; | |
| 312 int height; | |
| 313 bool is_screencast; | |
| 314 }; | |
| 315 | |
| 316 union VideoEncoderSettings { | |
| 317 webrtc::VideoCodecH264 h264; | |
| 318 webrtc::VideoCodecVP8 vp8; | |
| 319 webrtc::VideoCodecVP9 vp9; | |
| 320 }; | |
| 321 | |
| 322 static std::vector<webrtc::VideoStream> CreateVideoStreams( | |
| 323 const VideoCodec& codec, | |
| 324 const VideoOptions& options, | |
| 325 int max_bitrate_bps, | |
| 326 size_t num_streams); | |
| 327 static std::vector<webrtc::VideoStream> CreateSimulcastVideoStreams( | |
| 328 const VideoCodec& codec, | |
| 329 const VideoOptions& options, | |
| 330 int max_bitrate_bps, | |
| 331 size_t num_streams); | |
| 332 | |
| 333 void* ConfigureVideoEncoderSettings(const VideoCodec& codec, | |
| 334 const VideoOptions& options, | |
| 335 bool is_screencast) | |
| 336 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 337 | |
| 338 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec) | |
| 339 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 340 void DestroyVideoEncoder(AllocatedEncoder* encoder) | |
| 341 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 342 void SetCodecAndOptions(const VideoCodecSettings& codec, | |
| 343 const VideoOptions& options) | |
| 344 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 345 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 346 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | |
| 347 const Dimensions& dimensions, | |
| 348 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 349 void SetDimensions(int width, int height, bool is_screencast) | |
| 350 EXCLUSIVE_LOCKS_REQUIRED(lock_); | |
| 351 | |
| 352 const std::vector<uint32_t> ssrcs_; | |
| 353 const std::vector<SsrcGroup> ssrc_groups_; | |
| 354 webrtc::Call* const call_; | |
| 355 WebRtcVideoEncoderFactory* const external_encoder_factory_ | |
| 356 GUARDED_BY(lock_); | |
| 357 | |
| 358 rtc::CriticalSection lock_; | |
| 359 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | |
| 360 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | |
| 361 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | |
| 362 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | |
| 363 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | |
| 364 Dimensions last_dimensions_ GUARDED_BY(lock_); | |
| 365 | |
| 366 VideoCapturer* capturer_ GUARDED_BY(lock_); | |
| 367 bool sending_ GUARDED_BY(lock_); | |
| 368 bool muted_ GUARDED_BY(lock_); | |
| 369 VideoFormat format_ GUARDED_BY(lock_); | |
| 370 int old_adapt_changes_ GUARDED_BY(lock_); | |
| 371 | |
| 372 // The timestamp of the first frame received | |
| 373 // Used to generate the timestamps of subsequent frames | |
| 374 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | |
| 375 | |
| 376 // The timestamp of the last frame received | |
| 377 // Used to generate timestamp for the black frame when capturer is removed | |
| 378 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | |
| 379 }; | |
| 380 | |
| 381 // Wrapper for the receiver part, contains configs etc. that are needed to | |
| 382 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper | |
| 383 // between webrtc::VideoRenderer and cricket::VideoRenderer. | |
| 384 class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { | |
| 385 public: | |
| 386 WebRtcVideoReceiveStream( | |
| 387 webrtc::Call* call, | |
| 388 const StreamParams& sp, | |
| 389 const webrtc::VideoReceiveStream::Config& config, | |
| 390 WebRtcVideoDecoderFactory* external_decoder_factory, | |
| 391 bool default_stream, | |
| 392 const std::vector<VideoCodecSettings>& recv_codecs, | |
| 393 bool disable_prerenderer_smoothing); | |
| 394 ~WebRtcVideoReceiveStream(); | |
| 395 | |
| 396 const std::vector<uint32_t>& GetSsrcs() const; | |
| 397 | |
| 398 void SetLocalSsrc(uint32_t local_ssrc); | |
| 399 void SetFeedbackParameters(bool nack_enabled, | |
| 400 bool remb_enabled, | |
| 401 bool transport_cc_enabled); | |
| 402 void SetRecvParameters(const ChangedRecvParameters& recv_params); | |
| 403 | |
| 404 void RenderFrame(const webrtc::VideoFrame& frame, | |
| 405 int time_to_render_ms) override; | |
| 406 bool IsTextureSupported() const override; | |
| 407 bool SmoothsRenderedFrames() const override; | |
| 408 bool IsDefaultStream() const; | |
| 409 | |
| 410 void SetSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink); | |
| 411 | |
| 412 VideoReceiverInfo GetVideoReceiverInfo(); | |
| 413 | |
| 414 private: | |
| 415 struct AllocatedDecoder { | |
| 416 AllocatedDecoder(webrtc::VideoDecoder* decoder, | |
| 417 webrtc::VideoCodecType type, | |
| 418 bool external); | |
| 419 webrtc::VideoDecoder* decoder; | |
| 420 // Decoder wrapped into a fallback decoder to permit software fallback. | |
| 421 webrtc::VideoDecoder* external_decoder; | |
| 422 webrtc::VideoCodecType type; | |
| 423 bool external; | |
| 424 }; | |
| 425 | |
| 426 void RecreateWebRtcStream(); | |
| 427 | |
| 428 void ConfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs, | |
| 429 std::vector<AllocatedDecoder>* old_codecs); | |
| 430 AllocatedDecoder CreateOrReuseVideoDecoder( | |
| 431 std::vector<AllocatedDecoder>* old_decoder, | |
| 432 const VideoCodec& codec); | |
| 433 void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders); | |
| 434 | |
| 435 std::string GetCodecNameFromPayloadType(int payload_type); | |
| 436 | |
| 437 webrtc::Call* const call_; | |
| 438 const std::vector<uint32_t> ssrcs_; | |
| 439 const std::vector<SsrcGroup> ssrc_groups_; | |
| 440 | |
| 441 webrtc::VideoReceiveStream* stream_; | |
| 442 const bool default_stream_; | |
| 443 webrtc::VideoReceiveStream::Config config_; | |
| 444 | |
| 445 WebRtcVideoDecoderFactory* const external_decoder_factory_; | |
| 446 std::vector<AllocatedDecoder> allocated_decoders_; | |
| 447 | |
| 448 const bool disable_prerenderer_smoothing_; | |
| 449 | |
| 450 rtc::CriticalSection sink_lock_; | |
| 451 rtc::VideoSinkInterface<cricket::VideoFrame>* sink_ GUARDED_BY(sink_lock_); | |
| 452 int last_width_ GUARDED_BY(sink_lock_); | |
| 453 int last_height_ GUARDED_BY(sink_lock_); | |
| 454 // Expands remote RTP timestamps to int64_t to be able to estimate how long | |
| 455 // the stream has been running. | |
| 456 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ | |
| 457 GUARDED_BY(sink_lock_); | |
| 458 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); | |
| 459 // Start NTP time is estimated as current remote NTP time (estimated from | |
| 460 // RTCP) minus the elapsed time, as soon as remote NTP time is available. | |
| 461 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); | |
| 462 }; | |
| 463 | |
| 464 void Construct(webrtc::Call* call, WebRtcVideoEngine2* engine); | |
| 465 void SetDefaultOptions(); | |
| 466 | |
| 467 bool SendRtp(const uint8_t* data, | |
| 468 size_t len, | |
| 469 const webrtc::PacketOptions& options) override; | |
| 470 bool SendRtcp(const uint8_t* data, size_t len) override; | |
| 471 | |
| 472 void StartAllSendStreams(); | |
| 473 void StopAllSendStreams(); | |
| 474 | |
| 475 static std::vector<VideoCodecSettings> MapCodecs( | |
| 476 const std::vector<VideoCodec>& codecs); | |
| 477 std::vector<VideoCodecSettings> FilterSupportedCodecs( | |
| 478 const std::vector<VideoCodecSettings>& mapped_codecs) const; | |
| 479 static bool ReceiveCodecsHaveChanged(std::vector<VideoCodecSettings> before, | |
| 480 std::vector<VideoCodecSettings> after); | |
| 481 | |
| 482 void FillSenderStats(VideoMediaInfo* info); | |
| 483 void FillReceiverStats(VideoMediaInfo* info); | |
| 484 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, | |
| 485 VideoMediaInfo* info); | |
| 486 | |
| 487 rtc::ThreadChecker thread_checker_; | |
| 488 | |
| 489 uint32_t rtcp_receiver_report_ssrc_; | |
| 490 bool sending_; | |
| 491 webrtc::Call* const call_; | |
| 492 | |
| 493 uint32_t default_send_ssrc_; | |
| 494 | |
| 495 DefaultUnsignalledSsrcHandler default_unsignalled_ssrc_handler_; | |
| 496 UnsignalledSsrcHandler* const unsignalled_ssrc_handler_; | |
| 497 | |
| 498 // Separate list of set capturers used to signal CPU adaptation. These should | |
| 499 // not be locked while calling methods that take other locks to prevent | |
| 500 // lock-order inversions. | |
| 501 rtc::CriticalSection capturer_crit_; | |
| 502 bool signal_cpu_adaptation_ GUARDED_BY(capturer_crit_); | |
| 503 std::map<uint32_t, VideoCapturer*> capturers_ GUARDED_BY(capturer_crit_); | |
| 504 | |
| 505 rtc::CriticalSection stream_crit_; | |
| 506 // Using primary-ssrc (first ssrc) as key. | |
| 507 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_ | |
| 508 GUARDED_BY(stream_crit_); | |
| 509 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ | |
| 510 GUARDED_BY(stream_crit_); | |
| 511 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_); | |
| 512 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); | |
| 513 | |
| 514 rtc::Optional<VideoCodecSettings> send_codec_; | |
| 515 std::vector<webrtc::RtpExtension> send_rtp_extensions_; | |
| 516 | |
| 517 WebRtcVideoEncoderFactory* const external_encoder_factory_; | |
| 518 WebRtcVideoDecoderFactory* const external_decoder_factory_; | |
| 519 std::vector<VideoCodecSettings> recv_codecs_; | |
| 520 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | |
| 521 webrtc::Call::Config::BitrateConfig bitrate_config_; | |
| 522 VideoOptions options_; | |
| 523 // TODO(deadbeef): Don't duplicate information between | |
| 524 // send_params/recv_params, rtp_extensions, options, etc. | |
| 525 VideoSendParameters send_params_; | |
| 526 VideoRecvParameters recv_params_; | |
| 527 }; | |
| 528 | |
| 529 } // namespace cricket | |
| 530 | |
| 531 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ | |
| OLD | NEW |