Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Factor some DVD specific audio code into AVFormatDecoderDVD
  • Loading branch information
stuartm committed Dec 11, 2012
1 parent b082334 commit 33e8abb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
28 changes: 28 additions & 0 deletions mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
Expand Up @@ -166,3 +166,31 @@ long long AvFormatDecoderDVD::DVDFindPosition(long long desiredFrame)
}
return current_speed;
}

AudioTrackType AvFormatDecoderDVD::GetAudioTrackType(uint stream_index)
{
int type = 0;

if (ringBuffer && ringBuffer->DVD())
type = ringBuffer->DVD()->GetAudioTrackType(stream_index);

if (type > 0 && type < 5) // These are the only types defined in unofficial documentation
{
AudioTrackType ret = kAudioTypeNormal;
switch (type)
{
case 1:
ret = kAudioTypeNormal;
break;
case 2:
ret = kAudioTypeAudioDescription;
break;
case 3: case 4:
ret = kAudioTypeCommentary;
break;
}
return ret;
}
else // If the DVD metadata doesn't include the info then we might as well fall through, maybe we'll get lucky
return AvFormatDecoder::GetAudioTrackType(stream_index);
}
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
Expand Up @@ -17,6 +17,7 @@ class AvFormatDecoderDVD : public AvFormatDecoder
virtual void StreamChangeCheck(void);
virtual void PostProcessTracks(void);
virtual int GetAudioLanguage(uint audio_index, uint stream_index);
virtual AudioTrackType GetAudioTrackType(uint stream_index);

long long DVDFindPosition(long long desiredFrame);
};
Expand Down
19 changes: 3 additions & 16 deletions mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
Expand Up @@ -1571,7 +1571,7 @@ int DVDRingBuffer::GetAudioTrackNum(uint stream_id)

int DVDRingBuffer::GetAudioTrackType(uint stream_id)
{
AudioTrackType ret = kAudioTypeNormal;
int ret = -1;
audio_attr_t attributes;
int logicalStreamId = dvdnav_get_audio_logical_stream(m_dvdnav, stream_id);
if (dvdnav_get_audio_attr(m_dvdnav, logicalStreamId, &attributes) >= 1)
Expand All @@ -1580,23 +1580,10 @@ int DVDRingBuffer::GetAudioTrackType(uint stream_id)
"Extension Code - %2")
.arg(stream_id)
.arg(attributes.code_extension));
switch (attributes.code_extension)
{
case 1:
ret = kAudioTypeNormal;
break;
case 2:
ret = kAudioTypeAudioDescription;
break;
case 3: case 4:
ret = kAudioTypeCommentary;
break;
case 0: default:
break;
}
ret = attributes.code_extension;
}

return (int)ret;
return ret;
}

/** \brief get the subtitle language from the dvd
Expand Down
6 changes: 1 addition & 5 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -2343,11 +2343,7 @@ AudioTrackType AvFormatDecoder::GetAudioTrackType(uint stream_index)
AudioTrackType type = kAudioTypeNormal;
AVStream *stream = ic->streams[stream_index];

if (ringBuffer && ringBuffer->IsDVD()) // DVD
{
type = (AudioTrackType)(ringBuffer->DVD()->GetAudioTrackType(stream->id));
}
else if (ic->cur_pmt_sect) // mpeg-ts
if (ic->cur_pmt_sect) // mpeg-ts
{
const PESPacket pes = PESPacket::ViewData(ic->cur_pmt_sect);
const PSIPTable psip(pes);
Expand Down

0 comments on commit 33e8abb

Please sign in to comment.