diff options
-rw-r--r-- | dxr3interface.c | 31 | ||||
-rw-r--r-- | dxr3interface.h | 2 | ||||
-rw-r--r-- | dxr3output-audio.c | 14 | ||||
-rw-r--r-- | dxr3output.h | 1 | ||||
-rw-r--r-- | dxr3pesframe.h | 15 |
5 files changed, 63 insertions, 0 deletions
diff --git a/dxr3interface.c b/dxr3interface.c index d4b16c7..8346a19 100644 --- a/dxr3interface.c +++ b/dxr3interface.c @@ -24,6 +24,7 @@ #include "dxr3interface.h" #include "dxr3syncbuffer.h" #include "dxr3osd.h" +#include "dxr3pesframe.h" static const char *DEV_DXR3_OSD = "_sp"; static const char *DEV_DXR3_VIDEO = "_mv"; @@ -357,6 +358,36 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times) } // ================================== +void cDxr3Interface::PlayVideoFrame(cDxr3PesFrame *frame) +{ + if (!m_VideoActive) { + return; + } + + Lock(); + + const uint8_t *data = frame->GetPayload(); + uint32_t len = frame->GetPayloadLength(); + + while (len > 0) { + + int ret = write(m_fdVideo, data, len); + + if (ret > 0) { + len -= ret; + data += ret; + } + } + + Unlock(); + + SetAspectRatio(frame->GetAspectRatio()); + uint32_t pts = frame->GetPts(); + if (pts > 0) + m_lastSeenPts = pts; +} + +// ================================== void cDxr3Interface::ClaimDevices() { // devices already open diff --git a/dxr3interface.h b/dxr3interface.h index c08ef0c..86b07ed 100644 --- a/dxr3interface.h +++ b/dxr3interface.h @@ -33,6 +33,7 @@ // ================================== class cFixedLengthFrame; +class cDxr3PesFrame; class cDxr3Name { public: @@ -122,6 +123,7 @@ public: void SingleStep(); void PlayVideoFrame(cFixedLengthFrame* pFrame, int times = 1); void PlayVideoFrame(const uint8_t* pBuf, int length, int times = 1); + void PlayVideoFrame(cDxr3PesFrame *frame); // device access void ClaimDevices(); diff --git a/dxr3output-audio.c b/dxr3output-audio.c index 0d2e11d..4b478a6 100644 --- a/dxr3output-audio.c +++ b/dxr3output-audio.c @@ -23,6 +23,7 @@ #include <time.h> #include "dxr3output.h" #include "dxr3audio.h" +#include "dxr3pesframe.h" // ================================== const int AUDIO_OFFSET = 4500; @@ -125,6 +126,19 @@ void cDxr3AudioOutThread::PlayFrame(cFixedLengthFrame *frame) audioOutput->write(frame->GetData(), frame->GetCount()); } +void cDxr3AudioOutThread::PlayFrame(cDxr3PesFrame *frame) +{ + // update audio context + audioOutput->setup(frame->GetSampleContext()); + + // volume changes + if (!cDxr3Interface::Instance().IsAudioModeAC3()) { + audioOutput->changeVolume((short *)frame->GetDecoded(), (size_t)frame->GetDecodedSize()); + } + + audioOutput->write((uchar *)frame->GetDecoded(), frame->GetDecodedSize()); +} + #undef SCR // Local variables: diff --git a/dxr3output.h b/dxr3output.h index 6720bf1..e80478b 100644 --- a/dxr3output.h +++ b/dxr3output.h @@ -62,6 +62,7 @@ private: iAudio *audioOutput; void PlayFrame(cFixedLengthFrame *frame); + void PlayFrame(cDxr3PesFrame *frame); }; // ================================== diff --git a/dxr3pesframe.h b/dxr3pesframe.h index 5c174b5..b9aa664 100644 --- a/dxr3pesframe.h +++ b/dxr3pesframe.h @@ -114,6 +114,21 @@ public: return m_verticalSize; } + SampleContext GetSampleContext() const + { + return ctx; + } + + uint32_t GetDecodedSize() const + { + return decodedSize; + } + + const int16_t *GetDecoded() + { + return decoded; + } + private: ePesDataType m_pesDataType; const uint8_t* m_pesStart; |