mirror of
https://github.com/rofafor/vdr-plugin-femon.git
synced 2023-10-10 13:36:53 +02:00
Revert "Changed cRingBufferLinear to cRingBufferFrame."
This reverts commit edb8b4090a
.
This commit is contained in:
parent
ea4561a874
commit
8267abcc3b
111
femonreceiver.c
111
femonreceiver.c
@ -20,18 +20,18 @@ cFemonReceiver::cFemonReceiver(tChannelID ChannelID, int Ca, int Vtype, int Vpid
|
|||||||
m_DetectMPEG(this, this),
|
m_DetectMPEG(this, this),
|
||||||
m_DetectAAC(this),
|
m_DetectAAC(this),
|
||||||
m_DetectAC3(this),
|
m_DetectAC3(this),
|
||||||
m_VideoBuffer(KILOBYTE(256)),
|
m_VideoBuffer(KILOBYTE(256), TS_SIZE, false, "Femon video"),
|
||||||
m_VideoType(Vtype),
|
m_VideoType(Vtype),
|
||||||
m_VideoPid(Vpid),
|
m_VideoPid(Vpid),
|
||||||
m_VideoPacketCount(0),
|
m_VideoPacketCount(0),
|
||||||
m_VideoBitrate(0.0),
|
m_VideoBitrate(0.0),
|
||||||
m_VideoValid(false),
|
m_VideoValid(false),
|
||||||
m_AudioBuffer(KILOBYTE(256)),
|
m_AudioBuffer(KILOBYTE(256), TS_SIZE, false, "Femon audio"),
|
||||||
m_AudioPid(Apid[0]),
|
m_AudioPid(Apid[0]),
|
||||||
m_AudioPacketCount(0),
|
m_AudioPacketCount(0),
|
||||||
m_AudioBitrate(0.0),
|
m_AudioBitrate(0.0),
|
||||||
m_AudioValid(false),
|
m_AudioValid(false),
|
||||||
m_AC3Buffer(KILOBYTE(256)),
|
m_AC3Buffer(KILOBYTE(256), TS_SIZE, false, "Femon AC3"),
|
||||||
m_AC3Pid(Dpid[0]),
|
m_AC3Pid(Dpid[0]),
|
||||||
m_AC3PacketCount(0),
|
m_AC3PacketCount(0),
|
||||||
m_AC3Bitrate(0),
|
m_AC3Bitrate(0),
|
||||||
@ -95,14 +95,33 @@ void cFemonReceiver::Activate(bool On)
|
|||||||
|
|
||||||
void cFemonReceiver::Receive(uchar *Data, int Length)
|
void cFemonReceiver::Receive(uchar *Data, int Length)
|
||||||
{
|
{
|
||||||
if ((Length == TS_SIZE) && (*Data == TS_SYNC_BYTE)) {
|
// TS packet length: TS_SIZE
|
||||||
int pid = TsPid(Data);
|
if ((*Data == TS_SYNC_BYTE) || (Length == TS_SIZE)) {
|
||||||
if (pid == m_VideoPid)
|
int len, pid = TsPid(Data);
|
||||||
m_VideoBuffer.Put(new cFrame(Data, Length, ftVideo, m_VideoPacketCount++));
|
if (pid == m_VideoPid) {
|
||||||
else if (pid == m_AudioPid)
|
++m_VideoPacketCount;
|
||||||
m_AudioBuffer.Put(new cFrame(Data, Length, ftAudio, m_AudioPacketCount++));
|
len = m_VideoBuffer.Put(Data, Length);
|
||||||
else if (pid == m_AC3Pid)
|
if (len != Length) {
|
||||||
m_AC3Buffer.Put(new cFrame(Data, Length, ftDolby, m_AC3PacketCount++));
|
m_VideoBuffer.ReportOverflow(Length - len);
|
||||||
|
m_VideoBuffer.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (pid == m_AudioPid) {
|
||||||
|
++m_AudioPacketCount;
|
||||||
|
len = m_AudioBuffer.Put(Data, Length);
|
||||||
|
if (len != Length) {
|
||||||
|
m_AudioBuffer.ReportOverflow(Length - len);
|
||||||
|
m_AudioBuffer.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (pid == m_AC3Pid) {
|
||||||
|
++m_AC3PacketCount;
|
||||||
|
len = m_AC3Buffer.Put(Data, Length);
|
||||||
|
if (len != Length) {
|
||||||
|
m_AC3Buffer.ReportOverflow(Length - len);
|
||||||
|
m_AC3Buffer.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,25 +132,37 @@ void cFemonReceiver::Action(void)
|
|||||||
m_Active = true;
|
m_Active = true;
|
||||||
|
|
||||||
while (Running() && m_Active) {
|
while (Running() && m_Active) {
|
||||||
cFrame *frame;
|
uint8_t *Data;
|
||||||
double timeout;
|
double timeout;
|
||||||
const uint8_t *data;
|
int len, Length;
|
||||||
int len;
|
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
|
|
||||||
// process available video data
|
// process available video data
|
||||||
while ((frame = m_VideoBuffer.Get()) && m_Active) {
|
while (Data = m_VideoBuffer.Get(Length)) {
|
||||||
|
if (!m_Active || (Length < TS_SIZE))
|
||||||
|
break;
|
||||||
|
Length = TS_SIZE;
|
||||||
|
if (*Data != TS_SYNC_BYTE) {
|
||||||
|
for (int i = 1; i < Length; ++i) {
|
||||||
|
if (Data[i] == TS_SYNC_BYTE) {
|
||||||
|
Length = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_VideoBuffer.Del(Length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
if (TsPayloadStart(frame->Data())) {
|
if (TsPayloadStart(Data)) {
|
||||||
while ((data = m_VideoAssembler.GetPes(len)) && m_Active) {
|
while (const uint8_t *p = m_VideoAssembler.GetPes(len)) {
|
||||||
if (m_VideoType == 0x1B) { // MPEG4
|
if (m_VideoType == 0x1B) { // MPEG4
|
||||||
if (m_DetectH264.processVideo(data, len)) {
|
if (m_DetectH264.processVideo(p, len)) {
|
||||||
m_VideoValid = true;
|
m_VideoValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_DetectMPEG.processVideo(data, len)) {
|
if (m_DetectMPEG.processVideo(p, len)) {
|
||||||
m_VideoValid = true;
|
m_VideoValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -139,32 +170,58 @@ void cFemonReceiver::Action(void)
|
|||||||
}
|
}
|
||||||
m_VideoAssembler.Reset();
|
m_VideoAssembler.Reset();
|
||||||
}
|
}
|
||||||
m_VideoAssembler.PutTs(frame->Data(), frame->Count());
|
m_VideoAssembler.PutTs(Data, Length);
|
||||||
m_VideoBuffer.Drop(frame);
|
m_VideoBuffer.Del(Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process available audio data
|
// process available audio data
|
||||||
while ((frame = m_AudioBuffer.Get()) && m_Active) {
|
while (Data = m_AudioBuffer.Get(Length)) {
|
||||||
|
if (!m_Active || (Length < TS_SIZE))
|
||||||
|
break;
|
||||||
|
Length = TS_SIZE;
|
||||||
|
if (*Data != TS_SYNC_BYTE) {
|
||||||
|
for (int i = 1; i < Length; ++i) {
|
||||||
|
if (Data[i] == TS_SYNC_BYTE) {
|
||||||
|
Length = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_AudioBuffer.Del(Length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
if (const uint8_t *p = m_AudioAssembler.GetPes(len)) {
|
if (const uint8_t *p = m_AudioAssembler.GetPes(len)) {
|
||||||
if (m_DetectAAC.processAudio(p, len) || m_DetectMPEG.processAudio(p, len))
|
if (m_DetectAAC.processAudio(p, len) || m_DetectMPEG.processAudio(p, len))
|
||||||
m_AudioValid = true;
|
m_AudioValid = true;
|
||||||
m_AudioAssembler.Reset();
|
m_AudioAssembler.Reset();
|
||||||
}
|
}
|
||||||
m_AudioAssembler.PutTs(frame->Data(), frame->Count());
|
m_AudioAssembler.PutTs(Data, Length);
|
||||||
m_AudioBuffer.Drop(frame);
|
m_AudioBuffer.Del(Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process available dolby data
|
// process available dolby data
|
||||||
while ((frame = m_AC3Buffer.Get()) && m_Active) {
|
while (Data = m_AC3Buffer.Get(Length)) {
|
||||||
|
if (!m_Active || (Length < TS_SIZE))
|
||||||
|
break;
|
||||||
|
Length = TS_SIZE;
|
||||||
|
if (*Data != TS_SYNC_BYTE) {
|
||||||
|
for (int i = 1; i < Length; ++i) {
|
||||||
|
if (Data[i] == TS_SYNC_BYTE) {
|
||||||
|
Length = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_AC3Buffer.Del(Length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
if (const uint8_t *p = m_AC3Assembler.GetPes(len)) {
|
if (const uint8_t *p = m_AC3Assembler.GetPes(len)) {
|
||||||
if (m_DetectAC3.processAudio(p, len))
|
if (m_DetectAC3.processAudio(p, len))
|
||||||
m_AC3Valid = true;
|
m_AC3Valid = true;
|
||||||
m_AC3Assembler.Reset();
|
m_AC3Assembler.Reset();
|
||||||
}
|
}
|
||||||
m_AC3Assembler.PutTs(frame->Data(), frame->Count());
|
m_AC3Assembler.PutTs(Data, Length);
|
||||||
m_AudioBuffer.Drop(frame);
|
m_AudioBuffer.Del(Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate bitrates
|
// calculate bitrates
|
||||||
|
@ -30,7 +30,7 @@ private:
|
|||||||
cFemonAAC m_DetectAAC;
|
cFemonAAC m_DetectAAC;
|
||||||
cFemonAC3 m_DetectAC3;
|
cFemonAC3 m_DetectAC3;
|
||||||
|
|
||||||
cRingBufferFrame m_VideoBuffer;
|
cRingBufferLinear m_VideoBuffer;
|
||||||
cTsToPes m_VideoAssembler;
|
cTsToPes m_VideoAssembler;
|
||||||
int m_VideoType;
|
int m_VideoType;
|
||||||
int m_VideoPid;
|
int m_VideoPid;
|
||||||
@ -39,7 +39,7 @@ private:
|
|||||||
bool m_VideoValid;
|
bool m_VideoValid;
|
||||||
video_info_t m_VideoInfo;
|
video_info_t m_VideoInfo;
|
||||||
|
|
||||||
cRingBufferFrame m_AudioBuffer;
|
cRingBufferLinear m_AudioBuffer;
|
||||||
cTsToPes m_AudioAssembler;
|
cTsToPes m_AudioAssembler;
|
||||||
int m_AudioPid;
|
int m_AudioPid;
|
||||||
int m_AudioPacketCount;
|
int m_AudioPacketCount;
|
||||||
@ -47,7 +47,7 @@ private:
|
|||||||
bool m_AudioValid;
|
bool m_AudioValid;
|
||||||
audio_info_t m_AudioInfo;
|
audio_info_t m_AudioInfo;
|
||||||
|
|
||||||
cRingBufferFrame m_AC3Buffer;
|
cRingBufferLinear m_AC3Buffer;
|
||||||
cTsToPes m_AC3Assembler;
|
cTsToPes m_AC3Assembler;
|
||||||
int m_AC3Pid;
|
int m_AC3Pid;
|
||||||
int m_AC3PacketCount;
|
int m_AC3PacketCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user