Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1202)

Unified Diff: webrtc/video/video_send_stream.h

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Rebased Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video/video_send_stream.h
diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h
index d5ea36398535e935052e936ee0aef29c9c00c98d..d3bc6b8371abb7f9784f70747cf3bc9e6b2f3002 100644
--- a/webrtc/video/video_send_stream.h
+++ b/webrtc/video/video_send_stream.h
@@ -17,6 +17,8 @@
#include "webrtc/call/bitrate_allocator.h"
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/event.h"
+#include "webrtc/base/task_queue.h"
#include "webrtc/call.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/protection_bitrate_calculator.h"
@@ -24,7 +26,6 @@
#include "webrtc/video/payload_router.h"
#include "webrtc/video/send_delay_stats.h"
#include "webrtc/video/send_statistics_proxy.h"
-#include "webrtc/video/video_capture_input.h"
#include "webrtc/video/vie_encoder.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
@@ -37,32 +38,29 @@ class CongestionController;
class IvfFileWriter;
class ProcessThread;
class RtpRtcp;
-class ViEEncoder;
class VieRemb;
class RtcEventLog;
-namespace vcm {
-class VideoSender;
-} // namespace vcm
-
namespace internal {
-class VideoSendStream : public webrtc::VideoSendStream,
- public webrtc::CpuOveruseObserver,
- public webrtc::BitrateAllocatorObserver,
- public webrtc::VCMProtectionCallback,
- public EncodedImageCallback {
+class VideoSendStreamInternal;
+
+// VideoSendStream implements webrtc::VideoSendStream.
+// Internally, it delegates all public methods to VideoSendStreamInternal.
+// VideoSendStreamInternal is created and deleted on |worker_queue|.
stefan-webrtc 2016/07/08 15:56:42 Hm, so now we have webrtc::VideoSendStream, webrtc
perkj_webrtc 2016/07/11 11:41:08 VideoSendStreamImpl ?
+class VideoSendStream : public webrtc::VideoSendStream {
public:
VideoSendStream(int num_cpu_cores,
ProcessThread* module_process_thread,
+ rtc::TaskQueue* worker_queue,
CallStats* call_stats,
CongestionController* congestion_controller,
BitrateAllocator* bitrate_allocator,
SendDelayStats* send_delay_stats,
VieRemb* remb,
RtcEventLog* event_log,
- const VideoSendStream::Config& config,
- const VideoEncoderConfig& encoder_config,
+ VideoSendStream::Config config,
+ VideoEncoderConfig encoder_config,
const std::map<uint32_t, RtpState>& suspended_ssrcs);
~VideoSendStream() override;
@@ -74,17 +72,58 @@ class VideoSendStream : public webrtc::VideoSendStream,
void Start() override;
void Stop() override;
VideoCaptureInput* Input() override;
- void ReconfigureVideoEncoder(const VideoEncoderConfig& config) override;
+ void ReconfigureVideoEncoder(VideoEncoderConfig) override;
Stats GetStats() override;
- // webrtc::CpuOveruseObserver implementation.
- void OveruseDetected() override;
- void NormalUsage() override;
-
typedef std::map<uint32_t, RtpState> RtpStateMap;
- RtpStateMap GetRtpStates() const;
+ RtpStateMap StopPermanentlyAndGetRtpStates();
+
+ private:
+ class ConstructionTask;
+ class DestructAndGetRTPStateTask;
+
+ rtc::ThreadChecker thread_checker_;
+ rtc::TaskQueue* const worker_queue_;
+ rtc::Event thread_sync_event_;
- int GetPaddingNeededBps() const;
+ SendStatisticsProxy stats_proxy_;
+ const VideoSendStream::Config config_;
+ std::unique_ptr<VideoSendStreamInternal> send_stream_;
+ std::unique_ptr<ViEEncoder> vie_encoder_;
+};
+
+class VideoSendStreamInternal : public webrtc::BitrateAllocatorObserver,
stefan-webrtc 2016/07/08 15:56:42 Move this to the .cc file
perkj_webrtc 2016/07/11 11:41:08 Done.
+ public webrtc::VCMProtectionCallback,
+ public EncodedImageCallback {
+ public:
+ VideoSendStreamInternal(SendStatisticsProxy* stats_proxy,
+ rtc::TaskQueue* worker_queue,
+ CallStats* call_stats,
+ CongestionController* congestion_controller,
+ BitrateAllocator* bitrate_allocator,
+ SendDelayStats* send_delay_stats,
+ VieRemb* remb,
+ ViEEncoder* vie_encoder,
+ RtcEventLog* event_log,
+ const VideoSendStream::Config* config,
+ std::map<uint32_t, RtpState> suspended_ssrcs);
+ ~VideoSendStreamInternal() override;
+
+ // RegisterProcessThread register |module_process_thread| with those objects
+ // that use it. Registration have to happen on the thread where
+ // |module_process_thread| where created (libjingles worker thread).
+ // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue,
+ // maybe |worker_queue|.
+ void RegisterProcessThread(ProcessThread* module_process_thread);
+ void DeRegisterProcessThread();
+
+ void SignalNetworkState(NetworkState state);
+ bool DeliverRtcp(const uint8_t* packet, size_t length);
+ void Start();
+ void Stop();
+
+ void ReconfigureVideoEncoder(const VideoEncoderConfig& config);
+ VideoSendStream::RtpStateMap GetRtpStates() const;
// Implements BitrateAllocatorObserver.
uint32_t OnBitrateUpdated(uint32_t bitrate_bps,
@@ -100,10 +139,7 @@ class VideoSendStream : public webrtc::VideoSendStream,
uint32_t* sent_fec_rate_bps) override;
private:
- struct EncoderSettings {
- VideoCodec video_codec;
- VideoEncoderConfig config;
- };
+ class CheckEncoderActivityTask;
// Implements EncodedImageCallback. The implementation routes encoded frames
// to the |payload_router_| and |config.pre_encode_callback| if set.
@@ -112,17 +148,22 @@ class VideoSendStream : public webrtc::VideoSendStream,
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation) override;
- static bool EncoderThreadFunction(void* obj);
- void EncoderProcess();
-
void ConfigureProtection();
void ConfigureSsrcs();
+ void SignalEncoderTimedOut();
+ void SignalEncoderActive();
- SendStatisticsProxy stats_proxy_;
- const VideoSendStream::Config config_;
+ SendStatisticsProxy* const stats_proxy_;
+ const VideoSendStream::Config* const config_;
std::map<uint32_t, RtpState> suspended_ssrcs_;
- ProcessThread* const module_process_thread_;
+ ProcessThread* module_process_thread_;
+ rtc::ThreadChecker module_process_thread_checker_;
+ rtc::TaskQueue* const worker_queue_;
+
+ rtc::CriticalSection encoder_activity_crit_sect_;
+ CheckEncoderActivityTask* check_encoder_activity_task_
+ GUARDED_BY(encoder_activity_crit_sect_);
CallStats* const call_stats_;
CongestionController* const congestion_controller_;
BitrateAllocator* const bitrate_allocator_;
@@ -132,41 +173,19 @@ class VideoSendStream : public webrtc::VideoSendStream,
static const int kMaxLayers = 3;
std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers];
- rtc::PlatformThread encoder_thread_;
- rtc::Event encoder_wakeup_event_;
- volatile int stop_encoder_thread_;
- rtc::CriticalSection encoder_settings_crit_;
- std::unique_ptr<EncoderSettings> pending_encoder_settings_
- GUARDED_BY(encoder_settings_crit_);
- uint32_t encoder_max_bitrate_bps_ GUARDED_BY(encoder_settings_crit_);
- uint32_t encoder_target_rate_bps_ GUARDED_BY(encoder_settings_crit_);
-
- enum class State {
- kStopped, // VideoSendStream::Start has not yet been called.
- kStarted, // VideoSendStream::Start has been called.
- // VideoSendStream::Start has been called but the encoder have timed out.
- kEncoderTimedOut,
- };
- rtc::Optional<State> pending_state_change_ GUARDED_BY(encoder_settings_crit_);
-
- // Only used on the encoder thread.
- rtc::ThreadChecker encoder_thread_checker_;
- State state_ ACCESS_ON(&encoder_thread_checker_);
- std::unique_ptr<EncoderSettings> current_encoder_settings_
- ACCESS_ON(&encoder_thread_checker_);
-
- OveruseFrameDetector overuse_detector_;
- ViEEncoder vie_encoder_;
+ int max_padding_bitrate_;
+ int encoder_min_bitrate_bps_;
+ uint32_t encoder_max_bitrate_bps_;
+ uint32_t encoder_target_rate_bps_;
+
+ ViEEncoder* const vie_encoder_;
EncoderStateFeedback encoder_feedback_;
ProtectionBitrateCalculator protection_bitrate_calculator_;
- vcm::VideoSender* const video_sender_;
-
const std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
// RtpRtcp modules, declared here as they use other members on construction.
const std::vector<RtpRtcp*> rtp_rtcp_modules_;
PayloadRouter payload_router_;
- VideoCaptureInput input_;
};
} // namespace internal
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698