Rtsp streaming green screen (Android)

1.5k Views Asked by At

Hello guys I am working on a project to stream the content of the screen of an android device over the network. I have used libstreaming as my code base.

I have achieved several things:

  • I can record the screen using MediaCodec and VirtualDisplay (using MediaProjection) to a mp4 file. This is just to verify that the parameters are ok.
  • I can send the data from MediaCodec (ByteBuffer) over the network. I have printed the actual stream that is sent for each frame, it seems to be different and not empty. I even used wireshark and I can see all packages sent using UDP protocol.

Now I have a problem. When I connect to the rtsp server with VLC, the video screen gets opened. But all I can see is a green screen, or sometimes gray. Just for a second or even less, sometimes I can see a portion of the android screen (one of the icons for example).

The same project it's working if I stream video from the camera instead. This makes me think that all the packetization and rtsp server are ok.

I run vlc from the command line and this is an example of what I get:

[h264 @ 0x1050cdc00] Frame num gap 45065 45063
[h264 @ 0x1050cdc00] number of reference frames (1+1) exceeds max (1; probably corrupt input), discarding one
[h264 @ 0x1050cdc00] QP 4294967291 out of range
[h264 @ 0x1050cdc00] decode_slice_header error
[h264 @ 0x10091e800] number of reference frames (1+1) exceeds max (1; probably corrupt input), discarding one
[h264 @ 0x10091e800] Frame num gap 49161 49159
[h264 @ 0x10091e800] number of reference frames (1+1) exceeds max (1; probably corrupt input), discarding one
[h264 @ 0x10091e800] QP 4294967293 out of range
[h264 @ 0x10091e800] decode_slice_header error
[h264 @ 0x10091ee00] number of reference frames (1+1) exceeds max (1; probably corrupt input), discarding one

This is the log from vlc: http://pastebin.com/3TsDKrur

The sps and pps parameters are set correctly. When I connect to the rtsp server, I can see that this replies with the sdp configuration, and both parameters are within it.

Does anybody have any clue what I might be doing wrong here?

Thanks.

PS: I haven't posted any code as it is kind of big and it seems to be fine when the frames come from the camera. If anybody needs it, I will be more than happy to post it.

UPDATE:

I have been trying to debug the code a little bit more. It might be that rtp packets are not properly created?. Is there any way where I can check if the format is correct? I have been looking for an example where packets are created in java but I couldn't find any. Any suggestion will be welcomed.

So far I have been using the H264Packetizer from libstreaming, but I think it is not correct as it is a very old code.

Here you have a screenshot taken from Wireshark. The package seems to be ok though.

Wireshark screenshot

0

There are 0 best solutions below