Client Sample code?

Topics: Question
Dec 18, 2014 at 7:01 PM
Have tried to build a application using the rtspclient but I am struggling how to extract videoinformation in the framChanged callback.
I get the video streaming with framechanged callbacks, so I guess I am connected.

What can I use for decode the data, any suggestions?
Is there a property for what type of encoding the video is encoded with (answer on the describe command)?

Is there some sample code for how to consume a videostream?

Keep up the good work
Patrik Svensson
Dec 19, 2014 at 10:57 PM
Can you post the response to the "DESCRIBE", because yes that does contain the information which indicates what streams are available and what codec.

If the streams are JPEG you will be able to decode them using the library.

If they are RAW / Uncompressed you should also be able to use the library but I might have to work on the RFC4421Frame class to ensure there are no bugs.

Other formats can be hosted but not decoded.

You are already consuming a stream so I am confused what you need.

See this issue where a code sample is present.

There are also several examples in the Testing code.

Let me know if you need anything else!
Marked as answer by juliusfriedman on 12/19/2014 at 2:57 PM
Dec 20, 2014 at 8:09 AM
Thanks for the reply.
I think I am out luck using the library for decoding as it seems to be a video with H264 coding.
I was just wondering if I can interrogate the data received in reply on the describe message so that I can select what codec to use?
I want to grab a frame and present it as a bitmap in a control preferable on my windows phone.
Any suggestions on decoder libraries for H264?

Caught this using wireshark, just an extract.
DESCRIBE rtsp:// RTSP/1.0
Content-Encoding: utf-8
Accept: application/sdp
User-Agent: ASTI RTP Client
CSeq: 2

RTSP/1.0 200 OK
CSeq: 2
Content-Type: application/sdp
Content-Base: rtsp://
Server: GStreamer RTSP server
Date: Sat, 20 Dec 2014 09:59:15 GMT
Content-Length: 332

o=- 1188340656180883 1 IN IP4
s=Session streamed with GStreamer
t=0 0
m=video 0 RTP/AVP 96
c=IN IP4
a=rtpmap:96 H264/90000
a=fmtp:96 sprop-parameter-sets=Z0IAHqaAtBJkAA==,aM44gAA=
Marked as answer by juliusfriedman on 12/20/2014 at 11:48 AM
Dec 20, 2014 at 7:48 PM
It looks like it's an H.264 Stream, you should be able to use Silverlight to decode or Media Foundation / CsCodec / FFMPEG etc.

I am still a ways off from releasing the Decoders, I have to finish reading for the remaining containers and then writing for all of them first.

However JPEG is completely working right now so that may help you. (See RFC2435Media)

If you need anything else let me know!
Dec 22, 2014 at 6:18 AM
I am as I said originally struggling with the payload, I can't get the complete flag to be set to true, seems like HasMarker is never set to true.
Ignored that and tried to use IsMissing packet == false instead.
The mediaplayload is 96, do you have any tip on which rfcmedia I should use?
Then I can use Buffer ? or what to extract media data?.
Do you have a property or something for accessing the data returned in describe reply, I guess I have to provide some to the codec?

(I am beginning to realize that it's more work than I hoped for in the beginning as its likely that I have to read more about rtp and mpeg4 decoding to ask the right questions.)

As before keep up the good work
// Patrik Svensson
Dec 22, 2014 at 4:40 PM
Honestly I cannot say if that is because of a setting on the camera or not.

For media payload with type >= 96 that indicates the SDP tells you the Codec and Information.

The SDP can be accessed from the RtspClient.SessionDescription property after a valid SDP Describe response is received.

The Buffer is just a MemoryStream where packets are depacketized to.

See this thread

It explains how to use a csCodec to decode frames. It also shows you how to get a h.264 rbsp which you can then feed to VLC or another decoder such as silverlight.

If you camera supports JPEG then you don't need csCodec as the .Net Framework can support JPEG images but the bandwidth used will be greater.

What is your end goal? You can also use something like an FFMPEG wrapper to consume data from the RtspServer and thus saving bandwidth at the source and creating thumbs from the aggregated stream.

I do plan on having a fully featured decoder I just have to finish up a few things first before I can move on.

Please do let me know if you need anything else.
Marked as answer by juliusfriedman on 12/22/2014 at 8:40 AM