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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool mute, | 154 bool mute, |
155 const VideoOptions* options) override; | 155 const VideoOptions* options) override; |
156 bool AddSendStream(const StreamParams& sp) override; | 156 bool AddSendStream(const StreamParams& sp) override; |
157 bool RemoveSendStream(uint32_t ssrc) override; | 157 bool RemoveSendStream(uint32_t ssrc) override; |
158 bool AddRecvStream(const StreamParams& sp) override; | 158 bool AddRecvStream(const StreamParams& sp) override; |
159 bool AddRecvStream(const StreamParams& sp, bool default_stream); | 159 bool AddRecvStream(const StreamParams& sp, bool default_stream); |
160 bool RemoveRecvStream(uint32_t ssrc) override; | 160 bool RemoveRecvStream(uint32_t ssrc) override; |
161 bool SetSink(uint32_t ssrc, | 161 bool SetSink(uint32_t ssrc, |
162 rtc::VideoSinkInterface<VideoFrame>* sink) override; | 162 rtc::VideoSinkInterface<VideoFrame>* sink) override; |
163 bool GetStats(VideoMediaInfo* info) override; | 163 bool GetStats(VideoMediaInfo* info) override; |
164 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; | 164 void SetSource( |
| 165 uint32_t ssrc, |
| 166 rtc::VideoSourceInterface<cricket::VideoFrame>* source) override; |
165 | 167 |
166 void OnPacketReceived(rtc::Buffer* packet, | 168 void OnPacketReceived(rtc::Buffer* packet, |
167 const rtc::PacketTime& packet_time) override; | 169 const rtc::PacketTime& packet_time) override; |
168 void OnRtcpReceived(rtc::Buffer* packet, | 170 void OnRtcpReceived(rtc::Buffer* packet, |
169 const rtc::PacketTime& packet_time) override; | 171 const rtc::PacketTime& packet_time) override; |
170 void OnReadyToSend(bool ready) override; | 172 void OnReadyToSend(bool ready) override; |
171 void SetInterface(NetworkInterface* iface) override; | 173 void SetInterface(NetworkInterface* iface) override; |
172 | 174 |
173 // Implemented for VideoMediaChannelTest. | 175 // Implemented for VideoMediaChannelTest. |
174 bool sending() const { return sending_; } | 176 bool sending() const { return sending_; } |
(...skipping 26 matching lines...) Expand all Loading... |
201 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; | 203 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; |
202 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; | 204 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; |
203 rtc::Optional<webrtc::RtcpMode> rtcp_mode; | 205 rtc::Optional<webrtc::RtcpMode> rtcp_mode; |
204 }; | 206 }; |
205 | 207 |
206 bool GetChangedSendParameters(const VideoSendParameters& params, | 208 bool GetChangedSendParameters(const VideoSendParameters& params, |
207 ChangedSendParameters* changed_params) const; | 209 ChangedSendParameters* changed_params) const; |
208 bool GetChangedRecvParameters(const VideoRecvParameters& params, | 210 bool GetChangedRecvParameters(const VideoRecvParameters& params, |
209 ChangedRecvParameters* changed_params) const; | 211 ChangedRecvParameters* changed_params) const; |
210 | 212 |
211 bool MuteStream(uint32_t ssrc, bool mute); | |
212 | |
213 void SetMaxSendBandwidth(int bps); | 213 void SetMaxSendBandwidth(int bps); |
214 void SetOptions(uint32_t ssrc, const VideoOptions& options); | 214 void SetOptions(uint32_t ssrc, const VideoOptions& options); |
215 | 215 |
216 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, | 216 void ConfigureReceiverRtp(webrtc::VideoReceiveStream::Config* config, |
217 const StreamParams& sp) const; | 217 const StreamParams& sp) const; |
218 bool CodecIsExternallySupported(const std::string& name) const; | 218 bool CodecIsExternallySupported(const std::string& name) const; |
219 bool ValidateSendSsrcAvailability(const StreamParams& sp) const | 219 bool ValidateSendSsrcAvailability(const StreamParams& sp) const |
220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
221 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const | 221 bool ValidateReceiveSsrcAvailability(const StreamParams& sp) const |
222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
223 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 223 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
224 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 224 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
225 | 225 |
226 static std::string CodecSettingsVectorToString( | 226 static std::string CodecSettingsVectorToString( |
227 const std::vector<VideoCodecSettings>& codecs); | 227 const std::vector<VideoCodecSettings>& codecs); |
228 | 228 |
229 // 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 |
230 // frames are then converted from cricket frames to webrtc frames. | 230 // frames are then converted from cricket frames to webrtc frames. |
231 class WebRtcVideoSendStream | 231 class WebRtcVideoSendStream |
232 : public rtc::VideoSinkInterface<cricket::VideoFrame>, | 232 : public rtc::VideoSinkInterface<cricket::VideoFrame>, |
233 public webrtc::LoadObserver { | 233 public webrtc::LoadObserver { |
234 public: | 234 public: |
235 WebRtcVideoSendStream( | 235 WebRtcVideoSendStream( |
236 webrtc::Call* call, | 236 webrtc::Call* call, |
237 const StreamParams& sp, | 237 const StreamParams& sp, |
238 const webrtc::VideoSendStream::Config& config, | 238 const webrtc::VideoSendStream::Config& config, |
239 const VideoOptions& options, | 239 const VideoOptions& options, |
240 WebRtcVideoEncoderFactory* external_encoder_factory, | 240 WebRtcVideoEncoderFactory* external_encoder_factory, |
241 bool enable_cpu_overuse_detection, | 241 bool enable_cpu_overuse_detection, |
242 int max_bitrate_bps, | 242 int max_bitrate_bps, |
243 const rtc::Optional<VideoCodecSettings>& codec_settings, | 243 const rtc::Optional<VideoCodecSettings>& codec_settings, |
244 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 244 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
245 const VideoSendParameters& send_params); | 245 const VideoSendParameters& send_params); |
246 virtual ~WebRtcVideoSendStream(); | 246 virtual ~WebRtcVideoSendStream(); |
247 | 247 |
248 void SetOptions(const VideoOptions& options); | 248 void SetOptions(const VideoOptions& options); |
249 // TODO(pbos): Move logic from SetOptions into this method. | 249 // TODO(pbos): Move logic from SetOptions into this method. |
250 void SetSendParameters(const ChangedSendParameters& send_params); | 250 void SetSendParameters(const ChangedSendParameters& send_params); |
251 bool SetRtpParameters(const webrtc::RtpParameters& parameters); | 251 bool SetRtpParameters(const webrtc::RtpParameters& parameters); |
252 | 252 |
253 void OnFrame(const cricket::VideoFrame& frame) override; | 253 void OnFrame(const cricket::VideoFrame& frame) override; |
254 bool SetCapturer(VideoCapturer* capturer); | 254 void SetSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
255 void MuteStream(bool mute); | 255 void DisconnectSource(); |
256 bool DisconnectCapturer(); | |
257 | 256 |
258 void Start(); | 257 void Start(); |
259 void Stop(); | 258 void Stop(); |
260 | 259 |
261 webrtc::RtpParameters rtp_parameters() const { return rtp_parameters_; } | 260 webrtc::RtpParameters rtp_parameters() const { return rtp_parameters_; } |
262 | 261 |
263 // Implements webrtc::LoadObserver. | 262 // Implements webrtc::LoadObserver. |
264 void OnLoadUpdate(Load load) override; | 263 void OnLoadUpdate(Load load) override; |
265 | 264 |
266 const std::vector<uint32_t>& GetSsrcs() const; | 265 const std::vector<uint32_t>& GetSsrcs() const; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); | 346 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); |
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_; | 375 webrtc::RtpParameters rtp_parameters_; |
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_); |
380 Dimensions last_dimensions_ GUARDED_BY(lock_); | 379 Dimensions last_dimensions_ GUARDED_BY(lock_); |
381 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 380 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
382 webrtc::kVideoRotation_0; | 381 webrtc::kVideoRotation_0; |
383 | 382 |
384 bool sending_ GUARDED_BY(lock_); | 383 bool sending_ GUARDED_BY(lock_); |
385 bool muted_ GUARDED_BY(lock_); | |
386 | 384 |
387 // The timestamp of the first frame received | 385 // The timestamp of the first frame received |
388 // Used to generate the timestamps of subsequent frames | 386 // Used to generate the timestamps of subsequent frames |
389 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | 387 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); |
390 | 388 |
391 // The timestamp of the last frame received | 389 // The timestamp of the last frame received |
392 // Used to generate timestamp for the black frame when capturer is removed | 390 // Used to generate timestamp for the black frame when source is removed |
393 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 391 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
394 }; | 392 }; |
395 | 393 |
396 // Wrapper for the receiver part, contains configs etc. that are needed to | 394 // Wrapper for the receiver part, contains configs etc. that are needed to |
397 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper | 395 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper |
398 // between webrtc::VideoRenderer and cricket::VideoRenderer. | 396 // between webrtc::VideoRenderer and cricket::VideoRenderer. |
399 class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { | 397 class WebRtcVideoReceiveStream : public webrtc::VideoRenderer { |
400 public: | 398 public: |
401 WebRtcVideoReceiveStream( | 399 WebRtcVideoReceiveStream( |
402 webrtc::Call* call, | 400 webrtc::Call* call, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 // TODO(deadbeef): Don't duplicate information between | 529 // TODO(deadbeef): Don't duplicate information between |
532 // send_params/recv_params, rtp_extensions, options, etc. | 530 // send_params/recv_params, rtp_extensions, options, etc. |
533 VideoSendParameters send_params_; | 531 VideoSendParameters send_params_; |
534 VideoOptions default_send_options_; | 532 VideoOptions default_send_options_; |
535 VideoRecvParameters recv_params_; | 533 VideoRecvParameters recv_params_; |
536 }; | 534 }; |
537 | 535 |
538 } // namespace cricket | 536 } // namespace cricket |
539 | 537 |
540 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 538 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
OLD | NEW |