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

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

Issue 7260008: Implement proper synchronization between HW video decode IPC and CommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing compilation errors from bots. Created 9 years, 5 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) 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_service.h" 5 #include "content/common/gpu/media/gpu_video_service.h"
6 6
7 #include "content/common/gpu/gpu_channel.h" 7 #include "content/common/gpu/gpu_channel.h"
8 #include "content/common/gpu/gpu_messages.h" 8 #include "content/common/gpu/gpu_messages.h"
9 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 9 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
11 10
12 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 11 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
13 #include "content/common/gpu/media/omx_video_decode_accelerator.h" 12 #include "content/common/gpu/media/omx_video_decode_accelerator.h"
14 #include "ui/gfx/gl/gl_surface_egl.h" 13 #include "ui/gfx/gl/gl_surface_egl.h"
15 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 14 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
16 15
17 GpuVideoService::GpuVideoService() { 16 GpuVideoService::GpuVideoService() {
18 // TODO(jiesun): move this time consuming stuff out of here. 17 // TODO(jiesun): move this time consuming stuff out of here.
19 IntializeGpuVideoService(); 18 IntializeGpuVideoService();
20 } 19 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 51
53 bool GpuVideoService::UnintializeGpuVideoService() { 52 bool GpuVideoService::UnintializeGpuVideoService() {
54 return true; 53 return true;
55 } 54 }
56 55
57 bool GpuVideoService::CreateVideoDecoder( 56 bool GpuVideoService::CreateVideoDecoder(
58 GpuChannel* channel, 57 GpuChannel* channel,
59 MessageRouter* router, 58 MessageRouter* router,
60 int32 decoder_host_id, 59 int32 decoder_host_id,
61 int32 decoder_id, 60 int32 decoder_id,
62 gpu::gles2::GLES2Decoder* command_decoder, 61 GpuCommandBufferStub* stub,
63 const std::vector<uint32>& configs) { 62 const std::vector<uint32>& configs) {
64 // Create GpuVideoDecodeAccelerator and add to map. 63 // Create GpuVideoDecodeAccelerator and add to map.
65 scoped_refptr<GpuVideoDecodeAccelerator> decoder = 64 scoped_refptr<GpuVideoDecodeAccelerator> decoder =
66 new GpuVideoDecodeAccelerator(channel, decoder_host_id); 65 new GpuVideoDecodeAccelerator(channel, decoder_host_id, decoder_id, stub);
67
68 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
69 OmxVideoDecodeAccelerator* omx_decoder =
70 new OmxVideoDecodeAccelerator(decoder, MessageLoop::current());
71 omx_decoder->SetEglState(gfx::GLSurfaceEGL::GetDisplay(),
72 command_decoder->GetGLContext()->GetHandle());
73 decoder->set_video_decode_accelerator(omx_decoder);
74 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
75 66
76 bool result = decoder_map_.insert(std::make_pair( 67 bool result = decoder_map_.insert(std::make_pair(
77 decoder_id, VideoDecoderInfo(decoder, command_decoder))).second; 68 decoder_id, VideoDecoderInfo(decoder, stub))).second;
78 69
79 // Decoder ID is a unique ID determined by GpuVideoServiceHost. 70 // Decoder ID is a unique ID determined by GpuVideoServiceHost.
80 // We should always be adding entries here. 71 // We should always be adding entries here.
81 DCHECK(result); 72 DCHECK(result);
82 73
83 router->AddRoute(decoder_id, decoder); 74 router->AddRoute(decoder_id, decoder);
84 75
85 // Tell client that initialization is complete. 76 // Tell client that initialization is complete.
86 channel->Send( 77 channel->Send(
87 new AcceleratedVideoDecoderHostMsg_CreateDone( 78 new AcceleratedVideoDecoderHostMsg_CreateDone(
88 decoder_host_id, decoder_id)); 79 decoder_host_id, decoder_id));
89 80
90 return true; 81 return true;
91 } 82 }
92 83
84 void GpuVideoService::InitializeVideoDecoder(int32 decoder_id) {
85 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
86 DecoderMap::iterator it = decoder_map_.find(decoder_id);
87 DCHECK(it != decoder_map_.end());
88 GpuVideoDecodeAccelerator* decoder = it->second.video_decoder.get();
89 GpuCommandBufferStub* stub = it->second.stub;
90 DCHECK(stub->scheduler());
91 OmxVideoDecodeAccelerator* omx_decoder =
92 new OmxVideoDecodeAccelerator(decoder, MessageLoop::current());
93 omx_decoder->SetEglState(
94 gfx::GLSurfaceEGL::GetDisplay(),
95 stub->scheduler()->decoder()->GetGLContext()->GetHandle());
96 decoder->set_video_decode_accelerator(omx_decoder);
97 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
scherkus (not reviewing) 2011/06/27 22:54:47 #else NOTIMPLEMENTED() ???
Ami GONE FROM CHROMIUM 2011/06/28 00:06:35 nice.
98 }
99
93 void GpuVideoService::DestroyVideoDecoder( 100 void GpuVideoService::DestroyVideoDecoder(
94 MessageRouter* router, 101 MessageRouter* router,
95 int32 decoder_id) { 102 int32 decoder_id) {
96 router->RemoveRoute(decoder_id); 103 router->RemoveRoute(decoder_id);
97 decoder_map_.erase(decoder_id); 104 decoder_map_.erase(decoder_id);
98 } 105 }
99 106
100 void GpuVideoService::AssignTexturesToDecoder( 107 void GpuVideoService::AssignTexturesToDecoder(
101 int32 decoder_id, 108 int32 decoder_id,
102 const std::vector<int32>& buffer_ids, 109 const std::vector<int32>& buffer_ids,
103 const std::vector<uint32>& texture_ids, 110 const std::vector<uint32>& texture_ids,
104 const std::vector<gfx::Size>& sizes) { 111 const std::vector<gfx::Size>& sizes) {
105 DecoderMap::iterator it = decoder_map_.find(decoder_id); 112 DecoderMap::iterator it = decoder_map_.find(decoder_id);
106 DCHECK(it != decoder_map_.end()); 113 DCHECK(it != decoder_map_.end());
107 DCHECK_EQ(it->first, decoder_id); 114 DCHECK_EQ(it->first, decoder_id);
108 GpuVideoDecodeAccelerator* video_decoder = it->second.video_decoder; 115 GpuVideoDecodeAccelerator* video_decoder = it->second.video_decoder;
109 gpu::gles2::GLES2Decoder* command_decoder = it->second.command_decoder; 116 DCHECK(it->second.stub->scheduler()); // Ensure already Initialize()'d.
117 gpu::gles2::GLES2Decoder* command_decoder =
118 it->second.stub->scheduler()->decoder();
110 119
111 std::vector<media::GLESBuffer> buffers; 120 std::vector<media::GLESBuffer> buffers;
112 for (uint32 i = 0; i < buffer_ids.size(); ++i) { 121 for (uint32 i = 0; i < buffer_ids.size(); ++i) {
113 uint32 service_texture_id; 122 uint32 service_texture_id;
114 if (!command_decoder->GetServiceTextureId( 123 if (!command_decoder->GetServiceTextureId(
115 texture_ids[i], &service_texture_id)) { 124 texture_ids[i], &service_texture_id)) {
116 // TODO(vrk): Send an error for invalid GLES buffers. 125 // TODO(vrk): Send an error for invalid GLES buffers.
117 LOG(DFATAL) << "Failed to translate texture!"; 126 LOG(DFATAL) << "Failed to translate texture!";
118 return; 127 return;
119 } 128 }
120 buffers.push_back(media::GLESBuffer( 129 buffers.push_back(media::GLESBuffer(
121 buffer_ids[i], sizes[i], service_texture_id)); 130 buffer_ids[i], sizes[i], service_texture_id));
122 } 131 }
123 video_decoder->AssignGLESBuffers(buffers); 132 video_decoder->AssignGLESBuffers(buffers);
124 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698