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

Side by Side Diff: content/common/gpu/client/gpu_video_encode_accelerator_host.cc

Issue 1378073002: Removed NOTIFY_ERROR() macro from GpuVEAH. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment reflected Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/client/gpu_video_encode_accelerator_host.h" 5 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/common/gpu/client/gpu_channel_host.h" 8 #include "content/common/gpu/client/gpu_channel_host.h"
9 #include "content/common/gpu/gpu_messages.h" 9 #include "content/common/gpu/gpu_messages.h"
10 #include "content/common/gpu/media/gpu_video_accelerator_util.h" 10 #include "content/common/gpu/media/gpu_video_accelerator_util.h"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 #define NOTIFY_ERROR(error) \
16 PostNotifyError(error); \
17 DLOG(ERROR)
18
19 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost( 15 GpuVideoEncodeAcceleratorHost::GpuVideoEncodeAcceleratorHost(
20 GpuChannelHost* channel, 16 GpuChannelHost* channel,
21 CommandBufferProxyImpl* impl) 17 CommandBufferProxyImpl* impl)
22 : channel_(channel), 18 : channel_(channel),
23 encoder_route_id_(MSG_ROUTING_NONE), 19 encoder_route_id_(MSG_ROUTING_NONE),
24 client_(NULL), 20 client_(NULL),
25 impl_(impl), 21 impl_(impl),
26 next_frame_id_(0), 22 next_frame_id_(0),
27 weak_this_factory_(this) { 23 weak_this_factory_(this) {
28 DCHECK(channel_); 24 DCHECK(channel_);
(...skipping 29 matching lines...) Expand all
58 return handled; 54 return handled;
59 } 55 }
60 56
61 void GpuVideoEncodeAcceleratorHost::OnChannelError() { 57 void GpuVideoEncodeAcceleratorHost::OnChannelError() {
62 DCHECK(CalledOnValidThread()); 58 DCHECK(CalledOnValidThread());
63 if (channel_) { 59 if (channel_) {
64 if (encoder_route_id_ != MSG_ROUTING_NONE) 60 if (encoder_route_id_ != MSG_ROUTING_NONE)
65 channel_->RemoveRoute(encoder_route_id_); 61 channel_->RemoveRoute(encoder_route_id_);
66 channel_ = NULL; 62 channel_ = NULL;
67 } 63 }
68 NOTIFY_ERROR(kPlatformFailureError) << "OnChannelError()"; 64 DLOG(ERROR) << "OnChannelError()";
65 PostNotifyError(kPlatformFailureError);
69 } 66 }
70 67
71 media::VideoEncodeAccelerator::SupportedProfiles 68 media::VideoEncodeAccelerator::SupportedProfiles
72 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() { 69 GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() {
73 DCHECK(CalledOnValidThread()); 70 DCHECK(CalledOnValidThread());
74 if (!channel_) 71 if (!channel_)
75 return media::VideoEncodeAccelerator::SupportedProfiles(); 72 return media::VideoEncodeAccelerator::SupportedProfiles();
76 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( 73 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(
77 channel_->gpu_info().video_encode_accelerator_supported_profiles); 74 channel_->gpu_info().video_encode_accelerator_supported_profiles);
78 } 75 }
(...skipping 28 matching lines...) Expand all
107 } 104 }
108 105
109 void GpuVideoEncodeAcceleratorHost::Encode( 106 void GpuVideoEncodeAcceleratorHost::Encode(
110 const scoped_refptr<media::VideoFrame>& frame, 107 const scoped_refptr<media::VideoFrame>& frame,
111 bool force_keyframe) { 108 bool force_keyframe) {
112 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
113 if (!channel_) 110 if (!channel_)
114 return; 111 return;
115 112
116 if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) { 113 if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
117 NOTIFY_ERROR(kPlatformFailureError) << "EncodeSharedMemory(): cannot " 114 DLOG(ERROR) << "EncodeSharedMemory(): cannot encode frame with "
118 "encode frame with invalid shared " 115 "invalid shared memory handle";
119 "memory handle"; 116 PostNotifyError(kPlatformFailureError);
120 return; 117 return;
121 } 118 }
122 119
123 AcceleratedVideoEncoderMsg_Encode_Params params; 120 AcceleratedVideoEncoderMsg_Encode_Params params;
124 params.frame_id = next_frame_id_; 121 params.frame_id = next_frame_id_;
125 params.buffer_handle = 122 params.buffer_handle =
126 channel_->ShareToGpuProcess(frame->shared_memory_handle()); 123 channel_->ShareToGpuProcess(frame->shared_memory_handle());
127 if (!base::SharedMemory::IsHandleValid(params.buffer_handle)) { 124 if (!base::SharedMemory::IsHandleValid(params.buffer_handle)) {
128 NOTIFY_ERROR(kPlatformFailureError) << "EncodeSharedMemory(): failed to " 125 DLOG(ERROR) << "EncodeSharedMemory(): failed to "
Pawel Osciak 2015/09/30 08:22:20 Sorry, but this could also fit in 2 lines.
msu.koo 2015/09/30 08:28:48 Done.
129 "duplicate buffer handle for GPU " 126 "duplicate buffer handle for GPU "
130 "process"; 127 "process";
128 PostNotifyError(kPlatformFailureError);
131 return; 129 return;
132 } 130 }
133 params.buffer_offset = 131 params.buffer_offset =
134 base::checked_cast<uint32_t>(frame->shared_memory_offset()); 132 base::checked_cast<uint32_t>(frame->shared_memory_offset());
135 // We assume that planar frame data passed here is packed and contiguous. 133 // We assume that planar frame data passed here is packed and contiguous.
136 base::CheckedNumeric<uint32_t> buffer_size = 0u; 134 base::CheckedNumeric<uint32_t> buffer_size = 0u;
137 for (size_t i = 0; i < media::VideoFrame::NumPlanes(frame->format()); ++i) { 135 for (size_t i = 0; i < media::VideoFrame::NumPlanes(frame->format()); ++i) {
138 // Cast DCHECK parameters to void* to avoid printing uint8* as a string. 136 // Cast DCHECK parameters to void* to avoid printing uint8* as a string.
139 DCHECK_EQ( 137 DCHECK_EQ(
140 reinterpret_cast<void*>(frame->data(i)), 138 reinterpret_cast<void*>(frame->data(i)),
(...skipping 14 matching lines...) Expand all
155 153
156 void GpuVideoEncodeAcceleratorHost::UseOutputBitstreamBuffer( 154 void GpuVideoEncodeAcceleratorHost::UseOutputBitstreamBuffer(
157 const media::BitstreamBuffer& buffer) { 155 const media::BitstreamBuffer& buffer) {
158 DCHECK(CalledOnValidThread()); 156 DCHECK(CalledOnValidThread());
159 if (!channel_) 157 if (!channel_)
160 return; 158 return;
161 159
162 base::SharedMemoryHandle handle = 160 base::SharedMemoryHandle handle =
163 channel_->ShareToGpuProcess(buffer.handle()); 161 channel_->ShareToGpuProcess(buffer.handle());
164 if (!base::SharedMemory::IsHandleValid(handle)) { 162 if (!base::SharedMemory::IsHandleValid(handle)) {
165 NOTIFY_ERROR(kPlatformFailureError) 163 DLOG(ERROR)
166 << "UseOutputBitstreamBuffer(): failed to duplicate buffer handle " 164 << "UseOutputBitstreamBuffer(): failed to duplicate buffer handle "
Pawel Osciak 2015/09/30 08:22:20 And this as well.
msu.koo 2015/09/30 08:28:48 Done.
167 "for GPU process: buffer.id()=" << buffer.id(); 165 "for GPU process: buffer.id()=" << buffer.id();
166 PostNotifyError(kPlatformFailureError);
168 return; 167 return;
169 } 168 }
170 Send(new AcceleratedVideoEncoderMsg_UseOutputBitstreamBuffer( 169 Send(new AcceleratedVideoEncoderMsg_UseOutputBitstreamBuffer(
171 encoder_route_id_, buffer.id(), handle, buffer.size())); 170 encoder_route_id_, buffer.id(), handle, buffer.size()));
172 } 171 }
173 172
174 void GpuVideoEncodeAcceleratorHost::RequestEncodingParametersChange( 173 void GpuVideoEncodeAcceleratorHost::RequestEncodingParametersChange(
175 uint32 bitrate, 174 uint32 bitrate,
176 uint32 framerate) { 175 uint32 framerate) {
177 DCHECK(CalledOnValidThread()); 176 DCHECK(CalledOnValidThread());
(...skipping 26 matching lines...) Expand all
204 // Post the error notification back to this thread, to avoid re-entrancy. 203 // Post the error notification back to this thread, to avoid re-entrancy.
205 base::ThreadTaskRunnerHandle::Get()->PostTask( 204 base::ThreadTaskRunnerHandle::Get()->PostTask(
206 FROM_HERE, base::Bind(&GpuVideoEncodeAcceleratorHost::OnNotifyError, 205 FROM_HERE, base::Bind(&GpuVideoEncodeAcceleratorHost::OnNotifyError,
207 weak_this_factory_.GetWeakPtr(), error)); 206 weak_this_factory_.GetWeakPtr(), error));
208 } 207 }
209 208
210 void GpuVideoEncodeAcceleratorHost::Send(IPC::Message* message) { 209 void GpuVideoEncodeAcceleratorHost::Send(IPC::Message* message) {
211 DCHECK(CalledOnValidThread()); 210 DCHECK(CalledOnValidThread());
212 uint32 message_type = message->type(); 211 uint32 message_type = message->type();
213 if (!channel_->Send(message)) { 212 if (!channel_->Send(message)) {
214 NOTIFY_ERROR(kPlatformFailureError) << "Send(" << message_type 213 DLOG(ERROR) << "Send(" << message_type << ") failed";
215 << ") failed"; 214 PostNotifyError(kPlatformFailureError);
216 } 215 }
217 } 216 }
218 217
219 void GpuVideoEncodeAcceleratorHost::OnRequireBitstreamBuffers( 218 void GpuVideoEncodeAcceleratorHost::OnRequireBitstreamBuffers(
220 uint32 input_count, 219 uint32 input_count,
221 const gfx::Size& input_coded_size, 220 const gfx::Size& input_coded_size,
222 uint32 output_buffer_size) { 221 uint32 output_buffer_size) {
223 DCHECK(CalledOnValidThread()); 222 DCHECK(CalledOnValidThread());
224 DVLOG(2) << "OnRequireBitstreamBuffers(): input_count=" << input_count 223 DVLOG(2) << "OnRequireBitstreamBuffers(): input_count=" << input_count
225 << ", input_coded_size=" << input_coded_size.ToString() 224 << ", input_coded_size=" << input_coded_size.ToString()
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 weak_this_factory_.InvalidateWeakPtrs(); 270 weak_this_factory_.InvalidateWeakPtrs();
272 271
273 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the 272 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the
274 // last thing done on this stack! 273 // last thing done on this stack!
275 media::VideoEncodeAccelerator::Client* client = NULL; 274 media::VideoEncodeAccelerator::Client* client = NULL;
276 std::swap(client_, client); 275 std::swap(client_, client);
277 client->NotifyError(error); 276 client->NotifyError(error);
278 } 277 }
279 278
280 } // namespace content 279 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698