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

Unified Diff: services/video_capture/device_media_to_mojo_adapter.cc

Issue 2818513003: [Mojo Video Capture] Adapt video_capture service to refactored video capture stack (Closed)
Patch Set: Fix compile errors Created 3 years, 8 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: services/video_capture/device_media_to_mojo_adapter.cc
diff --git a/services/video_capture/device_media_to_mojo_adapter.cc b/services/video_capture/device_media_to_mojo_adapter.cc
index a68c87fbb6b1e19c1fd14cebd438103079f7631b..ea7656a2efa153af72827e4d57c8035cc10fcfd5 100644
--- a/services/video_capture/device_media_to_mojo_adapter.cc
+++ b/services/video_capture/device_media_to_mojo_adapter.cc
@@ -11,6 +11,14 @@
#include "media/capture/video/video_capture_jpeg_decoder.h"
#include "services/video_capture/receiver_mojo_to_media_adapter.h"
+namespace {
+
+// The maximum number of video frame buffers in-flight at any one time.
+// If all buffers are still in use by consumers when new frames are produced
+// those frames get dropped.
+static const int kMaxBufferCount = 3;
+}
+
namespace video_capture {
DeviceMediaToMojoAdapter::DeviceMediaToMojoAdapter(
@@ -22,7 +30,8 @@ DeviceMediaToMojoAdapter::DeviceMediaToMojoAdapter(
device_running_(false) {}
DeviceMediaToMojoAdapter::~DeviceMediaToMojoAdapter() {
- Stop();
+ if (device_running_)
+ device_->StopAndDeAllocate();
}
void DeviceMediaToMojoAdapter::Start(
@@ -36,12 +45,11 @@ void DeviceMediaToMojoAdapter::Start(
base::MakeUnique<ReceiverMojoToMediaAdapter>(std::move(receiver));
// Create a dedicated buffer pool for the device usage session.
- const int kMaxBufferCount = 2;
auto buffer_tracker_factory =
base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>();
scoped_refptr<media::VideoCaptureBufferPool> buffer_pool(
new media::VideoCaptureBufferPoolImpl(std::move(buffer_tracker_factory),
- kMaxBufferCount));
+ max_buffer_pool_buffer_count()));
auto device_client = base::MakeUnique<media::VideoCaptureDeviceClient>(
std::move(media_receiver), buffer_pool, jpeg_decoder_factory_callback_);
@@ -50,15 +58,26 @@ void DeviceMediaToMojoAdapter::Start(
device_running_ = true;
}
+void DeviceMediaToMojoAdapter::OnReceiverReportingUtilization(
+ int32_t frame_feedback_id,
+ double utilization) {
+ device_->OnUtilizationReport(frame_feedback_id, utilization);
+}
+
void DeviceMediaToMojoAdapter::Stop() {
if (device_running_ == false)
return;
- device_->StopAndDeAllocate();
device_running_ = false;
+ device_->StopAndDeAllocate();
}
void DeviceMediaToMojoAdapter::OnClientConnectionErrorOrClose() {
Stop();
}
+// static
+int DeviceMediaToMojoAdapter::max_buffer_pool_buffer_count() {
+ return kMaxBufferCount;
+}
+
} // namespace video_capture

Powered by Google App Engine
This is Rietveld 408576698