int MRtmpSource::dispatch(MRtmpMessage &msg) { list<MRtmpPool *>::iterator iter; for (iter = m_pools.begin(); iter != m_pools.end(); ++iter) { MRtmpPool *rp = *iter; rp->onMessage(msg); } return E_SUCCESS; }
int BlsHttpClient::sendHttpLiveFlv(const MString &url) { // response http header MHttpResponseHeader header; header.setStatusLine(200); header.addValue("Connection", "close"); header.addValue("Accept-Ranges", "bytes"); header.addValue("Cache-Control", "no-store"); header.setContentType(MHttpHeader::contentType("flv")); if (response(header, flv_header, 13) != E_SUCCESS) { log_error("response http failed."); return -1; } MRtmpSource *source = MRtmpSource::findSource(url); MRtmpPool *pool = new MRtmpPool(url); source->addPool(pool); while (true) { list<MRtmpMessage> msgs = pool->getMessage(); list<MRtmpMessage>::iterator iter; for (iter = msgs.begin(); iter != msgs.end(); ++iter) { MRtmpMessage &msg = *iter; // to FLV message MStream stream = serialFlv(&msg); if (m_socket->write(stream) != stream.size()) { log_error("send flv tag failed"); return -2; } } mMSleep(5); } return E_SUCCESS; }
int MRtmpConnection::playService() { int ret = E_SUCCESS; MString url = m_protocol->getRtmpCtx()->url(); MRtmpPool *pool = new MRtmpPool(url, this); m_source->addPool(pool); while (!RequestStop) { list<MRtmpMessage> msgs = pool->getMessage(); list<MRtmpMessage>::iterator iter; for (iter = msgs.begin(); iter != msgs.end(); ++iter) { MRtmpMessage &msg = *iter; if ((ret = m_protocol->send_message(&msg)) != E_SUCCESS) { return ret; } } mMSleep(100); } return ret; }