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

Side by Side Diff: media/base/composite_filter.cc

Issue 8922010: <video> decode in hardware! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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/base/composite_filter.h ('k') | media/base/composite_filter_unittest.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) 2011 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 "media/base/composite_filter.h" 5 #include "media/base/composite_filter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 CompositeFilter::~CompositeFilter() { 52 CompositeFilter::~CompositeFilter() {
53 DCHECK_EQ(message_loop_, MessageLoop::current()); 53 DCHECK_EQ(message_loop_, MessageLoop::current());
54 DCHECK(state_ == kCreated || state_ == kStopped); 54 DCHECK(state_ == kCreated || state_ == kStopped);
55 55
56 filters_.clear(); 56 filters_.clear();
57 } 57 }
58 58
59 bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) { 59 bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) {
60 // TODO(fischman,scherkus): s/bool/void/ the return type and CHECK on failure
61 // of the sanity-checks that return false today.
60 DCHECK_EQ(message_loop_, MessageLoop::current()); 62 DCHECK_EQ(message_loop_, MessageLoop::current());
61 if (!filter.get() || state_ != kCreated || !host()) 63 if (!filter.get() || state_ != kCreated || !host())
62 return false; 64 return false;
63 65
64 // Register ourselves as the filter's host. 66 // Register ourselves as the filter's host.
65 filter->set_host(host_impl_.get()); 67 filter->set_host(host_impl_.get());
66 filters_.push_back(make_scoped_refptr(filter.get())); 68 filters_.push_back(make_scoped_refptr(filter.get()));
67 return true; 69 return true;
68 } 70 }
69 71
72 void CompositeFilter::RemoveFilter(scoped_refptr<Filter> filter) {
73 DCHECK_EQ(message_loop_, MessageLoop::current());
74 if (!filter.get() || state_ != kCreated || !host())
75 LOG(FATAL) << "Unknown filter, or in unexpected state.";
76
77 for (FilterVector::iterator it = filters_.begin();
78 it != filters_.end(); ++it) {
79 if (it->get() != filter.get())
80 continue;
81 filters_.erase(it);
82 filter->clear_host();
83 return;
84 }
85 NOTREACHED() << "Filter missing.";
86 }
87
70 void CompositeFilter::set_host(FilterHost* host) { 88 void CompositeFilter::set_host(FilterHost* host) {
71 DCHECK_EQ(message_loop_, MessageLoop::current()); 89 DCHECK_EQ(message_loop_, MessageLoop::current());
72 DCHECK(host); 90 DCHECK(host);
73 DCHECK(!host_impl_.get()); 91 DCHECK(!host_impl_.get());
74 host_impl_.reset(new FilterHostImpl(this, host)); 92 host_impl_.reset(new FilterHostImpl(this, host));
75 } 93 }
76 94
77 FilterHost* CompositeFilter::host() { 95 FilterHost* CompositeFilter::host() {
78 return host_impl_.get() ? host_impl_->host() : NULL; 96 return host_impl_.get() ? host_impl_->host() : NULL;
79 } 97 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 348 }
331 349
332 void CompositeFilter::SerialCallback() { 350 void CompositeFilter::SerialCallback() {
333 DCHECK_EQ(message_loop_, MessageLoop::current()); 351 DCHECK_EQ(message_loop_, MessageLoop::current());
334 if (status_ != PIPELINE_OK) { 352 if (status_ != PIPELINE_OK) {
335 // We encountered an error. Terminate the sequence now. 353 // We encountered an error. Terminate the sequence now.
336 ChangeState(kError); 354 ChangeState(kError);
337 DispatchPendingCallback(status_); 355 DispatchPendingCallback(status_);
338 return; 356 return;
339 } 357 }
340
341 if (!filters_.empty()) 358 if (!filters_.empty())
342 sequence_index_++; 359 sequence_index_++;
343 360
344 if (sequence_index_ == filters_.size()) { 361 if (sequence_index_ == filters_.size()) {
345 // All filters have been successfully called without error. 362 // All filters have been successfully called without error.
346 OnCallSequenceDone(); 363 OnCallSequenceDone();
347 } else if (GetNextState(state_) == kStopPending) { 364 } else if (GetNextState(state_) == kStopPending) {
348 // Abort sequence early and start issuing Stop() calls. 365 // Abort sequence early and start issuing Stop() calls.
349 ChangeState(kStopPending); 366 ChangeState(kStopPending);
350 StartSerialCallSequence(); 367 StartSerialCallSequence();
(...skipping 17 matching lines...) Expand all
368 DispatchPendingCallback(status_); 385 DispatchPendingCallback(status_);
369 return; 386 return;
370 } 387 }
371 388
372 OnCallSequenceDone(); 389 OnCallSequenceDone();
373 } 390 }
374 } 391 }
375 392
376 void CompositeFilter::OnCallSequenceDone() { 393 void CompositeFilter::OnCallSequenceDone() {
377 State next_state = GetNextState(state_); 394 State next_state = GetNextState(state_);
378
379 if (next_state == kInvalid) { 395 if (next_state == kInvalid) {
380 // We somehow got into an unexpected state. 396 // We somehow got into an unexpected state.
381 ChangeState(kError); 397 ChangeState(kError);
382 DispatchPendingCallback(PIPELINE_ERROR_INVALID_STATE); 398 DispatchPendingCallback(PIPELINE_ERROR_INVALID_STATE);
383 return; 399 return;
384 } 400 }
385 401
386 ChangeState(next_state); 402 ChangeState(next_state);
387 403
388 if (state_ == kStopPending) { 404 if (state_ == kStopPending) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 544
529 void CompositeFilter::FilterHostImpl::SetCurrentReadPosition(int64 offset) { 545 void CompositeFilter::FilterHostImpl::SetCurrentReadPosition(int64 offset) {
530 host_->SetCurrentReadPosition(offset); 546 host_->SetCurrentReadPosition(offset);
531 } 547 }
532 548
533 int64 CompositeFilter::FilterHostImpl::GetCurrentReadPosition() { 549 int64 CompositeFilter::FilterHostImpl::GetCurrentReadPosition() {
534 return host_->GetCurrentReadPosition(); 550 return host_->GetCurrentReadPosition();
535 } 551 }
536 552
537 } // namespace media 553 } // namespace media
OLDNEW
« no previous file with comments | « media/base/composite_filter.h ('k') | media/base/composite_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698