| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bool mute, | 151 bool mute, |
| 152 const VideoOptions* options) override; | 152 const VideoOptions* options) override; |
| 153 bool AddSendStream(const StreamParams& sp) override; | 153 bool AddSendStream(const StreamParams& sp) override; |
| 154 bool RemoveSendStream(uint32_t ssrc) override; | 154 bool RemoveSendStream(uint32_t ssrc) override; |
| 155 bool AddRecvStream(const StreamParams& sp) override; | 155 bool AddRecvStream(const StreamParams& sp) override; |
| 156 bool AddRecvStream(const StreamParams& sp, bool default_stream); | 156 bool AddRecvStream(const StreamParams& sp, bool default_stream); |
| 157 bool RemoveRecvStream(uint32_t ssrc) override; | 157 bool RemoveRecvStream(uint32_t ssrc) override; |
| 158 bool SetSink(uint32_t ssrc, | 158 bool SetSink(uint32_t ssrc, |
| 159 rtc::VideoSinkInterface<VideoFrame>* sink) override; | 159 rtc::VideoSinkInterface<VideoFrame>* sink) override; |
| 160 bool GetStats(VideoMediaInfo* info) override; | 160 bool GetStats(VideoMediaInfo* info) override; |
| 161 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; | 161 void SetSource( |
| 162 uint32_t ssrc, |
| 163 rtc::VideoSourceInterface<cricket::VideoFrame>* source) override; |
| 162 | 164 |
| 163 void OnPacketReceived(rtc::Buffer* packet, | 165 void OnPacketReceived(rtc::Buffer* packet, |
| 164 const rtc::PacketTime& packet_time) override; | 166 const rtc::PacketTime& packet_time) override; |
| 165 void OnRtcpReceived(rtc::Buffer* packet, | 167 void OnRtcpReceived(rtc::Buffer* packet, |
| 166 const rtc::PacketTime& packet_time) override; | 168 const rtc::PacketTime& packet_time) override; |
| 167 void OnReadyToSend(bool ready) override; | 169 void OnReadyToSend(bool ready) override; |
| 168 void SetInterface(NetworkInterface* iface) override; | 170 void SetInterface(NetworkInterface* iface) override; |
| 169 | 171 |
| 170 // Implemented for VideoMediaChannelTest. | 172 // Implemented for VideoMediaChannelTest. |
| 171 bool sending() const { return sending_; } | 173 bool sending() const { return sending_; } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 bool ValidateSendSsrcAvailability(const StreamParams& sp) const | 219 bool ValidateSendSsrcAvailability(const StreamParams& sp) const |
| 218 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 219 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const | 221 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const |
| 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 221 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 223 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
| 222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 224 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
| 223 | 225 |
| 224 static std::string CodecSettingsVectorToString( | 226 static std::string CodecSettingsVectorToString( |
| 225 const std::vector<VideoCodecSettings>& codecs); | 227 const std::vector<VideoCodecSettings>& codecs); |
| 226 | 228 |
| 227 // Wrapper for the sender part, this is where the capturer is connected and | 229 // Wrapper for the sender part, this is where the source is connected and |
| 228 // frames are then converted from cricket frames to webrtc frames. | 230 // frames are then converted from cricket frames to webrtc frames. |
| 229 class WebRtcVideoSendStream | 231 class WebRtcVideoSendStream |
| 230 : public rtc::VideoSinkInterface<cricket::VideoFrame>, | 232 : public rtc::VideoSinkInterface<cricket::VideoFrame>, |
| 231 public webrtc::LoadObserver { | 233 public webrtc::LoadObserver { |
| 232 public: | 234 public: |
| 233 WebRtcVideoSendStream( | 235 WebRtcVideoSendStream( |
| 234 webrtc::Call* call, | 236 webrtc::Call* call, |
| 235 const StreamParams& sp, | 237 const StreamParams& sp, |
| 236 const webrtc::VideoSendStream::Config& config, | 238 const webrtc::VideoSendStream::Config& config, |
| 237 WebRtcVideoEncoderFactory* external_encoder_factory, | 239 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 238 bool enable_cpu_overuse_detection, | 240 bool enable_cpu_overuse_detection, |
| 239 int max_bitrate_bps, | 241 int max_bitrate_bps, |
| 240 const rtc::Optional<VideoCodecSettings>& codec_settings, | 242 const rtc::Optional<VideoCodecSettings>& codec_settings, |
| 241 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 243 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
| 242 const VideoSendParameters& send_params); | 244 const VideoSendParameters& send_params); |
| 243 virtual ~WebRtcVideoSendStream(); | 245 virtual ~WebRtcVideoSendStream(); |
| 244 | 246 |
| 245 void SetOptions(const VideoOptions& options); | 247 void SetOptions(const VideoOptions& options); |
| 246 // TODO(pbos): Move logic from SetOptions into this method. | 248 // TODO(pbos): Move logic from SetOptions into this method. |
| 247 void SetSendParameters(const ChangedSendParameters& send_params); | 249 void SetSendParameters(const ChangedSendParameters& send_params); |
| 248 | 250 |
| 249 void OnFrame(const cricket::VideoFrame& frame) override; | 251 void OnFrame(const cricket::VideoFrame& frame) override; |
| 250 bool SetCapturer(VideoCapturer* capturer); | 252 void SetSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
| 251 void MuteStream(bool mute); | 253 void MuteStream(bool mute); |
| 252 bool DisconnectCapturer(); | 254 void DisconnectSource(); |
| 253 | 255 |
| 254 void Start(); | 256 void Start(); |
| 255 void Stop(); | 257 void Stop(); |
| 256 | 258 |
| 257 // Implements webrtc::LoadObserver. | 259 // Implements webrtc::LoadObserver. |
| 258 void OnLoadUpdate(Load load) override; | 260 void OnLoadUpdate(Load load) override; |
| 259 | 261 |
| 260 const std::vector<uint32_t>& GetSsrcs() const; | 262 const std::vector<uint32_t>& GetSsrcs() const; |
| 261 VideoSenderInfo GetVideoSenderInfo(); | 263 VideoSenderInfo GetVideoSenderInfo(); |
| 262 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 264 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 342 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 341 | 343 |
| 342 rtc::ThreadChecker thread_checker_; | 344 rtc::ThreadChecker thread_checker_; |
| 343 rtc::AsyncInvoker invoker_; | 345 rtc::AsyncInvoker invoker_; |
| 344 rtc::Thread* worker_thread_; | 346 rtc::Thread* worker_thread_; |
| 345 const std::vector<uint32_t> ssrcs_; | 347 const std::vector<uint32_t> ssrcs_; |
| 346 const std::vector<SsrcGroup> ssrc_groups_; | 348 const std::vector<SsrcGroup> ssrc_groups_; |
| 347 webrtc::Call* const call_; | 349 webrtc::Call* const call_; |
| 348 rtc::VideoSinkWants sink_wants_; | 350 rtc::VideoSinkWants sink_wants_; |
| 349 // Counter used for deciding if the video resolution is currently | 351 // Counter used for deciding if the video resolution is currently |
| 350 // restricted by CPU usage. It is reset if |capturer_| is changed. | 352 // restricted by CPU usage. It is reset if |source_| is changed. |
| 351 int cpu_restricted_counter_; | 353 int cpu_restricted_counter_; |
| 352 // Total number of times resolution as been requested to be changed due to | 354 // Total number of times resolution as been requested to be changed due to |
| 353 // CPU adaptation. | 355 // CPU adaptation. |
| 354 int number_of_cpu_adapt_changes_; | 356 int number_of_cpu_adapt_changes_; |
| 355 VideoCapturer* capturer_; | 357 rtc::VideoSourceInterface<cricket::VideoFrame>* source_; |
| 356 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 358 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 357 GUARDED_BY(lock_); | 359 GUARDED_BY(lock_); |
| 358 | 360 |
| 359 rtc::CriticalSection lock_; | 361 rtc::CriticalSection lock_; |
| 360 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 362 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
| 361 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 363 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 362 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 364 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
| 363 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 365 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
| 364 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 366 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
| 365 Dimensions last_dimensions_ GUARDED_BY(lock_); | 367 Dimensions last_dimensions_ GUARDED_BY(lock_); |
| 366 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 368 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
| 367 webrtc::kVideoRotation_0; | 369 webrtc::kVideoRotation_0; |
| 368 | 370 |
| 369 bool sending_ GUARDED_BY(lock_); | 371 bool sending_ GUARDED_BY(lock_); |
| 370 bool muted_ GUARDED_BY(lock_); | 372 bool muted_ GUARDED_BY(lock_); |
| 371 | 373 |
| 372 // The timestamp of the first frame received | 374 // The timestamp of the first frame received |
| 373 // Used to generate the timestamps of subsequent frames | 375 // Used to generate the timestamps of subsequent frames |
| 374 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | 376 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); |
| 375 | 377 |
| 376 // The timestamp of the last frame received | 378 // The timestamp of the last frame received |
| 377 // Used to generate timestamp for the black frame when capturer is removed | 379 // Used to generate timestamp for the black frame when source is removed |
| 378 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 380 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
| 379 }; | 381 }; |
| 380 | 382 |
| 381 // Wrapper for the receiver part, contains configs etc. that are needed to | 383 // Wrapper for the receiver part, contains configs etc. that are needed to |
| 382 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper | 384 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper |
| 383 // between webrtc::VideoRenderer and cricket::VideoRenderer. | 385 // between webrtc::VideoRenderer and cricket::VideoRenderer. |
| 384 class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { | 386 class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { |
| 385 public: | 387 public: |
| 386 WebRtcVideoReceiveStream( | 388 WebRtcVideoReceiveStream( |
| 387 webrtc::Call* call, | 389 webrtc::Call* call, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 webrtc::Call::Config::BitrateConfig bitrate_config_; | 517 webrtc::Call::Config::BitrateConfig bitrate_config_; |
| 516 // TODO(deadbeef): Don't duplicate information between | 518 // TODO(deadbeef): Don't duplicate information between |
| 517 // send_params/recv_params, rtp_extensions, options, etc. | 519 // send_params/recv_params, rtp_extensions, options, etc. |
| 518 VideoSendParameters send_params_; | 520 VideoSendParameters send_params_; |
| 519 VideoRecvParameters recv_params_; | 521 VideoRecvParameters recv_params_; |
| 520 }; | 522 }; |
| 521 | 523 |
| 522 } // namespace cricket | 524 } // namespace cricket |
| 523 | 525 |
| 524 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 526 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |