[Confluence] align subtitle popup to the bottom
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDCodecs / Video / StageFrightVideoPrivate.h
1 #pragma once
2 /*
3  *      Copyright (C) 2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21 /***************************************************************************/
22
23 #include "threads/Thread.h"
24 #include "xbmc/guilib/FrameBufferObject.h"
25 #include "cores/VideoRenderers/RenderFormats.h"
26
27 #include <android/native_window.h>
28 #include <android/native_window_jni.h>
29
30 #include <media/stagefright/MetaData.h>
31 #include <media/stagefright/MediaBuffer.h>
32 #include <media/stagefright/MediaBufferGroup.h>
33 #include <media/stagefright/MediaDefs.h>
34 #include <media/stagefright/MediaSource.h>
35
36 #include <binder/ProcessState.h>
37 #include <media/stagefright/OMXClient.h>
38 #include <media/stagefright/OMXCodec.h>
39 #include <media/stagefright/foundation/ABuffer.h>
40 #include <utils/List.h>
41 #include <utils/RefBase.h>
42 #include <ui/GraphicBuffer.h>
43 #include <ui/PixelFormat.h>
44 #include <gui/SurfaceTexture.h>
45
46 #include "system_gl.h"
47
48 #include <map>
49 #include <list>
50
51 #define NUMFBOTEX 4
52 #define INBUFCOUNT 16
53
54 class CStageFrightDecodeThread;
55 class CJNISurface;
56 class CJNISurfaceTexture;
57
58 using namespace android;
59
60 struct tex_slot
61 {
62   GLuint texid;
63   EGLImageKHR eglimg;
64 };
65
66 struct Frame
67 {
68   status_t status;
69   int32_t width, height;
70   int64_t pts;
71   ERenderFormat format;
72   EGLImageKHR eglimg;
73   MediaBuffer* medbuf;
74 };
75
76 enum StageFrightQuirks
77 {
78   QuirkNone = 0,
79   QuirkSWRender = 0x01,
80 };
81
82 class CStageFrightVideoPrivate : public MediaBufferObserver
83 {
84 public:
85   CStageFrightVideoPrivate();
86
87   virtual void signalBufferReturned(MediaBuffer *buffer);
88
89   MediaBuffer* getBuffer(size_t size);
90   bool inputBufferAvailable();
91
92   void loadOESShader(GLenum shaderType, const char* pSource, GLuint* outShader);
93   void createOESProgram(const char* pVertexSource, const char* pFragmentSource, GLuint* outPgm);
94   void OES_shader_setUp();
95   void InitializeEGL(int w, int h);
96   void UninitializeEGL();
97
98 public:
99   CStageFrightDecodeThread* decode_thread;
100
101   sp<MediaSource> source;
102
103   MediaBuffer* inbuf[INBUFCOUNT];
104
105   GLuint mPgm;
106   GLint mPositionHandle;
107   GLint mTexSamplerHandle;
108   GLint mTexMatrixHandle;
109
110   CFrameBufferObject fbo;
111   EGLDisplay eglDisplay;
112   EGLSurface eglSurface;
113   EGLContext eglContext;
114   bool eglInitialized;
115
116   tex_slot slots[NUMFBOTEX];
117   std::list< std::pair<EGLImageKHR, int> > free_queue;
118   std::list< std::pair<EGLImageKHR, int> > busy_queue;
119
120   sp<MetaData> meta;
121   int64_t framecount;
122   std::map<int64_t, Frame*> in_queue;
123   std::map<int64_t, Frame*> out_queue;
124   CCriticalSection in_mutex;
125   CCriticalSection out_mutex;
126   CCriticalSection free_mutex;
127   XbmcThreads::ConditionVariable in_condition;
128   XbmcThreads::ConditionVariable out_condition;
129
130   int quirks;
131   Frame *cur_frame;
132   Frame *prev_frame;
133   bool source_done;
134   int x, y;
135   int width, height;
136   int texwidth, texheight;
137
138   OMXClient *client;
139   sp<MediaSource> decoder;
140   const char *decoder_component;
141   int videoColorFormat;
142   int videoStride;
143   int videoSliceHeight;
144
145   bool drop_state;
146   bool resetting;
147 #if defined(DEBUG_VERBOSE)
148   unsigned int cycle_time;
149 #endif
150
151   unsigned int mVideoTextureId;
152   CJNISurfaceTexture* mSurfTexture;
153   CJNISurface* mSurface;
154   sp<ANativeWindow> mVideoNativeWindow;
155
156   bool InitStagefrightSurface();
157   void UninitStagefrightSurface();
158   void UpdateStagefrightTexture();
159   void GetStagefrightTransformMatrix(float* transformMatrix);
160 };