qt: playlist: use item title if available
[vlc.git] / modules / demux / adaptive / plumbing / FakeESOut.hpp
blobe173bfe9af1707c4a658b6b40780f0517401bd38
1 /*
2 * FakeESOut.hpp
3 *****************************************************************************
4 * Copyright © 2014-2015 VideoLAN and VLC Authors
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20 #ifndef FAKEESOUT_HPP
21 #define FAKEESOUT_HPP
23 #include <vlc_common.h>
24 #include <list>
26 namespace adaptive
28 class ExtraFMTInfoInterface
30 public:
31 virtual void fillExtraFMTInfo( es_format_t * ) const = 0;
32 virtual ~ExtraFMTInfoInterface() = default;
35 class CommandsQueue;
36 class CommandsFactory;
37 class AbstractFakeESOutID;
38 class FakeESOutID;
40 class AbstractFakeEsOut
42 friend class EsOutCallbacks;
43 public:
44 AbstractFakeEsOut();
45 virtual ~AbstractFakeEsOut();
46 operator es_out_t*();
47 /* Used by FakeES ID */
48 virtual void recycle( AbstractFakeESOutID * ) = 0;
49 virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) = 0;
50 virtual void setPriority(int) = 0;
51 virtual void sendData( AbstractFakeESOutID *, block_t * ) = 0;
52 virtual void sendMeta( int, const vlc_meta_t * ) = 0;
54 private:
55 void *esoutpriv;
56 virtual es_out_id_t *esOutAdd( const es_format_t * ) = 0;
57 virtual int esOutSend( es_out_id_t *, block_t * ) = 0;
58 virtual void esOutDel( es_out_id_t * ) = 0;
59 virtual int esOutControl( int, va_list ) = 0;
60 virtual void esOutDestroy() = 0;
63 class FakeESOut : public AbstractFakeEsOut
65 public:
66 class LockedFakeEsOut
68 friend class FakeESOut;
69 public:
70 ~LockedFakeEsOut();
71 operator es_out_t*();
72 FakeESOut & operator*();
73 FakeESOut * operator->();
74 private:
75 FakeESOut *p;
76 LockedFakeEsOut(FakeESOut &q);
78 FakeESOut( es_out_t *, CommandsQueue *, CommandsFactory * );
79 virtual ~FakeESOut();
80 LockedFakeEsOut WithLock();
81 CommandsQueue * commandsQueue();
82 CommandsFactory *commandsFactory() const;
83 void setAssociatedTimestamp( vlc_tick_t );
84 void setExpectedTimestamp( vlc_tick_t );
85 void resetTimestamps();
86 bool getStartTimestamps( vlc_tick_t *, vlc_tick_t * );
87 size_t esCount() const;
88 bool hasSelectedEs() const;
89 bool decodersDrained();
90 bool restarting() const;
91 void setExtraInfoProvider( ExtraFMTInfoInterface * );
92 vlc_tick_t fixTimestamp(vlc_tick_t);
93 void declareEs( const es_format_t * );
95 /* Used by FakeES ID */
96 virtual void recycle( AbstractFakeESOutID *id ) override;
97 virtual void createOrRecycleRealEsID( AbstractFakeESOutID * ) override;
98 virtual void setPriority(int) override;
99 virtual void sendData( AbstractFakeESOutID *, block_t * ) override;
100 virtual void sendMeta( int, const vlc_meta_t * ) override;
102 /**/
103 void schedulePCRReset();
104 void scheduleAllForDeletion(); /* Queue Del commands for non Del issued ones */
105 void recycleAll(); /* Cancels all commands and send fakees for recycling */
106 void gc();
108 private:
109 friend class LockedFakeESOut;
110 vlc_mutex_t lock;
111 virtual es_out_id_t *esOutAdd( const es_format_t * ) override;
112 virtual int esOutSend( es_out_id_t *, block_t * ) override;
113 virtual void esOutDel( es_out_id_t * ) override;
114 virtual int esOutControl( int, va_list ) override;
115 virtual void esOutDestroy() override;
116 es_out_t *real_es_out;
117 FakeESOutID * createNewID( const es_format_t * );
118 ExtraFMTInfoInterface *extrainfo;
119 CommandsQueue *commandsqueue;
120 CommandsFactory *commandsfactory;
121 struct
123 vlc_tick_t timestamp;
124 bool b_timestamp_set;
125 bool b_offset_calculated;
126 } associated, expected;
127 vlc_tick_t timestamp_first;
128 vlc_tick_t timestamps_offset;
129 int priority;
130 std::list<FakeESOutID *> fakeesidlist;
131 std::list<FakeESOutID *> recycle_candidates;
132 std::list<FakeESOutID *> declared;
136 #endif // FAKEESOUT_HPP