-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a module for every codec in
ExWebRTC.RTP
(#122)
- Loading branch information
Showing
8 changed files
with
49 additions
and
49 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
lib/ex_webrtc/rtp/opus_depayloader.ex → lib/ex_webrtc/rtp/opus/depayloader.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/ex_webrtc/rtp/opus_payloader.ex → lib/ex_webrtc/rtp/opus/payloader.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/ex_webrtc/rtp/vp8_payload.ex → lib/ex_webrtc/rtp/vp8/payload.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/ex_webrtc/rtp/vp8_payloader.ex → lib/ex_webrtc/rtp/vp8/payloader.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 18 additions & 18 deletions
36
test/ex_webrtc/rtp/vp8_depayloader_test.exs → test/ex_webrtc/rtp/vp8/depayloader_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
defmodule ExWebRTC.RTP.VP8DepayloaderTest do | ||
defmodule ExWebRTC.RTP.VP8.DepayloaderTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias ExWebRTC.RTP.{VP8Payload, VP8Depayloader} | ||
alias ExWebRTC.RTP.VP8.{Payload, Depayloader} | ||
|
||
test "write/2" do | ||
depayloader = VP8Depayloader.new() | ||
depayloader = Depayloader.new() | ||
# random vp8 data, not necessarily correct | ||
data = <<0, 1, 2, 3>> | ||
|
||
# packet with entire frame | ||
vp8_payload = %VP8Payload{n: 0, s: 1, pid: 0, payload: data} | ||
vp8_payload = VP8Payload.serialize(vp8_payload) | ||
vp8_payload = %Payload{n: 0, s: 1, pid: 0, payload: data} | ||
vp8_payload = Payload.serialize(vp8_payload) | ||
|
||
packet = ExRTP.Packet.new(vp8_payload, marker: true) | ||
|
||
assert {:ok, ^data, %{current_frame: nil, current_timestamp: nil} = depayloader} = | ||
VP8Depayloader.write(depayloader, packet) | ||
Depayloader.write(depayloader, packet) | ||
|
||
# packet that doesn't start a new frame | ||
vp8_payload = %VP8Payload{n: 0, s: 0, pid: 0, payload: data} | ||
vp8_payload = VP8Payload.serialize(vp8_payload) | ||
vp8_payload = %Payload{n: 0, s: 0, pid: 0, payload: data} | ||
vp8_payload = Payload.serialize(vp8_payload) | ||
|
||
packet = ExRTP.Packet.new(vp8_payload) | ||
|
||
assert {:ok, %{current_frame: nil, current_timestamp: nil} = depayloader} = | ||
VP8Depayloader.write(depayloader, packet) | ||
Depayloader.write(depayloader, packet) | ||
|
||
# packet that starts a new frame without finishing the previous one | ||
vp8_payload = %VP8Payload{n: 0, s: 1, pid: 0, payload: data} | ||
vp8_payload = VP8Payload.serialize(vp8_payload) | ||
vp8_payload = %Payload{n: 0, s: 1, pid: 0, payload: data} | ||
vp8_payload = Payload.serialize(vp8_payload) | ||
|
||
packet = ExRTP.Packet.new(vp8_payload) | ||
|
||
assert {:ok, %{current_frame: ^data, current_timestamp: 0} = depayloader} = | ||
VP8Depayloader.write(depayloader, packet) | ||
Depayloader.write(depayloader, packet) | ||
|
||
data2 = data <> <<0>> | ||
vp8_payload = %VP8Payload{n: 0, s: 1, pid: 0, payload: data2} | ||
vp8_payload = VP8Payload.serialize(vp8_payload) | ||
vp8_payload = %Payload{n: 0, s: 1, pid: 0, payload: data2} | ||
vp8_payload = Payload.serialize(vp8_payload) | ||
|
||
packet = ExRTP.Packet.new(vp8_payload, timestamp: 3000) | ||
|
||
assert {:ok, %{current_frame: ^data2, current_timestamp: 3000} = depayloader} = | ||
VP8Depayloader.write(depayloader, packet) | ||
Depayloader.write(depayloader, packet) | ||
|
||
# packet with timestamp from a new frame that is not a beginning of this frame | ||
data2 = data | ||
vp8_payload = %VP8Payload{n: 0, s: 0, pid: 0, payload: data2} | ||
vp8_payload = VP8Payload.serialize(vp8_payload) | ||
vp8_payload = %Payload{n: 0, s: 0, pid: 0, payload: data2} | ||
vp8_payload = Payload.serialize(vp8_payload) | ||
|
||
packet = ExRTP.Packet.new(vp8_payload, timestamp: 6000) | ||
|
||
assert {:ok, %{current_frame: nil, current_timestamp: nil}} = | ||
VP8Depayloader.write(depayloader, packet) | ||
Depayloader.write(depayloader, packet) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
test/ex_webrtc/rtp/vp8_payloader_test.exs → test/ex_webrtc/rtp/vp8/payloader_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters