| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does | 121 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does |
| 122 // not take the ownership of |decoder_factory|. The caller needs to make sure | 122 // not take the ownership of |decoder_factory|. The caller needs to make sure |
| 123 // that |decoder_factory| outlives the video engine. | 123 // that |decoder_factory| outlives the video engine. |
| 124 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); | 124 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); |
| 125 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does | 125 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does |
| 126 // not take the ownership of |encoder_factory|. The caller needs to make sure | 126 // not take the ownership of |encoder_factory|. The caller needs to make sure |
| 127 // that |encoder_factory| outlives the video engine. | 127 // that |encoder_factory| outlives the video engine. |
| 128 virtual void SetExternalEncoderFactory( | 128 virtual void SetExternalEncoderFactory( |
| 129 WebRtcVideoEncoderFactory* encoder_factory); | 129 WebRtcVideoEncoderFactory* encoder_factory); |
| 130 | 130 |
| 131 bool EnableTimedRender(); | |
| 132 | |
| 133 bool FindCodec(const VideoCodec& in); | 131 bool FindCodec(const VideoCodec& in); |
| 134 // Check whether the supplied trace should be ignored. | 132 // Check whether the supplied trace should be ignored. |
| 135 bool ShouldIgnoreTrace(const std::string& trace); | 133 bool ShouldIgnoreTrace(const std::string& trace); |
| 136 | 134 |
| 137 private: | 135 private: |
| 138 std::vector<VideoCodec> GetSupportedCodecs() const; | 136 std::vector<VideoCodec> GetSupportedCodecs() const; |
| 139 | 137 |
| 140 std::vector<VideoCodec> video_codecs_; | 138 std::vector<VideoCodec> video_codecs_; |
| 141 | 139 |
| 142 bool initialized_; | 140 bool initialized_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 186 |
| 189 void OnMessage(rtc::Message* msg) override; | 187 void OnMessage(rtc::Message* msg) override; |
| 190 | 188 |
| 191 void OnLoadUpdate(Load load) override; | 189 void OnLoadUpdate(Load load) override; |
| 192 | 190 |
| 193 // Implemented for VideoMediaChannelTest. | 191 // Implemented for VideoMediaChannelTest. |
| 194 bool sending() const { return sending_; } | 192 bool sending() const { return sending_; } |
| 195 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } | 193 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } |
| 196 | 194 |
| 197 private: | 195 private: |
| 196 struct VideoCodecSettings { |
| 197 VideoCodecSettings(); |
| 198 |
| 199 bool operator==(const VideoCodecSettings& other) const; |
| 200 bool operator!=(const VideoCodecSettings& other) const; |
| 201 |
| 202 VideoCodec codec; |
| 203 webrtc::FecConfig fec; |
| 204 int rtx_payload_type; |
| 205 }; |
| 206 |
| 207 struct ChangedSendParameters { |
| 208 // These optionals are unset if not changed. |
| 209 rtc::Optional<VideoCodecSettings> codec; |
| 210 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; |
| 211 rtc::Optional<int> max_bandwidth_bps; |
| 212 rtc::Optional<VideoOptions> options; |
| 213 webrtc::RtcpMode rtcp_mode; |
| 214 }; |
| 215 bool GetChangedSendParameters(const VideoSendParameters& params, |
| 216 ChangedSendParameters* changed_params) const; |
| 198 bool MuteStream(uint32_t ssrc, bool mute); | 217 bool MuteStream(uint32_t ssrc, bool mute); |
| 199 class WebRtcVideoReceiveStream; | 218 class WebRtcVideoReceiveStream; |
| 200 | 219 |
| 201 bool SetSendCodecs(const std::vector<VideoCodec>& codecs); | 220 void SetMaxSendBandwidth(int bps); |
| 202 bool SetSendRtpHeaderExtensions( | 221 void SetOptions(const VideoOptions& options); |
| 203 const std::vector<RtpHeaderExtension>& extensions); | |
| 204 bool SetMaxSendBandwidth(int bps); | |
| 205 bool SetOptions(const VideoOptions& options); | |
| 206 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs); | 222 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs); |
| 207 bool SetRecvRtpHeaderExtensions( | 223 bool SetRecvRtpHeaderExtensions( |
| 208 const std::vector<RtpHeaderExtension>& extensions); | 224 const std::vector<RtpHeaderExtension>& extensions); |
| 209 | 225 |
| 210 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, | 226 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, |
| 211 const StreamParams& sp) const; | 227 const StreamParams& sp) const; |
| 212 bool CodecIsExternallySupported(const std::string& name) const; | 228 bool CodecIsExternallySupported(const std::string& name) const; |
| 213 bool ValidateSendSsrcAvailability(const StreamParams& sp) const | 229 bool ValidateSendSsrcAvailability(const StreamParams& sp) const |
| 214 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 230 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 215 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const | 231 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const |
| 216 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 232 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 217 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 233 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
| 218 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 234 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 219 | 235 |
| 220 struct VideoCodecSettings { | |
| 221 VideoCodecSettings(); | |
| 222 | |
| 223 bool operator==(const VideoCodecSettings& other) const; | |
| 224 bool operator!=(const VideoCodecSettings& other) const; | |
| 225 | |
| 226 VideoCodec codec; | |
| 227 webrtc::FecConfig fec; | |
| 228 int rtx_payload_type; | |
| 229 }; | |
| 230 | |
| 231 static std::string CodecSettingsVectorToString( | 236 static std::string CodecSettingsVectorToString( |
| 232 const std::vector<VideoCodecSettings>& codecs); | 237 const std::vector<VideoCodecSettings>& codecs); |
| 233 | 238 |
| 234 // Wrapper for the sender part, this is where the capturer is connected and | 239 // Wrapper for the sender part, this is where the capturer is connected and |
| 235 // frames are then converted from cricket frames to webrtc frames. | 240 // frames are then converted from cricket frames to webrtc frames. |
| 236 class WebRtcVideoSendStream : public sigslot::has_slots<> { | 241 class WebRtcVideoSendStream : public sigslot::has_slots<> { |
| 237 public: | 242 public: |
| 238 WebRtcVideoSendStream( | 243 WebRtcVideoSendStream( |
| 239 webrtc::Call* call, | 244 webrtc::Call* call, |
| 240 const StreamParams& sp, | 245 const StreamParams& sp, |
| 241 const webrtc::VideoSendStream::Config& config, | 246 const webrtc::VideoSendStream::Config& config, |
| 242 WebRtcVideoEncoderFactory* external_encoder_factory, | 247 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 243 const VideoOptions& options, | 248 const VideoOptions& options, |
| 244 int max_bitrate_bps, | 249 int max_bitrate_bps, |
| 245 const rtc::Optional<VideoCodecSettings>& codec_settings, | 250 const rtc::Optional<VideoCodecSettings>& codec_settings, |
| 246 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 251 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
| 247 const VideoSendParameters& send_params); | 252 const VideoSendParameters& send_params); |
| 248 ~WebRtcVideoSendStream(); | 253 ~WebRtcVideoSendStream(); |
| 249 | 254 |
| 250 void SetOptions(const VideoOptions& options); | 255 void SetOptions(const VideoOptions& options); |
| 251 void SetCodec(const VideoCodecSettings& codec); | 256 // TODO(pbos): Move logic from SetOptions into this method. |
| 252 void SetRtpExtensions( | 257 void SetSendParameters(const ChangedSendParameters& send_params); |
| 253 const std::vector<webrtc::RtpExtension>& rtp_extensions); | |
| 254 // TODO(deadbeef): Move logic from SetCodec/SetRtpExtensions/etc. | |
| 255 // into this method. Currently this method only sets the RTCP mode. | |
| 256 void SetSendParameters(const VideoSendParameters& send_params); | |
| 257 | 258 |
| 258 void InputFrame(VideoCapturer* capturer, const VideoFrame* frame); | 259 void InputFrame(VideoCapturer* capturer, const VideoFrame* frame); |
| 259 bool SetCapturer(VideoCapturer* capturer); | 260 bool SetCapturer(VideoCapturer* capturer); |
| 260 bool SetVideoFormat(const VideoFormat& format); | 261 bool SetVideoFormat(const VideoFormat& format); |
| 261 void MuteStream(bool mute); | 262 void MuteStream(bool mute); |
| 262 bool DisconnectCapturer(); | 263 bool DisconnectCapturer(); |
| 263 | 264 |
| 264 void SetApplyRotation(bool apply_rotation); | |
| 265 | |
| 266 void Start(); | 265 void Start(); |
| 267 void Stop(); | 266 void Stop(); |
| 268 | 267 |
| 269 const std::vector<uint32_t>& GetSsrcs() const; | 268 const std::vector<uint32_t>& GetSsrcs() const; |
| 270 VideoSenderInfo GetVideoSenderInfo(); | 269 VideoSenderInfo GetVideoSenderInfo(); |
| 271 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 270 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
| 272 | 271 |
| 273 void SetMaxBitrateBps(int max_bitrate_bps); | |
| 274 | |
| 275 private: | 272 private: |
| 276 // Parameters needed to reconstruct the underlying stream. | 273 // Parameters needed to reconstruct the underlying stream. |
| 277 // webrtc::VideoSendStream doesn't support setting a lot of options on the | 274 // webrtc::VideoSendStream doesn't support setting a lot of options on the |
| 278 // fly, so when those need to be changed we tear down and reconstruct with | 275 // fly, so when those need to be changed we tear down and reconstruct with |
| 279 // similar parameters depending on which options changed etc. | 276 // similar parameters depending on which options changed etc. |
| 280 struct VideoSendStreamParameters { | 277 struct VideoSendStreamParameters { |
| 281 VideoSendStreamParameters( | 278 VideoSendStreamParameters( |
| 282 const webrtc::VideoSendStream::Config& config, | 279 const webrtc::VideoSendStream::Config& config, |
| 283 const VideoOptions& options, | 280 const VideoOptions& options, |
| 284 int max_bitrate_bps, | 281 int max_bitrate_bps, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 351 |
| 355 const std::vector<uint32_t> ssrcs_; | 352 const std::vector<uint32_t> ssrcs_; |
| 356 const std::vector<SsrcGroup> ssrc_groups_; | 353 const std::vector<SsrcGroup> ssrc_groups_; |
| 357 webrtc::Call* const call_; | 354 webrtc::Call* const call_; |
| 358 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 355 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 359 GUARDED_BY(lock_); | 356 GUARDED_BY(lock_); |
| 360 | 357 |
| 361 rtc::CriticalSection lock_; | 358 rtc::CriticalSection lock_; |
| 362 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 359 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
| 363 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 360 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 361 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
| 364 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 362 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
| 365 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 363 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
| 366 Dimensions last_dimensions_ GUARDED_BY(lock_); | 364 Dimensions last_dimensions_ GUARDED_BY(lock_); |
| 367 | 365 |
| 368 VideoCapturer* capturer_ GUARDED_BY(lock_); | 366 VideoCapturer* capturer_ GUARDED_BY(lock_); |
| 369 bool sending_ GUARDED_BY(lock_); | 367 bool sending_ GUARDED_BY(lock_); |
| 370 bool muted_ GUARDED_BY(lock_); | 368 bool muted_ GUARDED_BY(lock_); |
| 371 VideoFormat format_ GUARDED_BY(lock_); | 369 VideoFormat format_ GUARDED_BY(lock_); |
| 372 int old_adapt_changes_ GUARDED_BY(lock_); | 370 int old_adapt_changes_ GUARDED_BY(lock_); |
| 373 | 371 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 VideoOptions options_; | 524 VideoOptions options_; |
| 527 // TODO(deadbeef): Don't duplicate information between | 525 // TODO(deadbeef): Don't duplicate information between |
| 528 // send_params/recv_params, rtp_extensions, options, etc. | 526 // send_params/recv_params, rtp_extensions, options, etc. |
| 529 VideoSendParameters send_params_; | 527 VideoSendParameters send_params_; |
| 530 VideoRecvParameters recv_params_; | 528 VideoRecvParameters recv_params_; |
| 531 }; | 529 }; |
| 532 | 530 |
| 533 } // namespace cricket | 531 } // namespace cricket |
| 534 | 532 |
| 535 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ | 533 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |