| OLD | NEW |
| 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 "content/common/gpu/media/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Destroy, OnDestroy) | 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Destroy, OnDestroy) |
| 52 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
| 53 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
| 54 return handled; | 54 return handled; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void GpuVideoDecodeAccelerator::ProvidePictureBuffers( | 57 void GpuVideoDecodeAccelerator::ProvidePictureBuffers( |
| 58 uint32 requested_num_of_buffers, const gfx::Size& dimensions) { | 58 uint32 requested_num_of_buffers, const gfx::Size& dimensions) { |
| 59 if (!Send(new AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers( | 59 if (!Send(new AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers( |
| 60 host_route_id_, requested_num_of_buffers, dimensions))) { | 60 host_route_id_, requested_num_of_buffers, dimensions))) { |
| 61 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers) " | 61 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers) " |
| 62 << "failed"; | 62 << "failed"; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 void GpuVideoDecodeAccelerator::DismissPictureBuffer( | 66 void GpuVideoDecodeAccelerator::DismissPictureBuffer( |
| 67 int32 picture_buffer_id) { | 67 int32 picture_buffer_id) { |
| 68 // Notify client that picture buffer is now unused. | 68 // Notify client that picture buffer is now unused. |
| 69 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( | 69 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( |
| 70 host_route_id_, picture_buffer_id))) { | 70 host_route_id_, picture_buffer_id))) { |
| 71 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " | 71 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " |
| 72 << "failed"; | 72 << "failed"; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 void GpuVideoDecodeAccelerator::PictureReady( | 76 void GpuVideoDecodeAccelerator::PictureReady( |
| 77 const media::Picture& picture) { | 77 const media::Picture& picture) { |
| 78 if (!Send(new AcceleratedVideoDecoderHostMsg_PictureReady( | 78 if (!Send(new AcceleratedVideoDecoderHostMsg_PictureReady( |
| 79 host_route_id_, | 79 host_route_id_, |
| 80 picture.picture_buffer_id(), | 80 picture.picture_buffer_id(), |
| 81 picture.bitstream_buffer_id()))) { | 81 picture.bitstream_buffer_id()))) { |
| 82 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_PictureReady) failed"; | 82 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_PictureReady) failed"; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void GpuVideoDecodeAccelerator::NotifyEndOfStream() { | 86 void GpuVideoDecodeAccelerator::NotifyEndOfStream() { |
| 87 Send(new AcceleratedVideoDecoderHostMsg_EndOfStream(host_route_id_)); | 87 Send(new AcceleratedVideoDecoderHostMsg_EndOfStream(host_route_id_)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void GpuVideoDecodeAccelerator::NotifyError( | 90 void GpuVideoDecodeAccelerator::NotifyError( |
| 91 media::VideoDecodeAccelerator::Error error) { | 91 media::VideoDecodeAccelerator::Error error) { |
| 92 if (init_done_msg_) { | 92 if (init_done_msg_) { |
| 93 // If we get an error while we're initializing, NotifyInitializeDone won't | 93 // If we get an error while we're initializing, NotifyInitializeDone won't |
| 94 // be called, so we need to send the reply (with an error) here. | 94 // be called, so we need to send the reply (with an error) here. |
| 95 init_done_msg_->set_reply_error(); | 95 init_done_msg_->set_reply_error(); |
| 96 Send(init_done_msg_); | 96 Send(init_done_msg_); |
| 97 init_done_msg_ = NULL; | 97 init_done_msg_ = NULL; |
| 98 } | 98 } |
| 99 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( | 99 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( |
| 100 host_route_id_, error))) { | 100 host_route_id_, error))) { |
| 101 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " | 101 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " |
| 102 << "failed"; | 102 << "failed"; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 void GpuVideoDecodeAccelerator::Initialize( | 106 void GpuVideoDecodeAccelerator::Initialize( |
| 107 const media::VideoDecodeAccelerator::Profile profile, | 107 const media::VideoDecodeAccelerator::Profile profile, |
| 108 IPC::Message* init_done_msg) { | 108 IPC::Message* init_done_msg) { |
| 109 DCHECK(!video_decode_accelerator_.get()); | 109 DCHECK(!video_decode_accelerator_.get()); |
| 110 DCHECK(!init_done_msg_); | 110 DCHECK(!init_done_msg_); |
| 111 DCHECK(init_done_msg); | 111 DCHECK(init_done_msg); |
| 112 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 112 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 136 const std::vector<gfx::Size>& sizes) { | 136 const std::vector<gfx::Size>& sizes) { |
| 137 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. | 137 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. |
| 138 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | 138 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); |
| 139 | 139 |
| 140 std::vector<media::PictureBuffer> buffers; | 140 std::vector<media::PictureBuffer> buffers; |
| 141 for (uint32 i = 0; i < buffer_ids.size(); ++i) { | 141 for (uint32 i = 0; i < buffer_ids.size(); ++i) { |
| 142 uint32 service_texture_id; | 142 uint32 service_texture_id; |
| 143 if (!command_decoder->GetServiceTextureId( | 143 if (!command_decoder->GetServiceTextureId( |
| 144 texture_ids[i], &service_texture_id)) { | 144 texture_ids[i], &service_texture_id)) { |
| 145 // TODO(vrk): Send an error for invalid GLES buffers. | 145 // TODO(vrk): Send an error for invalid GLES buffers. |
| 146 DLOG(DFATAL) << "Failed to translate texture!"; | 146 LOG(DFATAL) << "Failed to translate texture!"; |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 buffers.push_back(media::PictureBuffer( | 149 buffers.push_back(media::PictureBuffer( |
| 150 buffer_ids[i], sizes[i], service_texture_id)); | 150 buffer_ids[i], sizes[i], service_texture_id)); |
| 151 } | 151 } |
| 152 video_decode_accelerator_->AssignPictureBuffers(buffers); | 152 video_decode_accelerator_->AssignPictureBuffers(buffers); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( | 155 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( |
| 156 int32 picture_buffer_id) { | 156 int32 picture_buffer_id) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 178 if (!Send(new AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed( | 178 if (!Send(new AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed( |
| 179 host_route_id_, bitstream_buffer_id))) { | 179 host_route_id_, bitstream_buffer_id))) { |
| 180 DLOG(ERROR) | 180 DLOG(ERROR) |
| 181 << "Send(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed) " | 181 << "Send(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed) " |
| 182 << "failed"; | 182 << "failed"; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void GpuVideoDecodeAccelerator::NotifyInitializeDone() { | 186 void GpuVideoDecodeAccelerator::NotifyInitializeDone() { |
| 187 if (!Send(init_done_msg_)) | 187 if (!Send(init_done_msg_)) |
| 188 DLOG(ERROR) << "Send(init_done_msg_) failed"; | 188 LOG(ERROR) << "Send(init_done_msg_) failed"; |
| 189 init_done_msg_ = NULL; | 189 init_done_msg_ = NULL; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void GpuVideoDecodeAccelerator::NotifyFlushDone() { | 192 void GpuVideoDecodeAccelerator::NotifyFlushDone() { |
| 193 if (!Send(new AcceleratedVideoDecoderHostMsg_FlushDone(host_route_id_))) | 193 if (!Send(new AcceleratedVideoDecoderHostMsg_FlushDone(host_route_id_))) |
| 194 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; | 194 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; |
| 195 } | 195 } |
| 196 | 196 |
| 197 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 197 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
| 198 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 198 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
| 199 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 199 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 202 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 203 DCHECK(sender_); | 203 DCHECK(sender_); |
| 204 return sender_->Send(message); | 204 return sender_->Send(message); |
| 205 } | 205 } |
| OLD | NEW |