Commit graph

44 commits

Author SHA1 Message Date
Alessandro Decina
5977ef5552 vtenc: fix build on iOS 2014-11-12 16:45:12 +01:00
Alessandro Decina
a1cc1b34e1 vtenc: fix compilation on < 10.9 2014-11-12 10:00:11 +01:00
Alessandro Decina
bc7dbd7b51 vtenc: enable the hw encoder on OSX 2014-11-11 18:01:54 +01:00
Alessandro Decina
1d97516731 vtenc: add realtime and allow-frame-reordering properties 2014-11-07 00:22:08 +01:00
Sebastian Dröge
68c067e3c9 vtenc: Fix locking
The object lock only protects the session, as we modify
the session from other threads when the bitrate property
is changed. Don't hold it much longer than for session
related things.

And we need to release the video decoder stream lock before
enqueueing a frames. It might wait for our callback to dequeue
a frame from another thread, which will then take the stream
lock too and deadlock.
2014-10-21 16:22:06 +02:00
Sebastian Dröge
ad649138aa vtenc: Use kVTProfileLevel_H264_Baseline_AutoLevel only on iOS
It is not required on OSX apparently and was only added in 10.9.6 there.
Calculating the correct level from the configuration is not trivial, so let's
just not set a level at all here.
2014-10-19 14:57:43 +02:00
Sebastian Dröge
b57f255f26 vtenc: VTCompressionSessionPrepareToEncodeFrames only exists since 10.9.6
Check with configure for it instead of using one of the availability macros
as those wouldn't work as expected with minor versions.
2014-10-19 14:51:40 +02:00
Sebastian Dröge
e79355078e vtenc: Remove unused #define 2014-10-19 14:32:31 +02:00
Sebastian Dröge
3c1ccb64eb vtenc: Fix encoder to work on iOS
iOS has special stride requirements that we don't know yet, so copy
input buffers into buffers allocated by iOS for now.

Later we should check the stride and probably provide a buffer pool for these
buffers so upstream can directly write in there.
2014-09-19 14:47:05 +03:00
Sebastian Dröge
9380f6282d vtenc: Let the encoder automatically choose a h264 level
We should negotiate these things via caps...
2014-09-18 17:49:46 +03:00
Sebastian Dröge
31476a3c46 vtenc: Use 0 instead of G_MAXDOUBLE as the max keyframe interval
0 means no limit, which was meant here with G_MAXDOUBLE probably.
2014-09-18 13:45:33 +03:00
Sebastian Dröge
8c1e84ff71 vtenc: Expected duration is supposed to be the duration of the stream, not a frame
Just don't set it for now, it isn't really needed.
2014-09-18 13:42:24 +03:00
Sebastian Dröge
61c40523df vtenc: Properly handle keyframes
Especially set the SYNC_POINT flag on keyframes.
2014-09-18 13:11:05 +03:00
Sebastian Dröge
ddea2e4498 vtenc: Prepare encoder after setup
This will allow encoding to happen faster on the first frame.
2014-09-17 17:10:58 +03:00
Sebastian Dröge
c6f17d6013 vtenc: Only drain the encoder in ::finish(), not on every frame
Otherwise quality and bitrate will be bad.
2014-09-17 17:08:57 +03:00
Sebastian Dröge
0390398e39 vtenc: Error out if encoding returned an error
Otherwise we will just continue consuming frames until all memory is filled
up and the app crashes.
2014-09-17 15:39:26 +03:00
Sebastian Dröge
e3bc32fb58 vtenc: Check for errors from VTCompressionSessionCompleteFrames() 2014-09-17 14:56:05 +03:00
Sebastian Dröge
b93e0f5f99 vtenc: Properly scale timestamps for the API and set invalid values 2014-09-17 14:55:24 +03:00
Sebastian Dröge
7fa9bbc3b0 vtenc: Port to GstVideoEncoder base class 2014-09-16 17:04:31 +03:00
Sebastian Dröge
4e1f8285c2 vtenc: Use correct instance struct size 2014-09-16 16:13:16 +03:00
Sebastian Dröge
f2eedb9cee vtenc: Port to the real VideoToolbox API instead of using our dlopen() wrapper
It's a public framework since a long time.
2014-09-16 15:47:29 +03:00
Sebastian Rasmussen
b323fba934 vtenc: Avoid leaking caps object and its copy
gst_pad_get_pad_template_caps() returns a reference which is unreferenced,
so creating a copy using gst_caps_copy() results in a reference leak. Also
the caps are pushed as an event downstream, but this doesn't consume the
caps so it must still be unreferenced.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=734534
2014-08-10 12:13:48 +01:00
Matthieu Bouron
e1601406a5 vtenc: fix memory leak
The pixel buffer release callback is called if the void *
dataPtr given to the CVPixelBufferCreateWithPlanarBytes
is not NULL.

According to the documentation dataPtr is supposed to be a
"plane description block" but no specific type is given.

https://bugzilla.gnome.org/show_bug.cgi?id=711847
2014-06-30 13:09:28 +02:00
Matthieu Bouron
e728ee8208 coremediabuffer: handle stride alignment
Handle stride alignment through the use of the video meta API. The
code is based on the corevideobuffer implementation.

If the video meta API is not supported and the underlying buffer
contains padding, the core media buffer is copied to a system memory
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=727885
2014-04-24 12:27:59 +02:00
Andoni Morales Alastruey
110c21a136 vtenc: fix complier error using fixed lenght arrays 2014-04-18 20:17:00 +02:00
Matthieu Bouron
1b2b879bf4 vtenc: use proper release callback type in CVPixelBufferCreateWithPlanarBytes
https://bugzilla.gnome.org/show_bug.cgi?id=711140
2013-10-30 16:27:58 +00:00
Dominik Röttsches
b002490ab2 vtenc: Add support for I420
https://bugzilla.gnome.org/show_bug.cgi?id=709241
2013-10-02 13:18:04 +02:00
Dominik Röttsches
24c79af394 vtenc: Use correct strides, etc from the GstVideoFrame
https://bugzilla.gnome.org/show_bug.cgi?id=706211
2013-10-02 13:14:32 +02:00
Andoni Morales Alastruey
97bb1edf6c applemedia: don't use the dynamic API for public frameworks
Public frameworks don't need to build the API dynamically, we instead
use the framework directly.
The exception is for VideoToolbox which went public in the 10.8 SDK,
but it's still private in older version of the SDK and iOS. This allow
building the plugin against SDK's where it's not a public framework.
2013-05-20 13:31:02 +02:00
Ole André Vadla Ravnås
519cefdeee applemedia: update contact information 2013-02-16 02:51:52 +01:00
Ole André Vadla Ravnås
73bcf51f9f applemedia: port vtenc to 1.0 2013-02-16 02:51:51 +01:00
Ole André Vadla Ravnås
af6df7292c applemedia: port vtapi to run on OS X 10.8 2013-02-16 02:51:51 +01:00
Tim-Philipp Müller
9e1b75fda3 Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-04 00:09:59 +00:00
Mark Nauwelaerts
578861abea replace gst_element_class_set_details_simple with gst_element_class_set_metadata 2012-09-14 17:27:49 +02:00
Ole André Vadla Ravnås
f3d8e3920d applemedia: only enqueue buffers in the VideoToolbox callbacks
These callbacks may fire from any thread, hence we should only enqueue
buffers and let the streaming thread take care of the rest as soon as
the blocking encode or decode operation has finished.
2010-12-10 04:07:05 +01:00
Ole André Vadla Ravnås
ebd2a6d6e9 applemedia: don't push synchronously from callback
The codec that called us might be holding locks to shared resources, so
we should never push downstream from within its buffer callback.

Note that a GstBufferList is not used here because we need to preserve
the buffer metadata held by our GstBuffer subclasses.
2010-11-11 00:22:31 +01:00
Ole André Vadla Ravnås
6b63954f63 vtenc: bump H.264 level from 1.3 to 3.0
This should be turned into a property.
2010-11-11 00:22:31 +01:00
Ole André Vadla Ravnås
d10e029f51 applemedia: biplanar is actually NV12, not I420
D'oh!
2010-11-08 23:58:25 +01:00
Ole André Vadla Ravnås
d865feca82 vtenc: remove keyframe enforcement workaround
Was only needed for old iOS where the H.264 encoder didn't support
kVTEncodeFrameOptionKey_ForceKeyFrame.
2010-11-08 23:58:25 +01:00
Ole André Vadla Ravnås
c2672f71cd applemedia: improve vtenc/vtdec performance
Profiling of H.264 encode and decode revealed that conversions
between packed and planar were happening behind the scenes.

Hence we now choose I420 instead of YUY2.
2010-11-08 14:02:50 +01:00
Ole André Vadla Ravnås
50c6e05924 applemedia: fix stream-format caps used for H.264
The stream-format's "avc-sample" member is now called just "avc".
2010-11-04 14:32:09 +01:00
Ole André Vadla Ravnås
c6b32b42de applemedia: switch vtapi to CFTypeRef style typedefs 2010-11-02 23:14:26 +01:00
Ole André Vadla Ravnås
2e349576eb applemedia: support public version of CoreMedia
Also rename the relevant API so we mirror the public API more closely, and
switch to CoreFoundation CFTypeRef style typedefs. We still support the old
private CoreMedia in order to not break OS X support.

This means that vtenc and vtdec are now compatible with iOS 4.x, and in
theory also future versions of OS X, where this API may turn public like
it has on iOS.
2010-11-02 23:14:26 +01:00
Ole André Vadla Ravnås
0e4e351b83 applemedia: New plugin for Apple multimedia APIs
Provides the following elements:

qtkitvideosrc: OS X video source relying on the QTKit API. Comes with
hard-coded caps as the API does not provide any way of querying for
formats supported by the hardware. Hasn't been tested a lot, but seems
to work.

miovideosrc: OS X video source which uses the undocumented/private
CoreMediaIOServices API, which is also the one used by iChat.
Present on latest version of Leopard and all versions of Snow Leopard.
Has been tested extensively with built-in cameras and TANDBERG's
PrecisionHD USB camera.

vtenc, vtdec: Generic codec wrappers which make use of the undocumented/
private VideoToolbox API on OS X and iOS. List of codecs are currently
hard-coded to H.264 for vtenc, and H.264 + JPEG for vtdec. Can easily be
expanded by adding new entries to the lists, but haven't yet had time to
do that. Should probably also implement probing as available codecs depend
on the OS and its version, and there doesn't seem to be any way to
enumerate the available codecs.

vth264decbin, vth264encbin: Wrapper bins to make it easier to use
vtdec_h264/vtenc_h264 in live scenarios.

iphonecamerasrc: iPhone camera source relying on the undocumented/private
Celestial API. Tested on iOS 3.1 running on an iPhone 3GS. Stops working
after a few minutes, presumably because of a resource leak. Needs some
love.

Note that the iOS parts haven't yet been ported to iOS 4.x.
2010-10-28 15:08:08 +02:00