Bug #607 ยป audiopid_fix.diff
server/livestreamer.c | ||
---|---|---|
cStreamdevBuffer siBuffer;
|
||
const cChannel *m_Channel;
|
||
int m_Apid;
|
||
cStreamdevLiveStreamer *m_Streamer;
|
||
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
|
||
int GetPid(SI::PMT::Stream& stream);
|
||
public:
|
||
cStreamdevPatFilter(cStreamdevLiveStreamer *Streamer, const cChannel *Channel);
|
||
cStreamdevPatFilter(cStreamdevLiveStreamer *Streamer, const cChannel *Channel, int Apid = 0);
|
||
uchar* Get(int &Count) { return siBuffer.Get(Count); }
|
||
void Del(int Count) { return siBuffer.Del(Count); }
|
||
};
|
||
cStreamdevPatFilter::cStreamdevPatFilter(cStreamdevLiveStreamer *Streamer, const cChannel *Channel): siBuffer(10 * TS_SIZE, TS_SIZE)
|
||
cStreamdevPatFilter::cStreamdevPatFilter(cStreamdevLiveStreamer *Streamer, const cChannel *Channel, int Apid): siBuffer(10 * TS_SIZE, TS_SIZE)
|
||
{
|
||
Dprintf("cStreamdevPatFilter(\"%s\")\n", Channel->Name());
|
||
assert(Streamer);
|
||
m_Channel = Channel;
|
||
m_Apid = Apid;
|
||
m_Streamer = Streamer;
|
||
pmtPid = 0;
|
||
pmtSid = 0;
|
||
... | ... | |
return 0;
|
||
switch (stream.getStreamType()) {
|
||
case 0x01: // ISO/IEC 11172 Video
|
||
case 0x02: // ISO/IEC 13818-2 Video
|
||
case 0x03: // ISO/IEC 11172 Audio
|
||
case 0x04: // ISO/IEC 13818-3 Audio
|
||
case 0x0f: // ISO/IEC 13818-7 Audio with ADTS transport syntax
|
||
case 0x11: // ISO/IEC 14496-3 Audio with LATM transport syntax
|
||
if (m_Apid && stream.getPid() != m_Apid)
|
||
return 0;
|
||
case 0x01: // ISO/IEC 11172 Video
|
||
case 0x02: // ISO/IEC 13818-2 Video
|
||
#if 0
|
||
case 0x07: // ISO/IEC 13512 MHEG
|
||
case 0x08: // ISO/IEC 13818-1 Annex A DSM CC
|
||
... | ... | |
case 0x0d: // ISO/IEC 13818-6 Sections (any type, including private data)
|
||
case 0x0e: // ISO/IEC 13818-1 auxiliary
|
||
#endif
|
||
case 0x0f: // ISO/IEC 13818-7 Audio with ADTS transport syntax
|
||
case 0x10: // ISO/IEC 14496-2 Visual (MPEG-4)
|
||
case 0x11: // ISO/IEC 14496-3 Audio with LATM transport syntax
|
||
case 0x1b: // ISO/IEC 14496-10 Video (MPEG-4 part 10/AVC, aka H.264)
|
||
Dprintf("cStreamdevPatFilter PMT scanner adding PID %d (%s)\n",
|
||
stream.getPid(), psStreamTypes[stream.getStreamType()]);
|
||
... | ... | |
switch (d->getDescriptorTag()) {
|
||
case SI::AC3DescriptorTag:
|
||
case SI::EnhancedAC3DescriptorTag:
|
||
delete d;
|
||
if (m_Apid && stream.getPid() != m_Apid)
|
||
return 0;
|
||
Dprintf("cStreamdevPatFilter PMT scanner: adding PID %d (%s) %s\n",
|
||
stream.getPid(), psStreamTypes[stream.getStreamType()], "AC3");
|
||
delete d;
|
||
return stream.getPid();
|
||
case SI::TeletextDescriptorTag:
|
||
Dprintf("cStreamdevPatFilter PMT scanner: adding PID %d (%s) %s\n",
|
||
... | ... | |
if (/*rawdata[0] == 5 && rawdata[1] >= 4 && */
|
||
rawdata[2] == 'A' && rawdata[3] == 'C' &&
|
||
rawdata[4] == '-' && rawdata[5] == '3') {
|
||
int len = d->getLength();
|
||
delete d;
|
||
if (m_Apid && stream.getPid() != m_Apid)
|
||
return 0;
|
||
isyslog("cStreamdevPatFilter PMT scanner:"
|
||
"Adding pid %d (type 0x%x) RegDesc len %d (%c%c%c%c)",
|
||
stream.getPid(), stream.getStreamType(),
|
||
d->getLength(), rawdata[2], rawdata[3],
|
||
rawdata[4], rawdata[5]);
|
||
delete d;
|
||
len, rawdata[2], rawdata[3], rawdata[4], rawdata[5]);
|
||
return stream.getPid();
|
||
}
|
||
}
|
||
... | ... | |
delete d;
|
||
}
|
||
if(!found) {
|
||
if (m_Apid && stream.getPid() != m_Apid)
|
||
return 0;
|
||
isyslog("Adding pid %d (type 0x%x) RegDesc not found -> assume AC-3",
|
||
stream.getPid(), stream.getStreamType());
|
||
return stream.getPid();
|
||
... | ... | |
const int *Apids = Apid ? Apid : m_Channel->Apids();
|
||
const int *Dpids = Dpid ? Dpid : m_Channel->Dpids();
|
||
int selectedPid = 0;
|
||
if (Apid && Apid[0])
|
||
selectedPid = Apid[0];
|
||
else if (Dpid && Dpid[0])
|
||
selectedPid = Dpid[0];
|
||
switch (m_StreamType) {
|
||
case stES:
|
||
{
|
||
int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid();
|
||
if (Apid && Apid[0])
|
||
pid = Apid[0];
|
||
else if (Dpid && Dpid[0])
|
||
pid = Dpid[0];
|
||
int pid = selectedPid ? selectedPid : (ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid());
|
||
m_Remux = new cTS2ESRemux(pid);
|
||
return SetPids(pid);
|
||
}
|
||
... | ... | |
if (m_Channel->Vpid() != m_Channel->Ppid())
|
||
SetPid(m_Channel->Ppid(), true);
|
||
// Set pids from PMT
|
||
m_PatFilter = new cStreamdevPatFilter(this, m_Channel);
|
||
m_PatFilter = new cStreamdevPatFilter(this, m_Channel, selectedPid);
|
||
return true;
|
||
case stTSPIDS:
|