[vlma-devel] commit: Add a new class for stream channels. (U-PORTADRIEN\Adrien )
git version control
git at videolan.org
Mon May 19 20:39:30 CEST 2008
vlma | branch: master | U-PORTADRIEN\Adrien <Adrien at portadrien.(none)> | Mon May 19 20:11:06 2008 +0200| [669eda49bc11e2076c7573b38872d0994ebacce7]
Add a new class for stream channels.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=669eda49bc11e2076c7573b38872d0994ebacce7
---
.../videolan/vlma/model/media/StreamChannel.java | 158 ++++++++++++++++++++
1 files changed, 158 insertions(+), 0 deletions(-)
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/media/StreamChannel.java b/vlma-model/src/main/java/org/videolan/vlma/model/media/StreamChannel.java
new file mode 100755
index 0000000..22b2be3
--- /dev/null
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/media/StreamChannel.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2006-2008 the VideoLAN team
+ *
+ * This file is part of VLMa.
+ *
+ * VLMa is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * VLMa 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VLMa. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.videolan.vlma.model.media;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import org.videolan.vlma.VLMa;
+import org.videolan.vlma.model.program.Program;
+
+
+/**
+ * This class represents a channel where outer streams are diffused.
+ *
+ * @author MagSoft
+ */
+public class StreamChannel extends AbstractMedia {
+
+
+ private static final Logger logger = Logger.getLogger(FilesChannel.class);
+
+ private String fullname;
+
+ /**
+ * The URL of the stream
+ */
+ private String streamURL;
+
+ /**
+ * The constructor of the class
+ */
+ public StreamChannel() {
+ streamURL = "http://";
+ }
+
+ /**
+ * Sets the media program.
+ *
+ * @param program the program to set
+ */
+ @Override
+ public void setProgram(Program program)
+ {
+ super.setProgram(program);
+ updateSapGroup();
+ }
+
+ /**
+ * Updates the SAP group.
+ *
+ */
+ protected void updateSapGroup() {
+ if (program != null) {
+ String sapGroup = VLMa.getInstance().getString("vlma.sap.stream.group");
+ program.setSapGroup(sapGroup);
+ }
+ }
+
+
+ /**
+ * Gives the full name of the channel (used in the SAP announce).
+ *
+ * @return the channel name
+ */
+ public String getFullname() {
+ return fullname;
+ }
+
+ /**
+ * Sets the channel fullname.
+ *
+ * @param fullname
+ * the name to set
+ */
+ public void setFullname(String fullname) {
+ this.fullname = fullname;
+ }
+
+ public String getStreamURL() {
+ return this.streamURL;
+ }
+
+ public void setStreamURL(String URL) {
+ this.streamURL = URL;
+ }
+
+
+ /**
+ * Compares two StreamChannels.
+ *
+ * @return true if objects are the same, false otherwise
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o.getClass().equals(StreamChannel.class)) {
+ StreamChannel c = (StreamChannel) o;
+ logger.log(Level.DEBUG, "Comparaison de " + getName() + " et "
+ + c.getName());
+ return (c.streamURL.equals(this.streamURL) &&
+ (c.name.equals(this.name)));
+ }
+ return false;
+ }
+
+ @Override
+ public boolean sameGroup(Media media) {
+ return true;
+ }
+
+ @Override
+ public boolean belongsToGroup(MediaGroup group) {
+ if (!group.medias.isEmpty()) {
+ return sameGroup(group.medias.get(0));
+ }
+ return false;
+ }
+
+ /**
+ * Gives the channel hashcode.
+ *
+ * @return hashCode the channel hashcode
+ */
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ public int compareTo(Media other) {
+ if (other.getClass().equals(StreamChannel.class)) {
+ StreamChannel channel = (StreamChannel) other;
+ return name.compareTo(channel.getName());
+ }
+ return -1;
+ }
+
+ public int getId() {
+ return hashCode();
+ }
+
+}
More information about the vlma-devel
mailing list