diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index 0b75f21fb..da376a52b 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -193,7 +193,7 @@ void CStreamInstance::run() dmx->addPid(*it); } - dmx->Start(true); + dmx->Start(); if (!send_raw) CCamManager::getInstance()->Start(channel_id, CCamManager::STREAM); @@ -384,6 +384,7 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro { char cbuf[512]; char *bp; + send_raw = false; FILE * fp = fdopen(fd, "r+"); if (fp == NULL) { @@ -426,22 +427,18 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro t_channel_id tmpid = 0; bp = &cbuf[5]; - if (sscanf(bp, "id=%" SCNx64, &tmpid) == 1) { - channel = CServiceManager::getInstance()->FindChannel(tmpid); - chid = tmpid; - } - int tmpraw = 0; - bp = &cbuf[25]; - - if (sscanf(bp, "raw=%d", &tmpraw) == 1) + if (strstr(bp,"id=")) { - send_raw = (tmpraw > 0); + if (sscanf(bp, "id=%" SCNx64, &tmpid) == 1) { + channel = CServiceManager::getInstance()->FindChannel(tmpid); + chid = tmpid; + send_raw = false; + pids.clear(); // to catch and stream all pids later ! + } } - - if (!tmpid) + else { - bp = &cbuf[5]; u_int service; u_int i1, i2, i3, i4, satpos; @@ -454,23 +451,18 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro { printf("e2 -> n chid:%" SCNx64 "\n", tmp_channel->getChannelID()); channel = tmp_channel; - chid = tmp_channel->getChannelID(); + chid = channel->getChannelID(); send_raw = true; + pids.clear(); // to catch and stream all pids later ! } } } + if (!channel) return false; printf("CStreamManager::Parse: channel_id %" PRIx64 " [%s] send %s\n", chid, channel->getName().c_str(), send_raw ? "raw" : "decrypted"); - streammap_iterator_t it = streams.find(chid); - if (it != streams.end()) - { - printf("CStreamManager::Parse: channel_id %" PRIx64 " already streaming, just add client %d\n", chid, fd); - return true; - } - if (IS_WEBCHAN(chid)) return true; @@ -547,9 +539,7 @@ bool CStreamManager::AddClient(int connfd) stream_pids_t pids; t_channel_id channel_id; CFrontend *frontend; - bool send_raw; - - pids.clear(); // to catch and stream all pids later ! + bool send_raw = false; if (Parse(connfd, pids, channel_id, frontend, send_raw)) { OpenThreads::ScopedLock m_lock(mutex); @@ -639,13 +629,11 @@ void CStreamManager::run() perror("CStreamManager::run(): accept"); continue; } - - g_RCInput->postMsg(NeutrinoMessages::EVT_STREAM_START, 0); +#if 0 if (!AddClient(connfd)) - { close(connfd); - g_RCInput->postMsg(NeutrinoMessages::EVT_STREAM_STOP, 0); - } +#endif + g_RCInput->postMsg(NeutrinoMessages::EVT_STREAM_START, connfd); poll_timeout = 1000; } else { if (pfd[i].revents & (POLLHUP | POLLRDHUP)) { diff --git a/src/neutrino.cpp b/src/neutrino.cpp index e0212f45a..28559cff0 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4330,11 +4330,16 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) return messages_return::handled; } else if (msg == NeutrinoMessages::EVT_STREAM_START) { - printf("NeutrinoMessages::EVT_STREAM_START\n"); + int fd = (int) data; + printf("NeutrinoMessages::EVT_STREAM_START: fd %d\n", fd); wakeupFromStandby(); if (g_Radiotext) g_Radiotext->setPid(0); + if (!CStreamManager::getInstance()->AddClient(fd)) { + close(fd); + g_RCInput->postMsg(NeutrinoMessages::EVT_STREAM_STOP, 0); + } #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE if (!CRecordManager::getInstance()->GetRecordCount()) { CVFD::getInstance()->ShowIcon(FP_ICON_CAM1, false);