Patch-stream-vdr-1.4.0

Un article de VDR Wiki FR.

File
patch-stream-vdr-1.4.0
diff -urN stream-0.1.1/HISTORY stream-0.1.1-vdr-1.4.0/HISTORY
--- stream-0.1.1/HISTORY	2003-02-14 12:59:01.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/HISTORY	2006-05-31 12:43:54.000000000 +0200
@@ -43,3 +43,7 @@
 - Completely adopted to the new RingBuffer API, so no memcopies are done
   anymore. This also fixed a serious bug that broke the Video Stream on 
 	slower machines.
+
+2006-05-20: Patch version for vdr 1.4.0 by agneau
+- Upadte for vdr 1.4.0 
+- Add svdrp command for start and stop streaming svdrpsend.pl PLUG stream START|STOP
diff -urN stream-0.1.1/Makefile stream-0.1.1-vdr-1.4.0/Makefile
--- stream-0.1.1/Makefile	2002-11-05 22:23:24.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/Makefile	2006-05-27 14:37:18.000000000 +0200
@@ -24,6 +24,7 @@
 ### The version number of VDR (taken from VDR's "config.h"):
 
 VDRVERSION = $(shell grep 'define VDRVERSION ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g')
+APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
 
 ### The name of the distribution archive:
 
@@ -65,7 +66,7 @@
 
 libvdr-$(PLUGIN).so: $(OBJS)
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
-	@cp $@ $(LIBDIR)/$@.$(VDRVERSION)
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -urN stream-0.1.1/setup.c stream-0.1.1-vdr-1.4.0/setup.c
--- stream-0.1.1/setup.c	2002-11-07 23:09:26.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/setup.c	2006-05-31 10:49:48.000000000 +0200
@@ -43,7 +43,8 @@
 	switch(Key) {
 	case kOk:
 		if (!cStreamRTPSocket::IsValidIp(newMulticastIp)) {
-			Interface->Error(tr("Multicast IP is invalid"));
+			//Interface->Error(tr("Multicast IP is invalid"));
+			printf("Multicast IP is invalid\n");
 			return osContinue;
 		}
 			
@@ -58,7 +59,8 @@
 			|| ((MulticastPort != newMulticastPort) && (newStreamType == MODE_MULTICAST))
 			|| (StreamType != newStreamType)
 			|| (strcmp(MulticastIp, newMulticastIp) != 0) && (newStreamType == MODE_MULTICAST) ) {
-		Interface->Info(tr("Please restart streaming to activate changes"));
+//		Interface->Info(tr("Please restart streaming to activate changes"));
+		printf("Please restart streaming to activate changes\n");		
 	}
   SetupStore("ChannelMode", ChannelMode = newChannelMode);
   SetupStore("UnicastPort", UnicastPort = newUnicastPort);
diff -urN stream-0.1.1/status.c stream-0.1.1-vdr-1.4.0/status.c
--- stream-0.1.1/status.c	2003-02-14 15:27:29.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/status.c	2006-05-29 13:15:16.000000000 +0200
@@ -54,15 +54,14 @@
 void cStreamStatus::CreateTransceiver(void) {
 	cChannel *curChan = Channels.GetByNumber(cDevice::PrimaryDevice()->CurrentChannel());
 	isyslog("stream: broadcasting channel %d, Vpid = %d, Apid = %d\n", 
-		cDevice::PrimaryDevice()->CurrentChannel(), curChan->Vpid(), curChan->Apid1());
+		cDevice::PrimaryDevice()->CurrentChannel(), curChan->Vpid(), curChan->Apid(0));
 
-	cDevice *device = cDevice::GetDevice(curChan, ChannelMode == MODE_FIXED 
-			? 0 : -1);
+	cDevice *device = cDevice::GetDevice(curChan, ChannelMode == MODE_FIXED ?  0 : -1);
 
 	if (device == NULL)
 		esyslog("stream: channel not available");
-
-	Transceiver = new cStreamTransceiver(Socket, curChan->Ca(), curChan->Vpid(), curChan->Apid1());
+ 
+	Transceiver = new cStreamTransceiver(Socket, curChan->Ca(), curChan->Vpid(), curChan->Apid(0),curChan->Tpid());
 	if (!device->AttachReceiver(Transceiver))
 		esyslog("stream: couldn't attach receiver object");
 }
diff -urN stream-0.1.1/stream.c stream-0.1.1-vdr-1.4.0/stream.c
--- stream-0.1.1/stream.c	2003-02-11 23:32:49.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/stream.c	2006-05-29 15:16:13.000000000 +0200
@@ -54,7 +54,6 @@
 			esyslog("stream: Unrecognized commandline option '%c'", optopt);
 			fprintf(stderr, "stream: Unrecognized commandline option '%c'\n", optopt);
 			return false;
-
 		case ':':
 			esyslog("stream: Parameter missing for commandline option '%c'", optopt);
 			fprintf(stderr, "stream: Parameter missing for commandline option '%c'\n", optopt);
@@ -103,4 +102,38 @@
 	return true;
 }
 
+const char **cPluginStream::SVDRPHelpPages(void)
+{
+  static const char *HelpPages[] = {
+      "start\n"
+      "    start the streaming.",
+      "stop \n"
+      "    stop the streaming.\n",
+      "state\n"
+      "State of the streaming",
+      NULL
+				          };
+  return HelpPages;
+}
+
+
+cString cPluginStream::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
+{
+  if(strcasecmp(Command,"START")==0) {
+    if (Status != NULL)  return "stream déjà démarré";
+    else {MainMenuAction();ReplyCode=901;return "Start streaming";}
+  }
+  if(strcasecmp(Command,"STOP")==0) {
+    if (Status == NULL)  return "stream déjà arrété";
+    else {MainMenuAction();ReplyCode=901;return "Stop streaming";}
+  }
+  if(strcasecmp(Command,"STATE")==0) {
+    if (Status == NULL)  return "stream arrété";
+    else return "stream demarré";
+  }
+
+  return NULL;
+}
+
+
 VDRPLUGINCREATOR(cPluginStream); // Don't touch this!
diff -urN stream-0.1.1/stream.h stream-0.1.1-vdr-1.4.0/stream.h
--- stream-0.1.1/stream.h	2002-11-07 23:09:28.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/stream.h	2006-05-29 15:09:54.000000000 +0200
@@ -27,6 +27,8 @@
   virtual cOsdMenu *MainMenuAction(void);
   virtual cMenuSetupPage *SetupMenu(void);
   virtual bool SetupParse(const char *Name, const char *Value);
+  virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
+  const char **SVDRPHelpPages(void);
 };
 
 #endif //  VDR_STREAM_H
diff -urN stream-0.1.1/transceiver.c stream-0.1.1-vdr-1.4.0/transceiver.c
--- stream-0.1.1/transceiver.c	2003-02-14 15:27:28.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/transceiver.c	2006-05-31 12:39:57.000000000 +0200
@@ -8,15 +8,17 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#define VIDEOBUFSIZE MEGABYTE(5)
+#define VIDEOBUFSIZE MEGABYTE(50)
 
-cStreamTransceiver::cStreamTransceiver(cStreamSocket *Socket, int Ca, int Vpid, int Apid):
-		cReceiver(Ca, ChannelMode == MODE_FIXED ? 0 : -1, 2, Vpid, Apid),
+cStreamTransceiver::cStreamTransceiver(cStreamSocket *Socket, int Ca, int Vpid, int Apid,int Tpid):
+//		cReceiver(Ca, ChannelMode == MODE_FIXED ? 0 : -1, 2, Vpid, Apid),
+		cReceiver(Ca, ChannelMode == MODE_FIXED ? 0 : -1, Vpid, &Apid,NULL),
 		ringBuffer(new cRingBufferLinear(VIDEOBUFSIZE, TS_SIZE * 2, true)),
 		socket(Socket), 
-		remux(new cRemux(Vpid, Apid, 0, 0, 0, true)),
+		remux(new cRemux((int)Vpid, (const int*)&Apid, NULL,NULL, true)),
 		pictureType(NO_PICTURE),
 		active(false) {
+
 }
 
 cStreamTransceiver::~cStreamTransceiver(void) {
@@ -59,18 +61,24 @@
 			int count = recvd;
 			int result;
 			
-			uchar *remuxBlock = remux->Process(block, count, result, 
-					&pictureType);
-			ringBuffer->Del(count);
-
+//			uchar *remuxBlock = remux->Process(block, count, result, 
+//					&pictureType);
+			count = remux->Put(block,count);
+
+			if (count)
+			  ringBuffer->Del(count);
+ 
+			uchar *remuxBlock = remux->Get(result,&pictureType);
 			if (remuxBlock && result > 0) {
 				if (!active && pictureType == I_FRAME)
 					break;
 				// Remux guarantees that the first Frame is an I-Frame, right?
 				socket->Broadcast(remuxBlock, result);
+				remux->Del(result);
 			}
-		} else
+		} else {
 			usleep(1);
+		}
 	}
 	
 	dsyslog("streaming transceiver thread ended (pid=%d)", getpid());
Les fichiers stream-0.1.1/.transceiver.c.swp et stream-0.1.1-vdr-1.4.0/.transceiver.c.swp sont différents.
diff -urN stream-0.1.1/transceiver.h stream-0.1.1-vdr-1.4.0/transceiver.h
--- stream-0.1.1/transceiver.h	2002-11-03 21:59:48.000000000 +0100
+++ stream-0.1.1-vdr-1.4.0/transceiver.h	2006-05-29 12:59:23.000000000 +0200
@@ -26,7 +26,7 @@
 	void Stop(void);
 
 public:
-	cStreamTransceiver(cStreamSocket *Socket, int Ca, int Vpid, int Apid);
+	cStreamTransceiver(cStreamSocket *Socket, int Ca, int Vpid, int Apid,int Tpid);
 	virtual ~cStreamTransceiver(void);
 };