Libmoq 0.2.13 api refactor fix#35
Conversation
WalkthroughThis PR updates the frame data retrieval in 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/moq-source.cpp`:
- Line 791: The call to the non-existent moq_consume_frame must be replaced with
libmoq 0.2.13 API calls: call moq_consume_frame_chunk(frame_id, 0, &frame_data)
to read the first chunk (use index 0) and check its return value for errors, and
after processing call moq_consume_frame_close(frame_id) to release the frame;
update any error handling that relied on moq_consume_frame to use the chunk and
close return codes and ensure you still populate/use frame_data as before.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| // Get frame data | ||
| struct moq_frame frame_data; | ||
| if (moq_consume_frame_chunk(frame_id, 0, &frame_data) < 0) { | ||
| if (moq_consume_frame(frame_id, &frame_data) < 0) { |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for any remaining usage of moq_consume_frame_chunk
# Search for the old API function name
rg -n 'moq_consume_frame_chunk' --type=cpp --type=c --type=hRepository: moq-dev/obs
Length of output: 37
🌐 Web query:
libmoq 0.2.13 moq_consume_frame API documentation
💡 Result:
In libmoq 0.2.13, the moq_consume_frame APIs are the frame-consuming functions in the crate’s public C ABI, exposed as the following functions: 1) moq_consume_frame_chunk(uint32_t frame, uint32_t index, moq_frame *dst) - Purpose: retrieve a chunk of a frame’s payload (“Consuming: Frames” → “moq_consume_frame_chunk”). [1] 2) moq_consume_frame_close(uint32_t frame) - Purpose: close/clean up a frame consumer (“Consuming: Frames” → “moq_consume_frame_close”). [1] Related lifecycle functions you typically use around frame consumption: - moq_consume_close(uint32_t consume): close the overall consumer resource. [2] Where to find the API documentation for libmoq 0.2.13: - The libmoq 0.2.13 docs are published on docs.rs and include the C API header declarations and/or “README.md” excerpt that lists the consuming APIs including moq_consume_frame_chunk and moq_consume_frame_close. [3] - The crate itself indicates that it generates the C header moq.h during the build (“Generate the C header file at target/include/moq.h”), which is where these symbols originate in the C integration. [1] Primary sources: - libmoq v0.2.13 crate page (version/update date and build notes about generating the C header). [1] - docs.rs/libmoq 0.2.13 README source excerpt containing the “Consuming: Frames” function names. [3]
Citations:
- 1: https://crates.io/crates/libmoq
- 2: https://docs.rs/libmoq/latest/moq/
- 3: https://docs.rs/crate/libmoq/0.2.13/source/README.md
🏁 Script executed:
# Read the context around line 791 in src/moq-source.cpp
sed -n '785,800p' src/moq-source.cppRepository: moq-dev/obs
Length of output: 476
🏁 Script executed:
# Search for the definition of moq_consume_frame in the codebase
rg -n 'moq_consume_frame' --type=cpp --type=c --type=h -A 3Repository: moq-dev/obs
Length of output: 2822
🏁 Script executed:
# Find libmoq header files to verify the API
fd -e h -e hpp | xargs grep -l 'moq_consume_frame' 2>/dev/null | head -20Repository: moq-dev/obs
Length of output: 37
🏁 Script executed:
# Find where libmoq headers are included
rg -n '#include.*moq' src/moq-source.cppRepository: moq-dev/obs
Length of output: 102
🏁 Script executed:
# Check if moq_consume_frame is declared anywhere in this codebase
rg -n 'moq_consume_frame\(' --type=cpp --type=c --type=h --type=hpp -B 2 | head -50Repository: moq-dev/obs
Length of output: 83
🌐 Web query:
moq_consume_frame libmoq API function
💡 Result:
In libmoq, there is no function named moq_consume_frame. Instead, libmoq exposes frame-consumption functions named: 1) moq_consume_frame_chunk(uint32_t frame, uint32_t index, moq_frame *dst) - “Consuming: Frames” API for retrieving a chunk of a frame’s payload [1]. 2) moq_consume_frame_close(uint32_t frame) - “Consuming: Frames” API for closing/cleaning up a consumed frame [1]. Context: these frame functions are part of libmoq’s C API for consuming media tracks/frames (e.g., moq_consume_video_ordered / moq_consume_audio_ordered ultimately deliver frames, which you then read via moq_consume_frame_chunk and release via moq_consume_frame_close) [2][1]. References: libmoq C API function list includes moq_consume_frame_chunk and moq_consume_frame_close under “Consuming: Frames” [1], and libmoq’s docs.rs page enumerates moq_consume_frame_chunk / moq_consume_frame_close under consuming frames [2].
Citations:
🏁 Script executed:
# Find and read the moq.h header file to check for moq_consume_frame definition
find . -name "moq.h" -type f 2>/dev/null | head -5Repository: moq-dev/obs
Length of output: 37
🏁 Script executed:
# Search for moq_consume_frame definition or declaration
rg -n 'moq_consume_frame' --type=c --type=h -A 5 -B 1Repository: moq-dev/obs
Length of output: 37
🌐 Web query:
libmoq 0.2.13 "moq_consume_frame" C API function signature
💡 Result:
In libmoq v0.2.13, the C API does not expose a function named moq_consume_frame; instead, frame-consuming functions are: 1) int32_t moq_consume_frame_chunk(uint32_t frame, uint32_t index, moq_frame dst); 2) int32_t moq_consume_frame_close(uint32_t frame); So there is no C API function signature for moq_consume_frame in that version; the closest equivalents are moq_consume_frame_chunk (to read a chunk payload into moq_frame) and moq_consume_frame_close (to close/cleanup the frame consumer handle). [1] If you intended the Rust API (not the C bindings), the Rust docs list moq_consume_frame_close and moq_consume_frame_chunk as well, not a Rust function named moq_consume_frame. [2]
Citations:
🏁 Script executed:
# Search for moq_consume_frame definition across entire codebase with looser pattern
rg 'moq_consume_frame' --type=c --type=h -iRepository: moq-dev/obs
Length of output: 37
🏁 Script executed:
# Check if there's a local wrapper or definition in any file
git ls-files | xargs grep -l 'moq_consume_frame' 2>/dev/nullRepository: moq-dev/obs
Length of output: 74
🏁 Script executed:
# Look for recent commits or comments that might explain this API
git log --oneline --all -S 'moq_consume_frame' 2>/dev/null | head -20Repository: moq-dev/obs
Length of output: 144
🏁 Script executed:
# Read the actual commit that changed this
git show 8d96b63 --statRepository: moq-dev/obs
Length of output: 5865
🏁 Script executed:
# Get more details on the commit
git show 8d96b63 | head -100Repository: moq-dev/obs
Length of output: 2940
🏁 Script executed:
# Check CMakeLists.txt or build configuration for libmoq version
find . -name "CMakeLists.txt" -o -name "*.cmake" -o -name "conanfile.*" | xargs grep -l 'libmoq' 2>/dev/nullRepository: moq-dev/obs
Length of output: 72
🏁 Script executed:
# Check CMakeLists.txt for libmoq version specification
cat CMakeLists.txt | grep -i libmoq -A 5 -B 5Repository: moq-dev/obs
Length of output: 631
🏁 Script executed:
# Look for libmoq in conanfile or other dependency files
find . -name "conanfile.*" -o -name "requirements.txt" -o -name "package.json" | xargs cat 2>/dev/null | grep -i libmoqRepository: moq-dev/obs
Length of output: 37
🌐 Web query:
libmoq C API moq_consume_frame newer version function
💡 Result:
In the current libmoq C API, there is no function named moq_consume_frame. Instead, the frame-consumption API is split into “chunk” and “close” calls: 1) moq_consume_frame_chunk(frame, index, moq_frame* dst) 2) moq_consume_frame_close(frame) So if you previously used moq_consume_frame in older code, the equivalent newer pattern is to: - call moq_consume_frame_chunk(...), repeatedly for each chunk index in the frame, and - call moq_consume_frame_close(...) when you’re done with the frame. This split is reflected in the documented C functions exposed by libmoq (e.g., libmoq v0.2.13): it lists moq_consume_frame_chunk(...) and moq_consume_frame_close(...) under “Consuming: Frames”. [1]
Citations:
🏁 Script executed:
# Find where MOQ_VERSION is defined
rg -n 'MOQ_VERSION' CMakeLists.txt -B 5 -A 5Repository: moq-dev/obs
Length of output: 443
🏁 Script executed:
# Check if there's a version file or defaults
find . -name "*.cmake" -o -name "CMakePresets.json" | xargs grep -i 'MOQ_VERSION' 2>/dev/nullRepository: moq-dev/obs
Length of output: 108
🌐 Web query:
libmoq moq_consume_frame latest version C API
💡 Result:
In libmoq (C FFI for moq-lite), the “consume frame” operations are exposed as frame-level functions, not a single function literally named moq_consume_frame. Latest libmoq version (as published on crates.io at the time of research): v0.2.13 [1]. C API frame consumption functions (consuming frames): - int32_t moq_consume_frame_chunk(uint32_t frame, uint32_t index, moq_frame *dst); [1][2] - int32_t moq_consume_frame_close(uint32_t frame); [1][2] Related frame consumer lifecycle (consume handle cleanup): - int32_t moq_consume_close(uint32_t consume); (close the broadcast consumer / top-level consume handle) [1][2] Notes on “latest version C API”: - The libmoq crate documentation states the library exposes C functions and points to api.rs for full details [3]. - The Rust bindings documentation page lists the consuming frame APIs including moq_consume_frame_chunk and moq_consume_frame_close [2]. If you meant a different API surface (e.g., moq-lite Rust FrameConsumer vs libmoq C FFI), tell me which language/API you’re using and I’ll map the corresponding calls.
Citations:
- 1: https://crates.io/crates/libmoq
- 2: https://docs.rs/libmoq/latest/moq/
- 3: https://doc.moq.dev/rs/crate/libmoq.html
Fix API call to match libmoq 0.2.13 C API.
The function moq_consume_frame does not exist in libmoq 0.2.13. The official C API provides only:
moq_consume_frame_chunk(uint32_t frame, uint32_t index, moq_frame *dst)moq_consume_frame_close(uint32_t frame)
Line 791 will fail at link time with an undefined reference. The code needs to use the actual libmoq 0.2.13 API, likely calling moq_consume_frame_chunk with an appropriate chunk index (0 for the first chunk, if applicable) instead of the non-existent moq_consume_frame.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/moq-source.cpp` at line 791, The call to the non-existent
moq_consume_frame must be replaced with libmoq 0.2.13 API calls: call
moq_consume_frame_chunk(frame_id, 0, &frame_data) to read the first chunk (use
index 0) and check its return value for errors, and after processing call
moq_consume_frame_close(frame_id) to release the frame; update any error
handling that relied on moq_consume_frame to use the chunk and close return
codes and ensure you still populate/use frame_data as before.
Related: #34
The libmoq api refactor requires to be changed for the moq source. There is a build issue with an error