| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
| 11 #ifndef WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ | 11 #ifndef WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ |
| 12 #define WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ | 12 #define WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "webrtc/call/bitrate_allocator.h" |
| 17 #include "webrtc/call.h" | 18 #include "webrtc/call.h" |
| 18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 19 #include "webrtc/video/encoded_frame_callback_adapter.h" | 20 #include "webrtc/video/encoded_frame_callback_adapter.h" |
| 20 #include "webrtc/video/encoder_state_feedback.h" | 21 #include "webrtc/video/encoder_state_feedback.h" |
| 21 #include "webrtc/video/payload_router.h" | 22 #include "webrtc/video/payload_router.h" |
| 22 #include "webrtc/video/send_statistics_proxy.h" | 23 #include "webrtc/video/send_statistics_proxy.h" |
| 23 #include "webrtc/video/video_capture_input.h" | 24 #include "webrtc/video/video_capture_input.h" |
| 24 #include "webrtc/video/vie_channel.h" | 25 #include "webrtc/video/vie_channel.h" |
| 25 #include "webrtc/video/vie_encoder.h" | 26 #include "webrtc/video/vie_encoder.h" |
| 26 #include "webrtc/video_receive_stream.h" | 27 #include "webrtc/video_receive_stream.h" |
| 27 #include "webrtc/video_send_stream.h" | 28 #include "webrtc/video_send_stream.h" |
| 28 | 29 |
| 29 namespace webrtc { | 30 namespace webrtc { |
| 30 | 31 |
| 31 class BitrateAllocator; | 32 class BitrateAllocator; |
| 32 class CallStats; | 33 class CallStats; |
| 33 class CongestionController; | 34 class CongestionController; |
| 34 class ProcessThread; | 35 class ProcessThread; |
| 35 class RtpRtcp; | 36 class RtpRtcp; |
| 36 class ViEChannel; | 37 class ViEChannel; |
| 37 class ViEEncoder; | 38 class ViEEncoder; |
| 38 class VieRemb; | 39 class VieRemb; |
| 39 | 40 |
| 40 namespace internal { | 41 namespace internal { |
| 41 | 42 |
| 42 class VideoSendStream : public webrtc::VideoSendStream, | 43 class VideoSendStream : public webrtc::VideoSendStream, |
| 43 public webrtc::CpuOveruseObserver { | 44 public webrtc::CpuOveruseObserver, |
| 45 public webrtc::BitrateAllocatorObserver { |
| 44 public: | 46 public: |
| 45 VideoSendStream(int num_cpu_cores, | 47 VideoSendStream(int num_cpu_cores, |
| 46 ProcessThread* module_process_thread, | 48 ProcessThread* module_process_thread, |
| 47 CallStats* call_stats, | 49 CallStats* call_stats, |
| 48 CongestionController* congestion_controller, | 50 CongestionController* congestion_controller, |
| 51 BitrateAllocator* bitrate_allocator, |
| 49 VieRemb* remb, | 52 VieRemb* remb, |
| 50 BitrateAllocator* bitrate_allocator, | |
| 51 const VideoSendStream::Config& config, | 53 const VideoSendStream::Config& config, |
| 52 const VideoEncoderConfig& encoder_config, | 54 const VideoEncoderConfig& encoder_config, |
| 53 const std::map<uint32_t, RtpState>& suspended_ssrcs); | 55 const std::map<uint32_t, RtpState>& suspended_ssrcs); |
| 54 | 56 |
| 55 ~VideoSendStream() override; | 57 ~VideoSendStream() override; |
| 56 | 58 |
| 57 // webrtc::SendStream implementation. | 59 // webrtc::SendStream implementation. |
| 58 void Start() override; | 60 void Start() override; |
| 59 void Stop() override; | 61 void Stop() override; |
| 60 void SignalNetworkState(NetworkState state) override; | 62 void SignalNetworkState(NetworkState state) override; |
| 61 bool DeliverRtcp(const uint8_t* packet, size_t length) override; | 63 bool DeliverRtcp(const uint8_t* packet, size_t length) override; |
| 62 | 64 |
| 63 // webrtc::VideoSendStream implementation. | 65 // webrtc::VideoSendStream implementation. |
| 64 VideoCaptureInput* Input() override; | 66 VideoCaptureInput* Input() override; |
| 65 void ReconfigureVideoEncoder(const VideoEncoderConfig& config) override; | 67 void ReconfigureVideoEncoder(const VideoEncoderConfig& config) override; |
| 66 Stats GetStats() override; | 68 Stats GetStats() override; |
| 67 | 69 |
| 68 // webrtc::CpuOveruseObserver implementation. | 70 // webrtc::CpuOveruseObserver implementation. |
| 69 void OveruseDetected() override; | 71 void OveruseDetected() override; |
| 70 void NormalUsage() override; | 72 void NormalUsage() override; |
| 71 | 73 |
| 72 typedef std::map<uint32_t, RtpState> RtpStateMap; | 74 typedef std::map<uint32_t, RtpState> RtpStateMap; |
| 73 RtpStateMap GetRtpStates() const; | 75 RtpStateMap GetRtpStates() const; |
| 74 | 76 |
| 75 int GetPaddingNeededBps() const; | 77 int GetPaddingNeededBps() const; |
| 76 | 78 |
| 79 // Implements BitrateAllocatorObserver. |
| 80 void OnBitrateUpdated(uint32_t bitrate_bps, |
| 81 uint8_t fraction_loss, |
| 82 int64_t rtt) override; |
| 83 |
| 77 private: | 84 private: |
| 78 static bool EncoderThreadFunction(void* obj); | 85 static bool EncoderThreadFunction(void* obj); |
| 79 void EncoderProcess(); | 86 void EncoderProcess(); |
| 80 | 87 |
| 81 void ConfigureSsrcs(); | 88 void ConfigureSsrcs(); |
| 82 | 89 |
| 83 SendStatisticsProxy stats_proxy_; | 90 SendStatisticsProxy stats_proxy_; |
| 84 EncodedFrameCallbackAdapter encoded_frame_proxy_; | 91 EncodedFrameCallbackAdapter encoded_frame_proxy_; |
| 85 const VideoSendStream::Config config_; | 92 const VideoSendStream::Config config_; |
| 86 std::map<uint32_t, RtpState> suspended_ssrcs_; | 93 std::map<uint32_t, RtpState> suspended_ssrcs_; |
| 87 | 94 |
| 88 ProcessThread* const module_process_thread_; | 95 ProcessThread* const module_process_thread_; |
| 89 CallStats* const call_stats_; | 96 CallStats* const call_stats_; |
| 90 CongestionController* const congestion_controller_; | 97 CongestionController* const congestion_controller_; |
| 98 BitrateAllocator* const bitrate_allocator_; |
| 91 VieRemb* const remb_; | 99 VieRemb* const remb_; |
| 92 | 100 |
| 93 rtc::PlatformThread encoder_thread_; | 101 rtc::PlatformThread encoder_thread_; |
| 94 rtc::Event encoder_wakeup_event_; | 102 rtc::Event encoder_wakeup_event_; |
| 95 volatile int stop_encoder_thread_; | 103 volatile int stop_encoder_thread_; |
| 96 | 104 |
| 97 OveruseFrameDetector overuse_detector_; | 105 OveruseFrameDetector overuse_detector_; |
| 98 PayloadRouter payload_router_; | 106 PayloadRouter payload_router_; |
| 99 EncoderStateFeedback encoder_feedback_; | 107 EncoderStateFeedback encoder_feedback_; |
| 100 ViEChannel vie_channel_; | 108 ViEChannel vie_channel_; |
| 101 ViEReceiver* const vie_receiver_; | 109 ViEReceiver* const vie_receiver_; |
| 102 ViEEncoder vie_encoder_; | 110 ViEEncoder vie_encoder_; |
| 103 VideoCodingModule* const vcm_; | 111 VideoCodingModule* const vcm_; |
| 104 // TODO(pbos): Move RtpRtcp ownership to VideoSendStream. | 112 // TODO(pbos): Move RtpRtcp ownership to VideoSendStream. |
| 105 // RtpRtcp modules, currently owned by ViEChannel but ownership should | 113 // RtpRtcp modules, currently owned by ViEChannel but ownership should |
| 106 // eventually move here. | 114 // eventually move here. |
| 107 const std::vector<RtpRtcp*> rtp_rtcp_modules_; | 115 const std::vector<RtpRtcp*> rtp_rtcp_modules_; |
| 108 VideoCaptureInput input_; | 116 VideoCaptureInput input_; |
| 109 }; | 117 }; |
| 110 } // namespace internal | 118 } // namespace internal |
| 111 } // namespace webrtc | 119 } // namespace webrtc |
| 112 | 120 |
| 113 #endif // WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ | 121 #endif // WEBRTC_VIDEO_VIDEO_SEND_STREAM_H_ |
| OLD | NEW |