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

Side by Side Diff: remoting/client/rectangle_update_decoder.cc

Issue 7062013: Move media library AutoTaskRunner to base and rename ScopedTaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add innocuous but critical BASE_API modifier to ScopedTaskRunner declaration. Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/rectangle_update_decoder.h" 5 #include "remoting/client/rectangle_update_decoder.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "media/base/callback.h"
10 #include "remoting/base/decoder.h" 9 #include "remoting/base/decoder.h"
11 #include "remoting/base/decoder_row_based.h" 10 #include "remoting/base/decoder_row_based.h"
12 #include "remoting/base/decoder_vp8.h" 11 #include "remoting/base/decoder_vp8.h"
13 #include "remoting/base/tracer.h" 12 #include "remoting/base/tracer.h"
14 #include "remoting/base/util.h" 13 #include "remoting/base/util.h"
15 #include "remoting/client/frame_consumer.h" 14 #include "remoting/client/frame_consumer.h"
16 #include "remoting/protocol/session_config.h" 15 #include "remoting/protocol/session_config.h"
17 16
18 using media::AutoTaskRunner;
19 using remoting::protocol::ChannelConfig; 17 using remoting::protocol::ChannelConfig;
20 using remoting::protocol::SessionConfig; 18 using remoting::protocol::SessionConfig;
21 19
22 namespace remoting { 20 namespace remoting {
23 21
24 namespace { 22 namespace {
25 23
26 class PartialFrameCleanup : public Task { 24 class PartialFrameCleanup : public Task {
27 public: 25 public:
28 PartialFrameCleanup(media::VideoFrame* frame, UpdatedRects* rects) 26 PartialFrameCleanup(media::VideoFrame* frame, UpdatedRects* rects)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet, 75 void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet,
78 Task* done) { 76 Task* done) {
79 if (message_loop_ != MessageLoop::current()) { 77 if (message_loop_ != MessageLoop::current()) {
80 message_loop_->PostTask( 78 message_loop_->PostTask(
81 FROM_HERE, 79 FROM_HERE,
82 NewTracedMethod(this, 80 NewTracedMethod(this,
83 &RectangleUpdateDecoder::DecodePacket, packet, 81 &RectangleUpdateDecoder::DecodePacket, packet,
84 done)); 82 done));
85 return; 83 return;
86 } 84 }
87 AutoTaskRunner done_runner(done); 85 base::ScopedTaskRunner done_runner(done);
88 86
89 TraceContext::tracer()->PrintString("Decode Packet called."); 87 TraceContext::tracer()->PrintString("Decode Packet called.");
90 88
91 AllocateFrame(packet, done_runner.release()); 89 AllocateFrame(packet, done_runner.Release());
92 } 90 }
93 91
94 void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet, 92 void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet,
95 Task* done) { 93 Task* done) {
96 if (message_loop_ != MessageLoop::current()) { 94 if (message_loop_ != MessageLoop::current()) {
97 message_loop_->PostTask( 95 message_loop_->PostTask(
98 FROM_HERE, 96 FROM_HERE,
99 NewTracedMethod(this, 97 NewTracedMethod(this,
100 &RectangleUpdateDecoder::AllocateFrame, packet, done)); 98 &RectangleUpdateDecoder::AllocateFrame, packet, done));
101 return; 99 return;
102 } 100 }
103 AutoTaskRunner done_runner(done); 101 base::ScopedTaskRunner done_runner(done);
104 102
105 TraceContext::tracer()->PrintString("AllocateFrame called."); 103 TraceContext::tracer()->PrintString("AllocateFrame called.");
106 104
107 // Find the required frame size. 105 // Find the required frame size.
108 bool has_screen_size = packet->format().has_screen_width() && 106 bool has_screen_size = packet->format().has_screen_width() &&
109 packet->format().has_screen_height(); 107 packet->format().has_screen_height();
110 gfx::Size screen_size(packet->format().screen_width(), 108 gfx::Size screen_size(packet->format().screen_width(),
111 packet->format().screen_height()); 109 packet->format().screen_height());
112 if (!has_screen_size) 110 if (!has_screen_size)
113 screen_size = initial_screen_size_; 111 screen_size = initial_screen_size_;
(...skipping 12 matching lines...) Expand all
126 frame_ = NULL; 124 frame_ = NULL;
127 } 125 }
128 TraceContext::tracer()->PrintString("Requesting new frame."); 126 TraceContext::tracer()->PrintString("Requesting new frame.");
129 127
130 consumer_->AllocateFrame(media::VideoFrame::RGB32, 128 consumer_->AllocateFrame(media::VideoFrame::RGB32,
131 screen_size.width(), screen_size.height(), 129 screen_size.width(), screen_size.height(),
132 base::TimeDelta(), base::TimeDelta(), 130 base::TimeDelta(), base::TimeDelta(),
133 &frame_, 131 &frame_,
134 NewRunnableMethod(this, 132 NewRunnableMethod(this,
135 &RectangleUpdateDecoder::ProcessPacketData, 133 &RectangleUpdateDecoder::ProcessPacketData,
136 packet, done_runner.release())); 134 packet, done_runner.Release()));
137 frame_is_new_ = true; 135 frame_is_new_ = true;
138 return; 136 return;
139 } 137 }
140 ProcessPacketData(packet, done_runner.release()); 138 ProcessPacketData(packet, done_runner.Release());
141 } 139 }
142 140
143 void RectangleUpdateDecoder::ProcessPacketData( 141 void RectangleUpdateDecoder::ProcessPacketData(
144 const VideoPacket* packet, Task* done) { 142 const VideoPacket* packet, Task* done) {
145 if (message_loop_ != MessageLoop::current()) { 143 if (message_loop_ != MessageLoop::current()) {
146 message_loop_->PostTask( 144 message_loop_->PostTask(
147 FROM_HERE, 145 FROM_HERE,
148 NewTracedMethod(this, 146 NewTracedMethod(this,
149 &RectangleUpdateDecoder::ProcessPacketData, packet, 147 &RectangleUpdateDecoder::ProcessPacketData, packet,
150 done)); 148 done));
151 return; 149 return;
152 } 150 }
153 AutoTaskRunner done_runner(done); 151 base::ScopedTaskRunner done_runner(done);
154 152
155 if (frame_is_new_) { 153 if (frame_is_new_) {
156 decoder_->Reset(); 154 decoder_->Reset();
157 decoder_->Initialize(frame_); 155 decoder_->Initialize(frame_);
158 frame_is_new_ = false; 156 frame_is_new_ = false;
159 } 157 }
160 158
161 if (!decoder_->IsReadyForData()) { 159 if (!decoder_->IsReadyForData()) {
162 // TODO(ajwong): This whole thing should move into an invalid state. 160 // TODO(ajwong): This whole thing should move into an invalid state.
163 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; 161 LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
164 return; 162 return;
165 } 163 }
166 164
167 TraceContext::tracer()->PrintString("Executing Decode."); 165 TraceContext::tracer()->PrintString("Executing Decode.");
168 166
169 if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) { 167 if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) {
170 UpdatedRects* rects = new UpdatedRects(); 168 UpdatedRects* rects = new UpdatedRects();
171 decoder_->GetUpdatedRects(rects); 169 decoder_->GetUpdatedRects(rects);
172 consumer_->OnPartialFrameOutput(frame_, rects, 170 consumer_->OnPartialFrameOutput(frame_, rects,
173 new PartialFrameCleanup(frame_, rects)); 171 new PartialFrameCleanup(frame_, rects));
174 } 172 }
175 } 173 }
176 174
177 } // namespace remoting 175 } // namespace remoting
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698