~ubuntu-branches/ubuntu/trusty/libavg/trusty-proposed

« back to all changes in this revision

Viewing changes to src/player/Player.h

  • Committer: Package Import Robot
  • Author(s): OXullo Intersecans
  • Date: 2011-12-06 22:44:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20111206224456-qc7250z3ya1vi8s9
Tags: 1.7.0-0ubuntu1
* New upstream release (LP: #899183)
* Remove patches 0002-libav-0.7.patch, 0003-fglrx-segfault-on-startup.patch
  now merged to upstream
* Remove unnecessary .la files
* Update debian/watch file
* Fix debian/copyright dep-5 compliancy
* Update standards to version 3.9.2
* Add man pages for avg_checktouch, avg_checkvsync, avg_showsvg
* Minor debian/rules enhancement
* Add librsvg2-dev, libgdk-pixbuf2.0-dev to Build-Depends
* Proper transition to dh_python2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
//  libavg - Media Playback Engine. 
3
 
//  Copyright (C) 2003-2008 Ulrich von Zadow
 
3
//  Copyright (C) 2003-2011 Ulrich von Zadow
4
4
//
5
5
//  This library is free software; you can redistribute it and/or
6
6
//  modify it under the terms of the GNU Lesser General Public
24
24
 
25
25
#include "../api.h"
26
26
#include "Timeout.h"
27
 
#include "DisplayEngine.h"
28
27
#include "NodeRegistry.h"
29
 
#include "MouseEvent.h"
30
28
#include "DisplayParams.h"
31
 
#include "GLConfig.h"
32
 
#include "IEventSink.h"
33
 
#include "EventDispatcher.h"
34
 
#include "KeyEvent.h"
35
 
#include "MouseEvent.h"
36
29
#include "CursorState.h"
37
 
#include "MouseState.h"
 
30
#include "TestHelper.h"
 
31
#include "BoostPython.h"
38
32
 
39
33
#include "../audio/AudioParams.h"
 
34
#include "../graphics/GLConfig.h"
40
35
 
41
36
#include <libxml/parser.h>
 
37
#include <boost/shared_ptr.hpp>
42
38
 
43
39
#include <string>
44
40
#include <vector>
 
41
#include <set>
45
42
 
46
43
namespace avg {
47
44
 
48
45
class AudioEngine;
49
46
class Node;
50
 
class VisibleNode;
51
 
class TestHelper;
52
47
class Canvas;
53
48
class MainCanvas;
54
49
class OffscreenCanvas;
55
 
class TrackerEventSource;
56
 
class MultitouchEventSource;
 
50
class TrackerInputDevice;
 
51
class MultitouchInputDevice;
57
52
class IFrameEndListener;
58
53
class IPlaybackEndListener;
59
54
class IPreRenderListener;
 
55
class Contact;
 
56
class EventDispatcher;
 
57
class MouseEvent;
 
58
class CursorEvent;
 
59
class SDLDisplayEngine;
60
60
 
61
61
typedef boost::shared_ptr<Node> NodePtr;
62
62
typedef boost::weak_ptr<Node> NodeWeakPtr;
63
 
typedef boost::shared_ptr<VisibleNode> VisibleNodePtr;
64
 
typedef boost::weak_ptr<VisibleNode> VisibleNodeWeakPtr;
65
63
typedef boost::shared_ptr<Canvas> CanvasPtr;
66
64
typedef boost::shared_ptr<MainCanvas> MainCanvasPtr;
67
65
typedef boost::shared_ptr<OffscreenCanvas> OffscreenCanvasPtr;
 
66
typedef boost::shared_ptr<class Contact> ContactPtr;
 
67
typedef boost::shared_ptr<EventDispatcher> EventDispatcherPtr;
 
68
typedef boost::shared_ptr<MouseEvent> MouseEventPtr;
 
69
typedef boost::shared_ptr<CursorEvent> CursorEventPtr;
 
70
typedef boost::shared_ptr<SDLDisplayEngine> SDLDisplayEnginePtr;
68
71
 
69
 
class AVG_API Player: IEventSink
 
72
class AVG_API Player
70
73
{
71
74
    public:
72
75
        Player();
76
79
 
77
80
        void setResolution(bool bFullscreen,
78
81
                int width=0, int height=0, int bpp=0);
 
82
        bool isFullscreen();
79
83
        void setWindowFrame(bool bHasWindowFrame);
80
84
        void setWindowPos(int x=0, int y=0);
81
85
        void setOGLOptions(bool bUsePOTTextures, bool bUseShaders, 
82
86
                bool bUsePixelBuffers, int multiSampleSamples);
83
87
        void setMultiSampleSamples(int multiSampleSamples);
84
 
        void enableAudio(bool bEnable);
85
88
        void setAudioOptions(int samplerate, int channels);
86
89
        DPoint getScreenResolution();
 
90
        double getPixelsPerMM();
 
91
        DPoint getPhysicalScreenDimensions();
 
92
        void assumePixelsPerMM(double ppmm);
87
93
 
88
94
        CanvasPtr loadFile(const std::string& sFilename);
89
95
        CanvasPtr loadString(const std::string& sAVG);
90
96
 
91
97
        OffscreenCanvasPtr loadCanvasFile(const std::string& sFilename);
92
98
        OffscreenCanvasPtr loadCanvasString(const std::string& sAVG);
 
99
        CanvasPtr createMainCanvas(const boost::python::dict& params);
 
100
        OffscreenCanvasPtr createCanvas(const boost::python::dict& params);
93
101
        void deleteCanvas(const std::string& sID);
94
102
        CanvasPtr getMainCanvas() const;
95
103
        OffscreenCanvasPtr getCanvas(const std::string& sID) const;
119
127
        int setOnFrameHandler(PyObject * pyfunc);
120
128
        bool clearInterval(int id);
121
129
 
122
 
        void addEventSource(IEventSource* pSource);
 
130
        void addInputDevice(IInputDevicePtr pSource);
123
131
        MouseEventPtr getMouseState() const;
124
 
        TrackerEventSource * addTracker();
125
 
        TrackerEventSource * getTracker();
 
132
        TrackerInputDevice * addTracker();
 
133
        TrackerInputDevice * getTracker();
126
134
        void enableMultitouch();
127
135
        bool isMultitouchAvailable() const;
128
 
        void setEventCapture(VisibleNodePtr pNode, int cursorID);
 
136
        void setEventCapture(NodePtr pNode, int cursorID);
129
137
        void releaseEventCapture(int cursorID);
130
 
 
 
138
        bool isCaptured(int cursorID);
131
139
        EventPtr getCurEvent() const;
132
140
        void setMousePos(const IntPoint& pos);
133
141
        int getKeyModifierState() const;
 
142
 
134
143
        BitmapPtr screenshot();
135
144
        void setCursor(const Bitmap* pBmp, IntPoint hotSpot);
136
145
        void showCursor(bool bShow);
137
146
 
138
 
        VisibleNodePtr getElementByID(const std::string& id);
 
147
        NodePtr getElementByID(const std::string& id);
139
148
        AVGNodePtr getRootNode();
140
149
        void doFrame(bool bFirstFrame);
141
150
        double getFramerate();
142
151
        double getVideoRefreshRate();
143
152
        bool isUsingShaders();
144
153
        void setGamma(double red, double green, double blue);
145
 
        DisplayEngine * getDisplayEngine() const;
 
154
        SDLDisplayEngine * getDisplayEngine() const;
146
155
        void setStopOnEscape(bool bStop);
147
156
        bool getStopOnEscape() const;
148
157
        void setVolume(double volume);
155
164
        const NodeDefinition& getNodeDef(const std::string& sType);
156
165
 
157
166
        void disablePython();
158
 
        bool isAudioEnabled() const;
159
167
 
160
 
        void loadPlugin(const std::string& name);
 
168
        boost::python::object loadPlugin(const std::string& name);
161
169
        void setPluginPath(const std::string& newPath);
162
170
        std::string getPluginPath() const;
163
171
        
171
179
        void registerPreRenderListener(IPreRenderListener* pListener);
172
180
        void unregisterPreRenderListener(IPreRenderListener* pListener);
173
181
 
174
 
        virtual bool handleEvent(EventPtr pEvent);
175
 
        
 
182
        bool handleEvent(EventPtr pEvent);
 
183
 
176
184
    private:
177
185
        void initConfig();
178
186
        void initGraphics();
183
191
        NodePtr loadMainNodeFromFile(const std::string& sFilename);
184
192
        NodePtr loadMainNodeFromString(const std::string& sAVG);
185
193
        NodePtr internalLoad(const std::string& sAVG);
 
194
        SDLDisplayEnginePtr safeGetDisplayEngine();
186
195
 
187
196
        NodePtr createNodeFromXml(const xmlDocPtr xmlDoc,
188
197
                const xmlNodePtr xmlNode);
191
200
        void endFrame();
192
201
 
193
202
        void sendFakeEvents();
194
 
        void sendOver(CursorEventPtr pOtherEvent, Event::Type type, VisibleNodePtr pNode);
 
203
        void sendOver(CursorEventPtr pOtherEvent, Event::Type type, NodePtr pNode);
195
204
        void handleCursorEvent(CursorEventPtr pEvent, bool bOnlyCheckCursorOver=false);
196
205
 
197
206
        void dispatchOffscreenRendering(OffscreenCanvas* pOffscreenCanvas);
200
209
 
201
210
        MainCanvasPtr m_pMainCanvas;
202
211
 
203
 
        DisplayEngine * m_pDisplayEngine;
204
 
        AudioEngine * m_pAudioEngine;
205
 
        TestHelper * m_pTestHelper;
 
212
        SDLDisplayEnginePtr m_pDisplayEngine;
 
213
        TestHelperPtr m_pTestHelper;
206
214
       
207
 
        bool m_bAudioEnabled;
208
215
        std::string m_CurDirName;
209
216
        bool m_bStopping;
210
217
        NodeRegistry m_NodeRegistry;
211
218
 
212
 
        IEventSource* m_pMultitouchEventSource;
 
219
        IInputDevicePtr m_pMultitouchInputDevice;
213
220
 
214
221
        int addTimeout(Timeout* pTimeout);
215
222
        void removeTimeout(Timeout* pTimeout);
249
256
        
250
257
        EventDispatcherPtr m_pEventDispatcher;
251
258
        struct EventCaptureInfo {
252
 
            EventCaptureInfo(const VisibleNodeWeakPtr& pNode);
 
259
            EventCaptureInfo(const NodeWeakPtr& pNode);
253
260
 
254
 
            VisibleNodeWeakPtr m_pNode;
 
261
            NodeWeakPtr m_pNode;
255
262
            int m_CaptureCount;
256
263
        };
257
264
        typedef boost::shared_ptr<EventCaptureInfo> EventCaptureInfoPtr;
258
265
        
259
266
        std::map<int, EventCaptureInfoPtr> m_EventCaptureInfoMap;
260
 
        
261
 
        MouseState m_MouseState;
262
 
 
263
 
        // These are maps for each cursor id.
 
267
 
 
268
        MouseEventPtr m_pLastMouseEvent;
 
269
 
 
270
        // The indexes of this map are cursorids.
264
271
        std::map<int, CursorStatePtr> m_pLastCursorStates;
 
272
 
265
273
        PyObject * m_EventHookPyFunc;
266
274
};
267
275