├── .gitignore ├── .gitlab-ci.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── NEWS ├── README ├── RELEASE ├── config ├── bellagio │ ├── gstomx.conf │ └── meson.build ├── meson.build ├── rpi │ ├── gstomx.conf │ └── meson.build ├── tizonia │ ├── gstomx.conf.in │ └── meson.build └── zynqultrascaleplus │ ├── gstomx.conf │ └── meson.build ├── docs ├── gst_plugins_cache.json ├── index.md ├── meson.build └── sitemap.txt ├── examples ├── egl │ ├── cube_texture_and_coords.h │ ├── meson.build │ └── testegl.c └── meson.build ├── gst-omx.doap ├── hooks └── pre-commit.hook ├── meson.build ├── meson_options.txt ├── omx ├── gstomx.c ├── gstomx.h ├── gstomxaacdec.c ├── gstomxaacdec.h ├── gstomxaacenc.c ├── gstomxaacenc.h ├── gstomxallocator.c ├── gstomxallocator.h ├── gstomxamrdec.c ├── gstomxamrdec.h ├── gstomxanalogaudiosink.c ├── gstomxanalogaudiosink.h ├── gstomxaudiodec.c ├── gstomxaudiodec.h ├── gstomxaudioenc.c ├── gstomxaudioenc.h ├── gstomxaudiosink.c ├── gstomxaudiosink.h ├── gstomxbufferpool.c ├── gstomxbufferpool.h ├── gstomxh263dec.c ├── gstomxh263dec.h ├── gstomxh263enc.c ├── gstomxh263enc.h ├── gstomxh264dec.c ├── gstomxh264dec.h ├── gstomxh264enc.c ├── gstomxh264enc.h ├── gstomxh264utils.c ├── gstomxh264utils.h ├── gstomxh265dec.c ├── gstomxh265dec.h ├── gstomxh265enc.c ├── gstomxh265enc.h ├── gstomxh265utils.c ├── gstomxh265utils.h ├── gstomxhdmiaudiosink.c ├── gstomxhdmiaudiosink.h ├── gstomxmjpegdec.c ├── gstomxmjpegdec.h ├── gstomxmp3dec.c ├── gstomxmp3dec.h ├── gstomxmp3enc.c ├── gstomxmp3enc.h ├── gstomxmpeg2videodec.c ├── gstomxmpeg2videodec.h ├── gstomxmpeg4videodec.c ├── gstomxmpeg4videodec.h ├── gstomxmpeg4videoenc.c ├── gstomxmpeg4videoenc.h ├── gstomxtheoradec.c ├── gstomxtheoradec.h ├── gstomxvideo.c ├── gstomxvideo.h ├── gstomxvideodec.c ├── gstomxvideodec.h ├── gstomxvideoenc.c ├── gstomxvideoenc.h ├── gstomxvp8dec.c ├── gstomxvp8dec.h ├── gstomxwmvdec.c ├── gstomxwmvdec.h ├── meson.build └── openmax │ ├── OMX_Audio.h │ ├── OMX_Component.h │ ├── OMX_ComponentExt.h │ ├── OMX_ContentPipe.h │ ├── OMX_Core.h │ ├── OMX_CoreExt.h │ ├── OMX_IVCommon.h │ ├── OMX_Image.h │ ├── OMX_Index.h │ ├── OMX_IndexExt.h │ ├── OMX_Other.h │ ├── OMX_Types.h │ ├── OMX_Video.h │ └── OMX_VideoExt.h ├── scripts └── extract-release-date-from-doap-file.py ├── tests ├── check │ ├── generic │ │ └── states.c │ └── meson.build └── meson.build └── tools ├── listcomponents.c └── meson.build /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.bak 3 | *.swp 4 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/master/gitlab/ci_template.yml" 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Sebastian Dröge 2 | 3 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | GStreamer OpenMAX IL wrapper plugin 2 | -------------------------- 3 | 4 | This plugin wraps available OpenMAX IL components and makes 5 | them available as standard GStreamer elements. 6 | 7 | License: 8 | -------- 9 | 10 | This package and its contents are licensend under the GNU Lesser General 11 | Public License (LGPL). 12 | 13 | Dependencies: 14 | ------------- 15 | 16 | * GStreamer core 17 | * gst-plugins-base 18 | -------------------------------------------------------------------------------- /RELEASE: -------------------------------------------------------------------------------- 1 | This is GStreamer gst-omx 1.19.2. 2 | 3 | GStreamer 1.19 is the development branch leading up to the next major 4 | stable version which will be 1.20. 5 | 6 | The 1.19 development series adds new features on top of the 1.18 series and is 7 | part of the API and ABI-stable 1.x release series of the GStreamer multimedia 8 | framework. 9 | 10 | Full release notes will one day be found at: 11 | 12 | https://gstreamer.freedesktop.org/releases/1.20/ 13 | 14 | Binaries for Android, iOS, Mac OS X and Windows will usually be provided 15 | shortly after the release. 16 | 17 | This module will not be very useful by itself and should be used in conjunction 18 | with other GStreamer modules for a complete multimedia experience. 19 | 20 | - gstreamer: provides the core GStreamer libraries and some generic plugins 21 | 22 | - gst-plugins-base: a basic set of well-supported plugins and additional 23 | media-specific GStreamer helper libraries for audio, 24 | video, rtsp, rtp, tags, OpenGL, etc. 25 | 26 | - gst-plugins-good: a set of well-supported plugins under our preferred 27 | license 28 | 29 | - gst-plugins-ugly: a set of well-supported plugins which might pose 30 | problems for distributors 31 | 32 | - gst-plugins-bad: a set of plugins of varying quality that have not made 33 | their way into one of core/base/good/ugly yet, for one 34 | reason or another. Many of these are are production quality 35 | elements, but may still be missing documentation or unit 36 | tests; others haven't passed the rigorous quality testing 37 | we expect yet. 38 | 39 | - gst-libav: a set of codecs plugins based on the ffmpeg library. This is 40 | where you can find audio and video decoders and encoders 41 | for a wide variety of formats including H.264, AAC, etc. 42 | 43 | - gstreamer-vaapi: hardware-accelerated video decoding and encoding using 44 | VA-API on Linux. Primarily for Intel graphics hardware. 45 | 46 | - gst-omx: hardware-accelerated video decoding and encoding, primarily for 47 | embedded Linux systems that provide an OpenMax 48 | implementation layer such as the Raspberry Pi. 49 | 50 | - gst-rtsp-server: library to serve files or streaming pipelines via RTSP 51 | 52 | - gst-editing-services: library an plugins for non-linear editing 53 | 54 | ==== Download ==== 55 | 56 | You can find source releases of gstreamer in the download 57 | directory: https://gstreamer.freedesktop.org/src/gstreamer/ 58 | 59 | The git repository and details how to clone it can be found at 60 | https://gitlab.freedesktop.org/gstreamer/ 61 | 62 | ==== Homepage ==== 63 | 64 | The project's website is https://gstreamer.freedesktop.org/ 65 | 66 | ==== Support and Bugs ==== 67 | 68 | We have recently moved from GNOME Bugzilla to GitLab on freedesktop.org 69 | for bug reports and feature requests: 70 | 71 | https://gitlab.freedesktop.org/gstreamer 72 | 73 | Please submit patches via GitLab as well, in form of Merge Requests. See 74 | 75 | https://gstreamer.freedesktop.org/documentation/contribute/ 76 | 77 | for more details. 78 | 79 | For help and support, please subscribe to and send questions to the 80 | gstreamer-devel mailing list (see below for details). 81 | 82 | There is also a #gstreamer IRC channel on the Freenode IRC network. 83 | 84 | ==== Developers ==== 85 | 86 | GStreamer source code repositories can be found on GitLab on freedesktop.org: 87 | 88 | https://gitlab.freedesktop.org/gstreamer 89 | 90 | and can also be cloned from there and this is also where you can submit 91 | Merge Requests or file issues for bugs or feature requests. 92 | 93 | Interested developers of the core library, plugins, and applications should 94 | subscribe to the gstreamer-devel list: 95 | 96 | https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel 97 | -------------------------------------------------------------------------------- /config/bellagio/gstomx.conf: -------------------------------------------------------------------------------- 1 | [omxmpeg4videodec] 2 | type-name=GstOMXMPEG4VideoDec 3 | core-name=/usr/local/lib/libomxil-bellagio.so.0 4 | component-name=OMX.st.video_decoder.mpeg4 5 | rank=257 6 | in-port-index=0 7 | out-port-index=1 8 | hacks=event-port-settings-changed-ndata-parameter-swap;event-port-settings-changed-port-0-to-1 9 | 10 | [omxh264dec] 11 | type-name=GstOMXH264Dec 12 | core-name=/usr/local/lib/libomxil-bellagio.so.0 13 | component-name=OMX.st.video_decoder.avc 14 | rank=257 15 | in-port-index=0 16 | out-port-index=1 17 | hacks=event-port-settings-changed-ndata-parameter-swap;event-port-settings-changed-port-0-to-1 18 | 19 | [omxmpeg4videoenc] 20 | type-name=GstOMXMPEG4VideoEnc 21 | core-name=/usr/local/lib/libomxil-bellagio.so.0 22 | component-name=OMX.st.video_encoder.mpeg4 23 | rank=0 24 | in-port-index=0 25 | out-port-index=1 26 | hacks=event-port-settings-changed-ndata-parameter-swap;video-framerate-integer;syncframe-flag-not-used 27 | 28 | [omxaacenc] 29 | type-name=GstOMXAACEnc 30 | core-name=/usr/local/lib/libomxil-bellagio.so.0 31 | component-name=OMX.st.audio_encoder.aac 32 | rank=0 33 | in-port-index=0 34 | out-port-index=1 35 | hacks=event-port-settings-changed-ndata-parameter-swap 36 | 37 | [omxmp3dec] 38 | type-name=GstOMXMP3Dec 39 | core-name=/usr/lib/libomxil-bellagio.so.0 40 | component-name=OMX.st.audio_decoder.mp3.mad 41 | rank=0 42 | in-port-index=0 43 | out-port-index=1 44 | hacks=event-port-settings-changed-ndata-parameter-swap;no-component-role;no-disable-outport;drain-may-not-return 45 | 46 | [omxh264dec] 47 | type-name=GstOMXH264Dec 48 | core-name=/usr/lib/libomxil-bellagio.so.0 49 | component-name=OMX.mesa.video_decoder.avc 50 | rank=0 51 | in-port-index=0 52 | out-port-index=1 53 | 54 | [omxmpeg2dec] 55 | type-name=GstOMXMPEG2VideoDec 56 | core-name=/usr/lib/libomxil-bellagio.so.0 57 | component-name=OMX.mesa.video_decoder.mpeg2 58 | rank=0 59 | in-port-index=0 60 | out-port-index=1 61 | -------------------------------------------------------------------------------- /config/bellagio/meson.build: -------------------------------------------------------------------------------- 1 | install_data (['gstomx.conf'], install_dir : omx_conf_dir) 2 | -------------------------------------------------------------------------------- /config/meson.build: -------------------------------------------------------------------------------- 1 | if omx_target == 'rpi' 2 | sub = 'rpi' 3 | elif omx_target == 'bellagio' 4 | sub = 'bellagio' 5 | elif omx_target == 'zynqultrascaleplus' 6 | sub = 'zynqultrascaleplus' 7 | elif omx_target == 'tizonia' 8 | sub = 'tizonia' 9 | else 10 | # No config file defined for the 'generic' target 11 | sub = '' 12 | endif 13 | 14 | if sub != '' 15 | subdir (sub) 16 | # Used by tests to load the proper conf file 17 | omx_config_dir = join_paths (meson.current_source_dir(), sub) 18 | else 19 | omx_config_dir = '' 20 | endif 21 | -------------------------------------------------------------------------------- /config/rpi/gstomx.conf: -------------------------------------------------------------------------------- 1 | [omxmpeg2videodec] 2 | type-name=GstOMXMPEG2VideoDec 3 | core-name=/opt/vc/lib/libopenmaxil.so 4 | component-name=OMX.broadcom.video_decode 5 | rank=257 6 | in-port-index=130 7 | out-port-index=131 8 | hacks=no-component-role 9 | 10 | [omxmpeg4videodec] 11 | type-name=GstOMXMPEG4VideoDec 12 | core-name=/opt/vc/lib/libopenmaxil.so 13 | component-name=OMX.broadcom.video_decode 14 | rank=257 15 | in-port-index=130 16 | out-port-index=131 17 | hacks=no-component-role 18 | 19 | [omxh263dec] 20 | type-name=GstOMXH263Dec 21 | core-name=/opt/vc/lib/libopenmaxil.so 22 | component-name=OMX.broadcom.video_decode 23 | rank=257 24 | in-port-index=130 25 | out-port-index=131 26 | hacks=no-component-role 27 | 28 | [omxh264dec] 29 | type-name=GstOMXH264Dec 30 | core-name=/opt/vc/lib/libopenmaxil.so 31 | component-name=OMX.broadcom.video_decode 32 | rank=257 33 | in-port-index=130 34 | out-port-index=131 35 | hacks=no-component-role;signals-premature-eos 36 | 37 | [omxtheoradec] 38 | type-name=GstOMXTheoraDec 39 | core-name=/opt/vc/lib/libopenmaxil.so 40 | component-name=OMX.broadcom.video_decode 41 | rank=257 42 | in-port-index=130 43 | out-port-index=131 44 | hacks=no-component-role 45 | 46 | [omxvp8dec] 47 | type-name=GstOMXVP8Dec 48 | core-name=/opt/vc/lib/libopenmaxil.so 49 | component-name=OMX.broadcom.video_decode 50 | rank=257 51 | in-port-index=130 52 | out-port-index=131 53 | hacks=no-component-role 54 | 55 | [omxmjpegdec] 56 | type-name=GstOMXMJPEGDec 57 | core-name=/opt/vc/lib/libopenmaxil.so 58 | component-name=OMX.broadcom.video_decode 59 | rank=257 60 | in-port-index=130 61 | out-port-index=131 62 | hacks=no-component-role 63 | 64 | [omxvc1dec] 65 | type-name=GstOMXWMVDec 66 | core-name=/opt/vc/lib/libopenmaxil.so 67 | component-name=OMX.broadcom.video_decode 68 | rank=257 69 | in-port-index=130 70 | out-port-index=131 71 | hacks=no-component-role 72 | sink-template-caps=video/x-wmv,wmvversion=(int)3,format=(string){WMV3,WVC1},width=(int)[1,MAX],height=(int)[1,MAX] 73 | 74 | [omxh264enc] 75 | type-name=GstOMXH264Enc 76 | core-name=/opt/vc/lib/libopenmaxil.so 77 | component-name=OMX.broadcom.video_encode 78 | rank=257 79 | in-port-index=200 80 | out-port-index=201 81 | hacks=no-component-role;no-component-reconfigure 82 | 83 | [omxanalogaudiosink] 84 | type-name=GstOMXAnalogAudioSink 85 | core-name=/opt/vc/lib/libopenmaxil.so 86 | component-name=OMX.broadcom.audio_render 87 | rank=257 88 | in-port-index=100 89 | out-port-index=101 90 | hacks=no-component-role 91 | sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,2] 92 | 93 | [omxhdmiaudiosink] 94 | type-name=GstOMXHdmiAudioSink 95 | core-name=/opt/vc/lib/libopenmaxil.so 96 | component-name=OMX.broadcom.audio_render 97 | rank=258 98 | in-port-index=100 99 | out-port-index=101 100 | hacks=no-component-role 101 | sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000},channels=(int)[1,8];audio/x-ac3,framed=(boolean)true;audio/x-dts,framed=(boolean)true,block-size=(int){512,1024,2048} 102 | 103 | -------------------------------------------------------------------------------- /config/rpi/meson.build: -------------------------------------------------------------------------------- 1 | install_data (['gstomx.conf'], install_dir : omx_conf_dir) 2 | -------------------------------------------------------------------------------- /config/tizonia/gstomx.conf.in: -------------------------------------------------------------------------------- 1 | [omxmp3dec] 2 | type-name=GstOMXMP3Dec 3 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 4 | component-name=OMX.Aratelia.audio_decoder.mp3 5 | rank=0 6 | in-port-index=0 7 | out-port-index=1 8 | 9 | [omxmp3enc] 10 | type-name=GstOMXMP3Enc 11 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 12 | component-name=OMX.Aratelia.audio_encoder.mp3 13 | rank=0 14 | in-port-index=0 15 | out-port-index=1 16 | 17 | [omxaacdec] 18 | type-name=GstOMXAACDec 19 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 20 | component-name=OMX.Aratelia.audio_decoder.aac 21 | rank=0 22 | in-port-index=0 23 | out-port-index=1 24 | 25 | [omxvp8dec] 26 | type-name=GstOMXVP8Dec 27 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 28 | component-name=OMX.Aratelia.video_decoder.vp8 29 | rank=0 30 | in-port-index=0 31 | out-port-index=1 32 | 33 | [omxh264dec] 34 | type-name=GstOMXH264Dec 35 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 36 | component-name=OMX.mesa.video.all 37 | component-role=video_decoder.avc 38 | rank=0 39 | in-port-index=0 40 | out-port-index=1 41 | 42 | [omxh264enc] 43 | type-name=GstOMXH264Enc 44 | core-name=@TIZONIA_LIBDIR@/libtizcore.so 45 | component-name=OMX.mesa.video.all 46 | component-role=video_encoder.avc 47 | rank=0 48 | in-port-index=0 49 | out-port-index=1 50 | -------------------------------------------------------------------------------- /config/tizonia/meson.build: -------------------------------------------------------------------------------- 1 | tizonia_cdata = cdata 2 | configure_file(input : 'gstomx.conf.in', 3 | output : 'gstomx.conf', 4 | configuration : tizonia_cdata, 5 | install_dir : omx_conf_dir) 6 | -------------------------------------------------------------------------------- /config/zynqultrascaleplus/gstomx.conf: -------------------------------------------------------------------------------- 1 | [omxh264enc] 2 | type-name=GstOMXH264Enc 3 | core-name=/usr/lib/libOMX.allegro.core.so.1 4 | component-name=OMX.allegro.h264.encoder 5 | in-port-index=0 6 | out-port-index=1 7 | rank=257 8 | hacks=ensure-buffer-count-actual 9 | 10 | [omxh264dec] 11 | type-name=GstOMXH264Dec 12 | core-name=/usr/lib/libOMX.allegro.core.so.1 13 | component-name=OMX.allegro.h264.decoder 14 | in-port-index=0 15 | out-port-index=1 16 | rank=257 17 | hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual 18 | 19 | [omxh265enc] 20 | type-name=GstOMXH265Enc 21 | core-name=/usr/lib/libOMX.allegro.core.so.1 22 | component-name=OMX.allegro.h265.encoder 23 | in-port-index=0 24 | out-port-index=1 25 | rank=257 26 | hacks=ensure-buffer-count-actual 27 | 28 | [omxh265dec] 29 | type-name=GstOMXH265Dec 30 | core-name=/usr/lib/libOMX.allegro.core.so.1 31 | component-name=OMX.allegro.h265.decoder 32 | in-port-index=0 33 | out-port-index=1 34 | rank=257 35 | hacks=pass-profile-to-decoder;pass-color-format-to-decoder;ensure-buffer-count-actual 36 | -------------------------------------------------------------------------------- /config/zynqultrascaleplus/meson.build: -------------------------------------------------------------------------------- 1 | install_data (['gstomx.conf'], install_dir : omx_conf_dir) 2 | -------------------------------------------------------------------------------- /docs/gst_plugins_cache.json: -------------------------------------------------------------------------------- 1 | { 2 | "omx": { 3 | "description": "GStreamer OpenMAX Plug-ins", 4 | "elements": {}, 5 | "filename": "gstomx", 6 | "license": "LGPL", 7 | "other-types": {}, 8 | "package": "GStreamer OpenMAX Plug-ins", 9 | "source": "gst-omx", 10 | "tracers": {}, 11 | "url": "Unknown package origin" 12 | } 13 | } -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | short-description: GStreamer plugins from OpenMax 3 | ... -------------------------------------------------------------------------------- /docs/meson.build: -------------------------------------------------------------------------------- 1 | build_hotdoc = false 2 | 3 | if meson.is_cross_build() 4 | if get_option('doc').enabled() 5 | error('Documentation enabled but building the doc while cross building is not supported yet.') 6 | endif 7 | 8 | message('Documentation not built as building the docmentation while cross building is not supported yet.') 9 | subdir_done() 10 | endif 11 | 12 | required_hotdoc_extensions = ['gst-extension'] 13 | if gst_dep.type_name() == 'internal' 14 | gst_proj = subproject('gstreamer') 15 | plugins_cache_generator = gst_proj.get_variable('plugins_cache_generator') 16 | else 17 | required_hotdoc_extensions += ['gst-extension'] 18 | plugins_cache_generator = find_program(join_paths(gst_dep.get_pkgconfig_variable('libexecdir'), 'gstreamer-' + api_version, 'gst-plugins-doc-cache-generator'), 19 | required: false) 20 | endif 21 | 22 | plugins_cache = join_paths(meson.current_source_dir(), 'gst_plugins_cache.json') 23 | if plugins_cache_generator.found() 24 | plugins_doc_dep = custom_target('omx-plugins-doc-cache', 25 | command: [plugins_cache_generator, plugins_cache, '@OUTPUT@', '@INPUT@'], 26 | input: plugins, 27 | output: 'gst_plugins_cache.json', 28 | ) 29 | else 30 | warning('GStreamer plugin inspector for documentation not found, can\'t update the cache') 31 | endif 32 | 33 | hotdoc_p = find_program('hotdoc', required: get_option('doc')) 34 | if not hotdoc_p.found() 35 | message('Hotdoc not found, not building the documentation') 36 | subdir_done() 37 | endif 38 | 39 | build_hotdoc = true 40 | hotdoc = import('hotdoc') 41 | if not hotdoc.has_extensions(required_hotdoc_extensions) 42 | if get_option('doc').enabled() 43 | error('Documentation enabled but gi-extension missing') 44 | endif 45 | 46 | message('@0@ extensions not found, not building documentation'.format(required_hotdoc_extensions)) 47 | subdir_done() 48 | endif 49 | 50 | message('Plugins: @0@'.format(plugins)) 51 | libs_doc = [] 52 | plugins_doc = [hotdoc.generate_doc('omx', 53 | project_version: api_version, 54 | sitemap: 'sitemap.txt', 55 | index: 'index.md', 56 | gst_index: 'index.md', 57 | gst_smart_index: true, 58 | gst_c_sources: ['../gst/*/*.[ch]',], 59 | gst_cache_file: plugins_cache, 60 | gst_plugin_name: 'omx', 61 | dependencies: [gstomx], 62 | )] 63 | -------------------------------------------------------------------------------- /docs/sitemap.txt: -------------------------------------------------------------------------------- 1 | gst-index 2 | -------------------------------------------------------------------------------- /examples/egl/cube_texture_and_coords.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Broadcom Europe Ltd 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // Spatial coordinates for the cube 29 | 30 | static const GLfloat quadx[6*4*3] = { 31 | /* FRONT */ 32 | -1.f, -1.f, 1.f, 33 | 1.f, -1.f, 1.f, 34 | -1.f, 1.f, 1.f, 35 | 1.f, 1.f, 1.f, 36 | 37 | /* BACK */ 38 | -1.f, -1.f, -1.f, 39 | -1.f, 1.f, -1.f, 40 | 1.f, -1.f, -1.f, 41 | 1.f, 1.f, -1.f, 42 | 43 | /* LEFT */ 44 | -1.f, -1.f, 1.f, 45 | -1.f, 1.f, 1.f, 46 | -1.f, -1.f, -1.f, 47 | -1.f, 1.f, -1.f, 48 | 49 | /* RIGHT */ 50 | 1.f, -1.f, -1.f, 51 | 1.f, 1.f, -1.f, 52 | 1.f, -1.f, 1.f, 53 | 1.f, 1.f, 1.f, 54 | 55 | /* TOP */ 56 | -1.f, 1.f, 1.f, 57 | 1.f, 1.f, 1.f, 58 | -1.f, 1.f, -1.f, 59 | 1.f, 1.f, -1.f, 60 | 61 | /* BOTTOM */ 62 | -1.f, -1.f, 1.f, 63 | -1.f, -1.f, -1.f, 64 | 1.f, -1.f, 1.f, 65 | 1.f, -1.f, -1.f, 66 | }; 67 | 68 | /** Texture coordinates for the quad. */ 69 | static const GLfloat texCoords[6 * 4 * 2] = { 70 | 0.f, 0.f, 71 | 1.f, 0.f, 72 | 0.f, 1.f, 73 | 1.f, 1.f, 74 | 75 | 0.f, 0.f, 76 | 1.f, 0.f, 77 | 0.f, 1.f, 78 | 1.f, 1.f, 79 | 80 | 0.f, 0.f, 81 | 1.f, 0.f, 82 | 0.f, 1.f, 83 | 1.f, 1.f, 84 | 85 | 0.f, 0.f, 86 | 1.f, 0.f, 87 | 0.f, 1.f, 88 | 1.f, 1.f, 89 | 90 | 0.f, 0.f, 91 | 1.f, 0.f, 92 | 0.f, 1.f, 93 | 1.f, 1.f, 94 | 95 | 0.f, 0.f, 96 | 1.f, 0.f, 97 | 0.f, 1.f, 98 | 1.f, 1.f, 99 | }; 100 | 101 | -------------------------------------------------------------------------------- /examples/egl/meson.build: -------------------------------------------------------------------------------- 1 | optional_deps = [] 2 | if x11_dep.found() 3 | optional_deps += x11_dep 4 | endif 5 | 6 | if x11_dep.found() or omx_target == 'rpi' 7 | egl_sources = ['testegl.c'] 8 | 9 | egl_dep = dependency('egl', required : false) 10 | if not egl_dep.found() 11 | egl_dep = cc.find_library ('EGL') 12 | endif 13 | 14 | gles2_dep = dependency('glesv2', required : false) 15 | if not gles2_dep.found() 16 | gles2_dep = cc.find_library ('GLESv2') 17 | endif 18 | 19 | if omx_target == 'rpi' 20 | brcmegl_dep = dependency('brcmegl', required : true) 21 | optional_deps += brcmegl_dep 22 | endif 23 | 24 | executable ('testegl', 25 | sources : egl_sources, 26 | c_args : gst_omx_args, 27 | include_directories : [configinc], 28 | dependencies : [libm, gst_dep, gstvideo_dep, gstgl_dep, egl_dep, 29 | gles2_dep] + optional_deps 30 | ) 31 | endif 32 | -------------------------------------------------------------------------------- /examples/meson.build: -------------------------------------------------------------------------------- 1 | if gstgl_dep.found() 2 | subdir('egl') 3 | endif 4 | -------------------------------------------------------------------------------- /hooks/pre-commit.hook: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Check that the code follows a consistant code style 4 | # 5 | 6 | # Check for existence of indent, and error out if not present. 7 | # On some *bsd systems the binary seems to be called gnunindent, 8 | # so check for that first. 9 | 10 | version=`gnuindent --version 2>/dev/null` 11 | if test "x$version" = "x"; then 12 | version=`gindent --version 2>/dev/null` 13 | if test "x$version" = "x"; then 14 | version=`indent --version 2>/dev/null` 15 | if test "x$version" = "x"; then 16 | echo "GStreamer git pre-commit hook:" 17 | echo "Did not find GNU indent, please install it before continuing." 18 | exit 1 19 | else 20 | INDENT=indent 21 | fi 22 | else 23 | INDENT=gindent 24 | fi 25 | else 26 | INDENT=gnuindent 27 | fi 28 | 29 | case `$INDENT --version` in 30 | GNU*) 31 | ;; 32 | default) 33 | echo "GStreamer git pre-commit hook:" 34 | echo "Did not find GNU indent, please install it before continuing." 35 | echo "(Found $INDENT, but it doesn't seem to be GNU indent)" 36 | exit 1 37 | ;; 38 | esac 39 | 40 | INDENT_PARAMETERS="--braces-on-if-line \ 41 | --case-brace-indentation0 \ 42 | --case-indentation2 \ 43 | --braces-after-struct-decl-line \ 44 | --line-length80 \ 45 | --no-tabs \ 46 | --cuddle-else \ 47 | --dont-line-up-parentheses \ 48 | --continuation-indentation4 \ 49 | --honour-newlines \ 50 | --tab-size8 \ 51 | --indent-level2 \ 52 | --leave-preprocessor-space" 53 | 54 | echo "--Checking style--" 55 | for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$"` ; do 56 | # nf is the temporary checkout. This makes sure we check against the 57 | # revision in the index (and not the checked out version). 58 | nf=`git checkout-index --temp ${file} | cut -f 1` 59 | newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 60 | $INDENT ${INDENT_PARAMETERS} \ 61 | $nf -o $newfile 2>> /dev/null 62 | # FIXME: Call indent twice as it tends to do line-breaks 63 | # different for every second call. 64 | $INDENT ${INDENT_PARAMETERS} \ 65 | $newfile 2>> /dev/null 66 | diff -u -p "${nf}" "${newfile}" 67 | r=$? 68 | rm "${newfile}" 69 | rm "${nf}" 70 | if [ $r != 0 ] ; then 71 | echo "=================================================================================================" 72 | echo " Code style error in: $file " 73 | echo " " 74 | echo " Please fix before committing. Don't forget to run git add before trying to commit again. " 75 | echo " If the whole file is to be committed, this should work (run from the top-level directory): " 76 | echo " " 77 | echo " gst-indent $file; git add $file; git commit" 78 | echo " " 79 | echo "=================================================================================================" 80 | exit 1 81 | fi 82 | done 83 | echo "--Checking style pass--" 84 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('header_path', type : 'string', value : '', 2 | description : 'An extra include directory to find the OpenMax headers') 3 | option('target', type : 'combo', 4 | choices : ['none', 'generic', 'rpi', 'bellagio', 'tizonia', 'zynqultrascaleplus'], value : 'none', 5 | description : 'The OMX platform to target') 6 | option('struct_packing', type : 'combo', 7 | choices : ['0', '1', '2', '4', '8'], value : '0', 8 | description : 'Force OpenMAX struct packing') 9 | 10 | # Common feature options 11 | option('examples', type : 'feature', value : 'auto', yield : true) 12 | option('tests', type : 'feature', value : 'auto', yield : true) 13 | option('tools', type : 'feature', value : 'auto', yield : true) 14 | option('doc', type : 'feature', value : 'auto', yield : true) 15 | -------------------------------------------------------------------------------- /omx/gstomxaacdec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation 7 | * version 2.1 of the License. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | */ 19 | 20 | #ifndef __GST_OMX_AAC_DEC_H__ 21 | #define __GST_OMX_AAC_DEC_H__ 22 | 23 | #include 24 | #include "gstomxaudiodec.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define GST_TYPE_OMX_AAC_DEC \ 29 | (gst_omx_aac_dec_get_type()) 30 | #define GST_OMX_AAC_DEC(obj) \ 31 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AAC_DEC,GstOMXAACDec)) 32 | #define GST_OMX_AAC_DEC_CLASS(klass) \ 33 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AAC_DEC,GstOMXAACDecClass)) 34 | #define GST_OMX_AAC_DEC_GET_CLASS(obj) \ 35 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AAC_DEC,GstOMXAACDecClass)) 36 | #define GST_IS_OMX_AAC_DEC(obj) \ 37 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AAC_DEC)) 38 | #define GST_IS_OMX_AAC_DEC_CLASS(obj) \ 39 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AAC_DEC)) 40 | 41 | typedef struct _GstOMXAACDec GstOMXAACDec; 42 | typedef struct _GstOMXAACDecClass GstOMXAACDecClass; 43 | 44 | struct _GstOMXAACDec 45 | { 46 | GstOMXAudioDec parent; 47 | gint spf; 48 | }; 49 | 50 | struct _GstOMXAACDecClass 51 | { 52 | GstOMXAudioDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_aac_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_AAC_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxaacenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_AAC_ENC_H__ 22 | #define __GST_OMX_AAC_ENC_H__ 23 | 24 | #include 25 | #include "gstomxaudioenc.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_AAC_ENC \ 30 | (gst_omx_aac_enc_get_type()) 31 | #define GST_OMX_AAC_ENC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AAC_ENC,GstOMXAACEnc)) 33 | #define GST_OMX_AAC_ENC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AAC_ENC,GstOMXAACEncClass)) 35 | #define GST_OMX_AAC_ENC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AAC_ENC,GstOMXAACEncClass)) 37 | #define GST_IS_OMX_AAC_ENC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AAC_ENC)) 39 | #define GST_IS_OMX_AAC_ENC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AAC_ENC)) 41 | 42 | typedef struct _GstOMXAACEnc GstOMXAACEnc; 43 | typedef struct _GstOMXAACEncClass GstOMXAACEncClass; 44 | 45 | struct _GstOMXAACEnc 46 | { 47 | GstOMXAudioEnc parent; 48 | 49 | /* properties */ 50 | guint bitrate; 51 | guint aac_tools; 52 | guint aac_er_tools; 53 | }; 54 | 55 | struct _GstOMXAACEncClass 56 | { 57 | GstOMXAudioEncClass parent_class; 58 | }; 59 | 60 | GType gst_omx_aac_enc_get_type (void); 61 | 62 | G_END_DECLS 63 | 64 | #endif /* __GST_OMX_AAC_ENC_H__ */ 65 | 66 | -------------------------------------------------------------------------------- /omx/gstomxallocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019, Collabora Ltd. 3 | * Author: George Kiagiadakis 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_ALLOCATOR_H__ 22 | #define __GST_OMX_ALLOCATOR_H__ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | 30 | #include "gstomx.h" 31 | 32 | G_BEGIN_DECLS 33 | 34 | #define GST_OMX_MEMORY_QUARK gst_omx_memory_quark () 35 | 36 | #define GST_TYPE_OMX_ALLOCATOR (gst_omx_allocator_get_type()) 37 | #define GST_IS_OMX_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OMX_ALLOCATOR)) 38 | #define GST_OMX_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_OMX_ALLOCATOR, GstOMXAllocator)) 39 | 40 | typedef struct _GstOMXMemory GstOMXMemory; 41 | typedef struct _GstOMXAllocator GstOMXAllocator; 42 | typedef struct _GstOMXAllocatorClass GstOMXAllocatorClass; 43 | 44 | typedef enum { 45 | GST_OMX_ALLOCATOR_FOREIGN_MEM_NONE, 46 | GST_OMX_ALLOCATOR_FOREIGN_MEM_DMABUF, 47 | GST_OMX_ALLOCATOR_FOREIGN_MEM_OTHER_POOL, 48 | } GstOMXAllocatorForeignMemMode; 49 | 50 | struct _GstOMXMemory 51 | { 52 | GstMemory mem; 53 | GstOMXBuffer *buf; 54 | 55 | /* TRUE if the memory is in use outside the allocator */ 56 | gboolean acquired; 57 | 58 | /* memory allocated from the foreign_allocator 59 | * or planted externally when using a foreign buffer pool */ 60 | GstMemory *foreign_mem; 61 | /* the original dispose function of foreign_mem */ 62 | GstMiniObjectDisposeFunction foreign_dispose; 63 | }; 64 | 65 | struct _GstOMXAllocator 66 | { 67 | GstAllocator parent; 68 | 69 | GstOMXComponent *component; 70 | GstOMXPort *port; 71 | 72 | GstOMXAllocatorForeignMemMode foreign_mode; 73 | GstAllocator *foreign_allocator; 74 | 75 | /* array of GstOMXMemory */ 76 | GPtrArray *memories; 77 | guint n_memories; 78 | 79 | guint n_outstanding; 80 | gboolean active; 81 | 82 | GMutex lock; 83 | GCond cond; 84 | }; 85 | 86 | struct _GstOMXAllocatorClass 87 | { 88 | GstAllocatorClass parent_class; 89 | }; 90 | 91 | GType gst_omx_allocator_get_type (void); 92 | 93 | GQuark gst_omx_memory_quark (void); 94 | 95 | GstOMXBuffer * gst_omx_memory_get_omx_buf (GstMemory * mem); 96 | 97 | GstOMXAllocator * gst_omx_allocator_new (GstOMXComponent * component, 98 | GstOMXPort * port); 99 | 100 | gboolean gst_omx_allocator_configure (GstOMXAllocator * allocator, guint count, 101 | GstOMXAllocatorForeignMemMode mode); 102 | gboolean gst_omx_allocator_set_active (GstOMXAllocator * allocator, 103 | gboolean active); 104 | void gst_omx_allocator_wait_inactive (GstOMXAllocator * allocator); 105 | 106 | GstFlowReturn gst_omx_allocator_acquire (GstOMXAllocator * allocator, 107 | GstMemory ** memory, gint index, GstOMXBuffer * omx_buf); 108 | 109 | GstMemory * gst_omx_allocator_allocate (GstOMXAllocator * allocator, gint index, 110 | GstMemory * foreign_mem); 111 | 112 | G_END_DECLS 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /omx/gstomxamrdec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * Copyright (C) 2014, LG Electronics, Inc. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxamrdec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_amr_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_amr_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_amr_dec_set_format (GstOMXAudioDec * dec, 34 | GstOMXPort * port, GstCaps * caps); 35 | static gboolean gst_omx_amr_dec_is_format_change (GstOMXAudioDec * dec, 36 | GstOMXPort * port, GstCaps * caps); 37 | static gint gst_omx_amr_dec_get_samples_per_frame (GstOMXAudioDec * dec, 38 | GstOMXPort * port); 39 | static gboolean gst_omx_amr_dec_get_channel_positions (GstOMXAudioDec * dec, 40 | GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]); 41 | 42 | /* class initialization */ 43 | 44 | #define DEBUG_INIT \ 45 | GST_DEBUG_CATEGORY_INIT (gst_omx_amr_dec_debug_category, "omxamrdec", 0, \ 46 | "debug category for gst-omx amr audio decoder"); 47 | 48 | G_DEFINE_TYPE_WITH_CODE (GstOMXAMRDec, gst_omx_amr_dec, 49 | GST_TYPE_OMX_AUDIO_DEC, DEBUG_INIT); 50 | 51 | static void 52 | gst_omx_amr_dec_class_init (GstOMXAMRDecClass * klass) 53 | { 54 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 55 | GstOMXAudioDecClass *audiodec_class = GST_OMX_AUDIO_DEC_CLASS (klass); 56 | 57 | audiodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_amr_dec_set_format); 58 | audiodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_amr_dec_is_format_change); 60 | audiodec_class->get_samples_per_frame = 61 | GST_DEBUG_FUNCPTR (gst_omx_amr_dec_get_samples_per_frame); 62 | audiodec_class->get_channel_positions = 63 | GST_DEBUG_FUNCPTR (gst_omx_amr_dec_get_channel_positions); 64 | 65 | audiodec_class->cdata.default_sink_template_caps = 66 | "audio/AMR, rate=(int)8000, channels=(int)1; " 67 | "audio/AMR-WB, rate=(int)16000, channels=(int)1"; 68 | 69 | gst_element_class_set_static_metadata (element_class, 70 | "OpenMAX AMR Audio Decoder", 71 | "Codec/Decoder/Audio/Hardware", 72 | "Decode AMR audio streams", 73 | "Sebastian Dröge "); 74 | 75 | gst_omx_set_default_role (&audiodec_class->cdata, "audio_decoder.amrnb"); 76 | } 77 | 78 | static void 79 | gst_omx_amr_dec_init (GstOMXAMRDec * self) 80 | { 81 | self->spf = -1; 82 | } 83 | 84 | static gboolean 85 | gst_omx_amr_dec_set_format (GstOMXAudioDec * dec, GstOMXPort * port, 86 | GstCaps * caps) 87 | { 88 | GstOMXAMRDec *self = GST_OMX_AMR_DEC (dec); 89 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 90 | OMX_AUDIO_PARAM_AMRTYPE amr_param; 91 | OMX_ERRORTYPE err; 92 | GstStructure *s; 93 | gint rate, channels; 94 | 95 | gst_omx_port_get_port_definition (port, &port_def); 96 | port_def.format.audio.eEncoding = OMX_AUDIO_CodingAMR; /* not tested for AMRWB */ 97 | err = gst_omx_port_update_port_definition (port, &port_def); 98 | if (err != OMX_ErrorNone) { 99 | GST_ERROR_OBJECT (self, 100 | "Failed to set AMR format on component: %s (0x%08x)", 101 | gst_omx_error_to_string (err), err); 102 | return FALSE; 103 | } 104 | 105 | GST_OMX_INIT_STRUCT (&amr_param); 106 | amr_param.nPortIndex = port->index; 107 | 108 | err = 109 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioAmr, 110 | &amr_param); 111 | if (err != OMX_ErrorNone) { 112 | GST_ERROR_OBJECT (self, 113 | "Failed to get AMR parameters from component: %s (0x%08x)", 114 | gst_omx_error_to_string (err), err); 115 | return FALSE; 116 | } 117 | 118 | s = gst_caps_get_structure (caps, 0); 119 | 120 | if (!gst_structure_get_int (s, "rate", &rate) || 121 | !gst_structure_get_int (s, "channels", &channels)) { 122 | GST_ERROR_OBJECT (self, "Incomplete caps"); 123 | return FALSE; 124 | } 125 | 126 | self->rate = rate; 127 | 128 | if (rate == 8000) 129 | self->spf = 160; /* (8000/50) */ 130 | else if (rate == 16000) 131 | self->spf = 320; /* (16000/50) */ 132 | 133 | amr_param.nChannels = channels; 134 | amr_param.eAMRBandMode = 0; /*FIXME: It may require a specific value */ 135 | amr_param.eAMRDTXMode = 0; 136 | amr_param.eAMRFrameFormat = 0; 137 | 138 | err = 139 | gst_omx_component_set_parameter (dec->dec, OMX_IndexParamAudioAmr, 140 | &amr_param); 141 | if (err != OMX_ErrorNone) { 142 | GST_ERROR_OBJECT (self, "Error setting AMR parameters: %s (0x%08x)", 143 | gst_omx_error_to_string (err), err); 144 | return FALSE; 145 | } 146 | 147 | return TRUE; 148 | } 149 | 150 | static gboolean 151 | gst_omx_amr_dec_is_format_change (GstOMXAudioDec * dec, GstOMXPort * port, 152 | GstCaps * caps) 153 | { 154 | GstOMXAMRDec *self = GST_OMX_AMR_DEC (dec); 155 | OMX_AUDIO_PARAM_AMRTYPE amr_param; 156 | OMX_ERRORTYPE err; 157 | GstStructure *s; 158 | gint rate, channels; 159 | 160 | GST_OMX_INIT_STRUCT (&amr_param); 161 | amr_param.nPortIndex = port->index; 162 | 163 | err = 164 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioAmr, 165 | &amr_param); 166 | if (err != OMX_ErrorNone) { 167 | GST_ERROR_OBJECT (self, 168 | "Failed to get AMR parameters from component: %s (0x%08x)", 169 | gst_omx_error_to_string (err), err); 170 | return FALSE; 171 | } 172 | 173 | s = gst_caps_get_structure (caps, 0); 174 | 175 | if (!gst_structure_get_int (s, "rate", &rate) || 176 | !gst_structure_get_int (s, "channels", &channels)) { 177 | GST_ERROR_OBJECT (self, "Incomplete caps"); 178 | return FALSE; 179 | } 180 | 181 | if (self->rate != rate) 182 | return TRUE; 183 | 184 | if (amr_param.nChannels != channels) 185 | return TRUE; 186 | 187 | return FALSE; 188 | } 189 | 190 | static gint 191 | gst_omx_amr_dec_get_samples_per_frame (GstOMXAudioDec * dec, GstOMXPort * port) 192 | { 193 | return GST_OMX_AMR_DEC (dec)->spf; 194 | } 195 | 196 | static gboolean 197 | gst_omx_amr_dec_get_channel_positions (GstOMXAudioDec * dec, 198 | GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]) 199 | { 200 | OMX_AUDIO_PARAM_PCMMODETYPE pcm_param; 201 | OMX_ERRORTYPE err; 202 | 203 | GST_OMX_INIT_STRUCT (&pcm_param); 204 | pcm_param.nPortIndex = port->index; 205 | err = 206 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioPcm, 207 | &pcm_param); 208 | if (err != OMX_ErrorNone) { 209 | GST_ERROR_OBJECT (dec, "Failed to get PCM parameters: %s (0x%08x)", 210 | gst_omx_error_to_string (err), err); 211 | return FALSE; 212 | } 213 | 214 | 215 | g_return_val_if_fail (pcm_param.nChannels == 1, FALSE); /* AMR supports only mono */ 216 | 217 | position[0] = GST_AUDIO_CHANNEL_POSITION_MONO; 218 | 219 | return TRUE; 220 | } 221 | -------------------------------------------------------------------------------- /omx/gstomxamrdec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation 7 | * version 2.1 of the License. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | */ 19 | 20 | #ifndef __GST_OMX_AMR_DEC_H__ 21 | #define __GST_OMX_AMR_DEC_H__ 22 | 23 | #include 24 | #include "gstomxaudiodec.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define GST_TYPE_OMX_AMR_DEC \ 29 | (gst_omx_amr_dec_get_type()) 30 | #define GST_OMX_AMR_DEC(obj) \ 31 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AMR_DEC,GstOMXAMRDec)) 32 | #define GST_OMX_AMR_DEC_CLASS(klass) \ 33 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AMR_DEC,GstOMXAMRDecClass)) 34 | #define GST_OMX_AMR_DEC_GET_CLASS(obj) \ 35 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AMR_DEC,GstOMXAMRDecClass)) 36 | #define GST_IS_OMX_AMR_DEC(obj) \ 37 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AMR_DEC)) 38 | #define GST_IS_OMX_AMR_DEC_CLASS(obj) \ 39 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AMR_DEC)) 40 | 41 | typedef struct _GstOMXAMRDec GstOMXAMRDec; 42 | typedef struct _GstOMXAMRDecClass GstOMXAMRDecClass; 43 | 44 | struct _GstOMXAMRDec 45 | { 46 | GstOMXAudioDec parent; 47 | gint spf; 48 | gint rate; 49 | }; 50 | 51 | struct _GstOMXAMRDecClass 52 | { 53 | GstOMXAudioDecClass parent_class; 54 | }; 55 | 56 | GType gst_omx_amr_dec_get_type (void); 57 | 58 | G_END_DECLS 59 | 60 | #endif /* __GST_OMX_AMR_DEC_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /omx/gstomxanalogaudiosink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Fluendo, S.A. 3 | * Copyright (C) 2014, Metrological Media Innovations B.V. 4 | * Author: Josep Torra 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | 28 | #include "gstomxanalogaudiosink.h" 29 | 30 | GST_DEBUG_CATEGORY_STATIC (gst_omx_analog_audio_sink_debug_category); 31 | #define GST_CAT_DEFAULT gst_omx_analog_audio_sink_debug_category 32 | 33 | /* class initialization */ 34 | 35 | #define DEBUG_INIT \ 36 | GST_DEBUG_CATEGORY_INIT (gst_omx_analog_audio_sink_debug_category, \ 37 | "omxanalogaudiosink", 0, "debug category for gst-omx analog audio sink"); 38 | 39 | G_DEFINE_TYPE_WITH_CODE (GstOMXAnalogAudioSink, gst_omx_analog_audio_sink, 40 | GST_TYPE_OMX_AUDIO_SINK, DEBUG_INIT); 41 | 42 | static void 43 | gst_omx_analog_audio_sink_class_init (GstOMXAnalogAudioSinkClass * klass) 44 | { 45 | GstOMXAudioSinkClass *audiosink_class = GST_OMX_AUDIO_SINK_CLASS (klass); 46 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 47 | 48 | audiosink_class->cdata.default_sink_template_caps = "audio/x-raw, " 49 | "format = (string) " GST_AUDIO_FORMATS_ALL ", " 50 | "layout = (string) interleaved, " 51 | "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ] "; 52 | audiosink_class->destination = "local"; 53 | 54 | gst_element_class_set_static_metadata (element_class, 55 | "OpenMAX Analog Audio Sink", 56 | "Sink/Audio", "Output analog audio", "Josep Torra "); 57 | 58 | gst_omx_set_default_role (&audiosink_class->cdata, "audio_render.local"); 59 | } 60 | 61 | static void 62 | gst_omx_analog_audio_sink_init (GstOMXAnalogAudioSink * self) 63 | { 64 | } 65 | -------------------------------------------------------------------------------- /omx/gstomxanalogaudiosink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Fluendo, S.A. 3 | * Copyright (C) 2014, Metrological Media Innovations B.V. 4 | * Author: Josep Torra 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_ANALOG_AUDIO_SINK_H__ 23 | #define __GST_OMX_ANALOG_AUDIO_SINK_H__ 24 | 25 | #include 26 | #include "gstomxaudiosink.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define GST_TYPE_OMX_ANALOG_AUDIO_SINK \ 31 | (gst_omx_analog_audio_sink_get_type()) 32 | #define GST_OMX_ANALOG_AUDIO_SINK(obj) \ 33 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSink)) 34 | #define GST_OMX_ANALOG_AUDIO_SINK_CLASS(klass) \ 35 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSinkClass)) 36 | #define GST_OMX_ANALOG_AUDIO_SINK_GET_CLASS(obj) \ 37 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSinkClass)) 38 | #define GST_IS_OMX_ANALOG_AUDIO_SINK(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK)) 40 | #define GST_IS_OMX_ANALOG_AUDIO_SINK_CLASS(obj) \ 41 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_ANALOG_AUDIO_SINK)) 42 | 43 | typedef struct _GstOMXAnalogAudioSink GstOMXAnalogAudioSink; 44 | typedef struct _GstOMXAnalogAudioSinkClass GstOMXAnalogAudioSinkClass; 45 | 46 | struct _GstOMXAnalogAudioSink 47 | { 48 | GstOMXAudioSink parent; 49 | }; 50 | 51 | struct _GstOMXAnalogAudioSinkClass 52 | { 53 | GstOMXAudioSinkClass parent_class; 54 | }; 55 | 56 | GType gst_omx_analog_audio_sink_get_type (void); 57 | 58 | G_END_DECLS 59 | 60 | #endif /* __GST_OMX_ANALOG_AUDIO_SINK_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /omx/gstomxaudiodec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation 7 | * version 2.1 of the License. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | */ 19 | 20 | #ifndef __GST_OMX_AUDIO_DEC_H__ 21 | #define __GST_OMX_AUDIO_DEC_H__ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | #include "config.h" 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "gstomx.h" 32 | 33 | G_BEGIN_DECLS 34 | 35 | #define GST_TYPE_OMX_AUDIO_DEC \ 36 | (gst_omx_audio_dec_get_type()) 37 | #define GST_OMX_AUDIO_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDec)) 39 | #define GST_OMX_AUDIO_DEC_CLASS(klass) \ 40 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDecClass)) 41 | #define GST_OMX_AUDIO_DEC_GET_CLASS(obj) \ 42 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AUDIO_DEC,GstOMXAudioDecClass)) 43 | #define GST_IS_OMX_AUDIO_DEC(obj) \ 44 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AUDIO_DEC)) 45 | #define GST_IS_OMX_AUDIO_DEC_CLASS(obj) \ 46 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AUDIO_DEC)) 47 | 48 | typedef struct _GstOMXAudioDec GstOMXAudioDec; 49 | typedef struct _GstOMXAudioDecClass GstOMXAudioDecClass; 50 | 51 | struct _GstOMXAudioDec 52 | { 53 | GstAudioDecoder parent; 54 | 55 | /* < protected > */ 56 | GstOMXComponent *dec; 57 | GstOMXPort *dec_in_port, *dec_out_port; 58 | 59 | GstBufferPool *in_port_pool, *out_port_pool; 60 | 61 | /* < private > */ 62 | GstAudioInfo info; 63 | GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]; 64 | gint reorder_map[OMX_AUDIO_MAXCHANNELS]; 65 | gboolean needs_reorder; 66 | GstBuffer *codec_data; 67 | /* TRUE if the component is configured and saw 68 | * the first buffer */ 69 | gboolean started; 70 | 71 | GstClockTime last_upstream_ts; 72 | 73 | /* Draining state */ 74 | GMutex drain_lock; 75 | GCond drain_cond; 76 | /* TRUE if EOS buffers shouldn't be forwarded */ 77 | gboolean draining; 78 | 79 | GstAdapter *output_adapter; 80 | 81 | GstFlowReturn downstream_flow_ret; 82 | }; 83 | 84 | struct _GstOMXAudioDecClass 85 | { 86 | GstAudioDecoderClass parent_class; 87 | 88 | GstOMXClassData cdata; 89 | 90 | gboolean (*is_format_change) (GstOMXAudioDec * self, GstOMXPort * port, GstCaps * caps); 91 | gboolean (*set_format) (GstOMXAudioDec * self, GstOMXPort * port, GstCaps * caps); 92 | gint (*get_samples_per_frame) (GstOMXAudioDec * self, GstOMXPort * port); 93 | gboolean (*get_channel_positions) (GstOMXAudioDec * self, GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]); 94 | }; 95 | 96 | GType gst_omx_audio_dec_get_type (void); 97 | 98 | G_END_DECLS 99 | 100 | #endif /* __GST_OMX_AUDIO_DEC_H__ */ 101 | -------------------------------------------------------------------------------- /omx/gstomxaudioenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_AUDIO_ENC_H__ 22 | #define __GST_OMX_AUDIO_ENC_H__ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "gstomx.h" 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define GST_TYPE_OMX_AUDIO_ENC \ 33 | (gst_omx_audio_enc_get_type()) 34 | #define GST_OMX_AUDIO_ENC(obj) \ 35 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AUDIO_ENC,GstOMXAudioEnc)) 36 | #define GST_OMX_AUDIO_ENC_CLASS(klass) \ 37 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AUDIO_ENC,GstOMXAudioEncClass)) 38 | #define GST_OMX_AUDIO_ENC_GET_CLASS(obj) \ 39 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AUDIO_ENC,GstOMXAudioEncClass)) 40 | #define GST_IS_OMX_AUDIO_ENC(obj) \ 41 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AUDIO_ENC)) 42 | #define GST_IS_OMX_AUDIO_ENC_CLASS(obj) \ 43 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AUDIO_ENC)) 44 | 45 | typedef struct _GstOMXAudioEnc GstOMXAudioEnc; 46 | typedef struct _GstOMXAudioEncClass GstOMXAudioEncClass; 47 | 48 | struct _GstOMXAudioEnc 49 | { 50 | GstAudioEncoder parent; 51 | 52 | /* < protected > */ 53 | GstOMXComponent *enc; 54 | GstOMXPort *enc_in_port, *enc_out_port; 55 | 56 | /* < private > */ 57 | /* TRUE if the component is configured and saw 58 | * the first buffer */ 59 | gboolean started; 60 | 61 | GstClockTime last_upstream_ts; 62 | 63 | /* Draining state */ 64 | GMutex drain_lock; 65 | GCond drain_cond; 66 | /* TRUE if EOS buffers shouldn't be forwarded */ 67 | gboolean draining; 68 | 69 | GstFlowReturn downstream_flow_ret; 70 | }; 71 | 72 | struct _GstOMXAudioEncClass 73 | { 74 | GstAudioEncoderClass parent_class; 75 | 76 | GstOMXClassData cdata; 77 | 78 | gboolean (*set_format) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info); 79 | GstCaps *(*get_caps) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info); 80 | guint (*get_num_samples) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info, GstOMXBuffer * buffer); 81 | }; 82 | 83 | GType gst_omx_audio_enc_get_type (void); 84 | 85 | G_END_DECLS 86 | 87 | #endif /* __GST_OMX_AUDIO_ENC_H__ */ 88 | -------------------------------------------------------------------------------- /omx/gstomxaudiosink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Fluendo, S.A. 3 | * Copyright (C) 2014, Metrological Media Innovations B.V. 4 | * Author: Josep Torra 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_AUDIO_SINK_H__ 23 | #define __GST_OMX_AUDIO_SINK_H__ 24 | 25 | #ifdef HAVE_CONFIG_H 26 | #include "config.h" 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #include "gstomx.h" 33 | 34 | G_BEGIN_DECLS 35 | 36 | #define GST_TYPE_OMX_AUDIO_SINK \ 37 | (gst_omx_audio_sink_get_type()) 38 | #define GST_OMX_AUDIO_SINK(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSink)) 40 | #define GST_OMX_AUDIO_SINK_CLASS(klass) \ 41 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSinkClass)) 42 | #define GST_OMX_AUDIO_SINK_GET_CLASS(obj) \ 43 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSinkClass)) 44 | #define GST_IS_OMX_AUDIO_SINK(obj) \ 45 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AUDIO_SINK)) 46 | #define GST_IS_OMX_AUDIO_SINK_CLASS(obj) \ 47 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AUDIO_SINK)) 48 | #define GST_OMX_AUDIO_SINK_CAST(obj) ((GstOMXAudioSink *) (obj)) 49 | 50 | #define GST_OMX_AUDIO_SINK_GET_LOCK(obj) (&GST_OMX_AUDIO_SINK_CAST (obj)->lock) 51 | #define GST_OMX_AUDIO_SINK_LOCK(obj) (g_mutex_lock (GST_OMX_AUDIO_SINK_GET_LOCK (obj))) 52 | #define GST_OMX_AUDIO_SINK_UNLOCK(obj) (g_mutex_unlock (GST_OMX_AUDIO_SINK_GET_LOCK (obj))) 53 | 54 | #define PASSTHROUGH_CAPS \ 55 | "audio/x-ac3, framed = (boolean) true;" \ 56 | "audio/x-eac3, framed = (boolean) true; " \ 57 | "audio/x-dts, framed = (boolean) true, " \ 58 | "block-size = (int) { 512, 1024, 2048 }; " \ 59 | "audio/mpeg, mpegversion = (int) 1, " \ 60 | "mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;" 61 | 62 | typedef struct _GstOMXAudioSink GstOMXAudioSink; 63 | typedef struct _GstOMXAudioSinkClass GstOMXAudioSinkClass; 64 | 65 | struct _GstOMXAudioSink 66 | { 67 | GstAudioSink parent; 68 | 69 | /* < protected > */ 70 | GstOMXComponent *comp; 71 | GstOMXPort *in_port, *out_port; 72 | 73 | gboolean mute; 74 | gdouble volume; 75 | 76 | gboolean iec61937; 77 | guint endianness; 78 | guint rate; 79 | guint channels; 80 | guint width; 81 | gboolean is_signed; 82 | gboolean is_float; 83 | 84 | guint buffer_size; 85 | guint samples; 86 | 87 | GMutex lock; 88 | }; 89 | 90 | struct _GstOMXAudioSinkClass 91 | { 92 | GstAudioSinkClass parent_class; 93 | 94 | GstOMXClassData cdata; 95 | const gchar * destination; 96 | }; 97 | 98 | GType gst_omx_audio_sink_get_type (void); 99 | 100 | G_END_DECLS 101 | 102 | #endif /* __GST_OMX_AUDIO_SINK_H__ */ 103 | 104 | -------------------------------------------------------------------------------- /omx/gstomxbufferpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Advanced Micro Devices, Inc. 3 | * Author: Christian König 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_BUFFER_POOL_H__ 22 | #define __GST_OMX_BUFFER_POOL_H__ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "gstomx.h" 33 | #include "gstomxallocator.h" 34 | 35 | G_BEGIN_DECLS 36 | 37 | #define GST_TYPE_OMX_BUFFER_POOL \ 38 | (gst_omx_buffer_pool_get_type()) 39 | #define GST_OMX_BUFFER_POOL(obj) \ 40 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_BUFFER_POOL,GstOMXBufferPool)) 41 | #define GST_IS_OMX_BUFFER_POOL(obj) \ 42 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_BUFFER_POOL)) 43 | 44 | typedef struct _GstOMXBufferPool GstOMXBufferPool; 45 | typedef struct _GstOMXBufferPoolClass GstOMXBufferPoolClass; 46 | 47 | typedef enum { 48 | GST_OMX_BUFFER_MODE_SYSTEM_MEMORY, 49 | GST_OMX_BUFFER_MODE_DMABUF, 50 | } GstOMXBufferMode; 51 | 52 | struct _GstOMXBufferPool 53 | { 54 | GstVideoBufferPool parent; 55 | 56 | GstElement *element; 57 | 58 | GstCaps *caps; 59 | gboolean add_videometa; 60 | gboolean need_copy; 61 | GstVideoInfo video_info; 62 | 63 | /* Owned by element, element has to stop this pool before 64 | * it destroys component or port */ 65 | GstOMXComponent *component; 66 | GstOMXPort *port; 67 | 68 | /* For handling OpenMAX allocated memory */ 69 | GstOMXAllocator *allocator; 70 | 71 | /* Set from outside this pool */ 72 | /* TRUE if the pool is not used anymore */ 73 | gboolean deactivated; 74 | 75 | /* For populating the pool from another one */ 76 | GstBufferPool *other_pool; 77 | GPtrArray *buffers; 78 | 79 | /* Used during acquire for output ports to 80 | * specify which buffer has to be retrieved 81 | * and during alloc, which buffer has to be 82 | * wrapped 83 | */ 84 | gint current_buffer_index; 85 | 86 | /* The type of buffers produced by the decoder */ 87 | GstOMXBufferMode output_mode; 88 | }; 89 | 90 | struct _GstOMXBufferPoolClass 91 | { 92 | GstVideoBufferPoolClass parent_class; 93 | }; 94 | 95 | GType gst_omx_buffer_pool_get_type (void); 96 | 97 | GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port, GstOMXBufferMode output_mode); 98 | 99 | G_END_DECLS 100 | 101 | #endif /* __GST_OMX_BUFFER_POOL_H__ */ 102 | -------------------------------------------------------------------------------- /omx/gstomxh263dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxh263dec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_h263_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_h263_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_h263_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_h263_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_h263_dec_debug_category, "omxh263dec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXH263Dec, gst_omx_h263_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | static void 53 | gst_omx_h263_dec_class_init (GstOMXH263DecClass * klass) 54 | { 55 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 56 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 57 | 58 | videodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_h263_dec_is_format_change); 60 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h263_dec_set_format); 61 | 62 | videodec_class->cdata.default_sink_template_caps = "video/x-h263, " 63 | "variant=(string) itu, " 64 | "parsed=(boolean) true, " "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 65 | 66 | gst_element_class_set_static_metadata (element_class, 67 | "OpenMAX H.263 Video Decoder", 68 | "Codec/Decoder/Video/Hardware", 69 | "Decode H.263 video streams", 70 | "Sebastian Dröge "); 71 | 72 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.h263"); 73 | } 74 | 75 | static void 76 | gst_omx_h263_dec_init (GstOMXH263Dec * self) 77 | { 78 | } 79 | 80 | static gboolean 81 | gst_omx_h263_dec_is_format_change (GstOMXVideoDec * dec, 82 | GstOMXPort * port, GstVideoCodecState * state) 83 | { 84 | return FALSE; 85 | } 86 | 87 | static gboolean 88 | gst_omx_h263_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 89 | GstVideoCodecState * state) 90 | { 91 | gboolean ret; 92 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 93 | 94 | gst_omx_port_get_port_definition (port, &port_def); 95 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; 96 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 97 | 98 | return ret; 99 | } 100 | -------------------------------------------------------------------------------- /omx/gstomxh263dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_H263_DEC_H__ 22 | #define __GST_OMX_H263_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_H263_DEC \ 30 | (gst_omx_h263_dec_get_type()) 31 | #define GST_OMX_H263_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H263_DEC,GstOMXH263Dec)) 33 | #define GST_OMX_H263_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H263_DEC,GstOMXH263DecClass)) 35 | #define GST_OMX_H263_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H263_DEC,GstOMXH263DecClass)) 37 | #define GST_IS_OMX_H263_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H263_DEC)) 39 | #define GST_IS_OMX_H263_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H263_DEC)) 41 | 42 | typedef struct _GstOMXH263Dec GstOMXH263Dec; 43 | typedef struct _GstOMXH263DecClass GstOMXH263DecClass; 44 | 45 | struct _GstOMXH263Dec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXH263DecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_h263_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_H263_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxh263enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_H263_ENC_H__ 22 | #define __GST_OMX_H263_ENC_H__ 23 | 24 | #include 25 | #include "gstomxvideoenc.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_H263_ENC \ 30 | (gst_omx_h263_enc_get_type()) 31 | #define GST_OMX_H263_ENC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H263_ENC,GstOMXH263Enc)) 33 | #define GST_OMX_H263_ENC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H263_ENC,GstOMXH263EncClass)) 35 | #define GST_OMX_H263_ENC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H263_ENC,GstOMXH263EncClass)) 37 | #define GST_IS_OMX_H263_ENC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H263_ENC)) 39 | #define GST_IS_OMX_H263_ENC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H263_ENC)) 41 | 42 | typedef struct _GstOMXH263Enc GstOMXH263Enc; 43 | typedef struct _GstOMXH263EncClass GstOMXH263EncClass; 44 | 45 | struct _GstOMXH263Enc 46 | { 47 | GstOMXVideoEnc parent; 48 | }; 49 | 50 | struct _GstOMXH263EncClass 51 | { 52 | GstOMXVideoEncClass parent_class; 53 | }; 54 | 55 | GType gst_omx_h263_enc_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_H263_ENC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxh264dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxh264dec.h" 28 | #include "gstomxh264utils.h" 29 | 30 | GST_DEBUG_CATEGORY_STATIC (gst_omx_h264_dec_debug_category); 31 | #define GST_CAT_DEFAULT gst_omx_h264_dec_debug_category 32 | 33 | /* prototypes */ 34 | static gboolean gst_omx_h264_dec_is_format_change (GstOMXVideoDec * dec, 35 | GstOMXPort * port, GstVideoCodecState * state); 36 | static gboolean gst_omx_h264_dec_set_format (GstOMXVideoDec * dec, 37 | GstOMXPort * port, GstVideoCodecState * state); 38 | 39 | enum 40 | { 41 | PROP_0 42 | }; 43 | 44 | /* class initialization */ 45 | 46 | #define DEBUG_INIT \ 47 | GST_DEBUG_CATEGORY_INIT (gst_omx_h264_dec_debug_category, "omxh264dec", 0, \ 48 | "debug category for gst-omx video decoder base class"); 49 | 50 | G_DEFINE_TYPE_WITH_CODE (GstOMXH264Dec, gst_omx_h264_dec, 51 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 52 | 53 | #define MAKE_CAPS(alignment) \ 54 | "video/x-h264, " \ 55 | "alignment=(string) " alignment ", " \ 56 | "stream-format=(string) byte-stream, " \ 57 | "width=(int) [1,MAX], height=(int) [1,MAX]" 58 | 59 | /* The Zynq supports decoding subframes, though we want "au" to be the 60 | * default, so we keep it prepended. This is the only way that it works with 61 | * rtph264depay. */ 62 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 63 | #define SINK_CAPS MAKE_CAPS ("au") ";" MAKE_CAPS ("nal") 64 | #else 65 | #define SINK_CAPS MAKE_CAPS ("au") 66 | #endif 67 | 68 | static void 69 | gst_omx_h264_dec_class_init (GstOMXH264DecClass * klass) 70 | { 71 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 72 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 73 | 74 | videodec_class->is_format_change = 75 | GST_DEBUG_FUNCPTR (gst_omx_h264_dec_is_format_change); 76 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_dec_set_format); 77 | 78 | videodec_class->cdata.default_sink_template_caps = SINK_CAPS; 79 | 80 | gst_element_class_set_static_metadata (element_class, 81 | "OpenMAX H.264 Video Decoder", 82 | "Codec/Decoder/Video/Hardware", 83 | "Decode H.264 video streams", 84 | "Sebastian Dröge "); 85 | 86 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.avc"); 87 | } 88 | 89 | static void 90 | gst_omx_h264_dec_init (GstOMXH264Dec * self) 91 | { 92 | } 93 | 94 | static gboolean 95 | gst_omx_h264_dec_is_format_change (GstOMXVideoDec * dec, 96 | GstOMXPort * port, GstVideoCodecState * state) 97 | { 98 | GstCaps *old_caps = NULL; 99 | GstCaps *new_caps = state->caps; 100 | GstStructure *old_structure, *new_structure; 101 | const gchar *old_profile, *old_level, *old_alignment, *new_profile, 102 | *new_level, *new_alignment; 103 | 104 | if (dec->input_state) { 105 | old_caps = dec->input_state->caps; 106 | } 107 | 108 | if (!old_caps) { 109 | return FALSE; 110 | } 111 | 112 | old_structure = gst_caps_get_structure (old_caps, 0); 113 | new_structure = gst_caps_get_structure (new_caps, 0); 114 | old_profile = gst_structure_get_string (old_structure, "profile"); 115 | old_level = gst_structure_get_string (old_structure, "level"); 116 | old_alignment = gst_structure_get_string (old_structure, "alignment"); 117 | new_profile = gst_structure_get_string (new_structure, "profile"); 118 | new_level = gst_structure_get_string (new_structure, "level"); 119 | new_alignment = gst_structure_get_string (new_structure, "alignment"); 120 | 121 | if (g_strcmp0 (old_profile, new_profile) != 0 122 | || g_strcmp0 (old_level, new_level) != 0 123 | || g_strcmp0 (old_alignment, new_alignment) != 0) { 124 | return TRUE; 125 | } 126 | 127 | return FALSE; 128 | } 129 | 130 | static gboolean 131 | set_profile_and_level (GstOMXH264Dec * self, GstVideoCodecState * state) 132 | { 133 | OMX_ERRORTYPE err; 134 | OMX_VIDEO_PARAM_PROFILELEVELTYPE param; 135 | const gchar *profile_string, *level_string; 136 | GstStructure *s; 137 | 138 | GST_OMX_INIT_STRUCT (¶m); 139 | param.nPortIndex = GST_OMX_VIDEO_DEC (self)->dec_in_port->index; 140 | 141 | /* Pass profile and level to the decoder if we have both info from the 142 | * caps. */ 143 | s = gst_caps_get_structure (state->caps, 0); 144 | profile_string = gst_structure_get_string (s, "profile"); 145 | if (!profile_string) 146 | return TRUE; 147 | 148 | param.eProfile = gst_omx_h264_utils_get_profile_from_str (profile_string); 149 | if (param.eProfile == OMX_VIDEO_AVCProfileMax) 150 | goto unsupported_profile; 151 | 152 | level_string = gst_structure_get_string (s, "level"); 153 | if (!level_string) 154 | return TRUE; 155 | 156 | param.eLevel = gst_omx_h264_utils_get_level_from_str (level_string); 157 | if (param.eLevel == OMX_VIDEO_AVCLevelMax) 158 | goto unsupported_level; 159 | 160 | GST_DEBUG_OBJECT (self, "Set profile (%s) and level (%s) on decoder", 161 | profile_string, level_string); 162 | 163 | err = 164 | gst_omx_component_set_parameter (GST_OMX_VIDEO_DEC (self)->dec, 165 | OMX_IndexParamVideoProfileLevelCurrent, ¶m); 166 | if (err == OMX_ErrorUnsupportedIndex) { 167 | GST_WARNING_OBJECT (self, 168 | "Setting profile/level not supported by component"); 169 | } else if (err != OMX_ErrorNone) { 170 | GST_ERROR_OBJECT (self, 171 | "Error setting profile %u and level %u: %s (0x%08x)", 172 | (guint) param.eProfile, (guint) param.eLevel, 173 | gst_omx_error_to_string (err), err); 174 | return FALSE; 175 | } 176 | 177 | return TRUE; 178 | 179 | unsupported_profile: 180 | GST_ERROR_OBJECT (self, "Unsupported profile %s", profile_string); 181 | return FALSE; 182 | 183 | unsupported_level: 184 | GST_ERROR_OBJECT (self, "Unsupported level %s", level_string); 185 | return FALSE; 186 | } 187 | 188 | static gboolean 189 | gst_omx_h264_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 190 | GstVideoCodecState * state) 191 | { 192 | GstOMXVideoDecClass *klass = GST_OMX_VIDEO_DEC_GET_CLASS (dec); 193 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 194 | OMX_ERRORTYPE err; 195 | const GstStructure *s; 196 | 197 | gst_omx_port_get_port_definition (port, &port_def); 198 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; 199 | err = gst_omx_port_update_port_definition (port, &port_def); 200 | if (err != OMX_ErrorNone) 201 | return FALSE; 202 | 203 | if (klass->cdata.hacks & GST_OMX_HACK_PASS_PROFILE_TO_DECODER) { 204 | if (!set_profile_and_level (GST_OMX_H264_DEC (dec), state)) 205 | return FALSE; 206 | } 207 | 208 | /* Enable subframe mode if NAL aligned */ 209 | s = gst_caps_get_structure (state->caps, 0); 210 | if (!g_strcmp0 (gst_structure_get_string (s, "alignment"), "nal") 211 | && gst_omx_port_set_subframe (dec->dec_in_port, TRUE)) { 212 | gst_video_decoder_set_subframe_mode (GST_VIDEO_DECODER (dec), TRUE); 213 | } 214 | 215 | return TRUE; 216 | } 217 | -------------------------------------------------------------------------------- /omx/gstomxh264dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_H264_DEC_H__ 22 | #define __GST_OMX_H264_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_H264_DEC \ 30 | (gst_omx_h264_dec_get_type()) 31 | #define GST_OMX_H264_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H264_DEC,GstOMXH264Dec)) 33 | #define GST_OMX_H264_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H264_DEC,GstOMXH264DecClass)) 35 | #define GST_OMX_H264_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H264_DEC,GstOMXH264DecClass)) 37 | #define GST_IS_OMX_H264_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H264_DEC)) 39 | #define GST_IS_OMX_H264_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H264_DEC)) 41 | 42 | typedef struct _GstOMXH264Dec GstOMXH264Dec; 43 | typedef struct _GstOMXH264DecClass GstOMXH264DecClass; 44 | 45 | struct _GstOMXH264Dec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXH264DecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_h264_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_H264_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxh264enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_H264_ENC_H__ 22 | #define __GST_OMX_H264_ENC_H__ 23 | 24 | #include 25 | #include "gstomxvideoenc.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_H264_ENC \ 30 | (gst_omx_h264_enc_get_type()) 31 | #define GST_OMX_H264_ENC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H264_ENC,GstOMXH264Enc)) 33 | #define GST_OMX_H264_ENC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H264_ENC,GstOMXH264EncClass)) 35 | #define GST_OMX_H264_ENC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H264_ENC,GstOMXH264EncClass)) 37 | #define GST_IS_OMX_H264_ENC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H264_ENC)) 39 | #define GST_IS_OMX_H264_ENC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H264_ENC)) 41 | 42 | typedef struct _GstOMXH264Enc GstOMXH264Enc; 43 | typedef struct _GstOMXH264EncClass GstOMXH264EncClass; 44 | 45 | struct _GstOMXH264Enc 46 | { 47 | GstOMXVideoEnc parent; 48 | 49 | #ifdef USE_OMX_TARGET_RPI 50 | gboolean inline_sps_pps_headers; 51 | #endif 52 | guint32 periodicty_idr; 53 | guint32 interval_intraframes; 54 | guint32 b_frames; 55 | guint32 entropy_mode; 56 | gboolean constrained_intra_prediction; 57 | guint32 loop_filter_mode; 58 | guint8 ref_frames; 59 | 60 | GList *headers; 61 | }; 62 | 63 | struct _GstOMXH264EncClass 64 | { 65 | GstOMXVideoEncClass parent_class; 66 | }; 67 | 68 | GType gst_omx_h264_enc_get_type (void); 69 | 70 | G_END_DECLS 71 | 72 | #endif /* __GST_OMX_H264_ENC_H__ */ 73 | 74 | -------------------------------------------------------------------------------- /omx/gstomxh264utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "gstomxh264utils.h" 26 | 27 | typedef struct 28 | { 29 | const gchar *profile; 30 | OMX_VIDEO_AVCPROFILETYPE e; 31 | } H264ProfileMapping; 32 | 33 | static const H264ProfileMapping h264_profiles[] = { 34 | {"baseline", OMX_VIDEO_AVCProfileBaseline}, 35 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 36 | {"constrained-baseline", 37 | (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileConstrainedBaseline}, 38 | #else 39 | {"constrained-baseline", OMX_VIDEO_AVCProfileBaseline}, 40 | #endif 41 | {"main", OMX_VIDEO_AVCProfileMain}, 42 | {"high", OMX_VIDEO_AVCProfileHigh}, 43 | {"high-10", OMX_VIDEO_AVCProfileHigh10}, 44 | {"high-4:2:2", OMX_VIDEO_AVCProfileHigh422}, 45 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 46 | {"progressive-high", 47 | (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileProgressiveHigh}, 48 | {"constrained-high", 49 | (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileConstrainedHigh}, 50 | {"high-10-intra", 51 | (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileHigh10_Intra}, 52 | {"high-4:2:2-intra", 53 | (OMX_VIDEO_AVCPROFILETYPE) OMX_ALG_VIDEO_AVCProfileHigh422_Intra}, 54 | #endif 55 | }; 56 | 57 | OMX_VIDEO_AVCPROFILETYPE 58 | gst_omx_h264_utils_get_profile_from_str (const gchar * profile) 59 | { 60 | guint i; 61 | 62 | for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) { 63 | if (g_str_equal (profile, h264_profiles[i].profile)) 64 | return h264_profiles[i].e; 65 | } 66 | 67 | return OMX_VIDEO_AVCProfileMax; 68 | } 69 | 70 | const gchar * 71 | gst_omx_h264_utils_get_profile_from_enum (OMX_VIDEO_AVCPROFILETYPE e) 72 | { 73 | guint i; 74 | 75 | for (i = 0; i < G_N_ELEMENTS (h264_profiles); i++) { 76 | if (e == h264_profiles[i].e) 77 | return h264_profiles[i].profile; 78 | } 79 | 80 | return NULL; 81 | } 82 | 83 | OMX_VIDEO_AVCLEVELTYPE 84 | gst_omx_h264_utils_get_level_from_str (const gchar * level) 85 | { 86 | if (g_str_equal (level, "1")) { 87 | return OMX_VIDEO_AVCLevel1; 88 | } else if (g_str_equal (level, "1b")) { 89 | return OMX_VIDEO_AVCLevel1b; 90 | } else if (g_str_equal (level, "1.1")) { 91 | return OMX_VIDEO_AVCLevel11; 92 | } else if (g_str_equal (level, "1.2")) { 93 | return OMX_VIDEO_AVCLevel12; 94 | } else if (g_str_equal (level, "1.3")) { 95 | return OMX_VIDEO_AVCLevel13; 96 | } else if (g_str_equal (level, "2")) { 97 | return OMX_VIDEO_AVCLevel2; 98 | } else if (g_str_equal (level, "2.1")) { 99 | return OMX_VIDEO_AVCLevel21; 100 | } else if (g_str_equal (level, "2.2")) { 101 | return OMX_VIDEO_AVCLevel22; 102 | } else if (g_str_equal (level, "3")) { 103 | return OMX_VIDEO_AVCLevel3; 104 | } else if (g_str_equal (level, "3.1")) { 105 | return OMX_VIDEO_AVCLevel31; 106 | } else if (g_str_equal (level, "3.2")) { 107 | return OMX_VIDEO_AVCLevel32; 108 | } else if (g_str_equal (level, "4")) { 109 | return OMX_VIDEO_AVCLevel4; 110 | } else if (g_str_equal (level, "4.1")) { 111 | return OMX_VIDEO_AVCLevel41; 112 | } else if (g_str_equal (level, "4.2")) { 113 | return OMX_VIDEO_AVCLevel42; 114 | } else if (g_str_equal (level, "5")) { 115 | return OMX_VIDEO_AVCLevel5; 116 | } else if (g_str_equal (level, "5.1")) { 117 | return OMX_VIDEO_AVCLevel51; 118 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 119 | } else if (g_str_equal (level, "5.2")) { 120 | return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel52; 121 | } else if (g_str_equal (level, "6.0")) { 122 | return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel60; 123 | } else if (g_str_equal (level, "6.1")) { 124 | return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel61; 125 | } else if (g_str_equal (level, "6.2")) { 126 | return (OMX_VIDEO_AVCLEVELTYPE) OMX_ALG_VIDEO_AVCLevel62; 127 | #endif 128 | } 129 | 130 | return OMX_VIDEO_AVCLevelMax; 131 | } 132 | -------------------------------------------------------------------------------- /omx/gstomxh264utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_H264_UTILS_H__ 22 | #define __GST_OMX_H264_UTILS_H__ 23 | 24 | #include "gstomx.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | OMX_VIDEO_AVCPROFILETYPE gst_omx_h264_utils_get_profile_from_str (const 29 | gchar * profile); 30 | OMX_VIDEO_AVCLEVELTYPE gst_omx_h264_utils_get_level_from_str (const gchar * 31 | level); 32 | 33 | const gchar * gst_omx_h264_utils_get_profile_from_enum (OMX_VIDEO_AVCPROFILETYPE e); 34 | 35 | G_END_DECLS 36 | #endif /* __GST_OMX_H264_UTILS_H__ */ 37 | -------------------------------------------------------------------------------- /omx/gstomxh265dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Copyright (C) 2017 Xilinx, Inc. 4 | * Author: Sebastian Dröge , Collabora Ltd. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | 28 | #include "gstomxh265dec.h" 29 | #include "gstomxh265utils.h" 30 | 31 | GST_DEBUG_CATEGORY_STATIC (gst_omx_h265_dec_debug_category); 32 | #define GST_CAT_DEFAULT gst_omx_h265_dec_debug_category 33 | 34 | /* prototypes */ 35 | static gboolean gst_omx_h265_dec_is_format_change (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | static gboolean gst_omx_h265_dec_set_format (GstOMXVideoDec * dec, 38 | GstOMXPort * port, GstVideoCodecState * state); 39 | 40 | enum 41 | { 42 | PROP_0 43 | }; 44 | 45 | /* class initialization */ 46 | 47 | #define DEBUG_INIT \ 48 | GST_DEBUG_CATEGORY_INIT (gst_omx_h265_dec_debug_category, "omxh265dec", 0, \ 49 | "debug category for gst-omx H265 video decoder"); 50 | 51 | G_DEFINE_TYPE_WITH_CODE (GstOMXH265Dec, gst_omx_h265_dec, 52 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 53 | 54 | #define MAKE_CAPS(alignment) \ 55 | "video/x-h265, " \ 56 | "alignment=(string) " alignment ", " \ 57 | "stream-format=(string) byte-stream, " \ 58 | "width=(int) [1,MAX], height=(int) [1,MAX]" 59 | 60 | /* The Zynq MPSoC supports decoding subframes though we want "au" to be the 61 | * default, so we keep it prepended. This is the only way that it works with 62 | * rtph265depay. */ 63 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 64 | #define SINK_CAPS MAKE_CAPS ("au") ";" MAKE_CAPS ("nal"); 65 | #else 66 | #define SINK_CAPS MAKE_CAPS ("au") 67 | #endif 68 | 69 | static void 70 | gst_omx_h265_dec_class_init (GstOMXH265DecClass * klass) 71 | { 72 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 73 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 74 | 75 | videodec_class->is_format_change = 76 | GST_DEBUG_FUNCPTR (gst_omx_h265_dec_is_format_change); 77 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h265_dec_set_format); 78 | 79 | videodec_class->cdata.default_sink_template_caps = SINK_CAPS; 80 | 81 | gst_element_class_set_static_metadata (element_class, 82 | "OpenMAX H.265 Video Decoder", 83 | "Codec/Decoder/Video/Hardware", 84 | "Decode H.265 video streams", 85 | "Sebastian Dröge "); 86 | 87 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.hevc"); 88 | } 89 | 90 | static void 91 | gst_omx_h265_dec_init (GstOMXH265Dec * self) 92 | { 93 | } 94 | 95 | static gboolean 96 | gst_omx_h265_dec_is_format_change (GstOMXVideoDec * dec, 97 | GstOMXPort * port, GstVideoCodecState * state) 98 | { 99 | GstCaps *old_caps = NULL; 100 | GstCaps *new_caps = state->caps; 101 | GstStructure *old_structure, *new_structure; 102 | const gchar *old_profile, *old_level, *old_tier, *old_alignment, 103 | *new_profile, *new_level, *new_tier, *new_alignment; 104 | 105 | if (dec->input_state) { 106 | old_caps = dec->input_state->caps; 107 | } 108 | 109 | if (!old_caps) { 110 | return FALSE; 111 | } 112 | 113 | old_structure = gst_caps_get_structure (old_caps, 0); 114 | new_structure = gst_caps_get_structure (new_caps, 0); 115 | old_profile = gst_structure_get_string (old_structure, "profile"); 116 | old_level = gst_structure_get_string (old_structure, "level"); 117 | old_tier = gst_structure_get_string (old_structure, "tier"); 118 | old_alignment = gst_structure_get_string (old_structure, "alignment"); 119 | new_profile = gst_structure_get_string (new_structure, "profile"); 120 | new_level = gst_structure_get_string (new_structure, "level"); 121 | new_tier = gst_structure_get_string (new_structure, "tier"); 122 | new_alignment = gst_structure_get_string (new_structure, "alignment"); 123 | 124 | if (g_strcmp0 (old_profile, new_profile) != 0 125 | || g_strcmp0 (old_level, new_level) != 0 126 | || g_strcmp0 (old_tier, new_tier) != 0 127 | || g_strcmp0 (old_alignment, new_alignment) != 0) { 128 | return TRUE; 129 | } 130 | 131 | return FALSE; 132 | } 133 | 134 | static gboolean 135 | set_profile_and_level (GstOMXH265Dec * self, GstVideoCodecState * state) 136 | { 137 | OMX_ERRORTYPE err; 138 | OMX_VIDEO_PARAM_PROFILELEVELTYPE param; 139 | const gchar *profile_string, *level_string, *tier_string; 140 | GstStructure *s; 141 | 142 | GST_OMX_INIT_STRUCT (¶m); 143 | param.nPortIndex = GST_OMX_VIDEO_DEC (self)->dec_in_port->index; 144 | 145 | /* Pass profile, level and tier to the decoder if we have all info from the 146 | * caps. */ 147 | s = gst_caps_get_structure (state->caps, 0); 148 | profile_string = gst_structure_get_string (s, "profile"); 149 | if (!profile_string) 150 | return TRUE; 151 | 152 | param.eProfile = gst_omx_h265_utils_get_profile_from_str (profile_string); 153 | if (param.eProfile == OMX_VIDEO_HEVCProfileUnknown) 154 | goto unsupported_profile; 155 | 156 | level_string = gst_structure_get_string (s, "level"); 157 | tier_string = gst_structure_get_string (s, "tier"); 158 | if (!level_string || !tier_string) 159 | return TRUE; 160 | 161 | param.eLevel = 162 | gst_omx_h265_utils_get_level_from_str (level_string, tier_string); 163 | if (param.eLevel == OMX_VIDEO_HEVCLevelUnknown) 164 | goto unsupported_level; 165 | 166 | GST_DEBUG_OBJECT (self, 167 | "Set profile (%s) level (%s) and tier (%s) on decoder", profile_string, 168 | level_string, tier_string); 169 | 170 | err = 171 | gst_omx_component_set_parameter (GST_OMX_VIDEO_DEC (self)->dec, 172 | OMX_IndexParamVideoProfileLevelCurrent, ¶m); 173 | if (err == OMX_ErrorUnsupportedIndex) { 174 | GST_WARNING_OBJECT (self, 175 | "Setting profile/level not supported by component"); 176 | } else if (err != OMX_ErrorNone) { 177 | GST_ERROR_OBJECT (self, 178 | "Error setting profile %u and level %u: %s (0x%08x)", 179 | (guint) param.eProfile, (guint) param.eLevel, 180 | gst_omx_error_to_string (err), err); 181 | return FALSE; 182 | } 183 | 184 | return TRUE; 185 | 186 | unsupported_profile: 187 | GST_ERROR_OBJECT (self, "Unsupported profile %s", profile_string); 188 | return FALSE; 189 | 190 | unsupported_level: 191 | GST_ERROR_OBJECT (self, "Unsupported level %s", level_string); 192 | return FALSE; 193 | } 194 | 195 | static gboolean 196 | gst_omx_h265_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 197 | GstVideoCodecState * state) 198 | { 199 | GstOMXVideoDecClass *klass = GST_OMX_VIDEO_DEC_GET_CLASS (dec); 200 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 201 | OMX_ERRORTYPE err; 202 | const GstStructure *s; 203 | 204 | gst_omx_port_get_port_definition (port, &port_def); 205 | port_def.format.video.eCompressionFormat = 206 | (OMX_VIDEO_CODINGTYPE) OMX_VIDEO_CodingHEVC; 207 | err = gst_omx_port_update_port_definition (port, &port_def); 208 | if (err != OMX_ErrorNone) 209 | return FALSE; 210 | 211 | if (klass->cdata.hacks & GST_OMX_HACK_PASS_PROFILE_TO_DECODER) { 212 | if (!set_profile_and_level (GST_OMX_H265_DEC (dec), state)) 213 | return FALSE; 214 | } 215 | 216 | /* Enable subframe mode if NAL aligned */ 217 | s = gst_caps_get_structure (state->caps, 0); 218 | if (!g_strcmp0 (gst_structure_get_string (s, "alignment"), "nal") 219 | && gst_omx_port_set_subframe (dec->dec_in_port, TRUE)) { 220 | gst_video_decoder_set_subframe_mode (GST_VIDEO_DECODER (dec), TRUE); 221 | } 222 | 223 | return TRUE; 224 | } 225 | -------------------------------------------------------------------------------- /omx/gstomxh265dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Copyright (C) 2017 Xilinx, Inc. 4 | * Author: Sebastian Dröge , Collabora Ltd. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_H265_DEC_H__ 23 | #define __GST_OMX_H265_DEC_H__ 24 | 25 | #include 26 | #include "gstomxvideodec.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define GST_TYPE_OMX_H265_DEC \ 31 | (gst_omx_h265_dec_get_type()) 32 | #define GST_OMX_H265_DEC(obj) \ 33 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H265_DEC,GstOMXH265Dec)) 34 | #define GST_OMX_H265_DEC_CLASS(klass) \ 35 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H265_DEC,GstOMXH265DecClass)) 36 | #define GST_OMX_H265_DEC_GET_CLASS(obj) \ 37 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H265_DEC,GstOMXH265DecClass)) 38 | #define GST_IS_OMX_H265_DEC(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H265_DEC)) 40 | #define GST_IS_OMX_H265_DEC_CLASS(obj) \ 41 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H265_DEC)) 42 | 43 | typedef struct _GstOMXH265Dec GstOMXH265Dec; 44 | typedef struct _GstOMXH265DecClass GstOMXH265DecClass; 45 | 46 | struct _GstOMXH265Dec 47 | { 48 | GstOMXVideoDec parent; 49 | }; 50 | 51 | struct _GstOMXH265DecClass 52 | { 53 | GstOMXVideoDecClass parent_class; 54 | }; 55 | 56 | GType gst_omx_h265_dec_get_type (void); 57 | 58 | G_END_DECLS 59 | 60 | #endif /* __GST_OMX_H265_DEC_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /omx/gstomxh265enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Copyright (C) 2017 Xilinx, Inc. 4 | * Author: Sebastian Dröge , Collabora Ltd. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_H265_ENC_H__ 23 | #define __GST_OMX_H265_ENC_H__ 24 | 25 | #include 26 | #include "gstomxvideoenc.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define GST_TYPE_OMX_H265_ENC \ 31 | (gst_omx_h265_enc_get_type()) 32 | #define GST_OMX_H265_ENC(obj) \ 33 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_H265_ENC,GstOMXH265Enc)) 34 | #define GST_OMX_H265_ENC_CLASS(klass) \ 35 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_H265_ENC,GstOMXH265EncClass)) 36 | #define GST_OMX_H265_ENC_GET_CLASS(obj) \ 37 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_H265_ENC,GstOMXH265EncClass)) 38 | #define GST_IS_OMX_H265_ENC(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_H265_ENC)) 40 | #define GST_IS_OMX_H265_ENC_CLASS(obj) \ 41 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_H265_ENC)) 42 | 43 | typedef struct _GstOMXH265Enc GstOMXH265Enc; 44 | typedef struct _GstOMXH265EncClass GstOMXH265EncClass; 45 | 46 | struct _GstOMXH265Enc 47 | { 48 | GstOMXVideoEnc parent; 49 | 50 | /* properties */ 51 | guint32 interval_intraframes; 52 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 53 | guint32 periodicity_idr; 54 | guint32 b_frames; 55 | gboolean constrained_intra_prediction; 56 | guint32 loop_filter_mode; 57 | #endif 58 | 59 | GList *headers; 60 | }; 61 | 62 | struct _GstOMXH265EncClass 63 | { 64 | GstOMXVideoEncClass parent_class; 65 | }; 66 | 67 | GType gst_omx_h265_enc_get_type (void); 68 | 69 | G_END_DECLS 70 | 71 | #endif /* __GST_OMX_H265_ENC_H__ */ 72 | 73 | -------------------------------------------------------------------------------- /omx/gstomxh265utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Copyright (C) 2017 Xilinx, Inc. 4 | * Author: Sebastian Dröge , Collabora Ltd. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include "gstomxh265utils.h" 27 | 28 | typedef struct 29 | { 30 | const gchar *profile; 31 | OMX_VIDEO_HEVCPROFILETYPE e; 32 | } H265ProfileMapping; 33 | 34 | static const H265ProfileMapping h265_profiles[] = { 35 | {"main", OMX_VIDEO_HEVCProfileMain}, 36 | {"main-10", OMX_VIDEO_HEVCProfileMain10}, 37 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 38 | {"main-still-picture", 39 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMainStill}, 40 | /* Format range extensions profiles (A.3.5) */ 41 | {"monochrome", 42 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMonochrome}, 43 | /* Not standard: 10 bits variation of monochrome-12 */ 44 | {"monochrome-10", 45 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMonochrome10}, 46 | /* Not standard: 8 bits variation of main-422-10 */ 47 | {"main-422", (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422}, 48 | {"main-422-10", 49 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422_10}, 50 | {"main-intra", 51 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain_Intra}, 52 | {"main-10-intra", 53 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain10_Intra}, 54 | /* Not standard: intra variation of main-422 */ 55 | {"main-422-intra", 56 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422_Intra}, 57 | {"main-422-10-intra", 58 | (OMX_VIDEO_HEVCPROFILETYPE) OMX_ALG_VIDEO_HEVCProfileMain422_10_Intra}, 59 | #endif 60 | }; 61 | 62 | OMX_VIDEO_HEVCPROFILETYPE 63 | gst_omx_h265_utils_get_profile_from_str (const gchar * profile) 64 | { 65 | guint i; 66 | 67 | for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) { 68 | if (g_str_equal (profile, h265_profiles[i].profile)) 69 | return h265_profiles[i].e; 70 | } 71 | 72 | return OMX_VIDEO_HEVCProfileUnknown; 73 | } 74 | 75 | const gchar * 76 | gst_omx_h265_utils_get_profile_from_enum (OMX_VIDEO_HEVCPROFILETYPE e) 77 | { 78 | guint i; 79 | 80 | for (i = 0; i < G_N_ELEMENTS (h265_profiles); i++) { 81 | if (e == h265_profiles[i].e) 82 | return h265_profiles[i].profile; 83 | } 84 | 85 | return NULL; 86 | } 87 | 88 | OMX_VIDEO_HEVCLEVELTYPE 89 | gst_omx_h265_utils_get_level_from_str (const gchar * level, const gchar * tier) 90 | { 91 | if (g_str_equal (tier, "main")) { 92 | if (g_str_equal (level, "1")) 93 | return OMX_VIDEO_HEVCMainTierLevel1; 94 | else if (g_str_equal (level, "2")) 95 | return OMX_VIDEO_HEVCMainTierLevel2; 96 | else if (g_str_equal (level, "2.1")) 97 | return OMX_VIDEO_HEVCMainTierLevel21; 98 | else if (g_str_equal (level, "3")) 99 | return OMX_VIDEO_HEVCMainTierLevel3; 100 | else if (g_str_equal (level, "3.1")) 101 | return OMX_VIDEO_HEVCMainTierLevel31; 102 | else if (g_str_equal (level, "4")) 103 | return OMX_VIDEO_HEVCMainTierLevel4; 104 | else if (g_str_equal (level, "4.1")) 105 | return OMX_VIDEO_HEVCMainTierLevel41; 106 | else if (g_str_equal (level, "5")) 107 | return OMX_VIDEO_HEVCMainTierLevel5; 108 | else if (g_str_equal (level, "5.1")) 109 | return OMX_VIDEO_HEVCMainTierLevel51; 110 | else if (g_str_equal (level, "5.2")) 111 | return OMX_VIDEO_HEVCMainTierLevel52; 112 | else if (g_str_equal (level, "6")) 113 | return OMX_VIDEO_HEVCMainTierLevel6; 114 | else if (g_str_equal (level, "6.1")) 115 | return OMX_VIDEO_HEVCMainTierLevel61; 116 | else if (g_str_equal (level, "6.2")) 117 | return OMX_VIDEO_HEVCMainTierLevel62; 118 | } else if (g_str_equal (tier, "high")) { 119 | if (g_str_equal (level, "4")) 120 | return OMX_VIDEO_HEVCHighTierLevel4; 121 | else if (g_str_equal (level, "4.1")) 122 | return OMX_VIDEO_HEVCHighTierLevel41; 123 | else if (g_str_equal (level, "5")) 124 | return OMX_VIDEO_HEVCHighTierLevel5; 125 | else if (g_str_equal (level, "5.1")) 126 | return OMX_VIDEO_HEVCHighTierLevel51; 127 | else if (g_str_equal (level, "5.2")) 128 | return OMX_VIDEO_HEVCHighTierLevel52; 129 | else if (g_str_equal (level, "6")) 130 | return OMX_VIDEO_HEVCHighTierLevel6; 131 | else if (g_str_equal (level, "6.1")) 132 | return OMX_VIDEO_HEVCHighTierLevel61; 133 | else if (g_str_equal (level, "6.2")) 134 | return OMX_VIDEO_HEVCHighTierLevel62; 135 | } 136 | 137 | return OMX_VIDEO_HEVCLevelUnknown; 138 | } 139 | -------------------------------------------------------------------------------- /omx/gstomxh265utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Copyright (C) 2017 Xilinx, Inc. 4 | * Author: Sebastian Dröge , Collabora Ltd. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_H265_UTILS_H__ 23 | #define __GST_OMX_H265_UTILS_H__ 24 | 25 | #include "gstomx.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | OMX_VIDEO_HEVCPROFILETYPE gst_omx_h265_utils_get_profile_from_str (const 30 | gchar * profile); 31 | OMX_VIDEO_HEVCLEVELTYPE gst_omx_h265_utils_get_level_from_str (const gchar * 32 | level, const gchar * tier); 33 | 34 | const gchar * gst_omx_h265_utils_get_profile_from_enum (OMX_VIDEO_HEVCPROFILETYPE e); 35 | 36 | G_END_DECLS 37 | #endif /* __GST_OMX_H265_UTILS_H__ */ 38 | -------------------------------------------------------------------------------- /omx/gstomxhdmiaudiosink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Fluendo, S.A. 3 | * Copyright (C) 2014, Metrological Media Innovations B.V. 4 | * Author: Josep Torra 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | 28 | #include "gstomxhdmiaudiosink.h" 29 | 30 | GST_DEBUG_CATEGORY_STATIC (gst_omx_hdmi_audio_sink_debug_category); 31 | #define GST_CAT_DEFAULT gst_omx_hdmi_audio_sink_debug_category 32 | 33 | /* class initialization */ 34 | 35 | #define DEBUG_INIT \ 36 | GST_DEBUG_CATEGORY_INIT (gst_omx_hdmi_audio_sink_debug_category, \ 37 | "omxhdmiaudiosink", 0, "debug category for gst-omx hdmi audio sink"); 38 | 39 | G_DEFINE_TYPE_WITH_CODE (GstOMXHdmiAudioSink, gst_omx_hdmi_audio_sink, 40 | GST_TYPE_OMX_AUDIO_SINK, DEBUG_INIT); 41 | 42 | static void 43 | gst_omx_hdmi_audio_sink_class_init (GstOMXHdmiAudioSinkClass * klass) 44 | { 45 | GstOMXAudioSinkClass *audiosink_class = GST_OMX_AUDIO_SINK_CLASS (klass); 46 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 47 | 48 | audiosink_class->cdata.default_sink_template_caps = "audio/x-raw, " 49 | "format = (string) " GST_AUDIO_FORMATS_ALL ", " 50 | "layout = (string) interleaved, " 51 | "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " 52 | PASSTHROUGH_CAPS; 53 | audiosink_class->destination = "hdmi"; 54 | 55 | gst_element_class_set_static_metadata (element_class, 56 | "OpenMAX HDMI Audio Sink", 57 | "Sink/Audio", 58 | "Output audio through HDMI", "Josep Torra "); 59 | 60 | gst_omx_set_default_role (&audiosink_class->cdata, "audio_render.hdmi"); 61 | } 62 | 63 | static void 64 | gst_omx_hdmi_audio_sink_init (GstOMXHdmiAudioSink * self) 65 | { 66 | } 67 | -------------------------------------------------------------------------------- /omx/gstomxhdmiaudiosink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Fluendo, S.A. 3 | * Copyright (C) 2014, Metrological Media Innovations B.V. 4 | * Author: Josep Torra 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef __GST_OMX_HDMI_AUDIO_SINK_H__ 23 | #define __GST_OMX_HDMI_AUDIO_SINK_H__ 24 | 25 | #include 26 | #include "gstomxaudiosink.h" 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define GST_TYPE_OMX_HDMI_AUDIO_SINK \ 31 | (gst_omx_hdmi_audio_sink_get_type()) 32 | #define GST_OMX_HDMI_AUDIO_SINK(obj) \ 33 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSink)) 34 | #define GST_OMX_HDMI_AUDIO_SINK_CLASS(klass) \ 35 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSinkClass)) 36 | #define GST_OMX_HDMI_AUDIO_SINK_GET_CLASS(obj) \ 37 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSinkClass)) 38 | #define GST_IS_OMX_HDMI_AUDIO_SINK(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK)) 40 | #define GST_IS_OMX_HDMI_AUDIO_SINK_CLASS(obj) \ 41 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_HDMI_AUDIO_SINK)) 42 | 43 | typedef struct _GstOMXHdmiAudioSink GstOMXHdmiAudioSink; 44 | typedef struct _GstOMXHdmiAudioSinkClass GstOMXHdmiAudioSinkClass; 45 | 46 | struct _GstOMXHdmiAudioSink 47 | { 48 | GstOMXAudioSink parent; 49 | }; 50 | 51 | struct _GstOMXHdmiAudioSinkClass 52 | { 53 | GstOMXAudioSinkClass parent_class; 54 | }; 55 | 56 | GType gst_omx_hdmi_audio_sink_get_type (void); 57 | 58 | G_END_DECLS 59 | 60 | #endif /* __GST_OMX_HDMI_AUDIO_SINK_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /omx/gstomxmjpegdec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013, Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxmjpegdec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_mjpeg_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_mjpeg_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_mjpeg_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_mjpeg_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_mjpeg_dec_debug_category, "omxmjpegdec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXMJPEGDec, gst_omx_mjpeg_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | static void 53 | gst_omx_mjpeg_dec_class_init (GstOMXMJPEGDecClass * klass) 54 | { 55 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 56 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 57 | 58 | videodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_is_format_change); 60 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mjpeg_dec_set_format); 61 | 62 | videodec_class->cdata.default_sink_template_caps = "image/jpeg, " 63 | "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 64 | 65 | gst_element_class_set_static_metadata (element_class, 66 | "OpenMAX MJPEG Video Decoder", 67 | "Codec/Decoder/Video/Hardware", 68 | "Decode MJPEG video streams", 69 | "Sebastian Dröge "); 70 | 71 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mjpeg"); 72 | } 73 | 74 | static void 75 | gst_omx_mjpeg_dec_init (GstOMXMJPEGDec * self) 76 | { 77 | } 78 | 79 | static gboolean 80 | gst_omx_mjpeg_dec_is_format_change (GstOMXVideoDec * dec, 81 | GstOMXPort * port, GstVideoCodecState * state) 82 | { 83 | return FALSE; 84 | } 85 | 86 | static gboolean 87 | gst_omx_mjpeg_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 88 | GstVideoCodecState * state) 89 | { 90 | gboolean ret; 91 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 92 | 93 | gst_omx_port_get_port_definition (port, &port_def); 94 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMJPEG; 95 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 96 | 97 | return ret; 98 | } 99 | -------------------------------------------------------------------------------- /omx/gstomxmjpegdec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_MJPEG_DEC_H__ 22 | #define __GST_OMX_MJPEG_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_MJPEG_DEC \ 30 | (gst_omx_mjpeg_dec_get_type()) 31 | #define GST_OMX_MJPEG_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MJPEG_DEC,GstOMXMJPEGDec)) 33 | #define GST_OMX_MJPEG_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MJPEG_DEC,GstOMXMJPEGDecClass)) 35 | #define GST_OMX_MJPEG_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MJPEG_DEC,GstOMXMJPEGDecClass)) 37 | #define GST_IS_OMX_MJPEG_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MJPEG_DEC)) 39 | #define GST_IS_OMX_MJPEG_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MJPEG_DEC)) 41 | 42 | typedef struct _GstOMXMJPEGDec GstOMXMJPEGDec; 43 | typedef struct _GstOMXMJPEGDecClass GstOMXMJPEGDecClass; 44 | 45 | struct _GstOMXMJPEGDec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXMJPEGDecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_mjpeg_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_MJPEG_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxmp3dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation 7 | * version 2.1 of the License. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include 25 | 26 | #include "gstomxmp3dec.h" 27 | 28 | GST_DEBUG_CATEGORY_STATIC (gst_omx_mp3_dec_debug_category); 29 | #define GST_CAT_DEFAULT gst_omx_mp3_dec_debug_category 30 | 31 | /* prototypes */ 32 | static gboolean gst_omx_mp3_dec_set_format (GstOMXAudioDec * dec, 33 | GstOMXPort * port, GstCaps * caps); 34 | static gboolean gst_omx_mp3_dec_is_format_change (GstOMXAudioDec * dec, 35 | GstOMXPort * port, GstCaps * caps); 36 | static gint gst_omx_mp3_dec_get_samples_per_frame (GstOMXAudioDec * dec, 37 | GstOMXPort * port); 38 | static gboolean gst_omx_mp3_dec_get_channel_positions (GstOMXAudioDec * dec, 39 | GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]); 40 | 41 | /* class initialization */ 42 | 43 | #define DEBUG_INIT \ 44 | GST_DEBUG_CATEGORY_INIT (gst_omx_mp3_dec_debug_category, "omxmp3dec", 0, \ 45 | "debug category for gst-omx mp3 audio decoder"); 46 | 47 | G_DEFINE_TYPE_WITH_CODE (GstOMXMP3Dec, gst_omx_mp3_dec, 48 | GST_TYPE_OMX_AUDIO_DEC, DEBUG_INIT); 49 | 50 | 51 | static void 52 | gst_omx_mp3_dec_class_init (GstOMXMP3DecClass * klass) 53 | { 54 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 55 | GstOMXAudioDecClass *audiodec_class = GST_OMX_AUDIO_DEC_CLASS (klass); 56 | 57 | audiodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mp3_dec_set_format); 58 | audiodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_mp3_dec_is_format_change); 60 | audiodec_class->get_samples_per_frame = 61 | GST_DEBUG_FUNCPTR (gst_omx_mp3_dec_get_samples_per_frame); 62 | audiodec_class->get_channel_positions = 63 | GST_DEBUG_FUNCPTR (gst_omx_mp3_dec_get_channel_positions); 64 | 65 | audiodec_class->cdata.default_sink_template_caps = "audio/mpeg, " 66 | "mpegversion=(int)1, " 67 | "layer=(int)3, " 68 | "mpegaudioversion=(int)[1,3], " 69 | "rate=(int)[8000,48000], " 70 | "channels=(int)[1,2], " "parsed=(boolean) true"; 71 | 72 | gst_element_class_set_static_metadata (element_class, 73 | "OpenMAX MP3 Audio Decoder", 74 | "Codec/Decoder/Audio/Hardware", 75 | "Decode MP3 audio streams", 76 | "Sebastian Dröge "); 77 | 78 | gst_omx_set_default_role (&audiodec_class->cdata, "audio_decoder.mp3"); 79 | } 80 | 81 | static void 82 | gst_omx_mp3_dec_init (GstOMXMP3Dec * self) 83 | { 84 | self->spf = -1; 85 | } 86 | 87 | static gboolean 88 | gst_omx_mp3_dec_set_format (GstOMXAudioDec * dec, GstOMXPort * port, 89 | GstCaps * caps) 90 | { 91 | GstOMXMP3Dec *self = GST_OMX_MP3_DEC (dec); 92 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 93 | OMX_AUDIO_PARAM_MP3TYPE mp3_param; 94 | OMX_ERRORTYPE err; 95 | GstStructure *s; 96 | gint rate, channels, layer, mpegaudioversion; 97 | 98 | gst_omx_port_get_port_definition (port, &port_def); 99 | port_def.format.audio.eEncoding = OMX_AUDIO_CodingMP3; 100 | err = gst_omx_port_update_port_definition (port, &port_def); 101 | if (err != OMX_ErrorNone) { 102 | GST_ERROR_OBJECT (self, 103 | "Failed to set MP3 format on component: %s (0x%08x)", 104 | gst_omx_error_to_string (err), err); 105 | return FALSE; 106 | } 107 | 108 | GST_OMX_INIT_STRUCT (&mp3_param); 109 | mp3_param.nPortIndex = port->index; 110 | 111 | err = 112 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioMp3, 113 | &mp3_param); 114 | if (err != OMX_ErrorNone) { 115 | GST_ERROR_OBJECT (self, 116 | "Failed to get MP3 parameters from component: %s (0x%08x)", 117 | gst_omx_error_to_string (err), err); 118 | return FALSE; 119 | } 120 | 121 | s = gst_caps_get_structure (caps, 0); 122 | 123 | if (!gst_structure_get_int (s, "mpegaudioversion", &mpegaudioversion) || 124 | !gst_structure_get_int (s, "layer", &layer) || 125 | !gst_structure_get_int (s, "rate", &rate) || 126 | !gst_structure_get_int (s, "channels", &channels)) { 127 | GST_ERROR_OBJECT (self, "Incomplete caps"); 128 | return FALSE; 129 | } 130 | 131 | self->spf = (mpegaudioversion == 1 ? 1152 : 576); 132 | 133 | mp3_param.nChannels = channels; 134 | mp3_param.nBitRate = 0; /* unknown */ 135 | mp3_param.nSampleRate = rate; 136 | mp3_param.nAudioBandWidth = 0; /* decoder decision */ 137 | mp3_param.eChannelMode = 0; /* FIXME */ 138 | if (mpegaudioversion == 1) 139 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP1Layer3; 140 | else if (mpegaudioversion == 2) 141 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP2Layer3; 142 | else 143 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP2_5Layer3; 144 | 145 | err = 146 | gst_omx_component_set_parameter (dec->dec, OMX_IndexParamAudioMp3, 147 | &mp3_param); 148 | if (err != OMX_ErrorNone) { 149 | GST_ERROR_OBJECT (self, "Error setting MP3 parameters: %s (0x%08x)", 150 | gst_omx_error_to_string (err), err); 151 | return FALSE; 152 | } 153 | 154 | return TRUE; 155 | } 156 | 157 | static gboolean 158 | gst_omx_mp3_dec_is_format_change (GstOMXAudioDec * dec, GstOMXPort * port, 159 | GstCaps * caps) 160 | { 161 | GstOMXMP3Dec *self = GST_OMX_MP3_DEC (dec); 162 | OMX_AUDIO_PARAM_MP3TYPE mp3_param; 163 | OMX_ERRORTYPE err; 164 | GstStructure *s; 165 | gint rate, channels, layer, mpegaudioversion; 166 | 167 | GST_OMX_INIT_STRUCT (&mp3_param); 168 | mp3_param.nPortIndex = port->index; 169 | 170 | err = 171 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioMp3, 172 | &mp3_param); 173 | if (err != OMX_ErrorNone) { 174 | GST_ERROR_OBJECT (self, 175 | "Failed to get MP3 parameters from component: %s (0x%08x)", 176 | gst_omx_error_to_string (err), err); 177 | return FALSE; 178 | } 179 | 180 | s = gst_caps_get_structure (caps, 0); 181 | 182 | if (!gst_structure_get_int (s, "mpegaudioversion", &mpegaudioversion) || 183 | !gst_structure_get_int (s, "layer", &layer) || 184 | !gst_structure_get_int (s, "rate", &rate) || 185 | !gst_structure_get_int (s, "channels", &channels)) { 186 | GST_ERROR_OBJECT (self, "Incomplete caps"); 187 | return FALSE; 188 | } 189 | 190 | if (mp3_param.nChannels != channels) 191 | return TRUE; 192 | 193 | if (mp3_param.nSampleRate != rate) 194 | return TRUE; 195 | 196 | if (mpegaudioversion == 1 197 | && mp3_param.eFormat != OMX_AUDIO_MP3StreamFormatMP1Layer3) 198 | return TRUE; 199 | if (mpegaudioversion == 2 200 | && mp3_param.eFormat != OMX_AUDIO_MP3StreamFormatMP2Layer3) 201 | return TRUE; 202 | if (mpegaudioversion == 3 203 | && mp3_param.eFormat != OMX_AUDIO_MP3StreamFormatMP2_5Layer3) 204 | return TRUE; 205 | 206 | return FALSE; 207 | } 208 | 209 | static gint 210 | gst_omx_mp3_dec_get_samples_per_frame (GstOMXAudioDec * dec, GstOMXPort * port) 211 | { 212 | return GST_OMX_MP3_DEC (dec)->spf; 213 | } 214 | 215 | static gboolean 216 | gst_omx_mp3_dec_get_channel_positions (GstOMXAudioDec * dec, 217 | GstOMXPort * port, GstAudioChannelPosition position[OMX_AUDIO_MAXCHANNELS]) 218 | { 219 | OMX_AUDIO_PARAM_PCMMODETYPE pcm_param; 220 | OMX_ERRORTYPE err; 221 | 222 | GST_OMX_INIT_STRUCT (&pcm_param); 223 | pcm_param.nPortIndex = port->index; 224 | err = 225 | gst_omx_component_get_parameter (dec->dec, OMX_IndexParamAudioPcm, 226 | &pcm_param); 227 | if (err != OMX_ErrorNone) { 228 | GST_ERROR_OBJECT (dec, "Failed to get PCM parameters: %s (0x%08x)", 229 | gst_omx_error_to_string (err), err); 230 | return FALSE; 231 | } 232 | 233 | switch (pcm_param.nChannels) { 234 | case 1: 235 | position[0] = GST_AUDIO_CHANNEL_POSITION_MONO; 236 | break; 237 | case 2: 238 | position[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT; 239 | position[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT; 240 | break; 241 | default: 242 | return FALSE; 243 | } 244 | 245 | return TRUE; 246 | } 247 | -------------------------------------------------------------------------------- /omx/gstomxmp3dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, Sebastian Dröge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation 7 | * version 2.1 of the License. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | */ 19 | 20 | #ifndef __GST_OMX_MP3_DEC_H__ 21 | #define __GST_OMX_MP3_DEC_H__ 22 | 23 | #include 24 | #include "gstomxaudiodec.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define GST_TYPE_OMX_MP3_DEC \ 29 | (gst_omx_mp3_dec_get_type()) 30 | #define GST_OMX_MP3_DEC(obj) \ 31 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MP3_DEC,GstOMXMP3Dec)) 32 | #define GST_OMX_MP3_DEC_CLASS(klass) \ 33 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MP3_DEC,GstOMXMP3DecClass)) 34 | #define GST_OMX_MP3_DEC_GET_CLASS(obj) \ 35 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MP3_DEC,GstOMXMP3DecClass)) 36 | #define GST_IS_OMX_MP3_DEC(obj) \ 37 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MP3_DEC)) 38 | #define GST_IS_OMX_MP3_DEC_CLASS(obj) \ 39 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MP3_DEC)) 40 | 41 | typedef struct _GstOMXMP3Dec GstOMXMP3Dec; 42 | typedef struct _GstOMXMP3DecClass GstOMXMP3DecClass; 43 | 44 | struct _GstOMXMP3Dec 45 | { 46 | GstOMXAudioDec parent; 47 | gint spf; 48 | }; 49 | 50 | struct _GstOMXMP3DecClass 51 | { 52 | GstOMXAudioDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_mp3_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_MP3_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxmp3enc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Author: Julien Isorce 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxmp3enc.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_mp3_enc_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_mp3_enc_debug_category 31 | 32 | /* prototypes */ 33 | static void gst_omx_mp3_enc_set_property (GObject * object, guint prop_id, 34 | const GValue * value, GParamSpec * pspec); 35 | static void gst_omx_mp3_enc_get_property (GObject * object, guint prop_id, 36 | GValue * value, GParamSpec * pspec); 37 | static gboolean gst_omx_mp3_enc_set_format (GstOMXAudioEnc * enc, 38 | GstOMXPort * port, GstAudioInfo * info); 39 | static GstCaps *gst_omx_mp3_enc_get_caps (GstOMXAudioEnc * enc, 40 | GstOMXPort * port, GstAudioInfo * info); 41 | static guint gst_omx_mp3_enc_get_num_samples (GstOMXAudioEnc * enc, 42 | GstOMXPort * port, GstAudioInfo * info, GstOMXBuffer * buf); 43 | 44 | enum 45 | { 46 | PROP_0, 47 | PROP_BITRATE 48 | }; 49 | 50 | #define DEFAULT_BITRATE (128) 51 | 52 | /* class initialization */ 53 | 54 | #define DEBUG_INIT \ 55 | GST_DEBUG_CATEGORY_INIT (gst_omx_mp3_enc_debug_category, "omxmp3enc", 0, \ 56 | "debug category for gst-omx audio encoder base class"); 57 | 58 | G_DEFINE_TYPE_WITH_CODE (GstOMXMP3Enc, gst_omx_mp3_enc, 59 | GST_TYPE_OMX_AUDIO_ENC, DEBUG_INIT); 60 | 61 | 62 | static void 63 | gst_omx_mp3_enc_class_init (GstOMXMP3EncClass * klass) 64 | { 65 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); 66 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 67 | GstOMXAudioEncClass *audioenc_class = GST_OMX_AUDIO_ENC_CLASS (klass); 68 | 69 | gobject_class->set_property = gst_omx_mp3_enc_set_property; 70 | gobject_class->get_property = gst_omx_mp3_enc_get_property; 71 | 72 | g_object_class_install_property (gobject_class, PROP_BITRATE, 73 | g_param_spec_uint ("bitrate", "Bitrate (kb/s)", 74 | "Bitrate in kbit/sec", 75 | 0, G_MAXUINT, DEFAULT_BITRATE, 76 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | 77 | GST_PARAM_MUTABLE_READY)); 78 | 79 | audioenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mp3_enc_set_format); 80 | audioenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_mp3_enc_get_caps); 81 | audioenc_class->get_num_samples = 82 | GST_DEBUG_FUNCPTR (gst_omx_mp3_enc_get_num_samples); 83 | 84 | audioenc_class->cdata.default_src_template_caps = "audio/mpeg, " 85 | "mpegversion=(int)1, " 86 | "layer=(int)3, " 87 | "mpegaudioversion=(int)[1,3], " 88 | "rate=(int)[8000,48000], " "channels=(int)[1,2]"; 89 | 90 | gst_element_class_set_static_metadata (element_class, 91 | "OpenMAX MP3 Audio Encoder", 92 | "Codec/Encoder/Audio/Hardware", 93 | "Encode AAC audio streams", "Julien Isorce "); 94 | 95 | gst_omx_set_default_role (&audioenc_class->cdata, "audio_encoder.mp3"); 96 | } 97 | 98 | static void 99 | gst_omx_mp3_enc_init (GstOMXMP3Enc * self) 100 | { 101 | self->mpegaudioversion = 1; 102 | self->bitrate = DEFAULT_BITRATE; 103 | } 104 | 105 | static void 106 | gst_omx_mp3_enc_set_property (GObject * object, guint prop_id, 107 | const GValue * value, GParamSpec * pspec) 108 | { 109 | GstOMXMP3Enc *self = GST_OMX_MP3_ENC (object); 110 | 111 | switch (prop_id) { 112 | case PROP_BITRATE: 113 | self->bitrate = g_value_get_uint (value); 114 | break; 115 | default: 116 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 117 | break; 118 | } 119 | } 120 | 121 | static void 122 | gst_omx_mp3_enc_get_property (GObject * object, guint prop_id, GValue * value, 123 | GParamSpec * pspec) 124 | { 125 | GstOMXMP3Enc *self = GST_OMX_MP3_ENC (object); 126 | 127 | switch (prop_id) { 128 | case PROP_BITRATE: 129 | g_value_set_uint (value, self->bitrate); 130 | break; 131 | default: 132 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 133 | break; 134 | } 135 | } 136 | 137 | static gboolean 138 | gst_omx_mp3_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port, 139 | GstAudioInfo * info) 140 | { 141 | GstOMXMP3Enc *self = GST_OMX_MP3_ENC (enc); 142 | OMX_AUDIO_PARAM_MP3TYPE mp3_param; 143 | GstCaps *peercaps; 144 | OMX_ERRORTYPE err; 145 | 146 | GST_OMX_INIT_STRUCT (&mp3_param); 147 | mp3_param.nPortIndex = enc->enc_out_port->index; 148 | 149 | err = 150 | gst_omx_component_get_parameter (enc->enc, OMX_IndexParamAudioMp3, 151 | &mp3_param); 152 | if (err != OMX_ErrorNone) { 153 | GST_ERROR_OBJECT (self, 154 | "Failed to get MP# parameters from component: %s (0x%08x)", 155 | gst_omx_error_to_string (err), err); 156 | return FALSE; 157 | } 158 | 159 | peercaps = gst_pad_peer_query_caps (GST_AUDIO_ENCODER_SRC_PAD (self), 160 | gst_pad_get_pad_template_caps (GST_AUDIO_ENCODER_SRC_PAD (self))); 161 | if (peercaps) { 162 | GstStructure *s; 163 | gint mpegaudioversion = 0; 164 | 165 | if (gst_caps_is_empty (peercaps)) { 166 | gst_caps_unref (peercaps); 167 | GST_ERROR_OBJECT (self, "Empty caps"); 168 | return FALSE; 169 | } 170 | 171 | s = gst_caps_get_structure (peercaps, 0); 172 | 173 | if (gst_structure_get_int (s, "mpegaudioversion", &mpegaudioversion)) { 174 | switch (mpegaudioversion) { 175 | case 1: 176 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP1Layer3; 177 | break; 178 | case 2: 179 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP2Layer3; 180 | break; 181 | case 3: 182 | mp3_param.eFormat = OMX_AUDIO_MP3StreamFormatMP2_5Layer3; 183 | break; 184 | default: 185 | GST_ERROR_OBJECT (self, "Unsupported mpegaudioversion '%d'", 186 | mpegaudioversion); 187 | gst_caps_unref (peercaps); 188 | return FALSE; 189 | } 190 | self->mpegaudioversion = mpegaudioversion; 191 | } 192 | 193 | gst_caps_unref (peercaps); 194 | 195 | mp3_param.nSampleRate = info->rate; 196 | mp3_param.nChannels = info->channels; 197 | 198 | mp3_param.eChannelMode = 199 | info->channels == 200 | 1 ? OMX_AUDIO_ChannelModeMono : OMX_AUDIO_ChannelModeStereo; 201 | } 202 | 203 | mp3_param.nBitRate = self->bitrate; 204 | 205 | err = 206 | gst_omx_component_set_parameter (enc->enc, OMX_IndexParamAudioMp3, 207 | &mp3_param); 208 | if (err != OMX_ErrorNone) { 209 | GST_ERROR_OBJECT (self, "Error setting MP3 parameters: %s (0x%08x)", 210 | gst_omx_error_to_string (err), err); 211 | return FALSE; 212 | } 213 | 214 | return TRUE; 215 | } 216 | 217 | static GstCaps * 218 | gst_omx_mp3_enc_get_caps (GstOMXAudioEnc * enc, GstOMXPort * port, 219 | GstAudioInfo * info) 220 | { 221 | GstCaps *caps; 222 | OMX_ERRORTYPE err; 223 | OMX_AUDIO_PARAM_MP3TYPE mp3_param; 224 | gint mpegaudioversion = 0; 225 | 226 | GST_OMX_INIT_STRUCT (&mp3_param); 227 | mp3_param.nPortIndex = enc->enc_out_port->index; 228 | 229 | err = 230 | gst_omx_component_get_parameter (enc->enc, OMX_IndexParamAudioMp3, 231 | &mp3_param); 232 | if (err != OMX_ErrorNone) { 233 | GST_ERROR_OBJECT (enc, 234 | "Failed to get MP3 parameters from component: %s (0x%08x)", 235 | gst_omx_error_to_string (err), err); 236 | return NULL; 237 | } 238 | 239 | switch (mp3_param.eFormat) { 240 | case OMX_AUDIO_MP3StreamFormatMP1Layer3: 241 | mpegaudioversion = 1; 242 | break; 243 | case OMX_AUDIO_MP3StreamFormatMP2Layer3: 244 | mpegaudioversion = 2; 245 | break; 246 | case OMX_AUDIO_MP3StreamFormatMP2_5Layer3: 247 | mpegaudioversion = 3; 248 | break; 249 | default: 250 | GST_ERROR_OBJECT (enc, "Unsupported mpegaudioversion %d", 251 | mp3_param.eFormat); 252 | break; 253 | } 254 | 255 | caps = 256 | gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "layer", 257 | G_TYPE_INT, 3, NULL); 258 | 259 | if (mpegaudioversion != 0) 260 | gst_caps_set_simple (caps, "mpegaudioversion", G_TYPE_INT, mpegaudioversion, 261 | NULL); 262 | if (mp3_param.nChannels != 0) 263 | gst_caps_set_simple (caps, "channels", G_TYPE_INT, mp3_param.nChannels, 264 | NULL); 265 | if (mp3_param.nSampleRate != 0) 266 | gst_caps_set_simple (caps, "rate", G_TYPE_INT, mp3_param.nSampleRate, NULL); 267 | 268 | return caps; 269 | 270 | } 271 | 272 | static guint 273 | gst_omx_mp3_enc_get_num_samples (GstOMXAudioEnc * enc, GstOMXPort * port, 274 | GstAudioInfo * info, GstOMXBuffer * buf) 275 | { 276 | GstOMXMP3Enc *self = GST_OMX_MP3_ENC (enc); 277 | return (self->mpegaudioversion == 1) ? 1152 : 576; 278 | } 279 | -------------------------------------------------------------------------------- /omx/gstomxmp3enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 3 | * Author: Julien Isorce 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_MP3_ENC_H__ 22 | #define __GST_OMX_MP3_ENC_H__ 23 | 24 | #include 25 | #include "gstomxaudioenc.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_MP3_ENC \ 30 | (gst_omx_mp3_enc_get_type()) 31 | #define GST_OMX_MP3_ENC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MP3_ENC,GstOMXMP3Enc)) 33 | #define GST_OMX_MP3_ENC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MP3_ENC,GstOMXMP3EncClass)) 35 | #define GST_OMX_MP3_ENC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MP3_ENC,GstOMXMP3EncClass)) 37 | #define GST_IS_OMX_MP3_ENC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MP3_ENC)) 39 | #define GST_IS_OMX_MP3_ENC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MP3_ENC)) 41 | 42 | typedef struct _GstOMXMP3Enc GstOMXMP3Enc; 43 | typedef struct _GstOMXMP3EncClass GstOMXMP3EncClass; 44 | 45 | struct _GstOMXMP3Enc 46 | { 47 | GstOMXAudioEnc parent; 48 | 49 | guint mpegaudioversion; 50 | 51 | /* properties */ 52 | guint bitrate; 53 | }; 54 | 55 | struct _GstOMXMP3EncClass 56 | { 57 | GstOMXAudioEncClass parent_class; 58 | }; 59 | 60 | GType gst_omx_mp3_enc_get_type (void); 61 | 62 | G_END_DECLS 63 | 64 | #endif /* __GST_OMX_MP3_ENC_H__ */ 65 | 66 | -------------------------------------------------------------------------------- /omx/gstomxmpeg2videodec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxmpeg2videodec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_mpeg2_video_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_mpeg2_video_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_mpeg2_video_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_mpeg2_video_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_mpeg2_video_dec_debug_category, "omxmpeg2dec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXMPEG2VideoDec, gst_omx_mpeg2_video_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | static void 53 | gst_omx_mpeg2_video_dec_class_init (GstOMXMPEG2VideoDecClass * klass) 54 | { 55 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 56 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 57 | 58 | videodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_mpeg2_video_dec_is_format_change); 60 | videodec_class->set_format = 61 | GST_DEBUG_FUNCPTR (gst_omx_mpeg2_video_dec_set_format); 62 | 63 | videodec_class->cdata.default_sink_template_caps = "video/mpeg, " 64 | "mpegversion=(int) [1, 2], " 65 | "systemstream=(boolean) false, " 66 | "parsed=(boolean) true, " "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 67 | 68 | gst_element_class_set_static_metadata (element_class, 69 | "OpenMAX MPEG2 Video Decoder", 70 | "Codec/Decoder/Video/Hardware", 71 | "Decode MPEG2 video streams", 72 | "Sebastian Dröge "); 73 | 74 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mpeg2"); 75 | } 76 | 77 | static void 78 | gst_omx_mpeg2_video_dec_init (GstOMXMPEG2VideoDec * self) 79 | { 80 | } 81 | 82 | static gboolean 83 | gst_omx_mpeg2_video_dec_is_format_change (GstOMXVideoDec * dec, 84 | GstOMXPort * port, GstVideoCodecState * state) 85 | { 86 | return FALSE; 87 | } 88 | 89 | static gboolean 90 | gst_omx_mpeg2_video_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 91 | GstVideoCodecState * state) 92 | { 93 | gboolean ret; 94 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 95 | 96 | gst_omx_port_get_port_definition (port, &port_def); 97 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2; 98 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 99 | 100 | return ret; 101 | } 102 | -------------------------------------------------------------------------------- /omx/gstomxmpeg2videodec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_MPEG2_VIDEO_DEC_H__ 22 | #define __GST_OMX_MPEG2_VIDEO_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_MPEG2_VIDEO_DEC \ 30 | (gst_omx_mpeg2_video_get_type()) 31 | #define GST_OMX_MPEG2_VIDEO_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MPEG2_VIDEO_DEC,GstOMXMPEG2VideoDec)) 33 | #define GST_OMX_MPEG2_VIDEO_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MPEG2_VIDEO_DEC,GstOMXMPEG2VideoDecClass)) 35 | #define GST_OMX_MPEG2_VIDEO_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MPEG2_VIDEO_DEC,GstOMXMPEG2VideoDecClass)) 37 | #define GST_IS_OMX_MPEG2_VIDEO_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MPEG2_VIDEO_DEC)) 39 | #define GST_IS_OMX_MPEG2_VIDEO_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MPEG2_VIDEO_DEC)) 41 | 42 | typedef struct _GstOMXMPEG2VideoDec GstOMXMPEG2VideoDec; 43 | typedef struct _GstOMXMPEG2VideoDecClass GstOMXMPEG2VideoDecClass; 44 | 45 | struct _GstOMXMPEG2VideoDec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXMPEG2VideoDecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_mpeg2_video_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_MPEG2_VIDEO_DEC_H__ */ 60 | -------------------------------------------------------------------------------- /omx/gstomxmpeg4videodec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxmpeg4videodec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_mpeg4_video_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_mpeg4_video_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_mpeg4_video_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_mpeg4_video_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_mpeg4_video_dec_debug_category, "omxmpeg4videodec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXMPEG4VideoDec, gst_omx_mpeg4_video_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | 53 | static void 54 | gst_omx_mpeg4_video_dec_class_init (GstOMXMPEG4VideoDecClass * klass) 55 | { 56 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 57 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 58 | 59 | videodec_class->is_format_change = 60 | GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_is_format_change); 61 | videodec_class->set_format = 62 | GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_set_format); 63 | 64 | videodec_class->cdata.default_sink_template_caps = "video/mpeg, " 65 | "mpegversion=(int) 4, " 66 | "systemstream=(boolean) false, " 67 | "parsed=(boolean) true, " "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 68 | 69 | gst_element_class_set_static_metadata (element_class, 70 | "OpenMAX MPEG4 Video Decoder", 71 | "Codec/Decoder/Video/Hardware", 72 | "Decode MPEG4 video streams", 73 | "Sebastian Dröge "); 74 | 75 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mpeg4"); 76 | } 77 | 78 | static void 79 | gst_omx_mpeg4_video_dec_init (GstOMXMPEG4VideoDec * self) 80 | { 81 | } 82 | 83 | static gboolean 84 | gst_omx_mpeg4_video_dec_is_format_change (GstOMXVideoDec * dec, 85 | GstOMXPort * port, GstVideoCodecState * state) 86 | { 87 | return FALSE; 88 | } 89 | 90 | static gboolean 91 | gst_omx_mpeg4_video_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 92 | GstVideoCodecState * state) 93 | { 94 | gboolean ret; 95 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 96 | 97 | gst_omx_port_get_port_definition (port, &port_def); 98 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; 99 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 100 | 101 | return ret; 102 | } 103 | -------------------------------------------------------------------------------- /omx/gstomxmpeg4videodec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_MPEG4_VIDEO_DEC_H__ 22 | #define __GST_OMX_MPEG4_VIDEO_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_MPEG4_VIDEO_DEC \ 30 | (gst_omx_mpeg4_video_dec_get_type()) 31 | #define GST_OMX_MPEG4_VIDEO_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MPEG4_VIDEO_DEC,GstOMXMPEG4VideoDec)) 33 | #define GST_OMX_MPEG4_VIDEO_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MPEG4_VIDEO_DEC,GstOMXMPEG4VideoDecClass)) 35 | #define GST_OMX_MPEG4_VIDEO_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MPEG4_VIDEO_DEC,GstOMXMPEG4VideoDecClass)) 37 | #define GST_IS_OMX_MPEG4_VIDEO_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MPEG4_VIDEO_DEC)) 39 | #define GST_IS_OMX_MPEG4_VIDEO_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MPEG4_VIDEO_DEC)) 41 | 42 | typedef struct _GstOMXMPEG4VideoDec GstOMXMPEG4VideoDec; 43 | typedef struct _GstOMXMPEG4VideoDecClass GstOMXMPEG4VideoDecClass; 44 | 45 | struct _GstOMXMPEG4VideoDec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXMPEG4VideoDecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_mpeg4_video_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_MPEG4_VIDEO_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxmpeg4videoenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_MPEG4_VIDEO_ENC_H__ 22 | #define __GST_OMX_MPEG4_VIDEO_ENC_H__ 23 | 24 | #include 25 | #include "gstomxvideoenc.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_MPEG4_VIDEO_ENC \ 30 | (gst_omx_mpeg4_video_enc_get_type()) 31 | #define GST_OMX_MPEG4_VIDEO_ENC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MPEG4_VIDEO_ENC,GstOMXMPEG4VideoEnc)) 33 | #define GST_OMX_MPEG4_VIDEO_ENC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MPEG4_VIDEO_ENC,GstOMXMPEG4VideoEncClass)) 35 | #define GST_OMX_MPEG4_VIDEO_ENC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MPEG4_VIDEO_ENC,GstOMXMPEG4VideoEncClass)) 37 | #define GST_IS_OMX_MPEG4_VIDEO_ENC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MPEG4_VIDEO_ENC)) 39 | #define GST_IS_OMX_MPEG4_VIDEO_ENC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MPEG4_VIDEO_ENC)) 41 | 42 | typedef struct _GstOMXMPEG4VideoEnc GstOMXMPEG4VideoEnc; 43 | typedef struct _GstOMXMPEG4VideoEncClass GstOMXMPEG4VideoEncClass; 44 | 45 | struct _GstOMXMPEG4VideoEnc 46 | { 47 | GstOMXVideoEnc parent; 48 | }; 49 | 50 | struct _GstOMXMPEG4VideoEncClass 51 | { 52 | GstOMXVideoEncClass parent_class; 53 | }; 54 | 55 | GType gst_omx_mpeg4_video_enc_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_MPEG4_VIDEO_ENC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxtheoradec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013, Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxtheoradec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_theora_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_theora_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_theora_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_theora_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | static GstFlowReturn gst_omx_theora_dec_handle_frame (GstVideoDecoder * decoder, 38 | GstVideoCodecFrame * frame); 39 | static gboolean gst_omx_theora_dec_stop (GstVideoDecoder * decoder); 40 | 41 | enum 42 | { 43 | PROP_0 44 | }; 45 | 46 | /* class initialization */ 47 | 48 | #define DEBUG_INIT \ 49 | GST_DEBUG_CATEGORY_INIT (gst_omx_theora_dec_debug_category, "omxtheoradec", 0, \ 50 | "debug category for gst-omx video decoder base class"); 51 | 52 | G_DEFINE_TYPE_WITH_CODE (GstOMXTheoraDec, gst_omx_theora_dec, 53 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 54 | 55 | static void 56 | gst_omx_theora_dec_class_init (GstOMXTheoraDecClass * klass) 57 | { 58 | GstVideoDecoderClass *gstvideodec_class = GST_VIDEO_DECODER_CLASS (klass); 59 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 60 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 61 | 62 | videodec_class->is_format_change = 63 | GST_DEBUG_FUNCPTR (gst_omx_theora_dec_is_format_change); 64 | videodec_class->set_format = 65 | GST_DEBUG_FUNCPTR (gst_omx_theora_dec_set_format); 66 | 67 | videodec_class->cdata.default_sink_template_caps = "video/x-theora, " 68 | "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 69 | 70 | gstvideodec_class->handle_frame = gst_omx_theora_dec_handle_frame; 71 | gstvideodec_class->stop = gst_omx_theora_dec_stop; 72 | 73 | gst_element_class_set_static_metadata (element_class, 74 | "OpenMAX Theora Video Decoder", 75 | "Codec/Decoder/Video/Hardware", 76 | "Decode Theora video streams", 77 | "Sebastian Dröge "); 78 | 79 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.theora"); 80 | } 81 | 82 | static void 83 | gst_omx_theora_dec_init (GstOMXTheoraDec * self) 84 | { 85 | } 86 | 87 | static gboolean 88 | gst_omx_theora_dec_is_format_change (GstOMXVideoDec * dec, 89 | GstOMXPort * port, GstVideoCodecState * state) 90 | { 91 | return FALSE; 92 | } 93 | 94 | static gboolean 95 | gst_omx_theora_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 96 | GstVideoCodecState * state) 97 | { 98 | gboolean ret; 99 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 100 | 101 | gst_omx_port_get_port_definition (port, &port_def); 102 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingTheora; 103 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 104 | 105 | return ret; 106 | } 107 | 108 | static GstFlowReturn 109 | gst_omx_theora_dec_handle_frame (GstVideoDecoder * decoder, 110 | GstVideoCodecFrame * frame) 111 | { 112 | GstOMXTheoraDec *self = GST_OMX_THEORA_DEC (decoder); 113 | 114 | if (GST_BUFFER_FLAG_IS_SET (frame->input_buffer, GST_BUFFER_FLAG_HEADER)) { 115 | guint16 size; 116 | GstBuffer *sbuf; 117 | 118 | if (!self->header) { 119 | self->header = gst_buffer_new (); 120 | gst_buffer_copy_into (self->header, frame->input_buffer, 121 | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1); 122 | } 123 | 124 | size = gst_buffer_get_size (frame->input_buffer); 125 | size = GUINT16_TO_BE (size); 126 | sbuf = gst_buffer_new_and_alloc (2); 127 | gst_buffer_fill (sbuf, 0, &size, 2); 128 | self->header = gst_buffer_append (self->header, sbuf); 129 | 130 | self->header = 131 | gst_buffer_append (self->header, gst_buffer_ref (frame->input_buffer)); 132 | 133 | gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame); 134 | 135 | return GST_FLOW_OK; 136 | } 137 | 138 | if (self->header) { 139 | gst_buffer_replace (&GST_OMX_VIDEO_DEC (self)->codec_data, self->header); 140 | gst_buffer_unref (self->header); 141 | self->header = NULL; 142 | } 143 | 144 | return 145 | GST_VIDEO_DECODER_CLASS (gst_omx_theora_dec_parent_class)->handle_frame 146 | (GST_VIDEO_DECODER (self), frame); 147 | } 148 | 149 | static gboolean 150 | gst_omx_theora_dec_stop (GstVideoDecoder * decoder) 151 | { 152 | GstOMXTheoraDec *self = GST_OMX_THEORA_DEC (decoder); 153 | 154 | gst_buffer_replace (&self->header, NULL); 155 | 156 | return TRUE; 157 | } 158 | -------------------------------------------------------------------------------- /omx/gstomxtheoradec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013, Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_THEORA_DEC_H__ 22 | #define __GST_OMX_THEORA_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_THEORA_DEC \ 30 | (gst_omx_theora_dec_get_type()) 31 | #define GST_OMX_THEORA_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_THEORA_DEC,GstOMXTheoraDec)) 33 | #define GST_OMX_THEORA_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_THEORA_DEC,GstOMXTheoraDecClass)) 35 | #define GST_OMX_THEORA_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_THEORA_DEC,GstOMXTheoraDecClass)) 37 | #define GST_IS_OMX_THEORA_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_THEORA_DEC)) 39 | #define GST_IS_OMX_THEORA_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_THEORA_DEC)) 41 | 42 | typedef struct _GstOMXTheoraDec GstOMXTheoraDec; 43 | typedef struct _GstOMXTheoraDecClass GstOMXTheoraDecClass; 44 | 45 | struct _GstOMXTheoraDec 46 | { 47 | GstOMXVideoDec parent; 48 | GstBuffer *header; 49 | }; 50 | 51 | struct _GstOMXTheoraDecClass 52 | { 53 | GstOMXVideoDecClass parent_class; 54 | }; 55 | 56 | GType gst_omx_theora_dec_get_type (void); 57 | 58 | G_END_DECLS 59 | 60 | #endif /* __GST_OMX_THEORA_DEC_H__ */ 61 | 62 | -------------------------------------------------------------------------------- /omx/gstomxvideo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Advanced Micro Devices, Inc. 3 | * Author: Christian König 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_VIDEO_H__ 22 | #define __GST_OMX_VIDEO_H__ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "gstomx.h" 34 | 35 | G_BEGIN_DECLS 36 | 37 | /* Keep synced with gst_omx_video_get_format_from_omx(). Sort by decreasing quality */ 38 | #define GST_OMX_VIDEO_DEC_SUPPORTED_FORMATS "{ NV16_10LE32, NV12_10LE32, " \ 39 | "NV16, YUY2, YVYU, UYVY, NV12, I420, RGB16, BGR16, ABGR, ARGB, GRAY8 }" 40 | 41 | #define GST_OMX_VIDEO_ENC_SUPPORTED_FORMATS "{ NV16_10LE32, NV12_10LE32, " \ 42 | "NV16, NV12, I420, GRAY8 }" 43 | 44 | typedef struct 45 | { 46 | GstVideoFormat format; 47 | OMX_COLOR_FORMATTYPE type; 48 | } GstOMXVideoNegotiationMap; 49 | 50 | GstVideoFormat 51 | gst_omx_video_get_format_from_omx (OMX_COLOR_FORMATTYPE omx_colorformat); 52 | 53 | GList * 54 | gst_omx_video_get_supported_colorformats (GstOMXPort * port, 55 | GstVideoCodecState * state); 56 | 57 | GstCaps * gst_omx_video_get_caps_for_map(GList * map); 58 | 59 | void 60 | gst_omx_video_negotiation_map_free (GstOMXVideoNegotiationMap * m); 61 | 62 | GstVideoCodecFrame * 63 | gst_omx_video_find_nearest_frame (GstElement * element, GstOMXBuffer * buf, GList * frames); 64 | 65 | OMX_U32 gst_omx_video_calculate_framerate_q16 (GstVideoInfo * info); 66 | 67 | gboolean gst_omx_video_is_equal_framerate_q16 (OMX_U32 q16_a, OMX_U32 q16_b); 68 | 69 | gboolean gst_omx_video_get_port_padding (GstOMXPort * port, GstVideoInfo * info_orig, 70 | GstVideoAlignment * align); 71 | 72 | G_END_DECLS 73 | 74 | #endif /* __GST_OMX_VIDEO_H__ */ 75 | -------------------------------------------------------------------------------- /omx/gstomxvideodec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_VIDEO_DEC_H__ 22 | #define __GST_OMX_VIDEO_DEC_H__ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "gstomx.h" 33 | 34 | G_BEGIN_DECLS 35 | 36 | #define GST_TYPE_OMX_VIDEO_DEC \ 37 | (gst_omx_video_dec_get_type()) 38 | #define GST_OMX_VIDEO_DEC(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDec)) 40 | #define GST_OMX_VIDEO_DEC_CLASS(klass) \ 41 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDecClass)) 42 | #define GST_OMX_VIDEO_DEC_GET_CLASS(obj) \ 43 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VIDEO_DEC,GstOMXVideoDecClass)) 44 | #define GST_IS_OMX_VIDEO_DEC(obj) \ 45 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VIDEO_DEC)) 46 | #define GST_IS_OMX_VIDEO_DEC_CLASS(obj) \ 47 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_DEC)) 48 | 49 | typedef struct _GstOMXVideoDec GstOMXVideoDec; 50 | typedef struct _GstOMXVideoDecClass GstOMXVideoDecClass; 51 | 52 | struct _GstOMXVideoDec 53 | { 54 | GstVideoDecoder parent; 55 | 56 | /* < protected > */ 57 | GstOMXComponent *dec; 58 | GstOMXPort *dec_in_port, *dec_out_port; 59 | 60 | GstBufferPool *in_port_pool, *out_port_pool; 61 | 62 | /* < private > */ 63 | GstVideoCodecState *input_state; 64 | GstBuffer *codec_data; 65 | /* TRUE if the component is configured and saw 66 | * the first buffer */ 67 | gboolean started; 68 | /* TRUE if the ports where disabled after being activated the first time. */ 69 | gboolean disabled; 70 | 71 | GstClockTime last_upstream_ts; 72 | 73 | /* Draining state */ 74 | GMutex drain_lock; 75 | GCond drain_cond; 76 | /* TRUE if EOS buffers shouldn't be forwarded */ 77 | gboolean draining; /* protected by drain_lock */ 78 | 79 | GstFlowReturn downstream_flow_ret; 80 | /* Initially FALSE. Switched to TRUE when all requirements 81 | * are met to try setting up the decoder with OMX_UseBuffer. 82 | * Switched to FALSE if this trial fails so that the decoder 83 | * can fallback to OMX_AllocateBuffer. */ 84 | gboolean use_buffers; 85 | 86 | #if defined (USE_OMX_TARGET_RPI) 87 | GstOMXComponent *egl_render; 88 | GstOMXPort *egl_in_port, *egl_out_port; 89 | #endif 90 | 91 | #if defined (HAVE_GST_GL) 92 | gboolean eglimage; 93 | #endif 94 | 95 | /* TRUE if decoder is producing dmabuf */ 96 | gboolean dmabuf; 97 | GstOMXBufferAllocation input_allocation; 98 | 99 | /* properties */ 100 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 101 | guint32 internal_entropy_buffers; 102 | #endif 103 | }; 104 | 105 | struct _GstOMXVideoDecClass 106 | { 107 | GstVideoDecoderClass parent_class; 108 | 109 | GstOMXClassData cdata; 110 | 111 | gboolean (*is_format_change) (GstOMXVideoDec * self, GstOMXPort * port, GstVideoCodecState * state); 112 | gboolean (*set_format) (GstOMXVideoDec * self, GstOMXPort * port, GstVideoCodecState * state); 113 | }; 114 | 115 | GType gst_omx_video_dec_get_type (void); 116 | 117 | G_END_DECLS 118 | 119 | #endif /* __GST_OMX_VIDEO_DEC_H__ */ 120 | -------------------------------------------------------------------------------- /omx/gstomxvideoenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_VIDEO_ENC_H__ 22 | #define __GST_OMX_VIDEO_ENC_H__ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "gstomx.h" 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define GST_TYPE_OMX_VIDEO_ENC \ 33 | (gst_omx_video_enc_get_type()) 34 | #define GST_OMX_VIDEO_ENC(obj) \ 35 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEnc)) 36 | #define GST_OMX_VIDEO_ENC_CLASS(klass) \ 37 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass)) 38 | #define GST_OMX_VIDEO_ENC_GET_CLASS(obj) \ 39 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass)) 40 | #define GST_IS_OMX_VIDEO_ENC(obj) \ 41 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VIDEO_ENC)) 42 | #define GST_IS_OMX_VIDEO_ENC_CLASS(obj) \ 43 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_ENC)) 44 | 45 | typedef struct _GstOMXVideoEnc GstOMXVideoEnc; 46 | typedef struct _GstOMXVideoEncClass GstOMXVideoEncClass; 47 | 48 | struct _GstOMXVideoEnc 49 | { 50 | GstVideoEncoder parent; 51 | 52 | /* < protected > */ 53 | GstOMXComponent *enc; 54 | GstOMXPort *enc_in_port, *enc_out_port; 55 | 56 | /* < private > */ 57 | GstVideoCodecState *input_state; 58 | /* TRUE if the component is configured and saw 59 | * the first buffer */ 60 | gboolean started; 61 | /* TRUE if the ports where disabled after being activated the first time. */ 62 | gboolean disabled; 63 | 64 | GstClockTime last_upstream_ts; 65 | 66 | /* Draining state */ 67 | GMutex drain_lock; 68 | GCond drain_cond; 69 | /* TRUE if EOS buffers shouldn't be forwarded */ 70 | gboolean draining; /* protected by drain_lock */ 71 | 72 | /* properties */ 73 | guint32 control_rate; 74 | guint32 target_bitrate; /* protected by object lock */ 75 | guint32 quant_i_frames; 76 | guint32 quant_p_frames; 77 | guint32 quant_b_frames; 78 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 79 | guint32 qp_mode; 80 | guint32 min_qp; 81 | guint32 max_qp; 82 | guint32 gop_mode; 83 | guint32 gdr_mode; 84 | guint32 initial_delay; 85 | guint32 cpb_size; 86 | guint32 scaling_list; 87 | gboolean low_bandwidth; 88 | guint32 max_bitrate; 89 | guint32 aspect_ratio; 90 | gboolean filler_data; 91 | guint32 num_slices; 92 | guint32 slice_size; 93 | gboolean dependent_slice; 94 | gint default_roi_quality; 95 | gboolean long_term_ref; 96 | guint32 long_term_freq; 97 | guint32 look_ahead; 98 | #endif 99 | 100 | guint32 default_target_bitrate; 101 | 102 | GstFlowReturn downstream_flow_ret; 103 | 104 | GstOMXBufferAllocation input_allocation; 105 | /* TRUE if encoder is passing dmabuf's fd directly to the OMX component */ 106 | gboolean input_dmabuf; 107 | /* Number of buffers requested downstream */ 108 | guint nb_downstream_buffers; 109 | 110 | /* TRUE if input buffers are from the pool we proposed to upstream */ 111 | gboolean in_pool_used; 112 | 113 | #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS 114 | GEnumClass *alg_roi_quality_enum_class; 115 | #endif 116 | }; 117 | 118 | struct _GstOMXVideoEncClass 119 | { 120 | GstVideoEncoderClass parent_class; 121 | 122 | GstOMXClassData cdata; 123 | 124 | gboolean (*set_format) (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state); 125 | GstCaps *(*get_caps) (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state); 126 | GstFlowReturn (*handle_output_frame) (GstOMXVideoEnc * self, GstOMXPort * port, GstOMXBuffer * buffer, GstVideoCodecFrame * frame); 127 | }; 128 | 129 | GType gst_omx_video_enc_get_type (void); 130 | 131 | G_END_DECLS 132 | 133 | #endif /* __GST_OMX_VIDEO_ENC_H__ */ 134 | -------------------------------------------------------------------------------- /omx/gstomxvp8dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013, Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxvp8dec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_vp8_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_vp8_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_vp8_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_vp8_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_vp8_dec_debug_category, "omxvp8dec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXVP8Dec, gst_omx_vp8_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | static void 53 | gst_omx_vp8_dec_class_init (GstOMXVP8DecClass * klass) 54 | { 55 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 56 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 57 | 58 | videodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_vp8_dec_is_format_change); 60 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_vp8_dec_set_format); 61 | 62 | videodec_class->cdata.default_sink_template_caps = "video/x-vp8, " 63 | "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 64 | 65 | gst_element_class_set_static_metadata (element_class, 66 | "OpenMAX VP8 Video Decoder", 67 | "Codec/Decoder/Video/Hardware", 68 | "Decode VP8 video streams", 69 | "Sebastian Dröge "); 70 | 71 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.vp8"); 72 | } 73 | 74 | static void 75 | gst_omx_vp8_dec_init (GstOMXVP8Dec * self) 76 | { 77 | } 78 | 79 | static gboolean 80 | gst_omx_vp8_dec_is_format_change (GstOMXVideoDec * dec, 81 | GstOMXPort * port, GstVideoCodecState * state) 82 | { 83 | return FALSE; 84 | } 85 | 86 | static gboolean 87 | gst_omx_vp8_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 88 | GstVideoCodecState * state) 89 | { 90 | gboolean ret; 91 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 92 | 93 | gst_omx_port_get_port_definition (port, &port_def); 94 | port_def.format.video.eCompressionFormat = 95 | (OMX_VIDEO_CODINGTYPE) OMX_VIDEO_CodingVP8; 96 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 97 | 98 | return ret; 99 | } 100 | -------------------------------------------------------------------------------- /omx/gstomxvp8dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013, Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_VP8_DEC_H__ 22 | #define __GST_OMX_VP8_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_VP8_DEC \ 30 | (gst_omx_vp8_dec_get_type()) 31 | #define GST_OMX_VP8_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VP8_DEC,GstOMXVP8Dec)) 33 | #define GST_OMX_VP8_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VP8_DEC,GstOMXVP8DecClass)) 35 | #define GST_OMX_VP8_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VP8_DEC,GstOMXVP8DecClass)) 37 | #define GST_IS_OMX_VP8_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VP8_DEC)) 39 | #define GST_IS_OMX_VP8_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VP8_DEC)) 41 | 42 | typedef struct _GstOMXVP8Dec GstOMXVP8Dec; 43 | typedef struct _GstOMXVP8DecClass GstOMXVP8DecClass; 44 | 45 | struct _GstOMXVP8Dec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXVP8DecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_vp8_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_VP8_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/gstomxwmvdec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | 27 | #include "gstomxwmvdec.h" 28 | 29 | GST_DEBUG_CATEGORY_STATIC (gst_omx_wmv_dec_debug_category); 30 | #define GST_CAT_DEFAULT gst_omx_wmv_dec_debug_category 31 | 32 | /* prototypes */ 33 | static gboolean gst_omx_wmv_dec_is_format_change (GstOMXVideoDec * dec, 34 | GstOMXPort * port, GstVideoCodecState * state); 35 | static gboolean gst_omx_wmv_dec_set_format (GstOMXVideoDec * dec, 36 | GstOMXPort * port, GstVideoCodecState * state); 37 | 38 | enum 39 | { 40 | PROP_0 41 | }; 42 | 43 | /* class initialization */ 44 | 45 | #define DEBUG_INIT \ 46 | GST_DEBUG_CATEGORY_INIT (gst_omx_wmv_dec_debug_category, "omxwmvdec", 0, \ 47 | "debug category for gst-omx video decoder base class"); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (GstOMXWMVDec, gst_omx_wmv_dec, 50 | GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); 51 | 52 | static void 53 | gst_omx_wmv_dec_class_init (GstOMXWMVDecClass * klass) 54 | { 55 | GstElementClass *element_class = GST_ELEMENT_CLASS (klass); 56 | GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); 57 | 58 | videodec_class->is_format_change = 59 | GST_DEBUG_FUNCPTR (gst_omx_wmv_dec_is_format_change); 60 | videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_wmv_dec_set_format); 61 | 62 | videodec_class->cdata.default_sink_template_caps = "video/x-wmv, " 63 | "width=(int) [1,MAX], " "height=(int) [1,MAX]"; 64 | 65 | gst_element_class_set_static_metadata (element_class, 66 | "OpenMAX WMV Video Decoder", 67 | "Codec/Decoder/Video/Hardware", 68 | "Decode WMV video streams", 69 | "Sebastian Dröge "); 70 | 71 | gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.wmv"); 72 | } 73 | 74 | static void 75 | gst_omx_wmv_dec_init (GstOMXWMVDec * self) 76 | { 77 | } 78 | 79 | static gboolean 80 | gst_omx_wmv_dec_is_format_change (GstOMXVideoDec * dec, 81 | GstOMXPort * port, GstVideoCodecState * state) 82 | { 83 | return FALSE; 84 | } 85 | 86 | static gboolean 87 | gst_omx_wmv_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, 88 | GstVideoCodecState * state) 89 | { 90 | gboolean ret; 91 | OMX_PARAM_PORTDEFINITIONTYPE port_def; 92 | 93 | gst_omx_port_get_port_definition (port, &port_def); 94 | port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV; 95 | ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; 96 | 97 | return ret; 98 | } 99 | -------------------------------------------------------------------------------- /omx/gstomxwmvdec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. 3 | * Author: Sebastian Dröge , Collabora Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifndef __GST_OMX_WMV_DEC_H__ 22 | #define __GST_OMX_WMV_DEC_H__ 23 | 24 | #include 25 | #include "gstomxvideodec.h" 26 | 27 | G_BEGIN_DECLS 28 | 29 | #define GST_TYPE_OMX_WMV_DEC \ 30 | (gst_omx_wmv_dec_get_type()) 31 | #define GST_OMX_WMV_DEC(obj) \ 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDec)) 33 | #define GST_OMX_WMV_DEC_CLASS(klass) \ 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDecClass)) 35 | #define GST_OMX_WMV_DEC_GET_CLASS(obj) \ 36 | (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDecClass)) 37 | #define GST_IS_OMX_WMV_DEC(obj) \ 38 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_WMV_DEC)) 39 | #define GST_IS_OMX_WMV_DEC_CLASS(obj) \ 40 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_WMV_DEC)) 41 | 42 | typedef struct _GstOMXWMVDec GstOMXWMVDec; 43 | typedef struct _GstOMXWMVDecClass GstOMXWMVDecClass; 44 | 45 | struct _GstOMXWMVDec 46 | { 47 | GstOMXVideoDec parent; 48 | }; 49 | 50 | struct _GstOMXWMVDecClass 51 | { 52 | GstOMXVideoDecClass parent_class; 53 | }; 54 | 55 | GType gst_omx_wmv_dec_get_type (void); 56 | 57 | G_END_DECLS 58 | 59 | #endif /* __GST_OMX_WMV_DEC_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /omx/meson.build: -------------------------------------------------------------------------------- 1 | omx_sources = [ 2 | 'gstomx.c', 3 | 'gstomxallocator.c', 4 | 'gstomxbufferpool.c', 5 | 'gstomxvideo.c', 6 | 'gstomxvideodec.c', 7 | 'gstomxvideoenc.c', 8 | 'gstomxaudiodec.c', 9 | 'gstomxaudioenc.c', 10 | 'gstomxmjpegdec.c', 11 | 'gstomxmpeg4videodec.c', 12 | 'gstomxmpeg2videodec.c', 13 | 'gstomxh264dec.c', 14 | 'gstomxh264utils.c', 15 | 'gstomxh263dec.c', 16 | 'gstomxwmvdec.c', 17 | 'gstomxmpeg4videoenc.c', 18 | 'gstomxh264enc.c', 19 | 'gstomxh263enc.c', 20 | 'gstomxaacdec.c', 21 | 'gstomxmp3dec.c', 22 | 'gstomxaacenc.c', 23 | 'gstomxamrdec.c', 24 | 'gstomxaudiosink.c', 25 | 'gstomxanalogaudiosink.c', 26 | 'gstomxhdmiaudiosink.c', 27 | 'gstomxmp3enc.c', 28 | ] 29 | 30 | extra_c_args = [] 31 | 32 | if have_omx_vp8 33 | omx_sources += 'gstomxvp8dec.c' 34 | endif 35 | 36 | if have_omx_theora 37 | omx_sources += 'gstomxtheoradec.c' 38 | endif 39 | 40 | if have_omx_hevc 41 | omx_sources += 'gstomxh265utils.c' 42 | omx_sources += 'gstomxh265enc.c' 43 | omx_sources += 'gstomxh265dec.c' 44 | endif 45 | 46 | optional_deps = [] 47 | if gstgl_dep.found() 48 | optional_deps += gstgl_dep 49 | extra_c_args += ['-DGST_USE_UNSTABLE_API'] 50 | endif 51 | 52 | gstomx = library('gstomx', 53 | omx_sources, 54 | c_args : gst_omx_args + extra_c_args, 55 | # link_args : noseh_link_args, 56 | include_directories : [configinc, omx_inc], 57 | dependencies : [gstvideo_dep, gstaudio_dep, gstbase_dep, gstcontroller_dep, 58 | libm, gmodule_dep, gstallocators_dep] + optional_deps, 59 | install : true, 60 | install_dir : plugins_install_dir, 61 | ) 62 | 63 | plugins = [gstomx] -------------------------------------------------------------------------------- /omx/openmax/OMX_ComponentExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The Khronos Group Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject 10 | * to the following conditions: 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | 24 | /** OMX_ComponentExt.h - OpenMax IL version 1.1.2 25 | * The OMX_ComponentExt header file contains extensions to the definitions used 26 | * by both the application and the component to access common items. 27 | */ 28 | 29 | #ifndef OMX_ComponentExt_h 30 | #define OMX_ComponentExt_h 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /* Each OMX header must include all required header files to allow the 37 | * header to compile without errors. The includes below are required 38 | * for this header file to compile successfully 39 | */ 40 | #include 41 | 42 | 43 | /** Set/query the commit mode */ 44 | typedef struct OMX_CONFIG_COMMITMODETYPE { 45 | OMX_U32 nSize; 46 | OMX_VERSIONTYPE nVersion; 47 | OMX_BOOL bDeferred; 48 | } OMX_CONFIG_COMMITMODETYPE; 49 | 50 | /** Explicit commit */ 51 | typedef struct OMX_CONFIG_COMMITTYPE { 52 | OMX_U32 nSize; 53 | OMX_VERSIONTYPE nVersion; 54 | } OMX_CONFIG_COMMITTYPE; 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif /* __cplusplus */ 60 | 61 | #endif /* OMX_ComponentExt_h */ 62 | -------------------------------------------------------------------------------- /omx/openmax/OMX_ContentPipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 The Khronos Group Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject 10 | * to the following conditions: 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | 24 | /** OMX_ContentPipe.h - OpenMax IL version 1.1.2 25 | * The OMX_ContentPipe header file contains the definitions used to define 26 | * the public interface for content piples. This header file is intended to 27 | * be used by the component. 28 | */ 29 | 30 | #ifndef OMX_CONTENTPIPE_H 31 | #define OMX_CONTENTPIPE_H 32 | 33 | #ifndef KD_EACCES 34 | /* OpenKODE error codes. CPResult values may be zero (indicating success 35 | or one of the following values) */ 36 | #define KD_EACCES (1) 37 | #define KD_EADDRINUSE (2) 38 | #define KD_EAGAIN (5) 39 | #define KD_EBADF (7) 40 | #define KD_EBUSY (8) 41 | #define KD_ECONNREFUSED (9) 42 | #define KD_ECONNRESET (10) 43 | #define KD_EDEADLK (11) 44 | #define KD_EDESTADDRREQ (12) 45 | #define KD_ERANGE (35) 46 | #define KD_EEXIST (13) 47 | #define KD_EFBIG (14) 48 | #define KD_EHOSTUNREACH (15) 49 | #define KD_EINVAL (17) 50 | #define KD_EIO (18) 51 | #define KD_EISCONN (20) 52 | #define KD_EISDIR (21) 53 | #define KD_EMFILE (22) 54 | #define KD_ENAMETOOLONG (23) 55 | #define KD_ENOENT (24) 56 | #define KD_ENOMEM (25) 57 | #define KD_ENOSPC (26) 58 | #define KD_ENOSYS (27) 59 | #define KD_ENOTCONN (28) 60 | #define KD_EPERM (33) 61 | #define KD_ETIMEDOUT (36) 62 | #define KD_EILSEQ (19) 63 | #endif 64 | 65 | /** Map types from OMX standard types only here so interface is as generic as possible. */ 66 | typedef OMX_U32 CPresult; 67 | typedef char * CPstring; 68 | typedef void * CPhandle; 69 | typedef OMX_U32 CPuint; 70 | typedef OMX_S32 CPint; 71 | typedef char CPbyte; 72 | typedef OMX_BOOL CPbool; 73 | 74 | /** enumeration of origin types used in the CP_PIPETYPE's Seek function 75 | * @ingroup cp 76 | */ 77 | typedef enum CP_ORIGINTYPE { 78 | CP_OriginBegin, 79 | CP_OriginCur, 80 | CP_OriginEnd, 81 | CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 82 | CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ 83 | CP_OriginMax = 0X7FFFFFFF 84 | } CP_ORIGINTYPE; 85 | 86 | /** enumeration of contact access types used in the CP_PIPETYPE's Open function 87 | * @ingroup cp 88 | */ 89 | typedef enum CP_ACCESSTYPE { 90 | CP_AccessRead, 91 | CP_AccessWrite, 92 | CP_AccessReadWrite , 93 | CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 94 | CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ 95 | CP_AccessMax = 0X7FFFFFFF 96 | } CP_ACCESSTYPE; 97 | 98 | /** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function 99 | * @ingroup cp 100 | */ 101 | typedef enum CP_CHECKBYTESRESULTTYPE 102 | { 103 | CP_CheckBytesOk, /**< There are at least the request number 104 | of bytes available */ 105 | CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes 106 | and presently lacks sufficient bytes. 107 | Client will be called when they are 108 | sufficient bytes are available. */ 109 | CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes 110 | but those available are less than those 111 | requested */ 112 | CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream 113 | and no more bytes are available. */ 114 | CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ 115 | CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 116 | CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ 117 | CP_CheckBytesMax = 0X7FFFFFFF 118 | } CP_CHECKBYTESRESULTTYPE; 119 | 120 | /** enumeration of content pipe events sent to the client callback. 121 | * @ingroup cp 122 | */ 123 | typedef enum CP_EVENTTYPE{ 124 | CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ 125 | CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ 126 | CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/ 127 | CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 128 | CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ 129 | CP_EventMax = 0X7FFFFFFF 130 | } CP_EVENTTYPE; 131 | 132 | /** content pipe definition 133 | * @ingroup cp 134 | */ 135 | typedef struct CP_PIPETYPE 136 | { 137 | /** Open a content stream for reading or writing. */ 138 | CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); 139 | 140 | /** Close a content stream. */ 141 | CPresult (*Close)( CPhandle hContent ); 142 | 143 | /** Create a content source and open it for writing. */ 144 | CPresult (*Create)( CPhandle *hContent, CPstring szURI ); 145 | 146 | /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ 147 | CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); 148 | 149 | /** Seek to certain position in the content relative to the specified origin. */ 150 | CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); 151 | 152 | /** Retrieve the current position relative to the start of the content. */ 153 | CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); 154 | 155 | /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). 156 | Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ 157 | CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); 158 | 159 | /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. 160 | Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also 161 | returns the size of the block actually read. Content pointer advances the by the returned size. 162 | Note: pipe provides pointer. This function is appropriate for large reads. The client must call 163 | ReleaseReadBuffer when done with buffer. 164 | 165 | In some cases the requested block may not reside in contiguous memory within the 166 | pipe implementation. For instance if the pipe leverages a circular buffer then the requested 167 | block may straddle the boundary of the circular buffer. By default a pipe implementation 168 | performs a copy in this case to provide the block to the pipe client in one contiguous buffer. 169 | If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory 170 | boundary. Here the client may retrieve the data in segments over successive calls. */ 171 | CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); 172 | 173 | /** Release a buffer obtained by ReadBuffer back to the pipe. */ 174 | CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); 175 | 176 | /** Write data of the specified size to the content (advance content pointer by size of data). 177 | Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ 178 | CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); 179 | 180 | /** Retrieve a buffer allocated by the pipe used to write data to the content. 181 | Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate 182 | for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ 183 | CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); 184 | 185 | /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the 186 | the contents of the buffer to content and advance content pointer by the size of the buffer */ 187 | CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); 188 | 189 | /** Register a per-handle client callback with the content pipe. */ 190 | CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); 191 | 192 | } CP_PIPETYPE; 193 | 194 | #endif 195 | 196 | -------------------------------------------------------------------------------- /omx/openmax/OMX_CoreExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The Khronos Group Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject 10 | * to the following conditions: 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | 24 | /** OMX_CoreExt.h - OpenMax IL version 1.1.2 25 | * The OMX_CoreExt header file contains extensions to the definitions used 26 | * by both the application and the component to access common items. 27 | */ 28 | 29 | #ifndef OMX_CoreExt_h 30 | #define OMX_CoreExt_h 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /* Each OMX header shall include all required header files to allow the 37 | * header to compile without errors. The includes below are required 38 | * for this header file to compile successfully 39 | */ 40 | #include 41 | 42 | /** Extensions to the standard IL errors. */ 43 | typedef enum OMX_ERROREXTTYPE 44 | { 45 | OMX_ErrorInvalidMode = (OMX_S32) (OMX_ErrorKhronosExtensions + 0x00000001), 46 | OMX_ErrorExtMax = 0x7FFFFFFF 47 | } OMX_ERROREXTTYPE; 48 | 49 | 50 | /** Event type extensions. */ 51 | typedef enum OMX_EVENTEXTTYPE 52 | { 53 | OMX_EventIndexSettingChanged = OMX_EventKhronosExtensions, /**< component signals the IL client of a change 54 | in a param, config, or extension */ 55 | OMX_EventExtMax = 0x7FFFFFFF 56 | } OMX_EVENTEXTTYPE; 57 | 58 | 59 | /** Enable or disable a callback event. */ 60 | typedef struct OMX_CONFIG_CALLBACKREQUESTTYPE { 61 | OMX_U32 nSize; /**< size of the structure in bytes */ 62 | OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ 63 | OMX_U32 nPortIndex; /**< port that this structure applies to */ 64 | OMX_INDEXTYPE nIndex; /**< the index the callback is requested for */ 65 | OMX_BOOL bEnable; /**< enable (OMX_TRUE) or disable (OMX_FALSE) the callback */ 66 | } OMX_CONFIG_CALLBACKREQUESTTYPE; 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif /* __cplusplus */ 71 | 72 | #endif /* OMX_CoreExt_h */ 73 | /* File EOF */ 74 | -------------------------------------------------------------------------------- /omx/openmax/OMX_IndexExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The Khronos Group Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject 10 | * to the following conditions: 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | 24 | /** @file OMX_IndexExt.h - OpenMax IL version 1.1.2 25 | * The OMX_IndexExt header file contains extensions to the definitions 26 | * for both applications and components . 27 | */ 28 | 29 | #ifndef OMX_IndexExt_h 30 | #define OMX_IndexExt_h 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /* Each OMX header shall include all required header files to allow the 37 | * header to compile without errors. The includes below are required 38 | * for this header file to compile successfully 39 | */ 40 | #include 41 | 42 | 43 | /** Khronos standard extension indices. 44 | 45 | This enum lists the current Khronos extension indices to OpenMAX IL. 46 | */ 47 | typedef enum OMX_INDEXEXTTYPE { 48 | 49 | /* Component parameters and configurations */ 50 | OMX_IndexExtComponentStartUnused = OMX_IndexKhronosExtensions + 0x00100000, 51 | OMX_IndexConfigCallbackRequest, /**< reference: OMX_CONFIG_CALLBACKREQUESTTYPE */ 52 | OMX_IndexConfigCommitMode, /**< reference: OMX_CONFIG_COMMITMODETYPE */ 53 | OMX_IndexConfigCommit, /**< reference: OMX_CONFIG_COMMITTYPE */ 54 | 55 | /* Port parameters and configurations */ 56 | OMX_IndexExtPortStartUnused = OMX_IndexKhronosExtensions + 0x00200000, 57 | 58 | /* Audio parameters and configurations */ 59 | OMX_IndexExtAudioStartUnused = OMX_IndexKhronosExtensions + 0x00400000, 60 | 61 | /* Image parameters and configurations */ 62 | OMX_IndexExtImageStartUnused = OMX_IndexKhronosExtensions + 0x00500000, 63 | 64 | /* Video parameters and configurations */ 65 | OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000, 66 | OMX_IndexParamNalStreamFormatSupported, /**< reference: OMX_NALSTREAMFORMATTYPE */ 67 | OMX_IndexParamNalStreamFormat, /**< reference: OMX_NALSTREAMFORMATTYPE */ 68 | OMX_IndexParamNalStreamFormatSelect, /**< reference: OMX_NALSTREAMFORMATTYPE */ 69 | 70 | /* Image & Video common configurations */ 71 | OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000, 72 | 73 | /* Other configurations */ 74 | OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000, 75 | 76 | /* Time configurations */ 77 | OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000, 78 | 79 | OMX_IndexExtMax = 0x7FFFFFFF 80 | } OMX_INDEXEXTTYPE; 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif /* __cplusplus */ 85 | 86 | #endif /* OMX_IndexExt_h */ 87 | /* File EOF */ 88 | -------------------------------------------------------------------------------- /omx/openmax/OMX_Other.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GStreamer/gst-omx/9fc9a20652a35ecfb4992697bf6481bdd74d51d9/omx/openmax/OMX_Other.h -------------------------------------------------------------------------------- /omx/openmax/OMX_VideoExt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The Khronos Group Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject 10 | * to the following conditions: 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | 24 | /** OMX_VideoExt.h - OpenMax IL version 1.1.2 25 | * The OMX_VideoExt header file contains extensions to the 26 | * definitions used by both the application and the component to 27 | * access video items. 28 | */ 29 | 30 | #ifndef OMX_VideoExt_h 31 | #define OMX_VideoExt_h 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif /* __cplusplus */ 36 | 37 | /* Each OMX header shall include all required header files to allow the 38 | * header to compile without errors. The includes below are required 39 | * for this header file to compile successfully 40 | */ 41 | #include 42 | 43 | /** NALU Formats */ 44 | typedef enum OMX_NALUFORMATSTYPE { 45 | OMX_NaluFormatStartCodes = 1, 46 | OMX_NaluFormatOneNaluPerBuffer = 2, 47 | OMX_NaluFormatOneByteInterleaveLength = 4, 48 | OMX_NaluFormatTwoByteInterleaveLength = 8, 49 | OMX_NaluFormatFourByteInterleaveLength = 16, 50 | OMX_NaluFormatCodingMax = 0x7FFFFFFF 51 | } OMX_NALUFORMATSTYPE; 52 | 53 | 54 | /** NAL Stream Format */ 55 | typedef struct OMX_NALSTREAMFORMATTYPE{ 56 | OMX_U32 nSize; 57 | OMX_VERSIONTYPE nVersion; 58 | OMX_U32 nPortIndex; 59 | OMX_NALUFORMATSTYPE eNaluFormat; 60 | } OMX_NALSTREAMFORMATTYPE; 61 | 62 | 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif /* __cplusplus */ 67 | 68 | #endif /* OMX_VideoExt_h */ 69 | /* File EOF */ 70 | -------------------------------------------------------------------------------- /scripts/extract-release-date-from-doap-file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # extract-release-date-from-doap-file.py VERSION DOAP-FILE 4 | # 5 | # Extract release date for the given release version from a DOAP file 6 | # 7 | # Copyright (C) 2020 Tim-Philipp Müller 8 | # 9 | # This library is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU Library General Public 11 | # License as published by the Free Software Foundation; either 12 | # version 2 of the License, or (at your option) any later version. 13 | # 14 | # This library is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # Library General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU Library General Public 20 | # License along with this library; if not, write to the 21 | # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 22 | # Boston, MA 02110-1301, USA. 23 | 24 | import sys 25 | import xml.etree.ElementTree as ET 26 | 27 | if len(sys.argv) != 3: 28 | sys.exit('Usage: {} VERSION DOAP-FILE'.format(sys.argv[0])) 29 | 30 | release_version = sys.argv[1] 31 | doap_fn = sys.argv[2] 32 | 33 | tree = ET.parse(doap_fn) 34 | root = tree.getroot() 35 | 36 | namespaces = {'doap': 'http://usefulinc.com/ns/doap#'} 37 | 38 | for v in root.findall('doap:release/doap:Version', namespaces=namespaces): 39 | if v.findtext('doap:revision', namespaces=namespaces) == release_version: 40 | release_date = v.findtext('doap:created', namespaces=namespaces) 41 | if release_date: 42 | print(release_date) 43 | sys.exit(0) 44 | 45 | sys.exit('Could not find a release with version {} in {}'.format(release_version, doap_fn)) 46 | -------------------------------------------------------------------------------- /tests/check/generic/states.c: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * 3 | * unit test for state changes on all elements 4 | * 5 | * Copyright (C) <2005> Thomas Vander Stichele 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Library General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Library General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Library General Public 18 | * License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | # include "config.h" 25 | #endif 26 | 27 | #include 28 | 29 | #include 30 | 31 | static GList *elements = NULL; 32 | 33 | static void 34 | setup (void) 35 | { 36 | GList *features, *f; 37 | GList *plugins, *p; 38 | gchar **ignorelist = NULL; 39 | const gchar *STATE_IGNORE_ELEMENTS = NULL; 40 | GstRegistry *def; 41 | 42 | GST_DEBUG ("getting elements for package %s", PACKAGE); 43 | STATE_IGNORE_ELEMENTS = g_getenv ("GST_STATE_IGNORE_ELEMENTS"); 44 | if (!g_getenv ("GST_NO_STATE_IGNORE_ELEMENTS") && STATE_IGNORE_ELEMENTS) { 45 | GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS); 46 | ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0); 47 | } 48 | 49 | def = gst_registry_get (); 50 | 51 | plugins = gst_registry_get_plugin_list (def); 52 | 53 | for (p = plugins; p; p = p->next) { 54 | GstPlugin *plugin = p->data; 55 | 56 | if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0) 57 | continue; 58 | 59 | features = 60 | gst_registry_get_feature_list_by_plugin (def, 61 | gst_plugin_get_name (plugin)); 62 | 63 | for (f = features; f; f = f->next) { 64 | GstPluginFeature *feature = f->data; 65 | const gchar *name = gst_plugin_feature_get_name (feature); 66 | gboolean ignore = FALSE; 67 | 68 | if (!GST_IS_ELEMENT_FACTORY (feature)) 69 | continue; 70 | 71 | if (ignorelist) { 72 | gchar **s; 73 | 74 | for (s = ignorelist; s && *s; ++s) { 75 | if (g_str_has_prefix (name, *s)) { 76 | GST_DEBUG ("ignoring element %s", name); 77 | ignore = TRUE; 78 | } 79 | } 80 | if (ignore) 81 | continue; 82 | } 83 | 84 | GST_DEBUG ("adding element %s", name); 85 | elements = g_list_prepend (elements, (gpointer) g_strdup (name)); 86 | } 87 | gst_plugin_feature_list_free (features); 88 | } 89 | gst_plugin_list_free (plugins); 90 | g_strfreev (ignorelist); 91 | } 92 | 93 | static void 94 | teardown (void) 95 | { 96 | GList *e; 97 | 98 | for (e = elements; e; e = e->next) { 99 | g_free (e->data); 100 | } 101 | g_list_free (elements); 102 | elements = NULL; 103 | } 104 | 105 | 106 | GST_START_TEST (test_state_changes_up_and_down_seq) 107 | { 108 | GstElement *element; 109 | GList *e; 110 | 111 | for (e = elements; e; e = e->next) { 112 | const gchar *name = e->data; 113 | 114 | GST_INFO ("testing element %s", name); 115 | element = gst_element_factory_make (name, name); 116 | fail_if (element == NULL, "Could not make element from factory %s", name); 117 | 118 | if (GST_IS_PIPELINE (element)) { 119 | GST_DEBUG ("element %s is a pipeline", name); 120 | } 121 | 122 | gst_element_set_state (element, GST_STATE_READY); 123 | gst_element_set_state (element, GST_STATE_PAUSED); 124 | gst_element_set_state (element, GST_STATE_PLAYING); 125 | gst_element_set_state (element, GST_STATE_PAUSED); 126 | gst_element_set_state (element, GST_STATE_READY); 127 | gst_element_set_state (element, GST_STATE_NULL); 128 | gst_element_set_state (element, GST_STATE_PAUSED); 129 | gst_element_set_state (element, GST_STATE_READY); 130 | gst_element_set_state (element, GST_STATE_PLAYING); 131 | gst_element_set_state (element, GST_STATE_PAUSED); 132 | gst_element_set_state (element, GST_STATE_NULL); 133 | gst_object_unref (GST_OBJECT (element)); 134 | } 135 | } 136 | 137 | GST_END_TEST; 138 | 139 | GST_START_TEST (test_state_changes_up_seq) 140 | { 141 | GstElement *element; 142 | GList *e; 143 | 144 | for (e = elements; e; e = e->next) { 145 | const gchar *name = e->data; 146 | 147 | GST_INFO ("testing element %s", name); 148 | element = gst_element_factory_make (name, name); 149 | fail_if (element == NULL, "Could not make element from factory %s", name); 150 | 151 | if (GST_IS_PIPELINE (element)) { 152 | GST_DEBUG ("element %s is a pipeline", name); 153 | } 154 | 155 | gst_element_set_state (element, GST_STATE_READY); 156 | 157 | gst_element_set_state (element, GST_STATE_PAUSED); 158 | gst_element_set_state (element, GST_STATE_READY); 159 | 160 | gst_element_set_state (element, GST_STATE_PAUSED); 161 | gst_element_set_state (element, GST_STATE_PLAYING); 162 | gst_element_set_state (element, GST_STATE_PAUSED); 163 | gst_element_set_state (element, GST_STATE_READY); 164 | 165 | gst_element_set_state (element, GST_STATE_NULL); 166 | gst_object_unref (GST_OBJECT (element)); 167 | } 168 | } 169 | 170 | GST_END_TEST; 171 | 172 | GST_START_TEST (test_state_changes_down_seq) 173 | { 174 | GstElement *element; 175 | GList *e; 176 | 177 | for (e = elements; e; e = e->next) { 178 | const gchar *name = e->data; 179 | 180 | GST_INFO ("testing element %s", name); 181 | element = gst_element_factory_make (name, name); 182 | fail_if (element == NULL, "Could not make element from factory %s", name); 183 | 184 | if (GST_IS_PIPELINE (element)) { 185 | GST_DEBUG ("element %s is a pipeline", name); 186 | } 187 | 188 | gst_element_set_state (element, GST_STATE_READY); 189 | gst_element_set_state (element, GST_STATE_PAUSED); 190 | gst_element_set_state (element, GST_STATE_PLAYING); 191 | 192 | gst_element_set_state (element, GST_STATE_PAUSED); 193 | gst_element_set_state (element, GST_STATE_PLAYING); 194 | 195 | gst_element_set_state (element, GST_STATE_PAUSED); 196 | gst_element_set_state (element, GST_STATE_READY); 197 | gst_element_set_state (element, GST_STATE_PAUSED); 198 | gst_element_set_state (element, GST_STATE_PLAYING); 199 | 200 | gst_element_set_state (element, GST_STATE_PAUSED); 201 | gst_element_set_state (element, GST_STATE_READY); 202 | gst_element_set_state (element, GST_STATE_NULL); 203 | gst_object_unref (GST_OBJECT (element)); 204 | } 205 | } 206 | 207 | GST_END_TEST; 208 | 209 | 210 | static Suite * 211 | states_suite (void) 212 | { 213 | Suite *s = suite_create ("states_omx"); 214 | TCase *tc_chain = tcase_create ("general"); 215 | 216 | suite_add_tcase (s, tc_chain); 217 | tcase_add_checked_fixture (tc_chain, setup, teardown); 218 | tcase_add_test (tc_chain, test_state_changes_up_and_down_seq); 219 | tcase_add_test (tc_chain, test_state_changes_up_seq); 220 | tcase_add_test (tc_chain, test_state_changes_down_seq); 221 | 222 | return s; 223 | } 224 | 225 | GST_CHECK_MAIN (states); 226 | -------------------------------------------------------------------------------- /tests/check/meson.build: -------------------------------------------------------------------------------- 1 | # name, condition when to skip the test and extra dependencies 2 | omx_tests = [ 3 | [ 'generic/states' ], 4 | ] 5 | 6 | test_defines = [ 7 | '-UG_DISABLE_ASSERT', 8 | '-UG_DISABLE_CAST_CHECKS', 9 | '-DGST_CHECK_TEST_ENVIRONMENT_BEACON="GST_PLUGIN_LOADING_WHITELIST"', 10 | ] 11 | 12 | pluginsdirs = [] 13 | if gst_dep.type_name() == 'pkgconfig' 14 | pbase = dependency('gstreamer-plugins-base-' + api_version, required : false) 15 | pluginsdirs = [gst_dep.get_pkgconfig_variable('pluginsdir'), 16 | pbase.get_pkgconfig_variable('pluginsdir')] 17 | endif 18 | 19 | state_ignore_elements='' 20 | 21 | # FIXME: check, also + PTHREAD_CFLAGS 22 | test_deps = [gst_dep, gstbase_dep, glib_dep, gstcheck_dep] 23 | 24 | # FIXME: add valgrind suppression common/gst.supp gst-plugins-good.supp 25 | foreach t : omx_tests 26 | fname = '@0@.c'.format(t.get(0)) 27 | test_name = t.get(0).underscorify() 28 | extra_deps = [ ] 29 | if t.length() == 3 30 | extra_deps = t.get(2) 31 | skip_test = t.get(1) 32 | elif t.length() == 2 33 | skip_test = t.get(1) 34 | else 35 | skip_test = false 36 | endif 37 | if not skip_test 38 | env = environment() 39 | env.set('GST_PLUGIN_SYSTEM_PATH_1_0', '') 40 | env.set('GST_STATE_IGNORE_ELEMENTS', state_ignore_elements) 41 | env.set('CK_DEFAULT_TIMEOUT', '20') 42 | env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer', 'gst-plugins-base', 43 | 'gst-plugins-good', 'gst-omx@' + meson.build_root(), separator: ':') 44 | env.set('GST_PLUGIN_PATH_1_0', [meson.build_root()] + pluginsdirs) 45 | env.set('GSETTINGS_BACKEND', 'memory') 46 | env.set('GST_OMX_CONFIG_DIR', omx_config_dir) 47 | 48 | env.set('GST_REGISTRY', '@0@/@1@.registry'.format(meson.current_build_dir(), test_name)) 49 | exe = executable(test_name, fname, 50 | include_directories : [configinc], 51 | c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines, 52 | dependencies : [libm] + test_deps + extra_deps, 53 | ) 54 | test(test_name, exe, env: env, timeout: 3 * 60) 55 | endif 56 | endforeach 57 | -------------------------------------------------------------------------------- /tests/meson.build: -------------------------------------------------------------------------------- 1 | # FIXME: make check work on windows 2 | if host_machine.system() != 'windows' 3 | subdir('check') 4 | endif 5 | -------------------------------------------------------------------------------- /tools/listcomponents.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Collabora Ltd. 3 | * Author: Sebastian Dröge 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation 8 | * version 2.1 of the License. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | #ifdef GST_OMX_STRUCT_PACKING 29 | # if GST_OMX_STRUCT_PACKING == 1 30 | # pragma pack(1) 31 | # elif GST_OMX_STRUCT_PACKING == 2 32 | # pragma pack(2) 33 | # elif GST_OMX_STRUCT_PACKING == 4 34 | # pragma pack(4) 35 | # elif GST_OMX_STRUCT_PACKING == 8 36 | # pragma pack(8) 37 | # else 38 | # error "Unsupported struct packing value" 39 | # endif 40 | #endif 41 | 42 | #include 43 | #include 44 | 45 | #ifdef GST_OMX_STRUCT_PACKING 46 | #pragma pack() 47 | #endif 48 | 49 | gint 50 | main (gint argc, gchar ** argv) 51 | { 52 | gchar *filename; 53 | GModule *core_module; 54 | OMX_ERRORTYPE err; 55 | OMX_ERRORTYPE (*omx_init) (void); 56 | OMX_ERRORTYPE (*omx_component_name_enum) (OMX_STRING cComponentName, 57 | OMX_U32 nNameLength, OMX_U32 nIndex); 58 | OMX_ERRORTYPE (*omx_get_roles_of_component) (OMX_STRING compName, 59 | OMX_U32 * pNumRoles, OMX_U8 ** roles); 60 | guint32 i; 61 | 62 | if (argc != 2) { 63 | g_printerr ("Usage: %s /path/to/libopenmaxil.so\n", argv[0]); 64 | return -1; 65 | } 66 | 67 | filename = argv[1]; 68 | 69 | if (!g_path_is_absolute (filename)) { 70 | g_printerr ("'%s' is not an absolute filename\n", filename); 71 | return -1; 72 | } 73 | 74 | /* Hack for the Broadcom OpenMAX IL implementation */ 75 | if (g_str_has_suffix (filename, "vc/lib/libopenmaxil.so")) { 76 | gchar *bcm_host_filename; 77 | gchar *bcm_host_path; 78 | GModule *bcm_host_module; 79 | void (*bcm_host_init) (void); 80 | 81 | bcm_host_path = g_path_get_dirname (filename); 82 | bcm_host_filename = 83 | g_build_filename (bcm_host_path, "libbcm_host.so", NULL); 84 | 85 | bcm_host_module = g_module_open (bcm_host_filename, G_MODULE_BIND_LAZY); 86 | 87 | g_free (bcm_host_filename); 88 | g_free (bcm_host_path); 89 | 90 | if (!bcm_host_module) { 91 | g_printerr ("Failed to load 'libbcm_host.so'\n"); 92 | return -1; 93 | } 94 | 95 | if (!g_module_symbol (bcm_host_module, "bcm_host_init", 96 | (gpointer *) & bcm_host_init)) { 97 | g_printerr ("Failed to find 'bcm_host_init' in 'libbcm_host.so'\n"); 98 | return -1; 99 | } 100 | 101 | bcm_host_init (); 102 | } 103 | 104 | core_module = g_module_open (filename, G_MODULE_BIND_LAZY); 105 | if (!core_module) { 106 | g_printerr ("Failed to load '%s'\n", filename); 107 | return -1; 108 | } 109 | 110 | if (!g_module_symbol (core_module, "OMX_Init", (gpointer *) & omx_init)) { 111 | g_printerr ("Failed to find '%s' in '%s'\n", "OMX_Init", filename); 112 | return -1; 113 | } 114 | 115 | if (!g_module_symbol (core_module, "OMX_ComponentNameEnum", 116 | (gpointer *) & omx_component_name_enum)) { 117 | g_printerr ("Failed to find '%s' in '%s'\n", "OMX_ComponentNameEnum", 118 | filename); 119 | return -1; 120 | } 121 | 122 | if (!g_module_symbol (core_module, "OMX_GetRolesOfComponent", 123 | (gpointer *) & omx_get_roles_of_component)) { 124 | g_printerr ("Failed to find '%s' in '%s'\n", "OMX_GetRolesOfComponent", 125 | filename); 126 | return -1; 127 | } 128 | 129 | 130 | if ((err = omx_init ()) != OMX_ErrorNone) { 131 | g_printerr ("Failed to initialize core: %d\n", err); 132 | return -1; 133 | } 134 | 135 | i = 0; 136 | while (err == OMX_ErrorNone) { 137 | gchar component_name[1024]; 138 | 139 | err = omx_component_name_enum (component_name, sizeof (component_name), i); 140 | if (err == OMX_ErrorNone || err == OMX_ErrorNoMore) { 141 | guint32 nroles; 142 | 143 | g_print ("Component %d: %s\n", i, component_name); 144 | 145 | if (omx_get_roles_of_component (component_name, (OMX_U32 *) & nroles, 146 | NULL) == OMX_ErrorNone && nroles > 0) { 147 | gchar **roles = g_new (gchar *, nroles); 148 | gint j; 149 | 150 | roles[0] = g_new0 (gchar, 129 * nroles); 151 | for (j = 1; j < nroles; j++) { 152 | roles[j] = roles[j - 1] + 129; 153 | } 154 | 155 | if (omx_get_roles_of_component (component_name, (OMX_U32 *) & nroles, 156 | (OMX_U8 **) roles) == OMX_ErrorNone) { 157 | for (j = 0; j < nroles; j++) { 158 | g_print (" Role %d: %s\n", j, roles[j]); 159 | } 160 | } 161 | g_free (roles[0]); 162 | g_free (roles); 163 | } 164 | } 165 | i++; 166 | } 167 | 168 | return 0; 169 | } 170 | -------------------------------------------------------------------------------- /tools/meson.build: -------------------------------------------------------------------------------- 1 | executable('listcomponents', 2 | 'listcomponents.c', 3 | install: false, 4 | include_directories : [configinc, omx_inc], 5 | dependencies : [glib_dep, gmodule_dep], 6 | link_with: [], 7 | c_args : gst_omx_args + extra_c_args, 8 | ) 9 | --------------------------------------------------------------------------------