EventManagerCX.hpp 4.55 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*****************************************************************************
* MediaCX.hpp: Media API
*****************************************************************************
* Copyright  2014 the VideoLAN team
*
* Authors: Hugo Beauze-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*****************************************************************************/

#include "EventManager.hpp"
#include "Media.hpp"
25
#include "StructuresCX.hpp"
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

#include <memory>

namespace libVLCX
{
    ref class Media;

    public delegate void MediaChanged(Media^);
    public delegate void NothingSpecial();
    public delegate void Opening();
    public delegate void Buffering(float);
    public delegate void Playing();
    public delegate void Paused();
    public delegate void Stopped();
    public delegate void Forward();
    public delegate void Backward();
    public delegate void EndReached();
    public delegate void EncounteredError();
    public delegate void TimeChanged(libvlc_time_t);
    public delegate void PositionChanged(float);
    public delegate void SeekableChanged(bool);
    public delegate void PausableChanged(bool);
    public delegate void TitleChanged(int);
    public delegate void SnapshotTaken(Platform::String^);
    public delegate void LengthChanged(libvlc_time_t);
    public delegate void Vout(int);
    public delegate void ScrambledChanged(int);
53 54 55
    public delegate void ESAdded(TrackType, int);
    public delegate void ESDeleted(TrackType, int);
    public delegate void ESSelected(TrackType, int);
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

    ref class EventManager;

    class MediaPlayerEventCb : public VLC::IMediaPlayerEventCb
    {
    public:
        MediaPlayerEventCb(EventManager^ em);
        virtual void mediaChanged(const VLC::Media&);
        virtual void nothingSpecial();
        virtual void opening();
        virtual void buffering(float);
        virtual void playing();
        virtual void paused();
        virtual void stopped();
        virtual void forward();
        virtual void backward();
        virtual void endReached();
        virtual void encounteredError();
        virtual void timeChanged(libvlc_time_t);
        virtual void positionChanged(float);
        virtual void seekableChanged(bool);
        virtual void pausableChanged(bool);
        virtual void titleChanged(int);
        virtual void snapshotTaken(const std::string&);
        virtual void lengthChanged(libvlc_time_t);
        virtual void vout(int);
        virtual void scrambledChanged(int);
        virtual void eSAdded(libvlc_track_type_t, int);
        virtual void eSDeleted(libvlc_track_type_t, int);
        virtual void eSSelected(libvlc_track_type_t, int);

    private:
        EventManager^ m_em;
    };

    public ref class EventManager sealed
    {
    public:
        event MediaChanged^ OnMediaChanged;
        event Opening^ OnOpening;
        event Buffering^ OnBuffering;
        event Playing^ OnPlaying;
        event Paused^ OnPaused;
        event Stopped^ OnStopped;
        event Forward^ OnForward;
        event Backward^ OnBackward;
        event EndReached^ OnEndReached;
        event EncounteredError^ OnEncounteredError;
        event TimeChanged^ OnTimeChanged;
        event PositionChanged^ OnPositionChanged;
        event SeekableChanged^ OnSeekableChanged;
        event PausableChanged^ OnPausableChanged;
        event TitleChanged^ OnTitleChanged;
        event SnapshotTaken^ OnSnapshotTaken;
        event LengthChanged^ OnLengthChanged;
        event Vout^ OnVoutCountChanged;
        event ScrambledChanged^ OnScrambledChanged;
113 114 115
        event ESAdded^ OnTrackAdded;
        event ESDeleted^ OnTrackDeleted;
        event ESSelected^ OnTrackSelected;
116 117 118 119 120 121 122 123 124 125 126 127 128 129

    internal:
        EventManager(VLC::EventManager& em);

    private:
        ~EventManager(){}

    private:
        VLC::EventManager m_em;
        std::unique_ptr<MediaPlayerEventCb> m_cb;

        friend class MediaPlayerEventCb;
    };
}