From 725dd255fc39bea4ba6277858d7028752ab8d8e9 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 14 Dec 2021 08:25:35 -0600 Subject: [PATCH] media-converter: Update dependencies --- dist.LICENSE | 37 +-- media-converter/Cargo.lock | 251 ++++++++---------- media-converter/Cargo.toml | 22 +- media-converter/build.rs | 2 +- .../src/{audioconv.rs => audioconv/imp.rs} | 153 +++++------ media-converter/src/audioconv/mod.rs | 46 ++++ .../{audioconvbin.rs => audioconvbin/imp.rs} | 124 ++++----- media-converter/src/audioconvbin/mod.rs | 47 ++++ media-converter/src/lib.rs | 4 +- .../src/{videoconv.rs => videoconv/imp.rs} | 170 ++++++------ media-converter/src/videoconv/mod.rs | 46 ++++ 11 files changed, 490 insertions(+), 412 deletions(-) rename media-converter/src/{audioconv.rs => audioconv/imp.rs} (88%) create mode 100644 media-converter/src/audioconv/mod.rs rename media-converter/src/{audioconvbin.rs => audioconvbin/imp.rs} (70%) create mode 100644 media-converter/src/audioconvbin/mod.rs rename media-converter/src/{videoconv.rs => videoconv/imp.rs} (86%) create mode 100644 media-converter/src/videoconv/mod.rs diff --git a/dist.LICENSE b/dist.LICENSE index 4965718b..3c5681b3 100644 --- a/dist.LICENSE +++ b/dist.LICENSE @@ -254,10 +254,7 @@ This software contains the following Rust libraries under the MIT license: gstreamer-rs array-init - Copyright (c) 2010 The Rust Project Developers - - autocfg - Copyright (c) 2018 Josh Stone + Copyright (c) 2017-2020 The array-init developers bitflags num-integer @@ -266,29 +263,21 @@ This software contains the following Rust libraries under the MIT license: Copyright (c) 2014 The Rust Project Developers cfg-if - pkg-config - proc-macro2 + proc-macro2 toml Copyright (c) 2014 Alex Crichton - chrono - Copyright (c) 2014 Kang Seonghoon - crc32fast Copyright (c) 2018 Sam Rijs, Alex Crichton and contributors futures-channel futures-core futures-executor - futures-macro futures-task futures-util Copyright (c) 2016 Alex Crichton Copyright (c) 2017 The Tokio Authors - glib - Copyright (c) 2013-2015 The Gtk-rs Project Developers - heck unicode-segmentation unicode-xid @@ -303,41 +292,35 @@ This software contains the following Rust libraries under the MIT license: murmur3 Copyright (c) 2016 Stu Small - pin-utils + pin-utils Copyright (c) 2018 The pin-utils authors pretty-hex Copyright (c) 2018 Andrei Volnin proc-macro-error + proc-macro-error-attr Copyright (c) 2019-2020 CreepySkeleton - proc-macro-hack - Copyright (c) 2018 David Tolnay - quote Copyright (c) 2016 The Rust Project Developers - slab + slab Copyright (c) 2019 Carl Lerche - time - Copyright (c) 2019 Jacob Pratt - - version_check - Copyright (c) 2017-2018 Sergio Benitez + smallvec + Copyright (c) 2018 The Servo Project Developers anyhow - either - itertools + glib once_cell paste - pin-project + pin-project-lite proc-macro-crate serde syn - syn-mid thiserror + thiserror-impl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/media-converter/Cargo.lock b/media-converter/Cargo.lock index 5bc3c00e..06e327e8 100644 --- a/media-converter/Cargo.lock +++ b/media-converter/Cargo.lock @@ -1,16 +1,18 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "array-init" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51c983d65b6691893a791e55aa8bda43bbd9b11f947e5a9581710362277cc95" +checksum = "6945cc5422176fc5e602e590c2878d2c2acd9a4fe20a4baa7c28022521698ec6" [[package]] name = "autocfg" @@ -20,9 +22,18 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-expr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b412e83326147c2bb881f8b40edfbf9905b9b8abaebd0e47ca190ba62fda8f0e" +dependencies = [ + "smallvec", +] [[package]] name = "cfg-if" @@ -45,9 +56,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if", ] @@ -60,92 +71,76 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "futures-channel" -version = "0.3.13" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.13" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" [[package]] name = "futures-executor" -version = "0.3.13" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" dependencies = [ "futures-core", "futures-task", "futures-util", ] -[[package]] -name = "futures-macro" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "futures-task" -version = "0.3.13" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" [[package]] name = "futures-util" -version = "0.3.13" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ "futures-core", - "futures-macro", "futures-task", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] [[package]] name = "glib" -version = "0.10.3" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c685013b7515e668f1b57a165b009d4d28cb139a8a989bbd699c10dad29d0c5" +checksum = "7c515f1e62bf151ef6635f528d05b02c11506de986e43b34a5c920ef0b3796a4" dependencies = [ "bitflags", "futures-channel", "futures-core", "futures-executor", "futures-task", - "futures-util", "glib-macros", "glib-sys", "gobject-sys", "libc", "once_cell", + "smallvec", ] [[package]] name = "glib-macros" -version = "0.10.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039" +checksum = "2aad66361f66796bfc73f530c51ef123970eb895ffba991a234fcf7bea89e518" dependencies = [ "anyhow", "heck", - "itertools", "proc-macro-crate", "proc-macro-error", "proc-macro2", @@ -155,9 +150,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.10.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e9b997a66e9a23d073f2b1abb4dbfc3925e0b8952f67efd8d9b6e168e4cdc1" +checksum = "1c1d60554a212445e2a858e42a0e48cece1bd57b311a19a9468f70376cf554ae" dependencies = [ "libc", "system-deps", @@ -165,9 +160,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.10.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "952133b60c318a62bf82ee75b93acc7e84028a093e06b9e27981c2b6fe68218c" +checksum = "aa92cae29759dae34ab5921d73fff5ad54b3d794ab842c117e36cafc7994c3f5" dependencies = [ "glib-sys", "libc", @@ -176,16 +171,16 @@ dependencies = [ [[package]] name = "gst-plugin-version-helper" -version = "0.2.0" -source = "git+https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs?tag=0.6.0#634d231269ab9b68c722c5037d1c94bed97ba45c" +version = "0.7.2" +source = "git+https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs?tag=0.7.2#d0466b3eee114207f851b37cae0015c0e718f021" dependencies = [ "chrono", ] [[package]] name = "gstreamer" -version = "0.16.7" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.16.7#30a323e24cd6020c872e5d5acf02b880497ff102" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "bitflags", "cfg-if", @@ -193,11 +188,10 @@ dependencies = [ "futures-core", "futures-util", "glib", - "glib-sys", - "gobject-sys", "gstreamer-sys", "libc", "muldiv", + "num-integer", "num-rational", "once_cell", "paste", @@ -207,27 +201,24 @@ dependencies = [ [[package]] name = "gstreamer-audio" -version = "0.16.7" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.16.7#30a323e24cd6020c872e5d5acf02b880497ff102" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "array-init", "bitflags", + "cfg-if", "glib", - "glib-sys", - "gobject-sys", "gstreamer", "gstreamer-audio-sys", "gstreamer-base", - "gstreamer-base-sys", - "gstreamer-sys", "libc", "once_cell", ] [[package]] name = "gstreamer-audio-sys" -version = "0.9.1" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys.git?branch=0.9#a20aae85e1bc976a97d1c942ff56f346fb2f8d4c" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "glib-sys", "gobject-sys", @@ -239,23 +230,21 @@ dependencies = [ [[package]] name = "gstreamer-base" -version = "0.16.7" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.16.7#30a323e24cd6020c872e5d5acf02b880497ff102" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "bitflags", + "cfg-if", "glib", - "glib-sys", - "gobject-sys", "gstreamer", "gstreamer-base-sys", - "gstreamer-sys", "libc", ] [[package]] name = "gstreamer-base-sys" -version = "0.9.1" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys.git?branch=0.9#a20aae85e1bc976a97d1c942ff56f346fb2f8d4c" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "glib-sys", "gobject-sys", @@ -266,8 +255,8 @@ dependencies = [ [[package]] name = "gstreamer-sys" -version = "0.9.1" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys.git?branch=0.9#a20aae85e1bc976a97d1c942ff56f346fb2f8d4c" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "glib-sys", "gobject-sys", @@ -277,19 +266,15 @@ dependencies = [ [[package]] name = "gstreamer-video" -version = "0.16.7" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.16.7#30a323e24cd6020c872e5d5acf02b880497ff102" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "bitflags", + "cfg-if", "futures-channel", - "futures-util", "glib", - "glib-sys", - "gobject-sys", "gstreamer", "gstreamer-base", - "gstreamer-base-sys", - "gstreamer-sys", "gstreamer-video-sys", "libc", "once_cell", @@ -297,8 +282,8 @@ dependencies = [ [[package]] name = "gstreamer-video-sys" -version = "0.9.1" -source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys.git?branch=0.9#a20aae85e1bc976a97d1c942ff56f346fb2f8d4c" +version = "0.17.4" +source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?tag=0.17.4#6c9815f0594045ef668bf3fefbaf5e0846516d4b" dependencies = [ "glib-sys", "gobject-sys", @@ -310,33 +295,33 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "itertools" -version = "0.9.0" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] [[package]] name = "libc" -version = "0.2.91" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "muldiv" -version = "0.2.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0419348c027fa7be448d2ae7ea0e4e04c2334c31dc4e74ab29f00a2a7ca69204" +checksum = "b5136edda114182728ccdedb9f5eda882781f35fa6e80cc360af12a8932507f3" [[package]] name = "num-integer" @@ -350,9 +335,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" dependencies = [ "autocfg", "num-integer", @@ -370,21 +355,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.7.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "paste" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" [[package]] name = "pin-project-lite" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pin-utils" @@ -394,9 +379,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "pretty-hex" @@ -406,10 +391,11 @@ checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" [[package]] name = "proc-macro-crate" -version = "0.1.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" dependencies = [ + "thiserror", "toml", ] @@ -437,30 +423,18 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" dependencies = [ "unicode-xid", ] [[package]] name = "proton-media-converter" -version = "6.3.0" +version = "7.0.0" dependencies = [ "array-init", "crc32fast", @@ -475,36 +449,42 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] [[package]] name = "serde" -version = "1.0.125" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" [[package]] name = "slab" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "strum" -version = "0.18.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" +checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" [[package]] name = "strum_macros" -version = "0.18.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" +checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" dependencies = [ "heck", "proc-macro2", @@ -514,9 +494,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.67" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", @@ -525,11 +505,14 @@ dependencies = [ [[package]] name = "system-deps" -version = "1.3.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b" +checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6" dependencies = [ + "anyhow", + "cfg-expr", "heck", + "itertools", "pkg-config", "strum", "strum_macros", @@ -540,18 +523,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -580,21 +563,21 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "version-compare" -version = "0.0.10" +version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" +checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" [[package]] name = "version_check" diff --git a/media-converter/Cargo.toml b/media-converter/Cargo.toml index 2b3559d9..1f889d1f 100644 --- a/media-converter/Cargo.toml +++ b/media-converter/Cargo.toml @@ -1,21 +1,21 @@ [package] name = "proton-media-converter" -version = "6.3.0" +version = "7.0.0" authors = ["Andrew Eikum "] repository = "https://github.com/ValveSoftware/Proton/" license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" description = "Proton media converter" [dependencies] -glib = "0.10" -gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.16.7" } -gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.16.7" } -gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.16.7" } -gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.16.7" } -once_cell = "1.7" -crc32fast = "1.2" -array-init = "1.0.*" # >=1.1 requires rust >= 1.51 +glib = "0.14" +gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.17.4" } +gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.17.4" } +gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.17.4" } +gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", tag = "0.17.4" } +once_cell = "1.9" +crc32fast = "1.3" +array-init = "2.0" [lib] name = "protonmediaconverter" @@ -23,7 +23,7 @@ crate-type = ["cdylib"] path = "src/lib.rs" [build-dependencies] -gst-plugin-version-helper = { git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", tag = "0.6.0" } +gst-plugin-version-helper = { git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", tag = "0.7.2" } [profile.release] lto = true diff --git a/media-converter/build.rs b/media-converter/build.rs index 0d1ddb61..72a8a02c 100644 --- a/media-converter/build.rs +++ b/media-converter/build.rs @@ -1,5 +1,5 @@ extern crate gst_plugin_version_helper; fn main() { - gst_plugin_version_helper::get_info() + gst_plugin_version_helper::info() } diff --git a/media-converter/src/audioconv.rs b/media-converter/src/audioconv/imp.rs similarity index 88% rename from media-converter/src/audioconv.rs rename to media-converter/src/audioconv/imp.rs index 291cc06d..a6e24105 100644 --- a/media-converter/src/audioconv.rs +++ b/media-converter/src/audioconv/imp.rs @@ -28,14 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -use glib; -use glib::subclass; -use glib::subclass::prelude::*; - use crate::format_hash; use crate::HASH_SEED; use gst; +use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; use gst::EventView; @@ -316,17 +313,16 @@ struct NeedTranscodeHead { impl NeedTranscodeHead { fn new_from_caps(caps: &gst::CapsRef) -> Result { - let s = caps.get_structure(0).ok_or_else(|| gst_loggable_error!(CAT, "Caps have no WMA data!"))?; + let s = caps.structure(0).ok_or_else(|| loggable_error!(CAT, "Caps have no WMA data!"))?; - let wmaversion = s.get_some::("wmaversion").map_err(|_| gst_loggable_error!(CAT, "Caps have no wmaversion field"))?; - let bitrate = s.get_some::("bitrate").map_err(|_| gst_loggable_error!(CAT, "Caps have no bitrate field"))?; - let channels = s.get_some::("channels").map_err(|_| gst_loggable_error!(CAT, "Caps have no channels field"))?; - let rate = s.get_some::("rate").map_err(|_| gst_loggable_error!(CAT, "Caps have no rate field"))?; - let block_align = s.get_some::("block_align").map_err(|_| gst_loggable_error!(CAT, "Caps have no block_align field"))?; - let depth = s.get_some::("depth").map_err(|_| gst_loggable_error!(CAT, "Caps have no depth field"))?; + let wmaversion = s.get::("wmaversion").map_err(|_| loggable_error!(CAT, "Caps have no wmaversion field"))?; + let bitrate = s.get::("bitrate").map_err(|_| loggable_error!(CAT, "Caps have no bitrate field"))?; + let channels = s.get::("channels").map_err(|_| loggable_error!(CAT, "Caps have no channels field"))?; + let rate = s.get::("rate").map_err(|_| loggable_error!(CAT, "Caps have no rate field"))?; + let block_align = s.get::("block_align").map_err(|_| loggable_error!(CAT, "Caps have no block_align field"))?; + let depth = s.get::("depth").map_err(|_| loggable_error!(CAT, "Caps have no depth field"))?; let codec_data_buf = s.get::("codec_data") - .map_err(|_| gst_loggable_error!(CAT, "Caps have no codec_data field"))? - .ok_or_else(|| gst_loggable_error!(CAT, "Caps have NULL codec_data field"))?; + .map_err(|_| loggable_error!(CAT, "Caps have no codec_data field"))?; let mapped = codec_data_buf.into_mapped_buffer_readable().unwrap(); let mut codec_data = Vec::new(); @@ -428,7 +424,7 @@ impl StreamState { let mut db = &mut db.open(true).fozdb; let db = match &mut db { Some(d) => d, - None => { return Err(gst_loggable_error!(CAT, "Failed to open fossilize db!")) }, + None => { return Err(loggable_error!(CAT, "Failed to open fossilize db!")) }, }; let mut found = db.has_entry(AUDIOCONV_FOZ_TAG_STREAM, self.cur_hash); @@ -476,20 +472,20 @@ impl StreamState { self.buffers[0].0, &mut self.codec_info.as_ref().unwrap().serialize().as_slice(), fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream header: {:?}", e))?; + .map_err(|e| loggable_error!(CAT, "Unable to write stream header: {:?}", e))?; db.write_entry(AUDIOCONV_FOZ_TAG_STREAM, self.cur_hash, &mut StreamStateSerializer::new(self), fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream: {:?}", e))?; + .map_err(|e| loggable_error!(CAT, "Unable to write stream: {:?}", e))?; for buffer in self.buffers.iter() { db.write_entry(AUDIOCONV_FOZ_TAG_AUDIODATA, buffer.0, &mut buffer.1.as_slice(), fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write audio data: {:?}", e))?; + .map_err(|e| loggable_error!(CAT, "Unable to write audio data: {:?}", e))?; } } } @@ -555,7 +551,7 @@ impl AudioConvState { fn new() -> Result { let read_fozdb_path = std::env::var("MEDIACONV_AUDIO_TRANSCODED_FILE").map_err(|_| { - gst_loggable_error!(CAT, "MEDIACONV_AUDIO_TRANSCODED_FILE is not set!") + loggable_error!(CAT, "MEDIACONV_AUDIO_TRANSCODED_FILE is not set!") })?; let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), AUDIOCONV_FOZ_NUM_TAGS) { @@ -590,7 +586,7 @@ impl AudioConvState { fn open_transcode_file(&mut self, buffer: gst::Buffer) -> io::Result> { let mapped = buffer.into_mapped_buffer_readable().unwrap(); - let buf_len = mapped.get_size(); + let buf_len = mapped.size(); let hash = hash_data(mapped.as_slice(), buf_len, &mut self.hash_state) .map_err(|e|{ gst_warning!(CAT, "Hashing buffer failed! {}", e); io::ErrorKind::Other })?; @@ -632,28 +628,26 @@ impl AudioConvState { /* if we can't, return the blank file */ self.stream_state.needs_dump = true; - let buf = Box::new(*include_bytes!("../blank.ptna")); + let buf = Box::new(*include_bytes!("../../blank.ptna")); Ok(buf) } } -struct AudioConv { +pub struct AudioConv { state: Mutex>, sinkpad: gst::Pad, srcpad: gst::Pad, } +#[glib::object_subclass] impl ObjectSubclass for AudioConv { const NAME: &'static str = "ProtonAudioConverter"; + type Type = super::AudioConv; type ParentType = gst::Element; - type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - glib_object_subclass!(); - - fn with_class(klass: &subclass::simple::ClassStruct) -> Self { - let templ = klass.get_pad_template("sink").unwrap(); + fn with_class(klass: &Self::Class) -> Self { + let templ = klass.pad_template("sink").unwrap(); let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) .chain_function(|pad, parent, buffer| { AudioConv::catch_panic_pad_function( @@ -670,7 +664,7 @@ impl ObjectSubclass for AudioConv { ) }).build(); - let templ = klass.get_pad_template("src").unwrap(); + let templ = klass.pad_template("src").unwrap(); let srcpad = gst::Pad::builder_with_template(&templ, Some("src")) .query_function(|pad, parent, query| { AudioConv::catch_panic_pad_function( @@ -682,7 +676,7 @@ impl ObjectSubclass for AudioConv { .activatemode_function(|pad, parent, mode, active| { AudioConv::catch_panic_pad_function( parent, - || Err(gst_loggable_error!(CAT, "Panic activating srcpad with mode")), + || Err(loggable_error!(CAT, "Panic activating srcpad with mode")), |audioconv, element| audioconv.src_activatemode(pad, element, mode, active) ) }).build(); @@ -693,53 +687,59 @@ impl ObjectSubclass for AudioConv { srcpad, } } - - fn class_init(klass: &mut subclass::simple::ClassStruct) { - - klass.set_metadata( - "Proton audio converter", - "Codec/Parser", - "Converts audio for Proton", - "Andrew Eikum "); - - let mut caps = gst::Caps::new_empty(); - { - let caps = caps.get_mut().unwrap(); - caps.append(gst::Caps::builder("audio/x-wma").build()); - } - let sink_pad_template = gst::PadTemplate::new( - "sink", - gst::PadDirection::Sink, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(sink_pad_template); - - let caps = gst::Caps::builder("audio/x-opus").build(); - let src_pad_template = gst::PadTemplate::new( - "src", - gst::PadDirection::Src, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(src_pad_template); - } } impl ObjectImpl for AudioConv { - glib_object_impl!(); - - fn constructed(&self, obj: &glib::Object) { + fn constructed(&self, obj: &Self::Type) { self.parent_constructed(obj); - let element = obj.downcast_ref::().unwrap(); - element.add_pad(&self.sinkpad).unwrap(); - element.add_pad(&self.srcpad).unwrap(); + obj.add_pad(&self.sinkpad).unwrap(); + obj.add_pad(&self.srcpad).unwrap(); } } impl ElementImpl for AudioConv { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "Proton audio converter", + "Codec/Parser", + "Converts audio for Proton", + "Andrew Eikum ") + }); + + Some(&*ELEMENT_METADATA) + } + + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + let mut caps = gst::Caps::new_empty(); + { + let caps = caps.get_mut().unwrap(); + caps.append(gst::Caps::builder("audio/x-wma").build()); + } + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &caps).unwrap(); + + let caps = gst::Caps::builder("audio/x-opus").build(); + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &caps).unwrap(); + + vec![src_pad_template, sink_pad_template] + }); + + PAD_TEMPLATES.as_ref() + } + fn change_state( &self, - element: &gst::Element, + element: &super::AudioConv, transition: gst::StateChange ) -> Result { @@ -797,7 +797,7 @@ impl AudioConv { fn chain( &self, _pad: &gst::Pad, - _element: &gst::Element, + _element: &super::AudioConv, buffer: gst::Buffer ) -> Result { gst_log!(CAT, "Handling buffer {:?}", buffer); @@ -849,7 +849,7 @@ impl AudioConv { let mut buffer = gst::Buffer::with_size(encoded_len as usize).unwrap(); if !pkt_is_header && padding_len > 0 { - gst_audio::AudioClippingMeta::add(buffer.get_mut().unwrap(), gst::format::Default(Some(0)), gst::format::Default(Some(padding_len as u64))); + gst_audio::AudioClippingMeta::add(buffer.get_mut().unwrap(), gst::format::Default(0), gst::format::Default(padding_len as u64)); } let mut writable = buffer.into_mapped_buffer_writable().unwrap(); @@ -872,7 +872,7 @@ impl AudioConv { fn sink_event( &self, pad: &gst::Pad, - element: &gst::Element, + element: &super::AudioConv, event: gst::Event ) -> bool { gst_log!(CAT, obj:pad, "Got an event {:?}", event); @@ -881,7 +881,7 @@ impl AudioConv { let mut state = self.state.lock().unwrap(); if let Some(state) = &mut *state { - let head = match NeedTranscodeHead::new_from_caps(&event_caps.get_caps()){ + let head = match NeedTranscodeHead::new_from_caps(&event_caps.caps()){ Ok(h) => h, Err(e) => { gst_error!(CAT, "Invalid WMA caps!"); @@ -920,7 +920,7 @@ impl AudioConv { fn src_query( &self, pad: &gst::Pad, - element: &gst::Element, + element: &super::AudioConv, query: &mut gst::QueryRef) -> bool { gst_log!(CAT, obj: pad, "got query: {:?}", query); @@ -932,7 +932,7 @@ impl AudioConv { return res; } - let (flags, min, max, align) = peer_query.get_result(); + let (flags, min, max, align) = peer_query.result(); q.set(flags, min, max, align); true @@ -944,7 +944,7 @@ impl AudioConv { fn src_activatemode( &self, _pad: &gst::Pad, - _element: &gst::Element, + _element: &super::AudioConv, mode: gst::PadMode, active: bool ) -> Result<(), gst::LoggableError> { @@ -953,13 +953,4 @@ impl AudioConv { Ok(()) } - -} - -pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { - gst::Element::register( - Some(plugin), - "protonaudioconverter", - gst::Rank::Marginal, - AudioConv::get_type()) } diff --git a/media-converter/src/audioconv/mod.rs b/media-converter/src/audioconv/mod.rs new file mode 100644 index 00000000..870f010e --- /dev/null +++ b/media-converter/src/audioconv/mod.rs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Valve Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +use gst::glib; +use gst::prelude::*; + +mod imp; + +glib::wrapper! { + pub struct AudioConv(ObjectSubclass) @extends gst::Element, gst::Object; +} + +pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { + gst::Element::register( + Some(plugin), + "protonaudioconverter", + gst::Rank::Marginal, + AudioConv::static_type()) +} diff --git a/media-converter/src/audioconvbin.rs b/media-converter/src/audioconvbin/imp.rs similarity index 70% rename from media-converter/src/audioconvbin.rs rename to media-converter/src/audioconvbin/imp.rs index b7aa1851..9a363b50 100644 --- a/media-converter/src/audioconvbin.rs +++ b/media-converter/src/audioconvbin/imp.rs @@ -28,11 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -use glib; -use glib::subclass; -use glib::subclass::prelude::*; - use gst; +use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; use gst::EventView; @@ -64,7 +61,7 @@ static CAT: Lazy = Lazy::new(|| { Some("Proton audio converter bin")) }); -struct AudioConvBin { +pub struct AudioConvBin { audioconv: gst::Element, opusdec: gst::Element, capssetter: gst::Element, @@ -72,21 +69,18 @@ struct AudioConvBin { sinkpad: gst::GhostPad, } +#[glib::object_subclass] impl ObjectSubclass for AudioConvBin { const NAME: &'static str = "ProtonAudioConverterBin"; - + type Type = super::AudioConvBin; type ParentType = gst::Bin; - type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - glib_object_subclass!(); + fn with_class(klass: &Self::Class) -> Self { - fn with_class(klass: &subclass::simple::ClassStruct) -> Self { - - let templ = klass.get_pad_template("src").unwrap(); + let templ = klass.pad_template("src").unwrap(); let srcpad = gst::GhostPad::builder_with_template(&templ, Some("src")).build(); - let templ = klass.get_pad_template("sink").unwrap(); + let templ = klass.pad_template("sink").unwrap(); let sinkpad = gst::GhostPad::builder_with_template(&templ, Some("sink")) .event_function(|pad, parent, event| { AudioConvBin::catch_panic_pad_function( @@ -108,79 +102,86 @@ impl ObjectSubclass for AudioConvBin { sinkpad, } } - - fn class_init(klass: &mut subclass::simple::ClassStruct) { - klass.set_metadata("Proton audio converter with rate fixup", - "Codec/Parser", - "Converts audio for Proton, fixing up samplerates", - "Andrew Eikum "); - - let mut caps = gst::Caps::new_empty(); - { - let caps = caps.get_mut().unwrap(); - caps.append(gst::Caps::builder("audio/x-wma").build()); - } - let sink_pad_template = gst::PadTemplate::new( - "sink", - gst::PadDirection::Sink, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(sink_pad_template); - - let caps = gst::Caps::builder("audio/x-raw").build(); - let src_pad_template = gst::PadTemplate::new( - "src", - gst::PadDirection::Src, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(src_pad_template); - } } impl ObjectImpl for AudioConvBin { - glib_object_impl!(); - - fn constructed(&self, obj: &glib::Object) { + fn constructed(&self, obj: &Self::Type) { self.parent_constructed(obj); - let bin = obj.downcast_ref::().unwrap(); - - bin.add(&self.audioconv).unwrap(); - bin.add(&self.opusdec).unwrap(); - bin.add(&self.capssetter).unwrap(); + obj.add(&self.audioconv).unwrap(); + obj.add(&self.opusdec).unwrap(); + obj.add(&self.capssetter).unwrap(); self.audioconv.link(&self.opusdec).unwrap(); self.opusdec.link(&self.capssetter).unwrap(); self.sinkpad - .set_target(Some(&self.audioconv.get_static_pad("sink").unwrap())) + .set_target(Some(&self.audioconv.static_pad("sink").unwrap())) .unwrap(); self.srcpad - .set_target(Some(&self.capssetter.get_static_pad("src").unwrap())) + .set_target(Some(&self.capssetter.static_pad("src").unwrap())) .unwrap(); - bin.add_pad(&self.sinkpad).unwrap(); - bin.add_pad(&self.srcpad).unwrap(); + obj.add_pad(&self.sinkpad).unwrap(); + obj.add_pad(&self.srcpad).unwrap(); } } impl BinImpl for AudioConvBin { } -impl ElementImpl for AudioConvBin { } +impl ElementImpl for AudioConvBin { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "Proton audio converter with rate fixup", + "Codec/Parser", + "Converts audio for Proton, fixing up samplerates", + "Andrew Eikum ") + }); + + Some(&*ELEMENT_METADATA) + } + + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + let mut caps = gst::Caps::new_empty(); + { + let caps = caps.get_mut().unwrap(); + caps.append(gst::Caps::builder("audio/x-wma").build()); + } + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &caps).unwrap(); + + let caps = gst::Caps::builder("audio/x-raw").build(); + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &caps).unwrap(); + + vec![src_pad_template, sink_pad_template] + }); + + PAD_TEMPLATES.as_ref() + } +} impl AudioConvBin { fn sink_event( &self, pad: &gst::GhostPad, - element: &gst::Element, + element: &super::AudioConvBin, event: gst::Event ) -> bool { match event.view() { EventView::Caps(event_caps) => { /* set up capssetter with this rate */ - if let Some(s) = event_caps.get_caps().get_structure(0) { + if let Some(s) = event_caps.caps().structure(0) { - if let Ok(override_rate) = s.get_some::("rate") { + if let Ok(override_rate) = s.get::("rate") { let mut rate_caps = gst::Caps::new_empty(); { @@ -200,19 +201,10 @@ impl AudioConvBin { } /* forward on to the real pad */ - self.audioconv.get_static_pad("sink").unwrap() + self.audioconv.static_pad("sink").unwrap() .send_event(event) }, _ => pad.event_default(Some(element), event) } } } - -pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { - gst::Element::register( - Some(plugin), - "protonaudioconverterbin", - gst::Rank::Marginal + 1, - AudioConvBin::get_type() - ) -} diff --git a/media-converter/src/audioconvbin/mod.rs b/media-converter/src/audioconvbin/mod.rs new file mode 100644 index 00000000..660eb929 --- /dev/null +++ b/media-converter/src/audioconvbin/mod.rs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Valve Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +use gst::glib; +use gst::prelude::*; + +mod imp; + +glib::wrapper! { + pub struct AudioConvBin(ObjectSubclass) @extends gst::Bin, gst::Element, gst::Object; +} + +pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { + gst::Element::register( + Some(plugin), + "protonaudioconverterbin", + gst::Rank::Marginal + 1, + AudioConvBin::static_type() + ) +} diff --git a/media-converter/src/lib.rs b/media-converter/src/lib.rs index e06eb587..5d65589e 100644 --- a/media-converter/src/lib.rs +++ b/media-converter/src/lib.rs @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#[macro_use] -extern crate glib; #[macro_use] extern crate gstreamer as gst; extern crate gstreamer_base as gst_base; @@ -148,7 +146,7 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { Ok(()) } -gst_plugin_define!( +plugin_define!( protonmediaconverter, env!("CARGO_PKG_DESCRIPTION"), plugin_init, diff --git a/media-converter/src/videoconv.rs b/media-converter/src/videoconv/imp.rs similarity index 86% rename from media-converter/src/videoconv.rs rename to media-converter/src/videoconv/imp.rs index 9a517aaa..eebbba5e 100644 --- a/media-converter/src/videoconv.rs +++ b/media-converter/src/videoconv/imp.rs @@ -28,10 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -use glib; -use glib::subclass; -use glib::subclass::prelude::*; - use crate::format_hash; use crate::HASH_SEED; use crate::box_array; @@ -39,6 +35,7 @@ use crate::copy_into_array; use crate::BufferedReader; use gst; +use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; use gst::EventView; @@ -240,14 +237,14 @@ impl<'a> Read for PadReader<'a> { Ok(buf) => { let to_copy; - if self.offs + buf.get_size() < self.stride { - to_copy = buf.get_size(); + if self.offs + buf.size() < self.stride { + to_copy = buf.size(); self.offs += to_copy; }else if self.offs < self.stride { to_copy = self.stride - self.offs; self.offs = self.stride; }else{ - to_copy = buf.get_size(); + to_copy = buf.size(); self.offs += self.stride; }; @@ -301,7 +298,7 @@ impl VideoConvState { fn new() -> Result { let read_fozdb_path = std::env::var("MEDIACONV_VIDEO_TRANSCODED_FILE").map_err(|_| { - gst_loggable_error!(CAT, "MEDIACONV_VIDEO_TRANSCODED_FILE is not set!") + loggable_error!(CAT, "MEDIACONV_VIDEO_TRANSCODED_FILE is not set!") })?; let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), VIDEOCONV_FOZ_NUM_TAGS) { @@ -343,7 +340,7 @@ impl VideoConvState { gst_log!(CAT, "No transcoded video for {}. Substituting a blank video.", format_hash(hash)); self.transcode_hash = None; - self.our_duration = Some(include_bytes!("../blank.mkv").len() as u64); + self.our_duration = Some(include_bytes!("../../blank.mkv").len() as u64); false } @@ -353,11 +350,11 @@ impl VideoConvState { Some(hash) => { let read_fozdb = self.read_fozdb.as_mut().unwrap(); read_fozdb.read_entry(self.transcoded_tag, hash, offs as u64, out, fossilize::CRCCheck::WithoutCRC) - .map_err(|e| gst_loggable_error!(CAT, "Error reading ogvdata: {:?}", e)) + .map_err(|e| loggable_error!(CAT, "Error reading ogvdata: {:?}", e)) }, None => { - let blank = include_bytes!("../blank.mkv"); + let blank = include_bytes!("../../blank.mkv"); let to_copy = std::cmp::min(blank.len() - offs, out.len()); @@ -369,22 +366,20 @@ impl VideoConvState { } } -struct VideoConv { +pub struct VideoConv { state: Mutex>, sinkpad: gst::Pad, srcpad: gst::Pad, } +#[glib::object_subclass] impl ObjectSubclass for VideoConv { const NAME: &'static str = "ProtonVideoConverter"; + type Type = super::VideoConv; type ParentType = gst::Element; - type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - glib_object_subclass!(); - - fn with_class(klass: &subclass::simple::ClassStruct) -> Self { - let templ = klass.get_pad_template("sink").unwrap(); + fn with_class(klass: &Self::Class) -> Self { + let templ = klass.pad_template("sink").unwrap(); let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) .event_function(|pad, parent, event| { VideoConv::catch_panic_pad_function( @@ -394,13 +389,13 @@ impl ObjectSubclass for VideoConv { ) }).build(); - let templ = klass.get_pad_template("src").unwrap(); + let templ = klass.pad_template("src").unwrap(); let srcpad = gst::Pad::builder_with_template(&templ, Some("src")) .getrange_function(|pad, parent, offset, in_buf, size| { VideoConv::catch_panic_pad_function( parent, || Err(gst::FlowError::Error), - |videoconv, element| videoconv.get_range(pad, element, offset, in_buf, size) + |videoconv, element| videoconv.range(pad, element, offset, in_buf, size) ) }) .query_function(|pad, parent, query| { @@ -413,7 +408,7 @@ impl ObjectSubclass for VideoConv { .activatemode_function(|pad, parent, mode, active| { VideoConv::catch_panic_pad_function( parent, - || Err(gst_loggable_error!(CAT, "Panic activating srcpad with mode")), + || Err(loggable_error!(CAT, "Panic activating srcpad with mode")), |videoconv, element| videoconv.src_activatemode(pad, element, mode, active) ) }).build(); @@ -424,61 +419,68 @@ impl ObjectSubclass for VideoConv { srcpad, } } - - fn class_init(klass: &mut subclass::simple::ClassStruct) { - - klass.set_metadata( - "Proton video converter", - "Codec/Parser", - "Converts video for Proton", - "Andrew Eikum "); - - let mut caps = gst::Caps::new_empty(); - { - let caps = caps.get_mut().unwrap(); - caps.append(gst::Caps::builder("video/x-ms-asf").build()); - caps.append(gst::Caps::builder("video/x-msvideo").build()); - caps.append(gst::Caps::builder("video/mpeg").build()); - caps.append(gst::Caps::builder("video/quicktime").build()); - } - let sink_pad_template = gst::PadTemplate::new( - "sink", - gst::PadDirection::Sink, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(sink_pad_template); - - let mut caps = gst::Caps::new_empty(); - { - let caps = caps.get_mut().unwrap(); - caps.append(gst::Caps::builder("video/x-matroska").build()); - caps.append(gst::Caps::builder("application/ogg").build()); - } - let src_pad_template = gst::PadTemplate::new( - "src", - gst::PadDirection::Src, - gst::PadPresence::Always, - &caps).unwrap(); - klass.add_pad_template(src_pad_template); - } } impl ObjectImpl for VideoConv { - glib_object_impl!(); - - fn constructed(&self, obj: &glib::Object) { + fn constructed(&self, obj: &Self::Type) { self.parent_constructed(obj); - let element = obj.downcast_ref::().unwrap(); - element.add_pad(&self.sinkpad).unwrap(); - element.add_pad(&self.srcpad).unwrap(); + obj.add_pad(&self.sinkpad).unwrap(); + obj.add_pad(&self.srcpad).unwrap(); } } impl ElementImpl for VideoConv { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "Proton video converter", + "Codec/Parser", + "Converts video for Proton", + "Andrew Eikum " + ) + }); + + Some(&*ELEMENT_METADATA) + } + + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + let mut caps = gst::Caps::new_empty(); + { + let caps = caps.get_mut().unwrap(); + caps.append(gst::Caps::builder("video/x-ms-asf").build()); + caps.append(gst::Caps::builder("video/x-msvideo").build()); + caps.append(gst::Caps::builder("video/mpeg").build()); + caps.append(gst::Caps::builder("video/quicktime").build()); + } + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &caps).unwrap(); + + let mut caps = gst::Caps::new_empty(); + { + let caps = caps.get_mut().unwrap(); + caps.append(gst::Caps::builder("video/x-matroska").build()); + caps.append(gst::Caps::builder("application/ogg").build()); + } + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &caps).unwrap(); + + vec![src_pad_template, sink_pad_template] + }); + + PAD_TEMPLATES.as_ref() + } + fn change_state( &self, - element: &gst::Element, + element: &super::VideoConv, transition: gst::StateChange ) -> Result { @@ -541,10 +543,10 @@ impl <'a> Read for StreamSerializer<'a> { } impl VideoConv { - fn get_range( + fn range( &self, _pad: &gst::Pad, - _element: &gst::Element, + _element: &super::VideoConv, offset: u64, in_buf: Option<&mut gst::BufferRef>, requested_size: u32, @@ -577,7 +579,7 @@ impl VideoConv { .map_err(|e| { e.log(); gst::FlowError::Error })?; } - if readed > 0 || buf.get_size() == 0 { + if readed > 0 || buf.size() == 0 { buf.set_size(readed); return Ok(gst::PadGetRangeSuccess::FilledBuffer); } @@ -597,7 +599,7 @@ impl VideoConv { let mut b = map.into_buffer(); - if readed > 0 || b.get_size() == 0 { + if readed > 0 || b.size() == 0 { b.get_mut().unwrap().set_size(readed); return Ok(gst::PadGetRangeSuccess::NewBuffer(b)); } @@ -610,7 +612,7 @@ impl VideoConv { fn sink_event( &self, pad: &gst::Pad, - element: &gst::Element, + element: &super::VideoConv, event: gst::Event ) -> bool { gst_log!(CAT, obj:pad, "Got an event {:?}", event); @@ -654,9 +656,8 @@ impl VideoConv { let mut query = gst::query::Duration::new(gst::Format::Bytes); if self.sinkpad.peer_query(&mut query) { - state.upstream_duration = match query.get_result() { - gst::format::GenericFormattedValue::Bytes(b) => - *b, + state.upstream_duration = match query.result().try_into().unwrap() { + Some(gst::format::Bytes(size)) => Some(size), _ => None, } }else{ @@ -676,7 +677,7 @@ impl VideoConv { fn src_query( &self, pad: &gst::Pad, - element: &gst::Element, + element: &super::VideoConv, query: &mut gst::QueryRef) -> bool { gst_log!(CAT, obj: pad, "got query: {:?}", query); @@ -688,7 +689,7 @@ impl VideoConv { return res; } - let (flags, min, max, align) = peer_query.get_result(); + let (flags, min, max, align) = peer_query.result(); q.set(flags, min, max, align); q.add_scheduling_modes(&[gst::PadMode::Pull]); @@ -708,8 +709,8 @@ impl VideoConv { } if let Some(sz) = state.our_duration { - if q.get_format() == gst::Format::Bytes { - q.set(gst::format::Bytes::from(sz)); + if q.format() == gst::Format::Bytes { + q.set(gst::format::Bytes(sz)); return true } } @@ -769,7 +770,7 @@ impl VideoConv { if let Ok(hash) = hash { if !state.begin_transcode(hash) { - self.dump_upstream_data(hash).map_err(|_| gst_loggable_error!(CAT, "Dumping file to disk failed"))?; + self.dump_upstream_data(hash).map_err(|_| loggable_error!(CAT, "Dumping file to disk failed"))?; } } } @@ -780,7 +781,7 @@ impl VideoConv { fn src_activatemode( &self, _pad: &gst::Pad, - _element: &gst::Element, + _element: &super::VideoConv, mode: gst::PadMode, active: bool ) -> Result<(), gst::LoggableError> { @@ -792,7 +793,7 @@ impl VideoConv { let mut state = match &mut *state { Some(s) => s, - None => { return Err(gst_loggable_error!(CAT, "VideoConv not yet in READY state?")); } + None => { return Err(loggable_error!(CAT, "VideoConv not yet in READY state?")); } }; /* once we're initted in pull mode, we can start transcoding */ @@ -801,13 +802,4 @@ impl VideoConv { Ok(()) } - -} - -pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { - gst::Element::register( - Some(plugin), - "protonvideoconverter", - gst::Rank::Marginal, - VideoConv::get_type()) } diff --git a/media-converter/src/videoconv/mod.rs b/media-converter/src/videoconv/mod.rs new file mode 100644 index 00000000..e3a41800 --- /dev/null +++ b/media-converter/src/videoconv/mod.rs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Valve Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +use gst::glib; +use gst::prelude::*; + +mod imp; + +glib::wrapper! { + pub struct VideoConv(ObjectSubclass) @extends gst::Element, gst::Object; +} + +pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { + gst::Element::register( + Some(plugin), + "protonvideoconverter", + gst::Rank::Marginal, + VideoConv::static_type()) +}