@@ -12,9 +12,11 @@ use std::default::Default;
1212use std:: hash:: Hash ;
1313
1414use crate :: codecs:: audio:: { AudioCodecId , AudioCodecParameters , AudioDecoder , AudioDecoderOptions } ;
15+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
1516use crate :: codecs:: subtitle:: {
1617 SubtitleCodecId , SubtitleCodecParameters , SubtitleDecoder , SubtitleDecoderOptions ,
1718} ;
19+ #[ cfg( feature = "exp-video-codecs" ) ]
1820use crate :: codecs:: video:: { VideoCodecId , VideoCodecParameters , VideoDecoder , VideoDecoderOptions } ;
1921use crate :: codecs:: CodecInfo ;
2022use crate :: common:: Tier ;
@@ -42,6 +44,7 @@ pub trait RegisterableAudioDecoder: AudioDecoder {
4244}
4345
4446/// Description of a supported video codec.
47+ #[ cfg( feature = "exp-video-codecs" ) ]
4548#[ derive( Copy , Clone ) ]
4649pub struct SupportedVideoCodec {
4750 pub codec : VideoCodecId ,
@@ -50,6 +53,7 @@ pub struct SupportedVideoCodec {
5053
5154/// To support registration in a codec registry, a `VideoDecoder` must implement the
5255/// `RegisterableVideoDecoder` trait.
56+ #[ cfg( feature = "exp-video-codecs" ) ]
5357pub trait RegisterableVideoDecoder : VideoDecoder {
5458 fn try_registry_new (
5559 params : & VideoCodecParameters ,
@@ -63,6 +67,7 @@ pub trait RegisterableVideoDecoder: VideoDecoder {
6367}
6468
6569/// Description of a supported subtitle codec.
70+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
6671#[ derive( Copy , Clone ) ]
6772pub struct SupportedSubtitleCodec {
6873 pub codec : SubtitleCodecId ,
@@ -71,6 +76,7 @@ pub struct SupportedSubtitleCodec {
7176
7277/// To support registration in a codec registry, a `SubtitleDecoder` must implement the
7378/// `RegisterableSubtitleDecoder` trait.
79+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
7480pub trait RegisterableSubtitleDecoded : SubtitleDecoder {
7581 fn try_registry_new (
7682 params : & SubtitleCodecParameters ,
@@ -88,10 +94,12 @@ pub type AudioDecoderFactoryFn =
8894 fn ( & AudioCodecParameters , & AudioDecoderOptions ) -> Result < Box < dyn AudioDecoder > > ;
8995
9096/// `VideoDecoder` factory function. Creates a boxed `VideoDecoder`.
97+ #[ cfg( feature = "exp-video-codecs" ) ]
9198pub type VideoDecoderFactoryFn =
9299 fn ( & VideoCodecParameters , & VideoDecoderOptions ) -> Result < Box < dyn VideoDecoder > > ;
93100
94101/// `SubtitleDecoder` factory function. Creates a boxed `SubtitleDecoder`.
102+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
95103pub type SubtitleDecoderFactoryFn =
96104 fn ( & SubtitleCodecParameters , & SubtitleDecoderOptions ) -> Result < Box < dyn SubtitleDecoder > > ;
97105
@@ -104,6 +112,7 @@ pub struct RegisteredAudioDecoder {
104112}
105113
106114/// Registration details of a video decoder for a particular video codec.
115+ #[ cfg( feature = "exp-video-codecs" ) ]
107116pub struct RegisteredVideoDecoder {
108117 /// Video codec details.
109118 pub codec : SupportedVideoCodec ,
@@ -112,6 +121,7 @@ pub struct RegisteredVideoDecoder {
112121}
113122
114123/// Registration details of a subtitle decoder for a particular subtitle codec.
124+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
115125pub struct RegisteredSubtitleDecoder {
116126 /// Subtitle codec details.
117127 pub codec : SupportedSubtitleCodec ,
@@ -165,7 +175,9 @@ where
165175#[ derive( Default ) ]
166176pub struct CodecRegistry {
167177 audio : InnerCodecRegistry < AudioCodecId , RegisteredAudioDecoder > ,
178+ #[ cfg( feature = "exp-video-codecs" ) ]
168179 video : InnerCodecRegistry < VideoCodecId , RegisteredVideoDecoder > ,
180+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
169181 subtitle : InnerCodecRegistry < SubtitleCodecId , RegisteredSubtitleDecoder > ,
170182}
171183
@@ -174,7 +186,9 @@ impl CodecRegistry {
174186 pub fn new ( ) -> Self {
175187 CodecRegistry {
176188 audio : Default :: default ( ) ,
189+ #[ cfg( feature = "exp-video-codecs" ) ]
177190 video : Default :: default ( ) ,
191+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
178192 subtitle : Default :: default ( ) ,
179193 }
180194 }
@@ -197,12 +211,14 @@ impl CodecRegistry {
197211
198212 /// Get the registration information of the most preferred video decoder for the specified
199213 /// video codec.
214+ #[ cfg( feature = "exp-video-codecs" ) ]
200215 pub fn get_video_decoder ( & self , id : VideoCodecId ) -> Option < & RegisteredVideoDecoder > {
201216 self . video . get ( & id)
202217 }
203218
204219 /// Get the registration information of the video decoder at the specified tier for the
205220 /// specified video codec.
221+ #[ cfg( feature = "exp-video-codecs" ) ]
206222 pub fn get_video_decoder_at_tier (
207223 & self ,
208224 tier : Tier ,
@@ -213,12 +229,14 @@ impl CodecRegistry {
213229
214230 /// Get the registration information of the most preferred subtitle decoder for the specified
215231 /// subtitle codec.
232+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
216233 pub fn get_subtitle_decoder ( & self , id : SubtitleCodecId ) -> Option < & RegisteredSubtitleDecoder > {
217234 self . subtitle . get ( & id)
218235 }
219236
220237 /// Get the registration information of the subtitle decoder at the specified tier for the
221238 /// specified subtitle codec.
239+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
222240 pub fn get_subtitle_decoder_at_tier (
223241 & self ,
224242 tier : Tier ,
@@ -254,6 +272,7 @@ impl CodecRegistry {
254272 ///
255273 /// If a supported video codec was previously registered by another video decoder at the same
256274 /// tier, it will be replaced within the registry.
275+ #[ cfg( feature = "exp-video-codecs" ) ]
257276 pub fn register_video_decoder < C : RegisterableVideoDecoder > ( & mut self ) {
258277 self . register_video_decoder_at_tier :: < C > ( Tier :: Standard ) ;
259278 }
@@ -262,6 +281,7 @@ impl CodecRegistry {
262281 ///
263282 /// If a supported codec was previously registered by another video decoder at the same tier, it
264283 /// will be replaced within the registry.
284+ #[ cfg( feature = "exp-video-codecs" ) ]
265285 pub fn register_video_decoder_at_tier < C : RegisterableVideoDecoder > ( & mut self , tier : Tier ) {
266286 for codec in C :: supported_codecs ( ) {
267287 let reg = RegisteredVideoDecoder {
@@ -277,6 +297,7 @@ impl CodecRegistry {
277297 ///
278298 /// If a supported subtitle codec was previously registered by another subtitle decoder at the
279299 /// same tier, it will be replaced within the registry.
300+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
280301 pub fn register_subtitle_decoder < C : RegisterableSubtitleDecoded > ( & mut self ) {
281302 self . register_subtitle_decoder_at_tier :: < C > ( Tier :: Standard ) ;
282303 }
@@ -285,6 +306,7 @@ impl CodecRegistry {
285306 ///
286307 /// If a supported codec was previously registered by another subtitle decoder at the same tier,
287308 /// it will be replaced within the registry.
309+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
288310 pub fn register_subtitle_decoder_at_tier < C : RegisterableSubtitleDecoded > (
289311 & mut self ,
290312 tier : Tier ,
@@ -324,6 +346,7 @@ impl CodecRegistry {
324346 /// found, it will be instantiated with the provided video codec parameters and video decoder
325347 /// options. If a suitable decoder could not be found, or the decoder could not be instantiated,
326348 /// an error will be returned.
349+ #[ cfg( feature = "exp-video-codecs" ) ]
327350 pub fn make_video_decoder (
328351 & self ,
329352 params : & VideoCodecParameters ,
@@ -343,6 +366,7 @@ impl CodecRegistry {
343366 /// is found, it will be instantiated with the provided subtitle codec parameters and subtitle
344367 /// decoder options. If a suitable decoder could not be found, or the decoder could not be
345368 /// instantiated, an error will be returned.
369+ #[ cfg( feature = "exp-subtitle-codecs" ) ]
346370 pub fn make_subtitle_decoder (
347371 & self ,
348372 params : & SubtitleCodecParameters ,
0 commit comments