pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 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 <vector> |
| 33 | #include <string> |
| 34 | |
| 35 | #include "talk/base/cpumonitor.h" |
| 36 | #include "talk/base/scoped_ptr.h" |
| 37 | #include "talk/media/base/mediaengine.h" |
| 38 | #include "talk/media/webrtc/webrtcvideochannelfactory.h" |
| 39 | #include "webrtc/common_video/interface/i420_video_frame.h" |
| 40 | #include "webrtc/system_wrappers/interface/thread_annotations.h" |
| 41 | #include "webrtc/transport.h" |
| 42 | #include "webrtc/video_renderer.h" |
| 43 | #include "webrtc/video_send_stream.h" |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 44 | #include "webrtc/video_receive_stream.h" |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 45 | |
| 46 | namespace webrtc { |
| 47 | class Call; |
| 48 | class VideoCaptureModule; |
| 49 | class VideoDecoder; |
| 50 | class VideoEncoder; |
| 51 | class VideoRender; |
| 52 | class VideoSendStreamInput; |
| 53 | class VideoReceiveStream; |
| 54 | } |
| 55 | |
| 56 | namespace talk_base { |
| 57 | class CpuMonitor; |
| 58 | class Thread; |
| 59 | } // namespace talk_base |
| 60 | |
| 61 | namespace cricket { |
| 62 | |
| 63 | class VideoCapturer; |
| 64 | class VideoFrame; |
| 65 | class VideoProcessor; |
| 66 | class VideoRenderer; |
| 67 | class VoiceMediaChannel; |
| 68 | class WebRtcVideoChannel2; |
| 69 | class WebRtcDecoderObserver; |
| 70 | class WebRtcEncoderObserver; |
| 71 | class WebRtcLocalStreamInfo; |
| 72 | class WebRtcRenderAdapter; |
| 73 | class WebRtcVideoChannelRecvInfo; |
| 74 | class WebRtcVideoChannelSendInfo; |
| 75 | class WebRtcVideoDecoderFactory; |
| 76 | class WebRtcVoiceEngine; |
| 77 | |
| 78 | struct CapturedFrame; |
| 79 | struct Device; |
| 80 | |
| 81 | class WebRtcVideoEngine2; |
| 82 | class WebRtcVideoChannel2; |
pbos@webrtc.org | e6f84ae | 2014-07-18 11:11:55 +0000 | [diff] [blame] | 83 | class WebRtcVideoRenderer; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 84 | |
| 85 | class WebRtcVideoEncoderFactory2 { |
| 86 | public: |
pbos@webrtc.org | 0d523ee | 2014-06-05 09:10:55 +0000 | [diff] [blame] | 87 | virtual ~WebRtcVideoEncoderFactory2(); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 88 | virtual std::vector<webrtc::VideoStream> CreateVideoStreams( |
| 89 | const VideoCodec& codec, |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 90 | const VideoOptions& options, |
buildbot@webrtc.org | d41eaeb | 2014-06-12 07:13:26 +0000 | [diff] [blame] | 91 | size_t num_streams); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 92 | |
| 93 | virtual webrtc::VideoEncoder* CreateVideoEncoder( |
| 94 | const VideoCodec& codec, |
buildbot@webrtc.org | d41eaeb | 2014-06-12 07:13:26 +0000 | [diff] [blame] | 95 | const VideoOptions& options); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 96 | |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame^] | 97 | virtual void* CreateVideoEncoderSettings( |
| 98 | const VideoCodec& codec, |
| 99 | const VideoOptions& options); |
| 100 | |
| 101 | virtual void DestroyVideoEncoderSettings(const VideoCodec& codec, |
| 102 | void* encoder_settings); |
| 103 | |
buildbot@webrtc.org | d41eaeb | 2014-06-12 07:13:26 +0000 | [diff] [blame] | 104 | virtual bool SupportsCodec(const cricket::VideoCodec& codec); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | // WebRtcVideoEngine2 is used for the new native WebRTC Video API (webrtc:1667). |
| 108 | class WebRtcVideoEngine2 : public sigslot::has_slots<> { |
| 109 | public: |
| 110 | // Creates the WebRtcVideoEngine2 with internal VideoCaptureModule. |
| 111 | WebRtcVideoEngine2(); |
| 112 | // Custom WebRtcVideoChannelFactory for testing purposes. |
| 113 | explicit WebRtcVideoEngine2(WebRtcVideoChannelFactory* channel_factory); |
| 114 | ~WebRtcVideoEngine2(); |
| 115 | |
| 116 | // Basic video engine implementation. |
| 117 | bool Init(talk_base::Thread* worker_thread); |
| 118 | void Terminate(); |
| 119 | |
| 120 | int GetCapabilities(); |
| 121 | bool SetOptions(const VideoOptions& options); |
| 122 | bool SetDefaultEncoderConfig(const VideoEncoderConfig& config); |
| 123 | VideoEncoderConfig GetDefaultEncoderConfig() const; |
| 124 | |
| 125 | WebRtcVideoChannel2* CreateChannel(VoiceMediaChannel* voice_channel); |
| 126 | |
| 127 | const std::vector<VideoCodec>& codecs() const; |
| 128 | const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; |
| 129 | void SetLogging(int min_sev, const char* filter); |
| 130 | |
| 131 | bool EnableTimedRender(); |
| 132 | // No-op, never used. |
| 133 | bool SetLocalRenderer(VideoRenderer* renderer); |
| 134 | // This is currently ignored. |
| 135 | sigslot::repeater2<VideoCapturer*, CaptureState> SignalCaptureStateChange; |
| 136 | |
| 137 | // Set the VoiceEngine for A/V sync. This can only be called before Init. |
| 138 | bool SetVoiceEngine(WebRtcVoiceEngine* voice_engine); |
| 139 | |
| 140 | // Functions called by WebRtcVideoChannel2. |
| 141 | const VideoFormat& default_codec_format() const { |
| 142 | return default_codec_format_; |
| 143 | } |
| 144 | |
| 145 | bool FindCodec(const VideoCodec& in); |
| 146 | bool CanSendCodec(const VideoCodec& in, |
| 147 | const VideoCodec& current, |
| 148 | VideoCodec* out); |
| 149 | // Check whether the supplied trace should be ignored. |
| 150 | bool ShouldIgnoreTrace(const std::string& trace); |
| 151 | |
| 152 | VideoFormat GetStartCaptureFormat() const { return default_codec_format_; } |
| 153 | |
| 154 | talk_base::CpuMonitor* cpu_monitor() { return cpu_monitor_.get(); } |
| 155 | |
buildbot@webrtc.org | d41eaeb | 2014-06-12 07:13:26 +0000 | [diff] [blame] | 156 | virtual WebRtcVideoEncoderFactory2* GetVideoEncoderFactory(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 157 | |
| 158 | private: |
| 159 | void Construct(WebRtcVideoChannelFactory* channel_factory, |
| 160 | WebRtcVoiceEngine* voice_engine, |
| 161 | talk_base::CpuMonitor* cpu_monitor); |
| 162 | |
| 163 | talk_base::Thread* worker_thread_; |
| 164 | WebRtcVoiceEngine* voice_engine_; |
| 165 | std::vector<VideoCodec> video_codecs_; |
| 166 | std::vector<RtpHeaderExtension> rtp_header_extensions_; |
| 167 | VideoFormat default_codec_format_; |
| 168 | |
| 169 | bool initialized_; |
| 170 | |
| 171 | bool capture_started_; |
| 172 | |
| 173 | // Critical section to protect the media processor register/unregister |
| 174 | // while processing a frame |
| 175 | talk_base::CriticalSection signal_media_critical_; |
| 176 | |
| 177 | talk_base::scoped_ptr<talk_base::CpuMonitor> cpu_monitor_; |
| 178 | WebRtcVideoChannelFactory* channel_factory_; |
buildbot@webrtc.org | d41eaeb | 2014-06-12 07:13:26 +0000 | [diff] [blame] | 179 | WebRtcVideoEncoderFactory2 default_video_encoder_factory_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 182 | class WebRtcVideoChannel2 : public talk_base::MessageHandler, |
| 183 | public VideoMediaChannel, |
| 184 | public webrtc::newapi::Transport { |
| 185 | public: |
| 186 | WebRtcVideoChannel2(WebRtcVideoEngine2* engine, |
| 187 | VoiceMediaChannel* voice_channel, |
| 188 | WebRtcVideoEncoderFactory2* encoder_factory); |
| 189 | // For testing purposes insert a pre-constructed call to verify that |
| 190 | // WebRtcVideoChannel2 calls the correct corresponding methods. |
| 191 | WebRtcVideoChannel2(webrtc::Call* call, |
| 192 | WebRtcVideoEngine2* engine, |
| 193 | WebRtcVideoEncoderFactory2* encoder_factory); |
| 194 | ~WebRtcVideoChannel2(); |
| 195 | bool Init(); |
| 196 | |
| 197 | // VideoMediaChannel implementation |
| 198 | virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) OVERRIDE; |
| 199 | virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) OVERRIDE; |
| 200 | virtual bool GetSendCodec(VideoCodec* send_codec) OVERRIDE; |
| 201 | virtual bool SetSendStreamFormat(uint32 ssrc, |
| 202 | const VideoFormat& format) OVERRIDE; |
| 203 | virtual bool SetRender(bool render) OVERRIDE; |
| 204 | virtual bool SetSend(bool send) OVERRIDE; |
| 205 | |
| 206 | virtual bool AddSendStream(const StreamParams& sp) OVERRIDE; |
| 207 | virtual bool RemoveSendStream(uint32 ssrc) OVERRIDE; |
| 208 | virtual bool AddRecvStream(const StreamParams& sp) OVERRIDE; |
| 209 | virtual bool RemoveRecvStream(uint32 ssrc) OVERRIDE; |
| 210 | virtual bool SetRenderer(uint32 ssrc, VideoRenderer* renderer) OVERRIDE; |
| 211 | virtual bool GetStats(const StatsOptions& options, |
| 212 | VideoMediaInfo* info) OVERRIDE; |
| 213 | virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) OVERRIDE; |
| 214 | virtual bool SendIntraFrame() OVERRIDE; |
| 215 | virtual bool RequestIntraFrame() OVERRIDE; |
| 216 | |
| 217 | virtual void OnPacketReceived(talk_base::Buffer* packet, |
| 218 | const talk_base::PacketTime& packet_time) |
| 219 | OVERRIDE; |
| 220 | virtual void OnRtcpReceived(talk_base::Buffer* packet, |
| 221 | const talk_base::PacketTime& packet_time) |
| 222 | OVERRIDE; |
| 223 | virtual void OnReadyToSend(bool ready) OVERRIDE; |
| 224 | virtual bool MuteStream(uint32 ssrc, bool mute) OVERRIDE; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 225 | |
| 226 | // Set send/receive RTP header extensions. This must be done before creating |
| 227 | // streams as it only has effect on future streams. |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 228 | virtual bool SetRecvRtpHeaderExtensions( |
| 229 | const std::vector<RtpHeaderExtension>& extensions) OVERRIDE; |
| 230 | virtual bool SetSendRtpHeaderExtensions( |
| 231 | const std::vector<RtpHeaderExtension>& extensions) OVERRIDE; |
| 232 | virtual bool SetStartSendBandwidth(int bps) OVERRIDE; |
| 233 | virtual bool SetMaxSendBandwidth(int bps) OVERRIDE; |
| 234 | virtual bool SetOptions(const VideoOptions& options) OVERRIDE; |
| 235 | virtual bool GetOptions(VideoOptions* options) const OVERRIDE { |
| 236 | *options = options_; |
| 237 | return true; |
| 238 | } |
| 239 | virtual void SetInterface(NetworkInterface* iface) OVERRIDE; |
| 240 | virtual void UpdateAspectRatio(int ratio_w, int ratio_h) OVERRIDE; |
| 241 | |
| 242 | virtual void OnMessage(talk_base::Message* msg) OVERRIDE; |
| 243 | |
| 244 | // Implemented for VideoMediaChannelTest. |
| 245 | bool sending() const { return sending_; } |
| 246 | uint32 GetDefaultChannelSsrc() { return default_send_ssrc_; } |
| 247 | bool GetRenderer(uint32 ssrc, VideoRenderer** renderer); |
| 248 | |
| 249 | private: |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 250 | void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, |
| 251 | const StreamParams& sp) const; |
| 252 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 253 | struct VideoCodecSettings { |
| 254 | VideoCodecSettings(); |
| 255 | |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 256 | VideoCodec codec; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 257 | webrtc::FecConfig fec; |
| 258 | int rtx_payload_type; |
| 259 | }; |
| 260 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 261 | // Wrapper for the sender part, this is where the capturer is connected and |
| 262 | // frames are then converted from cricket frames to webrtc frames. |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 263 | class WebRtcVideoSendStream : public sigslot::has_slots<> { |
| 264 | public: |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 265 | WebRtcVideoSendStream( |
| 266 | webrtc::Call* call, |
| 267 | WebRtcVideoEncoderFactory2* encoder_factory, |
| 268 | const VideoOptions& options, |
| 269 | const Settable<VideoCodecSettings>& codec_settings, |
| 270 | const StreamParams& sp, |
| 271 | const std::vector<webrtc::RtpExtension>& rtp_extensions); |
| 272 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 273 | ~WebRtcVideoSendStream(); |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 274 | void SetOptions(const VideoOptions& options); |
| 275 | void SetCodec(const VideoCodecSettings& codec); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 276 | void SetRtpExtensions( |
| 277 | const std::vector<webrtc::RtpExtension>& rtp_extensions); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 278 | |
| 279 | void InputFrame(VideoCapturer* capturer, const VideoFrame* frame); |
| 280 | bool SetCapturer(VideoCapturer* capturer); |
| 281 | bool SetVideoFormat(const VideoFormat& format); |
| 282 | bool MuteStream(bool mute); |
| 283 | bool DisconnectCapturer(); |
| 284 | |
| 285 | void Start(); |
| 286 | void Stop(); |
| 287 | |
pbos@webrtc.org | e6f84ae | 2014-07-18 11:11:55 +0000 | [diff] [blame] | 288 | VideoSenderInfo GetVideoSenderInfo(); |
| 289 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 290 | private: |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 291 | // Parameters needed to reconstruct the underlying stream. |
| 292 | // webrtc::VideoSendStream doesn't support setting a lot of options on the |
| 293 | // fly, so when those need to be changed we tear down and reconstruct with |
| 294 | // similar parameters depending on which options changed etc. |
| 295 | struct VideoSendStreamParameters { |
| 296 | VideoSendStreamParameters( |
| 297 | const webrtc::VideoSendStream::Config& config, |
| 298 | const VideoOptions& options, |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 299 | const Settable<VideoCodecSettings>& codec_settings); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 300 | webrtc::VideoSendStream::Config config; |
| 301 | VideoOptions options; |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 302 | Settable<VideoCodecSettings> codec_settings; |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 303 | // Sent resolutions + bitrates etc. by the underlying VideoSendStream, |
| 304 | // typically changes when setting a new resolution or reconfiguring |
| 305 | // bitrates. |
| 306 | std::vector<webrtc::VideoStream> video_streams; |
| 307 | }; |
| 308 | |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 309 | void SetCodecAndOptions(const VideoCodecSettings& codec, |
| 310 | const VideoOptions& options); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 311 | void RecreateWebRtcStream(); |
| 312 | void SetDimensions(int width, int height); |
| 313 | |
| 314 | webrtc::Call* const call_; |
| 315 | WebRtcVideoEncoderFactory2* const encoder_factory_; |
| 316 | |
| 317 | talk_base::CriticalSection lock_; |
| 318 | webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 319 | VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 320 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 321 | VideoCapturer* capturer_ GUARDED_BY(lock_); |
| 322 | bool sending_ GUARDED_BY(lock_); |
| 323 | bool muted_ GUARDED_BY(lock_); |
| 324 | VideoFormat format_ GUARDED_BY(lock_); |
| 325 | |
| 326 | talk_base::CriticalSection frame_lock_; |
| 327 | webrtc::I420VideoFrame video_frame_ GUARDED_BY(frame_lock_); |
| 328 | }; |
| 329 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 330 | // Wrapper for the receiver part, contains configs etc. that are needed to |
| 331 | // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper |
| 332 | // between webrtc::VideoRenderer and cricket::VideoRenderer. |
| 333 | class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { |
| 334 | public: |
| 335 | WebRtcVideoReceiveStream( |
| 336 | webrtc::Call*, |
| 337 | const webrtc::VideoReceiveStream::Config& config, |
| 338 | const std::vector<VideoCodecSettings>& recv_codecs); |
| 339 | ~WebRtcVideoReceiveStream(); |
| 340 | |
| 341 | void SetRecvCodecs(const std::vector<VideoCodecSettings>& recv_codecs); |
| 342 | void SetRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions); |
| 343 | |
| 344 | virtual void RenderFrame(const webrtc::I420VideoFrame& frame, |
| 345 | int time_to_render_ms) OVERRIDE; |
| 346 | |
| 347 | void SetRenderer(cricket::VideoRenderer* renderer); |
| 348 | cricket::VideoRenderer* GetRenderer(); |
| 349 | |
pbos@webrtc.org | e6f84ae | 2014-07-18 11:11:55 +0000 | [diff] [blame] | 350 | VideoReceiverInfo GetVideoReceiverInfo(); |
| 351 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 352 | private: |
| 353 | void SetSize(int width, int height); |
| 354 | void RecreateWebRtcStream(); |
| 355 | |
| 356 | webrtc::Call* const call_; |
| 357 | |
| 358 | webrtc::VideoReceiveStream* stream_; |
| 359 | webrtc::VideoReceiveStream::Config config_; |
| 360 | |
| 361 | talk_base::CriticalSection renderer_lock_; |
| 362 | cricket::VideoRenderer* renderer_ GUARDED_BY(renderer_lock_); |
pbos@webrtc.org | e6f84ae | 2014-07-18 11:11:55 +0000 | [diff] [blame] | 363 | int last_width_ GUARDED_BY(renderer_lock_); |
| 364 | int last_height_ GUARDED_BY(renderer_lock_); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 365 | }; |
| 366 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 367 | void Construct(webrtc::Call* call, WebRtcVideoEngine2* engine); |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame^] | 368 | void SetDefaultOptions(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 369 | |
| 370 | virtual bool SendRtp(const uint8_t* data, size_t len) OVERRIDE; |
| 371 | virtual bool SendRtcp(const uint8_t* data, size_t len) OVERRIDE; |
| 372 | |
| 373 | void StartAllSendStreams(); |
| 374 | void StopAllSendStreams(); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 375 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 376 | static std::vector<VideoCodecSettings> MapCodecs( |
| 377 | const std::vector<VideoCodec>& codecs); |
| 378 | std::vector<VideoCodecSettings> FilterSupportedCodecs( |
| 379 | const std::vector<VideoCodecSettings>& mapped_codecs); |
| 380 | |
pbos@webrtc.org | e6f84ae | 2014-07-18 11:11:55 +0000 | [diff] [blame] | 381 | void FillSenderStats(VideoMediaInfo* info); |
| 382 | void FillReceiverStats(VideoMediaInfo* info); |
| 383 | void FillBandwidthEstimationStats(VideoMediaInfo* info); |
| 384 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 385 | uint32_t rtcp_receiver_report_ssrc_; |
| 386 | bool sending_; |
| 387 | talk_base::scoped_ptr<webrtc::Call> call_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 388 | uint32_t default_send_ssrc_; |
| 389 | uint32_t default_recv_ssrc_; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 390 | VideoRenderer* default_renderer_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 391 | |
| 392 | // Using primary-ssrc (first ssrc) as key. |
| 393 | std::map<uint32, WebRtcVideoSendStream*> send_streams_; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 394 | std::map<uint32, WebRtcVideoReceiveStream*> receive_streams_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 395 | |
| 396 | Settable<VideoCodecSettings> send_codec_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 397 | std::vector<webrtc::RtpExtension> send_rtp_extensions_; |
| 398 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 399 | WebRtcVideoEncoderFactory2* const encoder_factory_; |
| 400 | std::vector<VideoCodecSettings> recv_codecs_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 401 | std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 402 | VideoOptions options_; |
| 403 | }; |
| 404 | |
| 405 | } // namespace cricket |
| 406 | |
| 407 | #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ |