1 #ifndef DISABLE_NETWORK
7 #include <lib/gui/ebutton.h>
8 #include <lib/gui/emessage.h>
9 #include <lib/dvb/decoder.h>
10 #include <lib/dvb/service.h>
11 #include <lib/dvb/dvb.h>
12 #include <lib/dvb/dvbservice.h>
13 #include <lib/dvb/epgcache.h>
14 //#include <lib/base/estring.h>
15 //#define TMP_NgrabXML "/var/tmp/e-ngrab.xml"
16 #include <lib/gui/enumber.h>
17 #include <lib/gui/statusbar.h>
18 #include <epgwindow.h>
20 static eString
getServiceName()
22 eService
*current
=eServiceInterface::getInstance()->addRef( eServiceInterface::getInstance()->service
);
24 return "no channel selected";
26 eString sname
= current
->service_name
;
28 eServiceInterface::getInstance()->removeRef( eServiceInterface::getInstance()->service
);
33 static eString
getEPGTitle()
35 eServiceReference
&ref
= eServiceInterface::getInstance()->service
;
37 eString
descr(_("no description is available"));
39 EITEvent
*tmp
=eEPGCache::getInstance()->lookupEvent((eServiceReferenceDVB
&)ref
);
45 led
.getLocalData(tmp
, &descr
, &text
, 0);
46 if ((text
.length() > 0) && (text
!= descr
))
63 eString
ENgrab::startxml( const char* descr
)
67 xmlstart
+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
68 xmlstart
+=" <neutrino commandversion=\"1\">\n";
69 xmlstart
+=" <record command=\"record\">\n";
70 xmlstart
+=" <channelname>"+getServiceName()+"</channelname>\n";//übernommen von trh
71 xmlstart
+=" <epgtitle>"+(descr
?eString(descr
):getEPGTitle())+"</epgtitle>\n"; //übernommen von trh
72 xmlstart
+=" <onidsid>123456</onidsid>\n"; // keine ahnung aber wies aussieht wird die sid und die onid nicht gebraucht von ngrab
73 xmlstart
+=" <epgid>123456</epgid>\n"; // und die epgid auch nicht
74 xmlstart
+=" <videopid>"+eString().sprintf("%d", Decoder::current
.vpid
)+"</videopid>\n";
75 xmlstart
+=" <audiopids selected=\""+eString().sprintf("%d", Decoder::current
.apid
)+"\">\n";
76 eDVBServiceController
*sapi
=eDVB::getInstance()->getServiceAPI();
77 if (!sapi
|| !sapi
->service
)
78 xmlstart
+=" <audio pid=\""+eString().sprintf("%d", Decoder::current
.apid
)+"\" name=\"standard\"/>\n";
81 std::list
<eDVBServiceController::audioStream
> &audioStreams
= sapi
->audioStreams
;
82 for (std::list
<eDVBServiceController::audioStream
>::iterator it
= audioStreams
.begin(); it
!= audioStreams
.end(); ++it
)
83 xmlstart
+=" <audio pid=\""+eString().sprintf("%d", it
->pmtentry
->elementary_PID
) + "\" name=\"" + it
->text
+ "\"/>\n";
85 xmlstart
+=" </audiopids>\n";
86 xmlstart
+=" </record>\n";
87 xmlstart
+=" </neutrino>\n";
91 std::fstream xmlstartf
;
92 char* Name0
=TMP_NgrabXML
;
93 xmlstartf
.open(Name0
,ios::out
);
94 xmlstartf
<<xmlstart
<<endl
;
101 eString
ENgrab::stopxml()
105 xmlstop
+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
106 xmlstop
+=" <neutrino commandversion=\"2\">\n";
107 xmlstop
+=" <record command=\"stop\">\n";
108 xmlstop
+=" <channelname></channelname>\n";
109 xmlstop
+=" <epgtitle></epgtitle>\n";
110 xmlstop
+=" <onidsid></onidsid>\n";
111 xmlstop
+=" <epgid></epgid>\n";
112 xmlstop
+=" <videopid></videopid>\n";
113 xmlstop
+=" <audiopids selected=\"\">\n";
114 xmlstop
+=" <audio pid=\"\" name=\"\"/>\n";
115 xmlstop
+=" </audiopids>\n";
116 xmlstop
+=" </record>\n";
117 xmlstop
+=" </neutrino>\n";
120 std::fstream xmlstopf
;
121 char* Name0
=TMP_NgrabXML
;
122 xmlstopf
.open(Name0
,ios::out
);
123 xmlstopf
<<xmlstop
<<endl
;
129 void ENgrab::sendstart( const char *descr
)
131 eDebug("ngrab sendstart requested");
132 sendStr
= startxml(descr
);
136 void ENgrab::sendstop()
138 eDebug("ngrab sendstop requested");
143 void ENgrab::connected()
145 eDebug("connection to ngrab established");
146 sd
->writeBlock(sendStr
.c_str(), sendStr
.length());
149 void ENgrab::dataWritten( int bytes
)
151 eDebug("all data to ngrab written...close connection");
152 if ( !sd
->bytesToWrite() )
156 void ENgrab::connectionTimeouted()
158 eDebug("could not connect to ngrab server...connection timeout");
162 void ENgrab::connectionClosed()
164 eDebug("ngrab connection closed");
169 void ENgrab::sending()
171 struct in_addr sinet_address
;
175 sinet_address
.s_addr
= 0xC0A80028; // 192.168.0.40
176 eConfig::getInstance()->getKey("/elitedvb/network/nserver", sinet_address
.s_addr
);
177 eConfig::getInstance()->getKey("/elitedvb/network/nservport", port
);
178 eNumber::unpack(sinet_address
.s_addr
, de
);
179 hostname
=eString().sprintf("%d.%d.%d.%d", de
[0], de
[1], de
[2], de
[3]);
183 timeout
.start(120000,true); // connection timeout
184 CONNECT( timeout
.timeout
, ENgrab::connectionTimeouted
);
185 sd
=new eSocket(eApp
);
186 CONNECT( sd
->connected_
, ENgrab::connected
);
187 CONNECT( sd
->connectionClosed_
, ENgrab::connectionClosed
);
188 CONNECT( sd
->bytesWritten_
, ENgrab::dataWritten
);
189 eDebug("connect to ngrab server at %s:%d", hostname
.c_str(), port
);
190 sd
->connectToHost(hostname
, port
);
194 #endif // DISABLE_NETWORK