Revert "dropped cServerConnection::m_Pending"

Required by VTP

This reverts commit bdaea38b86.
This commit is contained in:
Frank Schmirler 2011-10-24 08:44:31 +02:00
parent bdaea38b86
commit 077398fdef
4 changed files with 21 additions and 13 deletions

View File

@ -1,7 +1,6 @@
VDR Plugin 'streamdev' Revision History VDR Plugin 'streamdev' Revision History
--------------------------------------- ---------------------------------------
- dropped cServerConnection::m_Pending
- the icy-name HTTP header sent with radio streams makes VLC pick the wrong - the icy-name HTTP header sent with radio streams makes VLC pick the wrong
demuxer. Send icy-name only for ES audio streams. demuxer. Send icy-name only for ES audio streams.
- fixed regression of "live TV must be switched in VDR main thread" change: - fixed regression of "live TV must be switched in VDR main thread" change:

View File

@ -66,6 +66,7 @@ cServerConnection::cServerConnection(const char *Protocol, int Type):
cTBSocket(Type), cTBSocket(Type),
m_Protocol(Protocol), m_Protocol(Protocol),
m_DeferClose(false), m_DeferClose(false),
m_Pending(false),
m_ReadBytes(0), m_ReadBytes(0),
m_WriteBytes(0), m_WriteBytes(0),
m_WriteIndex(0) m_WriteIndex(0)
@ -195,6 +196,8 @@ bool cServerConnection::Write(void)
if (m_WriteIndex == m_WriteBytes) { if (m_WriteIndex == m_WriteBytes) {
m_WriteIndex = 0; m_WriteIndex = 0;
m_WriteBytes = 0; m_WriteBytes = 0;
if (m_Pending)
Command(NULL);
if (m_DeferClose) if (m_DeferClose)
return false; return false;
Flushed(); Flushed();
@ -202,12 +205,12 @@ bool cServerConnection::Write(void)
return true; return true;
} }
bool cServerConnection::Respond(const char *Message, ...) bool cServerConnection::Respond(const char *Message, bool Last, ...)
{ {
char *buffer; char *buffer;
int length; int length;
va_list ap; va_list ap;
va_start(ap, Message); va_start(ap, Last);
length = vasprintf(&buffer, Message, ap); length = vasprintf(&buffer, Message, ap);
va_end(ap); va_end(ap);
@ -230,6 +233,7 @@ bool cServerConnection::Respond(const char *Message, ...)
m_WriteBytes += length; m_WriteBytes += length;
m_WriteBuffer[m_WriteBytes++] = '\015'; m_WriteBuffer[m_WriteBytes++] = '\015';
m_WriteBuffer[m_WriteBytes++] = '\012'; m_WriteBuffer[m_WriteBytes++] = '\012';
m_Pending = !Last;
return true; return true;
} }

View File

@ -25,6 +25,7 @@ class cServerConnection: public cListObject, public cTBSocket
private: private:
const char *m_Protocol; const char *m_Protocol;
bool m_DeferClose; bool m_DeferClose;
bool m_Pending;
char m_ReadBuffer[MAXPARSEBUFFER]; char m_ReadBuffer[MAXPARSEBUFFER];
uint m_ReadBytes; uint m_ReadBytes;
@ -52,8 +53,12 @@ protected:
virtual bool Command(char *Cmd) = 0; virtual bool Command(char *Cmd) = 0;
/* Will put Message into the response queue, which will be sent in the next /* Will put Message into the response queue, which will be sent in the next
server cycle. Note that Message will be line-terminated by Respond. */ server cycle. Note that Message will be line-terminated by Respond.
virtual bool Respond(const char *Message, ...); Only one line at a time may be sent. If there are lines to follow, set
Last to false. Command(NULL) will be called in the next cycle, so you can
post the next line. */
virtual bool Respond(const char *Message, bool Last = true, ...);
//__attribute__ ((format (printf, 2, 4)));
/* Add a request header */ /* Add a request header */
void SetHeader(const char *Name, const char *Value, const char *Prefix = "") { m_Headers.insert(tStrStr(std::string(Prefix) + Name, Value)); } void SetHeader(const char *Name, const char *Value, const char *Prefix = "") { m_Headers.insert(tStrStr(std::string(Prefix) + Name, Value)); }
@ -82,8 +87,8 @@ public:
virtual bool HasData(void) const; virtual bool HasData(void) const;
/* Gets called by server when the socket can accept more data. Writes /* Gets called by server when the socket can accept more data. Writes
the buffer filled up by Respond(). Returns false in case of an the buffer filled up by Respond(). Calls Command(NULL) if there is a
error */ command pending. Returns false in case of an error */
virtual bool Write(void); virtual bool Write(void);
/* Gets called by server when there is incoming data to read. Calls /* Gets called by server when there is incoming data to read. Calls
@ -123,7 +128,7 @@ public:
inline bool cServerConnection::HasData(void) const inline bool cServerConnection::HasData(void) const
{ {
return m_WriteBytes > 0 || m_DeferClose; return m_WriteBytes > 0 || m_Pending || m_DeferClose;
} }
#endif // VDR_STREAMDEV_SERVER_CONNECTION_H #endif // VDR_STREAMDEV_SERVER_CONNECTION_H

View File

@ -147,7 +147,7 @@ bool cConnectionHTTP::ProcessRequest(void)
esyslog("streamdev-server connectionHTTP: Missing method or pathinfo"); esyslog("streamdev-server connectionHTTP: Missing method or pathinfo");
} else if (it_method->second.compare("GET") == 0 && ProcessURI(it_pathinfo->second)) { } else if (it_method->second.compare("GET") == 0 && ProcessURI(it_pathinfo->second)) {
if (m_ChannelList) if (m_ChannelList)
return Respond("%s", m_ChannelList->HttpHeader().c_str()); return Respond("%s", true, m_ChannelList->HttpHeader().c_str());
else if (m_Channel != NULL) { else if (m_Channel != NULL) {
cDevice *device = NULL; cDevice *device = NULL;
if (ProvidesChannel(m_Channel, 0)) if (ProvidesChannel(m_Channel, 0))
@ -164,7 +164,7 @@ bool cConnectionHTTP::ProcessRequest(void)
} else if (m_StreamType == stES && (m_Apid[0] || m_Dpid[0] || ISRADIO(m_Channel))) { } else if (m_StreamType == stES && (m_Apid[0] || m_Dpid[0] || ISRADIO(m_Channel))) {
return Respond("HTTP/1.0 200 OK") return Respond("HTTP/1.0 200 OK")
&& Respond("Content-Type: audio/mpeg") && Respond("Content-Type: audio/mpeg")
&& Respond("icy-name: %s", m_Channel->Name()) && Respond("icy-name: %s", true, m_Channel->Name())
&& Respond(""); && Respond("");
} else if (ISRADIO(m_Channel)) { } else if (ISRADIO(m_Channel)) {
return Respond("HTTP/1.0 200 OK") return Respond("HTTP/1.0 200 OK")
@ -190,7 +190,7 @@ bool cConnectionHTTP::ProcessRequest(void)
} else if (it_method->second.compare("HEAD") == 0 && ProcessURI(it_pathinfo->second)) { } else if (it_method->second.compare("HEAD") == 0 && ProcessURI(it_pathinfo->second)) {
DeferClose(); DeferClose();
if (m_ChannelList) if (m_ChannelList)
return Respond("%s", m_ChannelList->HttpHeader().c_str()); return Respond("%s", true, m_ChannelList->HttpHeader().c_str());
else if (m_Channel != NULL) { else if (m_Channel != NULL) {
if (ProvidesChannel(m_Channel, 0)) { if (ProvidesChannel(m_Channel, 0)) {
if (m_StreamType == stEXT) { if (m_StreamType == stEXT) {
@ -200,7 +200,7 @@ bool cConnectionHTTP::ProcessRequest(void)
} else if (m_StreamType == stES && (m_Apid[0] || m_Dpid[0] || ISRADIO(m_Channel))) { } else if (m_StreamType == stES && (m_Apid[0] || m_Dpid[0] || ISRADIO(m_Channel))) {
return Respond("HTTP/1.0 200 OK") return Respond("HTTP/1.0 200 OK")
&& Respond("Content-Type: audio/mpeg") && Respond("Content-Type: audio/mpeg")
&& Respond("icy-name: %s", m_Channel->Name()) && Respond("icy-name: %s", true, m_Channel->Name())
&& Respond(""); && Respond("");
} else if (ISRADIO(m_Channel)) { } else if (ISRADIO(m_Channel)) {
return Respond("HTTP/1.0 200 OK") return Respond("HTTP/1.0 200 OK")
@ -235,7 +235,7 @@ void cConnectionHTTP::Flushed(void)
if (m_ChannelList) { if (m_ChannelList) {
if (m_ChannelList->HasNext()) { if (m_ChannelList->HasNext()) {
if (!Respond("%s", m_ChannelList->Next().c_str())) if (!Respond("%s", true, m_ChannelList->Next().c_str()))
DeferClose(); DeferClose();
} }
else { else {