Commit graph

32 commits

Author SHA1 Message Date
Tim-Philipp Müller
435c2acdc5 rpicamsrc: hypothetical fix for data pointer calculation
mmal buffer header docs say data is valid for length bytes
from offset. In practice offset always seems to be 0 so
far though.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/682>
2020-07-24 17:13:04 +01:00
Tim-Philipp Müller
987a332076 rpicamsrc: mark buffers as header and keyframe/delta-unit
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/682>
2020-07-24 17:09:45 +01:00
Tim-Philipp Müller
9588108d6e rpicamsrc: fix nal alignment of output buffers
We claim output buffers are nal-aligned, but that wasn't
actually true: We would push out a partial nal in case
the nal doesn't fit into the max encoder-selected output
buffer size, and then the next buffer would not start
with a sync marker. That's not right and makes h264parse
unhappy.

Instead accumulate buffers until we have a full frame
(we can't rely on the NAL_END flag, it's always set).

Fixes #768

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/682>
2020-07-24 17:09:45 +01:00
Tim-Philipp Müller
8ceaefe101 rpicamsrc: fix indentation
Not touching the Raspi* files.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/667>
2020-07-10 17:37:28 +01:00
Tim-Philipp Müller
996d2389af rpicamsrc: fix and silence some compiler warnings
Some are in system headers, and in Raspi files we want
to keep modifications to a minimum.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/667>
2020-07-10 17:37:28 +01:00
Jan Schmidt
3c5327ae64 rpicamsrc: Attempt to workaround MMAL timeout bug
mmal_queue_timedwait() might spuriously return immediately
if called at exactly the wrong instant due to an internal
off-by-one bug. Attempt to work around that and just retry.
2020-07-10 16:46:33 +01:00
Jan Schmidt
c907deb15f rpicamsrc: Improve timeout error
Propagate timeout errors so they're not reported
generically
2020-07-10 16:46:31 +01:00
Jan Schmidt
09d9ac2d2e rpicamsrc: Don't destroy the camera component on startup error
Just disable the camera component when it fails to start. The
most common reason is that the camera device is already in use,
and if we just disable the mmal component correct cleanup
will happen later
2020-07-10 16:46:23 +01:00
Jan Schmidt
cab6585378 rpicamsrc: Expand frame timeout from 100ms to 500ms
rpicamsrc on a normal rpi camera doesn't start up fast enough,
and always fails the new 100ms timeout. A better solution
might be to have a longer timeout for the first frame, but
shorter once frames are running - but this quick fix will at
least make rpicamsrc work again.
2020-07-10 16:46:17 +01:00
Georgii Staroselskii
b45e239128 rpicamsrc: RaspiCapture: use mmal_queue_timedwait() for buffer queueing
If an external camera was disconnected, there were no feedback in an
application. It seems reasonable to wait on mmal_queue no longer than
100ms. If it's stuck we just return a FLOW_ERROR and let the application
decide what to do later.
2020-07-10 16:46:15 +01:00
Georgii Staroselskii
149fdee7fb rpicamsrc: RaspiCapture: handle MMAL_EVENT_ERROR 2020-07-10 16:46:13 +01:00
Jan Schmidt
ed893592ea rpicamsrc: Implement use-stc property to disable STC timestamps
If use-stc=false, then rpicamsrc won't apply
the camera timestamping to outgoing buffers, instead
relying on real-time timestamping by the
GStreamer clock. It means slightly less accuracy
and more jitter in timestamps, but might help on some
CSI inputs with broken timestamping.
2020-07-10 16:46:12 +01:00
Jan Schmidt
2c458819f5 rpicamsrc: Implement dynamic bitrate update
Use mmal_port_set_parameter_uint32 to update the encoder
bitrate.

Fixes https://github.com/thaytan/gst-rpicamsrc/issues/60
2020-07-10 16:45:54 +01:00
Jan Schmidt
dd9d7341b0 rpicamsrc: Destroy mmal pool on shutdown always.
Avoid hangs on the next run because we didn't clean up the mmal pool
last time we shutdown.
2020-07-10 16:45:52 +01:00
Jan Schmidt
38ef8c2411 rpicamsrc: Don't try and set H264 params with JPEG codec 2020-07-10 16:45:49 +01:00
Jan Schmidt
da86cec40e rpicamsrc: First attempt at implementing MJPEG and raw video support 2020-07-10 16:45:47 +01:00
Jan Schmidt
e97b50af51 rpicamsrc: Fix buffer PTS calculation
Timestamps from MMAL are in microseconds,
so make sure to convert to nanoseconds before
using them to adjust the GStreamer buffer time
2020-07-10 16:45:15 +01:00
Jan Schmidt
4e827949ef rpicamsrc: Fix initial config setting.
Make sure to update the captsure config before starting
capture. Since the capture component now keeps a local
copy of the config, it's not updated automatically.
2020-07-10 16:44:46 +01:00
Jan Schmidt
e58951cfb8 rpicamsrc: Disable bitrate, quantisation and intra-refresh dynamic changes
The firmware rejects dynamic changes of those encoder params.
2020-07-10 16:44:45 +01:00
Jan Schmidt
3b85ddd90e rpicamsrc: Update properties dynamically where possible
Update camera and encoder properties at runtime
where possible

Fixes https://github.com/thaytan/gst-rpicamsrc/issues/19
and https://github.com/thaytan/gst-rpicamsrc/issues/23
2020-07-10 16:44:23 +01:00
Jan Schmidt
3771777f7f rpicamsrc: Clear intra-refresh MMAL param struct.
Use memset on the stack allocated MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T
struct. Apparently mmal_port_parameter_get() doesn't retrieve all
parameters, causing random failures when we set the intra-refresh
param on the encoder.

Fixes https://github.com/thaytan/gst-rpicamsrc/issues/22 for me.
2020-07-10 16:44:13 +01:00
Jan Schmidt
4d70e1d8ee rpicamsrc: Merge changes from userland repo
Current to b69f807ce59189457662c2144a8e7e12dc776988

No integration of stereoscopic support as yet
2020-07-10 16:44:11 +01:00
Jan Schmidt
8fe0590c29 rpicamsrc: Use MMAL PTS and STC to calculate GStreamer timestamps
Don't apply timestamps based on output time from the encoder,
but use the MMAL STC and capture PTS to generate a GStreamer
timestamp that more accurately resembles the input (and would
preserve reordering should the encoder ever add B-frames).

Fixes https://github.com/thaytan/gst-rpicamsrc/issues/16
2020-07-10 16:43:55 +01:00
Jan Schmidt
c3ad9c99a6 rpicamsrc: Defer encoder creation until after caps are negotiated
This ensures the encoder is created with the profile
negotiated with downstream
2020-07-10 16:43:53 +01:00
Jan Schmidt
52ae74f9ce rpicamsrc: More conversion to GStreamer logging 2020-07-10 16:43:26 +01:00
Jan Schmidt
6bd0347bf0 rpicamsrc: Incorporate raspivid changes from upstream
Merge all changes for new features from upstream
raspberrypi userland, up to commit 0de0b2
2020-07-10 16:43:02 +01:00
Vivia Nikolaidou
d226968275 rpicamsrc: Add force-key-unit event support 2020-07-10 16:42:55 +01:00
Jan Schmidt
244091bb5e rpicamsrc: Move all debug output to go via GStreamer logs
Fixes https://github.com/thaytan/gst-rpicamsrc/issues/9
2020-07-10 16:42:16 +01:00
Jan Schmidt
cde8b33199 rpicamsrc: Initial caps nego and properties.
Support caps negotiation for H.264 frame size and framerate.

Add bitrate, saturation, brightness, contrast, sharpness properties.
2020-07-10 16:42:09 +01:00
Jan Schmidt
1416631df9 rpicamsrc: First version which generates buffers on the src pad
Fixed to 1920x1080 h264 regardless of caps.
2020-07-10 16:42:07 +01:00
Jan Schmidt
7ffb618b20 rpicamsrc: Checkpoint. Version which writes directly to test.out
Switch to plain basesrc for parent class
2020-07-10 16:42:06 +01:00
Jan Schmidt
f4af399350 rpicamsrc: checkpoint 2020-07-10 16:42:04 +01:00