Skip to content

Commit

Permalink
readme: update
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 committed Jul 8, 2023
1 parent 06d9320 commit 8b5b1ae
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ https://github.com/finger563/unreal-rtsp-display/assets/213467/05942919-d097-414
When running this example, you will need to configure the address, port, and
path of your RTSP server on the actor:

![CleanShot 2023-07-08 at 10 52
16@2x](https://github.com/finger563/unreal-rtsp-display/assets/213467/6cf9ff23-65af-47e6-8260-601499a0ef68)
<img height="300" alt="CleanShot 2023-07-08 at 10 52 16@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/6cf9ff23-65af-47e6-8260-601499a0ef68">

Note: this example currently only supports MJPEG streams over RTSP, which are
parsed with the RtpJpegPacket class into JpegFrames. This example uses Unreal
Expand All @@ -17,50 +16,55 @@ image data for use in a UTexture2D.

This example contains a few components:

1. The RtspClientComponent class: This component can be added to an actor and
1. The `RtspClientComponent` class: This component can be added to an actor and
exposes some functions for connecting to an RTSP server and configuring /
controlling the stream. Inside its TickComponent function, it waits for new
images (decompressed) to be available and if so, creates a new transient
UTexture2D and writes the decompressed data to the new texture. It then
broadcasts this new texture using the multicast delegate to any registered
listeners.
2. The RtpPacket, RtpJpegPacket, JpegHeader, and JpegFrame classes which handle
the parsing of the media data (as RTP over UDP from the server to the client)
and reassembling of multiple networks packets into a single jpeg frame.
3. The MyRunnable class: used by the RtspClientComponent when it connects to a
2. The `RtpPacket`, `RtpJpegPacket`, `JpegHeader`, and `JpegFrame` classes which
handle the parsing of the media data (as RTP over UDP from the server to the
client) and reassembling of multiple networks packets into a single jpeg
frame.
3. The `MyRunnable` class: used by the RtspClientComponent when it connects to a
server it spawns two runnables (Unreal Engine threads) for receiving data
from the server on the RTP/UDP socket and the RTCP/UDP socket. The RTP
runnable runs a bound function from the RtspClientComponent class which
receives the raw data, parses it into jpeg frames, decompresses the jpeg
frames, and then updates some mutex-protected data to inform the game thread
(RtspClientComponent::TickComponent) that new data is available.
4. M_Display and M_Display_Inst: these assets in the Content/Materials directory
are simple materials which render a texture parameter with optional
4. `M_Display` and `M_Display_Inst`: these assets in the Content/Materials
directory are simple materials which render a texture parameter with optional
configuration for the UV mapping of the texture. This material instance is
the base for the dynamic material instance that is created at runtime in the
RtspDisplay blueprint.
5. RtspDisplay: This blueprint actor contains an RtspClientComponent and a Plane
static mesh component. On BeginPlay it creates a dynamic material instance of
the M_Display_Inst which it stores a reference to so that it can dynamically
update the texture parameter that the material is rendering. It sets this
material on the plane static mesh component. It also uses the
5. `RtspDisplay`: This blueprint actor contains an RtspClientComponent and a
Plane static mesh component. On BeginPlay it creates a dynamic material
instance of the M_Display_Inst which it stores a reference to so that it can
dynamically update the texture parameter that the material is rendering. It
sets this material on the plane static mesh component. It also uses the
RtspClientComponent to connect to, setup, and start playing the RTSP stream
from the RTSP server. It binds an event to the OnFrameReceived event from the
RtspClientComponent and when it receives a message from that event, it sets
the new texture to be the dynamic material instance's texture parameter.

Image of the running example in the editor:

<img width="1725" alt="CleanShot 2023-07-08 at 10 37 49@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/74a2898c-718e-422e-87f3-79f995188df8">

Image showing the RTSP configuration parameters on the RtspDisplay blueprint actor:

<img width="1723" alt="CleanShot 2023-07-08 at 10 38 20@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/7315797f-4fb3-4af4-9d50-0ffbdee99de2">

### Details

RtspDisplay actor blueprint:
#### RtspDisplay Actor Blueprint

<img width="914" alt="CleanShot 2023-07-08 at 10 49 45@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/ded25e0e-a05a-4c32-a547-aa5455a982c6">
<img width="1124" alt="CleanShot 2023-07-08 at 10 50 28@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/cfdbea49-971d-4ddd-84af-b28e0d09e3a5">
<img width="1530" alt="CleanShot 2023-07-08 at 10 51 26@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/d252003d-6533-4de3-b045-e030644470d9">

M_Display material:
#### M_Display Material

<img width="1242" alt="CleanShot 2023-07-08 at 10 51 50@2x" src="https://github.com/finger563/unreal-rtsp-display/assets/213467/656a5447-39db-4fcc-bb16-92a839dc4e41">

0 comments on commit 8b5b1ae

Please sign in to comment.