DemuxPacket* CDVDDemuxClient::Read() { if (!m_IDemux) return nullptr; if (m_packet) return m_packet.release(); m_packet.reset(m_IDemux->ReadDemux()); if (!m_packet) { return nullptr; } if (m_packet->iStreamId == DMX_SPECIALID_STREAMINFO) { RequestStreams(); CDVDDemuxUtils::FreeDemuxPacket(m_packet.release()); return CDVDDemuxUtils::AllocateDemuxPacket(0); } else if (m_packet->iStreamId == DMX_SPECIALID_STREAMCHANGE) { RequestStreams(); } else if (m_packet->iStreamId >= 0 && m_streams.count(m_packet->iStreamId) > 0) { if (ParsePacket(m_packet.get())) { RequestStreams(); DemuxPacket *pPacket = CDVDDemuxUtils::AllocateDemuxPacket(0); pPacket->iStreamId = DMX_SPECIALID_STREAMCHANGE; pPacket->demuxerId = m_demuxerId; return pPacket; } } CDVDInputStream::IDisplayTime *inputStream = m_pInput->GetIDisplayTime(); if (inputStream) { int dispTime = inputStream->GetTime(); if (m_displayTime != dispTime) { m_displayTime = dispTime; if (m_packet->dts != DVD_NOPTS_VALUE) { m_dtsAtDisplayTime = m_packet->dts; } } if (m_dtsAtDisplayTime != DVD_NOPTS_VALUE && m_packet->dts != DVD_NOPTS_VALUE) { m_packet->dispTime = m_displayTime; m_packet->dispTime += DVD_TIME_TO_MSEC(m_packet->dts - m_dtsAtDisplayTime); } } return m_packet.release(); }
DemuxPacket* CDVDDemuxClient::Read() { if (!m_IDemux) return nullptr; DemuxPacket* pPacket = m_IDemux->ReadDemux(); if (!pPacket) { return nullptr; } if (pPacket->iStreamId == DMX_SPECIALID_STREAMINFO) { RequestStreams(); CDVDDemuxUtils::FreeDemuxPacket(pPacket); return CDVDDemuxUtils::AllocateDemuxPacket(0); } else if (pPacket->iStreamId == DMX_SPECIALID_STREAMCHANGE) { RequestStreams(); } else if (pPacket->iStreamId >= 0 && m_streams[pPacket->iStreamId]) { ParsePacket(pPacket); } CDVDInputStream::IDisplayTime *inputStream = m_pInput->GetIDisplayTime(); if (inputStream) { int dispTime = inputStream->GetTime(); if (m_displayTime != dispTime) { m_displayTime = dispTime; if (pPacket->dts != DVD_NOPTS_VALUE) { m_dtsAtDisplayTime = pPacket->dts; } } if (m_dtsAtDisplayTime != DVD_NOPTS_VALUE && pPacket->dts != DVD_NOPTS_VALUE) { pPacket->dispTime = m_displayTime; pPacket->dispTime += DVD_TIME_TO_MSEC(pPacket->dts - m_dtsAtDisplayTime); } } return pPacket; }