Compare commits

...

3 commits

Author SHA1 Message Date
François Laignel 953e3747f2 Pad: allow building a Pad with an automatically generated name
For convenience, the `Pad` builder checks a name is provided when a wildcard-
named template is used. For `GhostPad`s, the builder tries to assign the name of
the target `Pad` making sure the provided `name` conforms to the `PadTemplate`.

This commit adds a function to optionally keep the `gst::Object` automatically
generated unique `Pad` name (such as `ghostpad4`) and reorganises name handling
so it is processed when `build` is invoked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1428>
2024-04-26 09:57:28 +00:00
Sebastian Dröge e117010bc0 Update Cargo.lock
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1427>
2024-04-25 12:05:49 +03:00
Sebastian Dröge 694d1fd39b examples: Update to windows 0.56
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1427>
2024-04-25 12:05:49 +03:00
5 changed files with 377 additions and 263 deletions

262
Cargo.lock generated
View file

@ -50,9 +50,9 @@ checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "anyhow"
version = "1.0.81"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
[[package]]
name = "as-raw-xcb-connection"
@ -62,9 +62,9 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]]
name = "async-channel"
version = "2.2.0"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3"
checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928"
dependencies = [
"concurrent-queue",
"event-listener",
@ -139,9 +139,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.15.4"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "byte-slice-cast"
@ -170,7 +170,7 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
[[package]]
name = "cairo-rs"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"bitflags 2.5.0",
"cairo-sys-rs",
@ -182,7 +182,7 @@ dependencies = [
[[package]]
name = "cairo-sys-rs"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"glib-sys",
"libc",
@ -217,12 +217,13 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.91"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153"
checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b"
dependencies = [
"jobserver",
"libc",
"once_cell",
]
[[package]]
@ -233,9 +234,9 @@ checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
name = "cfg-expr"
version = "0.15.7"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d"
checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
dependencies = [
"smallvec",
"target-lexicon",
@ -300,9 +301,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "combine"
version = "4.6.6"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd"
dependencies = [
"bytes",
"memchr",
@ -426,9 +427,9 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
[[package]]
name = "either"
version = "1.10.0"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
[[package]]
name = "equivalent"
@ -556,7 +557,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
@ -621,7 +622,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
@ -666,9 +667,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.13"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6"
checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c"
dependencies = [
"cfg-if",
"libc",
@ -678,7 +679,7 @@ dependencies = [
[[package]]
name = "gio"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"futures-channel",
"futures-core",
@ -695,7 +696,7 @@ dependencies = [
[[package]]
name = "gio-sys"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"glib-sys",
"gobject-sys",
@ -724,7 +725,7 @@ dependencies = [
[[package]]
name = "glib"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"bitflags 2.5.0",
"futures-channel",
@ -745,19 +746,19 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"heck",
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
name = "glib-sys"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"libc",
"system-deps",
@ -820,7 +821,7 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"glib-sys",
"libc",
@ -1637,9 +1638,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jobserver"
version = "0.1.28"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6"
checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e"
dependencies = [
"libc",
]
@ -1678,7 +1679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [
"cfg-if",
"windows-targets 0.52.4",
"windows-targets 0.52.5",
]
[[package]]
@ -1831,7 +1832,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
@ -1851,9 +1852,9 @@ dependencies = [
[[package]]
name = "objc-sys"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459"
checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60"
[[package]]
name = "objc2"
@ -1898,7 +1899,7 @@ dependencies = [
[[package]]
name = "pango"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"gio",
"glib",
@ -1909,7 +1910,7 @@ dependencies = [
[[package]]
name = "pango-sys"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"glib-sys",
"gobject-sys",
@ -1920,7 +1921,7 @@ dependencies = [
[[package]]
name = "pangocairo"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"cairo-rs",
"glib",
@ -1932,7 +1933,7 @@ dependencies = [
[[package]]
name = "pangocairo-sys"
version = "0.20.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#e56b5fe936ed40d6c8666c0e53547dafa41f2bb9"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=master#7f4a1dcc3ca3420476b7481e91c5bf5a3e6a54c6"
dependencies = [
"cairo-sys-rs",
"glib-sys",
@ -1992,9 +1993,9 @@ dependencies = [
[[package]]
name = "polling"
version = "3.6.0"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6"
checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3"
dependencies = [
"cfg-if",
"concurrent-queue",
@ -2016,9 +2017,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.79"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [
"unicode-ident",
]
@ -2034,9 +2035,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.35"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
@ -2094,9 +2095,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.32"
version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [
"bitflags 2.5.0",
"errno",
@ -2134,9 +2135,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
[[package]]
name = "serde"
version = "1.0.197"
version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
dependencies = [
"serde_derive",
]
@ -2152,20 +2153,20 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.197"
version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
name = "serde_json"
version = "1.0.115"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd"
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
dependencies = [
"itoa",
"ryu",
@ -2255,9 +2256,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.58"
version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
@ -2309,22 +2310,22 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.58"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.58"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]
[[package]]
@ -2336,7 +2337,7 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.9",
"toml_edit 0.22.12",
]
[[package]]
@ -2361,15 +2362,15 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.22.9"
version = "0.22.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4"
checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.6.5",
"winnow 0.6.6",
]
[[package]]
@ -2477,7 +2478,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
"wasm-bindgen-shared",
]
@ -2511,7 +2512,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -2651,64 +2652,66 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"winapi",
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.54.0"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49"
checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132"
dependencies = [
"windows-core",
"windows-targets 0.52.4",
"windows-targets 0.52.5",
]
[[package]]
name = "windows-core"
version = "0.54.0"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6"
dependencies = [
"windows-implement",
"windows-interface",
"windows-result",
"windows-targets 0.52.4",
"windows-targets 0.52.5",
]
[[package]]
name = "windows-implement"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.60",
]
[[package]]
name = "windows-interface"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.60",
]
[[package]]
name = "windows-result"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64"
checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b"
dependencies = [
"windows-targets 0.52.4",
"windows-targets 0.52.5",
]
[[package]]
@ -2735,7 +2738,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.4",
"windows-targets 0.52.5",
]
[[package]]
@ -2770,17 +2773,18 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm 0.52.4",
"windows_aarch64_msvc 0.52.4",
"windows_i686_gnu 0.52.4",
"windows_i686_msvc 0.52.4",
"windows_x86_64_gnu 0.52.4",
"windows_x86_64_gnullvm 0.52.4",
"windows_x86_64_msvc 0.52.4",
"windows_aarch64_gnullvm 0.52.5",
"windows_aarch64_msvc 0.52.5",
"windows_i686_gnu 0.52.5",
"windows_i686_gnullvm",
"windows_i686_msvc 0.52.5",
"windows_x86_64_gnu 0.52.5",
"windows_x86_64_gnullvm 0.52.5",
"windows_x86_64_msvc 0.52.5",
]
[[package]]
@ -2797,9 +2801,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
@ -2815,9 +2819,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
@ -2833,9 +2837,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3"
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
@ -2851,9 +2861,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
@ -2869,9 +2879,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
@ -2887,9 +2897,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
@ -2905,9 +2915,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.4"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "winit"
@ -2967,9 +2977,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.6.5"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
dependencies = [
"memchr",
]
@ -3054,5 +3064,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"syn 2.0.60",
]

View file

@ -45,7 +45,7 @@ data-encoding = "2.0"
once_cell = "1"
[target.'cfg(windows)'.dependencies]
windows = { version = "0.54", features=["Win32_Graphics_Direct3D11",
windows = { version = "0.56", features=["Win32_Graphics_Direct3D11",
"Win32_Foundation", "Win32_Graphics_Direct3D", "Win32_Graphics_Dxgi",
"Win32_Graphics_Dxgi_Common", "Win32_Graphics_Direct2D",
"Win32_Graphics_Direct2D_Common", "Win32_Graphics_DirectWrite",

View file

@ -194,7 +194,7 @@ fn main() -> Result<()> {
let mut metrics = DWRITE_TEXT_METRICS::default();
layout.GetMetrics(&mut metrics).unwrap();
layout
.GetFontSize2(0, &mut font_size, Some(&mut range))
.GetFontSize(0, &mut font_size, Some(&mut range))
.unwrap();
if metrics.widthIncludingTrailingWhitespace >= desc.Width as f32 {

View file

@ -56,6 +56,8 @@ impl GhostPad {
// rustdoc-stripper-ignore-next
/// Creates a new [`GhostPad`] with an automatically generated name.
///
/// The [`Pad`] will be assigned the usual `gst::Object` generated unique name.
///
/// Use [`GhostPad::builder_from_template()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
#[doc(alias = "gst_ghost_pad_new_no_target")]
@ -65,10 +67,7 @@ impl GhostPad {
}
// rustdoc-stripper-ignore-next
/// Creates a [`PadBuilder`](crate::PadBuilder) for a [`PadBuilder`] with an automatically generated name.
///
/// Use [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name)
/// to specify a different name.
/// Creates a [`PadBuilder`](crate::PadBuilder) with the specified [`PadDirection`](crate::PadDirection).
#[doc(alias = "gst_ghost_pad_new_no_target")]
pub fn builder(direction: crate::PadDirection) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -82,12 +81,15 @@ impl GhostPad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `GhostPad` will automatically be named after the `name_template`.
///
/// Use [`GhostPad::builder_from_template()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
///
/// # Panics
///
/// Panics if the `name_template` is a wildcard-name.
///
/// Use [`GhostPad::builder_from_template()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
#[doc(alias = "gst_ghost_pad_new_no_target_from_static_template")]
pub fn from_static_template(templ: &StaticPadTemplate) -> Self {
skip_assert_initialized!();
@ -103,6 +105,9 @@ impl GhostPad {
///
/// Use [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name)
/// to specify a different name.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new_no_target_from_static_template")]
pub fn builder_from_static_template(templ: &StaticPadTemplate) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -116,12 +121,15 @@ impl GhostPad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `GhostPad` will automatically be named after the `name_template`.
///
/// Use [`GhostPad::builder_from_template()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
///
/// # Panics
///
/// Panics if the `name_template` is a wildcard-name.
///
/// Use [`GhostPad::builder_from_template()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
#[doc(alias = "gst_ghost_pad_new_no_target_from_template")]
pub fn from_template(templ: &crate::PadTemplate) -> Self {
skip_assert_initialized!();
@ -137,6 +145,9 @@ impl GhostPad {
///
/// Use [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name)
/// to specify a different name.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new_no_target_from_template")]
pub fn builder_from_template(templ: &crate::PadTemplate) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -150,6 +161,9 @@ impl GhostPad {
///
/// Use [`GhostPad::builder_with_target()`] to get a [`PadBuilder`](crate::PadBuilder)
/// and define options.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new")]
pub fn with_target<P: IsA<Pad> + IsA<crate::Object>>(
target: &P,
@ -165,13 +179,15 @@ impl GhostPad {
///
/// Use [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name)
/// to specify a different name.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new_no_target_from_template")]
pub fn builder_with_target<P: IsA<Pad> + IsA<crate::Object>>(
target: &P,
) -> Result<PadBuilder<Self>, glib::BoolError> {
skip_assert_initialized!();
let mut builder = Self::builder(target.direction());
builder.needs_specific_name = true;
let builder = Self::builder(target.direction());
builder.with_target(target)
}
@ -186,6 +202,9 @@ impl GhostPad {
/// If the `name_template` is a wildcard-name, then the `target` `name` is used,
/// if it is compatible. Otherwise, a specific name must be provided using
/// [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name).
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new_from_template")]
pub fn from_template_with_target<P: IsA<Pad> + IsA<crate::Object>>(
templ: &crate::PadTemplate,
@ -206,6 +225,9 @@ impl GhostPad {
/// If the `name_template` is a wildcard-name, then the `target` `name` is used,
/// if it is compatible. Otherwise, a specific name must be provided using
/// [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name).
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_ghost_pad_new_from_template")]
pub fn builder_from_template_with_target<P: IsA<Pad> + IsA<crate::Object>>(
templ: &crate::PadTemplate,
@ -689,6 +711,9 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
/// If the `name_template` is a wildcard-name, then the `target` `name` is used,
/// if it is compatible. Otherwise, a specific name must be provided using
/// [`PadBuilder::name`](crate::PadBuilder::name) or [`PadBuilder::maybe_name`](crate::PadBuilder::maybe_name).
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
pub fn with_target<P: IsA<Pad> + IsA<crate::Object>>(
mut self,
target: &P,
@ -696,92 +721,8 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
assert_eq!(self.pad.direction(), target.direction());
self.pad.set_target(Some(target))?;
if self.needs_specific_name {
let mut can_assign_target_name = true;
if let Some(pad_template) = self.pad.pad_template() {
if pad_template.presence() == crate::PadPresence::Request {
// Check if the target name is compatible with the name template.
use crate::CAT_RUST;
let target_name = target.name();
let mut target_parts = target_name.split('_');
for template_part in pad_template.name_template().split('_') {
let Some(target_part) = target_parts.next() else {
crate::debug!(
CAT_RUST,
"Not using target Pad name '{target_name}': not enough parts compared to template '{}'",
pad_template.name_template(),
);
can_assign_target_name = false;
break;
};
if let Some(conv_spec_start) = template_part.find('%') {
if conv_spec_start > 0
&& !target_part.starts_with(&template_part[..conv_spec_start])
{
crate::debug!(
CAT_RUST,
"Not using target Pad name '{target_name}': mismatch template '{}' prefix",
pad_template.name_template(),
);
can_assign_target_name = false;
break;
}
let conv_spec_pos = conv_spec_start + 1;
match template_part.get(conv_spec_pos..=conv_spec_pos) {
Some("s") => {
// *There can be only one* %s
break;
}
Some("u") => {
if target_part
.get(conv_spec_start..)
.map_or(true, |s| s.parse::<u32>().is_err())
{
crate::debug!(
CAT_RUST,
"Not using target Pad name '{target_name}': can't parse '%u' from '{target_part}' (template '{}')",
pad_template.name_template(),
);
can_assign_target_name = false;
break;
}
}
Some("d") => {
if target_part
.get(conv_spec_start..)
.map_or(true, |s| s.parse::<i32>().is_err())
{
crate::debug!(
CAT_RUST,
"Not using target Pad name '{target_name}': can't parse '%i' from '{target_part}' (template '{}')",
pad_template.name_template(),
);
can_assign_target_name = false;
break;
}
}
other => unreachable!("Unexpected conversion specifier {other:?}"),
}
} else if target_part != template_part {
can_assign_target_name = false;
break;
}
}
}
}
if can_assign_target_name {
self.pad.set_property("name", target.name());
self.needs_specific_name = false;
}
}
self.name =
crate::pad::PadBuilderName::CandidateForWildcardTemplate(target.name().to_string());
Ok(self)
}
@ -911,6 +852,13 @@ mod tests {
.name("ghost_test")
.build();
assert_eq!(ghost_pad.name(), "ghost_test");
let target = crate::Pad::from_template(&templ);
let ghost_pad = GhostPad::builder_with_target(&target)
.unwrap()
.generated_name()
.build();
assert!(ghost_pad.name().starts_with("ghostpad"));
}
#[test]
@ -952,6 +900,13 @@ mod tests {
.build();
assert_eq!(ghost_pad.name(), "my-sink");
let target = crate::Pad::from_template(&sink_templ);
let ghost_pad = GhostPad::builder_from_template_with_target(&ghost_templ, &target)
.unwrap()
.generated_name()
.build();
assert!(ghost_pad.name().starts_with("ghostpad"));
// # Request template %u
let wildcard_u_templ = crate::PadTemplate::new(
"sink_%u",
@ -983,6 +938,13 @@ mod tests {
.build();
assert_eq!(ghost_pad.name(), "sink_0");
let target = crate::Pad::from_template(&sink_0_templ);
let ghost_pad = GhostPad::builder_from_template_with_target(&wildcard_u_templ, &target)
.unwrap()
.generated_name()
.build();
assert!(ghost_pad.name().starts_with("ghostpad"));
// # Request template %d_%u
let wildcard_u_templ = crate::PadTemplate::new(
"sink_%d_%u",

View file

@ -1428,7 +1428,7 @@ impl Pad {
// rustdoc-stripper-ignore-next
/// Creates a new [`Pad`] with the specified [`PadDirection`](crate::PadDirection).
///
/// An automatically generated name will be assigned.
/// The [`Pad`] will be assigned the usual `gst::Object` generated unique name.
///
/// Use [`Pad::builder()`] to get a [`PadBuilder`] and define options.
#[doc(alias = "gst_pad_new")]
@ -1439,8 +1439,6 @@ impl Pad {
// rustdoc-stripper-ignore-next
/// Creates a [`PadBuilder`] with the specified [`PadDirection`](crate::PadDirection).
///
/// An automatically generated name will be assigned.
#[doc(alias = "gst_pad_new")]
pub fn builder(direction: crate::PadDirection) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -1454,11 +1452,14 @@ impl Pad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`Pad::builder_from_static_template()`] to get a [`PadBuilder`] and define options.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
///
/// # Panics
///
/// Panics if the `name_template` is a wildcard-name.
///
/// Use [`Pad::builder_from_static_template()`] to get a [`PadBuilder`] and define options.
#[doc(alias = "gst_pad_new_from_static_template")]
pub fn from_static_template(templ: &StaticPadTemplate) -> Self {
skip_assert_initialized!();
@ -1472,7 +1473,8 @@ impl Pad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`PadBuilder::name`] or [`PadBuilder::maybe_name`] to specify a different name.
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_pad_new_from_static_template")]
pub fn builder_from_static_template(templ: &StaticPadTemplate) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -1486,11 +1488,11 @@ impl Pad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`Pad::builder_from_template()`] to get a [`PadBuilder`] and define options.
///
/// # Panics
///
/// Panics if the `name_template` is a wildcard-name.
///
/// Use [`Pad::builder_from_template()`] to get a [`PadBuilder`] and define options.
#[doc(alias = "gst_pad_new_from_template")]
pub fn from_template(templ: &crate::PadTemplate) -> Self {
skip_assert_initialized!();
@ -1504,7 +1506,8 @@ impl Pad {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`PadBuilder::name`] or [`PadBuilder::maybe_name`] to specify a different name.
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[doc(alias = "gst_pad_new_from_template")]
pub fn builder_from_template(templ: &crate::PadTemplate) -> PadBuilder<Self> {
skip_assert_initialized!();
@ -1558,18 +1561,22 @@ impl Pad {
}
}
pub(crate) enum PadBuilderName {
Undefined,
KeepGenerated,
UserDefined(String),
CandidateForWildcardTemplate(String),
}
#[must_use = "The builder must be built to be used"]
pub struct PadBuilder<T> {
pub(crate) pad: T,
pub(crate) needs_specific_name: bool,
pub(crate) name: PadBuilderName,
}
impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
// rustdoc-stripper-ignore-next
/// Creates a `PadBuilder` with the specified [`PadDirection`](crate::PadDirection).
///
/// An automatically generated name will be assigned. Use [`PadBuilder::name`] or
/// [`PadBuilder::maybe_name`] to define a specific name.
pub fn new(direction: crate::PadDirection) -> Self {
assert_initialized_main_thread!();
@ -1588,7 +1595,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
PadBuilder {
pad,
needs_specific_name: false,
name: PadBuilderName::Undefined,
}
}
@ -1599,7 +1606,8 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`PadBuilder::name`] or [`PadBuilder::maybe_name`] to specify a different name.
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
pub fn from_static_template(templ: &StaticPadTemplate) -> Self {
skip_assert_initialized!();
@ -1614,7 +1622,8 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
/// i.e. if it's not a wildcard-name containing `%u`, `%s` or `%d`,
/// the `Pad` will automatically be named after the `name_template`.
///
/// Use [`PadBuilder::name`] or [`PadBuilder::maybe_name`] to specify a different name.
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
pub fn from_template(templ: &crate::PadTemplate) -> Self {
assert_initialized_main_thread!();
@ -1654,25 +1663,23 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
}
}
let needs_specific_name = if templ.name().find('%').is_some() {
// Pad needs a specific name
true
} else {
pad.set_property("name", templ.name());
false
};
PadBuilder {
pad,
needs_specific_name,
name: PadBuilderName::Undefined,
}
}
// rustdoc-stripper-ignore-next
/// Uses the `gst::Object` generated unique name.
pub fn generated_name(mut self) -> Self {
self.name = PadBuilderName::KeepGenerated;
self
}
// rustdoc-stripper-ignore-next
/// Sets the name of the Pad.
pub fn name(mut self, name: impl glib::IntoGStr) -> Self {
name.run_with_gstr(|name| self.pad.set_property("name", name));
self.needs_specific_name = false;
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = PadBuilderName::UserDefined(name.into());
self
}
@ -1682,7 +1689,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
///
/// This method is convenient when the `name` is provided as an `Option`.
/// If the `name` is `None`, this has no effect.
pub fn maybe_name<N: glib::IntoGStr>(self, name: Option<N>) -> Self {
pub fn maybe_name<N: Into<String>>(self, name: Option<N>) -> Self {
if let Some(name) = name {
self.name(name)
} else {
@ -1695,7 +1702,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
///
/// This method is convenient when the `name` is provided as an `Option`.
/// If the `name` is `None`, this has no effect.
pub fn name_if_some<N: glib::IntoGStr>(self, name: Option<N>) -> Self {
pub fn name_if_some<N: Into<String>>(self, name: Option<N>) -> Self {
if let Some(name) = name {
self.name(name)
} else {
@ -2047,18 +2054,132 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
/// and no specific `name` was provided using [`PadBuilder::name`]
/// or [`PadBuilder::maybe_name`], or for [`GhostPad`s](crate::GhostPad),
/// by defining a `target`.
///
/// Use [`generated_name()`](crate::PadBuilder::generated_name`) to keep the `gst::Object`
/// automatically generated unique name.
#[must_use = "Building the pad without using it has no effect"]
#[track_caller]
pub fn build(self) -> T {
if self.needs_specific_name {
panic!(concat!(
"Attempt to build a Pad from a wildcard-name template",
" or with a target Pad with an incompatible name.",
" Make sure to define a specific name using PadBuilder.",
));
let Self { pad, name } = self;
let templ = pad.pad_template();
use PadBuilderName::*;
match (name, templ) {
(KeepGenerated, _) => (),
(Undefined, None) => (),
(Undefined, Some(templ)) => {
if templ.name().find('%').is_some() {
panic!(concat!(
"Attempt to build a Pad from a wildcard-name template",
" or with a target Pad with an incompatible name.",
" Make sure to define a specific name using PadBuilder",
" or opt-in to keep the automatically generated name.",
));
} else {
pad.set_property("name", templ.name());
}
}
(UserDefined(name), _) | (CandidateForWildcardTemplate(name), None) => {
pad.set_property("name", name);
}
(CandidateForWildcardTemplate(name), Some(templ)) => {
if templ.name().find('%').is_none() {
// Not a widlcard template
pad.set_property("name", templ.name());
} else {
let mut can_assign_name = true;
if templ.presence() == crate::PadPresence::Request {
// Check if the name is compatible with the name template.
use crate::CAT_RUST;
let mut name_parts = name.split('_');
for templ_part in templ.name_template().split('_') {
let Some(name_part) = name_parts.next() else {
crate::debug!(
CAT_RUST,
"Not using Pad name '{name}': not enough parts compared to template '{}'",
templ.name_template(),
);
can_assign_name = false;
break;
};
if let Some(conv_spec_start) = templ_part.find('%') {
if conv_spec_start > 0
&& !name_part.starts_with(&templ_part[..conv_spec_start])
{
crate::debug!(
CAT_RUST,
"Not using Pad name '{name}': mismatch template '{}' prefix",
templ.name_template(),
);
can_assign_name = false;
break;
}
let conv_spec_pos = conv_spec_start + 1;
match templ_part.get(conv_spec_pos..=conv_spec_pos) {
Some("s") => {
// *There can be only one* %s
break;
}
Some("u") => {
if name_part
.get(conv_spec_start..)
.map_or(true, |s| s.parse::<u32>().is_err())
{
crate::debug!(
CAT_RUST,
"Not using Pad name '{name}': can't parse '%u' from '{name_part}' (template '{}')",
templ.name_template(),
);
can_assign_name = false;
break;
}
}
Some("d") => {
if name_part
.get(conv_spec_start..)
.map_or(true, |s| s.parse::<i32>().is_err())
{
crate::debug!(
CAT_RUST,
"Not using target Pad name '{name}': can't parse '%i' from '{name_part}' (template '{}')",
templ.name_template(),
);
can_assign_name = false;
break;
}
}
other => {
unreachable!("Unexpected conversion specifier {other:?}")
}
}
} else if name_part != templ_part {
can_assign_name = false;
}
}
}
if can_assign_name {
pad.set_property("name", name);
} else {
panic!(concat!(
"Attempt to build a Pad from a wildcard-name template",
" with a target Pad with an incompatible name.",
" Make sure to define a specific name using PadBuilder",
" or opt-in to keep the automatically generated name.",
));
}
}
}
}
self.pad
pad
}
}
@ -2484,11 +2605,21 @@ mod tests {
let pad = crate::Pad::builder(crate::PadDirection::Unknown).build();
assert!(pad.name().starts_with("pad"));
let pad = crate::Pad::builder(crate::PadDirection::Unknown)
.generated_name()
.build();
assert!(pad.name().starts_with("pad"));
let pad = crate::Pad::builder(crate::PadDirection::Unknown)
.maybe_name(None::<&str>)
.build();
assert!(pad.name().starts_with("pad"));
let pad = crate::Pad::builder(crate::PadDirection::Unknown)
.name_if_some(None::<&str>)
.build();
assert!(pad.name().starts_with("pad"));
let pad = crate::Pad::builder(crate::PadDirection::Sink)
.name("sink_0")
.build();
@ -2509,6 +2640,11 @@ mod tests {
.build();
assert_eq!(pad.name(), "test");
let pad = crate::Pad::builder(crate::PadDirection::Unknown)
.name_if_some(Some("test"))
.build();
assert_eq!(pad.name(), "test");
let caps = crate::Caps::new_any();
let templ = crate::PadTemplate::new(
"sink",
@ -2526,6 +2662,9 @@ mod tests {
.build();
assert!(pad.name().starts_with("audio_sink"));
let pad = Pad::builder_from_template(&templ).generated_name().build();
assert!(pad.name().starts_with("pad"));
let templ = crate::PadTemplate::new(
"audio_%u",
crate::PadDirection::Sink,
@ -2536,6 +2675,9 @@ mod tests {
let pad = Pad::builder_from_template(&templ).name("audio_0").build();
assert!(pad.name().starts_with("audio_0"));
let pad = Pad::builder_from_template(&templ).generated_name().build();
assert!(pad.name().starts_with("pad"));
}
#[test]