| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ |
| 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "webrtc/api/call/transport.h" | 20 #include "webrtc/api/call/transport.h" |
| 21 #include "webrtc/api/video/video_frame.h" | 21 #include "webrtc/api/video/video_frame.h" |
| 22 #include "webrtc/base/asyncinvoker.h" | 22 #include "webrtc/base/asyncinvoker.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 namespace cricket { | 48 namespace cricket { |
| 49 | 49 |
| 50 class VideoCapturer; | 50 class VideoCapturer; |
| 51 class VideoProcessor; | 51 class VideoProcessor; |
| 52 class VideoRenderer; | 52 class VideoRenderer; |
| 53 class VoiceMediaChannel; | 53 class VoiceMediaChannel; |
| 54 class WebRtcDecoderObserver; | 54 class WebRtcDecoderObserver; |
| 55 class WebRtcEncoderObserver; | 55 class WebRtcEncoderObserver; |
| 56 class WebRtcLocalStreamInfo; | 56 class WebRtcLocalStreamInfo; |
| 57 class WebRtcRenderAdapter; | 57 class WebRtcRenderAdapter; |
| 58 class WebRtcVideoChannel2; | 58 class WebRtcVideoChannel; |
| 59 class WebRtcVideoChannelRecvInfo; | 59 class WebRtcVideoChannelRecvInfo; |
| 60 class WebRtcVideoChannelSendInfo; | 60 class WebRtcVideoChannelSendInfo; |
| 61 class WebRtcVoiceEngine; | 61 class WebRtcVoiceEngine; |
| 62 class WebRtcVoiceMediaChannel; | 62 class WebRtcVoiceMediaChannel; |
| 63 | 63 |
| 64 struct Device; | 64 struct Device; |
| 65 | 65 |
| 66 class UnsignalledSsrcHandler { | 66 class UnsignalledSsrcHandler { |
| 67 public: | 67 public: |
| 68 enum Action { | 68 enum Action { |
| 69 kDropPacket, | 69 kDropPacket, |
| 70 kDeliverPacket, | 70 kDeliverPacket, |
| 71 }; | 71 }; |
| 72 virtual Action OnUnsignalledSsrc(WebRtcVideoChannel2* channel, | 72 virtual Action OnUnsignalledSsrc(WebRtcVideoChannel* channel, |
| 73 uint32_t ssrc) = 0; | 73 uint32_t ssrc) = 0; |
| 74 virtual ~UnsignalledSsrcHandler() = default; | 74 virtual ~UnsignalledSsrcHandler() = default; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // TODO(pbos): Remove, use external handlers only. | 77 // TODO(pbos): Remove, use external handlers only. |
| 78 class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler { | 78 class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler { |
| 79 public: | 79 public: |
| 80 DefaultUnsignalledSsrcHandler(); | 80 DefaultUnsignalledSsrcHandler(); |
| 81 Action OnUnsignalledSsrc(WebRtcVideoChannel2* channel, | 81 Action OnUnsignalledSsrc(WebRtcVideoChannel* channel, |
| 82 uint32_t ssrc) override; | 82 uint32_t ssrc) override; |
| 83 | 83 |
| 84 rtc::VideoSinkInterface<webrtc::VideoFrame>* GetDefaultSink() const; | 84 rtc::VideoSinkInterface<webrtc::VideoFrame>* GetDefaultSink() const; |
| 85 void SetDefaultSink(WebRtcVideoChannel2* channel, | 85 void SetDefaultSink(WebRtcVideoChannel* channel, |
| 86 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); | 86 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); |
| 87 | 87 |
| 88 virtual ~DefaultUnsignalledSsrcHandler() = default; | 88 virtual ~DefaultUnsignalledSsrcHandler() = default; |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 rtc::VideoSinkInterface<webrtc::VideoFrame>* default_sink_; | 91 rtc::VideoSinkInterface<webrtc::VideoFrame>* default_sink_; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // WebRtcVideoEngine2 is used for the new native WebRTC Video API (webrtc:1667). | 94 // WebRtcVideoEngine is used for the new native WebRTC Video API (webrtc:1667). |
| 95 class WebRtcVideoEngine2 { | 95 class WebRtcVideoEngine { |
| 96 public: | 96 public: |
| 97 WebRtcVideoEngine2(); | 97 WebRtcVideoEngine(); |
| 98 virtual ~WebRtcVideoEngine2(); | 98 virtual ~WebRtcVideoEngine(); |
| 99 | 99 |
| 100 // Basic video engine implementation. | 100 // Basic video engine implementation. |
| 101 void Init(); | 101 void Init(); |
| 102 | 102 |
| 103 WebRtcVideoChannel2* CreateChannel(webrtc::Call* call, | 103 WebRtcVideoChannel* CreateChannel(webrtc::Call* call, |
| 104 const MediaConfig& config, | 104 const MediaConfig& config, |
| 105 const VideoOptions& options); | 105 const VideoOptions& options); |
| 106 | 106 |
| 107 std::vector<VideoCodec> codecs() const; | 107 std::vector<VideoCodec> codecs() const; |
| 108 RtpCapabilities GetCapabilities() const; | 108 RtpCapabilities GetCapabilities() const; |
| 109 | 109 |
| 110 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does | 110 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does |
| 111 // not take the ownership of |decoder_factory|. The caller needs to make sure | 111 // not take the ownership of |decoder_factory|. The caller needs to make sure |
| 112 // that |decoder_factory| outlives the video engine. | 112 // that |decoder_factory| outlives the video engine. |
| 113 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); | 113 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); |
| 114 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does | 114 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does |
| 115 // not take the ownership of |encoder_factory|. The caller needs to make sure | 115 // not take the ownership of |encoder_factory|. The caller needs to make sure |
| 116 // that |encoder_factory| outlives the video engine. | 116 // that |encoder_factory| outlives the video engine. |
| 117 virtual void SetExternalEncoderFactory( | 117 virtual void SetExternalEncoderFactory( |
| 118 WebRtcVideoEncoderFactory* encoder_factory); | 118 WebRtcVideoEncoderFactory* encoder_factory); |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 bool initialized_; | 121 bool initialized_; |
| 122 | 122 |
| 123 WebRtcVideoDecoderFactory* external_decoder_factory_; | 123 WebRtcVideoDecoderFactory* external_decoder_factory_; |
| 124 WebRtcVideoEncoderFactory* external_encoder_factory_; | 124 WebRtcVideoEncoderFactory* external_encoder_factory_; |
| 125 std::unique_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; | 125 std::unique_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class WebRtcVideoChannel2 : public VideoMediaChannel, public webrtc::Transport { | 128 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { |
| 129 public: | 129 public: |
| 130 WebRtcVideoChannel2(webrtc::Call* call, | 130 WebRtcVideoChannel(webrtc::Call* call, |
| 131 const MediaConfig& config, | 131 const MediaConfig& config, |
| 132 const VideoOptions& options, | 132 const VideoOptions& options, |
| 133 WebRtcVideoEncoderFactory* external_encoder_factory, | 133 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 134 WebRtcVideoDecoderFactory* external_decoder_factory); | 134 WebRtcVideoDecoderFactory* external_decoder_factory); |
| 135 ~WebRtcVideoChannel2() override; | 135 ~WebRtcVideoChannel() override; |
| 136 | 136 |
| 137 // VideoMediaChannel implementation | 137 // VideoMediaChannel implementation |
| 138 rtc::DiffServCodePoint PreferredDscp() const override; | 138 rtc::DiffServCodePoint PreferredDscp() const override; |
| 139 | 139 |
| 140 bool SetSendParameters(const VideoSendParameters& params) override; | 140 bool SetSendParameters(const VideoSendParameters& params) override; |
| 141 bool SetRecvParameters(const VideoRecvParameters& params) override; | 141 bool SetRecvParameters(const VideoRecvParameters& params) override; |
| 142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; | 142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; |
| 143 bool SetRtpSendParameters(uint32_t ssrc, | 143 bool SetRtpSendParameters(uint32_t ssrc, |
| 144 const webrtc::RtpParameters& parameters) override; | 144 const webrtc::RtpParameters& parameters) override; |
| 145 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override; | 145 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // Expands remote RTP timestamps to int64_t to be able to estimate how long | 452 // Expands remote RTP timestamps to int64_t to be able to estimate how long |
| 453 // the stream has been running. | 453 // the stream has been running. |
| 454 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ | 454 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ |
| 455 GUARDED_BY(sink_lock_); | 455 GUARDED_BY(sink_lock_); |
| 456 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); | 456 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); |
| 457 // Start NTP time is estimated as current remote NTP time (estimated from | 457 // Start NTP time is estimated as current remote NTP time (estimated from |
| 458 // RTCP) minus the elapsed time, as soon as remote NTP time is available. | 458 // RTCP) minus the elapsed time, as soon as remote NTP time is available. |
| 459 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); | 459 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 void Construct(webrtc::Call* call, WebRtcVideoEngine2* engine); | 462 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine); |
| 463 | 463 |
| 464 bool SendRtp(const uint8_t* data, | 464 bool SendRtp(const uint8_t* data, |
| 465 size_t len, | 465 size_t len, |
| 466 const webrtc::PacketOptions& options) override; | 466 const webrtc::PacketOptions& options) override; |
| 467 bool SendRtcp(const uint8_t* data, size_t len) override; | 467 bool SendRtcp(const uint8_t* data, size_t len) override; |
| 468 | 468 |
| 469 static std::vector<VideoCodecSettings> MapCodecs( | 469 static std::vector<VideoCodecSettings> MapCodecs( |
| 470 const std::vector<VideoCodec>& codecs); | 470 const std::vector<VideoCodec>& codecs); |
| 471 // Select what video codec will be used for sending, i.e. what codec is used | 471 // Select what video codec will be used for sending, i.e. what codec is used |
| 472 // for local encoding, based on supported remote codecs. The first remote | 472 // for local encoding, based on supported remote codecs. The first remote |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); | 505 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); |
| 506 | 506 |
| 507 rtc::Optional<VideoCodecSettings> send_codec_; | 507 rtc::Optional<VideoCodecSettings> send_codec_; |
| 508 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; | 508 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; |
| 509 | 509 |
| 510 WebRtcVideoEncoderFactory* const external_encoder_factory_; | 510 WebRtcVideoEncoderFactory* const external_encoder_factory_; |
| 511 WebRtcVideoDecoderFactory* const external_decoder_factory_; | 511 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
| 512 std::vector<VideoCodecSettings> recv_codecs_; | 512 std::vector<VideoCodecSettings> recv_codecs_; |
| 513 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 513 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 514 // See reason for keeping track of the FlexFEC payload type separately in | 514 // See reason for keeping track of the FlexFEC payload type separately in |
| 515 // comment in WebRtcVideoChannel2::ChangedRecvParameters. | 515 // comment in WebRtcVideoChannel::ChangedRecvParameters. |
| 516 int recv_flexfec_payload_type_; | 516 int recv_flexfec_payload_type_; |
| 517 webrtc::Call::Config::BitrateConfig bitrate_config_; | 517 webrtc::Call::Config::BitrateConfig bitrate_config_; |
| 518 // TODO(deadbeef): Don't duplicate information between | 518 // TODO(deadbeef): Don't duplicate information between |
| 519 // send_params/recv_params, rtp_extensions, options, etc. | 519 // send_params/recv_params, rtp_extensions, options, etc. |
| 520 VideoSendParameters send_params_; | 520 VideoSendParameters send_params_; |
| 521 VideoOptions default_send_options_; | 521 VideoOptions default_send_options_; |
| 522 VideoRecvParameters recv_params_; | 522 VideoRecvParameters recv_params_; |
| 523 int64_t last_stats_log_ms_; | 523 int64_t last_stats_log_ms_; |
| 524 }; | 524 }; |
| 525 | 525 |
| 526 } // namespace cricket | 526 } // namespace cricket |
| 527 | 527 |
| 528 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 528 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ |
| OLD | NEW |