Use RTPS to send video and audio stream from a byte stream

Topics: Question
Sep 7, 2015 at 8:36 PM
Hello juliusfriedman,

i want to use your library. I already had a byte stream with seperated frames. I miss some documentation about how to use you library wihtout an existing stream.

The following should symbolize the signal chain.

Direct-Show filter -> memory stream .. each received byte stream is a frame -> RTPS Server ->
MPlayer

Can you tell me which steps i needed?

Best regards
Moe
Coordinator
Sep 8, 2015 at 1:33 PM
Thanks for your interest with the library.

It seems you have already indicated the steps you need to take via the signal chain...

Take care.
Sep 8, 2015 at 3:53 PM
Okay a little bit in Detail.

I receive a H264 raw byte stream from the Direct Show Filter. Now i want to use your library but i miss some documentation about in which cases ,which part of your library is used.

Following is done by me in the moment:

Create Members in the Direct Show filter:
        private RtspServer server = new RtspServer(System.Net.IPAddress.Any, 554);
        private RFC6184Media source = new RFC6184Media(1080, 1920, "test", null, false);
In the constructor of the the direct show filter:
      server.TryAddMedia(source);
In the render function. There we get a frame from the camera stream
public override int DoRenderSample(ref IMediaSampleImpl pMediaSample)
{
    IntPtr buffer = IntPtr.Zero;
    //Get a pointer to the data
    hr = (HRESULT)pMediaSample.GetPointer(out buffer); 
    // Create a byte buffer to store the data   
    byte[] managedArray = new byte[(size)];
    // Copy the data pointer on to the managed array
    Marshal.Copy(buffer, managedArray, 0, size);

    //Now create a H264 frame   
    Media.Rtsp.Server.MediaTypes.RFC6184Media.RFC6184Frame frame = new Media.Rtsp.Server.MediaTypes.RFC6184Media.RFC6184Frame(96);
    frame.Packetize(managedArray);
    source.AddFrame(frame);

    if (server.Logger == null)
       server.Logger = new Media.Rtsp.Server.RtspServerDebuggingLogger();
     if (!server.IsRunning)
        server.Start();
}
When i connect now to the server with vlc or mplayer following will be in the debug outputfile:
Response 1 OK e93103fc-37bb-40eb-b5d8-0a9a74acfbf6 

Request DESCRIBE rtsp://localhost/live/test e93103fc-37bb-40eb-b5d8-0a9a74acfbf6 

Response 2 OK e93103fc-37bb-40eb-b5d8-0a9a74acfbf6 

Adding Client: 13b5a132-410c-4354-b44a-9fcbf7876f75
Accepted Client: 13b5a132-410c-4354-b44a-9fcbf7876f75 @ 08.09.2015 11:54:39 Added =True
Request DESCRIBE rtsp://localhost/live/test 13b5a132-410c-4354-b44a-9fcbf7876f75 

Response 2 OK 13b5a132-410c-4354-b44a-9fcbf7876f75 

Request SETUP rtsp://127.0.0.1/live/bdbda2f1-459c-46c9-940b-87f8c9a67c2d//live/bdbda2f1-459c-46c9-940b-87f8c9a67c2d/video 13b5a132-410c-4354-b44a-9fcbf7876f75 

Response 3 OK 13b5a132-410c-4354-b44a-9fcbf7876f75 

Request PLAY rtsp://127.0.0.1/live/bdbda2f1-459c-46c9-940b-87f8c9a67c2d/ 13b5a132-410c-4354-b44a-9fcbf7876f75 

Response 4 OK 13b5a132-410c-4354-b44a-9fcbf7876f75 

RestartFaultedStreams
DisconnectAndRemoveInactiveSessions
Media.Rtp.RtpClient-0dbee188-4acc-4a6f-99a6-0ececde42ae5@SendRecieve - Begin
Media.Rtp.RtpClient-0dbee188-4acc-4a6f-99a6-0ececde42ae5@ParseAndCompleteData - Remaining= 4
0dbee188-4acc-4a6f-99a6-0ececde42ae5HandleIncomingRtcpPacket - No Context for packet -1488296362@201
0dbee188-4acc-4a6f-99a6-0ececde42ae5HandleIncomingRtcpPacket - No Context for packet -1488296362@202
Media.Rtp.RtpClient-0dbee188-4acc-4a6f-99a6-0ececde42ae5@ParseAndCompleteData - Remaining= 4
0dbee188-4acc-4a6f-99a6-0ececde42ae5HandleIncomingRtcpPacket - No Context for packet -1488296362@201
0dbee188-4acc-4a6f-99a6-0ececde42ae5HandleIncomingRtcpPacket - No Context for packet -1488296362@202
RestartFaultedStreams
DisconnectAndRemoveInactiveSessions
Also the "SendPackets" function in the RTPSink class isn't called. Can you give me some addtional information about the usage of the classes and there methods?
Coordinator
Sep 22, 2015 at 3:18 PM
Those outputs are just for debugging and probably relate to the '0xFACEFEED' or other such packets sent by certain libraries to increase chances of UDP reception through a firewall in certain cases.

I am confused about what you are trying to do, RtpSink is abstract, you would use the 'RFC6184Media' class which should be working for packetization and depacketization.
Marked as answer by juliusfriedman on 9/22/2015 at 8:18 AM