Skip to content
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

Add behaviour and dynamic dispatch for (de)payloaders #147

Merged
merged 4 commits into from
Aug 9, 2024

Conversation

sgfn
Copy link
Member

@sgfn sgfn commented Aug 6, 2024

Closes #143

Copy link
Member

@LVala LVala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unsure about adding specs to callback implementation. I believe that ex_doc will generate the spec anyway (based on the callback) and making the callback and implementation spec different is a big yucky, but on the other hand, we know that e.g. Opus.depayload will never return {nil, depyayloader}. I'm a bit torn when it comes to this.

examples/save_to_file/lib/save_to_file/peer_handler.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/rtp/depayloader.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/rtp/opus/depayloader.ex Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.51%. Comparing base (af1fec4) to head (b142d04).
Report is 4 commits behind head on master.

Files Patch % Lines
lib/ex_webrtc/rtp/vp8/depayloader.ex 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #147      +/-   ##
==========================================
+ Coverage   88.31%   88.51%   +0.20%     
==========================================
  Files          36       38       +2     
  Lines        1891     1907      +16     
==========================================
+ Hits         1670     1688      +18     
+ Misses        221      219       -2     
Files Coverage Δ
lib/ex_webrtc/rtp/depayloader.ex 100.00% <100.00%> (ø)
lib/ex_webrtc/rtp/opus/depayloader.ex 100.00% <100.00%> (+100.00%) ⬆️
lib/ex_webrtc/rtp/opus/payloader.ex 100.00% <100.00%> (+100.00%) ⬆️
lib/ex_webrtc/rtp/payloader.ex 100.00% <100.00%> (ø)
lib/ex_webrtc/rtp/vp8/payloader.ex 100.00% <ø> (ø)
lib/ex_webrtc/rtp/vp8/depayloader.ex 77.27% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af1fec4...b142d04. Read the comment docs.

@sgfn
Copy link
Member Author

sgfn commented Aug 6, 2024

@LVala I, too, thought that ex_doc would handle it, but alas

Without @spec in implementations:
image

With:
image

@LVala
Copy link
Member

LVala commented Aug 6, 2024

Removing the @doc will automatically add a doc with "Callback implementation for ". Indeed, not @spec in such a case.

Not sure which one is better, but having explicit spec seems more useful.

Edit: You also need to remove @impl true to generate the default doc, which is kinda yucky.

@mickel8
Copy link
Member

mickel8 commented Aug 7, 2024

I think that at the end of the day, we don't want to document functions from Opus/VP8 payloaders/depaylaoders. Instead, the whole documentation should be in the behaviour module or in the module that is responsible for dispatching or in both.

E.g.

d = ExWebRTC.RTP.Depayloader.new(ExWebRTC.RTP.Depayloader.VP8, some_options)
{frame, d} = ExWebRTC.RTP.Depayloader.depayload(d, packet)

In such case, we only need to document ExWebRTC.RTP.Depayloader.VP8 module. Its functions shouldn't appear in docs. But this is the final outcome.

@sgfn sgfn changed the title Add behaviour for (de)payloaders Add behaviour and dynamic dispatch for (de)payloaders Aug 8, 2024
@sgfn sgfn requested review from LVala and mickel8 August 8, 2024 11:50
@sgfn
Copy link
Member Author

sgfn commented Aug 8, 2024

@mickel8 Could you please reiterate on how exactly do you suggest the docs should look like? Specifically, which parts should I get rid of?

@mickel8
Copy link
Member

mickel8 commented Aug 8, 2024

@sgfn please take a look at #154

@mickel8 mickel8 merged commit 8f7866e into master Aug 9, 2024
1 check failed
@mickel8 mickel8 deleted the sgfn/payloader-behaviour branch August 9, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a common behaviour for payloaders and depayloaders
3 participants