demux: adaptive: fix cross category es recycling
[vlc.git] / modules / demux / adaptive / plumbing / FakeESOutID.cpp
blob41b93d99047618e70759e32a61499e84fa4905f1
1 /*
2 * FakeESOutID.cpp
3 *****************************************************************************
4 * Copyright © 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 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include "FakeESOutID.hpp"
26 #include "FakeESOut.hpp"
28 using namespace adaptive;
30 FakeESOutID::FakeESOutID( FakeESOut *fakeesout, const es_format_t *p_fmt )
31 : fakeesout( fakeesout )
32 , p_real_es_id( NULL )
33 , pending_delete( false )
35 es_format_Copy( &fmt, p_fmt );
38 FakeESOutID::~FakeESOutID()
40 es_format_Clean( &fmt );
43 void FakeESOutID::setRealESID( es_out_id_t *real_es_id )
45 p_real_es_id = real_es_id;
48 void FakeESOutID::notifyData()
50 fakeesout->gc();
53 void FakeESOutID::create()
55 fakeesout->createOrRecycleRealEsID( this );
58 void FakeESOutID::release()
60 fakeesout->recycle( this );
63 es_out_id_t * FakeESOutID::realESID()
65 return p_real_es_id;
68 const es_format_t *FakeESOutID::getFmt() const
70 return &fmt;
73 bool FakeESOutID::isCompatible( const FakeESOutID *p_other ) const
75 if( p_other->fmt.i_cat != fmt.i_cat )
76 return false;
78 switch(fmt.i_codec)
80 case VLC_CODEC_H264:
81 case VLC_CODEC_HEVC:
82 case VLC_CODEC_VC1:
83 return true;
85 default:
86 if(fmt.i_cat == AUDIO_ES)
88 /* Reject audio streams with different or unknown rates */
89 if(fmt.audio.i_rate != p_other->fmt.audio.i_rate || !fmt.audio.i_rate)
90 return false;
93 return es_format_IsSimilar( &p_other->fmt, &fmt ) &&
94 !p_other->fmt.i_extra && !fmt.i_extra;
98 void FakeESOutID::setScheduledForDeletion()
100 pending_delete = true;
103 bool FakeESOutID::scheduledForDeletion() const
105 return pending_delete;