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::CopyOnWriteBuffer* packet, | 168 void OnPacketReceived(rtc::CopyOnWriteBuffer* packet, |
167 const rtc::PacketTime& packet_time) override; | 169 const rtc::PacketTime& packet_time) override; |
168 void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, | 170 void OnRtcpReceived(rtc::CopyOnWriteBuffer* 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 OnNetworkRouteChanged(const std::string& transport_name, | 173 void OnNetworkRouteChanged(const std::string& transport_name, |
172 const NetworkRoute& network_route) override; | 174 const NetworkRoute& network_route) override; |
173 void SetInterface(NetworkInterface* iface) override; | 175 void SetInterface(NetworkInterface* iface) override; |
174 | 176 |
(...skipping 26 matching lines...) Expand all Loading... |
201 // These optionals are unset if not changed. | 203 // These optionals are unset if not changed. |
202 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; | 204 rtc::Optional<std::vector<VideoCodecSettings>> codec_settings; |
203 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; | 205 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; |
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 webrtc::RtpParameters GetRtpParameters() const; | 252 webrtc::RtpParameters GetRtpParameters() const; |
253 | 253 |
254 void OnFrame(const cricket::VideoFrame& frame) override; | 254 void OnFrame(const cricket::VideoFrame& frame) override; |
255 bool SetCapturer(VideoCapturer* capturer); | 255 void SetSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
256 void MuteStream(bool mute); | 256 void DisconnectSource(); |
257 bool DisconnectCapturer(); | |
258 | 257 |
259 void SetSend(bool send); | 258 void SetSend(bool send); |
260 | 259 |
261 // Implements webrtc::LoadObserver. | 260 // Implements webrtc::LoadObserver. |
262 void OnLoadUpdate(Load load) override; | 261 void OnLoadUpdate(Load load) override; |
263 | 262 |
264 const std::vector<uint32_t>& GetSsrcs() const; | 263 const std::vector<uint32_t>& GetSsrcs() const; |
265 VideoSenderInfo GetVideoSenderInfo(); | 264 VideoSenderInfo GetVideoSenderInfo(); |
266 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 265 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
267 | 266 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 348 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
350 | 349 |
351 rtc::ThreadChecker thread_checker_; | 350 rtc::ThreadChecker thread_checker_; |
352 rtc::AsyncInvoker invoker_; | 351 rtc::AsyncInvoker invoker_; |
353 rtc::Thread* worker_thread_; | 352 rtc::Thread* worker_thread_; |
354 const std::vector<uint32_t> ssrcs_; | 353 const std::vector<uint32_t> ssrcs_; |
355 const std::vector<SsrcGroup> ssrc_groups_; | 354 const std::vector<SsrcGroup> ssrc_groups_; |
356 webrtc::Call* const call_; | 355 webrtc::Call* const call_; |
357 rtc::VideoSinkWants sink_wants_; | 356 rtc::VideoSinkWants sink_wants_; |
358 // Counter used for deciding if the video resolution is currently | 357 // Counter used for deciding if the video resolution is currently |
359 // restricted by CPU usage. It is reset if |capturer_| is changed. | 358 // restricted by CPU usage. It is reset if |source_| is changed. |
360 int cpu_restricted_counter_; | 359 int cpu_restricted_counter_; |
361 // Total number of times resolution as been requested to be changed due to | 360 // Total number of times resolution as been requested to be changed due to |
362 // CPU adaptation. | 361 // CPU adaptation. |
363 int number_of_cpu_adapt_changes_; | 362 int number_of_cpu_adapt_changes_; |
364 VideoCapturer* capturer_; | 363 rtc::VideoSourceInterface<cricket::VideoFrame>* source_; |
365 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 364 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
366 GUARDED_BY(lock_); | 365 GUARDED_BY(lock_); |
367 | 366 |
368 rtc::CriticalSection lock_; | 367 rtc::CriticalSection lock_; |
369 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 368 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
370 // Contains settings that are the same for all streams in the MediaChannel, | 369 // Contains settings that are the same for all streams in the MediaChannel, |
371 // such as codecs, header extensions, and the global bitrate limit for the | 370 // such as codecs, header extensions, and the global bitrate limit for the |
372 // entire channel. | 371 // entire channel. |
373 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 372 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
374 // Contains settings that are unique for each stream, such as max_bitrate. | 373 // Contains settings that are unique for each stream, such as max_bitrate. |
375 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. | 374 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. |
376 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only | 375 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only |
377 // one stream per MediaChannel. | 376 // one stream per MediaChannel. |
378 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); | 377 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); |
379 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 378 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
380 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 379 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
381 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 380 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
382 Dimensions last_dimensions_ GUARDED_BY(lock_); | 381 Dimensions last_dimensions_ GUARDED_BY(lock_); |
383 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 382 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
384 webrtc::kVideoRotation_0; | 383 webrtc::kVideoRotation_0; |
385 | 384 |
386 bool sending_ GUARDED_BY(lock_); | 385 bool sending_ GUARDED_BY(lock_); |
387 bool muted_ GUARDED_BY(lock_); | |
388 | 386 |
389 // The timestamp of the first frame received | 387 // The timestamp of the first frame received |
390 // Used to generate the timestamps of subsequent frames | 388 // Used to generate the timestamps of subsequent frames |
391 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); | 389 int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_); |
392 | 390 |
393 // The timestamp of the last frame received | 391 // The timestamp of the last frame received |
394 // Used to generate timestamp for the black frame when capturer is removed | 392 // Used to generate timestamp for the black frame when source is removed |
395 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); | 393 int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_); |
396 }; | 394 }; |
397 | 395 |
398 // Wrapper for the receiver part, contains configs etc. that are needed to | 396 // Wrapper for the receiver part, contains configs etc. that are needed to |
399 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper | 397 // reconstruct the underlying VideoReceiveStream. Also serves as a wrapper |
400 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and | 398 // between rtc::VideoSinkInterface<webrtc::VideoFrame> and |
401 // rtc::VideoSinkInterface<cricket::VideoFrame>. | 399 // rtc::VideoSinkInterface<cricket::VideoFrame>. |
402 class WebRtcVideoReceiveStream | 400 class WebRtcVideoReceiveStream |
403 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { | 401 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
404 public: | 402 public: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // TODO(deadbeef): Don't duplicate information between | 524 // TODO(deadbeef): Don't duplicate information between |
527 // send_params/recv_params, rtp_extensions, options, etc. | 525 // send_params/recv_params, rtp_extensions, options, etc. |
528 VideoSendParameters send_params_; | 526 VideoSendParameters send_params_; |
529 VideoOptions default_send_options_; | 527 VideoOptions default_send_options_; |
530 VideoRecvParameters recv_params_; | 528 VideoRecvParameters recv_params_; |
531 }; | 529 }; |
532 | 530 |
533 } // namespace cricket | 531 } // namespace cricket |
534 | 532 |
535 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 533 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
OLD | NEW |