| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ | 6 #define CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <queue> | 11 #include <queue> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "gpu/command_buffer/common/mailbox.h" | 17 #include "gpu/command_buffer/common/mailbox.h" |
| 18 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
| 19 #include "media/video/video_decode_accelerator.h" | 19 #include "media/video/video_decode_accelerator.h" |
| 20 | |
| 21 #include "ppapi/c/pp_codecs.h" | 20 #include "ppapi/c/pp_codecs.h" |
| 22 | 21 |
| 23 namespace base { | 22 namespace base { |
| 24 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace cc_blink { | 26 namespace cc_blink { |
| 28 class ContextProviderWebContext; | 27 class ContextProviderWebContext; |
| 29 } | 28 } |
| 30 | 29 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 RESETTING, | 68 RESETTING, |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 struct PendingDecode; | 71 struct PendingDecode; |
| 73 struct PendingFrame; | 72 struct PendingFrame; |
| 74 class DecoderImpl; | 73 class DecoderImpl; |
| 75 class YUVConverter; | 74 class YUVConverter; |
| 76 | 75 |
| 77 void OnInitializeFailed(); | 76 void OnInitializeFailed(); |
| 78 void OnDecodeComplete(int32_t result, uint32_t decode_id); | 77 void OnDecodeComplete(int32_t result, uint32_t decode_id); |
| 79 void OnOutputComplete(scoped_ptr<PendingFrame> frame); | 78 void OnOutputComplete(std::unique_ptr<PendingFrame> frame); |
| 80 void SendPictures(); | 79 void SendPictures(); |
| 81 void OnResetComplete(); | 80 void OnResetComplete(); |
| 82 void NotifyCompletedDecodes(); | 81 void NotifyCompletedDecodes(); |
| 83 void DismissTexture(uint32_t texture_id); | 82 void DismissTexture(uint32_t texture_id); |
| 84 void DeleteTexture(uint32_t texture_id); | 83 void DeleteTexture(uint32_t texture_id); |
| 85 // Call this whenever we change GL state that the plugin relies on, such as | 84 // Call this whenever we change GL state that the plugin relies on, such as |
| 86 // creating picture textures. | 85 // creating picture textures. |
| 87 void FlushCommandBuffer(); | 86 void FlushCommandBuffer(); |
| 88 | 87 |
| 89 scoped_ptr<DecoderImpl> decoder_impl_; | 88 std::unique_ptr<DecoderImpl> decoder_impl_; |
| 90 State state_; | 89 State state_; |
| 91 | 90 |
| 92 PepperVideoDecoderHost* host_; | 91 PepperVideoDecoderHost* host_; |
| 93 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 92 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 94 scoped_refptr<cc_blink::ContextProviderWebContext> context_provider_; | 93 scoped_refptr<cc_blink::ContextProviderWebContext> context_provider_; |
| 95 | 94 |
| 96 // The current decoded frame size. | 95 // The current decoded frame size. |
| 97 gfx::Size texture_size_; | 96 gfx::Size texture_size_; |
| 98 // Map that takes the plugin's GL texture id to the renderer's GL texture id. | 97 // Map that takes the plugin's GL texture id to the renderer's GL texture id. |
| 99 typedef base::hash_map<uint32_t, uint32_t> TextureIdMap; | 98 typedef base::hash_map<uint32_t, uint32_t> TextureIdMap; |
| 100 TextureIdMap texture_id_map_; | 99 TextureIdMap texture_id_map_; |
| 101 // Available textures (these are plugin ids.) | 100 // Available textures (these are plugin ids.) |
| 102 typedef base::hash_set<uint32_t> TextureIdSet; | 101 typedef base::hash_set<uint32_t> TextureIdSet; |
| 103 TextureIdSet available_textures_; | 102 TextureIdSet available_textures_; |
| 104 // Track textures that are no longer needed (these are plugin ids.) | 103 // Track textures that are no longer needed (these are plugin ids.) |
| 105 TextureIdSet textures_to_dismiss_; | 104 TextureIdSet textures_to_dismiss_; |
| 106 // Mailboxes for pending texture requests, to write to plugin's textures. | 105 // Mailboxes for pending texture requests, to write to plugin's textures. |
| 107 std::vector<gpu::Mailbox> pending_texture_mailboxes_; | 106 std::vector<gpu::Mailbox> pending_texture_mailboxes_; |
| 108 | 107 |
| 109 // Queue of completed decode ids, for notifying the host. | 108 // Queue of completed decode ids, for notifying the host. |
| 110 typedef std::queue<uint32_t> CompletedDecodeQueue; | 109 typedef std::queue<uint32_t> CompletedDecodeQueue; |
| 111 CompletedDecodeQueue completed_decodes_; | 110 CompletedDecodeQueue completed_decodes_; |
| 112 | 111 |
| 113 // Queue of decoded frames that await rgb->yuv conversion. | 112 // Queue of decoded frames that await rgb->yuv conversion. |
| 114 typedef std::queue<scoped_ptr<PendingFrame>> PendingFrameQueue; | 113 typedef std::queue<std::unique_ptr<PendingFrame>> PendingFrameQueue; |
| 115 PendingFrameQueue pending_frames_; | 114 PendingFrameQueue pending_frames_; |
| 116 | 115 |
| 117 // The optimal number of textures to allocate for decoder_impl_. | 116 // The optimal number of textures to allocate for decoder_impl_. |
| 118 uint32_t texture_pool_size_; | 117 uint32_t texture_pool_size_; |
| 119 | 118 |
| 120 uint32_t num_pending_decodes_; | 119 uint32_t num_pending_decodes_; |
| 121 | 120 |
| 122 scoped_ptr<YUVConverter> yuv_converter_; | 121 std::unique_ptr<YUVConverter> yuv_converter_; |
| 123 | 122 |
| 124 base::WeakPtrFactory<VideoDecoderShim> weak_ptr_factory_; | 123 base::WeakPtrFactory<VideoDecoderShim> weak_ptr_factory_; |
| 125 | 124 |
| 126 DISALLOW_COPY_AND_ASSIGN(VideoDecoderShim); | 125 DISALLOW_COPY_AND_ASSIGN(VideoDecoderShim); |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 } // namespace content | 128 } // namespace content |
| 130 | 129 |
| 131 #endif // CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ | 130 #endif // CONTENT_RENDERER_PEPPER_VIDEO_DECODER_SHIM_H_ |
| OLD | NEW |