Skip to content

Commit

Permalink
AvFormatDecoder: Add support for font attachments.
Browse files Browse the repository at this point in the history
Refs #9294
  • Loading branch information
Mark Kendall committed May 3, 2011
1 parent a0b999d commit fa52b41
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -1689,6 +1689,7 @@ int AvFormatDecoder::ScanStreams(bool novideo)
bitrate = 0;
fps = 0;

tracks[kTrackTypeAttachment].clear();
tracks[kTrackTypeAudio].clear();
tracks[kTrackTypeSubtitle].clear();
tracks[kTrackTypeTeletextCaptions].clear();
Expand Down Expand Up @@ -1912,6 +1913,16 @@ int AvFormatDecoder::ScanStreams(bool novideo)
.arg(ff_codec_type_string(enc->codec_type)));
break;
}
case CODEC_TYPE_ATTACHMENT:
{
if (enc->codec_id == CODEC_ID_TTF)
tracks[kTrackTypeAttachment].push_back(
StreamInfo(i, 0, 0, ic->streams[i]->id, 0));
bitrate += enc->bit_rate;
VERBOSE(VB_PLAYBACK, LOC + QString("Attachment codec (%1)")
.arg(ff_codec_type_string(enc->codec_type)));
break;
}
default:
{
bitrate += enc->bit_rate;
Expand Down Expand Up @@ -3378,6 +3389,19 @@ QByteArray AvFormatDecoder::GetSubHeader(uint trackNo) const
ic->streams[index]->codec->subtitle_header_size);
}

void AvFormatDecoder::GetAttachmentData(uint trackNo, QByteArray &filename,
QByteArray &data)
{
if (trackNo >= tracks[kTrackTypeAttachment].size())
return;

int index = tracks[kTrackTypeAttachment][trackNo].av_stream_index;
// TODO deprecated - use AVMetaData
filename = QByteArray(ic->streams[index]->filename);
data = QByteArray((char *)ic->streams[index]->codec->extradata,
ic->streams[index]->codec->extradata_size);
}

bool AvFormatDecoder::SetAudioByComponentTag(int tag)
{
for (uint i = 0; i < tracks[kTrackTypeAudio].size(); i++)
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/avformatdecoder.h
Expand Up @@ -169,6 +169,8 @@ class AvFormatDecoder : public DecoderBase

virtual QString GetXDS(const QString&) const;
virtual QByteArray GetSubHeader(uint trackNo) const;
virtual void GetAttachmentData(uint trackNo, QByteArray &filename,
QByteArray &data);

// MHEG stuff
virtual bool SetAudioByComponentTag(int tag);
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/decoderbase.h
Expand Up @@ -31,6 +31,7 @@ typedef enum TrackTypes
kTrackTypeTeletextCaptions,
kTrackTypeTeletextMenu,
kTrackTypeRawText,
kTrackTypeAttachment,
kTrackTypeCount,

kTrackTypeTextSubtitle,
Expand Down Expand Up @@ -195,6 +196,8 @@ class DecoderBase

virtual QString GetXDS(const QString&) const { return QString::null; }
virtual QByteArray GetSubHeader(uint trackNo) const { return QByteArray(); }
virtual void GetAttachmentData(uint trackNo, QByteArray &filename,
QByteArray &data) {}

// MHEG/MHI stuff
virtual bool SetAudioByComponentTag(int) { return false; }
Expand Down

0 comments on commit fa52b41

Please sign in to comment.