const codec_profile_class_t *idclass;
AVCodec *codec;
const AVProfile *profiles;
+ int (*profile_init)(TVHCodecProfile *, htsmsg_t *conf);
SLIST_ENTRY(tvh_codec_t) link;
} TVHCodec;
/* video */
+int
+tvh_codec_profile_video_init(TVHCodecProfile *_self, htsmsg_t *conf);
+
int
tvh_codec_profile_video_get_hwaccel(TVHCodecProfile *self);
/* audio */
+int
+tvh_codec_profile_audio_init(TVHCodecProfile *_self, htsmsg_t *conf);
+
const enum AVSampleFormat *
tvh_codec_profile_audio_get_sample_fmts(TVHCodecProfile *self);
.size = sizeof(tvh_codec_profile_aac_t),
.idclass = &codec_profile_aac_class,
.profiles = aac_profiles,
+ .profile_init = tvh_codec_profile_audio_init,
.channel_layouts = aac_channel_layouts,
};
.name = "libfdk_aac",
.size = sizeof(tvh_codec_profile_libfdk_aac_t),
.idclass = &codec_profile_libfdk_aac_class,
+ .profile_init = tvh_codec_profile_audio_init,
+
};
.name = "libopus",
.size = sizeof(tvh_codec_profile_libopus_t),
.idclass = &codec_profile_libopus_class,
+ .profile_init = tvh_codec_profile_audio_init,
};
.name = "libtheora",
.size = sizeof(TVHVideoCodecProfile),
.idclass = &codec_profile_libtheora_class,
+ .profile_init = tvh_codec_profile_video_init,
};
.size = sizeof(TVHAudioCodecProfile),
.idclass = &codec_profile_libvorbis_class,
.channel_layouts = libvorbis_channel_layouts,
+ .profile_init = tvh_codec_profile_audio_init,
};
.name = "libvpx-vp9",
.size = sizeof(tvh_codec_profile_libvpx_t),
.idclass = &codec_profile_libvpx_class,
+ .profile_init = tvh_codec_profile_video_init,
};
.name = "libx265",
.size = sizeof(tvh_codec_profile_libx26x_t),
.idclass = &codec_profile_libx265_class,
+ .profile_init = tvh_codec_profile_video_init,
};
#endif
.name = "h264_omx",
.size = sizeof(tvh_codec_profile_omx_t),
.idclass = &codec_profile_omx_class,
+ .profile_init = tvh_codec_profile_video_init,
};
.size = sizeof(tvh_codec_profile_vaapi_t),
.idclass = &codec_profile_vaapi_hevc_class,
.profiles = vaapi_hevc_profiles,
+ .profile_init = tvh_codec_profile_video_init,
};
.name = "mp2",
.size = sizeof(TVHAudioCodecProfile),
.idclass = &codec_profile_mp2_class,
+ .profile_init = tvh_codec_profile_audio_init,
+
};
.name = "mpeg2video",
.size = sizeof(TVHVideoCodecProfile),
.idclass = &codec_profile_mpeg2video_class,
+ .profile_init = tvh_codec_profile_video_init,
};
.name = "vorbis",
.size = sizeof(TVHAudioCodecProfile),
.idclass = &codec_profile_vorbis_class,
+ .profile_init = tvh_codec_profile_audio_init,
.channel_layouts = vorbis_channel_layouts,
};
/* TVHCodecProfile ========================================================== */
static TVHCodecProfile *
-tvh_codec_profile_alloc(TVHCodec *codec)
+tvh_codec_profile_alloc(TVHCodec *codec, htsmsg_t *conf)
{
TVHCodecProfile *self = NULL;
if ((self = calloc(1, codec->size))) {
self->codec = codec;
+ if (codec->profile_init) {
+ if (codec->profile_init(self, conf)) {
+ free(self);
+ return NULL;
+ }
+ }
}
return self;
}
return;
if (tvh_codec_profile_find(name))
return;
- if (tvh_codec_profile_create(conf, NULL, 0))
+ if (tvh_codec_profile_create(conf, NULL, 1))
tvherror(LS_CODEC, "unable to create codec profile from config tree: '%s'",
(name = htsmsg_get_str(conf, "name")) ? name : "<unknown>");
}
tvherror(LS_CODEC, "codec '%s' not found", codec_name);
return ENOENT;
}
- if (!(profile = tvh_codec_profile_alloc(codec))) {
+ if (!(profile = tvh_codec_profile_alloc(codec, conf))) {
tvherror(LS_CODEC, "failed to allocate TVHCodecProfile");
return ENOMEM;
}
/* video */
+int
+tvh_codec_profile_video_init(TVHCodecProfile *_self, htsmsg_t *conf)
+{
+ TVHVideoCodecProfile *self = (TVHVideoCodecProfile *)_self;
+ self->pix_fmt = AV_PIX_FMT_NONE;
+ return 0;
+}
+
int
tvh_codec_profile_video_get_hwaccel(TVHCodecProfile *self)
{
/* audio */
+int
+tvh_codec_profile_audio_init(TVHCodecProfile *_self, htsmsg_t *conf)
+{
+ TVHAudioCodecProfile *self = (TVHAudioCodecProfile *)_self;
+ self->sample_fmt = AV_SAMPLE_FMT_NONE;
+ return 0;
+}
+
const enum AVSampleFormat *
tvh_codec_profile_audio_get_sample_fmts(TVHCodecProfile *self)
{