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

Side by Side Diff: content/common/gpu/omx_video_decode_accelerator.h

Issue 7088021: OmxVideoDecodeAcceleratorTest is born! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 6 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 #ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/shared_memory.h" 19 #include "base/shared_memory.h"
20 #include "media/video/video_decode_accelerator.h" 20 #include "media/video/video_decode_accelerator.h"
21 #include "third_party/angle/include/EGL/egl.h"
21 #include "third_party/openmax/il/OMX_Component.h" 22 #include "third_party/openmax/il/OMX_Component.h"
22 #include "third_party/openmax/il/OMX_Core.h" 23 #include "third_party/openmax/il/OMX_Core.h"
23 #include "third_party/openmax/il/OMX_Video.h" 24 #include "third_party/openmax/il/OMX_Video.h"
24 25
25 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. 26 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface.
26 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { 27 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
27 public: 28 public:
28 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client, 29 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client,
29 MessageLoop* message_loop); 30 MessageLoop* message_loop);
30 virtual ~OmxVideoDecodeAccelerator(); 31 virtual ~OmxVideoDecodeAccelerator();
31 32
32 // media::VideoDecodeAccelerator implementation. 33 // media::VideoDecodeAccelerator implementation.
33 void GetConfigs(const std::vector<uint32>& requested_configs, 34 void GetConfigs(const std::vector<uint32>& requested_configs,
34 std::vector<uint32>* matched_configs) OVERRIDE; 35 std::vector<uint32>* matched_configs) OVERRIDE;
35 bool Initialize(const std::vector<uint32>& config) OVERRIDE; 36 bool Initialize(const std::vector<uint32>& config) OVERRIDE;
36 bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; 37 bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
37 virtual void AssignGLESBuffers( 38 virtual void AssignGLESBuffers(
38 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; 39 const std::vector<media::GLESBuffer>& buffers) OVERRIDE;
39 virtual void AssignSysmemBuffers( 40 virtual void AssignSysmemBuffers(
40 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; 41 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE;
41 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; 42 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
42 bool Flush() OVERRIDE; 43 bool Flush() OVERRIDE;
43 bool Abort() OVERRIDE; 44 bool Abort() OVERRIDE;
44 45
46 void SetEglState(EGLDisplay egl_display, EGLContext egl_context);
47
45 private: 48 private:
46 MessageLoop* message_loop_; 49 MessageLoop* message_loop_;
47 OMX_HANDLETYPE component_handle_; 50 OMX_HANDLETYPE component_handle_;
48 51
49 // Common initialization code for Assign{GLES,Sysmem}Buffers. 52 // Common initialization code for Assign{GLES,Sysmem}Buffers.
50 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers); 53 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers);
51 54
52 // Create the Component for OMX. Handles all OMX initialization. 55 // Create the Component for OMX. Handles all OMX initialization.
53 bool CreateComponent(); 56 bool CreateComponent();
54 // Buffer allocation/free methods for input and output buffers. 57 // Buffer allocation/free methods for input and output buffers.
55 bool AllocateInputBuffers(); 58 bool AllocateInputBuffers();
56 bool AllocateOutputBuffers(); 59 bool AllocateOutputBuffers();
57 void FreeInputBuffers(); 60 void FreeInputBuffers();
58 void FreeOutputBuffers(); 61 void FreeOutputBuffers();
59 62
60 // Methods to handle OMX state transitions. 63 // Methods to handle OMX state transitions.
61 bool TransitionToState(OMX_STATETYPE new_state); 64 bool TransitionToState(OMX_STATETYPE new_state);
62 void OnStateChangeLoadedToIdle(OMX_STATETYPE state); 65 void OnStateChangeLoadedToIdle(OMX_STATETYPE state);
63 void OnStateChangeIdleToExecuting(OMX_STATETYPE state); 66 void OnStateChangeIdleToExecuting(OMX_STATETYPE state);
64 void OnPortCommandFlush(OMX_STATETYPE state); 67 void OnPortCommandFlush(OMX_STATETYPE state);
65 void OnStateChangeExecutingToIdle(OMX_STATETYPE state); 68 void OnStateChangeExecutingToIdle(OMX_STATETYPE state);
66 void OnStateChangeIdleToLoaded(OMX_STATETYPE state); 69 void OnStateChangeIdleToLoaded(OMX_STATETYPE state);
67 // Stop the components when error is detected. 70 // Stop the components when error is detected.
68 void StopOnError(); 71 void StopOnError();
69 // Trigger the initial call to FillBuffers to start the decoding process. 72 // Trigger the initial call to FillBuffers to start the decoding process.
70 void InitialFillBuffer(); 73 void InitialFillBuffer();
71 // Methods for shutdown 74 // Methods for shutdown
72 void PauseFromExecuting(OMX_STATETYPE ignored); 75 void PauseFromExecuting(OMX_STATETYPE ignored);
73 void FlushIOPorts(); 76 void FlushIOPorts();
74 void PortFlushDone(int port); 77 void InputPortFlushDone(int port);
78 void OutputPortFlushDone(int port);
75 void FlushBegin(); 79 void FlushBegin();
76 80
77 // Determine whether we actually start decoding the bitstream. 81 // Determine whether we actually start decoding the bitstream.
78 bool CanAcceptInput(); 82 bool CanAcceptInput();
79 // Determine whether we can issue fill buffer or empty buffer 83 // Determine whether we can issue fill buffer or empty buffer
80 // to the decoder based on the current state and port state. 84 // to the decoder based on the current state and port state.
81 bool CanEmptyBuffer(); 85 bool CanEmptyBuffer();
82 bool CanFillBuffer(); 86 bool CanFillBuffer();
83 void OnPortSettingsChangedRun(int port, OMX_INDEXTYPE index); 87 void OnPortSettingsChangedRun(int port, OMX_INDEXTYPE index);
84 88
(...skipping 11 matching lines...) Expand all
96 int input_port_; 100 int input_port_;
97 int input_buffers_at_component_; 101 int input_buffers_at_component_;
98 102
99 // Following are output port related variables. 103 // Following are output port related variables.
100 int output_buffer_count_; 104 int output_buffer_count_;
101 int output_buffer_size_; 105 int output_buffer_size_;
102 int output_port_; 106 int output_port_;
103 int output_buffers_at_component_; 107 int output_buffers_at_component_;
104 108
105 bool uses_egl_image_; 109 bool uses_egl_image_;
110 // NOTE: someday there may be multiple contexts for a single decoder. But not
111 // today.
112 // TODO(fischman,vrk): handle lost contexts?
113 EGLDisplay egl_display_;
114 EGLContext egl_context_;
115
106 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. 116 // Free input OpenMAX buffers that can be used to take bitstream from demuxer.
107 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; 117 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_;
108 118
109 // For output buffer recycling cases. 119 // For output buffer recycling cases.
110 std::vector<media::BaseBuffer*> assigned_picture_buffers_; 120 std::vector<media::BaseBuffer*> assigned_picture_buffers_;
111 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture; 121 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture;
112 std::vector<OutputPicture> output_pictures_; 122 std::vector<OutputPicture> output_pictures_;
113 123
114 // To expose client callbacks from VideoDecodeAccelerator. 124 // To expose client callbacks from VideoDecodeAccelerator.
125 // NOTE: all calls to this object *MUST* be executed in message_loop_.
115 Client* client_; 126 Client* client_;
116 127
117 std::vector<uint32> texture_ids_; 128 std::vector<uint32> texture_ids_;
118 std::vector<uint32> context_ids_; 129 std::vector<uint32> context_ids_;
119 // Method to handle events 130 // Method to handle events
120 void EventHandlerCompleteTask(OMX_EVENTTYPE event, 131 void EventHandlerCompleteTask(OMX_EVENTTYPE event,
121 OMX_U32 data1, 132 OMX_U32 data1,
122 OMX_U32 data2); 133 OMX_U32 data2);
123 134
124 // Method to receive buffers from component's input port 135 // Method to receive buffers from component's input port
(...skipping 27 matching lines...) Expand all
152 OMX_PTR event_data); 163 OMX_PTR event_data);
153 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, 164 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component,
154 OMX_PTR priv_data, 165 OMX_PTR priv_data,
155 OMX_BUFFERHEADERTYPE* buffer); 166 OMX_BUFFERHEADERTYPE* buffer);
156 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, 167 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component,
157 OMX_PTR priv_data, 168 OMX_PTR priv_data,
158 OMX_BUFFERHEADERTYPE* buffer); 169 OMX_BUFFERHEADERTYPE* buffer);
159 }; 170 };
160 171
161 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ 172 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « content/common/gpu/gles2_texture_to_egl_image_translator.cc ('k') | content/common/gpu/omx_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698