MLTInput.h 5.1 KB
Newer Older
luyikei's avatar
luyikei committed
1
/*****************************************************************************
luyikei's avatar
luyikei committed
2
 * MLTInput.h:  Wrapper of Mlt::Producer
luyikei's avatar
luyikei committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *****************************************************************************
 * Copyright (C) 2008-2016 VideoLAN
 *
 * Authors: Yikei Lu <luyikei.qmltu@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

luyikei's avatar
luyikei committed
23
24
#ifndef MLTINPUT_H
#define MLTINPUT_H
luyikei's avatar
luyikei committed
25

luyikei's avatar
luyikei committed
26
#include "Backend/IInput.h"
luyikei's avatar
luyikei committed
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "Backend/IProfile.h"
#include "MLTService.h"

namespace Mlt
{
class Producer;
}

namespace Backend
{
namespace MLT
{

luyikei's avatar
luyikei committed
40
class MLTInput : virtual public IInput, public MLTService
luyikei's avatar
luyikei committed
41
42
43
{
    public:

luyikei's avatar
luyikei committed
44
45
46
47
        MLTInput( Mlt::Producer* input, IInputEventCb* callback = nullptr );
        MLTInput( const char* path, IInputEventCb* callback = nullptr );
        MLTInput( IProfile& profile, const char* path, IInputEventCb* callback = nullptr );
        ~MLTInput();
luyikei's avatar
luyikei committed
48

49
50
51
52
53
54
        virtual Mlt::Producer*  producer();
        virtual Mlt::Producer*  producer() const;

        virtual Mlt::Service*   service() override;
        virtual Mlt::Service*   service() const override;

luyikei's avatar
luyikei committed
55
        static void             onPropertyChanged( void* owner, MLTInput* self, const char* id );
luyikei's avatar
luyikei committed
56

57
        virtual void            setCallback( IInputEventCb* callback ) override;
luyikei's avatar
luyikei committed
58
59
60
61
62
63
64
65

        virtual const char*     path() const override;
        virtual int64_t         begin() const override;
        virtual int64_t         end() const override;
        virtual void            setBegin( int64_t begin ) override;
        virtual void            setEnd( int64_t end ) override;
        virtual void            setBoundaries( int64_t begin, int64_t end ) override;

luyikei's avatar
luyikei committed
66
        virtual std::unique_ptr<IInput>      cut( int64_t begin = 0, int64_t end = EndOfMedia ) override;
luyikei's avatar
luyikei committed
67
68
        virtual bool            isCut() const override;

luyikei's avatar
luyikei committed
69
70
        virtual bool            sameClip( IInput& that ) const override;
        virtual bool            runsInto( IInput& that ) const override;
luyikei's avatar
luyikei committed
71
72
73
74

        // The playable (based on begin and end points) duration
        virtual int64_t         playableLength() const override;

luyikei's avatar
luyikei committed
75
        // The duration of the input regardless of begin and end points.
luyikei's avatar
luyikei committed
76
77
78
79
80
81
82
83
84
85
        virtual int64_t         length() const override;
        virtual const char*     lengthTime() const override;

        // The position in frame relative to its beginning
        virtual int64_t         position() const override;
        virtual void            setPosition( int64_t position ) override;

        // The absolete position in frame
        virtual int64_t         frame() const override;

86
87
88
89
90
91
        // Generates an 8-bit grayscale image at the current position
        virtual uint8_t*        waveform( uint32_t width, uint32_t height ) const override;

        // Generates an 32-bit RGBA image at the current position
        virtual uint8_t*        image( uint32_t width, uint32_t height ) const override;

luyikei's avatar
luyikei committed
92
        virtual double          fps() const override;
luyikei's avatar
luyikei committed
93
        virtual double          aspectRatio() const override;
luyikei's avatar
luyikei committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
        virtual int             width() const override;
        virtual int             height() const override;
        virtual bool            hasVideo() const override;
        virtual int             nbVideoTracks() const override;
        virtual bool            hasAudio() const override;
        virtual int             nbAudioTracks() const override;

        virtual void            playPause() override;
        virtual bool            isPaused() const override;
        virtual void            setPause( bool isPaused ) override;
        virtual void            nextFrame() override;
        virtual void            previousFrame() override;

        virtual bool            isBlank() const override;
luyikei's avatar
luyikei committed
108
109
110
111
112
113
114

        virtual bool            attach( IFilter& filter ) override;
        virtual bool            detach( IFilter& filter ) override;
        virtual bool            detach( int index ) override;
        virtual int             filterCount() const override;
        virtual bool            moveFilter( int from, int to ) override;
        virtual std::shared_ptr<IFilter>  filter( int index ) const override;
luyikei's avatar
luyikei committed
115
    protected:
luyikei's avatar
luyikei committed
116
        MLTInput();
luyikei's avatar
luyikei committed
117
118
119

        void                    calcTracks();

120
    private:
luyikei's avatar
luyikei committed
121
        Mlt::Producer*          m_producer;
luyikei's avatar
luyikei committed
122
        IInputEventCb*          m_callback;
luyikei's avatar
luyikei committed
123
124
125
126
127
128
129
130
131
        bool                    m_paused;

        int                     m_nbVideoTracks;
        int                     m_nbAudioTracks;
};

}
}

luyikei's avatar
luyikei committed
132
#endif // MLTINPUT_H