| 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 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool mute, | 153 bool mute, |
| 154 const VideoOptions* options) override; | 154 const VideoOptions* options) override; |
| 155 bool AddSendStream(const StreamParams& sp) override; | 155 bool AddSendStream(const StreamParams& sp) override; |
| 156 bool RemoveSendStream(uint32_t ssrc) override; | 156 bool RemoveSendStream(uint32_t ssrc) override; |
| 157 bool AddRecvStream(const StreamParams& sp) override; | 157 bool AddRecvStream(const StreamParams& sp) override; |
| 158 bool AddRecvStream(const StreamParams& sp, bool default_stream); | 158 bool AddRecvStream(const StreamParams& sp, bool default_stream); |
| 159 bool RemoveRecvStream(uint32_t ssrc) override; | 159 bool RemoveRecvStream(uint32_t ssrc) override; |
| 160 bool SetSink(uint32_t ssrc, | 160 bool SetSink(uint32_t ssrc, |
| 161 rtc::VideoSinkInterface<VideoFrame>* sink) override; | 161 rtc::VideoSinkInterface<VideoFrame>* sink) override; |
| 162 bool GetStats(VideoMediaInfo* info) override; | 162 bool GetStats(VideoMediaInfo* info) override; |
| 163 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; | 163 void SetSource( |
| 164 uint32_t ssrc, |
| 165 rtc::VideoSourceInterface<cricket::VideoFrame>* source) override; |
| 164 | 166 |
| 165 void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, | 167 void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
| 166 const rtc::PacketTime& packet_time) override; | 168 const rtc::PacketTime& packet_time) override; |
| 167 void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, | 169 void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, |
| 168 const rtc::PacketTime& packet_time) override; | 170 const rtc::PacketTime& packet_time) override; |
| 169 void OnReadyToSend(bool ready) override; | 171 void OnReadyToSend(bool ready) override; |
| 170 void SetInterface(NetworkInterface* iface) override; | 172 void SetInterface(NetworkInterface* iface) override; |
| 171 | 173 |
| 172 // Implemented for VideoMediaChannelTest. | 174 // Implemented for VideoMediaChannelTest. |
| 173 bool sending() const { return sending_; } | 175 bool sending() const { return sending_; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 199 // These optionals are unset if not changed. | 201 // These optionals are unset if not changed. |
| 200 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; | 202 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; |
| 201 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; | 203 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; |
| 202 }; | 204 }; |
| 203 | 205 |
| 204 bool GetChangedSendParameters(const VideoSendParameters& params, | 206 bool GetChangedSendParameters(const VideoSendParameters& params, |
| 205 ChangedSendParameters* changed_params) const; | 207 ChangedSendParameters* changed_params) const; |
| 206 bool GetChangedRecvParameters(const VideoRecvParameters& params, | 208 bool GetChangedRecvParameters(const VideoRecvParameters& params, |
| 207 ChangedRecvParameters* changed_params) const; | 209 ChangedRecvParameters* changed_params) const; |
| 208 | 210 |
| 209 bool MuteStream(uint32_t ssrc, bool mute); | |
| 210 | |
| 211 void SetMaxSendBandwidth(int bps); | 211 void SetMaxSendBandwidth(int bps); |
| 212 void SetOptions(uint32_t ssrc, const VideoOptions& options); | 212 void SetOptions(uint32_t ssrc, const VideoOptions& options); |
| 213 | 213 |
| 214 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, | 214 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, |
| 215 const StreamParams& sp) const; | 215 const StreamParams& sp) const; |
| 216 bool CodecIsExternallySupported(const std::string& name) const; | 216 bool CodecIsExternallySupported(const std::string& name) const; |
| 217 bool ValidateSendSsrcAvailability(const StreamParams& sp) const | 217 bool ValidateSendSsrcAvailability(const StreamParams& sp) const |
| 218 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 218 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 219 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const | 219 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const |
| 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 221 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 221 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
| 222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 223 | 223 |
| 224 static std::string CodecSettingsVectorToString( | 224 static std::string CodecSettingsVectorToString( |
| 225 const std::vector<VideoCodecSettings>& codecs); | 225 const std::vector<VideoCodecSettings>& codecs); |
| 226 | 226 |
| 227 // Wrapper for the sender part, this is where the capturer is connected and | 227 // Wrapper for the sender part, this is where the source is connected and |
| 228 // frames are then converted from cricket frames to webrtc frames. | 228 // frames are then converted from cricket frames to webrtc frames. |
| 229 class WebRtcVideoSendStream | 229 class WebRtcVideoSendStream |
| 230 : public rtc::VideoSinkInterface<cricket::VideoFrame>, | 230 : public rtc::VideoSinkInterface<cricket::VideoFrame>, |
| 231 public webrtc::LoadObserver { | 231 public webrtc::LoadObserver { |
| 232 public: | 232 public: |
| 233 WebRtcVideoSendStream( | 233 WebRtcVideoSendStream( |
| 234 webrtc::Call* call, | 234 webrtc::Call* call, |
| 235 const StreamParams& sp, | 235 const StreamParams& sp, |
| 236 const webrtc::VideoSendStream::Config& config, | 236 const webrtc::VideoSendStream::Config& config, |
| 237 const VideoOptions& options, | 237 const VideoOptions& options, |
| 238 WebRtcVideoEncoderFactory* external_encoder_factory, | 238 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 239 bool enable_cpu_overuse_detection, | 239 bool enable_cpu_overuse_detection, |
| 240 int max_bitrate_bps, | 240 int max_bitrate_bps, |
| 241 const rtc::Optional<VideoCodecSettings>& codec_settings, | 241 const rtc::Optional<VideoCodecSettings>& codec_settings, |
| 242 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 242 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
| 243 const VideoSendParameters& send_params); | 243 const VideoSendParameters& send_params); |
| 244 virtual ~WebRtcVideoSendStream(); | 244 virtual ~WebRtcVideoSendStream(); |
| 245 | 245 |
| 246 void SetOptions(const VideoOptions& options); | 246 void SetOptions(const VideoOptions& options); |
| 247 // TODO(pbos): Move logic from SetOptions into this method. | 247 // TODO(pbos): Move logic from SetOptions into this method. |
| 248 void SetSendParameters(const ChangedSendParameters& send_params); | 248 void SetSendParameters(const ChangedSendParameters& send_params); |
| 249 bool SetRtpParameters(const webrtc::RtpParameters& parameters); | 249 bool SetRtpParameters(const webrtc::RtpParameters& parameters); |
| 250 webrtc::RtpParameters GetRtpParameters() const; | 250 webrtc::RtpParameters GetRtpParameters() const; |
| 251 | 251 |
| 252 void OnFrame(const cricket::VideoFrame& frame) override; | 252 void OnFrame(const cricket::VideoFrame& frame) override; |
| 253 bool SetCapturer(VideoCapturer* capturer); | 253 void SetSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
| 254 void MuteStream(bool mute); | 254 void DisconnectSource(); |
| 255 bool DisconnectCapturer(); | |
| 256 | 255 |
| 257 void SetSend(bool send); | 256 void SetSend(bool send); |
| 258 | 257 |
| 259 // Implements webrtc::LoadObserver. | 258 // Implements webrtc::LoadObserver. |
| 260 void OnLoadUpdate(Load load) override; | 259 void OnLoadUpdate(Load load) override; |
| 261 | 260 |
| 262 const std::vector<uint32_t>& GetSsrcs() const; | 261 const std::vector<uint32_t>& GetSsrcs() const; |
| 263 VideoSenderInfo GetVideoSenderInfo(); | 262 VideoSenderInfo GetVideoSenderInfo(); |
| 264 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 263 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
| 265 | 264 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 346 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 348 | 347 |
| 349 rtc::ThreadChecker thread_checker_; | 348 rtc::ThreadChecker thread_checker_; |
| 350 rtc::AsyncInvoker invoker_; | 349 rtc::AsyncInvoker invoker_; |
| 351 rtc::Thread* worker_thread_; | 350 rtc::Thread* worker_thread_; |
| 352 const std::vector<uint32_t> ssrcs_; | 351 const std::vector<uint32_t> ssrcs_; |
| 353 const std::vector<SsrcGroup> ssrc_groups_; | 352 const std::vector<SsrcGroup> ssrc_groups_; |
| 354 webrtc::Call* const call_; | 353 webrtc::Call* const call_; |
| 355 rtc::VideoSinkWants sink_wants_; | 354 rtc::VideoSinkWants sink_wants_; |
| 356 // Counter used for deciding if the video resolution is currently | 355 // Counter used for deciding if the video resolution is currently |
| 357 // restricted by CPU usage. It is reset if |capturer_| is changed. | 356 // restricted by CPU usage. It is reset if |source_| is changed. |
| 358 int cpu_restricted_counter_; | 357 int cpu_restricted_counter_; |
| 359 // Total number of times resolution as been requested to be changed due to | 358 // Total number of times resolution as been requested to be changed due to |
| 360 // CPU adaptation. | 359 // CPU adaptation. |
| 361 int number_of_cpu_adapt_changes_; | 360 int number_of_cpu_adapt_changes_; |
| 362 VideoCapturer* capturer_; | 361 rtc::VideoSourceInterface<cricket::VideoFrame>* source_; |
| 363 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 362 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 364 GUARDED_BY(lock_); | 363 GUARDED_BY(lock_); |
| 365 | 364 |
| 366 rtc::CriticalSection lock_; | 365 rtc::CriticalSection lock_; |
| 367 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 366 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
| 368 // Contains settings that are the same for all streams in the MediaChannel, | 367 // Contains settings that are the same for all streams in the MediaChannel, |
| 369 // such as codecs, header extensions, and the global bitrate limit for the | 368 // such as codecs, header extensions, and the global bitrate limit for the |
| 370 // entire channel. | 369 // entire channel. |
| 371 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 370 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 372 // Contains settings that are unique for each stream, such as max_bitrate. | 371 // Contains settings that are unique for each stream, such as max_bitrate. |
| 373 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. | 372 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. |
| 374 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only | 373 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only |
| 375 // one stream per MediaChannel. | 374 // one stream per MediaChannel. |
| 376 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); | 375 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); |
| 377 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 376 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
| 378 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 377 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
| 379 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 378 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
| 379 // Original frame dimension, before adaptation due to cpu or |
| 380 // network bottlenecks. |
| 381 Dimensions input_dimensions_ GUARDED_BY(lock_); |
| 380 Dimensions last_dimensions_ GUARDED_BY(lock_); | 382 Dimensions last_dimensions_ GUARDED_BY(lock_); |
| 381 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 383 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
| 382 webrtc::kVideoRotation_0; | 384 webrtc::kVideoRotation_0; |
| 383 | 385 |
| 384 bool sending_ GUARDED_BY(lock_); | 386 bool sending_ GUARDED_BY(lock_); |
| 385 bool muted_ GUARDED_BY(lock_); | |
| 386 | 387 |
| 387 // The timestamp of the first frame received | 388 // The timestamp of the first frame received |
| 388 // Used to generate the timestamps of subsequent frames | 389 // Used to generate the timestamps of subsequent frames |
| 389 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | 390 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); |
| 390 | 391 |
| 391 // The timestamp of the last frame received | 392 // The timestamp of the last frame received |
| 392 // Used to generate timestamp for the black frame when capturer is removed | 393 // Used to generate timestamp for the black frame when source is removed |
| 393 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 394 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
| 394 }; | 395 }; |
| 395 | 396 |
| 396 // Wrapper for the receiver part, contains configs etc. that are needed to | 397 // Wrapper for the receiver part, contains configs etc. that are needed to |
| 397 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper | 398 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper |
| 398 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and | 399 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and |
| 399 // rtc::VideoSinkInterface<cricket::VideoFrame>. | 400 // rtc::VideoSinkInterface<cricket::VideoFrame>. |
| 400 class WebRtcVideoReceiveStream | 401 class WebRtcVideoReceiveStream |
| 401 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { | 402 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
| 402 public: | 403 public: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // TODO(deadbeef): Don't duplicate information between | 527 // TODO(deadbeef): Don't duplicate information between |
| 527 // send_params/recv_params, rtp_extensions, options, etc. | 528 // send_params/recv_params, rtp_extensions, options, etc. |
| 528 VideoSendParameters send_params_; | 529 VideoSendParameters send_params_; |
| 529 VideoOptions default_send_options_; | 530 VideoOptions default_send_options_; |
| 530 VideoRecvParameters recv_params_; | 531 VideoRecvParameters recv_params_; |
| 531 }; | 532 }; |
| 532 | 533 |
| 533 } // namespace cricket | 534 } // namespace cricket |
| 534 | 535 |
| 535 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 536 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |