FakeESOut.hpp 2.92 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
/*
 * FakeESOut.hpp
 *****************************************************************************
 * Copyright © 2014-2015 VideoLAN and VLC Authors
 *
 * 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.
 *****************************************************************************/
#ifndef FAKEESOUT_HPP
#define FAKEESOUT_HPP

23 24
#include <vlc_common.h>
#include <list>
25

26
namespace adaptive
27 28 29 30 31 32 33
{
    class ExtraFMTInfoInterface
    {
        public:
            virtual void fillExtraFMTInfo( es_format_t * ) const = 0;
    };

34 35 36
    class CommandsQueue;
    class FakeESOutID;

37 38 39
    class FakeESOut
    {
        public:
40
            FakeESOut( es_out_t *, CommandsQueue * );
41 42 43 44 45
            ~FakeESOut();
            es_out_t * getEsOut();
            void setTimestampOffset( mtime_t );
            size_t esCount() const;
            bool hasSelectedEs() const;
46
            bool drain();
47 48 49 50 51
            bool restarting() const;
            void setExtraInfoProvider( ExtraFMTInfoInterface * );

            /* Used by FakeES ID */
            void recycle( FakeESOutID *id );
52
            void createOrRecycleRealEsID( FakeESOutID * );
53 54

            /**/
55 56 57
            void schedulePCRReset();
            void scheduleAllForDeletion(); /* Queue Del commands for non Del issued ones */
            void recycleAll(); /* Cancels all commands and send fakees for recycling */
58 59 60 61 62 63 64 65 66 67
            void gc();

            /* static callbacks for demuxer */
            static es_out_id_t *esOutAdd_Callback( es_out_t *, const es_format_t * );
            static int esOutSend_Callback( es_out_t *, es_out_id_t *, block_t * );
            static void esOutDel_Callback( es_out_t *, es_out_id_t * );
            static int esOutControl_Callback( es_out_t *, int, va_list );
            static void esOutDestroy_Callback( es_out_t * );

        private:
68
            vlc_mutex_t lock;
69
            es_out_t *real_es_out;
70
            FakeESOutID * createNewID( const es_format_t * );
71 72
            ExtraFMTInfoInterface *extrainfo;
            mtime_t getTimestampOffset() const;
73
            CommandsQueue *commandsqueue;
74 75 76 77 78 79 80 81
            es_out_t *fakeesout;
            mtime_t timestamps_offset;
            std::list<FakeESOutID *> fakeesidlist;
            std::list<FakeESOutID *> recycle_candidates;
    };

}
#endif // FAKEESOUT_HPP