OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/gpu_video_service_host.h" | |
6 | |
7 #include "content/common/gpu/gpu_messages.h" | |
8 #include "content/renderer/gpu_video_decode_accelerator_host.h" | |
9 #include "content/renderer/render_thread.h" | |
10 #include "media/video/video_decode_accelerator.h" | |
11 | |
12 GpuVideoServiceHost::GpuVideoServiceHost() | |
13 : channel_(NULL), | |
14 next_decoder_host_id_(0) { | |
15 } | |
16 | |
17 GpuVideoServiceHost::~GpuVideoServiceHost() { | |
18 } | |
19 | |
20 void GpuVideoServiceHost::OnFilterAdded(IPC::Channel* channel) { | |
21 base::Closure on_initialized; | |
22 { | |
23 base::AutoLock auto_lock(lock_); | |
24 DCHECK(!channel_); | |
25 channel_ = channel; | |
26 on_initialized = on_initialized_; | |
27 } | |
28 if (!on_initialized.is_null()) | |
29 on_initialized.Run(); | |
30 } | |
31 | |
32 void GpuVideoServiceHost::OnFilterRemoved() { | |
33 // TODO(hclam): Implement. | |
34 } | |
35 | |
36 void GpuVideoServiceHost::OnChannelClosing() { | |
37 // TODO(hclam): Implement. | |
38 } | |
39 | |
40 bool GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { | |
41 switch (msg.type()) { | |
42 case AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed::ID: | |
43 case AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers::ID: | |
44 case AcceleratedVideoDecoderHostMsg_CreateDone::ID: | |
45 case AcceleratedVideoDecoderHostMsg_DismissPictureBuffer::ID: | |
46 case AcceleratedVideoDecoderHostMsg_PictureReady::ID: | |
47 case AcceleratedVideoDecoderHostMsg_FlushDone::ID: | |
48 case AcceleratedVideoDecoderHostMsg_AbortDone::ID: | |
49 case AcceleratedVideoDecoderHostMsg_EndOfStream::ID: | |
50 case AcceleratedVideoDecoderHostMsg_ErrorNotification::ID: | |
51 if (router_.RouteMessage(msg)) | |
52 return true; | |
53 LOG(ERROR) << "AcceleratedVideoDecoderHostMsg cannot be dispatched."; | |
54 default: | |
55 return false; | |
56 } | |
57 } | |
58 | |
59 void GpuVideoServiceHost::SetOnInitialized( | |
60 const base::Closure& on_initialized) { | |
61 IPC::Channel* channel; | |
62 { | |
63 base::AutoLock auto_lock(lock_); | |
64 DCHECK(on_initialized_.is_null()); | |
65 on_initialized_ = on_initialized; | |
66 channel = channel_; | |
67 } | |
68 if (channel) | |
69 on_initialized.Run(); | |
70 } | |
71 | |
72 GpuVideoDecoderHost* GpuVideoServiceHost::CreateVideoDecoder( | |
73 int context_route_id) { | |
74 // TODO(vrk): Delete all references to GpuVideoDecoder (deprecated). | |
75 return NULL; | |
76 } | |
77 | |
78 GpuVideoDecodeAcceleratorHost* GpuVideoServiceHost::CreateVideoAccelerator( | |
79 media::VideoDecodeAccelerator::Client* client) { | |
80 base::AutoLock auto_lock(lock_); | |
81 DCHECK(channel_); | |
82 return new GpuVideoDecodeAcceleratorHost( | |
83 &router_, channel_, next_decoder_host_id_++, client); | |
84 } | |
OLD | NEW |