-
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
Open
funman
wants to merge
7
commits into
Upipe:master
Choose a base branch
from
funman:pcap
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+915
−3
Open
pcap #1096
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aad6e2d
upipe_pcap_src: new pipe to read pcap files
funman d6bd135
Update examples/Build.mk
funman 9c2291d
pcap: changes suggested by Arnaud
funman d114d37
pcap: missing change
funman d5b3aec
pcap: remove dbg
funman 87686e4
pcap_src: supports setting uri to NULL
funman 589c9cf
pcap: add test
funman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,4 @@ | |
| /ts_encrypt | ||
| /dvbsrc | ||
| /frame | ||
| /pcap | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.