summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.h
blob: 2f5bf860654b47a908610e18a929ef6f9a0af5c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
                    This file is part of the Opie Project

                      Copyright (c)  2002 Max Reiss <harlekin@handhelds.org>
                             Copyright (c)  2002 LJP <>
                             Copyright (c)  2002 Holger Freyther <zecke@handhelds.org>
              =.
            .=l.
     .>+-=
_;:,   .>  :=|.         This program is free software; you can
.> <`_,  > .  <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--  :           the terms of the GNU General Public
.="- .-=="i,   .._         License as published by the Free Software
- .  .-<_>   .<>         Foundation; either version 2 of the License,
  ._= =}    :          or (at your option) any later version.
  .%`+i>    _;_.
  .i_,=:_.   -<s.       This program is distributed in the hope that
  + . -:.    =       it will be useful,  but WITHOUT ANY WARRANTY;
  : ..  .:,   . . .    without even the implied warranty of
  =_    +   =;=|`    MERCHANTABILITY or FITNESS FOR A
 _.=:.    :  :=>`:     PARTICULAR PURPOSE. See the GNU
..}^=.=    =    ;      Library General Public License for more
++=  -.   .`   .:       details.
:   = ...= . :.=-
-.  .:....=;==+<;          You should have received a copy of the GNU
 -_. . .  )=. =           Library General Public License along with
  --    :-=`           this library; see the file COPYING.LIB.
                             If not, write to the Free Software Foundation,
                             Inc., 59 Temple Place - Suite 330,
                             Boston, MA 02111-1307, USA.

*/

#ifndef XINE_VIDEO_LIB_H
#define XINE_VIDEO_LIB_H

#include <xine.h>

#include "threadutil.h"

class XineVideoWidget;

namespace XINE {

    /**
     * Lib wrapps the simple interface
     * of libxine for easy every day use
     * This will become a full C++ Wrapper
     * It supports playing, pausing, info,
     * stooping, seeking.
     */
    class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread
    {
        Q_OBJECT
    public:
        enum InitializationMode { InitializeImmediately, InitializeInThread };

        Lib( InitializationMode initMode, XineVideoWidget* = 0);

        ~Lib();
        static int majorVersion();
        static int minorVersion();
        static int subVersion();


        void resize ( const QSize &s );

        int setfile(const QString& fileName);
        int play( const QString& fileName,
                  int startPos = 0,
                  int start_time = 0 );
        void stop();
        void pause( bool toggle );

        int speed() const;

        /**
         * Set the speed of the stream, if codec supports it
         * XINE_SPEED_PAUSE                   0
         * XINE_SPEED_SLOW_4                  1
         * XINE_SPEED_SLOW_2                  2
         * XINE_SPEED_NORMAL                  4
         * XINE_SPEED_FAST_2                  8
         *XINE_SPEED_FAST_4                  16
         */
        void setSpeed( int speed = XINE_SPEED_PAUSE );

        int status() const;

        int currentPosition()const;
        //in seconds
        int currentTime()const;

        int length() const;

        bool isSeekable()const;

        /**
         * Whether or not to show video output
         */
        void setShowVideo(bool video);

        /**
         * is we show video
         */
        bool isShowingVideo() const;

        /**
         *
         */
        void showVideoFullScreen( bool fullScreen );

        /**
         *
         */
        bool isVideoFullScreen() const;


        /**
         * Get the meta info (like author etc) from the stream
         * XINE_META_INFO_TITLE               0
         * XINE_META_INFO_COMMENT             1
         * XINE_META_INFO_ARTIST              2
         * XINE_META_INFO_GENRE               3
         * XINE_META_INFO_ALBUM               4
         * XINE_META_INFO_YEAR                5
         * XINE_META_INFO_VIDEOCODEC          6
         * XINE_META_INFO_AUDIOCODEC          7
         * XINE_META_INFO_SYSTEMLAYER         8
         * XINE_META_INFO_INPUT_PLUGIN        9
         */
        QString metaInfo( int number ) const;

        /**
         *
         */
        bool isScaling() const;

        /**
         * seek to a position
         */
        void seekTo( int time );

        /**
         *
         * @return is media stream has video
         */
        bool hasVideo() const;

        /**
         *
         */
        void setScaling( bool );

        /**
         * Set the Gamma value for video output
         * @param int the value between -100 and 100, 0 is original
         */
        void setGamma( int );

        /**
         * Returns the error code
         * XINE_ERROR_NONE                    0
         * XINE_ERROR_NO_INPUT_PLUGIN         1
         * XINE_ERROR_NO_DEMUXER_PLUGIN       2
         * XINE_ERROR_DEMUXER_FAILED          3
         */
        int error() const;

        void ensureInitialized();

        void setWidget( XineVideoWidget *widget );

    signals:

        void stopped();

        void initialized();

    protected:
        virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );

        virtual void run();

    private:
        void initialize();

        int m_bytes_per_pixel;
        bool m_initialized:1;
        bool m_duringInitialization:1;
        bool m_video:1;
        XineVideoWidget *m_wid;
        xine_t *m_xine;
    xine_stream_t *m_stream;
        xine_cfg_entry_t *m_config;
        xine_vo_driver_t *m_videoOutput;
        xine_ao_driver_t* m_audioOutput;
    xine_event_queue_t *m_queue;

        void handleXineEvent( const xine_event_t* t );
    void handleXineEvent( int type, int data, const char* name );
        void drawFrame( uint8_t* frame, int width, int height, int bytes );
        // C -> C++ bridge for the event system
        static void xine_event_handler( void* user_data, const xine_event_t* t);
        static void xine_display_frame( void* user_data, uint8_t* frame ,
                                        int width, int height, int bytes );
    };
};


#endif