Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ex_webrtc/rtp/vp8.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ defmodule ExWebRTC.RTP.VP8 do
# for more information refer to RFC 7741 Sections 4.2 and 4.3

with {:ok, vp8_payload} <- VP8.Payload.parse(rtp_payload),
<<_size0::3, _h::1, _ver::3, p::1, _size1::8, _size2::8, _rest::binary>> <- rtp_payload do
<<_size0::3, _h::1, _ver::3, p::1, _size1::8, _size2::8, _rest::binary>> <-
vp8_payload.payload do
vp8_payload.s == 1 and vp8_payload.pid == 0 and p == 0
else
_err -> false
Expand Down
35 changes: 35 additions & 0 deletions test/ex_webrtc/rtp/vp8_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
defmodule ExWebRTC.RTP.VP8Test do
use ExUnit.Case, async: true

alias ExRTP.Packet
alias ExWebRTC.RTP.VP8

@vp8_packet "test/fixtures/rtp/vp8_packet.bin"

test "keyframe?/1" do
# from https://github.com/jech/galene/blob/master/codecs/codecs_test.go
binary1 =
<<0x80, 0xE0, 0x71, 0x3E, 0x5D, 0x6F, 0x3C, 0xC5, 0x75, 0xC, 0x80, 0x96, 0x90, 0x80, 0xB0,
0x4C, 0x90, 0x2, 0x0, 0x9D, 0x1, 0x2A, 0x10, 0x0, 0x10, 0x0, 0x39, 0x3, 0x0, 0x0, 0x1C,
0x22, 0x16, 0x16, 0x22, 0x66, 0x12, 0x20, 0x4, 0x90, 0x40, 0x4E, 0x9E, 0x8D, 0xE9, 0x40,
0xFE, 0xFF, 0xAB, 0x59, 0x72, 0x30, 0xD1, 0xAF, 0xE4, 0x6A, 0x11, 0x3, 0xFD, 0x15, 0xE9,
0x2, 0x2E, 0xDF, 0xD9, 0xD1, 0xB8, 0x0, 0x0>>

{:ok, packet1} = Packet.decode(binary1)
assert VP8.keyframe?(packet1)

binary2 =
<<0x80, 0x6F, 0x61, 0x8F, 0xD5, 0x36, 0xDC, 0x15, 0x1B, 0x4A, 0xB5, 0x29, 0x78, 0x9, 0xA1,
0x93, 0xA0, 0x5B, 0xD8, 0xF1, 0xDE, 0x87, 0x23, 0x5A, 0xB9, 0x19, 0x97, 0xB7, 0xBD, 0xBF,
0xF7, 0x6E, 0xAD, 0x82, 0xC4, 0x70, 0x1C, 0xC9, 0x3A, 0xB4, 0x1F, 0x13, 0x45, 0xB5, 0xF1,
0x0, 0xA5, 0xA5, 0xA9, 0xD0, 0xA5, 0xDF, 0x67, 0x88, 0x26, 0x30, 0x32>>

{:ok, packet2} = Packet.decode(binary2)
assert not VP8.keyframe?(packet2)

# https://github.com/elixir-webrtc/ex_webrtc/issues/234
{:ok, binary_packet3} = File.read(@vp8_packet)
packet3 = :erlang.binary_to_term(binary_packet3)
assert not VP8.keyframe?(packet3)
end
end
Binary file added test/fixtures/rtp/vp8_packet.bin
Binary file not shown.
Loading