Skip to content

Commit

Permalink
remove ulog in favour of uprobe
Browse files Browse the repository at this point in the history
ulog_error(upipe->ulog) -> upipe_err(upipe)
ulog_warning(upipe->ulog) -> upipe_warn(upipe)
ulog_notice(upipe->ulog) -> upipe_notice(upipe)
ulog_debug(upipe->ulog) -> upipe_dbg(upipe)
[note that if printf-style format is passed, you must use *_va functions]
ULOG_{ERROR,WARNING,NOTICE,DEBUG} -> UPROBE_LOG_{...}
ulog_stdio -> uprobe_stdio
ulog_sub -> uprobe_pfx
  • Loading branch information
Christophe Massiot committed Feb 8, 2013
1 parent eae4ec1 commit 40c3902
Show file tree
Hide file tree
Showing 86 changed files with 2,502 additions and 1,751 deletions.
502 changes: 502 additions & 0 deletions COPYING.LGPLv2

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions README
Expand Up @@ -11,6 +11,8 @@ The API documentation is written as a mkdoc file. Install mkdoc
The latest code is available from:
http://upipe.org/

Upipe core libraries are distributed under the MIT license. The Upipe
transport stream library is distributed under the GPLv2+ license. For non-GPL
uses, please contact info@openheadend.tv.
Upipe core libraries are distributed under the MIT license. The Upipe framers
library (which contains code typically used by demuxes) is distributed
under the LGPLv2.1+ license. The Upipe transport stream library is
distributed under the GPLv2+ license. For non-GPL or non-LGPL uses, please
contact info@openheadend.tv.
45 changes: 25 additions & 20 deletions examples/udpmulticat.c
Expand Up @@ -50,9 +50,9 @@

#undef NDEBUG

#include <upipe/ulog.h>
#include <upipe/ulog_stdio.h>
#include <upipe/uprobe.h>
#include <upipe/uprobe_stdio.h>
#include <upipe/uprobe_prefix.h>
#include <upipe/uprobe_log.h>
#include <upipe/uclock.h>
#include <upipe/uclock_std.h>
Expand Down Expand Up @@ -87,7 +87,7 @@
#define UREF_POOL_DEPTH 10
#define UBUF_POOL_DEPTH 10
#define READ_SIZE 4096
#define ULOG_LEVEL ULOG_WARNING
#define UPROBE_LOG_LEVEL UPROBE_LOG_WARNING

void sig_handler(int sig)
{
Expand Down Expand Up @@ -128,7 +128,7 @@ int main(int argc, char *argv[])
const char *srcpath, *dirpath, *suffix;
uint64_t rotate = 0;
int opt;
enum ulog_level loglevel = ULOG_LEVEL;
enum uprobe_log_level loglevel = UPROBE_LOG_LEVEL;

signal (SIGINT, sig_handler);

Expand All @@ -139,7 +139,7 @@ int main(int argc, char *argv[])
rotate = strtoull(optarg, NULL, 0);
break;
case 'd':
loglevel = ULOG_DEBUG;
loglevel = UPROBE_LOG_DEBUG;
break;
default:
usage(argv[0]);
Expand All @@ -166,14 +166,16 @@ int main(int argc, char *argv[])
struct uclock *uclock = uclock_std_alloc(UCLOCK_FLAG_REALTIME);
struct uprobe uprobe;
uprobe_init(&uprobe, catch, NULL);
struct uprobe *uprobe_log = uprobe_log_alloc(&uprobe, loglevel);
struct uprobe *uprobe_stdio = uprobe_stdio_alloc(&uprobe, stdout, loglevel);
struct uprobe *uprobe_log = uprobe_log_alloc(uprobe_stdio,
UPROBE_LOG_DEBUG);

struct upipe_mgr *upipe_multicat_sink_mgr = upipe_multicat_sink_mgr_alloc();
struct upipe_mgr *upipe_fsink_mgr = upipe_fsink_mgr_alloc();

// data files (multicat sink)
struct upipe *datasink= upipe_alloc(upipe_multicat_sink_mgr, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "datasink"));
struct upipe *datasink= upipe_alloc(upipe_multicat_sink_mgr,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "datasink"));
upipe_multicat_sink_set_fsink_mgr(datasink, upipe_fsink_mgr);
upipe_set_upump_mgr(datasink, upump_mgr);
if (rotate) {
Expand All @@ -182,8 +184,8 @@ int main(int argc, char *argv[])
upipe_multicat_sink_set_path(datasink, dirpath, suffix);

// aux files (multicat sink)
struct upipe *auxsink= upipe_alloc(upipe_multicat_sink_mgr, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "auxsink"));
struct upipe *auxsink= upipe_alloc(upipe_multicat_sink_mgr,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "auxsink"));
upipe_multicat_sink_set_fsink_mgr(auxsink, upipe_fsink_mgr);
upipe_set_upump_mgr(auxsink, upump_mgr);
if (rotate) {
Expand All @@ -193,24 +195,24 @@ int main(int argc, char *argv[])

// aux block generation pipe
struct upipe_mgr *upipe_genaux_mgr = upipe_genaux_mgr_alloc();
struct upipe *genaux = upipe_alloc(upipe_genaux_mgr, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "genaux"));
struct upipe *genaux = upipe_alloc(upipe_genaux_mgr,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "genaux"));
assert(upipe_set_ubuf_mgr(genaux, ubuf_mgr));
upipe_set_output(genaux, auxsink);

// dup
struct upipe_mgr *upipe_dup_mgr = upipe_dup_mgr_alloc();
struct upipe *upipe_dup = upipe_alloc(upipe_dup_mgr, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "dup"));
upipe_set_output(upipe_alloc_output(upipe_dup, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "dupdata")), datasink);
upipe_set_output(upipe_alloc_output(upipe_dup, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "dupaux")), genaux);
struct upipe *upipe_dup = upipe_alloc(upipe_dup_mgr,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "dup"));
upipe_set_output(upipe_alloc_output(upipe_dup,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "dupdata")), datasink);
upipe_set_output(upipe_alloc_output(upipe_dup,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "dupaux")), genaux);

// udp source
struct upipe_mgr *upipe_udpsrc_mgr = upipe_udpsrc_mgr_alloc();
struct upipe *upipe_udpsrc = upipe_alloc(upipe_udpsrc_mgr, uprobe_log,
ulog_stdio_alloc(stdout, loglevel, "udp source"));
struct upipe *upipe_udpsrc = upipe_alloc(upipe_udpsrc_mgr,
uprobe_pfx_adhoc_alloc(uprobe_log, loglevel, "udp source"));
upipe_set_upump_mgr(upipe_udpsrc, upump_mgr);
upipe_set_uref_mgr(upipe_udpsrc, uref_mgr);
upipe_set_ubuf_mgr(upipe_udpsrc, ubuf_mgr);
Expand All @@ -230,6 +232,9 @@ int main(int argc, char *argv[])
upipe_mgr_release(upipe_fsink_mgr); // nop
upipe_mgr_release(upipe_multicat_sink_mgr); // nop

uprobe_log_free(uprobe_log);
uprobe_stdio_free(uprobe_stdio);

upump_mgr_release(upump_mgr);
uref_mgr_release(uref_mgr);
ubuf_mgr_release(ubuf_mgr);
Expand Down
3 changes: 0 additions & 3 deletions include/Makefile.am
Expand Up @@ -18,9 +18,6 @@ nobase_include_HEADERS = \
upipe/ufifo.h \
upipe/ulifo.h \
upipe/ulist.h \
upipe/ulog.h \
upipe/ulog_stdio.h \
upipe/ulog_sub.h \
upipe/umem.h \
upipe/umem_alloc.h \
upipe/umem_pool.h \
Expand Down
7 changes: 3 additions & 4 deletions include/upipe-modules/upipe_queue_source.h
Expand Up @@ -140,17 +140,16 @@ static inline bool upipe_qsrc_get_length(struct upipe *upipe,
*
* @param mgr management structure for queue source type
* @param uprobe structure used to raise events
* @param ulog structure used to output logs
* @param length maximum length of the queue
* @return pointer to allocated pipe, or NULL in case of failure
*/
static inline struct upipe *upipe_qsrc_alloc(struct upipe_mgr *mgr,
struct uprobe *uprobe,
struct ulog *ulog,
unsigned int length)
{
struct upipe *upipe = upipe_alloc(mgr, uprobe, ulog);
if (unlikely(upipe == NULL)) return NULL;
struct upipe *upipe = upipe_alloc(mgr, uprobe);
if (unlikely(upipe == NULL))
return NULL;
if (unlikely(!upipe_qsrc_set_max_length(upipe, length))) {
upipe_release(upipe);
return NULL;
Expand Down
11 changes: 5 additions & 6 deletions include/upipe-ts/uprobe_ts_log.h
Expand Up @@ -24,26 +24,25 @@
*/

/** @file
* @short simple probe logging all received events from ts pipes, as a
* fall-back
* @short simple probe logging all received events from ts pipes
*/

#ifndef _UPIPE_UPROBE_TS_LOG_H_
/** @hidden */
#define _UPIPE_UPROBE_TS_LOG_H_

#include <upipe/uprobe.h>
#include <upipe/ulog.h>

/** @This allocates a new uprobe log structure.
/** @This allocates a new uprobe ts log structure.
*
* @param next next probe to test if this one doesn't catch the event
* @param level level at which to log the messages
* @return pointer to uprobe, or NULL in case of error
*/
struct uprobe *uprobe_ts_log_alloc(struct uprobe *next, enum ulog_level level);
struct uprobe *uprobe_ts_log_alloc(struct uprobe *next,
enum uprobe_log_level level);

/** @This frees a uprobe log structure.
/** @This frees a uprobe ts log structure.
*
* @param uprobe uprobe structure to free
*/
Expand Down
49 changes: 28 additions & 21 deletions include/upipe/udict_dump.h
Expand Up @@ -33,87 +33,94 @@

#include <upipe/ubase.h>
#include <upipe/udict.h>
#include <upipe/ulog.h>
#include <upipe/uprobe.h>

#include <stdint.h>
#include <inttypes.h>

/** @internal @This dumps the content of a udict for debug purposes.
*
* @param udict pointer to the udict
* @param ulog printing facility
* @param uprobe pipe module printing the messages
*/
static inline void udict_dump(struct udict *udict, struct ulog *ulog)
static inline void udict_dump(struct udict *udict, struct uprobe *uprobe)
{
const char *name = NULL;
enum udict_type type;
ulog_debug(ulog, "dumping udict %p", udict);
uprobe_dbg_va(uprobe, NULL, "dumping udict %p", udict);

while (udict_iterate(udict, &name, &type) && name != NULL) {
switch (type) {
default:
ulog_debug(ulog, " - \"%s\" [unknown]", name);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [unknown]", name);
break;

case UDICT_TYPE_OPAQUE:
ulog_debug(ulog, " - \"%s\" [opaque]", name);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [opaque]", name);
break;

case UDICT_TYPE_STRING: {
const char *val;
if (likely(udict_get_string(udict, &val, name)))
ulog_debug(ulog, " - \"%s\" [string]: \"%s\"", name, val);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [string]: \"%s\"",
name, val);
else
ulog_debug(ulog, " - \"%s\" [string]: [invalid]", name);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [string]: [invalid]",
name);
break;
}

case UDICT_TYPE_VOID:
ulog_debug(ulog, " - \"%s\" [void]", name);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [void]", name);
break;

case UDICT_TYPE_BOOL: {
bool val;
if (likely(udict_get_bool(udict, &val, name)))
ulog_debug(ulog, " - \"%s\" [bool]: %s", name,
val ? "true" : "false");
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [bool]: %s", name,
val ? "true" : "false");
else
ulog_debug(ulog, " - \"%s\" [bool]: [invalid]", name);
uprobe_dbg_va(uprobe, NULL, " - \"%s\" [bool]: [invalid]",
name);
break;
}

case UDICT_TYPE_RATIONAL: {
struct urational val;
if (likely(udict_get_rational(udict, &val, name)))
ulog_debug(ulog, " - \"%s\" [rational]: %"PRId64"/%"PRIu64,
name, val.num, val.den);
uprobe_dbg_va(uprobe, NULL,
" - \"%s\" [rational]: %"PRId64"/%"PRIu64,
name, val.num, val.den);
else
ulog_debug(ulog, " - \"%s\" [rational]: [invalid]", name);
uprobe_dbg_va(uprobe, NULL,
" - \"%s\" [rational]: [invalid]", name);
break;
}

#define UDICT_DUMP_TEMPLATE(TYPE, type, ctype, ftype) \
case UDICT_TYPE_##TYPE: { \
ctype val; \
if (likely(udict_get_##type(udict, &val, name))) \
ulog_debug(ulog, " - \"%s\" [" #type "]: " ftype, name, \
val); \
uprobe_dbg_va(uprobe, NULL, \
" - \"%s\" [" #type "]: " ftype, \
name, val); \
else \
ulog_debug(ulog, " - \"%s\" [" #type "]: [invalid]", \
name); \
uprobe_dbg_va(uprobe, NULL, \
" - \"%s\" [" #type "]: [invalid]", \
name); \
break; \
}

UDICT_DUMP_TEMPLATE(SMALL_UNSIGNED, small_unsigned, uint8_t,
"%"PRIu8)
"%"PRIu8)
UDICT_DUMP_TEMPLATE(SMALL_INT, small_int, int8_t, "%"PRId8)
UDICT_DUMP_TEMPLATE(UNSIGNED, unsigned, uint64_t, "%"PRIu64)
UDICT_DUMP_TEMPLATE(INT, int, int64_t, "%"PRId64)
UDICT_DUMP_TEMPLATE(FLOAT, float, double, "%f")
#undef UDICT_DUMP_TEMPLATE
}
}
ulog_debug(ulog, "end of attributes for udict %p", udict);
uprobe_dbg_va(uprobe, NULL, "end of attributes for udict %p", udict);
}

#endif

0 comments on commit 40c3902

Please sign in to comment.