Add streamer in Pixel Streaming2

In addition to the default ‘defaultstreamer’, I want to add a new stream for transmitting the video from another camera in Pixel Streaming2.

IPixelStreaming2Module& psModule = IPixelStreaming2Module::Get();
TSharedPtr streamer = psModule.CreateStreamer(TEXT(“Camera_FrontCenter”));
UPixelStreaming2VideoProducerRenderTarget* render = NewObject(GetTransientPackage());
render->Target = this->RenderTarget;
TSharedPtr video = render->GetVideoProducer();
streamer->SetVideoProducer(video);
streamer->StartStreaming();

I used this code to create a new Streamer, and the server has also received two streams.

[11:32:25.788] info: New streamer connection: ::ffff:127.0.0.1
[11:32:25.790] info: < UnknownStreamer :: {“type”:“identify”}
[11:32:25.790] info: < UnknownStreamer :: {“type”:“config”,“peerConnectionOptions”:{“iceServers”:[{“urls”:[“stun:stun.l.google.com:19302”,“turn:127.0.0.1:19303”],“username”:“1”,“credential”:“1”}]},“protocolVersion”:“1.3.0”}
[11:32:36.192] info: New streamer connection: ::ffff:127.0.0.1
[11:32:36.192] info: < UnknownStreamer1 :: {“type”:“identify”}
[11:32:36.193] info: < UnknownStreamer1 :: {“type”:“config”,“peerConnectionOptions”:{“iceServers”:[{“urls”:[“stun:stun.l.google.com:19302”,“turn:127.0.0.1:19303”],“username”:“1”,“credential”:“1”}]},“protocolVersion”:“1.3.0”}
[11:32:36.536] info: > UnknownStreamer :: {“id”:“DefaultStreamer”,“protocolVersion”:“1.1.0”,“type”:“endpointId”}
[11:32:36.536] info: < DefaultStreamer :: {“type”:“endpointIdConfirm”,“committedId”:“DefaultStreamer”}
[11:32:36.569] info: > DefaultStreamer :: {“type”:“ping”,“time”:1751945556}
[11:32:36.569] info: < DefaultStreamer :: {“type”:“pong”,“time”:1751945556}
[11:32:36.570] info: > UnknownStreamer1 :: {“type”:“ping”,“time”:1751945556}
[11:32:36.570] info: < UnknownStreamer1 :: {“type”:“pong”,“time”:1751945556}

The above is the log record.

Currently, the DefaultStreamer can connect normally,but UnknownStreamer1 has consistently failed to register successfully, and the newly added Streamer cannot be found on the server.

Is there any other configuration required?
Thanks

I found the problem: the streamer cannot be a local variable.

Glad you were able to find the solution.

If anyone is curious as to why it cannot be a local variable, the PixelStreaming2Module stores the streamers as TWeakPtr<IPixelStreaming2Streamer> meaning that anytime you call CreateStreamer, you are expected to manage the lifetime of that returned streamer pointer.