1 /*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "config.h"
17 #include "gst/gst.h"
18 #include "gst_subtitle_srt_parse.h"
19
20 typedef gboolean (*SubParserRegisterFunc)(GstPlugin *plugin);
21 typedef struct {
22 const gchar *name;
23 SubParserRegisterFunc func;
24 } SubtitleParserItem;
25
26 static SubtitleParserItem g_subtitle_parser[] = {
27 { "srt", gst_subtitle_srt_parse_register },
28 { nullptr, nullptr },
29 };
30
plugin_init(GstPlugin * plugin)31 static gboolean plugin_init(GstPlugin *plugin)
32 {
33 guint i = 0;
34 gboolean reg_parser = FALSE;
35 gboolean ret = FALSE;
36 SubtitleParserItem *item = &g_subtitle_parser[i];
37
38 while (item->name != nullptr && item->func != nullptr) {
39 reg_parser = item->func(plugin);
40 GST_INFO("subtitle: register %s parse %s", item->name, reg_parser ? "success" : "fail");
41 ret = (ret | reg_parser);
42 i++;
43 item = &g_subtitle_parser[i];
44 }
45
46 return ret;
47 }
48
49 GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR, _subtitle_parse_plugin, "GStreamer Subtitle Parser",
50 plugin_init, PACKAGE_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
51