-
Notifications
You must be signed in to change notification settings - Fork 39
pcap #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
pcap #1096
Changes from 1 commit
aad6e2d
d6bd135
9c2291d
d114d37
d5b3aec
87686e4
589c9cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,4 @@ | |
| /ts_encrypt | ||
| /dvbsrc | ||
| /frame | ||
| /pcap | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem to do anything useful? Shouln't it use a udpsink to send the packets instead of dropping them?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it could do something, don't remember how I tested it exactly. I can remove this dummy exemple if needed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| /* | ||
| * Copyright (C) 2025 Open Broadcast Systems Ltd | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining | ||
| * a copy of this software and associated documentation files (the | ||
| * "Software"), to deal in the Software without restriction, including | ||
| * without limitation the rights to use, copy, modify, merge, publish, | ||
| * distribute, sublicense, and/or sell copies of the Software, and to | ||
| * permit persons to whom the Software is furnished to do so, subject | ||
| * to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be | ||
| * included in all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| */ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
|
|
||
| #include "upipe/uprobe.h" | ||
| #include "upipe/uprobe_stdio.h" | ||
| #include "upipe/uprobe_prefix.h" | ||
| #include "upipe/uprobe_uref_mgr.h" | ||
| #include "upipe/uprobe_uclock.h" | ||
| #include "upipe/uprobe_upump_mgr.h" | ||
| #include "upipe/uprobe_ubuf_mem.h" | ||
| #include "upipe/umem.h" | ||
| #include "upipe/uclock.h" | ||
| #include "upipe/uclock_std.h" | ||
| #include "upipe/umem_pool.h" | ||
| #include "upipe/udict.h" | ||
| #include "upipe/udict_inline.h" | ||
| #include "upipe/uref.h" | ||
| #include "upipe/uref_std.h" | ||
| #include "upipe/upipe.h" | ||
| #include "upipe/upump.h" | ||
| #include "upump-ev/upump_ev.h" | ||
| #include "upipe-pcap/upipe_pcap_src.h" | ||
| #include "upipe-modules/upipe_null.h" | ||
|
|
||
| #define UPROBE_LOG_LEVEL UPROBE_LOG_INFO | ||
| #define UMEM_POOL 512 | ||
| #define UDICT_POOL_DEPTH 500 | ||
| #define UREF_POOL_DEPTH 500 | ||
| #define UBUF_POOL_DEPTH 3000 | ||
| #define UBUF_SHARED_POOL_DEPTH 50 | ||
| #define UPUMP_POOL 10 | ||
| #define UPUMP_BLOCKER_POOL 10 | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| if (argc < 2) { | ||
| printf("Usage: %s <input>\n", argv[0]); | ||
| exit(-1); | ||
| } | ||
|
|
||
| const char *input = argv[1]; | ||
|
|
||
| /* structures managers */ | ||
| struct upump_mgr *upump_mgr = | ||
| upump_ev_mgr_alloc_default(UPUMP_POOL, UPUMP_BLOCKER_POOL); | ||
| assert(upump_mgr != NULL); | ||
| struct umem_mgr *umem_mgr = umem_pool_mgr_alloc_simple(UMEM_POOL); | ||
| struct udict_mgr *udict_mgr = | ||
| udict_inline_mgr_alloc(UDICT_POOL_DEPTH, umem_mgr, -1, -1); | ||
| struct uref_mgr *uref_mgr = | ||
| uref_std_mgr_alloc(UREF_POOL_DEPTH, udict_mgr, 0); | ||
| udict_mgr_release(udict_mgr); | ||
|
|
||
| struct uclock *uclock = uclock_std_alloc(0); | ||
|
|
||
| /* probes */ | ||
| struct uprobe *uprobe; | ||
| uprobe = uprobe_stdio_alloc(NULL, stderr, UPROBE_LOG_DEBUG); | ||
| assert(uprobe != NULL); | ||
| uprobe = uprobe_uref_mgr_alloc(uprobe, uref_mgr); | ||
| assert(uprobe != NULL); | ||
| uprobe = uprobe_upump_mgr_alloc(uprobe, upump_mgr); | ||
| assert(uprobe != NULL); | ||
| uprobe = uprobe_ubuf_mem_alloc(uprobe, umem_mgr, UBUF_POOL_DEPTH, | ||
| UBUF_SHARED_POOL_DEPTH); | ||
| assert(uprobe != NULL); | ||
| uprobe = uprobe_uclock_alloc(uprobe, uclock); | ||
| assert(uprobe != NULL); | ||
|
|
||
| uref_mgr_release(uref_mgr); | ||
| upump_mgr_release(upump_mgr); | ||
| umem_mgr_release(umem_mgr); | ||
|
|
||
| /* pipes */ | ||
|
|
||
| struct upipe_mgr *upipe_pcap_src_mgr = upipe_pcap_src_mgr_alloc(); | ||
| struct upipe *upipe_src = upipe_void_alloc(upipe_pcap_src_mgr, | ||
| uprobe_pfx_alloc(uprobe_use(uprobe), UPROBE_LOG_DEBUG, "pcap")); | ||
| upipe_mgr_release(upipe_pcap_src_mgr); | ||
|
|
||
| upipe_attach_uclock(upipe_src); | ||
|
|
||
| struct upipe_mgr *upipe_null_mgr = upipe_null_mgr_alloc(); | ||
| struct upipe *upipe = upipe_void_alloc_output(upipe_src, upipe_null_mgr, | ||
| uprobe_pfx_alloc(uprobe_use(uprobe), UPROBE_LOG_DEBUG, "null")); | ||
| upipe_mgr_release(upipe_null_mgr); | ||
| upipe_release(upipe); | ||
|
|
||
| if (!ubase_check(upipe_set_uri(upipe_src, input))) { | ||
| fprintf(stderr, "invalid input\n"); | ||
| return EXIT_FAILURE; | ||
| } | ||
|
|
||
| uprobe_release(uprobe); | ||
|
|
||
| /* main loop */ | ||
| upump_mgr_run(upump_mgr, NULL); | ||
|
|
||
| uclock_release(uclock); | ||
| upipe_release(upipe_src); | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright (C) 2025 Open Broadcast Systems Ltd | ||
| * | ||
| * Authors: Rafaël Carré | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining | ||
| * a copy of this software and associated documentation files (the | ||
| * "Software"), to deal in the Software without restriction, including | ||
| * without limitation the rights to use, copy, modify, merge, publish, | ||
| * distribute, sublicense, and/or sell copies of the Software, and to | ||
| * permit persons to whom the Software is furnished to do so, subject | ||
| * to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be | ||
| * included in all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| */ | ||
|
|
||
| /** @file | ||
| * @short Upipe module to output data from a pcap | ||
| */ | ||
|
|
||
| #ifndef _UPIPE_PCAP_UPIPE_PCAP_SRC_H_ | ||
| # define _UPIPE_PCAP_UPIPE_PCAP_SRC_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #define UPIPE_PCAP_SRC_SIGNATURE UBASE_FOURCC('p','c','a','p') | ||
|
|
||
| struct upipe_mgr *upipe_pcap_src_mgr_alloc(void); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| lib-targets = libupipe_pcap | ||
|
|
||
| libupipe_pcap-desc = pcap file source | ||
| libupipe_pcap-so-version = 1.0.0 | ||
| libupipe_pcap-includes = upipe_pcap_src.h | ||
| libupipe_pcap-src = upipe_pcap_src.c | ||
| libupipe_pcap-libs = libupipe libpcap bitstream |
Uh oh!
There was an error while loading. Please reload this page.