summaryrefslogtreecommitdiffstats
path: root/content/renderer/media
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer/media')
-rw-r--r--content/renderer/media/rtc_video_capture_delegate.cc1
-rw-r--r--content/renderer/media/rtc_video_capturer.cc10
-rw-r--r--content/renderer/media/video_capture_impl.cc44
-rw-r--r--content/renderer/media/video_capture_impl_unittest.cc5
-rw-r--r--content/renderer/media/video_capture_message_filter_unittest.cc17
5 files changed, 39 insertions, 38 deletions
diff --git a/content/renderer/media/rtc_video_capture_delegate.cc b/content/renderer/media/rtc_video_capture_delegate.cc
index 9567e2c..4cc2b59 100644
--- a/content/renderer/media/rtc_video_capture_delegate.cc
+++ b/content/renderer/media/rtc_video_capture_delegate.cc
@@ -5,6 +5,7 @@
#include "content/renderer/media/rtc_video_capture_delegate.h"
#include "base/bind.h"
+#include "media/base/video_frame.h"
namespace content {
diff --git a/content/renderer/media/rtc_video_capturer.cc b/content/renderer/media/rtc_video_capturer.cc
index 2cf0d91..0a7a82c 100644
--- a/content/renderer/media/rtc_video_capturer.cc
+++ b/content/renderer/media/rtc_video_capturer.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
+#include "media/base/video_frame.h"
namespace content {
@@ -30,11 +31,10 @@ cricket::CaptureState RtcVideoCapturer::Start(
}
media::VideoCaptureParams request;
- request.requested_format =
- media::VideoCaptureFormat(capture_format.width,
- capture_format.height,
- capture_format.framerate(),
- media::ConstantResolutionVideoCaptureDevice);
+ request.requested_format = media::VideoCaptureFormat(
+ gfx::Size(capture_format.width, capture_format.height),
+ capture_format.framerate(),
+ media::PIXEL_FORMAT_I420);
SetCaptureFormat(&capture_format);
diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc
index 8fd24f8..30b43dd 100644
--- a/content/renderer/media/video_capture_impl.cc
+++ b/content/renderer/media/video_capture_impl.cc
@@ -10,6 +10,7 @@
#include "content/common/media/video_capture_messages.h"
#include "media/base/bind_to_loop.h"
#include "media/base/limits.h"
+#include "media/base/video_frame.h"
namespace content {
@@ -159,24 +160,23 @@ void VideoCaptureImpl::DoStartCaptureOnCaptureThread(
clients_[handler] = params;
} else if (state_ == VIDEO_CAPTURE_STATE_STOPPING) {
clients_pending_on_restart_[handler] = params;
- DVLOG(1) << "StartCapture: Got new resolution ("
- << params.requested_format.width << ", "
- << params.requested_format.height << ") "
- << ", during stopping.";
+ DVLOG(1) << "StartCapture: Got new resolution "
+ << params.requested_format.frame_size.ToString()
+ << " during stopping.";
} else {
- DCHECK_EQ(params.session_id, 0);
+ // TODO(sheu): Allowing resolution change will require that all
+ // outstanding clients of a capture session support resolution change.
+ DCHECK(!params.allow_resolution_change);
clients_[handler] = params;
DCHECK_EQ(1ul, clients_.size());
params_ = params;
- params_.session_id = session_id_;
if (params_.requested_format.frame_rate >
media::limits::kMaxFramesPerSecond) {
params_.requested_format.frame_rate =
media::limits::kMaxFramesPerSecond;
}
- DVLOG(1) << "StartCapture: starting with first resolution ("
- << params_.requested_format.width << ","
- << params_.requested_format.height << ")";
+ DVLOG(1) << "StartCapture: starting with first resolution "
+ << params_.requested_format.frame_size.ToString();
StartCaptureInternal();
}
@@ -252,7 +252,6 @@ void VideoCaptureImpl::DoBufferReceivedOnCaptureThread(
}
last_frame_format_ = format;
- gfx::Size size(format.width, format.height);
ClientBufferMap::iterator iter = client_buffers_.find(buffer_id);
DCHECK(iter != client_buffers_.end());
@@ -260,9 +259,9 @@ void VideoCaptureImpl::DoBufferReceivedOnCaptureThread(
scoped_refptr<media::VideoFrame> frame =
media::VideoFrame::WrapExternalPackedMemory(
media::VideoFrame::I420,
- size,
- gfx::Rect(size),
- size,
+ last_frame_format_.frame_size,
+ gfx::Rect(last_frame_format_.frame_size),
+ last_frame_format_.frame_size,
reinterpret_cast<uint8*>(buffer->buffer->memory()),
buffer->buffer_size,
buffer->buffer->handle(),
@@ -360,7 +359,7 @@ void VideoCaptureImpl::StopDevice() {
if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
state_ = VIDEO_CAPTURE_STATE_STOPPING;
Send(new VideoCaptureHostMsg_Stop(device_id_));
- params_.requested_format.width = params_.requested_format.height = 0;
+ params_.requested_format.frame_size.SetSize(0, 0);
}
}
@@ -372,20 +371,19 @@ void VideoCaptureImpl::RestartCapture() {
int height = 0;
for (ClientInfo::iterator it = clients_.begin();
it != clients_.end(); ++it) {
- width = std::max(width, it->second.requested_format.width);
- height = std::max(height, it->second.requested_format.height);
+ width = std::max(width, it->second.requested_format.frame_size.width());
+ height = std::max(height, it->second.requested_format.frame_size.height());
}
for (ClientInfo::iterator it = clients_pending_on_restart_.begin();
it != clients_pending_on_restart_.end(); ) {
- width = std::max(width, it->second.requested_format.width);
- height = std::max(height, it->second.requested_format.height);
+ width = std::max(width, it->second.requested_format.frame_size.width());
+ height = std::max(height, it->second.requested_format.frame_size.height());
clients_[it->first] = it->second;
clients_pending_on_restart_.erase(it++);
}
- params_.requested_format.width = width;
- params_.requested_format.height = height;
- DVLOG(1) << "RestartCapture, " << params_.requested_format.width << ", "
- << params_.requested_format.height;
+ params_.requested_format.frame_size.SetSize(width, height);
+ DVLOG(1) << "RestartCapture, "
+ << params_.requested_format.frame_size.ToString();
StartCaptureInternal();
}
@@ -393,7 +391,7 @@ void VideoCaptureImpl::StartCaptureInternal() {
DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread());
DCHECK(device_id_);
- Send(new VideoCaptureHostMsg_Start(device_id_, params_));
+ Send(new VideoCaptureHostMsg_Start(device_id_, session_id_, params_));
state_ = VIDEO_CAPTURE_STATE_STARTED;
}
diff --git a/content/renderer/media/video_capture_impl_unittest.cc b/content/renderer/media/video_capture_impl_unittest.cc
index f0bf333..713b3a0 100644
--- a/content/renderer/media/video_capture_impl_unittest.cc
+++ b/content/renderer/media/video_capture_impl_unittest.cc
@@ -81,6 +81,7 @@ class VideoCaptureImplTest : public ::testing::Test {
}
void DeviceStartCapture(int device_id,
+ media::VideoCaptureSessionId session_id,
const media::VideoCaptureParams& params) {
OnStateChanged(VIDEO_CAPTURE_STATE_STARTED);
}
@@ -96,10 +97,10 @@ class VideoCaptureImplTest : public ::testing::Test {
VideoCaptureImplTest() {
params_small_.requested_format = media::VideoCaptureFormat(
- 176, 144, 30, media::ConstantResolutionVideoCaptureDevice);
+ gfx::Size(176, 144), 30, media::PIXEL_FORMAT_I420);
params_large_.requested_format = media::VideoCaptureFormat(
- 320, 240, 30, media::ConstantResolutionVideoCaptureDevice);
+ gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420);
message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
message_loop_proxy_ = base::MessageLoopProxy::current().get();
diff --git a/content/renderer/media/video_capture_message_filter_unittest.cc b/content/renderer/media/video_capture_message_filter_unittest.cc
index 069673f..366bcb0 100644
--- a/content/renderer/media/video_capture_message_filter_unittest.cc
+++ b/content/renderer/media/video_capture_message_filter_unittest.cc
@@ -11,11 +11,10 @@
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
-using ::testing::AllOf;
using ::testing::AnyNumber;
-using ::testing::Field;
using ::testing::Mock;
using ::testing::Return;
+using ::testing::SaveArg;
using ::testing::StrictMock;
namespace content {
@@ -82,15 +81,17 @@ TEST(VideoCaptureMessageFilterTest, Basic) {
int buffer_id = 22;
base::Time timestamp = base::Time::FromInternalValue(1);
- media::VideoCaptureFormat format(234, 512, 30,
- media::ConstantResolutionVideoCaptureDevice);
- EXPECT_CALL(delegate, OnBufferReceived(buffer_id, timestamp,
- AllOf(Field(&media::VideoCaptureFormat::width, 234),
- Field(&media::VideoCaptureFormat::height, 512),
- Field(&media::VideoCaptureFormat::frame_rate, 30))));
+ media::VideoCaptureFormat format(
+ gfx::Size(234, 512), 30, media::PIXEL_FORMAT_I420);
+ media::VideoCaptureFormat saved_format;
+ EXPECT_CALL(delegate, OnBufferReceived(buffer_id, timestamp, _))
+ .WillRepeatedly(SaveArg<2>(&saved_format));
filter->OnMessageReceived(VideoCaptureMsg_BufferReady(
delegate.device_id(), buffer_id, timestamp, format));
Mock::VerifyAndClearExpectations(&delegate);
+ EXPECT_EQ(234, saved_format.frame_size.width());
+ EXPECT_EQ(512, saved_format.frame_size.height());
+ EXPECT_EQ(30, saved_format.frame_rate);
// VideoCaptureMsg_FreeBuffer
EXPECT_CALL(delegate, OnBufferDestroyed(buffer_id));