Commit Graph

28 Commits

Author SHA1 Message Date
Neil Roberts
a972024ed7 cogl-gst-video-sink: Fix a call to g_return_val_if_fail
cogl_gst_video_sink_get_natural_size was using g_return_val_if_fail
but its return type is void. For some reason GCC doesn't complain
about this but it causes a compile error on clang.
2014-03-21 15:30:30 +00:00
Lionel Landwerlin
1b2dd815b4 Registers gtypes for all public objects and structs
This adds much more comprehensive support for gobject-introspection
based bindings by registering all objects as fundamental types that
inherit from CoglObject, and all structs as boxed types.

Co-Author: Robert Bragg <robert@linux.intel.com>

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 18:27:12 +00:00
Robert Bragg
849f691969 cogl-gst: add cogl_gst_video_sink_get_natural_size() api
This adds api for querying a "natural" width and height for a video
which has the correct aspect ratio for displaying on square, 1:1 pixels.

The natural size is the minimum size where downscaling is not required.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
9f8ab5d809 cogl-gst: allocate textures synchronously
This makes sure video textures being uploaded via
video_texture_new_from_data are allocated before the function returns.
This function create a CoglBitmap to wrap the data from gstreamer and by
allowing cogl to allocate the texture lazily it's possible that the data
being pointed to by the bitmap won't remain valid until we actually come
to allocate the texture.

Note: we don't simply use cogl_texture_2d_[sliced_]new_from_data() here
because we need to be able to call cogl_texture_set_premultiplied()
before allocating the texture.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
a0441778ad This re-licenses Cogl 1.18 under the MIT license
Since the Cogl 1.18 branch is actively maintained in parallel with the
master branch; this is a counter part to commit 1b83ef938fc16b which
re-licensed the master branch to use the MIT license.

This re-licensing is a follow up to the proposal that was sent to the
Cogl mailing list:
http://lists.freedesktop.org/archives/cogl/2013-December/001465.html

Note: there was a copyright assignment policy in place for Clutter (and
therefore Cogl which was part of Clutter at the time) until the 11th of
June 2010 and so we only checked the details after that point (commit
0bbf50f905)

For each file, authors were identified via this Git command:
$ git blame -p -C -C -C20 -M -M10  0bbf50f905..HEAD

We received blanket approvals for re-licensing all Red Hat and Collabora
contributions which reduced how many people needed to be contacted
individually:
- http://lists.freedesktop.org/archives/cogl/2013-December/001470.html
- http://lists.freedesktop.org/archives/cogl/2014-January/001536.html

Individual approval requests were sent to all the other identified authors
who all confirmed the re-license on the Cogl mailinglist:
http://lists.freedesktop.org/archives/cogl/2014-January

As well as updating the copyright header in all sources files, the
COPYING file has been updated to reflect the license change and also
document the other licenses used in Cogl such as the SGI Free Software
License B, version 2.0 and the 3-clause BSD license.

This patch was not simply cherry-picked from master; but the same
methodology was used to check the source files.
2014-02-22 02:02:53 +00:00
Neil Roberts
b898333181 cogl-gst: Fix get_caps implementation when no context is set
If no context is set on the CoglGstVideoSink then it would previously
call gst_caps_ref with a NULL pointer. This patch makes it just return
NULL instead. I think that is a valid thing to do because that is what
gst_base_sink_default_get_caps does. If we don't do this then it's not
possible to use CoglGstVideoSink with GstParse because that tries to
link the pipeline after parsing the string. That was previously
causing a critical error because the freshly parsed sink doesn't have
a CoglContext.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Lionel Landwerlin <llandwerlin@gmail.com>
(cherry picked from commit cf26da2964e372c9fe5bd6da060a57006a83af38)
2014-01-31 12:42:03 +00:00
Neil Roberts
23044a1047 cogl-gst: video-sink: add NV12 support
This adds a cogl-gst renderer to decode NV12 data. NV12 is split into
two buffers, one for the luma component and another for the two
chrominance components at a quarter of the resolution. The second
buffer is uploaded to a two-component RG texture. RG-component
textures are only supported if COGL_FEATURE_ID_TEXTURE_RG is
advertised by Cogl so the NV12 cap is also only advertised when that
is available.

Based on a patch by Lionel Landwerlin which was in turn based on a
patch from Edward Hervey and Matthieu Bouron for Clutter-Gst:

https://bugzilla.gnome.org/show_bug.cgi?id=712832

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Lionel Landwerlin <llandwerlin@gmail.com>
(cherry picked from commit 2c619216964b46aab313be3ef1c405dfc720d258)
2014-01-31 12:42:03 +00:00
Neil Roberts
2543a86ba1 cogl-gst-video-sink: Premultiply the colors coming from the video
Commit 99a53c82e9ab0a1e5 removed the internal format argument when
uploading a video frame to a texture so that the format will just be
determined automatically from the image format. However this also
leaves the premultiplied state at the default and the default is TRUE.
That means that when we upload RGBA data Cogl will do a premultiplied
conversion on the CPU. We probably don't want to be putting a CPU
conversion in the way of video frames so this patch changes it to set
the premultiplied state to FALSE on the textures and then do the
premultiplied conversion in the shader.

This is particularly important for AYUV which uses the alpha channel
for the V component so doing a premultiplied conversion on the CPU
just creates garbage and messes up the image.

The RGB and RGBA renderers have each been split into two; one that
uses GLSL and one that uses a regular pipeline. The RGBA pipeline
without GLSL is then changed to use 2 layers so we that we can do the
premultiplied conversion in the second layer with a special layer
combine string.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 07a57f26596c72507035369c90ed6d62568330b5)
2014-01-31 12:42:03 +00:00
Lionel Landwerlin
5227853e10 cogl-gst: video-sink: fix not installed rgb shader
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 07114acc40406e3e0fa79ae6195836d56397fdfa)
2014-01-22 13:05:50 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Robert Bragg
9a879a7616 cogl-gst: video-sink: fix YV12/I420 support
This fixes a mistake in commit 637728dd89d51bc28 that was meant to fix
yv12/i420 support but when the patch was updated based on review to use
COGL_PIXEL_FORMAT_A instead of COGL_PIXEL_FORMAT_G the corresponding
glsl code wasn't also updated to sample the .a component.

(cherry picked from commit a02c55105c705471866df2d306879d8616289f2a)
2014-01-01 17:56:46 +00:00
Lionel Landwerlin
7dcdf4dfd6 cogl-gst: video-sink: fix ayuv pipeline setup 2013-12-11 10:49:36 +00:00
Lionel Landwerlin
6101360304 cogl-gst: video-sink: fix YV12/I420 support 2013-12-11 10:47:38 +00:00
Robert Bragg
6436cd073d Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
2013-11-27 19:33:44 +00:00
Lionel Landwerlin
69247c10f3 cogl-gst: emit ready signal on sink only after the first frame is uploaded
Developers listening to the 'ready' signal on CoglGstVideoSink might
call process the current frame once the signal is triggered. We need
to ensure the first frame has been uploaded before letting people know
that the sink is ready.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 53882aa0728c5540d8452045006a763e29d4306d)
2013-08-19 22:44:45 +01:00
Robert Bragg
1255d178e0 gst: don't use cogl_texture_new_with_data
This updates cogl-gst to use cogl_texture_2d_new_with_data instead of
cogl_texture_new_with_data in preparation for removing the automagic
apis in cogl-auto-texture.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d3af8dc9bf6c4c1b09a4f7559b0375f848368c10)

Conflicts:
	cogl-gst/cogl-gst-video-sink.c
2013-07-29 16:59:15 +01:00
Robert Bragg
4d5af45d99 cogl-gst: adds _sink_is_ready() api
This adds a cogl_gst_video_sink_is_ready() for code to be able to
check if it's safe to call cogl_gst_video_sink_get_pipeline() or
cogl_gst_video_sink_setup_pipeline() without causing an error.
Normally an application can listen for the pipeline-ready signal but
sometimes a sink can be passed between components that didn't have an
opportunity to connect a signal handler, so they need a way to
directly check the status.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 9e7db391a87beee7c448f2a67b3e7202779ce9b2)
2013-07-25 16:46:18 +01:00
Lionel Landwerlin
6cc9074cfb cogl-gst: move initialization code so CoglGstVideoSink can be subclassed
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 2f6068cb6783edf6e05d6e55e9700e22f31cb233)
2013-07-09 22:52:49 +01:00
Lionel Landwerlin
86cd26b67c cogl-gst: protect public API using type checks
(cherry picked from commit 9a8c6536088368060a85f74d082c3dd8487b877c)
2013-07-09 13:32:16 +01:00
Robert Bragg
5faed43f29 cogl-gst: expose aspect ratio apis
This adds several utility apis that aim to make it as easy as possible
for an application to determine what size a video should be drawn at.

The important detail here is that these apis take into account the
pixel-aspect-ratio in addition to the video's own aspect ratio.

This patch updates the cogl-basic-video-player example to use the
cogl_gst_video_sink_fit_size() api to perform letterboxing.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d26f17c97ff6b9f6d6211e0527d5965a85305a56)
2013-06-21 19:06:59 +01:00
Neil Roberts
ee559d4e93 cogl-gst: Remove the return value from attach_frame()
Previously cogl_gst_video_sink_attach_frame returned the last layer
used by the sink. This can also be retrieved via
cogl_gst_video_sink_get_free_layer so I don't think it's necessary to
return it here and it seems kind of out of place.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 0805f3e9db715fc2c97b7e60d4f3a25e7fa598fc)
2013-06-21 19:05:36 +01:00
Neil Roberts
735bf63063 cogl-gst: Move the PARAM macros into the C file
These are just internal convenience macros to define the GObject
properties so they shouldn't be in the public headers.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit b7b861aa87ad05a2c253afdd87323acd82fd988f)
2013-06-21 19:05:16 +01:00
Plamena Manolova
282505ba99 cogl-gst: Add a functions to facilitate layering
These functions are used when attaching frames at a start point other
than layer 0 is required. This could potentially be used to "layer"
videos and textures on top of each other in the CoglPipeline. This
layering could come handy if videos are used as alpha masks or normal
maps, or when arranging layers in a perticular order, so Cogl could
blend them nicely without extra hassle.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f98b437c9ea79f04ef1ebbb6ff547f58b49b0008)
2013-06-21 19:03:04 +01:00
Neil Roberts
4eb9987699 cogl-gst: Don't replace previous layers in default shader
Previously, when CoglGST generated the default sampling snippet it
would set the replace string so that Cogl wouldn't generate any
redundant code for the other layers. However this also meant that it
wouldn't modulate with the default colour. This patch changes it to
set the combine mode on all of the layers to REPLACE(PREVIOUS) so that
it just copies the previous layer without generating any texture
sampling. That way the fragment snippet for the final layer can just
modulate the previous value with the video sampling function. This
makes it possible to set a color on the pipeline and have it modulate
the video. Also if we eventually add a way to insert layers before the
GST sampling layer then it can modulate with those.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f5da8d2caf4b2fbaf6941642a5d5ea7b93d0dd0f)
2013-06-21 19:02:35 +01:00
Neil Roberts
e46ad9a91e cogl-gst: Use alpha textures instead of luminance textures
Luminance textures are not supported on GL3 and as the textures are
accessed via a shader anyway it doesn't seem like it should make much
difference which component the single-component textures are in. Cogl
already has code to fake alpha textures via the texture swizzle
extension on GL3.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ca1666860a325fa4d2362cdd38297d6281e997d8)
2013-06-21 19:01:56 +01:00
Neil Roberts
7acdf0114e cogl-gst: More pedantic style fixes
• Fixes some overly long lines, hugging asterisks in the pointer type
  declarations and indentation issues.

• Tidies up the GLSL source so that it will look nicer in the
  debug output.

• Removes the backwards ‘parent_class’ define which hacks the
  implementation of the G_DEFINE_TYPE macro and just uses the full
  type name instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3ffe8979da4d4dc7deb221e5653b6f24f41b412c)
2013-06-21 19:00:15 +01:00
Robert Bragg
595a06e415 cogl-gst: remove experimental "HW Decode" code
The experimental HW decode path was adapted from clutter-gst based on
some experimental gstreamer api. This path was disabled by upstream
gstreamer developers back in september last year due to instabilities.
Without understanding how the experimental api is implemented it seems
rather strange to be plucking out the GL handle of a cogl texture and
passing that to some unknown gstreamer code which would presumably
somehow have to use the same GL context as Cogl to be able to do
something with that texture. For now we can strip all of this unused
code and it would be easy enough to re-instate later if it's useful.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2a24cb9f2a283af87bb685b3e9c7e3af1ffeab6e)
2013-06-21 18:59:09 +01:00
Plamena Manolova
1eca1631a7 Include CoglGst
CoglGst is a GStreamer integration library that facilitates
video playback using the Cogl API. It works by retrieving
each video frame from the GStreamer pipeline and attaching
it to a Cogl pipeline in the form of a Cogl texture along
with possible color model conversion shaders. The pipeline
is then retrieved by the user during each draw. An example
use of the CoglGst API is included in the examples directory.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit dfb94cf4b0b6b42d6465df362a0c0af780596890)
2013-06-21 18:57:24 +01:00