OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 make_context_current_(make_context_current), | 60 make_context_current_(make_context_current), |
61 state_(kUninitialized), | 61 state_(kUninitialized), |
62 input_ready_(&lock_), | 62 input_ready_(&lock_), |
63 output_ready_(&lock_), | 63 output_ready_(&lock_), |
64 message_loop_(MessageLoop::current()), | 64 message_loop_(MessageLoop::current()), |
65 weak_this_(base::AsWeakPtr(this)), | 65 weak_this_(base::AsWeakPtr(this)), |
66 client_ptr_factory_(client), | 66 client_ptr_factory_(client), |
67 client_(client_ptr_factory_.GetWeakPtr()), | 67 client_(client_ptr_factory_.GetWeakPtr()), |
68 decoder_thread_("VaapiDecoderThread") { | 68 decoder_thread_("VaapiDecoderThread") { |
69 DCHECK(client); | 69 DCHECK(client); |
| 70 static bool vaapi_functions_initialized = PostSandboxInitialization(); |
| 71 RETURN_AND_NOTIFY_ON_FAILURE(vaapi_functions_initialized, |
| 72 "Failed to initialize VAAPI libs", |
| 73 PLATFORM_FAILURE, ); |
70 } | 74 } |
71 | 75 |
72 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { | 76 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { |
73 DCHECK_EQ(message_loop_, MessageLoop::current()); | 77 DCHECK_EQ(message_loop_, MessageLoop::current()); |
74 } | 78 } |
75 | 79 |
76 bool VaapiVideoDecodeAccelerator::Initialize( | 80 bool VaapiVideoDecodeAccelerator::Initialize( |
77 media::VideoCodecProfile profile) { | 81 media::VideoCodecProfile profile) { |
78 DCHECK_EQ(message_loop_, MessageLoop::current()); | 82 DCHECK_EQ(message_loop_, MessageLoop::current()); |
79 | 83 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 decoder_.Destroy(); | 552 decoder_.Destroy(); |
549 state_ = kUninitialized; | 553 state_ = kUninitialized; |
550 } | 554 } |
551 | 555 |
552 void VaapiVideoDecodeAccelerator::Destroy() { | 556 void VaapiVideoDecodeAccelerator::Destroy() { |
553 DCHECK_EQ(message_loop_, MessageLoop::current()); | 557 DCHECK_EQ(message_loop_, MessageLoop::current()); |
554 Cleanup(); | 558 Cleanup(); |
555 delete this; | 559 delete this; |
556 } | 560 } |
557 | 561 |
| 562 // static |
| 563 void VaapiVideoDecodeAccelerator::PreSandboxInitialization() { |
| 564 VaapiH264Decoder::PreSandboxInitialization(); |
| 565 } |
| 566 |
| 567 // static |
| 568 bool VaapiVideoDecodeAccelerator::PostSandboxInitialization() { |
| 569 return VaapiH264Decoder::PostSandboxInitialization(); |
| 570 } |
| 571 |
558 void VaapiVideoDecodeAccelerator::OutputPicCallback(int32 input_id, | 572 void VaapiVideoDecodeAccelerator::OutputPicCallback(int32 input_id, |
559 int32 output_id) { | 573 int32 output_id) { |
560 TRACE_EVENT2("Video Decoder", "VAVDA::OutputPicCallback", | 574 TRACE_EVENT2("Video Decoder", "VAVDA::OutputPicCallback", |
561 "Input id", input_id, "Picture id", output_id); | 575 "Input id", input_id, "Picture id", output_id); |
562 DVLOG(4) << "Outputting picture, input id: " << input_id | 576 DVLOG(4) << "Outputting picture, input id: " << input_id |
563 << " output id: " << output_id; | 577 << " output id: " << output_id; |
564 | 578 |
565 // Forward the request to the main thread. | 579 // Forward the request to the main thread. |
566 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); | 580 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); |
567 message_loop_->PostTask(FROM_HERE, base::Bind( | 581 message_loop_->PostTask(FROM_HERE, base::Bind( |
568 &VaapiVideoDecodeAccelerator::SyncAndNotifyPictureReady, weak_this_, | 582 &VaapiVideoDecodeAccelerator::SyncAndNotifyPictureReady, weak_this_, |
569 input_id, output_id)); | 583 input_id, output_id)); |
570 } | 584 } |
OLD | NEW |