Fix TestVideoCapturer and subclasses to support pause/resume video
Bug: b/272350185 Change-Id: I8e2e1a833430f78627ec6301ea23f2f8337a01ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309622 Reviewed-by: Jeremy Leconte <jleconte@google.com> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40329}
This commit is contained in:
parent
84fdf990e8
commit
5246ae20a2
@ -255,6 +255,7 @@ if (!build_with_chromium) {
|
|||||||
"../api:media_stream_interface",
|
"../api:media_stream_interface",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
"../modules/video_capture:video_capture_module",
|
"../modules/video_capture:video_capture_module",
|
||||||
|
"../rtc_base:logging",
|
||||||
"../rtc_base:threading",
|
"../rtc_base:threading",
|
||||||
"../sdk:base_objc",
|
"../sdk:base_objc",
|
||||||
"../sdk:native_api",
|
"../sdk:native_api",
|
||||||
|
|||||||
@ -52,8 +52,8 @@ class FrameGeneratorCapturer : public TestVideoCapturer {
|
|||||||
TaskQueueFactory& task_queue_factory);
|
TaskQueueFactory& task_queue_factory);
|
||||||
virtual ~FrameGeneratorCapturer();
|
virtual ~FrameGeneratorCapturer();
|
||||||
|
|
||||||
void Start();
|
void Start() override;
|
||||||
void Stop();
|
void Stop() override;
|
||||||
void ChangeResolution(size_t width, size_t height);
|
void ChangeResolution(size_t width, size_t height);
|
||||||
void ChangeFramerate(int target_framerate);
|
void ChangeFramerate(int target_framerate);
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "api/media_stream_interface.h"
|
#include "api/media_stream_interface.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "modules/video_capture/video_capture.h"
|
#include "modules/video_capture/video_capture.h"
|
||||||
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/thread.h"
|
#include "rtc_base/thread.h"
|
||||||
#include "test/test_video_capturer.h"
|
#include "test/test_video_capturer.h"
|
||||||
|
|
||||||
@ -32,6 +33,15 @@ class MacCapturer : public TestVideoCapturer,
|
|||||||
size_t capture_device_index);
|
size_t capture_device_index);
|
||||||
~MacCapturer() override;
|
~MacCapturer() override;
|
||||||
|
|
||||||
|
void Start() override {
|
||||||
|
RTC_LOG(LS_WARNING) << "Capturer doesn't support resume/pause and always "
|
||||||
|
"produces the video";
|
||||||
|
}
|
||||||
|
void Stop() override {
|
||||||
|
RTC_LOG(LS_WARNING) << "Capturer doesn't support resume/pause and always "
|
||||||
|
"produces the video";
|
||||||
|
}
|
||||||
|
|
||||||
void OnFrame(const VideoFrame& frame) override;
|
void OnFrame(const VideoFrame& frame) override;
|
||||||
|
|
||||||
int GetFrameWidth() const override { return static_cast<int>(width_); }
|
int GetFrameWidth() const override { return static_cast<int>(width_); }
|
||||||
|
|||||||
@ -45,9 +45,15 @@ class TestVideoCapturerVideoTrackSource : public test::TestVideoTrackSource {
|
|||||||
|
|
||||||
~TestVideoCapturerVideoTrackSource() = default;
|
~TestVideoCapturerVideoTrackSource() = default;
|
||||||
|
|
||||||
void Start() override { SetState(kLive); }
|
void Start() override {
|
||||||
|
SetState(kLive);
|
||||||
|
video_capturer_->Start();
|
||||||
|
}
|
||||||
|
|
||||||
void Stop() override { SetState(kMuted); }
|
void Stop() override {
|
||||||
|
SetState(kMuted);
|
||||||
|
video_capturer_->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
int GetFrameWidth() const override {
|
int GetFrameWidth() const override {
|
||||||
return video_capturer_->GetFrameWidth();
|
return video_capturer_->GetFrameWidth();
|
||||||
|
|||||||
@ -46,8 +46,9 @@ void TestVideoCapturer::OnFrame(const VideoFrame& original_frame) {
|
|||||||
MutexLock lock(&lock_);
|
MutexLock lock(&lock_);
|
||||||
enable_adaptation = enable_adaptation_;
|
enable_adaptation = enable_adaptation_;
|
||||||
}
|
}
|
||||||
if (enable_adaptation) {
|
if (!enable_adaptation) {
|
||||||
broadcaster_.OnFrame(frame);
|
broadcaster_.OnFrame(frame);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!video_adapter_.AdaptFrameResolution(
|
if (!video_adapter_.AdaptFrameResolution(
|
||||||
|
|||||||
@ -49,6 +49,13 @@ class TestVideoCapturer : public rtc::VideoSourceInterface<VideoFrame> {
|
|||||||
int height,
|
int height,
|
||||||
const absl::optional<int>& max_fps);
|
const absl::optional<int>& max_fps);
|
||||||
|
|
||||||
|
// Starts or resumes video capturing. Can be called multiple times during
|
||||||
|
// lifetime of this object.
|
||||||
|
virtual void Start() = 0;
|
||||||
|
// Stops or pauses video capturing. Can be called multiple times during
|
||||||
|
// lifetime of this object.
|
||||||
|
virtual void Stop() = 0;
|
||||||
|
|
||||||
virtual int GetFrameWidth() const = 0;
|
virtual int GetFrameWidth() const = 0;
|
||||||
virtual int GetFrameHeight() const = 0;
|
virtual int GetFrameHeight() const = 0;
|
||||||
|
|
||||||
@ -62,7 +69,7 @@ class TestVideoCapturer : public rtc::VideoSourceInterface<VideoFrame> {
|
|||||||
|
|
||||||
Mutex lock_;
|
Mutex lock_;
|
||||||
std::unique_ptr<FramePreprocessor> preprocessor_ RTC_GUARDED_BY(lock_);
|
std::unique_ptr<FramePreprocessor> preprocessor_ RTC_GUARDED_BY(lock_);
|
||||||
bool enable_adaptation_ RTC_GUARDED_BY(lock_) = false;
|
bool enable_adaptation_ RTC_GUARDED_BY(lock_) = true;
|
||||||
rtc::VideoBroadcaster broadcaster_;
|
rtc::VideoBroadcaster broadcaster_;
|
||||||
cricket::VideoAdapter video_adapter_;
|
cricket::VideoAdapter video_adapter_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "modules/video_capture/video_capture.h"
|
#include "modules/video_capture/video_capture.h"
|
||||||
|
#include "rtc_base/logging.h"
|
||||||
#include "test/test_video_capturer.h"
|
#include "test/test_video_capturer.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -29,6 +30,15 @@ class VcmCapturer : public TestVideoCapturer,
|
|||||||
size_t capture_device_index);
|
size_t capture_device_index);
|
||||||
virtual ~VcmCapturer();
|
virtual ~VcmCapturer();
|
||||||
|
|
||||||
|
void Start() override {
|
||||||
|
RTC_LOG(LS_WARNING) << "Capturer doesn't support resume/pause and always "
|
||||||
|
"produces the video";
|
||||||
|
}
|
||||||
|
void Stop() override {
|
||||||
|
RTC_LOG(LS_WARNING) << "Capturer doesn't support resume/pause and always "
|
||||||
|
"produces the video";
|
||||||
|
}
|
||||||
|
|
||||||
void OnFrame(const VideoFrame& frame) override;
|
void OnFrame(const VideoFrame& frame) override;
|
||||||
|
|
||||||
int GetFrameWidth() const override { return static_cast<int>(width_); }
|
int GetFrameWidth() const override { return static_cast<int>(width_); }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user