Skip to content

Commit

Permalink
Fix examples sometimes not loading in Chromium (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 authored Jul 8, 2024
1 parent 2ecd323 commit 0eb774c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions examples/echo/lib/echo/peer_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,19 @@ defmodule Echo.PeerHandler do
{:ok, state}
end

defp handle_webrtc_msg({:rtcp, _packets}, state) do
# do something with RTCP packets
defp handle_webrtc_msg({:rtcp, packets}, state) do
for packet <- packets do
case packet do
%ExRTCP.Packet.PayloadFeedback.PLI{} when state.in_video_track_id != nil ->
Logger.info("Received keyframe request. Sending PLI.")
:ok = PeerConnection.send_pli(state.peer_connection, state.in_video_track_id, "h")

_other ->
# do something with other RTCP packets
:ok
end
end

{:ok, state}
end

Expand Down
9 changes: 8 additions & 1 deletion examples/send_from_file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ While in `examples/send_from_file` directory
1. Generate media files

```shell
ffmpeg -f lavfi -i testsrc=duration=5:size=640x480:rate=30 video.ivf
ffmpeg -f lavfi -i testsrc=duration=5:size=640x480:rate=30 -g 60 video.ivf
ffmpeg -f lavfi -i sine=frequency=420:duration=5 -c:a libopus audio.ogg
```

> [!NOTE]
> Option `-g` defines a GOP size i.e. how frequently we will generate a new keyframe.
> Our framerate is 30, so we set the GOP to 60 to have a new keyframe every two seconds.
> This is to make sure, that even if something goes really badly and your keyframe is dropped
> (e.g. there is a bug in a web browser, or something strange happend on your network interface),
> a browser, in the worst case scenario, will get a new one in two seconds.
You may use your own files, if they meet the requirements:
* for video, it must be IVF in 30 FPS,
* for audio, it must be Ogg with a single Opus stream.
Expand Down

0 comments on commit 0eb774c

Please sign in to comment.