OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/gpu/media/fake_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/fake_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // This class asks for it on initialization instead. | 60 // This class asks for it on initialization instead. |
61 client_ = client; | 61 client_ = client; |
62 client_->ProvidePictureBuffers(kNumBuffers, | 62 client_->ProvidePictureBuffers(kNumBuffers, |
63 frame_buffer_size_, | 63 frame_buffer_size_, |
64 kDefaultTextureTarget); | 64 kDefaultTextureTarget); |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 void FakeVideoDecodeAccelerator::Decode( | 68 void FakeVideoDecodeAccelerator::Decode( |
69 const media::BitstreamBuffer& bitstream_buffer) { | 69 const media::BitstreamBuffer& bitstream_buffer) { |
| 70 // We won't really read from the bitstream_buffer, close the handle. |
| 71 if (base::SharedMemory::IsHandleValid(bitstream_buffer.handle())) |
| 72 base::SharedMemory::CloseHandle(bitstream_buffer.handle()); |
| 73 |
| 74 if (bitstream_buffer.id() < 0) { |
| 75 LOG(ERROR) << "Invalid bitstream: id=" << bitstream_buffer.id(); |
| 76 client_->NotifyError(INVALID_ARGUMENT); |
| 77 return; |
| 78 } |
| 79 |
70 int bitstream_buffer_id = bitstream_buffer.id(); | 80 int bitstream_buffer_id = bitstream_buffer.id(); |
71 queued_bitstream_ids_.push(bitstream_buffer_id); | 81 queued_bitstream_ids_.push(bitstream_buffer_id); |
72 child_task_runner_->PostTask( | 82 child_task_runner_->PostTask( |
73 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, | 83 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, |
74 weak_this_factory_.GetWeakPtr())); | 84 weak_this_factory_.GetWeakPtr())); |
75 } | 85 } |
76 | 86 |
77 // Similar to UseOutputBitstreamBuffer for the encode accelerator. | 87 // Similar to UseOutputBitstreamBuffer for the encode accelerator. |
78 void FakeVideoDecodeAccelerator::AssignPictureBuffers( | 88 void FakeVideoDecodeAccelerator::AssignPictureBuffers( |
79 const std::vector<media::PictureBuffer>& buffers) { | 89 const std::vector<media::PictureBuffer>& buffers) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Bitstream no longer needed. | 186 // Bitstream no longer needed. |
177 client_->NotifyEndOfBitstreamBuffer(bitstream_id); | 187 client_->NotifyEndOfBitstreamBuffer(bitstream_id); |
178 if (flushing_ && queued_bitstream_ids_.empty()) { | 188 if (flushing_ && queued_bitstream_ids_.empty()) { |
179 flushing_ = false; | 189 flushing_ = false; |
180 client_->NotifyFlushDone(); | 190 client_->NotifyFlushDone(); |
181 } | 191 } |
182 } | 192 } |
183 } | 193 } |
184 | 194 |
185 } // namespace content | 195 } // namespace content |
OLD | NEW |