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

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator.cc

Issue 10081018: Revert 132218 - Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
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 "content/common/gpu/media/dxva_video_decode_accelerator.h" 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #error This file should only be built on Windows. 8 #error This file should only be built on Windows.
9 #endif // !defined(OS_WIN) 9 #endif // !defined(OS_WIN)
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 RETURN_ON_HR_FAILURE(hr, "Failed to unlock buffer", NULL); 135 RETURN_ON_HR_FAILURE(hr, "Failed to unlock buffer", NULL);
136 136
137 hr = buffer->SetCurrentLength(size); 137 hr = buffer->SetCurrentLength(size);
138 RETURN_ON_HR_FAILURE(hr, "Failed to set buffer length", NULL); 138 RETURN_ON_HR_FAILURE(hr, "Failed to set buffer length", NULL);
139 139
140 return sample.Detach(); 140 return sample.Detach();
141 } 141 }
142 142
143 static IMFSample* CreateSampleFromInputBuffer( 143 static IMFSample* CreateSampleFromInputBuffer(
144 const media::BitstreamBuffer& bitstream_buffer, 144 const media::BitstreamBuffer& bitstream_buffer,
145 base::ProcessHandle renderer_process,
145 DWORD stream_size, 146 DWORD stream_size,
146 DWORD alignment) { 147 DWORD alignment) {
147 base::SharedMemory shm(bitstream_buffer.handle(), true); 148 HANDLE shared_memory_handle = NULL;
149 RETURN_ON_FAILURE(::DuplicateHandle(renderer_process,
150 bitstream_buffer.handle(),
151 base::GetCurrentProcessHandle(),
152 &shared_memory_handle,
153 0,
154 FALSE,
155 DUPLICATE_SAME_ACCESS),
156 "Duplicate handle failed", NULL);
157
158 base::SharedMemory shm(shared_memory_handle, true);
148 RETURN_ON_FAILURE(shm.Map(bitstream_buffer.size()), 159 RETURN_ON_FAILURE(shm.Map(bitstream_buffer.size()),
149 "Failed in base::SharedMemory::Map", NULL); 160 "Failed in base::SharedMemory::Map", NULL);
150 161
151 return CreateInputSample(reinterpret_cast<const uint8*>(shm.memory()), 162 return CreateInputSample(reinterpret_cast<const uint8*>(shm.memory()),
152 bitstream_buffer.size(), 163 bitstream_buffer.size(),
153 stream_size, 164 stream_size,
154 alignment); 165 alignment);
155 } 166 }
156 167
157 // Helper function to read the bitmap from the D3D surface passed in. 168 // Helper function to read the bitmap from the D3D surface passed in.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 hr = device_manager_->ResetDevice(device_, dev_manager_reset_token_); 498 hr = device_manager_->ResetDevice(device_, dev_manager_reset_token_);
488 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); 499 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false);
489 500
490 hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, &query_); 501 hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, &query_);
491 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false); 502 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false);
492 503
493 return true; 504 return true;
494 } 505 }
495 506
496 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( 507 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator(
497 media::VideoDecodeAccelerator::Client* client) 508 media::VideoDecodeAccelerator::Client* client,
509 base::ProcessHandle renderer_process)
498 : client_(client), 510 : client_(client),
499 egl_config_(NULL), 511 egl_config_(NULL),
500 state_(kUninitialized), 512 state_(kUninitialized),
501 pictures_requested_(false), 513 pictures_requested_(false),
514 renderer_process_(renderer_process),
502 last_input_buffer_id_(-1), 515 last_input_buffer_id_(-1),
503 inputs_before_decode_(0) { 516 inputs_before_decode_(0) {
504 memset(&input_stream_info_, 0, sizeof(input_stream_info_)); 517 memset(&input_stream_info_, 0, sizeof(input_stream_info_));
505 memset(&output_stream_info_, 0, sizeof(output_stream_info_)); 518 memset(&output_stream_info_, 0, sizeof(output_stream_info_));
506 } 519 }
507 520
508 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() { 521 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() {
509 client_ = NULL; 522 client_ = NULL;
510 } 523 }
511 524
(...skipping 28 matching lines...) Expand all
540 553
541 void DXVAVideoDecodeAccelerator::Decode( 554 void DXVAVideoDecodeAccelerator::Decode(
542 const media::BitstreamBuffer& bitstream_buffer) { 555 const media::BitstreamBuffer& bitstream_buffer) {
543 DCHECK(CalledOnValidThread()); 556 DCHECK(CalledOnValidThread());
544 557
545 RETURN_AND_NOTIFY_ON_FAILURE((state_ == kNormal || state_ == kStopped), 558 RETURN_AND_NOTIFY_ON_FAILURE((state_ == kNormal || state_ == kStopped),
546 "Invalid state: " << state_, ILLEGAL_STATE,); 559 "Invalid state: " << state_, ILLEGAL_STATE,);
547 560
548 base::win::ScopedComPtr<IMFSample> sample; 561 base::win::ScopedComPtr<IMFSample> sample;
549 sample.Attach(CreateSampleFromInputBuffer(bitstream_buffer, 562 sample.Attach(CreateSampleFromInputBuffer(bitstream_buffer,
563 renderer_process_,
550 input_stream_info_.cbSize, 564 input_stream_info_.cbSize,
551 input_stream_info_.cbAlignment)); 565 input_stream_info_.cbAlignment));
552 RETURN_AND_NOTIFY_ON_FAILURE(sample, "Failed to create input sample", 566 RETURN_AND_NOTIFY_ON_FAILURE(sample, "Failed to create input sample",
553 PLATFORM_FAILURE,); 567 PLATFORM_FAILURE,);
554 if (!inputs_before_decode_) { 568 if (!inputs_before_decode_) {
555 TRACE_EVENT_BEGIN_ETW("DXVAVideoDecodeAccelerator.Decoding", this, ""); 569 TRACE_EVENT_BEGIN_ETW("DXVAVideoDecodeAccelerator.Decoding", this, "");
556 } 570 }
557 inputs_before_decode_++; 571 inputs_before_decode_++;
558 572
559 RETURN_AND_NOTIFY_ON_FAILURE( 573 RETURN_AND_NOTIFY_ON_FAILURE(
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 gfx::Size(width, height)); 1032 gfx::Size(width, height));
1019 } 1033 }
1020 } 1034 }
1021 1035
1022 void DXVAVideoDecodeAccelerator::NotifyPictureReady( 1036 void DXVAVideoDecodeAccelerator::NotifyPictureReady(
1023 const media::Picture& picture) { 1037 const media::Picture& picture) {
1024 // This task could execute after the decoder has been torn down. 1038 // This task could execute after the decoder has been torn down.
1025 if (state_ != kUninitialized && client_) 1039 if (state_ != kUninitialized && client_)
1026 client_->PictureReady(picture); 1040 client_->PictureReady(picture);
1027 } 1041 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.h ('k') | content/common/gpu/media/gpu_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698