-
Notifications
You must be signed in to change notification settings - Fork 14
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
Ogg reader #43
Ogg reader #43
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #43 +/- ##
==========================================
- Coverage 88.15% 87.29% -0.87%
==========================================
Files 14 15 +1
Lines 701 748 +47
==========================================
+ Hits 618 653 +35
- Misses 83 95 +12
Continue to review full report in Codecov by Sentry.
|
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 didn't dive into Ogg itself but other than that looks great! I just added a couple of minor suggestions
examples/send_from_file/README.md
Outdated
4. Press the play button. | ||
|
||
You can replace `video.avf` or `audio.ogg` and use your own files instead. |
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.
video.avf -> video.ivf
examples/send_from_file/example.exs
Outdated
# and time spent on reading and parsing the file | ||
# that's why you might hear short pauses in audio playback, when using this example | ||
Process.send_after(self(), :send_audio_packet, duration) | ||
rtp_packet = ExRTP.Packet.new(packet, 111, 1000, state.last_audio_timestamp, 1000) |
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 would pass 0 for everything that RTP sender is responsible for. Right now, we might confuse user that they are responsible for handling e.g. pt
examples/send_from_file/example.exs
Outdated
@impl true | ||
def handle_info(:send_audio_packet, state) do | ||
case OggReader.next_packet(state.audio_reader) do | ||
{:ok, reader, {packet, duration}} -> |
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.
The convention is to return reader at the last place in the result tuple. Take a look at Map.pop and others
audio_track = MediaStreamTrack.new(:audio) | ||
video_track = MediaStreamTrack.new(:video) | ||
|
||
{:ok, _} = PeerConnection.add_track(pc, audio_track) |
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.
Brilliant!
examples/send_from_file/example.exs
Outdated
Process.send_after(self(), :send_frame, 30) | ||
%{state | ivf_reader: ivf_reader, payloader: payloader} | ||
Process.send_after(self(), :send_video_frame, 30) | ||
Process.send_after(self(), :send_audio_packet, 20) |
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.
Actually, we could do Process.sendafter 0
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.
Even better, send(self(), ...)
🙂
lib/ex_webrtc/media/ogg_reader.ex
Outdated
with {:ok, file} <- File.open(path), | ||
reader <- %{file: file, packets: [], rest: <<>>}, | ||
# for now, we ignore ID Header and Comment Header | ||
{:ok, reader, <<@id_signature, _rest::binary>>} <- do_next_packet(reader), |
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.
As above, keep reader at the end of return tuple
lib/ex_webrtc/media/ogg_reader.ex
Outdated
Reads next Ogg packet. | ||
|
||
One Ogg packet is equivalent to one Opus packet. | ||
This function also returns the duration of the audio in milliseconds, based on Opus packet TOC sequence. |
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.
Maybe let's elaborate on TOC
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'll just redirect the reader to the RFC.
No description provided.