From 0bdec7ee526ab2dc5142f550c00cd0b992be1284 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Sun, 30 Jul 2023 11:42:06 +0200 Subject: [PATCH] LDEV-3443 further remove old video code https://luceeserver.atlassian.net/browse/LDEV-3343 --- core/src/main/java/META-INF/MANIFEST.MF | 2 - .../lucee/runtime/config/ConfigAdmin.java | 13 +- .../runtime/functions/video/IsVideoFile.java | 45 --- .../main/java/lucee/runtime/tag/Admin.java | 13 - .../runtime/video/ProfileCollection.java | 257 ------------------ .../main/java/lucee/runtime/video/Range.java | 114 -------- core/src/main/java/resource/fld/core-base.fld | 18 -- 7 files changed, 1 insertion(+), 461 deletions(-) delete mode 100644 core/src/main/java/lucee/runtime/functions/video/IsVideoFile.java delete mode 100644 core/src/main/java/lucee/runtime/video/ProfileCollection.java delete mode 100644 core/src/main/java/lucee/runtime/video/Range.java diff --git a/core/src/main/java/META-INF/MANIFEST.MF b/core/src/main/java/META-INF/MANIFEST.MF index cfa622fc85..0dd175de2b 100644 --- a/core/src/main/java/META-INF/MANIFEST.MF +++ b/core/src/main/java/META-INF/MANIFEST.MF @@ -171,7 +171,6 @@ Export-Package: coldfusion, lucee.runtime.functions.string, lucee.runtime.functions.struct, lucee.runtime.functions.system, - lucee.runtime.functions.video, lucee.runtime.functions.xml, lucee.runtime.gateway, lucee.runtime.gateway.proxy, @@ -279,7 +278,6 @@ Export-Package: coldfusion, lucee.runtime.user, lucee.runtime.util, lucee.runtime.util.pool, - lucee.runtime.video, lucee.runtime.vm, lucee.runtime.writer, lucee.servlet, diff --git a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java index a46f99fb37..dd06339b2d 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java +++ b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java @@ -149,8 +149,6 @@ import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.ListUtil; import lucee.runtime.type.util.StructUtil; -import lucee.runtime.video.VideoExecuter; -import lucee.runtime.video.VideoExecuterNotSupported; import lucee.transformer.library.ClassDefinitionImpl; import lucee.transformer.library.function.FunctionLibException; import lucee.transformer.library.tag.TagLibException; @@ -4285,7 +4283,6 @@ private void setExtensionAttrs(Struct el, Extension extension) { el.setEL("author", extension.getAuthor()); el.setEL("type", extension.getType()); el.setEL("codename", extension.getCodename()); - el.setEL("video", extension.getVideo()); el.setEL("support", extension.getSupport()); el.setEL("documentation", extension.getDocumentation()); el.setEL("forum", extension.getForum()); @@ -5449,15 +5446,7 @@ public void updateRemoteClientUsage(String code, String displayname) { extensions.setEL("usage", toStringURLStyle(usage)); } - - public void updateVideoExecuterClass(ClassDefinition cd) throws PageException { - - if (cd.getClassName() == null) cd = new ClassDefinitionImpl(VideoExecuterNotSupported.class.getName()); - - Struct app = _getRootElement("video"); - setClass(app, VideoExecuter.class, "videoExecuter", cd); - } - + public void updateAdminSyncClass(ClassDefinition cd) throws PageException { if (cd.getClassName() == null) cd = new ClassDefinitionImpl(AdminSyncNotSupported.class.getName()); diff --git a/core/src/main/java/lucee/runtime/functions/video/IsVideoFile.java b/core/src/main/java/lucee/runtime/functions/video/IsVideoFile.java deleted file mode 100644 index 0c749847b9..0000000000 --- a/core/src/main/java/lucee/runtime/functions/video/IsVideoFile.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - **/ -package lucee.runtime.functions.video; - -import lucee.commons.lang.StringUtil; -import lucee.runtime.PageContext; -import lucee.runtime.config.ConfigWeb; -import lucee.runtime.exp.PageException; -import lucee.runtime.op.Caster; -import lucee.runtime.video.VideoExecuter; -import lucee.runtime.video.VideoInputImpl; -import lucee.runtime.video.VideoUtilImpl; - -public class IsVideoFile { - - public static boolean call(PageContext pc, String path) throws PageException { - try { - ConfigWeb config = pc.getConfig(); - VideoExecuter ve = VideoUtilImpl.createVideoExecuter(config); - ve.info(config, new VideoInputImpl(Caster.toResource(pc, path, true))); - } - catch (Exception e) { - - if (StringUtil.contains(e.getMessage(), "missing ffmpeg installation")) throw Caster.toPageException(e); - return false; - } - return true; - } -} \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/tag/Admin.java b/core/src/main/java/lucee/runtime/tag/Admin.java index 4b6cecdcc3..b83c1b6dcc 100755 --- a/core/src/main/java/lucee/runtime/tag/Admin.java +++ b/core/src/main/java/lucee/runtime/tag/Admin.java @@ -863,8 +863,6 @@ else if (check("getLoggedDebugData", ACCESS_FREE)) // no password necessary for else if (check("getAdminSyncClass", ACCESS_FREE) && check2(ACCESS_READ)) doGetAdminSyncClass(); else if (check("updateAdminSyncClass", ACCESS_FREE) && check2(ACCESS_WRITE)) doUpdateAdminSyncClass(); - else if (check("getVideoExecuterClass", ACCESS_FREE) && check2(ACCESS_READ)) doGetVideoExecuterClass(); - else if (check("updateVideoExecuterClass", ACCESS_FREE) && check2(ACCESS_WRITE)) doUpdateVideoExecuterClass(); else if (check("terminateRunningThread", ACCESS_FREE) && check2(ACCESS_WRITE)) doTerminateRunningThread(); else if (check("updateLabel", ACCESS_NOT_WHEN_WEB) && check2(ACCESS_WRITE)) doUpdateLabel(); @@ -2235,17 +2233,6 @@ private void doGetAdminSyncClass() throws PageException { pageContext.setVariable(getString("admin", action, "returnVariable"), config.getAdminSyncClass().getName()); } - private void doUpdateVideoExecuterClass() throws PageException { - ClassDefinition cd = new ClassDefinitionImpl(getString("admin", action, "class"), getString("bundleName", null), getString("bundleVersion", null), - config.getIdentification()); - admin.updateVideoExecuterClass(cd); - store(); - } - - private void doGetVideoExecuterClass() throws PageException { - pageContext.setVariable(getString("admin", action, "returnVariable"), config.getVideoExecuterClass().getName()); - } - /** * @throws PageException * diff --git a/core/src/main/java/lucee/runtime/video/ProfileCollection.java b/core/src/main/java/lucee/runtime/video/ProfileCollection.java deleted file mode 100644 index 89d2c85543..0000000000 --- a/core/src/main/java/lucee/runtime/video/ProfileCollection.java +++ /dev/null @@ -1,257 +0,0 @@ -/** - * - * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - **/ -package lucee.runtime.video; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.StringTokenizer; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import lucee.commons.io.IOUtil; -import lucee.commons.io.res.Resource; -import lucee.loader.util.Util; -import lucee.runtime.config.Config; -import lucee.runtime.exp.ApplicationException; -import lucee.runtime.exp.PageException; -import lucee.runtime.op.Caster; -import lucee.runtime.text.xml.XMLUtil; - -public class ProfileCollection { - - private static VideoUtil util = VideoUtilImpl.getInstance(); - - private Map profiles; - - public ProfileCollection(Config config) throws ApplicationException { - init(config, true); - } - - private void init(Config config, boolean initProfiles) throws ApplicationException { - // get the video directory - Resource dir = config.getVideoDirectory(); - - // get the video.xml - Resource xml = dir.getRealResource("video.xml"); - - // create (if not exist) and return video xml as dom - Element video; - try { - video = getVideoXML(xml); - } - catch (Exception e) { - throw new ApplicationException("can not load video xml file [" + xml + "]", Caster.toClassName(e) + ":" + e.getMessage()); - } - - // translate form DOM to a List of VideoProfile - if (initProfiles) { - try { - profiles = translateVideoXML(video); - } - catch (PageException e) { - throw new ApplicationException("can not load profiles from video xml file [" + xml + "] a type is invalid", e.getMessage()); - } - } - } - - /** - * @return the qualities - */ - public Map getProfiles() { - return profiles; - } - - /** - * translate form DOM to a List of VideoProfile - * - * @param video - * @return - * @throws PageException - */ - private static Map translateVideoXML(Element video) throws PageException { - Map profiles = new LinkedHashMap(); - // quality - Element qd = getChildByName(video, "profiles", false); - Element[] items = getChildren(qd, "profile"); - Element item; - VideoProfile vq; - String value; - for (int i = 0; i < items.length; i++) { - item = items[i]; - vq = new VideoProfileImpl(); - // aspect-ratio - value = item.getAttribute("aspect-ratio"); - if (!Util.isEmpty(value)) vq.setAspectRatio(value); - - // aspect-ratio - value = item.getAttribute("audio-bitrate"); - if (!Util.isEmpty(value)) vq.setAudioBitrate(util.toBytes(value)); - - // audio-samplerate - value = item.getAttribute("audio-samplerate"); - if (!Util.isEmpty(value)) vq.setAudioSamplerate(util.toHerz(value)); - - // dimension - String w = item.getAttribute("width"); - String h = item.getAttribute("height"); - if (!Util.isEmpty(w) && !Util.isEmpty(h)) { - vq.setDimension(Caster.toIntValue(w), Caster.toIntValue(h)); - } - - // framerate - value = item.getAttribute("framerate"); - String value2 = item.getAttribute("fps"); - if (!Util.isEmpty(value)) vq.setFramerate(Caster.toDoubleValue(value)); - else if (!Util.isEmpty(value2)) vq.setFramerate(Caster.toDoubleValue(value2)); - - // video-bitrate - value = item.getAttribute("video-bitrate"); - if (!Util.isEmpty(value)) vq.setVideoBitrate(util.toBytes(value)); - - // video-bitrate-max - value = item.getAttribute("video-bitrate-max"); - if (!Util.isEmpty(value)) vq.setVideoBitrateMax(util.toBytes(value)); - - // video-bitrate-min - value = item.getAttribute("video-bitrate-min"); - if (!Util.isEmpty(value)) vq.setVideoBitrateMin(util.toBytes(value)); - - // video-bitrate-tolerance - value = item.getAttribute("video-bitrate-tolerance"); - if (!Util.isEmpty(value)) vq.setVideoBitrateTolerance(util.toBytes(value)); - - // video-codec - value = item.getAttribute("video-codec"); - // print.out("video-codec:"+value); - if (!Util.isEmpty(value)) vq.setVideoCodec(value); - - // audio-codec - value = item.getAttribute("audio-codec"); - if (!Util.isEmpty(value)) vq.setAudioCodec(value); - - // - value = item.getAttribute("label"); - // print.out("label:"+value); - if (!Util.isEmpty(value)) { - String[] arr = toArray(value); - for (int y = 0; y < arr.length; y++) { - profiles.put(arr[y].trim().toLowerCase(), vq); - } - } - } - return profiles; - } - - private static Element getChildByName(Node parent, String nodeName, boolean insertBefore) { - if (parent == null) return null; - NodeList list = parent.getChildNodes(); - int len = list.getLength(); - - for (int i = 0; i < len; i++) { - Node node = list.item(i); - - if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) { - return (Element) node; - } - } - Element newEl = parent.getOwnerDocument().createElement(nodeName); - if (insertBefore) parent.insertBefore(newEl, parent.getFirstChild()); - else parent.appendChild(newEl); - return newEl; - } - - private static Element[] getChildren(Node parent, String nodeName) { - if (parent == null) return new Element[0]; - NodeList list = parent.getChildNodes(); - int len = list.getLength(); - ArrayList rtn = new ArrayList(); - - for (int i = 0; i < len; i++) { - Node node = list.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) { - rtn.add(node); - } - } - return (Element[]) rtn.toArray(new Element[rtn.size()]); - } - - private static String[] toArray(String str) { - StringTokenizer st = new StringTokenizer(str, ","); - ArrayList list = new ArrayList(); - while (st.hasMoreTokens()) { - list.add(str = st.nextToken()); - } - return list.toArray(new String[list.size()]); - } - - /** - * create (if not exist) and return video xml as dom - * - * @param xml - * @return - * @throws IOException - * @throws SAXException - */ - private static Element getVideoXML(Resource xml) throws IOException, SAXException { - if (!xml.exists()) { - createFileFromResource("/resource/video/video.xml", xml); - } - Document doc = loadDocument(xml); - return doc.getDocumentElement(); - } - - public static void createFileFromResource(String path, Resource bin) throws IOException { - InputStream is = null; - OutputStream os = null; - - if (bin.exists()) return; - - IOUtil.copy(is = new VideoInputImpl(null).getClass().getResourceAsStream(path), os = bin.getOutputStream(), true, true); - - } - - private static Document loadDocument(Resource xmlFile) throws SAXException, IOException { - InputStream is = null; - try { - return loadDocument(is = xmlFile.getInputStream()); - } - finally { - IOUtil.close(is); - } - } - - private static Document loadDocument(InputStream is) throws SAXException, IOException { - try { - InputSource source = new InputSource(is); - return XMLUtil.parse(source, null, false); - } - finally { - IOUtil.close(is); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/video/Range.java b/core/src/main/java/lucee/runtime/video/Range.java deleted file mode 100644 index fcbba1e22d..0000000000 --- a/core/src/main/java/lucee/runtime/video/Range.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - **/ -package lucee.runtime.video; - -import lucee.runtime.exp.PageException; -import lucee.runtime.op.Caster; -import lucee.runtime.op.Decision; - -public class Range { - - public static final Range TRUE = new Range(0, -1); - public static final Range FALSE = new Range(0, 0); - private double from; - private double to; - - public Range(double from, double to) { - this.from = from; - this.to = to; - } - - public static Range toRange(String def) throws PageException { - def = def.trim(); - // boolean - if (Decision.isBoolean(def)) { - return Caster.toBooleanValue(def) ? TRUE : FALSE; - } - - int index = def.indexOf(','); - // single value - if (index == -1) { - return new Range(toSeconds(def), -1); - } - - // double value - if (def.startsWith(",")) def = "0" + def; - if (def.endsWith(",")) def += "-1"; - - return new Range(toSeconds(def.substring(0, index)), toSeconds(def.substring(index + 1))); - - } - - private static double toSeconds(String str) throws PageException { - str = str.trim().toLowerCase(); - - if (str.endsWith("ms")) return Caster.toDoubleValue(str.substring(0, str.length() - 2)) / 1000D; - else if (str.endsWith("s")) return Caster.toDoubleValue(str.substring(0, str.length() - 1)); - else return Caster.toDoubleValue(str) / 1000D; - // TODO if(str.endsWith("f")) this.startFrame=VideoConfig.toLong(str.substring(0,str.length()-1)); - - } - - /** - * @return the from - */ - public double getFrom() { - return from; - } - - public String getFromAsString() { - return Caster.toString(from); - } - - /** - * @return the to - */ - public double getTo() { - return to; - } - - public String getToAsString() { - return Caster.toString(to); - } - - /** - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (!(obj instanceof Range)) return false; - Range other = (Range) obj; - return other.from == from && other.to == to; - } - - /** - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "" + from + ":" + to + ""; - } - - public boolean show() { - return !equals(Range.FALSE); - } -} \ No newline at end of file diff --git a/core/src/main/java/resource/fld/core-base.fld b/core/src/main/java/resource/fld/core-base.fld index ed63dd16b8..4024c3d875 100755 --- a/core/src/main/java/resource/fld/core-base.fld +++ b/core/src/main/java/resource/fld/core-base.fld @@ -8013,24 +8013,6 @@ The following things are considered to be empty: boolean - - - IsVideoFile - lucee.runtime.functions.video.IsVideoFile - decision,video - - Check if a String is a Video file - - - value - string - Yes - file to check - - - boolean - - isXML