summaryrefslogtreecommitdiffstats
path: root/remoting/client/rectangle_update_decoder.cc
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 16:54:48 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 16:54:48 +0000
commitd8a6ca901e27fe58e1385492b0fc0cc8bbccaa10 (patch)
tree97322432de7e2381eb065cc3af19d53abba6e2f3 /remoting/client/rectangle_update_decoder.cc
parent804443aef39615edd5b731aa5bfb3c611aeae697 (diff)
downloadchromium_src-d8a6ca901e27fe58e1385492b0fc0cc8bbccaa10.zip
chromium_src-d8a6ca901e27fe58e1385492b0fc0cc8bbccaa10.tar.gz
chromium_src-d8a6ca901e27fe58e1385492b0fc0cc8bbccaa10.tar.bz2
Revert 76747 - Let the host change resolution.
The screen size flows through the video pipeline, instead of being set statically when that pipeline is constructed. Only the Windows host actually detects when the screen size has changed. BUG=72469 TEST=none Review URL: http://codereview.chromium.org/6573005 TBR=simonmorris@chromium.org Review URL: http://codereview.chromium.org/6610018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/rectangle_update_decoder.cc')
-rw-r--r--remoting/client/rectangle_update_decoder.cc114
1 files changed, 50 insertions, 64 deletions
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc
index 5659fc5..2690e14 100644
--- a/remoting/client/rectangle_update_decoder.cc
+++ b/remoting/client/rectangle_update_decoder.cc
@@ -44,16 +44,15 @@ class PartialFrameCleanup : public Task {
RectangleUpdateDecoder::RectangleUpdateDecoder(MessageLoop* message_loop,
FrameConsumer* consumer)
: message_loop_(message_loop),
- consumer_(consumer),
- frame_is_new_(false) {
+ consumer_(consumer) {
}
RectangleUpdateDecoder::~RectangleUpdateDecoder() {
}
void RectangleUpdateDecoder::Initialize(const SessionConfig* config) {
- initial_screen_size_ = gfx::Size(config->initial_resolution().width,
- config->initial_resolution().height);
+ screen_size_ = gfx::Size(config->initial_resolution().width,
+ config->initial_resolution().height);
// Initialize decoder based on the selected codec.
ChannelConfig::Codec codec = config->video_config().codec;
@@ -88,90 +87,77 @@ void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet,
TraceContext::tracer()->PrintString("Decode Packet called.");
- AllocateFrame(packet, done_runner.release());
+ if (!decoder_->IsReadyForData()) {
+ InitializeDecoder(
+ NewTracedMethod(this,
+ &RectangleUpdateDecoder::ProcessPacketData,
+ packet, done_runner.release()));
+ } else {
+ ProcessPacketData(packet, done_runner.release());
+ }
}
-void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet,
- Task* done) {
+void RectangleUpdateDecoder::ProcessPacketData(
+ const VideoPacket* packet, Task* done) {
+ AutoTaskRunner done_runner(done);
+
+ if (!decoder_->IsReadyForData()) {
+ // TODO(ajwong): This whole thing should move into an invalid state.
+ LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
+ return;
+ }
+
+ TraceContext::tracer()->PrintString("Executing Decode.");
+
+ Decoder::DecodeResult result = decoder_->DecodePacket(packet);
+
+ if (result == Decoder::DECODE_DONE) {
+ UpdatedRects* rects = new UpdatedRects();
+ decoder_->GetUpdatedRects(rects);
+ consumer_->OnPartialFrameOutput(frame_, rects,
+ new PartialFrameCleanup(frame_, rects));
+ }
+}
+
+void RectangleUpdateDecoder::InitializeDecoder(Task* done) {
if (message_loop_ != MessageLoop::current()) {
message_loop_->PostTask(
FROM_HERE,
NewTracedMethod(this,
- &RectangleUpdateDecoder::AllocateFrame, packet, done));
+ &RectangleUpdateDecoder::InitializeDecoder, done));
return;
}
AutoTaskRunner done_runner(done);
- TraceContext::tracer()->PrintString("AllocateFrame called.");
-
- // Find the required frame size.
- bool has_screen_size = packet->format().has_screen_width() &&
- packet->format().has_screen_height();
- gfx::Size screen_size(packet->format().screen_width(),
- packet->format().screen_height());
- if (!has_screen_size)
- screen_size = initial_screen_size_;
-
- // Find the current frame size.
- gfx::Size frame_size(0, 0);
- if (frame_)
- frame_size = gfx::Size(static_cast<int>(frame_->width()),
- static_cast<int>(frame_->height()));
-
- // Allocate a new frame, if necessary.
- if ((!frame_) || (has_screen_size && (screen_size != frame_size))) {
+ // Check if we need to request a new frame.
+ if (!frame_ ||
+ frame_->width() != static_cast<size_t>(screen_size_.width()) ||
+ frame_->height() != static_cast<size_t>(screen_size_.height())) {
if (frame_) {
TraceContext::tracer()->PrintString("Releasing old frame.");
consumer_->ReleaseFrame(frame_);
frame_ = NULL;
}
TraceContext::tracer()->PrintString("Requesting new frame.");
-
consumer_->AllocateFrame(media::VideoFrame::RGB32,
- screen_size.width(), screen_size.height(),
+ screen_size_.width(), screen_size_.height(),
base::TimeDelta(), base::TimeDelta(),
&frame_,
- NewRunnableMethod(this,
- &RectangleUpdateDecoder::ProcessPacketData,
- packet, done_runner.release()));
- frame_is_new_ = true;
+ NewTracedMethod(
+ this,
+ &RectangleUpdateDecoder::InitializeDecoder,
+ done_runner.release()));
return;
}
- ProcessPacketData(packet, done_runner.release());
-}
-
-void RectangleUpdateDecoder::ProcessPacketData(
- const VideoPacket* packet, Task* done) {
- if (message_loop_ != MessageLoop::current()) {
- message_loop_->PostTask(
- FROM_HERE,
- NewTracedMethod(this,
- &RectangleUpdateDecoder::ProcessPacketData, packet,
- done));
- return;
- }
- AutoTaskRunner done_runner(done);
-
- if (frame_is_new_) {
- decoder_->Reset();
- decoder_->Initialize(frame_);
- frame_is_new_ = false;
- }
- if (!decoder_->IsReadyForData()) {
- // TODO(ajwong): This whole thing should move into an invalid state.
- LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
- return;
- }
+ // TODO(ajwong): We need to handle the allocator failing to create a frame
+ // and properly disable this class.
+ CHECK(frame_);
- TraceContext::tracer()->PrintString("Executing Decode.");
+ decoder_->Reset();
+ decoder_->Initialize(frame_);
- if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) {
- UpdatedRects* rects = new UpdatedRects();
- decoder_->GetUpdatedRects(rects);
- consumer_->OnPartialFrameOutput(frame_, rects,
- new PartialFrameCleanup(frame_, rects));
- }
+ TraceContext::tracer()->PrintString("Decoder is Initialized");
}
} // namespace remoting