• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2017, Collabora Ltd.
3  *   Author:Justin Kim <justin.kim@collabora.com>
4  * Copyright (C) <2020> The GStreamer Contributors.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "gstsrtelements.h"
27 #include <srt/srt.h>
28 
29 
30 GST_DEBUG_CATEGORY_STATIC (gst_debug_srtlib);
31 GST_DEBUG_CATEGORY (gst_debug_srtobject);
32 #define GST_CAT_DEFAULT gst_debug_srtobject
33 
34 #ifndef GST_DISABLE_GST_DEBUG
35 static void
gst_srt_log_handler(void * opaque,int level,const char * file,int line,const char * area,const char * message)36 gst_srt_log_handler (void *opaque, int level, const char *file, int line,
37     const char *area, const char *message)
38 {
39   GstDebugLevel gst_level;
40 
41   switch (level) {
42     case LOG_CRIT:
43       gst_level = GST_LEVEL_ERROR;
44       break;
45 
46     case LOG_ERR:
47       gst_level = GST_LEVEL_WARNING;
48       break;
49 
50     case LOG_WARNING:
51       gst_level = GST_LEVEL_INFO;
52       break;
53 
54     case LOG_NOTICE:
55       gst_level = GST_LEVEL_DEBUG;
56       break;
57 
58     case LOG_DEBUG:
59       gst_level = GST_LEVEL_LOG;
60       break;
61 
62     default:
63       gst_level = GST_LEVEL_FIXME;
64       break;
65   }
66 
67   if (G_UNLIKELY (gst_level <= _gst_debug_min)) {
68     gst_debug_log (gst_debug_srtlib, gst_level, file, area, line, NULL, "%s",
69         message);
70   }
71 }
72 #endif
73 
74 void
srt_element_init(GstPlugin * plugin)75 srt_element_init (GstPlugin * plugin)
76 {
77   static gsize res = FALSE;
78 
79   if (g_once_init_enter (&res)) {
80     GST_DEBUG_CATEGORY_INIT (gst_debug_srtobject, "srtobject", 0, "SRT Object");
81     GST_DEBUG_CATEGORY_INIT (gst_debug_srtlib, "srtlib", 0, "SRT Library");
82 #ifndef GST_DISABLE_GST_DEBUG
83     srt_setloghandler (NULL, gst_srt_log_handler);
84     srt_setlogflags (SRT_LOGF_DISABLE_TIME | SRT_LOGF_DISABLE_THREADNAME |
85         SRT_LOGF_DISABLE_SEVERITY | SRT_LOGF_DISABLE_EOL);
86     srt_setloglevel (LOG_DEBUG);
87 #endif
88     g_once_init_leave (&res, TRUE);
89   }
90 }
91